dts-universal-report-module 1.3.6 → 1.3.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 +6297 -6330
  2. package/dist/index.js +31 -31
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var pa=Object.defineProperty;var ha=(e,r,n)=>r in e?pa(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var ji=(e,r,n)=>ha(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),fa=require("xlsx"),$=require("@mui/icons-material"),o=require("@mui/material"),Ss=require("react-dom"),ma=require("@emotion/react"),ir=require("react-dnd"),si=require("react-dnd-html5-backend");function Cs(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const ln=Cs(p),Ho=Cs(fa),mt={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},ws="urm_dev_config";function xa(){try{const e=localStorage.getItem(ws);if(!e)return mt;const r=JSON.parse(e),n={sort:{...mt.sort,...r.sort},filter:{...mt.filter,...r.filter},columns:{...mt.columns,...r.columns},grouping:{...mt.grouping,...r.grouping},export:{...mt.export,...r.export},views:{...mt.views,...r.views},dates:{...mt.dates,...r.dates},display:{...mt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return mt}}function ga(e){try{localStorage.setItem(ws,JSON.stringify(e))}catch{}}function ya(e,r,n){if(!n||!r)return e;const i={sort:{...e.sort,...r.sort},filter:{...e.filter,...r.filter},columns:{...e.columns,...r.columns},grouping:{...e.grouping,...r.grouping},export:{...e.export,...r.export},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const js=p.createContext(mt);function gr(){return p.useContext(js)}const ba=/^\d{4}-\d{2}-\d{2}$/,va=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Sa=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ca=9783072e5,wa=41024448e5,ja=978307200,ka=4102444800;function za(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ca&&e<=wa?"timestamp_ms":Number.isInteger(e)&&e>=ja&&e<=ka?"timestamp_s":"unknown":typeof e!="string"?"unknown":va.test(e)||ba.test(e)?"iso":Sa.test(e.trim())?"locale_string":"unknown"}function Ta(e,r){const n=r.map(c=>c[e]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=za(c);i[l]++}const s=n.length,a=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=a)return c;return"unknown"}function Ba(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const ki=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ia=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ge(e){return String(e).padStart(2,"0")}function Ea(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/7),x=Math.floor(l/30),m=Math.floor(l/365);let h;return s<60?h="just now":a<60?h=`${a} minute${a!==1?"s":""}`:c<24?h=`${c} hour${c!==1?"s":""}`:l<7?h=`${l} day${l!==1?"s":""}`:u<5?h=`${u} week${u!==1?"s":""}`:x<12?h=`${x} month${x!==1?"s":""}`:h=`${m} year${m!==1?"s":""}`,s<60?h:i?`${h} ago`:`in ${h}`}function Da(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),c=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Ge(i+1)}-${Ge(s)}`;case"DD/MM/YYYY":return`${Ge(s)}/${Ge(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ge(i+1)}/${Ge(s)}/${n}`;case"MMM DD, YYYY":return`${ki[i]} ${Ge(s)}, ${n}`;case"DD MMM YYYY":return`${Ge(s)} ${ki[i]} ${n}`;case"MMMM D, YYYY":return`${Ia[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ge(i+1)}-${Ge(s)} ${Ge(a)}:${Ge(c)}`;case"DD/MM/YYYY HH:mm":return`${Ge(s)}/${Ge(i+1)}/${n} ${Ge(a)}:${Ge(c)}`;case"MM/DD/YYYY HH:mm":return`${Ge(i+1)}/${Ge(s)}/${n} ${Ge(a)}:${Ge(c)}`;case"relative":return Ea(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function _a(e,r,n){if(!n||r==="unknown")return String(e);const i=Ba(e,r);return!i||isNaN(i.getTime())?String(e):Da(i,n)}function $a(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function ks(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,c=e[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,ks(c,a,n+1)):i[a]=c}return i}function no(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ks(r))}function bo(e){if(!Array.isArray(e)||e.length===0)return[];const r=no(e),n=new Set;r.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let u=0;r.forEach(v=>{typeof v=="object"&&v!==null&&c in v&&(u++,l.add($a(v[c])))});const x=u===r.length,m=l.size>1&&!l.has("null");let h="mixed";if(l.size===1)h=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(w=>w!=="null");v.length===1&&(h=v[0])}i.push({name:c,type:h,required:x,hasConflict:m})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Ta(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function zi(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Oa(e){return e.some(r=>r.hasConflict)}function lt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Ti(e){return e==null}function Ma(e){return(r,n,i)=>{const s=Ti(r),a=Ti(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let c=0;switch(e){case"number":const l=Number(r),u=Number(n);c=l-u;break;case"boolean":c=(r?1:0)-(n?1:0);break;case"string":c=String(r).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(r).localeCompare(String(n));break}return i==="asc"?c:-c}}function Aa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const c of i){const l=r.find(m=>m.name===c.column);if(!l)continue;const x=Ma(l.type)(s[c.column],a[c.column],c.direction);if(x!==0)return x}return 0})}function Wa(e){return e===null?"asc":e==="asc"?"desc":null}function Ra(e){return e==="string"||e==="boolean"}function Pa(e){return e.filter(r=>Ra(r.type))}function Na(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,c)=>a+c,0))}}),n}function La(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ai(e,n.levels,r);return zs(i,n.collapsedGroups||[])}function ai(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(x=>{const m=x[a],h=m==null?"(empty)":String(m);c.has(h)||c.set(h,[]),c.get(h).push(x)});const l=[];return Array.from(c.keys()).sort().forEach(x=>{const m=c.get(x),h=`${a}:${x}`,v=i?`${i}|${h}`:h,w=Na(m,n),B=s<r.length-1?ai(m,r,n,v,s+1):m,S={key:v,level:s,column:a,value:x,rowCount:m.length,aggregates:w,children:B};l.push(S)}),l}function zs(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&zs(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function Bi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ai(e,n.levels,r),s=[],a=c=>{for(const l of c)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function Fa(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function Ts(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Va(e,r,n){const i=r?lt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function so(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function qe(e){return"children"in e}function $t(){return{id:so(),operator:"and",children:[]}}function Ne(e){return e?Array.isArray(e)?{id:so(),operator:"and",children:e.map(r=>({...r,id:r.id??so()}))}:e:$t()}function kt(e){return e?qe(e)?e.children.reduce((r,n)=>r+kt(n),0):1:0}function Qo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(qe(n)){const i=Qo(n,r);if(i)return i}}}function ao(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>qe(i)?ao(i,r,n):i)}}function li(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!qe(i)?{...i,...n}:qe(i)?li(i,r,n):i)}}function ci(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>qe(i)?ci(i,r,n):i)}}function di(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>qe(i)?di(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function Zn(e,r){return e?qe(e)?e.children.some(n=>Zn(n,r)):e.column===r:!1}function Bs(e,r){const n=e.children.filter(i=>qe(i)||i.column!==r).map(i=>qe(i)?Bs(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function Is(e){return e?qe(e)?e.children.flatMap(Is):[e]:[]}function Eo(e){if(!e)return null;if(!qe(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(Eo)}}function wo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function ui(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],c=new Set(i),l=new Set(s);let u=0;for(const x of n)c.has(x)?a.push(x):l.has(x)&&u<s.length?(a.push(s[u]),u++):l.has(x)||a.push(x);for(let x=u;x<s.length;x++)a.includes(s[x])||a.push(s[x]);return a}return[...e]}function Fn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:$t(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ha(e,r,n,i,s,a,c,l){const u={},x=[],m={};n.forEach(w=>{u[w.name]=!0,x.push(w.name),m[w.name]=170});const v=ui(s||x,c||null,l||x);return{filters:Ne(e),sortStack:r||[],columnVisibility:i||u,columnOrder:v,columnWidths:a||m,grouping:c||null}}function Ua(e,r){const n=w=>{if(w==null)return w;if(Array.isArray(w))return w.map(B=>n(B));if(typeof w=="object"){const B={};return Object.keys(w).sort().forEach(S=>{B[S]=n(w[S])}),B}return w},i=w=>JSON.stringify(n(w));if(i(Eo(e.filters))!==i(Eo(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const c=ui(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const x=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==x){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const w=[...c].sort().join(",");if(c.join(",")!==w)return!0}const h=e.columnWidths??{},v=r.columnWidths??{};return i(h)!==i(v)||i(e.grouping)!==i(r.grouping)}function Ga(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Ya(e,r){var S,f,b;const n=[],i=JSON.stringify(Eo(e.filters)),s=JSON.stringify(Eo(r.filters));if(i!==s){const g=kt(e.filters),T=kt(r.filters);g>T?n.push({category:"filters",label:"Filters Added",description:`${g-T} new filter${g-T>1?"s":""} added`}):g<T?n.push({category:"filters",label:"Filters Removed",description:`${T-g} filter${T-g>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(a!==c){const g=e.sortStack.length,T=r.sortStack.length;g>T?n.push({category:"sorting",label:"Sorting Added",description:`${g-T} new sort rule${g-T>1?"s":""} added`}):g<T?n.push({category:"sorting",label:"Sorting Removed",description:`${T-g} sort rule${T-g>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const g=Object.values(e.columnVisibility).filter(I=>I).length,T=Object.values(r.columnVisibility).filter(I=>I).length;g>T?n.push({category:"visibility",label:"Columns Shown",description:`${g-T} column${g-T>1?"s":""} made visible`}):g<T?n.push({category:"visibility",label:"Columns Hidden",description:`${T-g} column${T-g>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(e.columnOrder),m=JSON.stringify(r.columnOrder);x!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const h=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(h!==v){const g=Object.keys(e.columnWidths).filter(T=>e.columnWidths[T]!==r.columnWidths[T]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${g} column width${g>1?"s":""} modified`})}const w=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(w!==B){const g=(S=e.grouping)==null?void 0:S.enabled,T=(f=r.grouping)==null?void 0:f.enabled;if(g&&!T){const I=((b=e.grouping)==null?void 0:b.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${I} grouping level${I>1?"s":""} added`})}else!g&&T?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}function Ii(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Ei(e){return`[${e}]`}const Vt={warn(e,r,...n){Ii()&&console.warn(Ei(e),r,...n)},error(e,r,...n){Ii()&&console.error(Ei(e),r,...n)}},Es="urm_report_";function qa(e,r){try{const n=`${Es}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Vt.error("urm:persistence","Failed to save report state",n)}}function Ja(e){try{const r=`${Es}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Vt.error("urm:persistence","Failed to load report state",r),null}}function _o(e,r,n=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:n,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const c=s.children[0];if(Ka(c)){const l=s.children,u=_o(l,r,n+1);i.push(...u)}else{const l=s.children;for(const u of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function Ka(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function cn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function dn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function en(e,r,n,i,s,a,c){let l,u;a?(l={...a},u=c||r.map(m=>m.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(m=>{l[m.name]=!0,u.push(m.name)}));const x=Object.entries(l).filter(([m,h])=>!h).map(([m,h])=>m);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:x,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function tn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(h=>e.columnVisibility[h]);let l;if(a&&a.enabled){const h=a.collapsedGroups??[],v=_o(i,h);l=cn(v)}else l=i;const u=c.join(","),x=l.map(h=>c.map(v=>{const w=h[v];if(w==null)return"";const B=String(w);return B.includes(",")||B.includes('"')||B.includes(`
2
- `)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),m=[u,...x].join(`
3
- `);pi(m,dn(r,"csv"),"text/csv;charset=utf-8;")}function rn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(h=>e.columnVisibility[h]);let l;if(a&&a.enabled){const h=a.collapsedGroups??[],v=_o(i,h);l=cn(v)}else l=i;const u=[c,...l.map(h=>c.map(v=>h[v]??""))],x=Ho.utils.aoa_to_sheet(u),m=Ho.utils.book_new();Ho.utils.book_append_sheet(m,x,"Data"),Ho.writeFile(m,dn(r,"xlsx"))}function on(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:x}=e,m=u.filter(B=>e.columnVisibility[B]);let h;if(x&&x.enabled){const B=x.collapsedGroups??[],S=_o(i,B);h=cn(S)}else h=i;h=h.map(B=>{const S={};return m.forEach(f=>{S[f]=B[f]}),S});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Is(s).map(B=>({field:B.column,operator:B.operator,value:B.value})),sortStack:a.map(B=>({field:B.column,direction:B.direction,priority:B.priority})),grouping:x||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:h},w=JSON.stringify(v,null,2);pi(w,dn(r,"json"),"application/json;charset=utf-8;")}function pi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function hi(e,r="export",n){var S;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(f=>e.columnVisibility[f]);let l;if(a&&a.enabled){const f=a.collapsedGroups??[],b=_o(i,f);l=cn(b)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=c.map(f=>`<th>${Uo(f)}</th>`).join(""),m=l.map((f,b)=>{const g=c.map(T=>{const I=f[T],C=I==null?"":String(I);return`<td>${Uo(C)}</td>`}).join("");return`<tr class="${b%2===0?"even":"odd"}">${g}</tr>`}).join(""),h=`<!DOCTYPE html>
1
+ "use strict";var da=Object.defineProperty;var ua=(e,r,n)=>r in e?da(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Ci=(e,r,n)=>ua(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),pa=require("xlsx"),O=require("@mui/icons-material"),o=require("@mui/material"),bs=require("react-dom"),ha=require("@emotion/react"),ir=require("react-dnd"),si=require("react-dnd-html5-backend");function vs(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const an=vs(p),Vo=vs(pa),gt={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ss="urm_dev_config";function ma(){try{const e=localStorage.getItem(Ss);if(!e)return gt;const r=JSON.parse(e),n={sort:{...gt.sort,...r.sort},filter:{...gt.filter,...r.filter},columns:{...gt.columns,...r.columns},grouping:{...gt.grouping,...r.grouping},export:{...gt.export,...r.export},views:{...gt.views,...r.views},dates:{...gt.dates,...r.dates},display:{...gt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return gt}}function xa(e){try{localStorage.setItem(Ss,JSON.stringify(e))}catch{}}function fa(e,r,n){if(!n||!r)return e;const i={sort:{...e.sort,...r.sort},filter:{...e.filter,...r.filter},columns:{...e.columns,...r.columns},grouping:{...e.grouping,...r.grouping},export:{...e.export,...r.export},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const Cs=p.createContext(gt);function br(){return p.useContext(Cs)}const ga=/^\d{4}-\d{2}-\d{2}$/,ya=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,ba=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,va=9783072e5,Sa=41024448e5,Ca=978307200,wa=4102444800;function ja(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=va&&e<=Sa?"timestamp_ms":Number.isInteger(e)&&e>=Ca&&e<=wa?"timestamp_s":"unknown":typeof e!="string"?"unknown":ya.test(e)||ga.test(e)?"iso":ba.test(e.trim())?"locale_string":"unknown"}function ka(e,r){const n=r.map(c=>c[e]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=ja(c);i[l]++}const s=n.length,a=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=a)return c;return"unknown"}function za(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const wi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ta=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ye(e){return String(e).padStart(2,"0")}function Ba(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/7),g=Math.floor(l/30),f=Math.floor(l/365);let m;return s<60?m="just now":a<60?m=`${a} minute${a!==1?"s":""}`:c<24?m=`${c} hour${c!==1?"s":""}`:l<7?m=`${l} day${l!==1?"s":""}`:u<5?m=`${u} week${u!==1?"s":""}`:g<12?m=`${g} month${g!==1?"s":""}`:m=`${f} year${f!==1?"s":""}`,s<60?m:i?`${m} ago`:`in ${m}`}function Ia(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),c=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Ye(i+1)}-${Ye(s)}`;case"DD/MM/YYYY":return`${Ye(s)}/${Ye(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ye(i+1)}/${Ye(s)}/${n}`;case"MMM DD, YYYY":return`${wi[i]} ${Ye(s)}, ${n}`;case"DD MMM YYYY":return`${Ye(s)} ${wi[i]} ${n}`;case"MMMM D, YYYY":return`${Ta[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ye(i+1)}-${Ye(s)} ${Ye(a)}:${Ye(c)}`;case"DD/MM/YYYY HH:mm":return`${Ye(s)}/${Ye(i+1)}/${n} ${Ye(a)}:${Ye(c)}`;case"MM/DD/YYYY HH:mm":return`${Ye(i+1)}/${Ye(s)}/${n} ${Ye(a)}:${Ye(c)}`;case"relative":return Ba(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Ea(e,r,n){if(!n||r==="unknown")return String(e);const i=za(e,r);return!i||isNaN(i.getTime())?String(e):Ia(i,n)}function Da(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function ws(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,c=e[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,ws(c,a,n+1)):i[a]=c}return i}function oo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ws(r))}function fo(e){if(!Array.isArray(e)||e.length===0)return[];const r=oo(e),n=new Set;r.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let u=0;r.forEach(v=>{typeof v=="object"&&v!==null&&c in v&&(u++,l.add(Da(v[c])))});const g=u===r.length,f=l.size>1&&!l.has("null");let m="mixed";if(l.size===1)m=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(C=>C!=="null");v.length===1&&(m=v[0])}i.push({name:c,type:m,required:g,hasConflict:f})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=ka(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function ji(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function _a(e){return e.some(r=>r.hasConflict)}function dt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function ki(e){return e==null}function $a(e){return(r,n,i)=>{const s=ki(r),a=ki(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let c=0;switch(e){case"number":const l=Number(r),u=Number(n);c=l-u;break;case"boolean":c=(r?1:0)-(n?1:0);break;case"string":c=String(r).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(r).localeCompare(String(n));break}return i==="asc"?c:-c}}function Oa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const c of i){const l=r.find(f=>f.name===c.column);if(!l)continue;const g=$a(l.type)(s[c.column],a[c.column],c.direction);if(g!==0)return g}return 0})}function Ma(e){return e===null?"asc":e==="asc"?"desc":null}function Wa(e){return e==="string"||e==="boolean"}function Aa(e){return e.filter(r=>Wa(r.type))}function Ra(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,c)=>a+c,0))}}),n}function Pa(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ai(e,n.levels,r);return js(i,n.collapsedGroups||[])}function ai(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(g=>{const f=g[a],m=f==null?"(empty)":String(f);c.has(m)||c.set(m,[]),c.get(m).push(g)});const l=[];return Array.from(c.keys()).sort().forEach(g=>{const f=c.get(g),m=`${a}:${g}`,v=i?`${i}|${m}`:m,C=Ra(f,n),B=s<r.length-1?ai(f,r,n,v,s+1):f,b={key:v,level:s,column:a,value:g,rowCount:f.length,aggregates:C,children:B};l.push(b)}),l}function js(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&js(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function zi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ai(e,n.levels,r),s=[],a=c=>{for(const l of c)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function Na(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function ks(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function La(e,r,n){const i=r?dt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function io(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Je(e){return"children"in e}function Rt(){return{id:io(),operator:"and",children:[]}}function Fe(e){return e?Array.isArray(e)?{id:io(),operator:"and",children:e.map(r=>({...r,id:r.id??io()}))}:e:Rt()}function Tt(e){return e?Je(e)?e.children.reduce((r,n)=>r+Tt(n),0):1:0}function Xo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Je(n)){const i=Xo(n,r);if(i)return i}}}function so(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Je(i)?so(i,r,n):i)}}function li(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Je(i)?{...i,...n}:Je(i)?li(i,r,n):i)}}function ci(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Je(i)?ci(i,r,n):i)}}function di(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Je(i)?di(i,r):i).filter(i=>!Je(i)||i.children.length>0);return{...e,children:n}}function Zn(e,r){return e?Je(e)?e.children.some(n=>Zn(n,r)):e.column===r:!1}function zs(e,r){const n=e.children.filter(i=>Je(i)||i.column!==r).map(i=>Je(i)?zs(i,r):i).filter(i=>!Je(i)||i.children.length>0);return{...e,children:n}}function Ts(e){return e?Je(e)?e.children.flatMap(Ts):[e]:[]}function To(e){if(!e)return null;if(!Je(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(To)}}function vo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function ui(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],c=new Set(i),l=new Set(s);let u=0;for(const g of n)c.has(g)?a.push(g):l.has(g)&&u<s.length?(a.push(s[u]),u++):l.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Fn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:Rt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Fa(e,r,n,i,s,a,c,l){const u={},g=[],f={};n.forEach(C=>{u[C.name]=!0,g.push(C.name),f[C.name]=170});const v=ui(s||g,c||null,l||g);return{filters:Fe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:v,columnWidths:a||f,grouping:c||null}}function Va(e,r){const n=C=>{if(C==null)return C;if(Array.isArray(C))return C.map(B=>n(B));if(typeof C=="object"){const B={};return Object.keys(C).sort().forEach(b=>{B[b]=n(C[b])}),B}return C},i=C=>JSON.stringify(n(C));if(i(To(e.filters))!==i(To(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const c=ui(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const C=[...c].sort().join(",");if(c.join(",")!==C)return!0}const m=e.columnWidths??{},v=r.columnWidths??{};return i(m)!==i(v)||i(e.grouping)!==i(r.grouping)}function Ha(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Ga(e,r){var b,y,z;const n=[],i=JSON.stringify(To(e.filters)),s=JSON.stringify(To(r.filters));if(i!==s){const x=Tt(e.filters),j=Tt(r.filters);x>j?n.push({category:"filters",label:"Filters Added",description:`${x-j} new filter${x-j>1?"s":""} added`}):x<j?n.push({category:"filters",label:"Filters Removed",description:`${j-x} filter${j-x>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(a!==c){const x=e.sortStack.length,j=r.sortStack.length;x>j?n.push({category:"sorting",label:"Sorting Added",description:`${x-j} new sort rule${x-j>1?"s":""} added`}):x<j?n.push({category:"sorting",label:"Sorting Removed",description:`${j-x} sort rule${j-x>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const x=Object.values(e.columnVisibility).filter(E=>E).length,j=Object.values(r.columnVisibility).filter(E=>E).length;x>j?n.push({category:"visibility",label:"Columns Shown",description:`${x-j} column${x-j>1?"s":""} made visible`}):x<j?n.push({category:"visibility",label:"Columns Hidden",description:`${j-x} column${j-x>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),f=JSON.stringify(r.columnOrder);g!==f&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const m=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(m!==v){const x=Object.keys(e.columnWidths).filter(j=>e.columnWidths[j]!==r.columnWidths[j]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${x} column width${x>1?"s":""} modified`})}const C=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(C!==B){const x=(b=e.grouping)==null?void 0:b.enabled,j=(y=r.grouping)==null?void 0:y.enabled;if(x&&!j){const E=((z=e.grouping)==null?void 0:z.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${E} grouping level${E>1?"s":""} added`})}else!x&&j?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}function Ti(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Bi(e){return`[${e}]`}const Ut={warn(e,r,...n){Ti()&&console.warn(Bi(e),r,...n)},error(e,r,...n){Ti()&&console.error(Bi(e),r,...n)}},Bs="urm_report_";function Ua(e,r){try{const n=`${Bs}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Ut.error("urm:persistence","Failed to save report state",n)}}function Ya(e){try{const r=`${Bs}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Ut.error("urm:persistence","Failed to load report state",r),null}}function Io(e,r,n=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:n,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const c=s.children[0];if(qa(c)){const l=s.children,u=Io(l,r,n+1);i.push(...u)}else{const l=s.children;for(const u of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function qa(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function ln(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function cn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function Zo(e,r,n,i,s,a,c){let l,u;a?(l={...a},u=c||r.map(f=>f.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(f=>{l[f.name]=!0,u.push(f.name)}));const g=Object.entries(l).filter(([f,m])=>!m).map(([f,m])=>f);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function en(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],v=Io(i,m);l=ln(v)}else l=i;const u=c.join(","),g=l.map(m=>c.map(v=>{const C=m[v];if(C==null)return"";const B=String(C);return B.includes(",")||B.includes('"')||B.includes(`
2
+ `)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),f=[u,...g].join(`
3
+ `);pi(f,cn(r,"csv"),"text/csv;charset=utf-8;")}function tn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],v=Io(i,m);l=ln(v)}else l=i;const u=[c,...l.map(m=>c.map(v=>m[v]??""))],g=Vo.utils.aoa_to_sheet(u),f=Vo.utils.book_new();Vo.utils.book_append_sheet(f,g,"Data"),Vo.writeFile(f,cn(r,"xlsx"))}function rn(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:g}=e,f=u.filter(B=>e.columnVisibility[B]);let m;if(g&&g.enabled){const B=g.collapsedGroups??[],b=Io(i,B);m=ln(b)}else m=i;m=m.map(B=>{const b={};return f.forEach(y=>{b[y]=B[y]}),b});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Ts(s).map(B=>({field:B.column,operator:B.operator,value:B.value})),sortStack:a.map(B=>({field:B.column,direction:B.direction,priority:B.priority})),grouping:g||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},C=JSON.stringify(v,null,2);pi(C,cn(r,"json"),"application/json;charset=utf-8;")}function pi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function hi(e,r="export",n){var b;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(y=>e.columnVisibility[y]);let l;if(a&&a.enabled){const y=a.collapsedGroups??[],z=Io(i,y);l=ln(z)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),g=c.map(y=>`<th>${Ho(y)}</th>`).join(""),f=l.map((y,z)=>{const x=c.map(j=>{const E=y[j],S=E==null?"":String(E);return`<td>${Ho(S)}</td>`}).join("");return`<tr class="${z%2===0?"even":"odd"}">${x}</tr>`}).join(""),m=`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8" />
7
- <title>${Uo(r)}</title>
7
+ <title>${Ho(r)}</title>
8
8
  <style>
9
9
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
10
10
  body {
@@ -82,15 +82,15 @@
82
82
  </head>
83
83
  <body>
84
84
  <div class="report-header">
85
- <div class="report-title">${Uo(r)}</div>
85
+ <div class="report-title">${Ho(r)}</div>
86
86
  <div class="report-meta">
87
87
  ${l.length.toLocaleString()} row${l.length!==1?"s":""}<br/>
88
88
  Generated ${u}
89
89
  </div>
90
90
  </div>
91
91
  <table>
92
- <thead><tr>${x}</tr></thead>
93
- <tbody>${m}</tbody>
92
+ <thead><tr>${g}</tr></thead>
93
+ <tbody>${f}</tbody>
94
94
  </table>
95
95
  <div class="report-footer">Universal Report Module &mdash; PDF Export</div>
96
96
  <script>
@@ -102,26 +102,26 @@
102
102
  };
103
103
  <\/script>
104
104
  </body>
105
- </html>`;try{const f=document.createElement("iframe");f.style.position="fixed",f.style.right="0",f.style.bottom="0",f.style.width="0",f.style.height="0",f.style.border="0",document.body.appendChild(f);const b=((S=f.contentWindow)==null?void 0:S.document)||f.contentDocument;if(b){b.open(),b.write(h),b.close(),setTimeout(()=>{var g,T;try{(g=f.contentWindow)==null||g.focus(),(T=f.contentWindow)==null||T.print()}catch{}setTimeout(()=>{document.body.removeChild(f)},3e3)},300);return}}catch{}const v=new Blob([h],{type:"text/html;charset=utf-8;"}),w=URL.createObjectURL(v);window.open(w,"_blank")||pi(h,dn(r,"html"),"text/html;charset=utf-8;")}function Uo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Di=10;function Xa(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Di&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Di)),s}function Qa(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Za(e,r){return e.filter(n=>n.query!==r)}function el(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const tl={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function rl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function Ct(e,r){return tl[r].includes(e)}function wt(e){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data",promote_global_view:"promote views to global"}[e]||"perform this action"}.`}function ol(e){return e==="viewer"}const _i=1e3;function ei(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ft(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ei(n)}const nl={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function il(e){if(!e||!e.column)return"a filter";const r=Ft(e.column),n=nl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Vn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":il(e):"a filter"}function $i(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Ft(n.column)}"`).join(", ")}`}function sl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Vn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Vn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${Ft(u.column)}"`,detail:`Previously filtered "${Ft(l.column)}"`}:{summary:`Filter updated: ${Vn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?Ft(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?Ft(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${$i(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Ft(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${$i(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${Ft(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Ft(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: "${Ft(l)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return l&&u?{summary:`Switched to view "${u}"`,detail:`From "${l}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",h=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${h}`,detail:m?`${ei(x)} · View: "${m}"`:ei(x)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&u?{summary:`Theme changed from "${l}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:ll(r)}}}function al(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function To(e,r,n,i,s,a){return{id:al(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Bo(e,r){const n=[r,...e];return n.length>_i?n.slice(0,_i):n}function ll(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function cl(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function dl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Oi=100;function ul(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function pl(e){var a;const r=(a=e.views)==null?void 0:a.find(c=>c.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=ui(i,e.grouping||null,n);return{filters:Ne(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function hl(e,r,n,i){return{id:ul(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function fl(e,r){const n=e||[];if(n.length>=Oi)throw new Error(`Maximum of ${Oi} presets reached. Please delete old presets first.`);return[...n,r]}function ml(e,r){return(e||[]).filter(i=>i.id!==r)}function Mi(e,r){if(e)return e.find(n=>n.id===r)}function xl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function gl(e){const r=e.columnOrder,n=wo(r,e.grouping);return{filters:Ne(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:n,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function yl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Vt.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){Vt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Vt.error("urm:presets","Fallback copy method failed",r),!1}}function bl(e,r){return{totalRows:e.length,totalColumns:r.length}}function mr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:vl(e,r)};return process.env.NODE_ENV==="development"&&Vt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function vl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Sl(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Cl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function wl(e,r,n){n(e.id,{filters:Ne(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function jl(e,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Ds(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function _s(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function kl(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=c=>{const l=c.children.filter(u=>{if(qe(u))return!0;const x=i.has(u.column);return x||n.push(`Filter for column "${u.column}" ignored (column not found)`),x}).map(u=>qe(u)?a(u):u).filter(u=>!qe(u)||u.children.length>0);return{...c,children:l}};s.filters=a(Ne(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Ds(s.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:c}=_s(s.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function zl(e,r){return mr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Ai(e,r,n,i){const s=To(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Bo(i||[],s)}function Tl(e){return e==null}function Bl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Tl(e))return!1;if(n==="date"){const a=new Date(e).getTime(),c=new Date(s).getTime();switch(i){case"equals":return a===c;case"gt":return a>c;case"lt":return a<c;case"gte":return a>=c;case"lte":return a<=c;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ti(e,r,n){var s;if(qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ti(e,a,n)):r.children.some(a=>ti(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Bl(e[r.column],r,i)}function Il(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ti(i,r,n))}function nn(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function El(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Dl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Il(e,r,n),[e,r,n])}}function _l(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(c=>i.includes(c.name));return e.filter(c=>a.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function $l({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:_l(e,n,r,i),[e,r,n,i,s])}}function Ol({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Aa(e,n,r),[e,r,n])}}function Ml({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:La(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Al({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[n,e]),c=p.useMemo(()=>i.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Wl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=p.useMemo(()=>i?Ua(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(x=>x.isDefault),[e]),c=p.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),l=p.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),u=p.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Rl(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),c=a?s.groupLevel??0:s.__urm_group_level__??0;if(c===0&&a)return i;const l=c-1;if(l<0)return i;const u={};let x=l+1;for(let h=r-1;h>=0;h--){const v=e[h];if(v.__isGroupHeader||v.isGroupHeader){const w=v.groupLevel??0;if(w<=l&&u[w]===void 0&&(u[w]=v,x--,x<=0))break}}const m=[];for(let h=0;h<=l;h++)u[h]&&m.push({...u[h],__urm_is_continuation_header__:!0});return[...m,...i]}function Pl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const w=(s-1)*n,B=w+n;return Rl(e,w,B)},[e,r,s,n]),x=p.useCallback(w=>{const B=Math.max(1,Math.min(w,l));a(B)},[l]),m=p.useCallback(()=>{s<l&&a(w=>Math.min(w+1,l))},[l]),h=p.useCallback(()=>{s>1&&a(w=>Math.max(w-1,1))},[]),v=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:x,nextPage:m,prevPage:h,resetPage:v,hasNextPage:s<l,hasPrevPage:s>1}}function Nl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:u,columnOrder:x,columnWidths:m,views:h,activeViewId:v,pagination:w}=e,B=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:x,columnWidths:m}),[i,s,a,u,x,m]),S=Wl({views:h,activeViewId:v,currentState:B}),f=Al({schema:n,columnVisibility:u,columnOrder:x}),{filteredData:b}=Dl({data:r,filters:i,schema:n}),{sortedData:g}=Ol({data:b,sortStack:s,schema:n}),{groupedData:T,isGrouped:I}=Ml({data:g,grouping:a,schema:n}),{searchedData:C}=$l({data:T,searchQuery:c,schema:n,visibleColumns:f.visibleColumns,mode:l}),W=Pl({data:C,enabled:(w==null?void 0:w.enabled)||!1,pageSize:(w==null?void 0:w.pageSize)||100,initialPage:(w==null?void 0:w.currentPage)||1}),K=w!=null&&w.enabled?W.paginatedData:C,E=p.useMemo(()=>({totalRows:r.length,filteredRows:b.length,sortedRows:g.length,groupedRows:I?T.length:g.length,searchedRows:C.length,visibleRows:K.length,hiddenColumns:f.hiddenCount,activeFilters:kt(i),activeSorts:s.length,isGrouped:I}),[r.length,b.length,g.length,T.length,C.length,K.length,f.hiddenCount,i,s.length,I]);return{data:K,filteredData:b,sortedData:g,groupedData:T,searchedData:C,viewEngine:S,columnEngine:f,paginationEngine:W,metrics:E,isGrouped:I,isPaginated:(w==null?void 0:w.enabled)||!1}}let Ll=0;function Fl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Ll++,writable:!1,enumerable:!1,configurable:!1})}const _t="user-demo-001";function Vl(e={}){var Vo,vi,Si,Ci,wi;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:u,reportId:x,sharedReportId:m,sharedViewId:h,viewPersistence:v,permissions:w,config:B={}}=e,S=(v==null?void 0:v.mode)??"local",f=(a==null?void 0:a.mode)??"client",b=(c==null?void 0:c.mode)??"client",[g,T]=p.useState([]),I=gr(),[C,W]=p.useState(""),[K,E]=p.useState(!1),[U,G]=p.useState(!1),[M,y]=p.useState({message:"",severity:"info",open:!1}),k=(z,D="info")=>{y({message:z,severity:D,open:!0})},P=()=>y(z=>({...z,open:!1})),oe=B.notifDurationMs??2e3,d=g.find(z=>z.id===C),[J,ee]=p.useState("idle"),[Se,V]=p.useState(!1),[X,pe]=p.useState(!1),[ce,ie]=p.useState(!1),[te,se]=p.useState(!1),[R,L]=p.useState(!1),[de,he]=p.useState(void 0),[Te,Q]=p.useState(null),[ye,dt]=p.useState(null),[Ht,Ot]=p.useState(!1),[Mr,Mt]=p.useState(!1),[nt,Ut]=p.useState(null),[Je,Bt]=p.useState(!1),[br,yt]=p.useState(!1),[Gt,lo]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[ar,co]=p.useState(""),[It,vr]=p.useState(""),[Ke,At]=p.useState(new Set),[Yt,Ze]=p.useState(1),[et,Wt]=p.useState(15),[uo,Ar]=p.useState(!1),[Sr,Fe]=p.useState(!1),[ke,lr]=p.useState(!1),[Rt,Cr]=p.useState(null),[wr,qt]=p.useState(!1),[cr,tt]=p.useState(null),[dr,bt]=p.useState(null),Wr=p.useRef(null),re=p.useMemo(()=>d?rl(d.permissions,_t):"owner",[d]),jr=ol(re),Rr=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:bl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),Et=p.useCallback(()=>{d&&(Wr.current=Cl(d))},[d]),H=p.useCallback((z,D)=>{T(A=>A.map(O=>O.id===z?{...O,...D}:O))},[]),ut=p.useCallback(z=>{if(!d)return;bt(z);const D=Ai(d.id,_t,z,d.auditHistory||[]);H(d.id,{auditHistory:D}),k(z.message,"error"),z.recoverable&&Wr.current&&setTimeout(()=>{wl(d,Wr.current,H),k("Previous state restored","success")},100)},[d,H]),ae=p.useCallback((z,D,A,O)=>{if(!d)return;const Y=To(d.id,_t,z,D,A,O),q=d.auditHistory||[],le=Bo(q,Y);setTimeout(()=>{H(d.id,{auditHistory:le})},0)},[d,H]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=Fn(d.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),H(d.id,{views:[z],activeViewId:z.id,filters:z.snapshot.filters,sortStack:z.snapshot.sortStack,columnVisibility:z.snapshot.columnVisibility,columnOrder:z.snapshot.columnOrder,columnWidths:z.snapshot.columnWidths,grouping:z.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,H]),p.useEffect(()=>{if(i&&n&&!U&&g.length===0){const z=no(i),D={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:z,schema:zi(bo(z),B.hiddenColumns),permissions:w??{owner:_t,editors:[],viewers:[]}};T([D]),W(D.id),G(!0),ee("confirmed")}},[i,n,U,g.length,r,u,x]),p.useEffect(()=>{f!=="server"||!U||!C||H(C,{uploadedData:no(i||[])})},[i,f,U,C]),p.useEffect(()=>{f==="server"&&((a==null?void 0:a.page)!==void 0&&Ze(a.page),(a==null?void 0:a.pageSize)!==void 0&&Wt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,f]),p.useEffect(()=>{if(!s||U)return;let z=!1,D=null;const A=async()=>{try{ee("uploading");let O;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);O=await q.json()}else O=await s.fetch();if(z)return;if(!Array.isArray(O))throw new Error("Data source must return an array of objects");const Y=bo(O);if(U)T(q=>q.map(le=>le.id===C?{...le,uploadedData:no(O)}:le)),ee("confirmed");else{const q={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:no(O),schema:zi(bo(no(O)),B.hiddenColumns),permissions:w??{owner:_t,editors:[],viewers:[]}};T([q]),W(q.id),G(!0),ee("confirmed")}}catch(O){z||(ee("error"),d&&H(d.id,{uploadError:(O==null?void 0:O.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(D=setInterval(A,s.refreshInterval)),()=>{z=!0,D&&clearInterval(D)}},[s,u,r,x]);const Xe=(Vo=d==null?void 0:d.views)==null?void 0:Vo.find(z=>z.id===d.activeViewId),ur=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(z=>Fl(z,B.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{At(z=>{if(z.size===0)return z;const D=new Set(ur.map(O=>O==null?void 0:O.__urm_row_id__)),A=new Set(Array.from(z).filter(O=>D.has(O==null?void 0:O.__urm_row_id__)));return A.size===z.size?z:A})},[ur]);const Jt=Nl({rawData:ur,schema:(d==null?void 0:d.schema)||[],filters:Ne(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:It||"",searchMode:b,columnVisibility:(d==null?void 0:d.columnVisibility)||(Xe==null?void 0:Xe.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(Xe==null?void 0:Xe.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(Xe==null?void 0:Xe.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:f==="client",pageSize:et,currentPage:Yt}}),{data:po=[],searchedData:Kt=[],groupedData:kr=[],sortedData:Xt=[],metrics:pr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Qt=!1,paginationEngine:we}=Jt||{},vt=f==="server"?(a==null?void 0:a.totalRows)??0:pr.searchedRows,Z=((vi=Jt.viewEngine)==null?void 0:vi.activeView)||Xe,fe=((Si=Jt.viewEngine)==null?void 0:Si.isDirty)||!1;p.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const z=Z.snapshot.columnOrder,D=wo(z,Z.snapshot.grouping);H(d.id,{columnOrder:D})}},[d==null?void 0:d.activeViewId]);const Ce=p.useMemo(()=>!(d!=null&&d.schema)||!Z?null:Ha(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,Z.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,Z]),zr=p.useMemo(()=>!Z||!Ce||!fe?[]:Ya(Ce,Z.snapshot),[Z,Ce,fe]),Tr=p.useCallback((z,D,A)=>{const O={id:`report-${Date.now()}`,name:z,description:D,schemaLocked:!1,permissions:{owner:_t,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const Y=bo(A),q=Fn(Y);O.uploadedData=A,O.schema=Y,O.schemaLocked=!0,O.views=[q],O.activeViewId=q.id,O.sortStack=q.snapshot.sortStack,O.filters=q.snapshot.filters,O.columnVisibility=q.snapshot.columnVisibility,O.columnOrder=q.snapshot.columnOrder,O.columnWidths=q.snapshot.columnWidths,O.grouping=q.snapshot.grouping}T(Y=>[...Y,O]),W(O.id),E(!1),ee("confirmed")},[]),ho=p.useCallback(z=>{d&&(ee("uploading"),setTimeout(()=>{const D=bo(z);H(d.id,{uploadedData:z,schema:D,uploadError:void 0}),ee("preview")},500))},[d,H]),Pr=p.useCallback(z=>{d&&(H(d.id,{uploadError:z}),ee("idle"))},[d,H]),fo=p.useCallback(()=>{d&&(H(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),ee("idle"))},[d,H]),Zt=p.useCallback(()=>{d&&(H(d.id,{schemaLocked:!0}),ee("confirmed"))},[d,H]),Nr=p.useCallback(z=>{if(!d)return;if(!Ct("edit_sorting",re)){k(wt("edit_sorting"),"error");return}const D=d.sortStack??[],A=D.find(O=>O.column===z);if(A){const O=Wa(A.direction);if(O===null){const Y=D.filter(q=>q.column!==z).map((q,le)=>({...q,priority:le+1}));ae("sorting","sort_level_removed",A,null),H(d.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=O,q=D.map(le=>le.column===z?{...le,direction:Y}:le);ae("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:Y}),H(d.id,{sortStack:q})}}else{if(D.length>=I.sort.maxLevels){k(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"asc",priority:D.length+1};ae("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,re,H,ae]),Lr=p.useCallback(z=>{if(!d)return;const D=d.sortStack??[],A=z.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:O,invalidColumns:Y}=Ds(z,d.schema);Y.length>0&&k(`Removed invalid sort columns: ${Y.join(", ")}`),Et();try{ae("sorting",A,D,O.length>0?O:null),H(d.id,{sortStack:O.length>0?O:void 0})}catch(q){const le=mr("processing","sorting",q);ut(le)}}else ae("sorting",A,D,z.length>0?z:null),H(d.id,{sortStack:z.length>0?z:void 0})},[d,H,Et,ut,ae]),be=p.useCallback(z=>{if(!d)return;const D=d.sortStack??[],A=D.find(O=>O.column===z);if(!(A&&A.direction==="asc"))if(A){const O=D.map(Y=>Y.column===z?{...Y,direction:"asc"}:Y);ae("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:"asc"}),H(d.id,{sortStack:O})}else{if(D.length>=I.sort.maxLevels){k(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"asc",priority:D.length+1};ae("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,H,ae]),Ve=p.useCallback(z=>{if(!d)return;const D=d.sortStack??[],A=D.find(O=>O.column===z);if(!(A&&A.direction==="desc"))if(A){const O=D.map(Y=>Y.column===z?{...Y,direction:"desc"}:Y);ae("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:"desc"}),H(d.id,{sortStack:O})}else{if(D.length>=I.sort.maxLevels){k(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"desc",priority:D.length+1};ae("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,H,ae]),Br=p.useCallback((z,D)=>{var O;if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const A=(O=d.schema)==null?void 0:O.find(Y=>Y.name===D.column);if(A&&D.value!==void 0){const Y=jl(A.type,D.operator,D.value);if(!Y.isValid){k(Y.errorMessage||"Invalid filter value","error");return}}Et();try{const Y=Ne(d.filters),q={...D,id:so()},le=ao(Y,z,q);ae("filters","filter_added",null,q),H(d.id,{filters:le})}catch(Y){const q=mr("processing","filters",Y);ut(q)}},[d,re,H,Et,ut,ae]),it=p.useCallback(z=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const D=Ne(d.filters),A=ao(D,z,$t());ae("filters","filter_added",null,"a condition group"),H(d.id,{filters:A})},[d,re,H,ae]),er=p.useCallback((z,D)=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const A=Ne(d.filters),O=Qo(A,z),Y=li(A,z,D),q=Qo(Y,z);ae("filters","filter_updated",O,q),H(d.id,{filters:Y})},[d,re,H,ae]),Dt=p.useCallback((z,D)=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const A=Ne(d.filters),O=ci(A,z,D);ae("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),H(d.id,{filters:O})},[d,re,H,ae]),Ir=p.useCallback(z=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const D=Ne(d.filters),A=Qo(D,z),O=di(D,z);ae("filters","filter_removed",A,null),H(d.id,{filters:O})},[d,re,H,ae]),xe=p.useCallback(()=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const z=Ne(d.filters);ae("filters","filter_cleared",{count:kt(z)},null),H(d.id,{filters:$t()})},[d,re,H,ae]),ve=p.useCallback(z=>{if(!d)return;if(!Ct("edit_filters",re)){k(wt("edit_filters"),"error");return}const D=Ne(d.filters);ae("filters","filter_cleared",{count:kt(D)},{count:kt(z)}),H(d.id,{filters:z})},[d,re,H,ae]),He=p.useCallback(z=>{var Y;if(!d)return;const D=(Y=d.views)==null?void 0:Y.find(q=>q.id===z);if(!D)return;const A=D.snapshot.columnOrder,O=wo(A,D.snapshot.grouping);ae("views","view_switched",{previousViewId:d.activeViewId},{viewId:z,name:D.name}),H(d.id,{filters:D.snapshot.filters,sortStack:D.snapshot.sortStack.length>0?[...D.snapshot.sortStack]:void 0,columnVisibility:{...D.snapshot.columnVisibility},columnOrder:O,columnWidths:{...D.snapshot.columnWidths},grouping:D.snapshot.grouping,activeViewId:z}),At(new Set)},[d,H,ae]),Ye=p.useCallback((z,D,A)=>{var Ue;if(!(d!=null&&d.schema)||!Ce)return;const O=d.views??[],Y=O.filter(Ln=>!Ln.isDeleted).length,q=((Ue=I.views)==null?void 0:Ue.maxViews)??10;if(Y>=q){k(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const le={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:z,description:D||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:_t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ce}},je=A?O.map(Ln=>({...Ln,isDefault:!1})):O;ae("views","view_created",null,{viewId:le.id,name:z,isDefault:A}),H(d.id,{views:[...je,le],activeViewId:le.id}),k(`"${z}" view created`,"success")},[d,Ce,H,ae]),pt=p.useCallback(z=>{var le;if(!(d!=null&&d.views))return;const D=d.views.find(je=>je.id===z);if(!D)return;const A=d.views,O=A.filter(je=>!je.isDeleted).length,Y=((le=I.views)==null?void 0:le.maxViews)??10;if(O>=Y){k(`View limit reached — you can have at most ${Y} saved views. Delete an existing view to create a new one.`,"error");return}const q={...D,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${D.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:_t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...D.snapshot}};H(d.id,{views:[...A,q]}),k(`"${q.name}" created`,"success")},[d,I,H]),St=p.useCallback(()=>{var D;if(!Z||!Ce||!d)return;const z=(D=d.views)==null?void 0:D.map(A=>A.id===Z.id?{...A,snapshot:{...Ce}}:A);H(d.id,{views:z}),k(`"${Z.name}" view updated`,"success")},[Z,Ce,d,H]),Pt=p.useCallback(z=>{var O;if(!Z||!Ce||!d)return;const D=z??Ce.columnWidths,A=(O=d.views)==null?void 0:O.map(Y=>Y.id===Z.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:D},updatedAt:Date.now()}:Y);H(d.id,{views:A,columnWidths:D}),k(`Column configuration saved to "${Z.name}"`,"success")},[Z,Ce,d,H]),Fr=p.useCallback(z=>{var q,le;if(!Ce||!d||!Z)return;const D=z??Ce.columnWidths,A={...Z,snapshot:{...Z.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:D},updatedAt:Date.now()},O=(q=d.views)==null?void 0:q.map(je=>je.id===Z.id?A:{...je,snapshot:{...je.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:D},updatedAt:Date.now()});H(d.id,{views:O,columnWidths:D});const Y=(((le=d.views)==null?void 0:le.length)||0)-1;k(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[Ce,d,Z,H]),Tn=p.useCallback(()=>{ie(!0)},[]),Vr=p.useCallback(()=>{if(!Z||!d)return;const z=Z.snapshot.columnOrder,D=wo(z,Z.snapshot.grouping);H(d.id,{filters:Z.snapshot.filters,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:D,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),k("Changes reverted to last saved state","success")},[Z,d,H]),mo=p.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>({...O,isDefault:O.id===z}));H(d.id,{views:D});const A=d.views.find(O=>O.id===z);A&&k(`"${A.name}" set as default view`,"success")},[d,H]),Bn=p.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===z?{...O,isFavorite:!O.isFavorite,updatedAt:Date.now()}:O);H(d.id,{views:D});const A=d.views.find(O=>O.id===z);A&&!A.isFavorite?k(`"${A.name}" added to favorites`,"success"):A&&k(`"${A.name}" removed from favorites`,"info")},[d,H]),Ao=p.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.find(Ue=>Ue.id===z),A=d.views.filter(Ue=>!Ue.isDeleted||Ue.id===z);if((D==null?void 0:D.isDefault)&&A.filter(Ue=>Ue.isDefault).length===1){k("Cannot delete the last default view","error");return}const Y=d.views.map(Ue=>Ue.id===z?{...Ue,isDeleted:!0,updatedAt:Date.now()}:Ue),q=d.activeViewId===z,le=Y.find(Ue=>Ue.isDefault&&!Ue.isDeleted);H(d.id,{views:Y,activeViewId:q&&le?le.id:d.activeViewId,filters:q&&le?le.snapshot.filters:d.filters,sortStack:q&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack});const je=d.views.find(Ue=>Ue.id===z);je&&k(`"${je.name}" moved to Recently Deleted`,"info")},[d,H]),Hr=p.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===z?{...O,isDeleted:!1,updatedAt:Date.now()}:O);H(d.id,{views:D});const A=d.views.find(O=>O.id===z);A&&k(`"${A.name}" restored`,"success")},[d,H]),Wo=p.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.find(je=>je.id===z),A=d.views.filter(je=>!je.isDeleted||je.id===z);if((D==null?void 0:D.isDefault)&&A.filter(je=>je.isDefault).length===1){k("Cannot delete the last default view","error");return}const Y=d.views.filter(je=>je.id!==z),q=d.activeViewId===z,le=Y.find(je=>je.isDefault&&!je.isDeleted);H(d.id,{views:Y,activeViewId:q&&le?le.id:d.activeViewId,filters:q&&le?le.snapshot.filters:d.filters,sortStack:q&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack}),D&&k(`"${D.name}" permanently deleted`,"success")},[d,H]),Ur=p.useCallback(z=>{Q(z),se(!0)},[]),xo=p.useCallback(async z=>{if(!d)return;const D=new URLSearchParams(window.location.search);D.set("reportId",d.id),D.set("view",z);const A=`${window.location.origin}${window.location.pathname}?${D.toString()}`,O=await yl(A);k(O?"Link copied to clipboard":"Failed to copy link",O?"success":"error")},[d]),Ro=p.useCallback((z,D)=>{if(!Te||!(d!=null&&d.views))return;const A=d.views.map(O=>O.id===Te?{...O,name:z,description:D||void 0}:O);H(d.id,{views:A}),Q(null)},[Te,d,H]),Gr=p.useCallback(z=>{dt(z),L(!0)},[]),Yr=p.useCallback(()=>{if(!ye||!(d!=null&&d.views))return;const z=d.views.find(Y=>Y.id===ye),D=d.views.filter(Y=>Y.id!==ye),A=d.activeViewId===ye,O=D.find(Y=>Y.isDefault);ae("views","view_deleted",{viewId:ye,name:z==null?void 0:z.name},null),H(d.id,{views:D,activeViewId:A&&O?O.id:d.activeViewId,filters:A&&O?O.snapshot.filters:d.filters,sortStack:A&&O?O.snapshot.sortStack.length>0?O.snapshot.sortStack:void 0:d.sortStack}),dt(null),L(!1)},[ye,d,H,ae]),qr=p.useCallback(z=>{var Y;if(!(d!=null&&d.views))return;if(!(((Y=I.views)==null?void 0:Y.isAdmin)??!1)){k("Only administrators can promote views to Global.","error");return}const A=d.views.find(q=>q.id===z);if(!A)return;if(A.scope==="global"){k(`"${A.name}" is already a Global View.`,"info");return}const O=d.views.map(q=>q.id===z?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);H(d.id,{views:O}),k(`"${A.name}" promoted to Global View and set as default.`,"success")},[d,I,H]),hr=p.useCallback((z,D)=>{if(!(d!=null&&d.views))return;const A=d.views.find(q=>q.id===z);if(!A)return;const O=d.views.map(q=>q.id===z?{...q,isDefaultForAllUsers:D,updatedAt:Date.now()}:D&&q.isDefaultForAllUsers?{...q,isDefaultForAllUsers:!1}:q);ae("views",D?"view_set_default":"view_updated",{viewId:z,isDefaultForAllUsers:!D},{viewId:z,isDefaultForAllUsers:D}),H(d.id,{views:O}),k(`"${A.name}" ${D?"set as":"removed from"} default for all users.`,"success")},[d,H,ae]),go=p.useRef(!0);p.useEffect(()=>{var z;if(go.current){go.current=!1;return}if(f==="server"){Ze(1),(z=a==null?void 0:a.onPaginationChange)==null||z.call(a,1,et);return}we!=null&&we.resetPage?we.resetPage():Ze(1)},[d==null?void 0:d.filters,It,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const Jr=p.useCallback(z=>{var D;if(f==="server"){Ze(z),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,z,et);return}we!=null&&we.goToPage&&we.goToPage(z),Ze(z)},[f,a,et,we]),In=p.useCallback(z=>{var O;const D=(Yt-1)*et,A=Math.floor(D/z)+1;if(f==="server"){Wt(z),Ze(A),(O=a==null?void 0:a.onPaginationChange)==null||O.call(a,A,z);return}Wt(z),Ze(A),we==null||we.goToPage(A)},[Yt,et,f,a,we]),En=p.useCallback((z,D)=>{if(!d)return;if(!Ct("edit_columns",re)){k(wt("edit_columns"),"error");return}const O={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[z]:D};ae("columns",D?"column_shown":"column_hidden",{columnName:z,visible:!D},{columnName:z,visible:D}),H(d.id,{columnVisibility:O})},[d,Z,re,H,ae]),Dn=p.useCallback(z=>{if(d){if(!Ct("edit_columns",re)){k(wt("edit_columns"),"error");return}ae("columns","column_reordered",d.columnOrder,z),H(d.id,{columnOrder:z})}},[d,re,H,ae]),_n=p.useCallback((z,D)=>{if(!d)return;if(!Ct("edit_columns",re)){k(wt("edit_columns"),"error");return}const A=d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},O={...A,[z]:D};ae("columns","column_resized",{columnName:z,width:A[z]},{columnName:z,width:D}),H(d.id,{columnWidths:O})},[d,Z,re,H,ae]),$n=p.useCallback(z=>{if(!d)return;const D=Ne(d.filters),A=Bs(D,z);H(d.id,{filters:A})},[d,H]),On=p.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const z={},D=[],A={};d.schema.forEach(O=>{z[O.name]=!0,D.push(O.name),A[O.name]=170}),H(d.id,{columnVisibility:z,columnOrder:D,columnWidths:A,filters:void 0,sortStack:void 0}),k("Reset to default layout - all filters and sorts cleared","success")},[Z,d,H]);p.useEffect(()=>{const z=setTimeout(()=>vr(ar),300);return()=>clearTimeout(z)},[ar]),p.useEffect(()=>{var z;b==="server"&&((z=c==null?void 0:c.onSearchChange)==null||z.call(c,It))},[It,b,c]);const Mn=p.useCallback(z=>{co(z),Ze(1)},[]),An=p.useCallback(z=>{if(!z.trim()||!d)return;const D=d.searchHistory||[],A=Xa(D,z);H(d.id,{searchHistory:A})},[d,H]),Wn=p.useCallback(z=>{if(!d)return;const D=d.searchHistory||[],A=Qa(D,z);H(d.id,{searchHistory:A})},[d,H]),Kr=p.useCallback(z=>{if(!d)return;const D=d.searchHistory||[],A=Za(D,z);H(d.id,{searchHistory:A})},[d,H]);p.useEffect(()=>{if(!B.onSelectionChange)return;const z=Array.from(Ke);B.onSelectionChange(z,z.map(D=>D==null?void 0:D.__urm_row_id__))},[Ke,B.onSelectionChange]);const tr=p.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;At(A=>{const O=new Set(A);if(D!==void 0){const Y=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===D);Y!==void 0?O.delete(Y):O.add(z)}else{const Y=JSON.stringify(z),q=Array.from(O).find(le=>JSON.stringify(le)===Y);q!==void 0?O.delete(q):O.add(z)}return O})},[]),Rn=p.useCallback((z,D)=>{At(A=>{const O=new Set(A);for(const Y of D)z?O.add(Y):O.delete(Y);return O})},[]),Pn=p.useCallback((z,D,A)=>{At(O=>{const Y=new Set(O),q=Math.min(z,D),le=Math.max(z,D);for(let je=q;je<=le;je++)A[je]!==void 0&&Y.add(A[je]);return Y})},[]),We=p.useCallback(()=>{At(new Set)},[]),st=p.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;At(A=>{const O=new Set(A);if(D!==void 0){const Y=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===D);Y!==void 0&&O.delete(Y)}else O.delete(z);return O})},[]),yo=p.useCallback(z=>{var D,A;if(d){if(!Ct("edit_columns",re)){k(wt("edit_columns"),"error");return}if(z&&d.schema){const{validGrouping:O,invalidColumns:Y}=_s(z,d.schema);Y.length>0&&k(`Removed invalid grouping columns: ${Y.join(", ")}`,"warning"),Et();try{const q=d.grouping;O===null?ae("grouping","group_cleared",q,null):q?ae("grouping","group_reordered",q,O):ae("grouping","group_level_added",null,O);const le=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],je=wo(le,O),Ue=O.levels.length>0?{...O,collapsedGroups:Bi(Xt,d.schema,O)}:O;H(d.id,{grouping:Ue,columnOrder:je}),Ze(1),we==null||we.resetPage(),f==="server"&&((D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,et)),JSON.stringify(je)!==JSON.stringify(d.columnOrder)&&ae("columns","column_reordered",d.columnOrder,je),yt(!1)}catch(q){const le=mr("processing","grouping",q);ut(le)}}else{const O=d.grouping;ae("grouping","group_cleared",O,null);const Y=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:z,columnOrder:Y}),Ze(1),we==null||we.resetPage(),f==="server"&&((A=a==null?void 0:a.onPaginationChange)==null||A.call(a,1,et)),JSON.stringify(Y)!==JSON.stringify(d.columnOrder)&&ae("columns","column_reordered",d.columnOrder,Y),yt(!1)}}},[d,Z,re,H,Et,ut,ae,Xt]),Po=p.useCallback(z=>{if(!d||!I.grouping.allowCollapse)return;const D=d.grouping;if(!D)return;const A=Fa(D,z);H(d.id,{grouping:A})},[d,I,H]),Nn=p.useCallback(()=>{!(d!=null&&d.grouping)||!I.grouping.allowCollapse||H(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,I,H]),rr=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!I.grouping.allowCollapse)return;const z=Bi(Xt,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:z}})},[d,Xt,I,H]),Xr=p.useCallback(()=>{qt(!0)},[]),ht=p.useCallback(z=>{d!=null&&d.schema&&(Ot(!0),setTimeout(()=>{try{let D;z.scope==="visible"?D=Kt:D=d.uploadedData||[];let A;z.columnScope==="all"?(A={},(d.schema??[]).forEach(je=>{A[je.name]=!0})):A=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const O=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),Y=en(D,d.schema,Ne(d.filters),d.sortStack??[],Z,A,O),q=d.name;let le;switch(z.format){case"csv":tn(Y,q,z),le="export_csv";break;case"excel":rn(Y,q,z),le="export_excel";break;case"json":on(Y,q,z),le="export_json";break;case"pdf":hi(Y,q,z),le="export_pdf";break}ae("export",le,null,{format:z.format,scope:z.scope,columnScope:z.columnScope,rowCount:D.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),k(`Export completed successfully (${z.format.toUpperCase()})`,"success")}catch(D){const A=zl(D,{onRetry:()=>ht(z)});k(`Export failed: ${A.message}. Click Export to retry.`,"error");const O=Ai(d.id,_t,A,d.auditHistory||[]);H(d.id,{auditHistory:O}),Vt.error("urm:report-engine","Export failed",D)}finally{Ot(!1)}},500))},[d,Z,Kt,H,ae]),No=p.useCallback(z=>{if(d!=null&&d.schema){if(fe&&Z&&!Z.isDefault){Ut(z.format),Mt(!0),qt(!1);return}ht(z),qt(!1)}},[d,Z,fe,ht]),Qr=p.useCallback(z=>{ht({format:z,scope:"visible",columnScope:"visible"})},[ht]),Lo=p.useCallback(()=>{nt&&Qr(nt),Mt(!1),Ut(null)},[nt,Qr]),Fo=p.useCallback(()=>{St(),nt&&Qr(nt),Mt(!1),Ut(null)},[St,nt,Qr]),j=p.useCallback(()=>{Mt(!1),Ut(null)},[]),N=p.useCallback(z=>{!(d!=null&&d.schema)||Ke.size===0||(Ot(!0),setTimeout(()=>{try{const D=Array.from(Ke),A=en(D,d.schema,Ne(d.filters),d.sortStack??[],Z),O=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(z){case"csv":tn(A,O);break;case"excel":rn(A,O);break;case"json":on(A,O);break}k(`Exported ${D.length} selected rows`,"info")}catch(D){k("Export failed. Please try again.","error"),Vt.error("urm:report-engine","Bulk export failed",D)}finally{Ot(!1)}},500))},[d,Z,Ke,kr]),ne=p.useCallback((z,D)=>{if(d)try{const A=pl(d),O=hl(z,D,_t,A),Y=fl(d.presets,O);H(d.id,{presets:Y}),ae("presets","preset_created",null,{presetId:O.id,name:O.name}),Fe(!1),k(`Preset "${z}" saved successfully`,"success")}catch(A){k(A instanceof Error?A.message:"Failed to create preset","error")}},[d,H,ae]),ze=p.useCallback(()=>{Cr(null),k("Exited preset view","info")},[]),Me=p.useCallback(()=>{lr(!0)},[]),ot=p.useCallback((z,D)=>{if(!d)return;const A=ml(d.presets,z);H(d.id,{presets:A}),ae("presets","preset_deleted",{presetId:z,name:D},null),Rt===z&&Cr(null),k(`Preset "${D}" deleted`,"success")},[d,Rt,H,ae]);p.useEffect(()=>{if(!m||g.length===0)return;const z=g.find(D=>D.id===m);z&&z.id!==C&&W(z.id)},[m,g,C]);const Qe=p.useRef(!1);p.useEffect(()=>{var D;if(!h||Qe.current||!d||d.id!==m)return;const z=(D=d.views)==null?void 0:D.find(A=>A.id===h&&!A.isDeleted);z&&He(z.id),Qe.current=!0},[h,m,d,He]),p.useEffect(()=>{if(!d)return;const z=xl();if(z&&d.presets&&d.schemaLocked&&d.schema){const D=Mi(d.presets,z);if(D){const{sanitizedConfig:A,warnings:O}=kl(D.config,d.schema);O.length>0&&O.forEach(q=>k(q,"warning"));const Y=gl(A);H(d.id,Y),Cr(z),ae("presets","preset_applied",null,{presetId:D.id,name:D.name}),k(`Loaded preset: ${D.name}`,"info")}else k("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const me=Rt?Mi(d==null?void 0:d.presets,Rt):void 0;p.useEffect(()=>{var z;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(S==="api"?(z=v==null?void 0:v.onViewsChange)==null||z.call(v,d.views,d.activeViewId):qa(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,S]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=S==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ja(d.id);if(z&&z.views.length>0){const D=z.views.find(A=>A.id===z.activeViewId);if(D)H(d.id,{views:z.views,activeViewId:z.activeViewId,filters:Ne(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const A=z.views.find(O=>O.isDefault)||Fn(d.schema);H(d.id,{views:z.views,activeViewId:A.id,filters:Ne(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,S,v]);const Nt=p.useCallback(z=>{var O;const D=Ne(d==null?void 0:d.filters),A=((O=I.filter)==null?void 0:O.maxConditions)??3;if(kt(D)>=A){k(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}he(z),V(!0)},[d,I,k]),or=p.useCallback(()=>{V(!1),he(void 0)},[]),Be=(Ci=d==null?void 0:d.views)==null?void 0:Ci.find(z=>z.id===Te),ft=(wi=d==null?void 0:d.views)==null?void 0:wi.find(z=>z.id===ye);return{reports:g,activeReport:d,activeReportId:C,setActiveReportId:W,isModalOpen:K,setIsModalOpen:E,createReport:Tr,updateReport:H,uploadState:J,handleFileUpload:ho,handleUploadError:Pr,handleRetry:fo,handleConfirm:Zt,paginatedData:po,processedData:Kt,displayData:kr,tableMetrics:pr,isGrouped:Qt,tableEngine:Jt,activeView:Z,isDirty:fe,currentTableState:Ce,viewChanges:zr,filters:d==null?void 0:d.filters,showFilterPanel:Se,setShowFilterPanel:V,filterFocusColumn:de,handleAddCondition:Br,handleAddGroup:it,handleUpdateCondition:er,handleSetGroupOperator:Dt,handleRemoveFilterNode:Ir,handleClearAllFilters:xe,handleReplaceFilters:ve,handleOpenFilterForColumn:Nt,handleCloseFilterPanel:or,handleClearFiltersForColumn:$n,sortStack:d==null?void 0:d.sortStack,showSortPanel:X,setShowSortPanel:pe,handleSort:Nr,handleUpdateSortStack:Lr,handleSortAscending:be,handleSortDescending:Ve,views:d==null?void 0:d.views,showCreateViewModal:ce,setShowCreateViewModal:ie,showEditViewModal:te,setShowEditViewModal:se,showDeleteConfirmation:R,setShowDeleteConfirmation:L,editingView:Be,deletingView:ft,editingViewId:Te,deletingViewId:ye,handleSelectView:He,handleCreateView:Ye,handleCloneView:pt,handleUpdateCurrentView:St,handleSaveColumnConfigToCurrentView:Pt,handleSaveColumnConfigToAllViews:Fr,handleSaveAsNewView:Tn,handleRevertChanges:Vr,handleToggleDefault:mo,handleToggleFavorite:Bn,handleSoftDelete:Ao,handleRestoreView:Hr,handlePermanentDelete:Wo,handleEditView:Ur,handleCopyViewLink:xo,handleSaveEditView:Ro,handleDeleteView:Gr,handleConfirmDelete:Yr,handlePromoteToGlobal:qr,handleSetDefaultForAllUsers:hr,showManageColumns:Je,setShowManageColumns:Bt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:En,handleUpdateColumnOrder:Dn,handleUpdateColumnWidth:_n,handleResetColumnLayout:On,showGroupPanel:br,setShowGroupPanel:yt,grouping:d==null?void 0:d.grouping,groupingState:Gt,handleGroup:yo,handleToggleGroupCollapse:Po,handleExpandAllGroups:Nn,handleCollapseAllGroups:rr,searchQuery:ar,debouncedSearchQuery:It,searchHistory:el((d==null?void 0:d.searchHistory)||[]),handleSearchChange:Mn,handleAddToSearchHistory:An,handleToggleSearchFavourite:Wn,handleDeleteSearchHistory:Kr,selectedRowIds:Ke,handleToggleRowSelection:tr,handleToggleAllRows:Rn,handleRangeSelection:Pn,handleClearSelection:We,handleUpdateSelectionAfterDelete:st,currentPage:Yt,pageSize:et,paginationEngine:we,paginationMode:f,paginationTotalRows:vt,handlePageChange:Jr,handlePageSizeChange:In,isExporting:Ht,showExportModal:wr,setShowExportModal:qt,showDirtyExportWarning:Mr,handleExport:Xr,handleExportWithConfig:No,handleExportSelected:N,handleExportAnyway:Lo,handleSaveAndExport:Fo,handleCancelExport:j,showAuditHistory:uo,setShowAuditHistory:Ar,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:Sr,setShowCreatePreset:Fe,showManagePresets:ke,setShowManagePresets:lr,activePreset:me,activePresetId:Rt,handleOpenManagePresets:Me,handleCreatePreset:ne,handleClearActivePreset:ze,handleDeletePresetById:ot,userRole:re,isViewerRole:jr,currentUserId:_t,permissions:d==null?void 0:d.permissions,featureLimitWarning:cr,setFeatureLimitWarning:tt,datasetMeta:Rr,reportError:dr,setReportError:bt,handleError:ut,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Oa(d.schema):!1,snack:M,handleSnackClose:P,showSnack:k,snackDurationMs:oe,config:B,scheduler:l}}const $s=p.createContext(void 0);function fi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:u,scheduler:x,mode:m="builder",autoLoad:h=!0,config:v,devConfig:w,showDevPanel:B=!1,sharedReportId:S,sharedViewId:f,viewPersistence:b,permissions:g}=e,I=Vl({mode:m,autoLoad:h,initialData:i||n,dataSource:c,pagination:l,search:u,scheduler:x,reportName:s,reportId:a,sharedReportId:S,sharedViewId:f,viewPersistence:b,permissions:g,config:v}),[C,W]=p.useState(()=>xa()),K=(()=>{const M=ya(C,w,!!w);return{...M,display:{...M.display,showDevPanel:B||M.display.showDevPanel}}})(),E=p.useCallback(G=>{W(G),ga(G)},[]),U={...I,activeDevConfig:K,handleDevConfigChange:E};return t.jsx(js.Provider,{value:K,children:t.jsx($s.Provider,{value:U,children:r})})}function un(){const e=p.useContext($s);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Hl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var m,h,v;const c=((v=(h=(m=a.components)==null?void 0:m.MuiCardHeader)==null?void 0:h.styleOverrides)==null?void 0:v.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,u=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",x=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:x,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx($.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function _r(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Ul="$$material";function Gl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Yo={exports:{}},Ie={};/** @license React v16.13.1
105
+ </html>`;try{const y=document.createElement("iframe");y.style.position="fixed",y.style.right="0",y.style.bottom="0",y.style.width="0",y.style.height="0",y.style.border="0",document.body.appendChild(y);const z=((b=y.contentWindow)==null?void 0:b.document)||y.contentDocument;if(z){z.open(),z.write(m),z.close(),setTimeout(()=>{var x,j;try{(x=y.contentWindow)==null||x.focus(),(j=y.contentWindow)==null||j.print()}catch{}setTimeout(()=>{document.body.removeChild(y)},3e3)},300);return}}catch{}const v=new Blob([m],{type:"text/html;charset=utf-8;"}),C=URL.createObjectURL(v);window.open(C,"_blank")||pi(m,cn(r,"html"),"text/html;charset=utf-8;")}function Ho(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ii=10;function Ja(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Ii&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Ii)),s}function Ka(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Xa(e,r){return e.filter(n=>n.query!==r)}function Qa(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const Za={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function el(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function jt(e,r){return Za[r].includes(e)}function kt(e){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data",promote_global_view:"promote views to global"}[e]||"perform this action"}.`}function tl(e){return e==="viewer"}const Ei=1e3;function ei(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Gt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ei(n)}const rl={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function ol(e){if(!e||!e.column)return"a filter";const r=Gt(e.column),n=rl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Vn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":ol(e):"a filter"}function Di(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Gt(n.column)}"`).join(", ")}`}function nl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Vn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Vn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${Gt(u.column)}"`,detail:`Previously filtered "${Gt(l.column)}"`}:{summary:`Filter updated: ${Vn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?Gt(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${u}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?Gt(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${Di(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Gt(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Di(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${Gt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Gt(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return l.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${Gt(l)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return l&&u?{summary:`Switched to view "${u}"`,detail:`From "${l}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",f=(i==null?void 0:i.viewName)??"",m=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${m}`,detail:f?`${ei(g)} · View: "${f}"`:ei(g)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&u?{summary:`Theme changed from "${l}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:sl(r)}}}function il(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function jo(e,r,n,i,s,a){return{id:il(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function ko(e,r){const n=[r,...e];return n.length>Ei?n.slice(0,Ei):n}function sl(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function al(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function ll(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const _i=100;function cl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function dl(e){var a;const r=(a=e.views)==null?void 0:a.find(c=>c.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=ui(i,e.grouping||null,n);return{filters:Fe(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function ul(e,r,n,i){return{id:cl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function pl(e,r){const n=e||[];if(n.length>=_i)throw new Error(`Maximum of ${_i} presets reached. Please delete old presets first.`);return[...n,r]}function hl(e,r){return(e||[]).filter(i=>i.id!==r)}function $i(e,r){if(e)return e.find(n=>n.id===r)}function ml(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function xl(e){const r=e.columnOrder,n=vo(r,e.grouping);return{filters:Fe(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:n,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function fl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Ut.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){Ut.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Ut.error("urm:presets","Fallback copy method failed",r),!1}}function gl(e,r){return{totalRows:e.length,totalColumns:r.length}}function gr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:yl(e,r)};return process.env.NODE_ENV==="development"&&Ut.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function yl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function bl(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function vl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function Sl(e,r,n){n(e.id,{filters:Fe(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Cl(e,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Is(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function Es(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function wl(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=c=>{const l=c.children.filter(u=>{if(Je(u))return!0;const g=i.has(u.column);return g||n.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Je(u)?a(u):u).filter(u=>!Je(u)||u.children.length>0);return{...c,children:l}};s.filters=a(Fe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Is(s.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:c}=Es(s.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function jl(e,r){return gr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Oi(e,r,n,i){const s=jo(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return ko(i||[],s)}function kl(e){return e==null}function zl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(kl(e))return!1;if(n==="date"){const a=new Date(e).getTime(),c=new Date(s).getTime();switch(i){case"equals":return a===c;case"gt":return a>c;case"lt":return a<c;case"gte":return a>=c;case"lte":return a<=c;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ti(e,r,n){var s;if(Je(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ti(e,a,n)):r.children.some(a=>ti(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return zl(e[r.column],r,i)}function Tl(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ti(i,r,n))}function on(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Bl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Il({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Tl(e,r,n),[e,r,n])}}function El(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(c=>i.includes(c.name));return e.filter(c=>a.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Dl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:El(e,n,r,i),[e,r,n,i,s])}}function _l({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Oa(e,n,r),[e,r,n])}}function $l({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Pa(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Ol({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[n,e]),c=p.useMemo(()=>i.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Ml({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=p.useMemo(()=>i?Va(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(g=>g.isDefault),[e]),c=p.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),l=p.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=p.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Wl(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),c=a?s.groupLevel??0:s.__urm_group_level__??0;if(c===0&&a)return i;const l=c-1;if(l<0)return i;const u={};let g=l+1;for(let m=r-1;m>=0;m--){const v=e[m];if(v.__isGroupHeader||v.isGroupHeader){const C=v.groupLevel??0;if(C<=l&&u[C]===void 0&&(u[C]=v,g--,g<=0))break}}const f=[];for(let m=0;m<=l;m++)u[m]&&f.push({...u[m],__urm_is_continuation_header__:!0});return[...f,...i]}function Al({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const C=(s-1)*n,B=C+n;return Wl(e,C,B)},[e,r,s,n]),g=p.useCallback(C=>{const B=Math.max(1,Math.min(C,l));a(B)},[l]),f=p.useCallback(()=>{s<l&&a(C=>Math.min(C+1,l))},[l]),m=p.useCallback(()=>{s>1&&a(C=>Math.max(C-1,1))},[]),v=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:g,nextPage:f,prevPage:m,resetPage:v,hasNextPage:s<l,hasPrevPage:s>1}}function Rl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:u,columnOrder:g,columnWidths:f,views:m,activeViewId:v,pagination:C}=e,B=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:f}),[i,s,a,u,g,f]),b=Ml({views:m,activeViewId:v,currentState:B}),y=Ol({schema:n,columnVisibility:u,columnOrder:g}),{filteredData:z}=Il({data:r,filters:i,schema:n}),{sortedData:x}=_l({data:z,sortStack:s,schema:n}),{groupedData:j,isGrouped:E}=$l({data:x,grouping:a,schema:n}),{searchedData:S}=Dl({data:j,searchQuery:c,schema:n,visibleColumns:y.visibleColumns,mode:l}),R=Al({data:S,enabled:(C==null?void 0:C.enabled)||!1,pageSize:(C==null?void 0:C.pageSize)||100,initialPage:(C==null?void 0:C.currentPage)||1}),q=C!=null&&C.enabled?R.paginatedData:S,T=p.useMemo(()=>({totalRows:r.length,filteredRows:z.length,sortedRows:x.length,groupedRows:E?j.length:x.length,searchedRows:S.length,visibleRows:q.length,hiddenColumns:y.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:E}),[r.length,z.length,x.length,j.length,S.length,q.length,y.hiddenCount,i,s.length,E]);return{data:q,filteredData:z,sortedData:x,groupedData:j,searchedData:S,viewEngine:b,columnEngine:y,paginationEngine:R,metrics:T,isGrouped:E,isPaginated:(C==null?void 0:C.enabled)||!1}}let Pl=0;function Nl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Pl++,writable:!1,enumerable:!1,configurable:!1})}const At="user-demo-001";function Ll(e={}){var ke,pt,Fo,vi,Si;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:u,reportId:g,sharedReportId:f,sharedViewId:m,viewPersistence:v,config:C={}}=e,B=(v==null?void 0:v.mode)??"local",b=(a==null?void 0:a.mode)??"client",y=(c==null?void 0:c.mode)??"client",[z,x]=p.useState([]),j=br(),[E,S]=p.useState(""),[R,q]=p.useState(!1),[T,F]=p.useState(!1),[X,W]=p.useState({message:"",severity:"info",open:!1}),h=(k,_="info")=>{W({message:k,severity:_,open:!0})},I=()=>W(k=>({...k,open:!1})),N=C.notifDurationMs??2e3,d=z.find(k=>k.id===E),[oe,G]=p.useState("idle"),[te,ge]=p.useState(!1),[V,K]=p.useState(!1),[ce,de]=p.useState(!1),[ne,Q]=p.useState(!1),[pe,D]=p.useState(!1),[ee,xe]=p.useState(void 0),[ae,Te]=p.useState(null),[Y,Pe]=p.useState(null),[Et,mt]=p.useState(!1),[$r,Pt]=p.useState(!1),[it,Yt]=p.useState(null),[Ke,Dt]=p.useState(!1),[Sr,vt]=p.useState(!1),[qt,ao]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[ar,lo]=p.useState(""),[_t,Cr]=p.useState(""),[Xe,Nt]=p.useState(new Set),[Jt,Ze]=p.useState(1),[et,Lt]=p.useState(15),[co,Or]=p.useState(!1),[wr,He]=p.useState(!1),[Se,lr]=p.useState(!1),[Kt,cr]=p.useState(null),[uo,Ft]=p.useState(!1),[Mr,dr]=p.useState(null),[tt,Xt]=p.useState(null),xt=p.useRef(null),Be=p.useMemo(()=>d?el(d.permissions,At):"owner",[d]),he=tl(Be),jr=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:gl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),$t=p.useCallback(()=>{d&&(xt.current=vl(d))},[d]),H=p.useCallback((k,_)=>{x(A=>A.map(M=>M.id===k?{...M,..._}:M))},[]),St=p.useCallback(k=>{if(!d)return;Xt(k);const _=Oi(d.id,At,k,d.auditHistory||[]);H(d.id,{auditHistory:_}),h(k.message,"error"),k.recoverable&&xt.current&&setTimeout(()=>{Sl(d,xt.current,H),h("Previous state restored","success")},100)},[d,H]),ie=p.useCallback((k,_,A,M)=>{if(!d)return;const U=jo(d.id,At,k,_,A,M),J=d.auditHistory||[],le=ko(J,U);setTimeout(()=>{H(d.id,{auditHistory:le})},0)},[d,H]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=Fn(d.schema);(()=>{try{const _=localStorage.getItem("urm_dev_config");return _?JSON.parse(_):null}catch{return null}})(),H(d.id,{views:[k],activeViewId:k.id,filters:k.snapshot.filters,sortStack:k.snapshot.sortStack,columnVisibility:k.snapshot.columnVisibility,columnOrder:k.snapshot.columnOrder,columnWidths:k.snapshot.columnWidths,grouping:k.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,H]),p.useEffect(()=>{if(i&&n&&!T&&z.length===0){const k=oo(i),_={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:k,schema:ji(fo(k),C.hiddenColumns),permissions:{owner:At,editors:[],viewers:[]}};x([_]),S(_.id),F(!0),G("confirmed")}},[i,n,T,z.length,r,u,g]),p.useEffect(()=>{b!=="server"||!T||!E||H(E,{uploadedData:oo(i||[])})},[i,b,T,E]),p.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&Ze(a.page),(a==null?void 0:a.pageSize)!==void 0&&Lt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,b]),p.useEffect(()=>{if(!s||T)return;let k=!1,_=null;const A=async()=>{try{G("uploading");let M;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);M=await J.json()}else M=await s.fetch();if(k)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const U=fo(M);if(T)x(J=>J.map(le=>le.id===E?{...le,uploadedData:oo(M)}:le)),G("confirmed");else{const J={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:oo(M),schema:ji(fo(oo(M)),C.hiddenColumns),permissions:{owner:At,editors:[],viewers:[]}};x([J]),S(J.id),F(!0),G("confirmed")}}catch(M){k||(G("error"),d&&H(d.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(_=setInterval(A,s.refreshInterval)),()=>{k=!0,_&&clearInterval(_)}},[s,u,r,g]);const ut=(ke=d==null?void 0:d.views)==null?void 0:ke.find(k=>k.id===d.activeViewId),Ot=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(k=>Nl(k,C.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{Nt(k=>{if(k.size===0)return k;const _=new Set(Ot.map(M=>M==null?void 0:M.__urm_row_id__)),A=new Set(Array.from(k).filter(M=>_.has(M==null?void 0:M.__urm_row_id__)));return A.size===k.size?k:A})},[Ot]);const Qt=Rl({rawData:Ot,schema:(d==null?void 0:d.schema)||[],filters:Fe(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:_t||"",searchMode:y,columnVisibility:(d==null?void 0:d.columnVisibility)||(ut==null?void 0:ut.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(ut==null?void 0:ut.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(ut==null?void 0:ut.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:b==="client",pageSize:et,currentPage:Jt}}),{data:Wr=[],searchedData:kr=[],groupedData:Zt=[],sortedData:ur=[],metrics:pr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Ar=!1,paginationEngine:ze}=Qt||{},Qe=b==="server"?(a==null?void 0:a.totalRows)??0:pr.searchedRows,Z=((pt=Qt.viewEngine)==null?void 0:pt.activeView)||ut,se=((Fo=Qt.viewEngine)==null?void 0:Fo.isDirty)||!1;p.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const k=Z.snapshot.columnOrder,_=vo(k,Z.snapshot.grouping);H(d.id,{columnOrder:_})}},[d==null?void 0:d.activeViewId]);const be=p.useMemo(()=>!(d!=null&&d.schema)||!Z?null:Fa(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,Z.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,Z]),Rr=p.useMemo(()=>!Z||!be||!se?[]:Ga(be,Z.snapshot),[Z,be,se]),hr=p.useCallback((k,_,A)=>{const M={id:`report-${Date.now()}`,name:k,description:_,schemaLocked:!1,permissions:{owner:At,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const U=fo(A),J=Fn(U);M.uploadedData=A,M.schema=U,M.schemaLocked=!0,M.views=[J],M.activeViewId=J.id,M.sortStack=J.snapshot.sortStack,M.filters=J.snapshot.filters,M.columnVisibility=J.snapshot.columnVisibility,M.columnOrder=J.snapshot.columnOrder,M.columnWidths=J.snapshot.columnWidths,M.grouping=J.snapshot.grouping}x(U=>[...U,M]),S(M.id),q(!1),G("confirmed")},[]),Pr=p.useCallback(k=>{d&&(G("uploading"),setTimeout(()=>{const _=fo(k);H(d.id,{uploadedData:k,schema:_,uploadError:void 0}),G("preview")},500))},[d,H]),po=p.useCallback(k=>{d&&(H(d.id,{uploadError:k}),G("idle"))},[d,H]),Nr=p.useCallback(()=>{d&&(H(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),G("idle"))},[d,H]),mr=p.useCallback(()=>{d&&(H(d.id,{schemaLocked:!0}),G("confirmed"))},[d,H]),Lr=p.useCallback(k=>{if(!d)return;if(!jt("edit_sorting",Be)){h(kt("edit_sorting"),"error");return}const _=d.sortStack??[],A=_.find(M=>M.column===k);if(A){const M=Ma(A.direction);if(M===null){const U=_.filter(J=>J.column!==k).map((J,le)=>({...J,priority:le+1}));ie("sorting","sort_level_removed",A,null),H(d.id,{sortStack:U.length>0?U:void 0})}else{const U=M,J=_.map(le=>le.column===k?{...le,direction:U}:le);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:U}),H(d.id,{sortStack:J})}}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,Be,H,ie]),Fr=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=k.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:M,invalidColumns:U}=Is(k,d.schema);U.length>0&&h(`Removed invalid sort columns: ${U.join(", ")}`),$t();try{ie("sorting",A,_,M.length>0?M:null),H(d.id,{sortStack:M.length>0?M:void 0})}catch(J){const le=gr("processing","sorting",J);St(le)}}else ie("sorting",A,_,k.length>0?k:null),H(d.id,{sortStack:k.length>0?k:void 0})},[d,H,$t,St,ie]),Mt=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===k);if(!(A&&A.direction==="asc"))if(A){const M=_.map(U=>U.column===k?{...U,direction:"asc"}:U);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"asc"}),H(d.id,{sortStack:M})}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,H,ie]),Ce=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===k);if(!(A&&A.direction==="desc"))if(A){const M=_.map(U=>U.column===k?{...U,direction:"desc"}:U);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"desc"}),H(d.id,{sortStack:M})}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"desc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,H,ie]),Ge=p.useCallback((k,_)=>{var M;if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=(M=d.schema)==null?void 0:M.find(U=>U.name===_.column);if(A&&_.value!==void 0){const U=Cl(A.type,_.operator,_.value);if(!U.isValid){h(U.errorMessage||"Invalid filter value","error");return}}$t();try{const U=Fe(d.filters),J={..._,id:io()},le=so(U,k,J);ie("filters","filter_added",null,J),H(d.id,{filters:le})}catch(U){const J=gr("processing","filters",U);St(J)}},[d,Be,H,$t,St,ie]),zr=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters),A=so(_,k,Rt());ie("filters","filter_added",null,"a condition group"),H(d.id,{filters:A})},[d,Be,H,ie]),st=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=Fe(d.filters),M=Xo(A,k),U=li(A,k,_),J=Xo(U,k);ie("filters","filter_updated",M,J),H(d.id,{filters:U})},[d,Be,H,ie]),er=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=Fe(d.filters),M=ci(A,k,_);ie("filters","filter_updated",null,`group operator changed to ${_.toUpperCase()}`),H(d.id,{filters:M})},[d,Be,H,ie]),Wt=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters),A=Xo(_,k),M=di(_,k);ie("filters","filter_removed",A,null),H(d.id,{filters:M})},[d,Be,H,ie]),fe=p.useCallback(()=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const k=Fe(d.filters);ie("filters","filter_cleared",{count:Tt(k)},null),H(d.id,{filters:Rt()})},[d,Be,H,ie]),je=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters);ie("filters","filter_cleared",{count:Tt(_)},{count:Tt(k)}),H(d.id,{filters:k})},[d,Be,H,ie]),We=p.useCallback(k=>{var U;if(!d)return;const _=(U=d.views)==null?void 0:U.find(J=>J.id===k);if(!_)return;const A=_.snapshot.columnOrder,M=vo(A,_.snapshot.grouping);ie("views","view_switched",{previousViewId:d.activeViewId},{viewId:k,name:_.name}),H(d.id,{filters:_.snapshot.filters,sortStack:_.snapshot.sortStack.length>0?[..._.snapshot.sortStack]:void 0,columnVisibility:{..._.snapshot.columnVisibility},columnOrder:M,columnWidths:{..._.snapshot.columnWidths},grouping:_.snapshot.grouping,activeViewId:k}),Nt(new Set)},[d,H,ie]),qe=p.useCallback((k,_,A)=>{var Ue;if(!(d!=null&&d.schema)||!be)return;const M=d.views??[],U=M.filter(Ln=>!Ln.isDeleted).length,J=((Ue=j.views)==null?void 0:Ue.maxViews)??10;if(U>=J){h(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const le={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:k,description:_||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:At,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...be}},ve=A?M.map(Ln=>({...Ln,isDefault:!1})):M;ie("views","view_created",null,{viewId:le.id,name:k,isDefault:A}),H(d.id,{views:[...ve,le],activeViewId:le.id}),h(`"${k}" view created`,"success")},[d,be,H,ie]),at=p.useCallback(k=>{var le;if(!(d!=null&&d.views))return;const _=d.views.find(ve=>ve.id===k);if(!_)return;const A=d.views,M=A.filter(ve=>!ve.isDeleted).length,U=((le=j.views)==null?void 0:le.maxViews)??10;if(M>=U){h(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const J={..._,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${_.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:At,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{..._.snapshot}};H(d.id,{views:[...A,J]}),h(`"${J.name}" created`,"success")},[d,j,H]),Ct=p.useCallback(()=>{var _;if(!Z||!be||!d)return;const k=(_=d.views)==null?void 0:_.map(A=>A.id===Z.id?{...A,snapshot:{...be}}:A);H(d.id,{views:k}),h(`"${Z.name}" view updated`,"success")},[Z,be,d,H]),tr=p.useCallback(k=>{var M;if(!Z||!be||!d)return;const _=k??be.columnWidths,A=(M=d.views)==null?void 0:M.map(U=>U.id===Z.id?{...U,snapshot:{...U.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()}:U);H(d.id,{views:A,columnWidths:_}),h(`Column configuration saved to "${Z.name}"`,"success")},[Z,be,d,H]),$o=p.useCallback(k=>{var J,le;if(!be||!d||!Z)return;const _=k??be.columnWidths,A={...Z,snapshot:{...Z.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()},M=(J=d.views)==null?void 0:J.map(ve=>ve.id===Z.id?A:{...ve,snapshot:{...ve.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()});H(d.id,{views:M,columnWidths:_});const U=(((le=d.views)==null?void 0:le.length)||0)-1;h(`Column configuration saved to current view and ${U} other view${U===1?"":"s"}`,"success")},[be,d,Z,H]),Vr=p.useCallback(()=>{de(!0)},[]),zn=p.useCallback(()=>{if(!Z||!d)return;const k=Z.snapshot.columnOrder,_=vo(k,Z.snapshot.grouping);H(d.id,{filters:Z.snapshot.filters,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:_,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),h("Changes reverted to last saved state","success")},[Z,d,H]),Hr=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>({...M,isDefault:M.id===k}));H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&h(`"${A.name}" set as default view`,"success")},[d,H]),ho=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===k?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&!A.isFavorite?h(`"${A.name}" added to favorites`,"success"):A&&h(`"${A.name}" removed from favorites`,"info")},[d,H]),Tn=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.find(Ue=>Ue.id===k),A=d.views.filter(Ue=>!Ue.isDeleted||Ue.id===k);if((_==null?void 0:_.isDefault)&&A.filter(Ue=>Ue.isDefault).length===1){h("Cannot delete the last default view","error");return}const U=d.views.map(Ue=>Ue.id===k?{...Ue,isDeleted:!0,updatedAt:Date.now()}:Ue),J=d.activeViewId===k,le=U.find(Ue=>Ue.isDefault&&!Ue.isDeleted);H(d.id,{views:U,activeViewId:J&&le?le.id:d.activeViewId,filters:J&&le?le.snapshot.filters:d.filters,sortStack:J&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack});const ve=d.views.find(Ue=>Ue.id===k);ve&&h(`"${ve.name}" moved to Recently Deleted`,"info")},[d,H]),Oo=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===k?{...M,isDeleted:!1,updatedAt:Date.now()}:M);H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&h(`"${A.name}" restored`,"success")},[d,H]),Gr=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.find(ve=>ve.id===k),A=d.views.filter(ve=>!ve.isDeleted||ve.id===k);if((_==null?void 0:_.isDefault)&&A.filter(ve=>ve.isDefault).length===1){h("Cannot delete the last default view","error");return}const U=d.views.filter(ve=>ve.id!==k),J=d.activeViewId===k,le=U.find(ve=>ve.isDefault&&!ve.isDeleted);H(d.id,{views:U,activeViewId:J&&le?le.id:d.activeViewId,filters:J&&le?le.snapshot.filters:d.filters,sortStack:J&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack}),_&&h(`"${_.name}" permanently deleted`,"success")},[d,H]),Mo=p.useCallback(k=>{Te(k),Q(!0)},[]),Ur=p.useCallback(async k=>{if(!d)return;const _=new URLSearchParams(window.location.search);_.set("reportId",d.id),_.set("view",k);const A=`${window.location.origin}${window.location.pathname}?${_.toString()}`,M=await fl(A);h(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[d]),mo=p.useCallback((k,_)=>{if(!ae||!(d!=null&&d.views))return;const A=d.views.map(M=>M.id===ae?{...M,name:k,description:_||void 0}:M);H(d.id,{views:A}),Te(null)},[ae,d,H]),Wo=p.useCallback(k=>{Pe(k),D(!0)},[]),Yr=p.useCallback(()=>{if(!Y||!(d!=null&&d.views))return;const k=d.views.find(U=>U.id===Y),_=d.views.filter(U=>U.id!==Y),A=d.activeViewId===Y,M=_.find(U=>U.isDefault);ie("views","view_deleted",{viewId:Y,name:k==null?void 0:k.name},null),H(d.id,{views:_,activeViewId:A&&M?M.id:d.activeViewId,filters:A&&M?M.snapshot.filters:d.filters,sortStack:A&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:d.sortStack}),Pe(null),D(!1)},[Y,d,H,ie]),qr=p.useCallback(k=>{var U;if(!(d!=null&&d.views))return;if(!(((U=j.views)==null?void 0:U.isAdmin)??!1)){h("Only administrators can promote views to Global.","error");return}const A=d.views.find(J=>J.id===k);if(!A)return;if(A.scope==="global"){h(`"${A.name}" is already a Global View.`,"info");return}const M=d.views.map(J=>J.id===k?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);H(d.id,{views:M}),h(`"${A.name}" promoted to Global View and set as default.`,"success")},[d,j,H]),Tr=p.useRef(!0);p.useEffect(()=>{var k;if(Tr.current){Tr.current=!1;return}if(b==="server"){Ze(1),(k=a==null?void 0:a.onPaginationChange)==null||k.call(a,1,et);return}ze!=null&&ze.resetPage?ze.resetPage():Ze(1)},[d==null?void 0:d.filters,_t,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const xr=p.useCallback(k=>{var _;if(b==="server"){Ze(k),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,k,et);return}ze!=null&&ze.goToPage&&ze.goToPage(k),Ze(k)},[b,a,et,ze]),Ao=p.useCallback(k=>{var M;const _=(Jt-1)*et,A=Math.floor(_/k)+1;if(b==="server"){Lt(k),Ze(A),(M=a==null?void 0:a.onPaginationChange)==null||M.call(a,A,k);return}Lt(k),Ze(A),ze==null||ze.goToPage(A)},[Jt,et,b,a,ze]),Jr=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}const M={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[k]:_};ie("columns",_?"column_shown":"column_hidden",{columnName:k,visible:!_},{columnName:k,visible:_}),H(d.id,{columnVisibility:M})},[d,Z,Be,H,ie]),Bn=p.useCallback(k=>{if(d){if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}ie("columns","column_reordered",d.columnOrder,k),H(d.id,{columnOrder:k})}},[d,Be,H,ie]),In=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}const A=d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},M={...A,[k]:_};ie("columns","column_resized",{columnName:k,width:A[k]},{columnName:k,width:_}),H(d.id,{columnWidths:M})},[d,Z,Be,H,ie]),En=p.useCallback(k=>{if(!d)return;const _=Fe(d.filters),A=zs(_,k);H(d.id,{filters:A})},[d,H]),Dn=p.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const k={},_=[],A={};d.schema.forEach(M=>{k[M.name]=!0,_.push(M.name),A[M.name]=170}),H(d.id,{columnVisibility:k,columnOrder:_,columnWidths:A,filters:void 0,sortStack:void 0}),h("Reset to default layout - all filters and sorts cleared","success")},[Z,d,H]);p.useEffect(()=>{const k=setTimeout(()=>Cr(ar),300);return()=>clearTimeout(k)},[ar]),p.useEffect(()=>{var k;y==="server"&&((k=c==null?void 0:c.onSearchChange)==null||k.call(c,_t))},[_t,y,c]);const _n=p.useCallback(k=>{lo(k),Ze(1)},[]),$n=p.useCallback(k=>{if(!k.trim()||!d)return;const _=d.searchHistory||[],A=Ja(_,k);H(d.id,{searchHistory:A})},[d,H]),On=p.useCallback(k=>{if(!d)return;const _=d.searchHistory||[],A=Ka(_,k);H(d.id,{searchHistory:A})},[d,H]),Mn=p.useCallback(k=>{if(!d)return;const _=d.searchHistory||[],A=Xa(_,k);H(d.id,{searchHistory:A})},[d,H]);p.useEffect(()=>{if(!C.onSelectionChange)return;const k=Array.from(Xe);C.onSelectionChange(k,k.map(_=>_==null?void 0:_.__urm_row_id__))},[Xe,C.onSelectionChange]);const Wn=p.useCallback(k=>{const _=k==null?void 0:k.__urm_row_id__;Nt(A=>{const M=new Set(A);if(_!==void 0){const U=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===_);U!==void 0?M.delete(U):M.add(k)}else{const U=JSON.stringify(k),J=Array.from(M).find(le=>JSON.stringify(le)===U);J!==void 0?M.delete(J):M.add(k)}return M})},[]),Kr=p.useCallback((k,_)=>{Nt(A=>{const M=new Set(A);for(const U of _)k?M.add(U):M.delete(U);return M})},[]),rr=p.useCallback((k,_,A)=>{Nt(M=>{const U=new Set(M),J=Math.min(k,_),le=Math.max(k,_);for(let ve=J;ve<=le;ve++)A[ve]!==void 0&&U.add(A[ve]);return U})},[]),An=p.useCallback(()=>{Nt(new Set)},[]),Rn=p.useCallback(k=>{const _=k==null?void 0:k.__urm_row_id__;Nt(A=>{const M=new Set(A);if(_!==void 0){const U=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===_);U!==void 0&&M.delete(U)}else M.delete(k);return M})},[]),Re=p.useCallback(k=>{var _,A;if(d){if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}if(k&&d.schema){const{validGrouping:M,invalidColumns:U}=Es(k,d.schema);U.length>0&&h(`Removed invalid grouping columns: ${U.join(", ")}`,"warning"),$t();try{const J=d.grouping;M===null?ie("grouping","group_cleared",J,null):J?ie("grouping","group_reordered",J,M):ie("grouping","group_level_added",null,M);const le=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],ve=vo(le,M),Ue=M.levels.length>0?{...M,collapsedGroups:zi(ur,d.schema,M)}:M;H(d.id,{grouping:Ue,columnOrder:ve}),Ze(1),ze==null||ze.resetPage(),b==="server"&&((_=a==null?void 0:a.onPaginationChange)==null||_.call(a,1,et)),JSON.stringify(ve)!==JSON.stringify(d.columnOrder)&&ie("columns","column_reordered",d.columnOrder,ve),vt(!1)}catch(J){const le=gr("processing","grouping",J);St(le)}}else{const M=d.grouping;ie("grouping","group_cleared",M,null);const U=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:k,columnOrder:U}),Ze(1),ze==null||ze.resetPage(),b==="server"&&((A=a==null?void 0:a.onPaginationChange)==null||A.call(a,1,et)),JSON.stringify(U)!==JSON.stringify(d.columnOrder)&&ie("columns","column_reordered",d.columnOrder,U),vt(!1)}}},[d,Z,Be,H,$t,St,ie,ur]),lt=p.useCallback(k=>{if(!d||!j.grouping.allowCollapse)return;const _=d.grouping;if(!_)return;const A=Na(_,k);H(d.id,{grouping:A})},[d,j,H]),xo=p.useCallback(()=>{!(d!=null&&d.grouping)||!j.grouping.allowCollapse||H(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,j,H]),Ro=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!j.grouping.allowCollapse)return;const k=zi(ur,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:k}})},[d,ur,j,H]),Pn=p.useCallback(()=>{Ft(!0)},[]),ft=p.useCallback(k=>{d!=null&&d.schema&&(mt(!0),setTimeout(()=>{try{let _;k.scope==="visible"?_=kr:_=d.uploadedData||[];let A;k.columnScope==="all"?(A={},(d.schema??[]).forEach(ve=>{A[ve.name]=!0})):A=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const M=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),U=Zo(_,d.schema,Fe(d.filters),d.sortStack??[],Z,A,M),J=d.name;let le;switch(k.format){case"csv":en(U,J,k),le="export_csv";break;case"excel":tn(U,J,k),le="export_excel";break;case"json":rn(U,J,k),le="export_json";break;case"pdf":hi(U,J,k),le="export_pdf";break}ie("export",le,null,{format:k.format,scope:k.scope,columnScope:k.columnScope,rowCount:_.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),h(`Export completed successfully (${k.format.toUpperCase()})`,"success")}catch(_){const A=jl(_,{onRetry:()=>ft(k)});h(`Export failed: ${A.message}. Click Export to retry.`,"error");const M=Oi(d.id,At,A,d.auditHistory||[]);H(d.id,{auditHistory:M}),Ut.error("urm:report-engine","Export failed",_)}finally{mt(!1)}},500))},[d,Z,kr,H,ie]),Xr=p.useCallback(k=>{if(d!=null&&d.schema){if(se&&Z&&!Z.isDefault){Yt(k.format),Pt(!0),Ft(!1);return}ft(k),Ft(!1)}},[d,Z,se,ft]),wt=p.useCallback(k=>{ft({format:k,scope:"visible",columnScope:"visible"})},[ft]),Po=p.useCallback(()=>{it&&wt(it),Pt(!1),Yt(null)},[it,wt]),Nn=p.useCallback(()=>{Ct(),it&&wt(it),Pt(!1),Yt(null)},[Ct,it,wt]),No=p.useCallback(()=>{Pt(!1),Yt(null)},[]),Lo=p.useCallback(k=>{!(d!=null&&d.schema)||Xe.size===0||(mt(!0),setTimeout(()=>{try{const _=Array.from(Xe),A=Zo(_,d.schema,Fe(d.filters),d.sortStack??[],Z),M=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(k){case"csv":en(A,M);break;case"excel":tn(A,M);break;case"json":rn(A,M);break}h(`Exported ${_.length} selected rows`,"info")}catch(_){h("Export failed. Please try again.","error"),Ut.error("urm:report-engine","Bulk export failed",_)}finally{mt(!1)}},500))},[d,Z,Xe,Zt]),w=p.useCallback((k,_)=>{if(d)try{const A=dl(d),M=ul(k,_,At,A),U=pl(d.presets,M);H(d.id,{presets:U}),ie("presets","preset_created",null,{presetId:M.id,name:M.name}),He(!1),h(`Preset "${k}" saved successfully`,"success")}catch(A){h(A instanceof Error?A.message:"Failed to create preset","error")}},[d,H,ie]),P=p.useCallback(()=>{cr(null),h("Exited preset view","info")},[]),re=p.useCallback(()=>{lr(!0)},[]),we=p.useCallback((k,_)=>{if(!d)return;const A=hl(d.presets,k);H(d.id,{presets:A}),ie("presets","preset_deleted",{presetId:k,name:_},null),Kt===k&&cr(null),h(`Preset "${_}" deleted`,"success")},[d,Kt,H,ie]);p.useEffect(()=>{if(!f||z.length===0)return;const k=z.find(_=>_.id===f);k&&k.id!==E&&S(k.id)},[f,z,E]);const Me=p.useRef(!1);p.useEffect(()=>{var _;if(!m||Me.current||!d||d.id!==f)return;const k=(_=d.views)==null?void 0:_.find(A=>A.id===m&&!A.isDeleted);k&&We(k.id),Me.current=!0},[m,f,d,We]),p.useEffect(()=>{if(!d)return;const k=ml();if(k&&d.presets&&d.schemaLocked&&d.schema){const _=$i(d.presets,k);if(_){const{sanitizedConfig:A,warnings:M}=wl(_.config,d.schema);M.length>0&&M.forEach(J=>h(J,"warning"));const U=xl(A);H(d.id,U),cr(k),ie("presets","preset_applied",null,{presetId:_.id,name:_.name}),h(`Loaded preset: ${_.name}`,"info")}else h("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const nt=Kt?$i(d==null?void 0:d.presets,Kt):void 0;p.useEffect(()=>{var k;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(B==="api"?(k=v==null?void 0:v.onViewsChange)==null||k.call(v,d.views,d.activeViewId):Ua(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,B]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=B==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ya(d.id);if(k&&k.views.length>0){const _=k.views.find(A=>A.id===k.activeViewId);if(_)H(d.id,{views:k.views,activeViewId:k.activeViewId,filters:Fe(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0});else{const A=k.views.find(M=>M.isDefault)||Fn(d.schema);H(d.id,{views:k.views,activeViewId:A.id,filters:Fe(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,B,v]);const rt=p.useCallback(k=>{var M;const _=Fe(d==null?void 0:d.filters),A=((M=j.filter)==null?void 0:M.maxConditions)??3;if(Tt(_)>=A){h(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}xe(k),ge(!0)},[d,j,h]),me=p.useCallback(()=>{ge(!1),xe(void 0)},[]),Vt=(vi=d==null?void 0:d.views)==null?void 0:vi.find(k=>k.id===ae),or=(Si=d==null?void 0:d.views)==null?void 0:Si.find(k=>k.id===Y);return{reports:z,activeReport:d,activeReportId:E,setActiveReportId:S,isModalOpen:R,setIsModalOpen:q,createReport:hr,updateReport:H,uploadState:oe,handleFileUpload:Pr,handleUploadError:po,handleRetry:Nr,handleConfirm:mr,paginatedData:Wr,processedData:kr,displayData:Zt,tableMetrics:pr,isGrouped:Ar,tableEngine:Qt,activeView:Z,isDirty:se,currentTableState:be,viewChanges:Rr,filters:d==null?void 0:d.filters,showFilterPanel:te,setShowFilterPanel:ge,filterFocusColumn:ee,handleAddCondition:Ge,handleAddGroup:zr,handleUpdateCondition:st,handleSetGroupOperator:er,handleRemoveFilterNode:Wt,handleClearAllFilters:fe,handleReplaceFilters:je,handleOpenFilterForColumn:rt,handleCloseFilterPanel:me,handleClearFiltersForColumn:En,sortStack:d==null?void 0:d.sortStack,showSortPanel:V,setShowSortPanel:K,handleSort:Lr,handleUpdateSortStack:Fr,handleSortAscending:Mt,handleSortDescending:Ce,views:d==null?void 0:d.views,showCreateViewModal:ce,setShowCreateViewModal:de,showEditViewModal:ne,setShowEditViewModal:Q,showDeleteConfirmation:pe,setShowDeleteConfirmation:D,editingView:Vt,deletingView:or,editingViewId:ae,deletingViewId:Y,handleSelectView:We,handleCreateView:qe,handleCloneView:at,handleUpdateCurrentView:Ct,handleSaveColumnConfigToCurrentView:tr,handleSaveColumnConfigToAllViews:$o,handleSaveAsNewView:Vr,handleRevertChanges:zn,handleToggleDefault:Hr,handleToggleFavorite:ho,handleSoftDelete:Tn,handleRestoreView:Oo,handlePermanentDelete:Gr,handleEditView:Mo,handleCopyViewLink:Ur,handleSaveEditView:mo,handleDeleteView:Wo,handleConfirmDelete:Yr,handlePromoteToGlobal:qr,showManageColumns:Ke,setShowManageColumns:Dt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:Jr,handleUpdateColumnOrder:Bn,handleUpdateColumnWidth:In,handleResetColumnLayout:Dn,showGroupPanel:Sr,setShowGroupPanel:vt,grouping:d==null?void 0:d.grouping,groupingState:qt,handleGroup:Re,handleToggleGroupCollapse:lt,handleExpandAllGroups:xo,handleCollapseAllGroups:Ro,searchQuery:ar,debouncedSearchQuery:_t,searchHistory:Qa((d==null?void 0:d.searchHistory)||[]),handleSearchChange:_n,handleAddToSearchHistory:$n,handleToggleSearchFavourite:On,handleDeleteSearchHistory:Mn,selectedRowIds:Xe,handleToggleRowSelection:Wn,handleToggleAllRows:Kr,handleRangeSelection:rr,handleClearSelection:An,handleUpdateSelectionAfterDelete:Rn,currentPage:Jt,pageSize:et,paginationEngine:ze,paginationMode:b,paginationTotalRows:Qe,handlePageChange:xr,handlePageSizeChange:Ao,isExporting:Et,showExportModal:uo,setShowExportModal:Ft,showDirtyExportWarning:$r,handleExport:Pn,handleExportWithConfig:Xr,handleExportSelected:Lo,handleExportAnyway:Po,handleSaveAndExport:Nn,handleCancelExport:No,showAuditHistory:co,setShowAuditHistory:Or,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:wr,setShowCreatePreset:He,showManagePresets:Se,setShowManagePresets:lr,activePreset:nt,activePresetId:Kt,handleOpenManagePresets:re,handleCreatePreset:w,handleClearActivePreset:P,handleDeletePresetById:we,userRole:Be,isViewerRole:he,currentUserId:At,featureLimitWarning:Mr,setFeatureLimitWarning:dr,datasetMeta:jr,reportError:tt,setReportError:Xt,handleError:St,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?_a(d.schema):!1,snack:X,handleSnackClose:I,showSnack:h,snackDurationMs:N,config:C,scheduler:l}}const Ds=p.createContext(void 0);function mi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:u,scheduler:g,mode:f="builder",autoLoad:m=!0,config:v,devConfig:C,showDevPanel:B=!1,sharedReportId:b,sharedViewId:y,viewPersistence:z}=e,j=Ll({mode:f,autoLoad:m,initialData:i||n,dataSource:c,pagination:l,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:b,sharedViewId:y,viewPersistence:z,config:v}),[E,S]=p.useState(()=>ma()),R=(()=>{const X=fa(E,C,!!C);return{...X,display:{...X.display,showDevPanel:B||X.display.showDevPanel}}})(),q=p.useCallback(F=>{S(F),xa(F)},[]),T={...j,activeDevConfig:R,handleDevConfigChange:q};return t.jsx(Cs.Provider,{value:R,children:t.jsx(Ds.Provider,{value:T,children:r})})}function dn(){const e=p.useContext(Ds);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Fl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var f,m,v;const c=((v=(m=(f=a.components)==null?void 0:f.MuiCardHeader)==null?void 0:m.styleOverrides)==null?void 0:v.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,u=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",g=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(O.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Er(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Vl="$$material";function Hl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Uo={exports:{}},Ie={};/** @license React v16.13.1
106
106
  * react-is.production.min.js
107
107
  *
108
108
  * Copyright (c) Facebook, Inc. and its affiliates.
109
109
  *
110
110
  * This source code is licensed under the MIT license found in the
111
111
  * LICENSE file in the root directory of this source tree.
112
- */var Wi;function Yl(){if(Wi)return Ie;Wi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,m=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,w=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,S=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function T(C){if(typeof C=="object"&&C!==null){var W=C.$$typeof;switch(W){case r:switch(C=C.type,C){case u:case x:case i:case a:case s:case h:return C;default:switch(C=C&&C.$$typeof,C){case l:case m:case B:case w:case c:return C;default:return W}}case n:return W}}}function I(C){return T(C)===x}return Ie.AsyncMode=u,Ie.ConcurrentMode=x,Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=r,Ie.ForwardRef=m,Ie.Fragment=i,Ie.Lazy=B,Ie.Memo=w,Ie.Portal=n,Ie.Profiler=a,Ie.StrictMode=s,Ie.Suspense=h,Ie.isAsyncMode=function(C){return I(C)||T(C)===u},Ie.isConcurrentMode=I,Ie.isContextConsumer=function(C){return T(C)===l},Ie.isContextProvider=function(C){return T(C)===c},Ie.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===r},Ie.isForwardRef=function(C){return T(C)===m},Ie.isFragment=function(C){return T(C)===i},Ie.isLazy=function(C){return T(C)===B},Ie.isMemo=function(C){return T(C)===w},Ie.isPortal=function(C){return T(C)===n},Ie.isProfiler=function(C){return T(C)===a},Ie.isStrictMode=function(C){return T(C)===s},Ie.isSuspense=function(C){return T(C)===h},Ie.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===i||C===x||C===a||C===s||C===h||C===v||typeof C=="object"&&C!==null&&(C.$$typeof===B||C.$$typeof===w||C.$$typeof===c||C.$$typeof===l||C.$$typeof===m||C.$$typeof===f||C.$$typeof===b||C.$$typeof===g||C.$$typeof===S)},Ie.typeOf=T,Ie}var Ee={};/** @license React v16.13.1
112
+ */var Mi;function Gl(){if(Mi)return Ie;Mi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function j(S){if(typeof S=="object"&&S!==null){var R=S.$$typeof;switch(R){case r:switch(S=S.type,S){case u:case g:case i:case a:case s:case m:return S;default:switch(S=S&&S.$$typeof,S){case l:case f:case B:case C:case c:return S;default:return R}}case n:return R}}}function E(S){return j(S)===g}return Ie.AsyncMode=u,Ie.ConcurrentMode=g,Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=r,Ie.ForwardRef=f,Ie.Fragment=i,Ie.Lazy=B,Ie.Memo=C,Ie.Portal=n,Ie.Profiler=a,Ie.StrictMode=s,Ie.Suspense=m,Ie.isAsyncMode=function(S){return E(S)||j(S)===u},Ie.isConcurrentMode=E,Ie.isContextConsumer=function(S){return j(S)===l},Ie.isContextProvider=function(S){return j(S)===c},Ie.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===r},Ie.isForwardRef=function(S){return j(S)===f},Ie.isFragment=function(S){return j(S)===i},Ie.isLazy=function(S){return j(S)===B},Ie.isMemo=function(S){return j(S)===C},Ie.isPortal=function(S){return j(S)===n},Ie.isProfiler=function(S){return j(S)===a},Ie.isStrictMode=function(S){return j(S)===s},Ie.isSuspense=function(S){return j(S)===m},Ie.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===i||S===g||S===a||S===s||S===m||S===v||typeof S=="object"&&S!==null&&(S.$$typeof===B||S.$$typeof===C||S.$$typeof===c||S.$$typeof===l||S.$$typeof===f||S.$$typeof===y||S.$$typeof===z||S.$$typeof===x||S.$$typeof===b)},Ie.typeOf=j,Ie}var Ee={};/** @license React v16.13.1
113
113
  * react-is.development.js
114
114
  *
115
115
  * Copyright (c) Facebook, Inc. and its affiliates.
116
116
  *
117
117
  * This source code is licensed under the MIT license found in the
118
118
  * LICENSE file in the root directory of this source tree.
119
- */var Ri;function ql(){return Ri||(Ri=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,m=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,w=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,S=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function T(Q){return typeof Q=="string"||typeof Q=="function"||Q===i||Q===x||Q===a||Q===s||Q===h||Q===v||typeof Q=="object"&&Q!==null&&(Q.$$typeof===B||Q.$$typeof===w||Q.$$typeof===c||Q.$$typeof===l||Q.$$typeof===m||Q.$$typeof===f||Q.$$typeof===b||Q.$$typeof===g||Q.$$typeof===S)}function I(Q){if(typeof Q=="object"&&Q!==null){var ye=Q.$$typeof;switch(ye){case r:var dt=Q.type;switch(dt){case u:case x:case i:case a:case s:case h:return dt;default:var Ht=dt&&dt.$$typeof;switch(Ht){case l:case m:case B:case w:case c:return Ht;default:return ye}}case n:return ye}}}var C=u,W=x,K=l,E=c,U=r,G=m,M=i,y=B,k=w,P=n,oe=a,d=s,J=h,ee=!1;function Se(Q){return ee||(ee=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),V(Q)||I(Q)===u}function V(Q){return I(Q)===x}function X(Q){return I(Q)===l}function pe(Q){return I(Q)===c}function ce(Q){return typeof Q=="object"&&Q!==null&&Q.$$typeof===r}function ie(Q){return I(Q)===m}function te(Q){return I(Q)===i}function se(Q){return I(Q)===B}function R(Q){return I(Q)===w}function L(Q){return I(Q)===n}function de(Q){return I(Q)===a}function he(Q){return I(Q)===s}function Te(Q){return I(Q)===h}Ee.AsyncMode=C,Ee.ConcurrentMode=W,Ee.ContextConsumer=K,Ee.ContextProvider=E,Ee.Element=U,Ee.ForwardRef=G,Ee.Fragment=M,Ee.Lazy=y,Ee.Memo=k,Ee.Portal=P,Ee.Profiler=oe,Ee.StrictMode=d,Ee.Suspense=J,Ee.isAsyncMode=Se,Ee.isConcurrentMode=V,Ee.isContextConsumer=X,Ee.isContextProvider=pe,Ee.isElement=ce,Ee.isForwardRef=ie,Ee.isFragment=te,Ee.isLazy=se,Ee.isMemo=R,Ee.isPortal=L,Ee.isProfiler=de,Ee.isStrictMode=he,Ee.isSuspense=Te,Ee.isValidElementType=T,Ee.typeOf=I})()),Ee}var Pi;function Os(){return Pi||(Pi=1,process.env.NODE_ENV==="production"?Yo.exports=Yl():Yo.exports=ql()),Yo.exports}/*
119
+ */var Wi;function Ul(){return Wi||(Wi=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function j(Y){return typeof Y=="string"||typeof Y=="function"||Y===i||Y===g||Y===a||Y===s||Y===m||Y===v||typeof Y=="object"&&Y!==null&&(Y.$$typeof===B||Y.$$typeof===C||Y.$$typeof===c||Y.$$typeof===l||Y.$$typeof===f||Y.$$typeof===y||Y.$$typeof===z||Y.$$typeof===x||Y.$$typeof===b)}function E(Y){if(typeof Y=="object"&&Y!==null){var Pe=Y.$$typeof;switch(Pe){case r:var Et=Y.type;switch(Et){case u:case g:case i:case a:case s:case m:return Et;default:var mt=Et&&Et.$$typeof;switch(mt){case l:case f:case B:case C:case c:return mt;default:return Pe}}case n:return Pe}}}var S=u,R=g,q=l,T=c,F=r,X=f,W=i,h=B,I=C,N=n,d=a,oe=s,G=m,te=!1;function ge(Y){return te||(te=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),V(Y)||E(Y)===u}function V(Y){return E(Y)===g}function K(Y){return E(Y)===l}function ce(Y){return E(Y)===c}function de(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===r}function ne(Y){return E(Y)===f}function Q(Y){return E(Y)===i}function pe(Y){return E(Y)===B}function D(Y){return E(Y)===C}function ee(Y){return E(Y)===n}function xe(Y){return E(Y)===a}function ae(Y){return E(Y)===s}function Te(Y){return E(Y)===m}Ee.AsyncMode=S,Ee.ConcurrentMode=R,Ee.ContextConsumer=q,Ee.ContextProvider=T,Ee.Element=F,Ee.ForwardRef=X,Ee.Fragment=W,Ee.Lazy=h,Ee.Memo=I,Ee.Portal=N,Ee.Profiler=d,Ee.StrictMode=oe,Ee.Suspense=G,Ee.isAsyncMode=ge,Ee.isConcurrentMode=V,Ee.isContextConsumer=K,Ee.isContextProvider=ce,Ee.isElement=de,Ee.isForwardRef=ne,Ee.isFragment=Q,Ee.isLazy=pe,Ee.isMemo=D,Ee.isPortal=ee,Ee.isProfiler=xe,Ee.isStrictMode=ae,Ee.isSuspense=Te,Ee.isValidElementType=j,Ee.typeOf=E})()),Ee}var Ai;function _s(){return Ai||(Ai=1,process.env.NODE_ENV==="production"?Uo.exports=Gl():Uo.exports=Ul()),Uo.exports}/*
120
120
  object-assign
121
121
  (c) Sindre Sorhus
122
122
  @license MIT
123
- */var Hn,Ni;function Jl(){if(Ni)return Hn;Ni=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(m){return c[m]});if(u.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(m){x[m]=m}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Hn=s()?Object.assign:function(a,c){for(var l,u=i(a),x,m=1;m<arguments.length;m++){l=Object(arguments[m]);for(var h in l)r.call(l,h)&&(u[h]=l[h]);if(e){x=e(l);for(var v=0;v<x.length;v++)n.call(l,x[v])&&(u[x[v]]=l[x[v]])}}return u},Hn}var Un,Li;function mi(){if(Li)return Un;Li=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Un=e,Un}var Gn,Fi;function Ms(){return Fi||(Fi=1,Gn=Function.call.bind(Object.prototype.hasOwnProperty)),Gn}var Yn,Vi;function Kl(){if(Vi)return Yn;Vi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=mi(),n={},i=Ms();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,u,x){if(process.env.NODE_ENV!=="production"){for(var m in a)if(i(a,m)){var h;try{if(typeof a[m]!="function"){var v=Error((u||"React class")+": "+l+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}h=a[m](c,m,u,l,null,r)}catch(B){h=B}if(h&&!(h instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+m+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var w=x?x():"";e("Failed "+l+" type: "+h.message+(w??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Yn=s,Yn}var qn,Hi;function Xl(){if(Hi)return qn;Hi=1;var e=Os(),r=Jl(),n=mi(),i=Ms(),s=Kl(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return qn=function(l,u){var x=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function h(V){var X=V&&(x&&V[x]||V[m]);if(typeof X=="function")return X}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:T,element:I(),elementType:C(),instanceOf:W,node:G(),objectOf:E,oneOf:K,oneOfType:U,shape:y,exact:k};function B(V,X){return V===X?V!==0||1/V===1/X:V!==V&&X!==X}function S(V,X){this.message=V,this.data=X&&typeof X=="object"?X:{},this.stack=""}S.prototype=Error.prototype;function f(V){if(process.env.NODE_ENV!=="production")var X={},pe=0;function ce(te,se,R,L,de,he,Te){if(L=L||v,he=he||R,Te!==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 ye=L+":"+R;!X[ye]&&pe<3&&(a("You are manually calling a React.PropTypes validation function for the `"+he+"` prop on `"+L+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),X[ye]=!0,pe++)}}return se[R]==null?te?se[R]===null?new S("The "+de+" `"+he+"` is marked as required "+("in `"+L+"`, but its value is `null`.")):new S("The "+de+" `"+he+"` is marked as required in "+("`"+L+"`, but its value is `undefined`.")):null:V(se,R,L,de,he)}var ie=ce.bind(null,!1);return ie.isRequired=ce.bind(null,!0),ie}function b(V){function X(pe,ce,ie,te,se,R){var L=pe[ce],de=d(L);if(de!==V){var he=J(L);return new S("Invalid "+te+" `"+se+"` of type "+("`"+he+"` supplied to `"+ie+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return f(X)}function g(){return f(c)}function T(V){function X(pe,ce,ie,te,se){if(typeof V!="function")return new S("Property `"+se+"` of component `"+ie+"` has invalid PropType notation inside arrayOf.");var R=pe[ce];if(!Array.isArray(R)){var L=d(R);return new S("Invalid "+te+" `"+se+"` of type "+("`"+L+"` supplied to `"+ie+"`, expected an array."))}for(var de=0;de<R.length;de++){var he=V(R,de,ie,te,se+"["+de+"]",n);if(he instanceof Error)return he}return null}return f(X)}function I(){function V(X,pe,ce,ie,te){var se=X[pe];if(!l(se)){var R=d(se);return new S("Invalid "+ie+" `"+te+"` of type "+("`"+R+"` supplied to `"+ce+"`, expected a single ReactElement."))}return null}return f(V)}function C(){function V(X,pe,ce,ie,te){var se=X[pe];if(!e.isValidElementType(se)){var R=d(se);return new S("Invalid "+ie+" `"+te+"` of type "+("`"+R+"` supplied to `"+ce+"`, expected a single ReactElement type."))}return null}return f(V)}function W(V){function X(pe,ce,ie,te,se){if(!(pe[ce]instanceof V)){var R=V.name||v,L=Se(pe[ce]);return new S("Invalid "+te+" `"+se+"` of type "+("`"+L+"` supplied to `"+ie+"`, expected ")+("instance of `"+R+"`."))}return null}return f(X)}function K(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):a("Invalid argument supplied to oneOf, expected an array.")),c;function X(pe,ce,ie,te,se){for(var R=pe[ce],L=0;L<V.length;L++)if(B(R,V[L]))return null;var de=JSON.stringify(V,function(Te,Q){var ye=J(Q);return ye==="symbol"?String(Q):Q});return new S("Invalid "+te+" `"+se+"` of value `"+String(R)+"` "+("supplied to `"+ie+"`, expected one of "+de+"."))}return f(X)}function E(V){function X(pe,ce,ie,te,se){if(typeof V!="function")return new S("Property `"+se+"` of component `"+ie+"` has invalid PropType notation inside objectOf.");var R=pe[ce],L=d(R);if(L!=="object")return new S("Invalid "+te+" `"+se+"` of type "+("`"+L+"` supplied to `"+ie+"`, expected an object."));for(var de in R)if(i(R,de)){var he=V(R,de,ie,te,se+"."+de,n);if(he instanceof Error)return he}return null}return f(X)}function U(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var X=0;X<V.length;X++){var pe=V[X];if(typeof pe!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ee(pe)+" at index "+X+"."),c}function ce(ie,te,se,R,L){for(var de=[],he=0;he<V.length;he++){var Te=V[he],Q=Te(ie,te,se,R,L,n);if(Q==null)return null;Q.data&&i(Q.data,"expectedType")&&de.push(Q.data.expectedType)}var ye=de.length>0?", expected one of type ["+de.join(", ")+"]":"";return new S("Invalid "+R+" `"+L+"` supplied to "+("`"+se+"`"+ye+"."))}return f(ce)}function G(){function V(X,pe,ce,ie,te){return P(X[pe])?null:new S("Invalid "+ie+" `"+te+"` supplied to "+("`"+ce+"`, expected a ReactNode."))}return f(V)}function M(V,X,pe,ce,ie){return new S((V||"React class")+": "+X+" type `"+pe+"."+ce+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ie+"`.")}function y(V){function X(pe,ce,ie,te,se){var R=pe[ce],L=d(R);if(L!=="object")return new S("Invalid "+te+" `"+se+"` of type `"+L+"` "+("supplied to `"+ie+"`, expected `object`."));for(var de in V){var he=V[de];if(typeof he!="function")return M(ie,te,se,de,J(he));var Te=he(R,de,ie,te,se+"."+de,n);if(Te)return Te}return null}return f(X)}function k(V){function X(pe,ce,ie,te,se){var R=pe[ce],L=d(R);if(L!=="object")return new S("Invalid "+te+" `"+se+"` of type `"+L+"` "+("supplied to `"+ie+"`, expected `object`."));var de=r({},pe[ce],V);for(var he in de){var Te=V[he];if(i(V,he)&&typeof Te!="function")return M(ie,te,se,he,J(Te));if(!Te)return new S("Invalid "+te+" `"+se+"` key `"+he+"` supplied to `"+ie+"`.\nBad object: "+JSON.stringify(pe[ce],null," ")+`
124
- Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Q=Te(R,he,ie,te,se+"."+he,n);if(Q)return Q}return null}return f(X)}function P(V){switch(typeof V){case"number":case"string":case"undefined":return!0;case"boolean":return!V;case"object":if(Array.isArray(V))return V.every(P);if(V===null||l(V))return!0;var X=h(V);if(X){var pe=X.call(V),ce;if(X!==V.entries){for(;!(ce=pe.next()).done;)if(!P(ce.value))return!1}else for(;!(ce=pe.next()).done;){var ie=ce.value;if(ie&&!P(ie[1]))return!1}}else return!1;return!0;default:return!1}}function oe(V,X){return V==="symbol"?!0:X?X["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&X instanceof Symbol:!1}function d(V){var X=typeof V;return Array.isArray(V)?"array":V instanceof RegExp?"object":oe(X,V)?"symbol":X}function J(V){if(typeof V>"u"||V===null)return""+V;var X=d(V);if(X==="object"){if(V instanceof Date)return"date";if(V instanceof RegExp)return"regexp"}return X}function ee(V){var X=J(V);switch(X){case"array":case"object":return"an "+X;case"boolean":case"date":case"regexp":return"a "+X;default:return X}}function Se(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return w.checkPropTypes=s,w.resetWarningCache=s.resetWarningCache,w.PropTypes=w,w},qn}var Jn,Ui;function Ql(){if(Ui)return Jn;Ui=1;var e=mi();function r(){}function n(){}return n.resetWarningCache=r,Jn=function(){function i(c,l,u,x,m,h){if(h!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:r};return a.PropTypes=a,a},Jn}var Gi;function Zl(){if(Gi)return Go.exports;if(Gi=1,process.env.NODE_ENV!=="production"){var e=Os(),r=!0;Go.exports=Xl()(e.isElement,r)}else Go.exports=Ql()();return Go.exports}var ec=Zl();const vo=Gl(ec);var qo={exports:{}},$e={};/**
123
+ */var Hn,Ri;function Yl(){if(Ri)return Hn;Ri=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(f){return c[f]});if(u.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(f){g[f]=f}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Hn=s()?Object.assign:function(a,c){for(var l,u=i(a),g,f=1;f<arguments.length;f++){l=Object(arguments[f]);for(var m in l)r.call(l,m)&&(u[m]=l[m]);if(e){g=e(l);for(var v=0;v<g.length;v++)n.call(l,g[v])&&(u[g[v]]=l[g[v]])}}return u},Hn}var Gn,Pi;function xi(){if(Pi)return Gn;Pi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Gn=e,Gn}var Un,Ni;function $s(){return Ni||(Ni=1,Un=Function.call.bind(Object.prototype.hasOwnProperty)),Un}var Yn,Li;function ql(){if(Li)return Yn;Li=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=xi(),n={},i=$s();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,u,g){if(process.env.NODE_ENV!=="production"){for(var f in a)if(i(a,f)){var m;try{if(typeof a[f]!="function"){var v=Error((u||"React class")+": "+l+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}m=a[f](c,f,u,l,null,r)}catch(B){m=B}if(m&&!(m instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+f+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var C=g?g():"";e("Failed "+l+" type: "+m.message+(C??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Yn=s,Yn}var qn,Fi;function Jl(){if(Fi)return qn;Fi=1;var e=_s(),r=Yl(),n=xi(),i=$s(),s=ql(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return qn=function(l,u){var g=typeof Symbol=="function"&&Symbol.iterator,f="@@iterator";function m(V){var K=V&&(g&&V[g]||V[f]);if(typeof K=="function")return K}var v="<<anonymous>>",C={array:z("array"),bigint:z("bigint"),bool:z("boolean"),func:z("function"),number:z("number"),object:z("object"),string:z("string"),symbol:z("symbol"),any:x(),arrayOf:j,element:E(),elementType:S(),instanceOf:R,node:X(),objectOf:T,oneOf:q,oneOfType:F,shape:h,exact:I};function B(V,K){return V===K?V!==0||1/V===1/K:V!==V&&K!==K}function b(V,K){this.message=V,this.data=K&&typeof K=="object"?K:{},this.stack=""}b.prototype=Error.prototype;function y(V){if(process.env.NODE_ENV!=="production")var K={},ce=0;function de(Q,pe,D,ee,xe,ae,Te){if(ee=ee||v,ae=ae||D,Te!==n){if(u){var Y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw Y.name="Invariant Violation",Y}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Pe=ee+":"+D;!K[Pe]&&ce<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ae+"` prop on `"+ee+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),K[Pe]=!0,ce++)}}return pe[D]==null?Q?pe[D]===null?new b("The "+xe+" `"+ae+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new b("The "+xe+" `"+ae+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:V(pe,D,ee,xe,ae)}var ne=de.bind(null,!1);return ne.isRequired=de.bind(null,!0),ne}function z(V){function K(ce,de,ne,Q,pe,D){var ee=ce[de],xe=oe(ee);if(xe!==V){var ae=G(ee);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ae+"` supplied to `"+ne+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return y(K)}function x(){return y(c)}function j(V){function K(ce,de,ne,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ne+"` has invalid PropType notation inside arrayOf.");var D=ce[de];if(!Array.isArray(D)){var ee=oe(D);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected an array."))}for(var xe=0;xe<D.length;xe++){var ae=V(D,xe,ne,Q,pe+"["+xe+"]",n);if(ae instanceof Error)return ae}return null}return y(K)}function E(){function V(K,ce,de,ne,Q){var pe=K[ce];if(!l(pe)){var D=oe(pe);return new b("Invalid "+ne+" `"+Q+"` of type "+("`"+D+"` supplied to `"+de+"`, expected a single ReactElement."))}return null}return y(V)}function S(){function V(K,ce,de,ne,Q){var pe=K[ce];if(!e.isValidElementType(pe)){var D=oe(pe);return new b("Invalid "+ne+" `"+Q+"` of type "+("`"+D+"` supplied to `"+de+"`, expected a single ReactElement type."))}return null}return y(V)}function R(V){function K(ce,de,ne,Q,pe){if(!(ce[de]instanceof V)){var D=V.name||v,ee=ge(ce[de]);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected ")+("instance of `"+D+"`."))}return null}return y(K)}function q(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):a("Invalid argument supplied to oneOf, expected an array.")),c;function K(ce,de,ne,Q,pe){for(var D=ce[de],ee=0;ee<V.length;ee++)if(B(D,V[ee]))return null;var xe=JSON.stringify(V,function(Te,Y){var Pe=G(Y);return Pe==="symbol"?String(Y):Y});return new b("Invalid "+Q+" `"+pe+"` of value `"+String(D)+"` "+("supplied to `"+ne+"`, expected one of "+xe+"."))}return y(K)}function T(V){function K(ce,de,ne,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ne+"` has invalid PropType notation inside objectOf.");var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected an object."));for(var xe in D)if(i(D,xe)){var ae=V(D,xe,ne,Q,pe+"."+xe,n);if(ae instanceof Error)return ae}return null}return y(K)}function F(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var K=0;K<V.length;K++){var ce=V[K];if(typeof ce!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+te(ce)+" at index "+K+"."),c}function de(ne,Q,pe,D,ee){for(var xe=[],ae=0;ae<V.length;ae++){var Te=V[ae],Y=Te(ne,Q,pe,D,ee,n);if(Y==null)return null;Y.data&&i(Y.data,"expectedType")&&xe.push(Y.data.expectedType)}var Pe=xe.length>0?", expected one of type ["+xe.join(", ")+"]":"";return new b("Invalid "+D+" `"+ee+"` supplied to "+("`"+pe+"`"+Pe+"."))}return y(de)}function X(){function V(K,ce,de,ne,Q){return N(K[ce])?null:new b("Invalid "+ne+" `"+Q+"` supplied to "+("`"+de+"`, expected a ReactNode."))}return y(V)}function W(V,K,ce,de,ne){return new b((V||"React class")+": "+K+" type `"+ce+"."+de+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ne+"`.")}function h(V){function K(ce,de,ne,Q,pe){var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+ee+"` "+("supplied to `"+ne+"`, expected `object`."));for(var xe in V){var ae=V[xe];if(typeof ae!="function")return W(ne,Q,pe,xe,G(ae));var Te=ae(D,xe,ne,Q,pe+"."+xe,n);if(Te)return Te}return null}return y(K)}function I(V){function K(ce,de,ne,Q,pe){var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+ee+"` "+("supplied to `"+ne+"`, expected `object`."));var xe=r({},ce[de],V);for(var ae in xe){var Te=V[ae];if(i(V,ae)&&typeof Te!="function")return W(ne,Q,pe,ae,G(Te));if(!Te)return new b("Invalid "+Q+" `"+pe+"` key `"+ae+"` supplied to `"+ne+"`.\nBad object: "+JSON.stringify(ce[de],null," ")+`
124
+ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=Te(D,ae,ne,Q,pe+"."+ae,n);if(Y)return Y}return null}return y(K)}function N(V){switch(typeof V){case"number":case"string":case"undefined":return!0;case"boolean":return!V;case"object":if(Array.isArray(V))return V.every(N);if(V===null||l(V))return!0;var K=m(V);if(K){var ce=K.call(V),de;if(K!==V.entries){for(;!(de=ce.next()).done;)if(!N(de.value))return!1}else for(;!(de=ce.next()).done;){var ne=de.value;if(ne&&!N(ne[1]))return!1}}else return!1;return!0;default:return!1}}function d(V,K){return V==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function oe(V){var K=typeof V;return Array.isArray(V)?"array":V instanceof RegExp?"object":d(K,V)?"symbol":K}function G(V){if(typeof V>"u"||V===null)return""+V;var K=oe(V);if(K==="object"){if(V instanceof Date)return"date";if(V instanceof RegExp)return"regexp"}return K}function te(V){var K=G(V);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function ge(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return C.checkPropTypes=s,C.resetWarningCache=s.resetWarningCache,C.PropTypes=C,C},qn}var Jn,Vi;function Kl(){if(Vi)return Jn;Vi=1;var e=xi();function r(){}function n(){}return n.resetWarningCache=r,Jn=function(){function i(c,l,u,g,f,m){if(m!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:r};return a.PropTypes=a,a},Jn}var Hi;function Xl(){if(Hi)return Go.exports;if(Hi=1,process.env.NODE_ENV!=="production"){var e=_s(),r=!0;Go.exports=Jl()(e.isElement,r)}else Go.exports=Kl()();return Go.exports}var Ql=Xl();const go=Hl(Ql);var Yo={exports:{}},$e={};/**
125
125
  * @license React
126
126
  * react-is.production.js
127
127
  *
@@ -129,7 +129,7 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Q=Te(R,he,ie,te,se+"
129
129
  *
130
130
  * This source code is licensed under the MIT license found in the
131
131
  * LICENSE file in the root directory of this source tree.
132
- */var Yi;function tc(){if(Yi)return $e;Yi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),w=Symbol.for("react.client.reference");function B(S){if(typeof S=="object"&&S!==null){var f=S.$$typeof;switch(f){case e:switch(S=S.type,S){case n:case s:case i:case u:case x:case v:return S;default:switch(S=S&&S.$$typeof,S){case c:case l:case h:case m:return S;case a:return S;default:return f}}case r:return f}}}return $e.ContextConsumer=a,$e.ContextProvider=c,$e.Element=e,$e.ForwardRef=l,$e.Fragment=n,$e.Lazy=h,$e.Memo=m,$e.Portal=r,$e.Profiler=s,$e.StrictMode=i,$e.Suspense=u,$e.SuspenseList=x,$e.isContextConsumer=function(S){return B(S)===a},$e.isContextProvider=function(S){return B(S)===c},$e.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===e},$e.isForwardRef=function(S){return B(S)===l},$e.isFragment=function(S){return B(S)===n},$e.isLazy=function(S){return B(S)===h},$e.isMemo=function(S){return B(S)===m},$e.isPortal=function(S){return B(S)===r},$e.isProfiler=function(S){return B(S)===s},$e.isStrictMode=function(S){return B(S)===i},$e.isSuspense=function(S){return B(S)===u},$e.isSuspenseList=function(S){return B(S)===x},$e.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===n||S===s||S===i||S===u||S===x||typeof S=="object"&&S!==null&&(S.$$typeof===h||S.$$typeof===m||S.$$typeof===c||S.$$typeof===a||S.$$typeof===l||S.$$typeof===w||S.getModuleId!==void 0)},$e.typeOf=B,$e}var Oe={};/**
132
+ */var Gi;function Zl(){if(Gi)return $e;Gi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),C=Symbol.for("react.client.reference");function B(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case e:switch(b=b.type,b){case n:case s:case i:case u:case g:case v:return b;default:switch(b=b&&b.$$typeof,b){case c:case l:case m:case f:return b;case a:return b;default:return y}}case r:return y}}}return $e.ContextConsumer=a,$e.ContextProvider=c,$e.Element=e,$e.ForwardRef=l,$e.Fragment=n,$e.Lazy=m,$e.Memo=f,$e.Portal=r,$e.Profiler=s,$e.StrictMode=i,$e.Suspense=u,$e.SuspenseList=g,$e.isContextConsumer=function(b){return B(b)===a},$e.isContextProvider=function(b){return B(b)===c},$e.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===e},$e.isForwardRef=function(b){return B(b)===l},$e.isFragment=function(b){return B(b)===n},$e.isLazy=function(b){return B(b)===m},$e.isMemo=function(b){return B(b)===f},$e.isPortal=function(b){return B(b)===r},$e.isProfiler=function(b){return B(b)===s},$e.isStrictMode=function(b){return B(b)===i},$e.isSuspense=function(b){return B(b)===u},$e.isSuspenseList=function(b){return B(b)===g},$e.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===s||b===i||b===u||b===g||typeof b=="object"&&b!==null&&(b.$$typeof===m||b.$$typeof===f||b.$$typeof===c||b.$$typeof===a||b.$$typeof===l||b.$$typeof===C||b.getModuleId!==void 0)},$e.typeOf=B,$e}var Oe={};/**
133
133
  * @license React
134
134
  * react-is.development.js
135
135
  *
@@ -137,16 +137,16 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Q=Te(R,he,ie,te,se+"
137
137
  *
138
138
  * This source code is licensed under the MIT license found in the
139
139
  * LICENSE file in the root directory of this source tree.
140
- */var qi;function rc(){return qi||(qi=1,process.env.NODE_ENV!=="production"&&(function(){function e(S){if(typeof S=="object"&&S!==null){var f=S.$$typeof;switch(f){case r:switch(S=S.type,S){case i:case a:case s:case x:case m:case w:return S;default:switch(S=S&&S.$$typeof,S){case l:case u:case v:case h:return S;case c:return S;default:return f}}case n:return f}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),B=Symbol.for("react.client.reference");Oe.ContextConsumer=c,Oe.ContextProvider=l,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=v,Oe.Memo=h,Oe.Portal=n,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=x,Oe.SuspenseList=m,Oe.isContextConsumer=function(S){return e(S)===c},Oe.isContextProvider=function(S){return e(S)===l},Oe.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===r},Oe.isForwardRef=function(S){return e(S)===u},Oe.isFragment=function(S){return e(S)===i},Oe.isLazy=function(S){return e(S)===v},Oe.isMemo=function(S){return e(S)===h},Oe.isPortal=function(S){return e(S)===n},Oe.isProfiler=function(S){return e(S)===a},Oe.isStrictMode=function(S){return e(S)===s},Oe.isSuspense=function(S){return e(S)===x},Oe.isSuspenseList=function(S){return e(S)===m},Oe.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===i||S===a||S===s||S===x||S===m||typeof S=="object"&&S!==null&&(S.$$typeof===v||S.$$typeof===h||S.$$typeof===l||S.$$typeof===c||S.$$typeof===u||S.$$typeof===B||S.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var Ji;function oc(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?qo.exports=tc():qo.exports=rc()),qo.exports}var As=oc();function fr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ws(e){if(ln.isValidElement(e)||As.isValidElementType(e)||!fr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ws(e[n])}),r}function gt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return fr(e)&&fr(r)&&Object.keys(r).forEach(s=>{ln.isValidElement(r[s])||As.isValidElementType(r[s])?i[s]=r[s]:fr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&fr(e[s])?i[s]=gt(e[s],r[s],n):n.clone?i[s]=fr(r[s])?Ws(r[s]):r[s]:i[s]=r[s]}),i}const nc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function ic(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=nc(r),c=Object.keys(a);function l(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function u(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function x(v,w){const B=c.indexOf(w);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(B!==-1&&typeof r[c[B]]=="number"?r[c[B]]:w)-i/100}${n})`}function m(v){return c.indexOf(v)+1<c.length?x(v,c[c.indexOf(v)+1]):l(v)}function h(v){const w=c.indexOf(v);return w===0?l(c[1]):w===c.length-1?u(c[w]):x(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:u,between:x,only:m,not:h,unit:n,...s}}function Ki(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const a=/min-width:\s*([0-9.]+)/;return+(((c=i.match(a))==null?void 0:c[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function sc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function ac(e,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function lc(e){const r=(a,c)=>a.replace("@media",c?`@container ${c}`:"@container");function n(a,c){a.up=(...l)=>r(e.breakpoints.up(...l),c),a.down=(...l)=>r(e.breakpoints.down(...l),c),a.between=(...l)=>r(e.breakpoints.between(...l),c),a.only=(...l)=>r(e.breakpoints.only(...l),c),a.not=(...l)=>{const u=r(e.breakpoints.not(...l),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const cc={borderRadius:4},yr=process.env.NODE_ENV!=="production"?vo.oneOfType([vo.number,vo.string,vo.object,vo.array]):{};function Io(e,r){return r?gt(e,r,{clone:!1}):e}const pn={xs:0,sm:600,md:900,lg:1200,xl:1536},Xi={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${pn[e]}px)`},dc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:pn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function sr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Xi;return r.reduce((c,l,u)=>(c[a.up(a.keys[u])]=n(r[u]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Xi;return Object.keys(r).reduce((c,l)=>{if(sc(a.keys,l)){const u=ac(i.containerQueries?i:dc,l);u&&(c[u]=n(r[l],l))}else if(Object.keys(a.values||pn).includes(l)){const u=a.up(l);c[u]=n(r[l],l)}else{const u=l;c[u]=r[u]}return c},{})}return n(r)}function uc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Qi(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Rs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":_r(7));return e.charAt(0).toUpperCase()+e.slice(1)}function hn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function sn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=hn(e,n)||i,r&&(s=r(s,i,e)),s}function Le(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=c=>{if(c[r]==null)return null;const l=c[r],u=c.theme,x=hn(u,i)||{};return sr(c,l,h=>{let v=sn(x,s,h);return h===v&&typeof h=="string"&&(v=sn(x,s,`${r}${h==="default"?"":Rs(h)}`,h)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:yr}:{},a.filterProps=[r],a}function pc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const hc={m:"margin",p:"padding"},fc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Zi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},mc=pc(e=>{if(e.length>2)if(Zi[e])e=Zi[e];else return[e];const[r,n]=e.split(""),i=hc[r],s=fc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),fn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],mn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],xc=[...fn,...mn];function $o(e,r,n,i){const s=hn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const c=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>s.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${c} > ${s.length-1}, you need to add the missing values.`].join(`
140
+ */var Ui;function ec(){return Ui||(Ui=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case r:switch(b=b.type,b){case i:case a:case s:case g:case f:case C:return b;default:switch(b=b&&b.$$typeof,b){case l:case u:case v:case m:return b;case c:return b;default:return y}}case n:return y}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),C=Symbol.for("react.view_transition"),B=Symbol.for("react.client.reference");Oe.ContextConsumer=c,Oe.ContextProvider=l,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=v,Oe.Memo=m,Oe.Portal=n,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=g,Oe.SuspenseList=f,Oe.isContextConsumer=function(b){return e(b)===c},Oe.isContextProvider=function(b){return e(b)===l},Oe.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},Oe.isForwardRef=function(b){return e(b)===u},Oe.isFragment=function(b){return e(b)===i},Oe.isLazy=function(b){return e(b)===v},Oe.isMemo=function(b){return e(b)===m},Oe.isPortal=function(b){return e(b)===n},Oe.isProfiler=function(b){return e(b)===a},Oe.isStrictMode=function(b){return e(b)===s},Oe.isSuspense=function(b){return e(b)===g},Oe.isSuspenseList=function(b){return e(b)===f},Oe.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===a||b===s||b===g||b===f||typeof b=="object"&&b!==null&&(b.$$typeof===v||b.$$typeof===m||b.$$typeof===l||b.$$typeof===c||b.$$typeof===u||b.$$typeof===B||b.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var Yi;function tc(){return Yi||(Yi=1,process.env.NODE_ENV==="production"?Yo.exports=Zl():Yo.exports=ec()),Yo.exports}var Os=tc();function fr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ms(e){if(an.isValidElement(e)||Os.isValidElementType(e)||!fr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ms(e[n])}),r}function bt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return fr(e)&&fr(r)&&Object.keys(r).forEach(s=>{an.isValidElement(r[s])||Os.isValidElementType(r[s])?i[s]=r[s]:fr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&fr(e[s])?i[s]=bt(e[s],r[s],n):n.clone?i[s]=fr(r[s])?Ms(r[s]):r[s]:i[s]=r[s]}),i}const rc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function oc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=rc(r),c=Object.keys(a);function l(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function u(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function g(v,C){const B=c.indexOf(C);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(B!==-1&&typeof r[c[B]]=="number"?r[c[B]]:C)-i/100}${n})`}function f(v){return c.indexOf(v)+1<c.length?g(v,c[c.indexOf(v)+1]):l(v)}function m(v){const C=c.indexOf(v);return C===0?l(c[1]):C===c.length-1?u(c[C]):g(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:u,between:g,only:f,not:m,unit:n,...s}}function qi(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const a=/min-width:\s*([0-9.]+)/;return+(((c=i.match(a))==null?void 0:c[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function nc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function ic(e,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function sc(e){const r=(a,c)=>a.replace("@media",c?`@container ${c}`:"@container");function n(a,c){a.up=(...l)=>r(e.breakpoints.up(...l),c),a.down=(...l)=>r(e.breakpoints.down(...l),c),a.between=(...l)=>r(e.breakpoints.between(...l),c),a.only=(...l)=>r(e.breakpoints.only(...l),c),a.not=(...l)=>{const u=r(e.breakpoints.not(...l),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const ac={borderRadius:4},vr=process.env.NODE_ENV!=="production"?go.oneOfType([go.number,go.string,go.object,go.array]):{};function zo(e,r){return r?bt(e,r,{clone:!1}):e}const un={xs:0,sm:600,md:900,lg:1200,xl:1536},Ji={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${un[e]}px)`},lc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:un[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function sr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Ji;return r.reduce((c,l,u)=>(c[a.up(a.keys[u])]=n(r[u]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Ji;return Object.keys(r).reduce((c,l)=>{if(nc(a.keys,l)){const u=ic(i.containerQueries?i:lc,l);u&&(c[u]=n(r[l],l))}else if(Object.keys(a.values||un).includes(l)){const u=a.up(l);c[u]=n(r[l],l)}else{const u=l;c[u]=r[u]}return c},{})}return n(r)}function cc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Ki(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Ws(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Er(7));return e.charAt(0).toUpperCase()+e.slice(1)}function pn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function nn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=pn(e,n)||i,r&&(s=r(s,i,e)),s}function Ve(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=c=>{if(c[r]==null)return null;const l=c[r],u=c.theme,g=pn(u,i)||{};return sr(c,l,m=>{let v=nn(g,s,m);return m===v&&typeof m=="string"&&(v=nn(g,s,`${r}${m==="default"?"":Ws(m)}`,m)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:vr}:{},a.filterProps=[r],a}function dc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const uc={m:"margin",p:"padding"},pc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Xi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},hc=dc(e=>{if(e.length>2)if(Xi[e])e=Xi[e];else return[e];const[r,n]=e.split(""),i=uc[r],s=pc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),hn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],mn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],mc=[...hn,...mn];function Eo(e,r,n,i){const s=pn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const c=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>s.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${c} > ${s.length-1}, you need to add the missing values.`].join(`
142
142
  `)):console.error([`MUI: The \`theme.${r}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${r}\` as a number.`].join(`
143
143
  `)));const l=s[c];return a>=0?l:typeof l=="number"?-l:typeof l=="string"&&l.startsWith("var(")?`calc(-1 * ${l})`:`-${l}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
144
- `)),()=>{})}function xi(e){return $o(e,"spacing",8,"spacing")}function Oo(e,r){return typeof r=="string"||r==null?r:e(r)}function gc(e,r){return n=>e.reduce((i,s)=>(i[s]=Oo(r,n),i),{})}function yc(e,r,n,i){if(!r.includes(n))return null;const s=mc(n),a=gc(s,i),c=e[n];return sr(e,c,a)}function Ps(e,r){const n=xi(e.theme);return Object.keys(e).map(i=>yc(e,r,i,n)).reduce(Io,{})}function Re(e){return Ps(e,fn)}Re.propTypes=process.env.NODE_ENV!=="production"?fn.reduce((e,r)=>(e[r]=yr,e),{}):{};Re.filterProps=fn;function Pe(e){return Ps(e,mn)}Pe.propTypes=process.env.NODE_ENV!=="production"?mn.reduce((e,r)=>(e[r]=yr,e),{}):{};Pe.filterProps=mn;process.env.NODE_ENV!=="production"&&xc.reduce((e,r)=>(e[r]=yr,e),{});function Ns(e=8,r=xi({spacing:e})){if(e.mui)return e;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(a=>{const c=r(a);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function xn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?Io(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function jt(e){return typeof e!="number"?e:`${e}px solid`}function Tt(e,r){return Le({prop:e,themeKey:"borders",transform:r})}const bc=Tt("border",jt),vc=Tt("borderTop",jt),Sc=Tt("borderRight",jt),Cc=Tt("borderBottom",jt),wc=Tt("borderLeft",jt),jc=Tt("borderColor"),kc=Tt("borderTopColor"),zc=Tt("borderRightColor"),Tc=Tt("borderBottomColor"),Bc=Tt("borderLeftColor"),Ic=Tt("outline",jt),Ec=Tt("outlineColor"),gn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=$o(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Oo(r,i)});return sr(e,e.borderRadius,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:yr}:{};gn.filterProps=["borderRadius"];xn(bc,vc,Sc,Cc,wc,jc,kc,zc,Tc,Bc,gn,Ic,Ec);const yn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=$o(e.theme,"spacing",8,"gap"),n=i=>({gap:Oo(r,i)});return sr(e,e.gap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{gap:yr}:{};yn.filterProps=["gap"];const bn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=$o(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Oo(r,i)});return sr(e,e.columnGap,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:yr}:{};bn.filterProps=["columnGap"];const vn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=$o(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Oo(r,i)});return sr(e,e.rowGap,n)}return null};vn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:yr}:{};vn.filterProps=["rowGap"];const Dc=Le({prop:"gridColumn"}),_c=Le({prop:"gridRow"}),$c=Le({prop:"gridAutoFlow"}),Oc=Le({prop:"gridAutoColumns"}),Mc=Le({prop:"gridAutoRows"}),Ac=Le({prop:"gridTemplateColumns"}),Wc=Le({prop:"gridTemplateRows"}),Rc=Le({prop:"gridTemplateAreas"}),Pc=Le({prop:"gridArea"});xn(yn,bn,vn,Dc,_c,$c,Oc,Mc,Ac,Wc,Rc,Pc);function io(e,r){return r==="grey"?r:e}const Nc=Le({prop:"color",themeKey:"palette",transform:io}),Lc=Le({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:io}),Fc=Le({prop:"backgroundColor",themeKey:"palette",transform:io});xn(Nc,Lc,Fc);function xt(e){return e<=1&&e!==0?`${e*100}%`:e}const Vc=Le({prop:"width",transform:xt}),gi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,u;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||pn[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:xt(n)}};return sr(e,e.maxWidth,r)}return null};gi.filterProps=["maxWidth"];const Hc=Le({prop:"minWidth",transform:xt}),Uc=Le({prop:"height",transform:xt}),Gc=Le({prop:"maxHeight",transform:xt}),Yc=Le({prop:"minHeight",transform:xt});Le({prop:"size",cssProperty:"width",transform:xt});Le({prop:"size",cssProperty:"height",transform:xt});const qc=Le({prop:"boxSizing"});xn(Vc,gi,Hc,Uc,Gc,Yc,qc);const Sn={border:{themeKey:"borders",transform:jt},borderTop:{themeKey:"borders",transform:jt},borderRight:{themeKey:"borders",transform:jt},borderBottom:{themeKey:"borders",transform:jt},borderLeft:{themeKey:"borders",transform:jt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:jt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:gn},color:{themeKey:"palette",transform:io},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:io},backgroundColor:{themeKey:"palette",transform:io},p:{style:Pe},pt:{style:Pe},pr:{style:Pe},pb:{style:Pe},pl:{style:Pe},px:{style:Pe},py:{style:Pe},padding:{style:Pe},paddingTop:{style:Pe},paddingRight:{style:Pe},paddingBottom:{style:Pe},paddingLeft:{style:Pe},paddingX:{style:Pe},paddingY:{style:Pe},paddingInline:{style:Pe},paddingInlineStart:{style:Pe},paddingInlineEnd:{style:Pe},paddingBlock:{style:Pe},paddingBlockStart:{style:Pe},paddingBlockEnd:{style:Pe},m:{style:Re},mt:{style:Re},mr:{style:Re},mb:{style:Re},ml:{style:Re},mx:{style:Re},my:{style:Re},margin:{style:Re},marginTop:{style:Re},marginRight:{style:Re},marginBottom:{style:Re},marginLeft:{style:Re},marginX:{style:Re},marginY:{style:Re},marginInline:{style:Re},marginInlineStart:{style:Re},marginInlineEnd:{style:Re},marginBlock:{style:Re},marginBlockStart:{style:Re},marginBlockEnd:{style:Re},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:yn},rowGap:{style:vn},columnGap:{style:bn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:xt},maxWidth:{style:gi},minWidth:{transform:xt},height:{transform:xt},maxHeight:{transform:xt},minHeight:{transform:xt},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function Jc(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function Kc(e,r){return typeof e=="function"?e(r):e}function Xc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:x,transform:m,style:h}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const v=hn(s,x)||{};return h?h(c):sr(c,i,B=>{let S=sn(v,m,B);return B===S&&typeof B=="string"&&(S=sn(v,m,`${n}${B==="default"?"":Rs(B)}`,B)),u===!1?S:{[u]:S}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Sn;function l(u){let x=u;if(typeof u=="function")x=u(s);else if(typeof u!="object")return u;if(!x)return null;const m=uc(s.breakpoints),h=Object.keys(m);let v=m;return Object.keys(x).forEach(w=>{const B=Kc(x[w],s);if(B!=null)if(typeof B=="object")if(c[w])v=Io(v,e(w,B,s,c));else{const S=sr({theme:s},B,f=>({[w]:f}));Jc(S,B)?v[w]=r({sx:B,theme:s,nested:!0}):v=Io(v,S)}else v=Io(v,e(w,B,s,c))}),!a&&s.modularCssLayers?{"@layer sx":Ki(s,Qi(h,v))}:Ki(s,Qi(h,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const Cn=Xc();Cn.filterProps=["sx"];function Qc(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Ls(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=ic(n),u=Ns(s);let x=gt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...cc,...a}},c);return x=lc(x),x.applyStyles=Qc,x=r.reduce((m,h)=>gt(m,h),x),x.unstable_sxConfig={...Sn,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(h){return Cn({sx:h,theme:this})},x}function Zc(e){return Object.keys(e).length===0}function ed(e=null){const r=ln.useContext(ma.ThemeContext);return!r||Zc(r)?e:r}const td=Ls();function rd(e=td){return ed(e)}const es=e=>e,od=()=>{let e=es;return{configure(r){e=r},generate(r){return e(r)},reset(){e=es}}},nd=od(),id={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function sd(e,r,n="Mui"){const i=id[r];return i?`${n}-${i}`:`${nd.generate(e)}-${r}`}function ad(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function yi(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),ad(e,r,n)}function ld(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function xr(e){if(e.type)return e;if(e.charAt(0)==="#")return xr(ld(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
- The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:_r(9,e));let i=e.substring(r+1,e.length-1),s;if(n==="color"){if(i=i.split(" "),s=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:_r(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const cd=e=>{const r=xr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},jo=(e,r)=>{try{return cd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function wn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Fs(e){e=xr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(x,m=(x+n/30)%12)=>s-a*Math.max(Math.min(m-3,9-m,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),wn({type:l,values:u})}function ri(e){e=xr(e);let r=e.type==="hsl"||e.type==="hsla"?xr(Fs(e)).values:e.values;return r=r.map(n=>(e.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function ts(e,r){const n=ri(e),i=ri(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function _(e,r){return e=xr(e),r=yi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,wn(e)}function Er(e,r,n){try{return _(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=xr(e),r=yi(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return wn(e)}function De(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function kn(e,r){if(e=xr(e),r=yi(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return wn(e)}function _e(e,r,n){try{return kn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function dd(e,r=.15){return ri(e)>.5?jn(e,r):kn(e,r)}function Jo(e,r,n){try{return dd(e,r)}catch{return e}}function ud(e=""){function r(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const rs=(e,r,n,i=[])=>{let s=e;r.forEach((a,c)=>{c===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},pd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...c,l]:c):r([...a,l],u,c))})}i(e)},hd=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function Kn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return pd(e,(l,u,x)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const m=`--${n?`${n}-`:""}${l.join("-")}`,h=hd(l,u);Object.assign(s,{[m]:h}),rs(a,l,`var(${m})`,x),rs(c,l,`var(${m}, ${h})`,x)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function fd(e,r={}){const{getSelector:n=b,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...x}=e,{vars:m,css:h,varsWithDefaults:v}=Kn(x,r);let w=v;const B={},{[u]:S,...f}=c;if(Object.entries(f||{}).forEach(([I,C])=>{const{vars:W,css:K,varsWithDefaults:E}=Kn(C,r);w=gt(w,E),B[I]={css:K,vars:W}}),S){const{css:I,vars:C,varsWithDefaults:W}=Kn(S,r);w=gt(w,W),B[u]={css:I,vars:C}}function b(I,C){var K,E;let W=s;if(s==="class"&&(W=".%s"),s==="data"&&(W="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(W=`[${s}="%s"]`),I){if(W==="media")return e.defaultColorScheme===I?":root":{[`@media (prefers-color-scheme: ${((E=(K=c[I])==null?void 0:K.palette)==null?void 0:E.mode)||I})`]:{":root":C}};if(W)return e.defaultColorScheme===I?`:root, ${W.replace("%s",String(I))}`:W.replace("%s",String(I))}return":root"}return{vars:w,generateThemeVars:()=>{let I={...m};return Object.entries(B).forEach(([,{vars:C}])=>{I=gt(I,C)}),I},generateStyleSheets:()=>{var U,G;const I=[],C=e.defaultColorScheme||"light";function W(M,y){Object.keys(y).length&&I.push(typeof M=="string"?{[M]:{...y}}:M)}W(n(void 0,{...h}),h);const{[C]:K,...E}=B;if(K){const{css:M}=K,y=(G=(U=c[C])==null?void 0:U.palette)==null?void 0:G.mode,k=!i&&y?{colorScheme:y,...M}:{...M};W(n(C,{...k}),k)}return Object.entries(E).forEach(([M,{css:y}])=>{var oe,d;const k=(d=(oe=c[M])==null?void 0:oe.palette)==null?void 0:d.mode,P=!i&&k?{colorScheme:k,...y}:{...y};W(n(M,{...P}),P)}),a&&I.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),I}}}function md(e){return function(n){return e==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const Do={black:"#000",white:"#fff"},xd={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},Zr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},eo={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},So={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},to={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},ro={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},oo={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Vs(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Do.white,default:Do.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const Hs=Vs();function Us(){return{text:{primary:Do.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:Do.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const oi=Us();function os(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=kn(e.main,s):r==="dark"&&(e.dark=jn(e.main,a)))}function ns(e,r,n,i,s){const a=s.light||s,c=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(c*100).toFixed(0)}%)`))}function gd(e="light"){return e==="dark"?{main:to[200],light:to[50],dark:to[400]}:{main:to[700],light:to[400],dark:to[800]}}function yd(e="light"){return e==="dark"?{main:Zr[200],light:Zr[50],dark:Zr[400]}:{main:Zr[500],light:Zr[300],dark:Zr[700]}}function bd(e="light"){return e==="dark"?{main:eo[500],light:eo[300],dark:eo[700]}:{main:eo[700],light:eo[400],dark:eo[800]}}function vd(e="light"){return e==="dark"?{main:ro[400],light:ro[300],dark:ro[700]}:{main:ro[700],light:ro[500],dark:ro[900]}}function Sd(e="light"){return e==="dark"?{main:oo[400],light:oo[300],dark:oo[700]}:{main:oo[800],light:oo[500],dark:oo[900]}}function Cd(e="light"){return e==="dark"?{main:So[400],light:So[300],dark:So[700]}:{main:"#ed6c02",light:So[500],dark:So[900]}}function wd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function bi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||gd(r),l=e.secondary||yd(r),u=e.error||bd(r),x=e.info||vd(r),m=e.success||Sd(r),h=e.warning||Cd(r);function v(f){if(s)return wd(f);const b=ts(f,oi.text.primary)>=n?oi.text.primary:Hs.text.primary;if(process.env.NODE_ENV!=="production"){const g=ts(f,b);g<3&&console.error([`MUI: The contrast ratio of ${g}:1 for ${b} on ${f}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
147
- `))}return b}const w=({color:f,name:b,mainShade:g=500,lightShade:T=300,darkShade:I=700})=>{if(f={...f},!f.main&&f[g]&&(f.main=f[g]),!f.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${b?` (${b})`:""} provided to augmentColor(color) is invalid.
148
- The color object needs to have a \`main\` property or a \`${g}\` property.`:_r(11,b?` (${b})`:"",g));if(typeof f.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${b?` (${b})`:""} provided to augmentColor(color) is invalid.
149
- \`color.main\` should be a string, but \`${JSON.stringify(f.main)}\` was provided instead.
144
+ `)),()=>{})}function fi(e){return Eo(e,"spacing",8,"spacing")}function Do(e,r){return typeof r=="string"||r==null?r:e(r)}function xc(e,r){return n=>e.reduce((i,s)=>(i[s]=Do(r,n),i),{})}function fc(e,r,n,i){if(!r.includes(n))return null;const s=hc(n),a=xc(s,i),c=e[n];return sr(e,c,a)}function As(e,r){const n=fi(e.theme);return Object.keys(e).map(i=>fc(e,r,i,n)).reduce(zo,{})}function Ne(e){return As(e,hn)}Ne.propTypes=process.env.NODE_ENV!=="production"?hn.reduce((e,r)=>(e[r]=vr,e),{}):{};Ne.filterProps=hn;function Le(e){return As(e,mn)}Le.propTypes=process.env.NODE_ENV!=="production"?mn.reduce((e,r)=>(e[r]=vr,e),{}):{};Le.filterProps=mn;process.env.NODE_ENV!=="production"&&mc.reduce((e,r)=>(e[r]=vr,e),{});function Rs(e=8,r=fi({spacing:e})){if(e.mui)return e;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(a=>{const c=r(a);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function xn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?zo(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function zt(e){return typeof e!="number"?e:`${e}px solid`}function It(e,r){return Ve({prop:e,themeKey:"borders",transform:r})}const gc=It("border",zt),yc=It("borderTop",zt),bc=It("borderRight",zt),vc=It("borderBottom",zt),Sc=It("borderLeft",zt),Cc=It("borderColor"),wc=It("borderTopColor"),jc=It("borderRightColor"),kc=It("borderBottomColor"),zc=It("borderLeftColor"),Tc=It("outline",zt),Bc=It("outlineColor"),fn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Eo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Do(r,i)});return sr(e,e.borderRadius,n)}return null};fn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:vr}:{};fn.filterProps=["borderRadius"];xn(gc,yc,bc,vc,Sc,Cc,wc,jc,kc,zc,fn,Tc,Bc);const gn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Eo(e.theme,"spacing",8,"gap"),n=i=>({gap:Do(r,i)});return sr(e,e.gap,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{gap:vr}:{};gn.filterProps=["gap"];const yn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Eo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Do(r,i)});return sr(e,e.columnGap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:vr}:{};yn.filterProps=["columnGap"];const bn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Eo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Do(r,i)});return sr(e,e.rowGap,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:vr}:{};bn.filterProps=["rowGap"];const Ic=Ve({prop:"gridColumn"}),Ec=Ve({prop:"gridRow"}),Dc=Ve({prop:"gridAutoFlow"}),_c=Ve({prop:"gridAutoColumns"}),$c=Ve({prop:"gridAutoRows"}),Oc=Ve({prop:"gridTemplateColumns"}),Mc=Ve({prop:"gridTemplateRows"}),Wc=Ve({prop:"gridTemplateAreas"}),Ac=Ve({prop:"gridArea"});xn(gn,yn,bn,Ic,Ec,Dc,_c,$c,Oc,Mc,Wc,Ac);function no(e,r){return r==="grey"?r:e}const Rc=Ve({prop:"color",themeKey:"palette",transform:no}),Pc=Ve({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:no}),Nc=Ve({prop:"backgroundColor",themeKey:"palette",transform:no});xn(Rc,Pc,Nc);function yt(e){return e<=1&&e!==0?`${e*100}%`:e}const Lc=Ve({prop:"width",transform:yt}),gi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,u;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||un[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:yt(n)}};return sr(e,e.maxWidth,r)}return null};gi.filterProps=["maxWidth"];const Fc=Ve({prop:"minWidth",transform:yt}),Vc=Ve({prop:"height",transform:yt}),Hc=Ve({prop:"maxHeight",transform:yt}),Gc=Ve({prop:"minHeight",transform:yt});Ve({prop:"size",cssProperty:"width",transform:yt});Ve({prop:"size",cssProperty:"height",transform:yt});const Uc=Ve({prop:"boxSizing"});xn(Lc,gi,Fc,Vc,Hc,Gc,Uc);const vn={border:{themeKey:"borders",transform:zt},borderTop:{themeKey:"borders",transform:zt},borderRight:{themeKey:"borders",transform:zt},borderBottom:{themeKey:"borders",transform:zt},borderLeft:{themeKey:"borders",transform:zt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:zt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:fn},color:{themeKey:"palette",transform:no},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:no},backgroundColor:{themeKey:"palette",transform:no},p:{style:Le},pt:{style:Le},pr:{style:Le},pb:{style:Le},pl:{style:Le},px:{style:Le},py:{style:Le},padding:{style:Le},paddingTop:{style:Le},paddingRight:{style:Le},paddingBottom:{style:Le},paddingLeft:{style:Le},paddingX:{style:Le},paddingY:{style:Le},paddingInline:{style:Le},paddingInlineStart:{style:Le},paddingInlineEnd:{style:Le},paddingBlock:{style:Le},paddingBlockStart:{style:Le},paddingBlockEnd:{style:Le},m:{style:Ne},mt:{style:Ne},mr:{style:Ne},mb:{style:Ne},ml:{style:Ne},mx:{style:Ne},my:{style:Ne},margin:{style:Ne},marginTop:{style:Ne},marginRight:{style:Ne},marginBottom:{style:Ne},marginLeft:{style:Ne},marginX:{style:Ne},marginY:{style:Ne},marginInline:{style:Ne},marginInlineStart:{style:Ne},marginInlineEnd:{style:Ne},marginBlock:{style:Ne},marginBlockStart:{style:Ne},marginBlockEnd:{style:Ne},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:gn},rowGap:{style:bn},columnGap:{style:yn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:yt},maxWidth:{style:gi},minWidth:{transform:yt},height:{transform:yt},maxHeight:{transform:yt},minHeight:{transform:yt},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function Yc(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function qc(e,r){return typeof e=="function"?e(r):e}function Jc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:g,transform:f,style:m}=l;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[n]:i};const v=pn(s,g)||{};return m?m(c):sr(c,i,B=>{let b=nn(v,f,B);return B===b&&typeof B=="string"&&(b=nn(v,f,`${n}${B==="default"?"":Ws(B)}`,B)),u===!1?b:{[u]:b}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??vn;function l(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const f=cc(s.breakpoints),m=Object.keys(f);let v=f;return Object.keys(g).forEach(C=>{const B=qc(g[C],s);if(B!=null)if(typeof B=="object")if(c[C])v=zo(v,e(C,B,s,c));else{const b=sr({theme:s},B,y=>({[C]:y}));Yc(b,B)?v[C]=r({sx:B,theme:s,nested:!0}):v=zo(v,b)}else v=zo(v,e(C,B,s,c))}),!a&&s.modularCssLayers?{"@layer sx":qi(s,Ki(m,v))}:qi(s,Ki(m,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const Sn=Jc();Sn.filterProps=["sx"];function Kc(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Ps(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=oc(n),u=Rs(s);let g=bt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...ac,...a}},c);return g=sc(g),g.applyStyles=Kc,g=r.reduce((f,m)=>bt(f,m),g),g.unstable_sxConfig={...vn,...c==null?void 0:c.unstable_sxConfig},g.unstable_sx=function(m){return Sn({sx:m,theme:this})},g}function Xc(e){return Object.keys(e).length===0}function Qc(e=null){const r=an.useContext(ha.ThemeContext);return!r||Xc(r)?e:r}const Zc=Ps();function ed(e=Zc){return Qc(e)}const Qi=e=>e,td=()=>{let e=Qi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=Qi}}},rd=td(),od={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function nd(e,r,n="Mui"){const i=od[r];return i?`${n}-${i}`:`${rd.generate(e)}-${r}`}function id(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function yi(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),id(e,r,n)}function sd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function yr(e){if(e.type)return e;if(e.charAt(0)==="#")return yr(sd(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Er(9,e));let i=e.substring(r+1,e.length-1),s;if(n==="color"){if(i=i.split(" "),s=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Er(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const ad=e=>{const r=yr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},So=(e,r)=>{try{return ad(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Cn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Ns(e){e=yr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(g,f=(g+n/30)%12)=>s-a*Math.max(Math.min(f-3,9-f,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),Cn({type:l,values:u})}function ri(e){e=yr(e);let r=e.type==="hsl"||e.type==="hsla"?yr(Ns(e)).values:e.values;return r=r.map(n=>(e.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function Zi(e,r){const n=ri(e),i=ri(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function $(e,r){return e=yr(e),r=yi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Cn(e)}function Br(e,r,n){try{return $(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function wn(e,r){if(e=yr(e),r=yi(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return Cn(e)}function De(e,r,n){try{return wn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=yr(e),r=yi(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return Cn(e)}function _e(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function ld(e,r=.15){return ri(e)>.5?wn(e,r):jn(e,r)}function qo(e,r,n){try{return ld(e,r)}catch{return e}}function cd(e=""){function r(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const es=(e,r,n,i=[])=>{let s=e;r.forEach((a,c)=>{c===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},dd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...c,l]:c):r([...a,l],u,c))})}i(e)},ud=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function Kn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return dd(e,(l,u,g)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const f=`--${n?`${n}-`:""}${l.join("-")}`,m=ud(l,u);Object.assign(s,{[f]:m}),es(a,l,`var(${f})`,g),es(c,l,`var(${f}, ${m})`,g)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function pd(e,r={}){const{getSelector:n=z,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...g}=e,{vars:f,css:m,varsWithDefaults:v}=Kn(g,r);let C=v;const B={},{[u]:b,...y}=c;if(Object.entries(y||{}).forEach(([E,S])=>{const{vars:R,css:q,varsWithDefaults:T}=Kn(S,r);C=bt(C,T),B[E]={css:q,vars:R}}),b){const{css:E,vars:S,varsWithDefaults:R}=Kn(b,r);C=bt(C,R),B[u]={css:E,vars:S}}function z(E,S){var q,T;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),E){if(R==="media")return e.defaultColorScheme===E?":root":{[`@media (prefers-color-scheme: ${((T=(q=c[E])==null?void 0:q.palette)==null?void 0:T.mode)||E})`]:{":root":S}};if(R)return e.defaultColorScheme===E?`:root, ${R.replace("%s",String(E))}`:R.replace("%s",String(E))}return":root"}return{vars:C,generateThemeVars:()=>{let E={...f};return Object.entries(B).forEach(([,{vars:S}])=>{E=bt(E,S)}),E},generateStyleSheets:()=>{var F,X;const E=[],S=e.defaultColorScheme||"light";function R(W,h){Object.keys(h).length&&E.push(typeof W=="string"?{[W]:{...h}}:W)}R(n(void 0,{...m}),m);const{[S]:q,...T}=B;if(q){const{css:W}=q,h=(X=(F=c[S])==null?void 0:F.palette)==null?void 0:X.mode,I=!i&&h?{colorScheme:h,...W}:{...W};R(n(S,{...I}),I)}return Object.entries(T).forEach(([W,{css:h}])=>{var d,oe;const I=(oe=(d=c[W])==null?void 0:d.palette)==null?void 0:oe.mode,N=!i&&I?{colorScheme:I,...h}:{...h};R(n(W,{...N}),N)}),a&&E.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),E}}}function hd(e){return function(n){return e==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const Bo={black:"#000",white:"#fff"},md={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},Qr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Zr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},yo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},eo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},to={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},ro={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Ls(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Bo.white,default:Bo.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const Fs=Ls();function Vs(){return{text:{primary:Bo.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:Bo.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const oi=Vs();function ts(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=jn(e.main,s):r==="dark"&&(e.dark=wn(e.main,a)))}function rs(e,r,n,i,s){const a=s.light||s,c=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(c*100).toFixed(0)}%)`))}function xd(e="light"){return e==="dark"?{main:eo[200],light:eo[50],dark:eo[400]}:{main:eo[700],light:eo[400],dark:eo[800]}}function fd(e="light"){return e==="dark"?{main:Qr[200],light:Qr[50],dark:Qr[400]}:{main:Qr[500],light:Qr[300],dark:Qr[700]}}function gd(e="light"){return e==="dark"?{main:Zr[500],light:Zr[300],dark:Zr[700]}:{main:Zr[700],light:Zr[400],dark:Zr[800]}}function yd(e="light"){return e==="dark"?{main:to[400],light:to[300],dark:to[700]}:{main:to[700],light:to[500],dark:to[900]}}function bd(e="light"){return e==="dark"?{main:ro[400],light:ro[300],dark:ro[700]}:{main:ro[800],light:ro[500],dark:ro[900]}}function vd(e="light"){return e==="dark"?{main:yo[400],light:yo[300],dark:yo[700]}:{main:"#ed6c02",light:yo[500],dark:yo[900]}}function Sd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function bi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||xd(r),l=e.secondary||fd(r),u=e.error||gd(r),g=e.info||yd(r),f=e.success||bd(r),m=e.warning||vd(r);function v(y){if(s)return Sd(y);const z=Zi(y,oi.text.primary)>=n?oi.text.primary:Fs.text.primary;if(process.env.NODE_ENV!=="production"){const x=Zi(y,z);x<3&&console.error([`MUI: The contrast ratio of ${x}:1 for ${z} on ${y}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
147
+ `))}return z}const C=({color:y,name:z,mainShade:x=500,lightShade:j=300,darkShade:E=700})=>{if(y={...y},!y.main&&y[x]&&(y.main=y[x]),!y.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
148
+ The color object needs to have a \`main\` property or a \`${x}\` property.`:Er(11,z?` (${z})`:"",x));if(typeof y.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
149
+ \`color.main\` should be a string, but \`${JSON.stringify(y.main)}\` was provided instead.
150
150
 
151
151
  Did you intend to use one of the following approaches?
152
152
 
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
158
158
 
159
159
  const theme2 = createTheme({ palette: {
160
160
  primary: { main: green[500] },
161
- } });`:_r(12,b?` (${b})`:"",JSON.stringify(f.main)));return s?(ns(s,f,"light",T,i),ns(s,f,"dark",I,i)):(os(f,"light",T,i),os(f,"dark",I,i)),f.contrastText||(f.contrastText=v(f.main)),f};let B;return r==="light"?B=Vs():r==="dark"&&(B=Us()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),gt({common:{...Do},mode:r,primary:w({color:c,name:"primary"}),secondary:w({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:w({color:u,name:"error"}),warning:w({color:h,name:"warning"}),info:w({color:x,name:"info"}),success:w({color:m,name:"success"}),grey:xd,contrastThreshold:n,getContrastText:v,augmentColor:w,tonalOffset:i,...B},a)}function jd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function kd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function zd(e){return Math.round(e*1e5)/1e5}const is={textTransform:"uppercase"},ss='"Roboto", "Helvetica", "Arial", sans-serif';function Td(e,r){const{fontFamily:n=ss,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:x,pxToRem:m,...h}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const v=i/14,w=m||(f=>`${f/u*v}rem`),B=(f,b,g,T,I)=>({fontFamily:n,fontWeight:f,fontSize:w(b),lineHeight:g,...n===ss?{letterSpacing:`${zd(T/b)}em`}:{},...I,...x}),S={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(a,48,1.167,0),h4:B(a,34,1.235,.25),h5:B(a,24,1.334,0),h6:B(c,20,1.6,.15),subtitle1:B(a,16,1.75,.15),subtitle2:B(c,14,1.57,.1),body1:B(a,16,1.5,.15),body2:B(a,14,1.43,.15),button:B(c,14,1.75,.4,is),caption:B(a,12,1.66,.4),overline:B(a,12,2.66,1,is),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return gt({htmlFontSize:u,pxToRem:w,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...S},h,{clone:!1})}const Bd=.2,Id=.14,Ed=.12;function Ae(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Bd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Id})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Ed})`].join(",")}const Dd=["none",Ae(0,2,1,-1,0,1,1,0,0,1,3,0),Ae(0,3,1,-2,0,2,2,0,0,1,5,0),Ae(0,3,3,-2,0,3,4,0,0,1,8,0),Ae(0,2,4,-1,0,4,5,0,0,1,10,0),Ae(0,3,5,-1,0,5,8,0,0,1,14,0),Ae(0,3,5,-1,0,6,10,0,0,1,18,0),Ae(0,4,5,-2,0,7,10,1,0,2,16,1),Ae(0,5,5,-3,0,8,10,1,0,3,14,2),Ae(0,5,6,-3,0,9,12,1,0,3,16,2),Ae(0,6,6,-3,0,10,14,1,0,4,18,3),Ae(0,6,7,-4,0,11,15,1,0,4,20,3),Ae(0,7,8,-4,0,12,17,2,0,5,22,4),Ae(0,7,8,-4,0,13,19,2,0,5,24,4),Ae(0,7,9,-4,0,14,21,2,0,5,26,4),Ae(0,8,9,-5,0,15,22,2,0,6,28,5),Ae(0,8,10,-5,0,16,24,2,0,6,30,5),Ae(0,8,11,-5,0,17,26,2,0,6,32,5),Ae(0,9,11,-5,0,18,28,2,0,7,34,6),Ae(0,9,12,-6,0,19,29,2,0,7,36,6),Ae(0,10,13,-6,0,20,31,3,0,8,38,7),Ae(0,10,13,-6,0,21,33,3,0,8,40,7),Ae(0,10,14,-6,0,22,35,3,0,8,42,7),Ae(0,11,14,-7,0,23,36,3,0,9,44,8),Ae(0,11,15,-7,0,24,38,3,0,9,46,8)],_d={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},$d={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function as(e){return`${Math.round(e)}ms`}function Od(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Md(e){const r={..._d,...e.easing},n={...$d,...e.duration};return{getAutoHeightDuration:Od,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:u=0,...x}=a;if(process.env.NODE_ENV!=="production"){const m=v=>typeof v=="string",h=v=>!Number.isNaN(parseFloat(v));!m(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!h(c)&&!m(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),m(l)||console.error('MUI: Argument "easing" must be a string.'),!h(u)&&!m(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
162
- `)),Object.keys(x).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(x).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(m=>`${m} ${typeof c=="string"?c:as(c)} ${l} ${typeof u=="string"?u:as(u)}`).join(",")},...e,easing:r,duration:n}}const Ad={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Wd(e){return fr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Gs(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[c,l]=s[a];!Wd(l)||c.startsWith("unstable_")?delete i[c]:fr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
161
+ } });`:Er(12,z?` (${z})`:"",JSON.stringify(y.main)));return s?(rs(s,y,"light",j,i),rs(s,y,"dark",E,i)):(ts(y,"light",j,i),ts(y,"dark",E,i)),y.contrastText||(y.contrastText=v(y.main)),y};let B;return r==="light"?B=Ls():r==="dark"&&(B=Vs()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),bt({common:{...Bo},mode:r,primary:C({color:c,name:"primary"}),secondary:C({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:C({color:u,name:"error"}),warning:C({color:m,name:"warning"}),info:C({color:g,name:"info"}),success:C({color:f,name:"success"}),grey:md,contrastThreshold:n,getContrastText:v,augmentColor:C,tonalOffset:i,...B},a)}function Cd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function wd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function jd(e){return Math.round(e*1e5)/1e5}const os={textTransform:"uppercase"},ns='"Roboto", "Helvetica", "Arial", sans-serif';function kd(e,r){const{fontFamily:n=ns,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:g,pxToRem:f,...m}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const v=i/14,C=f||(y=>`${y/u*v}rem`),B=(y,z,x,j,E)=>({fontFamily:n,fontWeight:y,fontSize:C(z),lineHeight:x,...n===ns?{letterSpacing:`${jd(j/z)}em`}:{},...E,...g}),b={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(a,48,1.167,0),h4:B(a,34,1.235,.25),h5:B(a,24,1.334,0),h6:B(c,20,1.6,.15),subtitle1:B(a,16,1.75,.15),subtitle2:B(c,14,1.57,.1),body1:B(a,16,1.5,.15),body2:B(a,14,1.43,.15),button:B(c,14,1.75,.4,os),caption:B(a,12,1.66,.4),overline:B(a,12,2.66,1,os),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return bt({htmlFontSize:u,pxToRem:C,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...b},m,{clone:!1})}const zd=.2,Td=.14,Bd=.12;function Ae(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${zd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Td})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Bd})`].join(",")}const Id=["none",Ae(0,2,1,-1,0,1,1,0,0,1,3,0),Ae(0,3,1,-2,0,2,2,0,0,1,5,0),Ae(0,3,3,-2,0,3,4,0,0,1,8,0),Ae(0,2,4,-1,0,4,5,0,0,1,10,0),Ae(0,3,5,-1,0,5,8,0,0,1,14,0),Ae(0,3,5,-1,0,6,10,0,0,1,18,0),Ae(0,4,5,-2,0,7,10,1,0,2,16,1),Ae(0,5,5,-3,0,8,10,1,0,3,14,2),Ae(0,5,6,-3,0,9,12,1,0,3,16,2),Ae(0,6,6,-3,0,10,14,1,0,4,18,3),Ae(0,6,7,-4,0,11,15,1,0,4,20,3),Ae(0,7,8,-4,0,12,17,2,0,5,22,4),Ae(0,7,8,-4,0,13,19,2,0,5,24,4),Ae(0,7,9,-4,0,14,21,2,0,5,26,4),Ae(0,8,9,-5,0,15,22,2,0,6,28,5),Ae(0,8,10,-5,0,16,24,2,0,6,30,5),Ae(0,8,11,-5,0,17,26,2,0,6,32,5),Ae(0,9,11,-5,0,18,28,2,0,7,34,6),Ae(0,9,12,-6,0,19,29,2,0,7,36,6),Ae(0,10,13,-6,0,20,31,3,0,8,38,7),Ae(0,10,13,-6,0,21,33,3,0,8,40,7),Ae(0,10,14,-6,0,22,35,3,0,8,42,7),Ae(0,11,14,-7,0,23,36,3,0,9,44,8),Ae(0,11,15,-7,0,24,38,3,0,9,46,8)],Ed={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},Dd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function is(e){return`${Math.round(e)}ms`}function _d(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function $d(e){const r={...Ed,...e.easing},n={...Dd,...e.duration};return{getAutoHeightDuration:_d,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:u=0,...g}=a;if(process.env.NODE_ENV!=="production"){const f=v=>typeof v=="string",m=v=>!Number.isNaN(parseFloat(v));!f(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!m(c)&&!f(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),f(l)||console.error('MUI: Argument "easing" must be a string.'),!m(u)&&!f(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
162
+ `)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(f=>`${f} ${typeof c=="string"?c:is(c)} ${l} ${typeof u=="string"?u:is(u)}`).join(",")},...e,easing:r,duration:n}}const Od={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Md(e){return fr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Hs(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[c,l]=s[a];!Md(l)||c.startsWith("unstable_")?delete i[c]:fr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
163
163
 
164
164
  const theme = ${JSON.stringify(r,null,2)};
165
165
 
166
166
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
167
167
  theme.transitions = createTransitions(theme.transitions || {});
168
168
 
169
- export default theme;`}function ls(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Rd=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function Pd(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:_(r,Rd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ls(n)})`:kn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ls(n)})`:jn(r,n)}})}function ni(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:u,colorSpace:x,...m}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":_r(20));const h=bi({...a,colorSpace:x}),v=Ls(e);let w=gt(v,{mixins:kd(v.breakpoints,i),palette:h,shadows:Dd.slice(),typography:Td(h,l),transitions:Md(c),zIndex:{...Ad}});if(w=gt(w,m),w=r.reduce((B,S)=>gt(B,S),w),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],S=(f,b)=>{let g;for(g in f){const T=f[g];if(B.includes(g)&&Object.keys(T).length>0){if(process.env.NODE_ENV!=="production"){const I=sd("",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(f,null,2),"",`Instead, you need to use the '&.${I}' syntax:`,JSON.stringify({root:{[`&.${I}`]:T}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
- `))}f[g]={}}}};Object.keys(w.components).forEach(f=>{const b=w.components[f].styleOverrides;b&&f.startsWith("Mui")&&S(b,f)})}return w.unstable_sxConfig={...Sn,...m==null?void 0:m.unstable_sxConfig},w.unstable_sx=function(S){return Cn({sx:S,theme:this})},w.toRuntimeSource=Gs,Pd(w),w}function Nd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const Ld=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Nd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ys(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function qs(e){return e==="dark"?Ld:[]}function Fd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=bi({...r,colorSpace:s});return{palette:c,opacity:{...Ys(c.mode),...n},overlays:i||qs(c.mode),...a}}function Vd(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Hd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Ud=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const c={};return Hd(e.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:a?{[a.replace("%s",r)]:c,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...c}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Gd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function F(e,r,n){!e[r]&&n&&(e[r]=n)}function ko(e){return typeof e!="string"||!e.startsWith("hsl")?e:Fs(e)}function nr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=jo(ko(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
- To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function Yd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Lt=e=>{try{return e()}catch{}},qd=(e="mui")=>ud(e);function Xn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Fd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ni({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Ys(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||qs(a)},l}function Jd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Vd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...m}=e,h=Object.keys(n)[0],v=i||(n.light&&h!=="light"?"light":h),w=qd(a),{[v]:B,light:S,dark:f,...b}=n,g={...b};let T=B;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(T=!0),!T)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:_r(21,v));let I;c&&(I="oklch");const C=Xn(I,g,T,m,v);S&&!g.light&&Xn(I,g,S,void 0,"light"),f&&!g.dark&&Xn(I,g,f,void 0,"dark");let W={defaultColorScheme:v,...C,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:x,getCssVar:w,colorSchemes:g,font:{...jd(C.typography),...C.font},spacing:Yd(m.spacing)};Object.keys(W.colorSchemes).forEach(M=>{const y=W.colorSchemes[M].palette,k=oe=>{const d=oe.split("-"),J=d[1],ee=d[2];return w(oe,y[J][ee])};y.mode==="light"&&(F(y.common,"background","#fff"),F(y.common,"onBackground","#000")),y.mode==="dark"&&(F(y.common,"background","#000"),F(y.common,"onBackground","#fff"));function P(oe,d,J){if(I){let ee;return oe===Er&&(ee=`transparent ${((1-J)*100).toFixed(0)}%`),oe===De&&(ee=`#000 ${(J*100).toFixed(0)}%`),oe===_e&&(ee=`#fff ${(J*100).toFixed(0)}%`),`color-mix(in ${I}, ${d}, ${ee})`}return oe(d,J)}if(Gd(y,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),y.mode==="light"){F(y.Alert,"errorColor",P(De,y.error.light,.6)),F(y.Alert,"infoColor",P(De,y.info.light,.6)),F(y.Alert,"successColor",P(De,y.success.light,.6)),F(y.Alert,"warningColor",P(De,y.warning.light,.6)),F(y.Alert,"errorFilledBg",k("palette-error-main")),F(y.Alert,"infoFilledBg",k("palette-info-main")),F(y.Alert,"successFilledBg",k("palette-success-main")),F(y.Alert,"warningFilledBg",k("palette-warning-main")),F(y.Alert,"errorFilledColor",Lt(()=>y.getContrastText(y.error.main))),F(y.Alert,"infoFilledColor",Lt(()=>y.getContrastText(y.info.main))),F(y.Alert,"successFilledColor",Lt(()=>y.getContrastText(y.success.main))),F(y.Alert,"warningFilledColor",Lt(()=>y.getContrastText(y.warning.main))),F(y.Alert,"errorStandardBg",P(_e,y.error.light,.9)),F(y.Alert,"infoStandardBg",P(_e,y.info.light,.9)),F(y.Alert,"successStandardBg",P(_e,y.success.light,.9)),F(y.Alert,"warningStandardBg",P(_e,y.warning.light,.9)),F(y.Alert,"errorIconColor",k("palette-error-main")),F(y.Alert,"infoIconColor",k("palette-info-main")),F(y.Alert,"successIconColor",k("palette-success-main")),F(y.Alert,"warningIconColor",k("palette-warning-main")),F(y.AppBar,"defaultBg",k("palette-grey-100")),F(y.Avatar,"defaultBg",k("palette-grey-400")),F(y.Button,"inheritContainedBg",k("palette-grey-300")),F(y.Button,"inheritContainedHoverBg",k("palette-grey-A100")),F(y.Chip,"defaultBorder",k("palette-grey-400")),F(y.Chip,"defaultAvatarColor",k("palette-grey-700")),F(y.Chip,"defaultIconColor",k("palette-grey-700")),F(y.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),F(y.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),F(y.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),F(y.LinearProgress,"primaryBg",P(_e,y.primary.main,.62)),F(y.LinearProgress,"secondaryBg",P(_e,y.secondary.main,.62)),F(y.LinearProgress,"errorBg",P(_e,y.error.main,.62)),F(y.LinearProgress,"infoBg",P(_e,y.info.main,.62)),F(y.LinearProgress,"successBg",P(_e,y.success.main,.62)),F(y.LinearProgress,"warningBg",P(_e,y.warning.main,.62)),F(y.Skeleton,"bg",I?P(Er,y.text.primary,.11):`rgba(${k("palette-text-primaryChannel")} / 0.11)`),F(y.Slider,"primaryTrack",P(_e,y.primary.main,.62)),F(y.Slider,"secondaryTrack",P(_e,y.secondary.main,.62)),F(y.Slider,"errorTrack",P(_e,y.error.main,.62)),F(y.Slider,"infoTrack",P(_e,y.info.main,.62)),F(y.Slider,"successTrack",P(_e,y.success.main,.62)),F(y.Slider,"warningTrack",P(_e,y.warning.main,.62));const oe=I?P(De,y.background.default,.6825):Jo(y.background.default,.8);F(y.SnackbarContent,"bg",oe),F(y.SnackbarContent,"color",Lt(()=>I?oi.text.primary:y.getContrastText(oe))),F(y.SpeedDialAction,"fabHoverBg",Jo(y.background.paper,.15)),F(y.StepConnector,"border",k("palette-grey-400")),F(y.StepContent,"border",k("palette-grey-400")),F(y.Switch,"defaultColor",k("palette-common-white")),F(y.Switch,"defaultDisabledColor",k("palette-grey-100")),F(y.Switch,"primaryDisabledColor",P(_e,y.primary.main,.62)),F(y.Switch,"secondaryDisabledColor",P(_e,y.secondary.main,.62)),F(y.Switch,"errorDisabledColor",P(_e,y.error.main,.62)),F(y.Switch,"infoDisabledColor",P(_e,y.info.main,.62)),F(y.Switch,"successDisabledColor",P(_e,y.success.main,.62)),F(y.Switch,"warningDisabledColor",P(_e,y.warning.main,.62)),F(y.TableCell,"border",P(_e,P(Er,y.divider,1),.88)),F(y.Tooltip,"bg",P(Er,y.grey[700],.92))}if(y.mode==="dark"){F(y.Alert,"errorColor",P(_e,y.error.light,.6)),F(y.Alert,"infoColor",P(_e,y.info.light,.6)),F(y.Alert,"successColor",P(_e,y.success.light,.6)),F(y.Alert,"warningColor",P(_e,y.warning.light,.6)),F(y.Alert,"errorFilledBg",k("palette-error-dark")),F(y.Alert,"infoFilledBg",k("palette-info-dark")),F(y.Alert,"successFilledBg",k("palette-success-dark")),F(y.Alert,"warningFilledBg",k("palette-warning-dark")),F(y.Alert,"errorFilledColor",Lt(()=>y.getContrastText(y.error.dark))),F(y.Alert,"infoFilledColor",Lt(()=>y.getContrastText(y.info.dark))),F(y.Alert,"successFilledColor",Lt(()=>y.getContrastText(y.success.dark))),F(y.Alert,"warningFilledColor",Lt(()=>y.getContrastText(y.warning.dark))),F(y.Alert,"errorStandardBg",P(De,y.error.light,.9)),F(y.Alert,"infoStandardBg",P(De,y.info.light,.9)),F(y.Alert,"successStandardBg",P(De,y.success.light,.9)),F(y.Alert,"warningStandardBg",P(De,y.warning.light,.9)),F(y.Alert,"errorIconColor",k("palette-error-main")),F(y.Alert,"infoIconColor",k("palette-info-main")),F(y.Alert,"successIconColor",k("palette-success-main")),F(y.Alert,"warningIconColor",k("palette-warning-main")),F(y.AppBar,"defaultBg",k("palette-grey-900")),F(y.AppBar,"darkBg",k("palette-background-paper")),F(y.AppBar,"darkColor",k("palette-text-primary")),F(y.Avatar,"defaultBg",k("palette-grey-600")),F(y.Button,"inheritContainedBg",k("palette-grey-800")),F(y.Button,"inheritContainedHoverBg",k("palette-grey-700")),F(y.Chip,"defaultBorder",k("palette-grey-700")),F(y.Chip,"defaultAvatarColor",k("palette-grey-300")),F(y.Chip,"defaultIconColor",k("palette-grey-300")),F(y.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),F(y.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),F(y.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),F(y.LinearProgress,"primaryBg",P(De,y.primary.main,.5)),F(y.LinearProgress,"secondaryBg",P(De,y.secondary.main,.5)),F(y.LinearProgress,"errorBg",P(De,y.error.main,.5)),F(y.LinearProgress,"infoBg",P(De,y.info.main,.5)),F(y.LinearProgress,"successBg",P(De,y.success.main,.5)),F(y.LinearProgress,"warningBg",P(De,y.warning.main,.5)),F(y.Skeleton,"bg",I?P(Er,y.text.primary,.13):`rgba(${k("palette-text-primaryChannel")} / 0.13)`),F(y.Slider,"primaryTrack",P(De,y.primary.main,.5)),F(y.Slider,"secondaryTrack",P(De,y.secondary.main,.5)),F(y.Slider,"errorTrack",P(De,y.error.main,.5)),F(y.Slider,"infoTrack",P(De,y.info.main,.5)),F(y.Slider,"successTrack",P(De,y.success.main,.5)),F(y.Slider,"warningTrack",P(De,y.warning.main,.5));const oe=I?P(_e,y.background.default,.985):Jo(y.background.default,.98);F(y.SnackbarContent,"bg",oe),F(y.SnackbarContent,"color",Lt(()=>I?Hs.text.primary:y.getContrastText(oe))),F(y.SpeedDialAction,"fabHoverBg",Jo(y.background.paper,.15)),F(y.StepConnector,"border",k("palette-grey-600")),F(y.StepContent,"border",k("palette-grey-600")),F(y.Switch,"defaultColor",k("palette-grey-300")),F(y.Switch,"defaultDisabledColor",k("palette-grey-600")),F(y.Switch,"primaryDisabledColor",P(De,y.primary.main,.55)),F(y.Switch,"secondaryDisabledColor",P(De,y.secondary.main,.55)),F(y.Switch,"errorDisabledColor",P(De,y.error.main,.55)),F(y.Switch,"infoDisabledColor",P(De,y.info.main,.55)),F(y.Switch,"successDisabledColor",P(De,y.success.main,.55)),F(y.Switch,"warningDisabledColor",P(De,y.warning.main,.55)),F(y.TableCell,"border",P(De,P(Er,y.divider,1),.68)),F(y.Tooltip,"bg",P(Er,y.grey[700],.92))}nr(y.background,"default"),nr(y.background,"paper"),nr(y.common,"background"),nr(y.common,"onBackground"),nr(y,"divider"),Object.keys(y).forEach(oe=>{const d=y[oe];oe!=="tonalOffset"&&d&&typeof d=="object"&&(d.main&&F(y[oe],"mainChannel",jo(ko(d.main))),d.light&&F(y[oe],"lightChannel",jo(ko(d.light))),d.dark&&F(y[oe],"darkChannel",jo(ko(d.dark))),d.contrastText&&F(y[oe],"contrastTextChannel",jo(ko(d.contrastText))),oe==="text"&&(nr(y[oe],"primary"),nr(y[oe],"secondary")),oe==="action"&&(d.active&&nr(y[oe],"active"),d.selected&&nr(y[oe],"selected")))})}),W=r.reduce((M,y)=>gt(M,y),W);const K={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Ud(W),enableContrastVars:c},{vars:E,generateThemeVars:U,generateStyleSheets:G}=fd(W,K);return W.vars=E,Object.entries(W.colorSchemes[W.defaultColorScheme]).forEach(([M,y])=>{W[M]=y}),W.generateThemeVars=U,W.generateStyleSheets=G,W.generateSpacing=function(){return Ns(m.spacing,xi(this))},W.getColorSchemeSelector=md(u),W.spacing=W.generateSpacing(),W.shouldSkipGeneratingVar=l,W.unstable_sxConfig={...Sn,...m==null?void 0:m.unstable_sxConfig},W.unstable_sx=function(y){return Cn({sx:y,theme:this})},W.toRuntimeSource=Gs,W}function cs(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:bi({...n===!0?{}:n.palette,mode:r})})}function Kd(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...c}=e,l=a||"light",u=s==null?void 0:s[l],x={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ni(e,...r);let m=n;"palette"in e||x[l]&&(x[l]!==!0?m=x[l].palette:l==="dark"&&(m={mode:"dark"}));const h=ni({...e,palette:m},...r);return h.defaultColorScheme=l,h.colorSchemes=x,h.palette.mode==="light"&&(h.colorSchemes.light={...x.light!==!0&&x.light,palette:h.palette},cs(h,"dark",x.dark)),h.palette.mode==="dark"&&(h.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:h.palette},cs(h,"light",x.light)),h}return!n&&!("light"in x)&&l==="light"&&(x.light=!0),Jd({...c,colorSchemes:x,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Xd=Kd();function ct(){const e=rd(Xd);return process.env.NODE_ENV!=="production"&&ln.useDebugValue(e),e[Ul]||e}async function Qd(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(e,{headers:i,signal:s.signal})}catch(x){throw clearTimeout(a),(x==null?void 0:x.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(l))u=l;else if(n&&l[n]&&Array.isArray(l[n]))u=l[n];else{const m=["data","results","items","records"].find(h=>l[h]&&Array.isArray(l[h]));if(m)u=l[m];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function Zd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${_(e.palette.common.black,n.opacity)}`).join(", ")}const eu={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function ge(e,r){return Zd(e,eu[r])}function rt(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Mo(e){return`${Number(e.shape.borderRadius)}px`}function ds(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function at(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${_(n,.08)})`,hoverBg:`var(--highlight-hover, ${_(n,.12)})`}}function ue(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ge(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function tu({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=p.useState(""),[l,u]=p.useState(!1),[x,m]=p.useState(""),[h,v]=p.useState(null),[w,B]=p.useState(null),[S,f]=p.useState(!1),[b,g]=p.useState(""),T=p.useRef(null),[I,C]=p.useState("json"),[W,K]=p.useState(""),[E,U]=p.useState(""),[G,M]=p.useState(""),[y,k]=p.useState("idle"),[P,oe]=p.useState(""),[d,J]=p.useState(null),[ee,Se]=p.useState(0),V=async R=>{if(g(""),!R.name.endsWith(".json")){g("Only .json files are allowed");return}const L=10*1024*1024;if(R.size>L){g("File size exceeds 10MB limit");return}try{const de=await R.text();let he;try{he=JSON.parse(de)}catch{g("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(he)){g("JSON must be an array of objects");return}if(he.length===0){g("No data rows found in JSON file");return}v(R),B(he)}catch{g("Network error — please try again")}},X=R=>{R.preventDefault();const L=R.dataTransfer.files[0];L&&V(L)},pe=async()=>{if(W.trim()){k("loading"),oe("");try{const R=await Qd(W.trim(),E.trim()||void 0,G.trim()||void 0);J(R.data),Se(R.data.length),k("ready")}catch(R){oe((R==null?void 0:R.message)||"Connection failed"),k("error")}}},ce=()=>{if(!a.trim()){u(!0);return}const R=I==="api"?d:i||w;R&&(n(a.trim(),x.trim(),R),ie())},ie=()=>{c(""),u(!1),m(""),v(null),B(null),g(""),C("json"),K(""),U(""),M(""),k("idle"),oe(""),J(null),Se(0),r()},te=i||w,se=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ie,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:R=>({borderRadius:rt(R),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ue(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:L=>L.typography.h6.fontWeight||500,fontSize:L=>L.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...ue(R).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:ie,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:R=>{c(R.target.value),l&&R.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:se,helperText:se?"Report name is required":void 0,inputProps:{maxLength:255},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:x,onChange:R=>m(R.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsxs(o.Tabs,{value:I==="json"?0:1,onChange:(R,L)=>{C(L===0?"json":"api"),k("idle"),oe("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx($.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:R=>`var(--highlight-hover, ${_(R.palette.primary.main,.15)})`},"&:hover":{bgcolor:R=>`var(--highlight-hover, ${_(R.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx($.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:R=>`var(--highlight-hover, ${_(R.palette.primary.main,.15)})`},"&:hover":{bgcolor:R=>`var(--highlight-hover, ${_(R.palette.primary.main,.08)})`}}})]}),I==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:R=>_(R.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:R=>_(R.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>f(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:X,onDragOver:R=>R.preventDefault(),onPaste:R=>R.preventDefault(),onClick:()=>{var R;return(R=T.current)==null?void 0:R.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?R=>_(R.palette.success.main,.04):b?R=>_(R.palette.error.main,.04):R=>_(R.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:w?R=>_(R.palette.success.main,.08):b?R=>_(R.palette.error.main,.08):R=>_(R.palette.primary.main,.08),borderColor:w?"success.dark":b?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:T,type:"file",accept:".json",sx:{display:"none"},onChange:R=>{var L;return((L=R.target.files)==null?void 0:L[0])&&V(R.target.files[0])}}),w?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:R=>_(R.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx($.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:h==null?void 0:h.name}),t.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:R=>_(R.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx($.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),b&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:R=>_(R.palette.error.main,.08),border:1,borderColor:R=>_(R.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:b})})]})]})]})}),I==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:W,onChange:R=>{K(R.target.value),k("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:E,onChange:R=>U(R.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx($.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:G,onChange:R=>M(R.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!W.trim()||y==="loading",onClick:pe,startIcon:y==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx($.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:R=>_(R.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:y==="loading"?"Connecting...":"Test Connection & Load Data"}),y==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:R=>_(R.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[ee.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:W})]})]}),y==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:R=>_(R.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:P})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ie,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:R=>`${R.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:R=>_(R.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:ce,disabled:I==="json"&&!te||I==="api"&&y!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:R=>`${R.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:S,onClose:()=>f(!1),maxWidth:"sm",PaperProps:{sx:R=>({borderRadius:3,width:560,maxHeight:"80vh",...ue(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ue(R).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>f(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
169
+ export default theme;`}function ss(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Wd=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function Ad(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:$(r,Wd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ss(n)})`:jn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ss(n)})`:wn(r,n)}})}function ni(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:u,colorSpace:g,...f}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Er(20));const m=bi({...a,colorSpace:g}),v=Ps(e);let C=bt(v,{mixins:wd(v.breakpoints,i),palette:m,shadows:Id.slice(),typography:kd(m,l),transitions:$d(c),zIndex:{...Od}});if(C=bt(C,f),C=r.reduce((B,b)=>bt(B,b),C),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],b=(y,z)=>{let x;for(x in y){const j=y[x];if(B.includes(x)&&Object.keys(j).length>0){if(process.env.NODE_ENV!=="production"){const E=nd("",x);console.error([`MUI: The \`${z}\` component increases the CSS specificity of the \`${x}\` internal state.`,"You can not override it like this: ",JSON.stringify(y,null,2),"",`Instead, you need to use the '&.${E}' syntax:`,JSON.stringify({root:{[`&.${E}`]:j}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
+ `))}y[x]={}}}};Object.keys(C.components).forEach(y=>{const z=C.components[y].styleOverrides;z&&y.startsWith("Mui")&&b(z,y)})}return C.unstable_sxConfig={...vn,...f==null?void 0:f.unstable_sxConfig},C.unstable_sx=function(b){return Sn({sx:b,theme:this})},C.toRuntimeSource=Hs,Ad(C),C}function Rd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const Pd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Rd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Gs(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function Us(e){return e==="dark"?Pd:[]}function Nd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=bi({...r,colorSpace:s});return{palette:c,opacity:{...Gs(c.mode),...n},overlays:i||Us(c.mode),...a}}function Ld(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Fd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Vd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const c={};return Fd(e.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:a?{[a.replace("%s",r)]:c,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...c}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Hd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function Co(e){return typeof e!="string"||!e.startsWith("hsl")?e:Ns(e)}function nr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=So(Co(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
+ To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function Gd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Ht=e=>{try{return e()}catch{}},Ud=(e="mui")=>cd(e);function Xn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Nd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ni({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Gs(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Us(a)},l}function Yd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Ld,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:g=":root",...f}=e,m=Object.keys(n)[0],v=i||(n.light&&m!=="light"?"light":m),C=Ud(a),{[v]:B,light:b,dark:y,...z}=n,x={...z};let j=B;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(j=!0),!j)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:Er(21,v));let E;c&&(E="oklch");const S=Xn(E,x,j,f,v);b&&!x.light&&Xn(E,x,b,void 0,"light"),y&&!x.dark&&Xn(E,x,y,void 0,"dark");let R={defaultColorScheme:v,...S,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:C,colorSchemes:x,font:{...Cd(S.typography),...S.font},spacing:Gd(f.spacing)};Object.keys(R.colorSchemes).forEach(W=>{const h=R.colorSchemes[W].palette,I=d=>{const oe=d.split("-"),G=oe[1],te=oe[2];return C(d,h[G][te])};h.mode==="light"&&(L(h.common,"background","#fff"),L(h.common,"onBackground","#000")),h.mode==="dark"&&(L(h.common,"background","#000"),L(h.common,"onBackground","#fff"));function N(d,oe,G){if(E){let te;return d===Br&&(te=`transparent ${((1-G)*100).toFixed(0)}%`),d===De&&(te=`#000 ${(G*100).toFixed(0)}%`),d===_e&&(te=`#fff ${(G*100).toFixed(0)}%`),`color-mix(in ${E}, ${oe}, ${te})`}return d(oe,G)}if(Hd(h,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),h.mode==="light"){L(h.Alert,"errorColor",N(De,h.error.light,.6)),L(h.Alert,"infoColor",N(De,h.info.light,.6)),L(h.Alert,"successColor",N(De,h.success.light,.6)),L(h.Alert,"warningColor",N(De,h.warning.light,.6)),L(h.Alert,"errorFilledBg",I("palette-error-main")),L(h.Alert,"infoFilledBg",I("palette-info-main")),L(h.Alert,"successFilledBg",I("palette-success-main")),L(h.Alert,"warningFilledBg",I("palette-warning-main")),L(h.Alert,"errorFilledColor",Ht(()=>h.getContrastText(h.error.main))),L(h.Alert,"infoFilledColor",Ht(()=>h.getContrastText(h.info.main))),L(h.Alert,"successFilledColor",Ht(()=>h.getContrastText(h.success.main))),L(h.Alert,"warningFilledColor",Ht(()=>h.getContrastText(h.warning.main))),L(h.Alert,"errorStandardBg",N(_e,h.error.light,.9)),L(h.Alert,"infoStandardBg",N(_e,h.info.light,.9)),L(h.Alert,"successStandardBg",N(_e,h.success.light,.9)),L(h.Alert,"warningStandardBg",N(_e,h.warning.light,.9)),L(h.Alert,"errorIconColor",I("palette-error-main")),L(h.Alert,"infoIconColor",I("palette-info-main")),L(h.Alert,"successIconColor",I("palette-success-main")),L(h.Alert,"warningIconColor",I("palette-warning-main")),L(h.AppBar,"defaultBg",I("palette-grey-100")),L(h.Avatar,"defaultBg",I("palette-grey-400")),L(h.Button,"inheritContainedBg",I("palette-grey-300")),L(h.Button,"inheritContainedHoverBg",I("palette-grey-A100")),L(h.Chip,"defaultBorder",I("palette-grey-400")),L(h.Chip,"defaultAvatarColor",I("palette-grey-700")),L(h.Chip,"defaultIconColor",I("palette-grey-700")),L(h.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(h.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(h.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(h.LinearProgress,"primaryBg",N(_e,h.primary.main,.62)),L(h.LinearProgress,"secondaryBg",N(_e,h.secondary.main,.62)),L(h.LinearProgress,"errorBg",N(_e,h.error.main,.62)),L(h.LinearProgress,"infoBg",N(_e,h.info.main,.62)),L(h.LinearProgress,"successBg",N(_e,h.success.main,.62)),L(h.LinearProgress,"warningBg",N(_e,h.warning.main,.62)),L(h.Skeleton,"bg",E?N(Br,h.text.primary,.11):`rgba(${I("palette-text-primaryChannel")} / 0.11)`),L(h.Slider,"primaryTrack",N(_e,h.primary.main,.62)),L(h.Slider,"secondaryTrack",N(_e,h.secondary.main,.62)),L(h.Slider,"errorTrack",N(_e,h.error.main,.62)),L(h.Slider,"infoTrack",N(_e,h.info.main,.62)),L(h.Slider,"successTrack",N(_e,h.success.main,.62)),L(h.Slider,"warningTrack",N(_e,h.warning.main,.62));const d=E?N(De,h.background.default,.6825):qo(h.background.default,.8);L(h.SnackbarContent,"bg",d),L(h.SnackbarContent,"color",Ht(()=>E?oi.text.primary:h.getContrastText(d))),L(h.SpeedDialAction,"fabHoverBg",qo(h.background.paper,.15)),L(h.StepConnector,"border",I("palette-grey-400")),L(h.StepContent,"border",I("palette-grey-400")),L(h.Switch,"defaultColor",I("palette-common-white")),L(h.Switch,"defaultDisabledColor",I("palette-grey-100")),L(h.Switch,"primaryDisabledColor",N(_e,h.primary.main,.62)),L(h.Switch,"secondaryDisabledColor",N(_e,h.secondary.main,.62)),L(h.Switch,"errorDisabledColor",N(_e,h.error.main,.62)),L(h.Switch,"infoDisabledColor",N(_e,h.info.main,.62)),L(h.Switch,"successDisabledColor",N(_e,h.success.main,.62)),L(h.Switch,"warningDisabledColor",N(_e,h.warning.main,.62)),L(h.TableCell,"border",N(_e,N(Br,h.divider,1),.88)),L(h.Tooltip,"bg",N(Br,h.grey[700],.92))}if(h.mode==="dark"){L(h.Alert,"errorColor",N(_e,h.error.light,.6)),L(h.Alert,"infoColor",N(_e,h.info.light,.6)),L(h.Alert,"successColor",N(_e,h.success.light,.6)),L(h.Alert,"warningColor",N(_e,h.warning.light,.6)),L(h.Alert,"errorFilledBg",I("palette-error-dark")),L(h.Alert,"infoFilledBg",I("palette-info-dark")),L(h.Alert,"successFilledBg",I("palette-success-dark")),L(h.Alert,"warningFilledBg",I("palette-warning-dark")),L(h.Alert,"errorFilledColor",Ht(()=>h.getContrastText(h.error.dark))),L(h.Alert,"infoFilledColor",Ht(()=>h.getContrastText(h.info.dark))),L(h.Alert,"successFilledColor",Ht(()=>h.getContrastText(h.success.dark))),L(h.Alert,"warningFilledColor",Ht(()=>h.getContrastText(h.warning.dark))),L(h.Alert,"errorStandardBg",N(De,h.error.light,.9)),L(h.Alert,"infoStandardBg",N(De,h.info.light,.9)),L(h.Alert,"successStandardBg",N(De,h.success.light,.9)),L(h.Alert,"warningStandardBg",N(De,h.warning.light,.9)),L(h.Alert,"errorIconColor",I("palette-error-main")),L(h.Alert,"infoIconColor",I("palette-info-main")),L(h.Alert,"successIconColor",I("palette-success-main")),L(h.Alert,"warningIconColor",I("palette-warning-main")),L(h.AppBar,"defaultBg",I("palette-grey-900")),L(h.AppBar,"darkBg",I("palette-background-paper")),L(h.AppBar,"darkColor",I("palette-text-primary")),L(h.Avatar,"defaultBg",I("palette-grey-600")),L(h.Button,"inheritContainedBg",I("palette-grey-800")),L(h.Button,"inheritContainedHoverBg",I("palette-grey-700")),L(h.Chip,"defaultBorder",I("palette-grey-700")),L(h.Chip,"defaultAvatarColor",I("palette-grey-300")),L(h.Chip,"defaultIconColor",I("palette-grey-300")),L(h.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(h.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(h.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(h.LinearProgress,"primaryBg",N(De,h.primary.main,.5)),L(h.LinearProgress,"secondaryBg",N(De,h.secondary.main,.5)),L(h.LinearProgress,"errorBg",N(De,h.error.main,.5)),L(h.LinearProgress,"infoBg",N(De,h.info.main,.5)),L(h.LinearProgress,"successBg",N(De,h.success.main,.5)),L(h.LinearProgress,"warningBg",N(De,h.warning.main,.5)),L(h.Skeleton,"bg",E?N(Br,h.text.primary,.13):`rgba(${I("palette-text-primaryChannel")} / 0.13)`),L(h.Slider,"primaryTrack",N(De,h.primary.main,.5)),L(h.Slider,"secondaryTrack",N(De,h.secondary.main,.5)),L(h.Slider,"errorTrack",N(De,h.error.main,.5)),L(h.Slider,"infoTrack",N(De,h.info.main,.5)),L(h.Slider,"successTrack",N(De,h.success.main,.5)),L(h.Slider,"warningTrack",N(De,h.warning.main,.5));const d=E?N(_e,h.background.default,.985):qo(h.background.default,.98);L(h.SnackbarContent,"bg",d),L(h.SnackbarContent,"color",Ht(()=>E?Fs.text.primary:h.getContrastText(d))),L(h.SpeedDialAction,"fabHoverBg",qo(h.background.paper,.15)),L(h.StepConnector,"border",I("palette-grey-600")),L(h.StepContent,"border",I("palette-grey-600")),L(h.Switch,"defaultColor",I("palette-grey-300")),L(h.Switch,"defaultDisabledColor",I("palette-grey-600")),L(h.Switch,"primaryDisabledColor",N(De,h.primary.main,.55)),L(h.Switch,"secondaryDisabledColor",N(De,h.secondary.main,.55)),L(h.Switch,"errorDisabledColor",N(De,h.error.main,.55)),L(h.Switch,"infoDisabledColor",N(De,h.info.main,.55)),L(h.Switch,"successDisabledColor",N(De,h.success.main,.55)),L(h.Switch,"warningDisabledColor",N(De,h.warning.main,.55)),L(h.TableCell,"border",N(De,N(Br,h.divider,1),.68)),L(h.Tooltip,"bg",N(Br,h.grey[700],.92))}nr(h.background,"default"),nr(h.background,"paper"),nr(h.common,"background"),nr(h.common,"onBackground"),nr(h,"divider"),Object.keys(h).forEach(d=>{const oe=h[d];d!=="tonalOffset"&&oe&&typeof oe=="object"&&(oe.main&&L(h[d],"mainChannel",So(Co(oe.main))),oe.light&&L(h[d],"lightChannel",So(Co(oe.light))),oe.dark&&L(h[d],"darkChannel",So(Co(oe.dark))),oe.contrastText&&L(h[d],"contrastTextChannel",So(Co(oe.contrastText))),d==="text"&&(nr(h[d],"primary"),nr(h[d],"secondary")),d==="action"&&(oe.active&&nr(h[d],"active"),oe.selected&&nr(h[d],"selected")))})}),R=r.reduce((W,h)=>bt(W,h),R);const q={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Vd(R),enableContrastVars:c},{vars:T,generateThemeVars:F,generateStyleSheets:X}=pd(R,q);return R.vars=T,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([W,h])=>{R[W]=h}),R.generateThemeVars=F,R.generateStyleSheets=X,R.generateSpacing=function(){return Rs(f.spacing,fi(this))},R.getColorSchemeSelector=hd(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=l,R.unstable_sxConfig={...vn,...f==null?void 0:f.unstable_sxConfig},R.unstable_sx=function(h){return Sn({sx:h,theme:this})},R.toRuntimeSource=Hs,R}function as(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:bi({...n===!0?{}:n.palette,mode:r})})}function qd(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...c}=e,l=a||"light",u=s==null?void 0:s[l],g={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ni(e,...r);let f=n;"palette"in e||g[l]&&(g[l]!==!0?f=g[l].palette:l==="dark"&&(f={mode:"dark"}));const m=ni({...e,palette:f},...r);return m.defaultColorScheme=l,m.colorSchemes=g,m.palette.mode==="light"&&(m.colorSchemes.light={...g.light!==!0&&g.light,palette:m.palette},as(m,"dark",g.dark)),m.palette.mode==="dark"&&(m.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:m.palette},as(m,"light",g.light)),m}return!n&&!("light"in g)&&l==="light"&&(g.light=!0),Yd({...c,colorSchemes:g,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Jd=qd();function ht(){const e=ed(Jd);return process.env.NODE_ENV!=="production"&&an.useDebugValue(e),e[Vl]||e}async function Kd(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(l))u=l;else if(n&&l[n]&&Array.isArray(l[n]))u=l[n];else{const f=["data","results","items","records"].find(m=>l[m]&&Array.isArray(l[m]));if(f)u=l[f];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function Xd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${$(e.palette.common.black,n.opacity)}`).join(", ")}const Qd={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function ye(e,r){return Xd(e,Qd[r])}function ot(e){return`${Number(e.shape.borderRadius)*1.5}px`}function _o(e){return`${Number(e.shape.borderRadius)}px`}function ls(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function ct(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${$(n,.08)})`,hoverBg:`var(--highlight-hover, ${$(n,.12)})`}}function ue(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ye(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function Zd({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=p.useState(""),[l,u]=p.useState(!1),[g,f]=p.useState(""),[m,v]=p.useState(null),[C,B]=p.useState(null),[b,y]=p.useState(!1),[z,x]=p.useState(""),j=p.useRef(null),[E,S]=p.useState("json"),[R,q]=p.useState(""),[T,F]=p.useState(""),[X,W]=p.useState(""),[h,I]=p.useState("idle"),[N,d]=p.useState(""),[oe,G]=p.useState(null),[te,ge]=p.useState(0),V=async D=>{if(x(""),!D.name.endsWith(".json")){x("Only .json files are allowed");return}const ee=10*1024*1024;if(D.size>ee){x("File size exceeds 10MB limit");return}try{const xe=await D.text();let ae;try{ae=JSON.parse(xe)}catch{x("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){x("JSON must be an array of objects");return}if(ae.length===0){x("No data rows found in JSON file");return}v(D),B(ae)}catch{x("Network error — please try again")}},K=D=>{D.preventDefault();const ee=D.dataTransfer.files[0];ee&&V(ee)},ce=async()=>{if(R.trim()){I("loading"),d("");try{const D=await Kd(R.trim(),T.trim()||void 0,X.trim()||void 0);G(D.data),ge(D.data.length),I("ready")}catch(D){d((D==null?void 0:D.message)||"Connection failed"),I("error")}}},de=()=>{if(!a.trim()){u(!0);return}const D=E==="api"?oe:i||C;D&&(n(a.trim(),g.trim(),D),ne())},ne=()=>{c(""),u(!1),f(""),v(null),B(null),x(""),S("json"),q(""),F(""),W(""),I("idle"),d(""),G(null),ge(0),r()},Q=i||C,pe=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ne,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:D=>({borderRadius:ot(D),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ue(D).paper})},children:[t.jsxs(o.DialogTitle,{sx:D=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:ee=>ee.typography.h6.fontWeight||500,fontSize:ee=>ee.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...ue(D).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:ne,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:D=>{c(D.target.value),l&&D.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:pe,helperText:pe?"Report name is required":void 0,inputProps:{maxLength:255},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:g,onChange:D=>f(D.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsxs(o.Tabs,{value:E==="json"?0:1,onChange:(D,ee)=>{S(ee===0?"json":"api"),I("idle"),d("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(O.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.15)})`},"&:hover":{bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(O.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.15)})`},"&:hover":{bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.08)})`}}})]}),E==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:D=>$(D.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:D=>$(D.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:K,onDragOver:D=>D.preventDefault(),onPaste:D=>D.preventDefault(),onClick:()=>{var D;return(D=j.current)==null?void 0:D.click()},sx:{position:"relative",border:"1.5px",borderStyle:C?"solid":"dashed",borderColor:C?"success.main":z?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:C?D=>$(D.palette.success.main,.04):z?D=>$(D.palette.error.main,.04):D=>$(D.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:C?D=>$(D.palette.success.main,.08):z?D=>$(D.palette.error.main,.08):D=>$(D.palette.primary.main,.08),borderColor:C?"success.dark":z?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:j,type:"file",accept:".json",sx:{display:"none"},onChange:D=>{var ee;return((ee=D.target.files)==null?void 0:ee[0])&&V(D.target.files[0])}}),C?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:D=>$(D.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(O.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:m==null?void 0:m.name}),t.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:D=>$(D.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(O.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),z&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:D=>$(D.palette.error.main,.08),border:1,borderColor:D=>$(D.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:z})})]})]})]})}),E==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:D=>{q(D.target.value),I("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:T,onChange:D=>F(D.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(O.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:X,onChange:D=>W(D.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!R.trim()||h==="loading",onClick:ce,startIcon:h==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(O.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:D=>$(D.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:h==="loading"?"Connecting...":"Test Connection & Load Data"}),h==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:D=>$(D.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[te.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),h==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:D=>$(D.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:N})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ne,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:D=>$(D.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:de,disabled:E==="json"&&!Q||E==="api"&&h!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:b,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:D=>({borderRadius:3,width:560,maxHeight:"80vh",...ue(D).paper})},children:[t.jsxs(o.DialogTitle,{sx:D=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ue(D).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
172
172
  {
173
173
  "id": 1,
174
174
  "customerName": "John Smith",
@@ -178,7 +178,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
178
178
  "memberSince": "2024-01-15",
179
179
  "status": "active"
180
180
  }
181
- ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>f(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:R=>`${R.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Js({isOpen:e,onClose:r}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:n=>({borderRadius:rt(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(n).paper})},children:[t.jsxs(o.DialogTitle,{sx:n=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(n).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
181
+ ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ys({isOpen:e,onClose:r,content:n}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(i).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
182
182
  {
183
183
  "Active Sessions": 33,
184
184
  "Active State": true,
@@ -188,10 +188,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
188
188
  "Region": "Europe",
189
189
  "Subscription Type": "Basic"
190
190
  }
191
- ]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>ge(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ge(n,"hoverButton")},"&:active":{boxShadow:n=>ge(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ru({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=p.useState(!1),[a,c]=p.useState(""),[l,u]=p.useState(!1),x=p.useRef(null),m=async b=>{if(!b.name.endsWith(".json")){r("Only .json files are allowed");return}const g=10*1024*1024;if(b.size>g){r("File size exceeds 10MB limit");return}c(b.name);try{const T=await b.text();let I;try{I=JSON.parse(T)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(I)){r("JSON must be an array of objects");return}if(I.length===0){r("No data rows found in JSON file");return}e(I)}catch{r("Network error — please try again")}finally{c("")}},h=b=>{b.preventDefault(),s(!0)},v=b=>{b.preventDefault(),s(!1)},w=b=>{b.preventDefault(),s(!1);const g=b.dataTransfer.files[0];g&&m(g)},B=()=>{var b;(b=x.current)==null||b.click()},S=b=>{var T;const g=(T=b.target.files)==null?void 0:T[0];g&&m(g)},f=b=>{b.stopPropagation(),u(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:h,onDragLeave:v,onDrop:w,onPaste:b=>b.preventDefault(),onClick:B,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?b=>_(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:[t.jsx(o.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:S,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:b=>b.typography.body2.fontWeight||500,fontSize:b=>b.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),a&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:a})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:b=>_(b.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:f,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(Js,{isOpen:l,onClose:()=>u(!1)})]})}function ou({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&t.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?s=>_(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx($.Lock,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function nu({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>_(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>_(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(o.Button,{variant:"contained",color:"error",startIcon:t.jsx($.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Ks({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>_(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx($.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function iu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,u]=p.useState(!1),[x,m]=p.useState(!1),[h,v]=p.useState(-1),w=p.useRef(null),B=p.useRef(null);p.useEffect(()=>{function E(U){w.current&&!w.current.contains(U.target)&&(u(!1),m(!1))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const S=p.useCallback(()=>{m(!0),v(-1),n.length>0&&u(!0)},[n.length]),f=p.useCallback(E=>{r(E),v(-1)},[r]),b=p.useCallback(E=>{var U;r(E),i(E),u(!1),(U=B.current)==null||U.blur()},[r,i]),g=p.useCallback(E=>{v(-1),b(E)},[b]),T=p.useCallback(E=>{var U;E.key==="Enter"?h>=0&&h<n.length?(E.preventDefault(),g(n[h].query)):e.trim()&&b(e.trim()):E.key==="Escape"?(u(!1),v(-1),(U=B.current)==null||U.blur()):E.key==="ArrowDown"?(E.preventDefault(),n.length>0&&(l||u(!0),v(G=>G<n.length-1?G+1:G))):E.key==="ArrowUp"&&(E.preventDefault(),v(G=>G>0?G-1:-1))},[h,n,e,l,g,b]),I=p.useCallback(()=>{var E;r(""),(E=B.current)==null||E.focus()},[r]),C=p.useMemo(()=>n.filter(E=>E.isFavourite),[n]),W=p.useMemo(()=>n.filter(E=>!E.isFavourite),[n]),K=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:w,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:E=>f(E.target.value),onFocus:S,onKeyDown:T,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:E=>_(E.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:E=>_(E.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx($.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:I,edge:"end",sx:{mr:-.5},children:t.jsx($.Close,{sx:{fontSize:16}})})}):null}}),K&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[C.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),C.map((E,U)=>t.jsx(us,{entry:E,isSelected:h===U,onClick:()=>g(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`fav-${E.query}`))]}),W.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[C.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),W.map((E,U)=>{const G=C.length+U;return t.jsx(us,{entry:E,isSelected:h===G,onClick:()=>g(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`recent-${E.query}`)})]})]})]})}const us=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>_(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>_(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:c,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx($.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx($.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function su({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:u,onEditView:x,onCloneView:m,onCopyLink:h,onDeleteView:v,onPromoteToGlobal:w,onSetDefaultForAllUsers:B,isReadOnly:S,isAdmin:f=!1}){const b=ct(),[g,T]=p.useState(!1),[I,C]=p.useState(!1),[W,K]=p.useState({top:0,left:0}),[E,U]=p.useState(null),[G,M]=p.useState(null),y=p.useRef(null),k=p.useRef(null),P=e.find(L=>L.id===r),oe=P==null?void 0:P.isDefault,d=(L,de)=>L.name.localeCompare(de.name),J=e.filter(L=>L.scope==="global"&&!L.isDeleted).sort(d),ee=e.filter(L=>L.scope!=="global"&&!L.isDeleted).sort(d),Se=e.filter(L=>L.isFavorite&&!L.isDeleted).sort(d),V=e.filter(L=>L.isDeleted);p.useEffect(()=>{if(g&&k.current){const L=k.current.getBoundingClientRect();K({top:L.bottom+window.scrollY+8,left:L.right+window.scrollX-320})}},[g]),p.useEffect(()=>{const L=de=>{y.current&&!y.current.contains(de.target)&&k.current&&!k.current.contains(de.target)&&T(!1)};return g&&document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[g]);const X=L=>{if(n&&L!==r){U(L),T(!1);return}i(L),T(!1)},pe=()=>{E&&(i(E),U(null))},ce=()=>{U(null)},ie=(L,de=!1)=>{const he=L.scope==="global",Te=!S&&(!he||f),Q=f&&!he;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===L.id?_(b.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===L.id?_(b.palette.primary.main,.12):b.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>X(L.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===L.id&&t.jsx($.Check,{sx:{fontSize:16,flexShrink:0}}),r!==L.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===L.id?b.palette.primary.dark:b.palette.text.primary,fontWeight:r===L.id?ye=>ye.typography.body2.fontWeight||500:400,fontSize:ye=>ye.typography.body2.fontSize||"0.875rem"},children:L.name}),de&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:b.palette.text.secondary,backgroundColor:b.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Te&&c&&t.jsx(o.IconButton,{onClick:ye=>{ye.stopPropagation(),c(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},title:L.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx($.Star,{sx:{fontSize:16}})}),Te&&a&&!L.isDefault&&t.jsx(o.IconButton,{onClick:ye=>{ye.stopPropagation(),a(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},title:"Set as default",children:t.jsx($.RadioButtonUnchecked,{sx:{fontSize:16}})}),(Te||Q)&&(x||m||h||v||Q&&w)&&t.jsx(o.IconButton,{onClick:ye=>{ye.stopPropagation(),M({el:ye.currentTarget,view:L})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},title:"More actions",children:t.jsx($.MoreVert,{sx:{fontSize:16}})})]})]},L.id)},te=L=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:b.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:b.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:L.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:de=>{de.stopPropagation(),l(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},title:"Restore view",children:t.jsx($.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:de=>{de.stopPropagation(),u(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},title:"Delete permanently",children:t.jsx($.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},L.id),se=n||!oe,R=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:k,onClick:()=>T(!g),variant:"outlined",size:"small",endIcon:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:se?"warning.main":"text.primary",borderColor:se?"warning.main":"divider",bgcolor:se?_(b.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:se?"warning.dark":"primary.main",bgcolor:se?_(b.palette.warning.main,.2):_(b.palette.text.primary,.06),color:se?"warning.dark":"text.primary"}},title:`View: ${(P==null?void 0:P.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(P==null?void 0:P.name)||"Default View"}),R&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),g&&Ss.createPortal(t.jsxs(o.Box,{ref:y,sx:{position:"fixed",width:"320px",backgroundColor:b.palette.background.paper,border:`1px solid ${b.palette.divider}`,borderRadius:1,boxShadow:b.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:W.top,left:W.left},children:[J.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:L=>L.typography.caption.fontSize||"caption.fontSize",fontWeight:L=>L.typography.caption.fontWeight||600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),J.map(L=>ie(L,L.isDefault))]}),Se.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx($.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),Se.map(L=>ie(L))]})]}),ee.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:L=>L.typography.caption.fontSize||"caption.fontSize",fontWeight:L=>L.typography.caption.fontWeight||600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),ee.map(L=>ie(L))]})]}),V.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>C(!I),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",V.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),I&&t.jsx(o.Box,{sx:{backgroundColor:b.palette.action.hover},children:V.map(L=>te(L))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:b.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.action.hover}},children:[t.jsx($.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!G,anchorEl:(G==null?void 0:G.el)||null,onClose:()=>M(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{G&&x(G.view.id),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),h&&t.jsxs(o.MenuItem,{onClick:()=>{G&&h(G.view.id),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),m&&t.jsxs(o.MenuItem,{onClick:()=>{G&&m(G.view.id),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),w&&f&&(G==null?void 0:G.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{G&&w(G.view.id),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Language,{sx:{fontSize:18}}),"Promote to Global"]}),B&&G&&t.jsxs(o.MenuItem,{onClick:()=>{G&&B(G.view.id,!G.view.isDefaultForAllUsers),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Star,{sx:{fontSize:18,color:G.view.isDefaultForAllUsers?"warning.main":"inherit"}}),G.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{G&&v(G.view.id),M(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:E!==null,onClose:ce,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Mo(b)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx($.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:ce,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:pe,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function au({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:x,onRemoveSort:m,onFilter:h,onClearFilter:v,onGroupByColumn:w,onHideColumn:B,onManageColumns:S,onResetLayout:f,onClose:b}){const g=ct(),T=g.palette,I=p.useRef(null);p.useEffect(()=>{if(!I.current)return;const G=I.current,M=G.getBoundingClientRect(),y=window.innerWidth,k=window.innerHeight;M.right>y-8&&(G.style.left=`${y-M.width-8}px`),M.bottom>k-8&&(G.style.top=`${k-M.height-8}px`)},[l]),p.useEffect(()=>{const G=y=>{I.current&&!I.current.contains(y.target)&&b()},M=y=>{y.key==="Escape"&&b()};return document.addEventListener("mousedown",G),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",M)}},[b]);const C=p.useCallback(G=>()=>{G(),b()},[b]),W=(n==null?void 0:n.direction)==="asc",K=(n==null?void 0:n.direction)==="desc",E=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",U=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Ss.createPortal(t.jsxs(o.Paper,{ref:I,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:g.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Mo(g),overflow:"hidden",boxShadow:`0 4px 20px ${_(T.common.black,.12)}, 0 1px 4px ${_(T.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:G=>G.typography.body2.fontSize||"0.8125rem",fontWeight:G=>G.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${E})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:C(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:W?"primary.main":"text.secondary",bgcolor:W?_(T.primary.main,.1):"transparent","&:hover":{bgcolor:_(T.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${U})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:C(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:K?"primary.main":"text.secondary",bgcolor:K?_(T.primary.main,.1):"transparent","&:hover":{bgcolor:_(T.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:C(()=>m(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(T.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx($.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:C(()=>h(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:C(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(T.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&w&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:C(()=>w(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:C(()=>B(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:C(S),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(T.primary.main,.08),color:"primary.main"}},children:t.jsx($.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:C(S),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&f&&t.jsxs(o.MenuItem,{onClick:C(f),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(T.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const lu=176,ps="COLUMN_HEADER",cu=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:u=!1,width:x,onColumnClick:m,onMoveColumn:h,onColumnDragEnd:v,onResizeStart:w,onSortAscending:B,onSortDescending:S,onRemoveSort:f,onOpenFilterForColumn:b,onClearFiltersForColumn:g,onGroupByColumn:T,onHideColumn:I,onManageColumns:C,onResetLayout:W}){const E=ct().urmTable,U=p.useRef(null),[G,M]=p.useState(!1),[y,k]=p.useState({x:0,y:0}),[{handlerId:P,isOver:oe},d]=ir.useDrop({accept:ps,collect(te){return{handlerId:te.getHandlerId(),isOver:te.isOver()}},hover(te,se){var ye;if(!U.current)return;const R=te.index,L=n;if(R===L)return;const de=(ye=U.current)==null?void 0:ye.getBoundingClientRect(),he=(de.right-de.left)/2,Te=se.getClientOffset(),Q=((Te==null?void 0:Te.x)??0)-de.left;R<L&&Q<he||R>L&&Q>he||(h(R,L),te.index=L)}}),[{isDragging:J},ee]=ir.useDrag({type:ps,item:()=>({index:n,columnName:r.name}),collect:te=>({isDragging:te.isDragging()}),end:()=>{v==null||v()}});ee(d(U));const Se=p.useCallback(te=>{te.preventDefault(),te.stopPropagation(),k({x:te.clientX,y:te.clientY}),M(!0)},[]),V=p.useCallback(()=>M(!1),[]),X=p.useCallback(()=>{l||m(r.name)},[m,r.name,l]),pe=p.useCallback(te=>{te.stopPropagation(),b(r.name)},[b,r.name]),ce=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx($.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),ie=p.useCallback(()=>s?t.jsx($.FilterList,{onClick:pe,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,pe]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:U,"data-handler-id":P,"data-column-index":n,onClick:X,onContextMenu:Se,sx:{position:"sticky",top:0,zIndex:5,textAlign:(E==null?void 0:E.cellAlignH)??"left",verticalAlign:(E==null?void 0:E.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(E==null?void 0:E.headerColor)??"text.secondary",opacity:J?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease, width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease",bgcolor:oe?te=>_(te.palette.primary.main,.08):(E==null?void 0:E.headerBg)??"action.hover",boxShadow:te=>`0 1px 0 ${_(te.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(E==null?void 0:E.rowDivider)??"1px solid",borderRight:E==null?void 0:E.colDivider,borderColor:"divider",py:0,px:l?0:(E==null?void 0:E.cellPaddingX)??2,"&:hover":{bgcolor:te=>_(te.palette.primary.main,.1),color:"text.primary"},width:l?"32px":x?`${x}px`:`${lu}px`,minWidth:l?"32px":void 0,maxWidth:l?"32px":void 0},children:[!l&&t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[lt(r.name),ce(),ie()]}),!l&&t.jsx(o.Box,{draggable:!1,onDragStart:te=>te.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),w(te,r.name)},onClick:te=>te.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),oe&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),G&&t.jsx(au,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:u,position:y,onSortAscending:B,onSortDescending:S,onRemoveSort:f,onFilter:b,onClearFilter:g,onGroupByColumn:T,onHideColumn:I,onManageColumns:C,onResetLayout:W,onClose:V})]})}),du={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function an(e,r){const n=du[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:_(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function uu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const pu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function hu(e,r){const n=pu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function zt(e){return _(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function fu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>an(n,r).bg,color:n=>an(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function mu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return fu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const c=uu(a,s);return c?{color:c,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function xu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function gu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:x}){const[m,h]=p.useState(!1),{primaryCol:v,idCol:w,bodyColumns:B}=p.useMemo(()=>xu(n),[n]),S=v?e[v.name]:null,f=w?e[w.name]:null,b=m||i;return t.jsxs(o.Box,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onClick:g=>s(r,g),onDoubleClick:g=>a(e,r,g),onContextMenu:g=>{g.preventDefault(),g.stopPropagation(),c(e,r,g)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:g=>{var I,C,W,K;const T=(K=(W=(C=(I=g.components)==null?void 0:I.MuiCard)==null?void 0:C.styleOverrides)==null?void 0:W.root)==null?void 0:K.border;return i?"2px solid":T&&T!=="none"?T:"1px solid"},borderColor:i?g=>at(g).main:g=>{var I,C,W,K;const T=(K=(W=(C=(I=g.components)==null?void 0:I.MuiCard)==null?void 0:C.styleOverrides)==null?void 0:W.root)==null?void 0:K.border;return T&&T!=="none"?"inherit":_(g.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:g=>{var I,C,W,K;const T=(K=(W=(C=(I=g.components)==null?void 0:I.MuiCard)==null?void 0:C.styleOverrides)==null?void 0:W.root)==null?void 0:K.borderRadius;return T!==void 0?typeof T=="number"?`${T}px`:T:`${g.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?g=>`0 0 0 3px ${_(at(g).main,.15)}, 0 2px 8px ${_(g.palette.common.black,.08)}`:m?g=>{var I,C,W,K;const T=(K=(W=(C=(I=g.components)==null?void 0:I.MuiCard)==null?void 0:C.styleOverrides)==null?void 0:W.root)==null?void 0:K.boxShadow;return T&&T!=="none"?T:ge(g,"cardHover")}:g=>{var I,C,W,K;const T=(K=(W=(C=(I=g.components)==null?void 0:I.MuiCard)==null?void 0:C.styleOverrides)==null?void 0:W.root)==null?void 0:K.boxShadow;return T&&T!=="none"?T:ge(g,"cardRest")},transform:m&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:g=>_(at(g).main,.03)}},children:[t.jsxs(o.Box,{sx:g=>{var K,E,U,G;const T=((U=(E=(K=g.components)==null?void 0:K.MuiCardHeader)==null?void 0:E.styleOverrides)==null?void 0:U.root)||{},I=(T.backgroundColor&&T.backgroundColor!=="transparent"?T.backgroundColor:void 0)??((G=g.tokens)==null?void 0:G.cardHdrHex)??"transparent",C=T.borderBottom&&T.borderBottom!=="none"?T.borderBottom:void 0,W=T.boxShadow&&T.boxShadow!=="none"?T.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:I,borderBottom:C,boxShadow:W,display:"flex",alignItems:"center",gap:.5}},children:[!x&&b&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:g=>g.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:g=>g.typography.body2.fontWeight||600,fontSize:g=>g.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:S!=null&&S!==""?String(S):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:g=>{var C,W,K;const T=((K=(W=(C=g.components)==null?void 0:C.MuiCardHeader)==null?void 0:W.styleOverrides)==null?void 0:K.root)||{};return T.borderBottom&&T.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[B.map(g=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:T=>T.typography.body2.fontWeight||500,fontSize:T=>T.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:lt(g.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[g.name]??""),children:mu(g,e[g.name])})]},g.name)),B.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:g=>_(g.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:f?.85:0,userSelect:"none"},children:f?String(f):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:b?1:0,transition:"opacity 0.15s ease"},onClick:g=>g.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),l(e,r,g.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:g=>_(g.palette.text.primary,.08)}},children:t.jsx($.MoreVert,{sx:{fontSize:17}})})})})]})]})}function yu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>ge(s,"flatHover"),"&:hover":{bgcolor:s=>_(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:Va(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>_(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>Ts(a)).filter(Boolean).join(" • ")})]})}function bu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:x,onToggleSelection:m,hideSelectionCheckboxes:h}){const v=p.useMemo(()=>{const w=new Set;return i.forEach(B=>{const S=B==null?void 0:B.__urm_row_id__;S!==void 0&&w.add(S)}),w},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:w=>w.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:w=>ds(w).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:w=>ds(w).cardGap,alignContent:"start"},children:e.map((w,B)=>s&&w.isGroupHeader?t.jsx(yu,{row:w,grouping:n,onToggleCollapse:a||(()=>{})},`group-${w.groupKey}`):t.jsx(gu,{row:w,rowIndex:B,visibleColumns:r,isSelected:v.has(w==null?void 0:w.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:x,onToggleSelection:m,hideCheckbox:h},`card-${B}`))})})}const hs=[10,15,25,50,100];function vu(e,r){const n=e.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function Su({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=ct().palette,u=Math.ceil(n/r),[x,m]=p.useState(String(e)),[h,v]=p.useState(null),[w,B]=p.useState(!1),S=p.useRef(null);p.useEffect(()=>{w||(m(String(e)),v(null))},[e,w]);const f=p.useCallback(()=>{const k=vu(x,u);if(k){v(k);return}const P=parseInt(x.trim(),10);v(null),B(!1),P!==e&&s(P)},[x,u,e,s]),b=p.useCallback(k=>{var P;k.key==="Enter"?(k.preventDefault(),f()):k.key==="Escape"&&(m(String(e)),v(null),B(!1),(P=S.current)==null||P.blur())},[f,e]),g=p.useCallback(()=>{m(String(e)),v(null),B(!1)},[e]),T=p.useCallback(()=>{B(!0),v(null),setTimeout(()=>{var k;return(k=S.current)==null?void 0:k.select()},0)},[]);if(n<=Math.min(...hs))return null;const I=()=>{m(String(e)),v(null),B(!1)},C=()=>{I(),s(1)},W=()=>{I(),e>1&&s(e-1)},K=()=>{I(),e<u&&s(e+1)},E=()=>{I(),s(u)},U=(e-1)*r+1,G=Math.min(e*r,n),M=`${Math.max(2,String(u).length+.5)}ch`,y={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:k=>a(Number(k.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:hs.map(k=>t.jsx(o.MenuItem,{value:k,sx:{fontSize:"0.8125rem"},children:k},k))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[U,"–",G," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[h&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:_(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${_(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:_(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:h})}),t.jsx(o.InputBase,{inputRef:S,value:x,onChange:k=>{m(k.target.value),h&&v(null)},onKeyDown:b,onFocus:T,onBlur:g,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:M,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:h?"error.main":"text.primary",border:"1px solid",borderColor:h?"error.main":w?"primary.main":"divider",borderRadius:"4px",bgcolor:h?_(l.error.main,.04):w?_(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:h?"error.main":"text.secondary"},"&:focus-within":{boxShadow:h?`0 0 0 2px ${_(l.error.main,.2)}`:`0 0 0 2px ${_(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:C,disabled:e===1,size:"small",title:"First page",sx:y,children:t.jsx($.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:W,disabled:e===1,size:"small",title:"Previous page",sx:y,children:t.jsx($.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:K,disabled:e===u,size:"small",title:"Next page",sx:y,children:t.jsx($.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:E,disabled:e===u,size:"small",title:"Last page",sx:y,children:t.jsx($.LastPage,{sx:{fontSize:20}})})]})]})]})}function Cu(){return t.jsx(o.Chip,{icon:t.jsx($.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const Xs="urm_hint_seen_";function wu(e){try{return localStorage.getItem(Xs+e)==="true"}catch{return!1}}function ju(e){try{localStorage.setItem(Xs+e,"true")}catch{}}const Qs={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function ii(e,r){if(e==null||e==="")return"";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function Zs({row:e,schema:r}){const i=ct().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),c=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:lt(l.name),value:ii(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Qs},l.name)),c.map(l=>{const u=ii(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:x=>x.typography.caption.fontWeight||500,fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:lt(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function ku({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=ct(),c=a.palette;if(!n)return null;const l=i.filter(x=>x.name in n).length,u=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:rt(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:_(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:x=>x.typography.h6.fontSize||"1rem",fontWeight:x=>x.typography.h6.fontWeight||600,color:x=>x.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:_(c.text.primary,.015)},children:t.jsx(Zs,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:x=>`${x.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function zu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=ct(),c=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:rt(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>_(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(Zs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>_(l.palette.error.main,.1),border:l=>`1px solid ${_(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx($.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ge(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ge(l,"hoverButton")},"&:active":{boxShadow:l=>ge(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Tu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var b;const c=ct(),l=c.palette,[u,x]=p.useState({});if(p.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const m=s.filter(g=>g.name in i),h=m.filter(g=>g.type!=="object"&&g.type!=="array"),v=m.filter(g=>g.type==="object"||g.type==="array"),w=(g,T)=>{x(I=>({...I,[g]:T}))},B=()=>{const g={...u};m.forEach(T=>{const I=u[T.name];if(T.type==="number"){const C=Number(I);g[T.name]=isNaN(C)?i[T.name]:C}else T.type==="boolean"&&(g[T.name]=!!I)}),n(g),r()},S=m.length,f=ue(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:rt(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...f.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...f.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:_(((b=l.warning)==null?void 0:b.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:g=>g.typography.h6.fontSize||"1rem",fontWeight:g=>g.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",S," ",S===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:_(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[h.map(g=>{const T=u[g.name];return g.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:I=>I.typography.caption.fontWeight||500,fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:lt(g.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!T,onChange:I=>w(g.name,I.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:T?"Enabled":"Disabled"})]})]},g.name):t.jsx(o.TextField,{label:lt(g.name),value:T??"",onChange:I=>w(g.name,I.target.value),type:g.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Qs},g.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(g=>{const T=ii(i[g.name],g.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.caption.fontSize||"0.75rem",fontWeight:I=>I.typography.caption.fontWeight||500,color:"text.secondary"},children:lt(g.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:_(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx($.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:T?"text.primary":"text.disabled",fontStyle:T?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:T||"No value"})]},g.name)})}),m.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx($.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:g=>`${g.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",startIcon:t.jsx($.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:g=>`${g.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Bu=176,Iu=170,Eu=40,Du=32;function ea(e){return e.type==="date"?180:Bu}function _u(e,r){return r!=null&&r!==Iu&&r!==ea(e)}function $u(e,r,n,i){return p.useMemo(()=>{const s=e.map(v=>i!=null&&i.has(v.name)?{name:v.name,width:Du,explicit:!0}:{name:v.name,width:r[v.name]??ea(v),explicit:_u(v,r[v.name])}),a={};s.forEach(v=>{a[v.name]=v.width});const c=s.reduce((v,w)=>v+w.width,0),u=Math.max(0,n-Eu)-c;if(u<=0)return{widths:a,fillerWidth:0};const x=s.filter(v=>!v.explicit);if(x.length===0)return{widths:a,fillerWidth:u};const m=x.reduce((v,w)=>v+w.width,0)||1;let h=0;return x.forEach((v,w)=>{const S=w===x.length-1?v.width+u-h:Math.round(v.width+u*v.width/m);a[v.name]=S,h+=S-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const fs=176,Ou=$t(),Mu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Au(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>an(n,r).bg,color:n=>an(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Wu(e){const r=e.toLowerCase().trim(),n=Mu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Ru(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,c)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},c):a)}function Pu(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Au(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Wu(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=_a(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Ru(s,i)}function Nu({schema:e,data:r,sortStack:n=[],filters:i=Ou,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:x=[],columnWidths:m={},grouping:h=null,classTokens:v={},onSort:w,onSortAscending:B,onSortDescending:S,onOpenFilters:f,onOpenSort:b,onOpenFilterForColumn:g,onSelectView:T,onCreateView:I,onUpdateCurrentView:C,onSaveAsNewView:W,onDiscardChanges:K,onToggleDefault:E,onToggleFavorite:U,onRestoreView:G,onPermanentDelete:M,onEditView:y,onCloneView:k,onCopyLink:P,onDeleteView:oe,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:ee=!1,onExport:Se,onOpenColumns:V,onUpdateColumnWidth:X,onUpdateColumnOrder:pe,onUpdateColumnVisibility:ce,onClearFiltersForColumn:ie,onResetLayout:te,onOpenGroup:se,onGroupByColumn:R,onToggleGroupCollapse:L,onExpandAllGroups:de,onCollapseAllGroups:he,onOpenAuditHistory:Te,onOpenScheduledReports:Q,searchQuery:ye,highlightQuery:dt="",searchHistory:Ht=[],onAddToSearchHistory:Ot,onToggleSearchFavourite:Mr,onDeleteSearchHistory:Mt,selectedRowIds:nt=new Set,onSearchChange:Ut,onToggleRowSelection:Je,onToggleAllRows:Bt,onRangeSelection:br,onClearSelection:yt,onExportSelected:Gt,currentPage:lo=1,pageSize:ar=15,totalRowsBeforePagination:co=r.length,onPageChange:It,onPageSizeChange:vr,isReadOnly:Ke=!1,userRole:At,reportName:Yt,onEditRow:Ze,onDuplicateRow:et,onDeleteRow:Wt,showDevPanel:uo=!1,onOpenDevConfig:Ar,rowActions:Sr,hideDefaultRowActions:Fe,hideToolbarActions:ke,customSettingsActions:lr,viewOptions:Rt,defaultViewMode:Cr,bulkActions:wr,hideSelectionCheckboxes:qt,rowClickBehavior:cr="select",openModalOn:tt,onRowClick:dr,onRowRightClick:bt}){var Fo;const re=ct().urmTable,[jr,Rr]=p.useState(null),[Et,H]=p.useState(0),[ut,ae]=p.useState(0),[Xe,ur]=p.useState(null),Jt=gr(),po=((Fo=Jt.dates)==null?void 0:Fo.displayFormat)??null,[Kt,kr]=p.useState(null),[Xt,pr]=p.useState(null),[Qt,we]=p.useState(null),[vt,Z]=p.useState(!1),[fe,Ce]=p.useState(!1),[zr,Tr]=p.useState(null),[ho,Pr]=p.useState(!1),[fo,Zt]=p.useState(null),[Nr,Lr]=p.useState(null),[be,Ve]=p.useState(null),[Br,it]=p.useState(null),er=p.useRef(null),Dt=p.useCallback(()=>{er.current&&(clearTimeout(er.current),er.current=null)},[]),Ir=p.useCallback(()=>{Dt(),er.current=setTimeout(()=>it(null),200)},[Dt]);p.useEffect(()=>Dt,[Dt]);const[xe,ve]=p.useState(null),He=p.useMemo(()=>Rt??["list","grid"],[Rt]),[Ye,pt]=p.useState(()=>Cr??He[0]??"list"),[St,Pt]=p.useState(!1),[Fr,Tn]=p.useState(()=>!wu("toolbar_search")),Vr=p.useRef(null),mo=p.useRef(null),[Bn,Ao]=p.useState(0);p.useLayoutEffect(()=>{const j=Vr.current;if(!j)return;Ao(j.clientWidth);const N=new ResizeObserver(ne=>{Ao(ne[0].contentRect.width)});return N.observe(j),()=>N.disconnect()},[]);const Hr=p.useCallback(()=>{ju("toolbar_search"),Tn(!1)},[]);p.useEffect(()=>{if(!Fr)return;const j=setTimeout(Hr,2e3);return()=>clearTimeout(j)},[Fr,Hr]);const Wo=p.useMemo(()=>{const j=Xe??x;return j.length>0?j.map(N=>e.find(ne=>ne.name===N)).filter(N=>N!==void 0):e},[Xe,x,e]),Ur=p.useMemo(()=>Wo.filter(j=>u[j.name]!==!1),[Wo,u]),xo=p.useMemo(()=>new Set(((h==null?void 0:h.levels)??[]).map(j=>j.column)),[h]),Ro=!!(h!=null&&h.enabled&&(h!=null&&h.levels)&&h.levels.length>0),Gr=p.useMemo(()=>{if(!Ro)return Ur;const j=((h==null?void 0:h.levels)??[]).map(ne=>e.find(ze=>ze.name===ne.column)).filter(ne=>ne!==void 0),N=Ur.filter(ne=>!xo.has(ne.name));return[...j,...N]},[Ur,Ro,xo,h,e]),Yr=p.useMemo(()=>{const j=new Set;if(!(h!=null&&h.enabled)||!r)return j;for(const N of r)(N.isGroupHeader||N.__isGroupHeader)&&!N.isCollapsed&&N.groupColumn&&j.add(N.groupColumn);return j},[r,h]),{widths:qr}=$u(Gr,m,Bn,Yr),hr=p.useMemo(()=>e.filter(j=>u[j.name]===!1).length,[e,u]),go=p.useMemo(()=>e.map(j=>j.name),[e]),Jr=p.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(go),[x,go]),In=p.useCallback((j,N)=>{j.preventDefault(),j.stopPropagation(),Rr(N),H(j.clientX),ae(m[N]||150)},[m]);p.useEffect(()=>{if(!jr)return;const j=ne=>{const ze=ne.clientX-Et,Me=Math.max(100,Math.min(600,ut+ze));X==null||X(jr,Me)},N=()=>{Rr(null)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",N)}},[jr,Et,ut,X]);const En=p.useCallback(j=>j==null?"-":typeof j=="object"?JSON.stringify(j):typeof j=="boolean"?j?"true":"false":String(j),[]);p.useCallback(j=>{const N=n.find(ne=>ne.column===j);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:14}}):t.jsx($.ArrowDownward,{sx:{fontSize:14}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:N.priority})]}):null},[n]),p.useCallback(j=>Zn(i,j)?t.jsx(o.IconButton,{size:"small",onClick:ne=>{ne.stopPropagation(),g==null||g(j)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx($.FilterList,{sx:{fontSize:14}})}):null,[i,g]);const Dn=p.useCallback(j=>{w&&w(j)},[w]),_n=p.useCallback((j,N)=>{ur(ne=>{const Me=[...ne??(x.length>0?x:e.map(Qe=>Qe.name))],[ot]=Me.splice(j,1);return Me.splice(N,0,ot),Me})},[x,e]),$n=p.useCallback(()=>{Xe&&pe&&pe(Xe),ur(null)},[Xe,pe]),On=p.useCallback(j=>{if(!w)return;const N=n.find(ne=>ne.column===j);(!N||N.direction!=="asc")&&w(j)},[w,n]),Mn=p.useCallback(j=>{if(!w)return;const N=n.find(ne=>ne.column===j);N?N.direction==="asc"&&w(j):(w(j),setTimeout(()=>w(j),0))},[w,n]),An=p.useCallback(j=>{if(!w)return;const N=n.find(ne=>ne.column===j);N&&(N.direction==="asc"?(w(j),setTimeout(()=>w(j),0)):N.direction==="desc"&&w(j))},[w,n]),Wn=p.useCallback(j=>{ce&&ce(j,!1)},[ce]),Kr=!!(h!=null&&h.enabled&&(h!=null&&h.levels)&&h.levels.length>0),tr=p.useMemo(()=>kt(i),[i]),Rn=n.length>0||tr>0||((h==null?void 0:h.enabled)??!1)||Object.values(u).some(j=>j===!1),Pn=(lo-1)*ar,We=r,st=p.useMemo(()=>{const j=new Set;return nt.forEach(N=>{const ne=N==null?void 0:N.__urm_row_id__;ne!==void 0&&j.add(ne)}),j},[nt]);p.useEffect(()=>{const j=N=>{!Bt||!yt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),Bt(!0,We)),N.key==="Escape"&&(N.preventDefault(),yt()))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Bt,yt,We]);const yo=p.useCallback((j,N)=>{dr==null||dr(We[j],j,N),(cr==="activate"||cr==="both")&&(we(We[j]),Z(!0)),cr!=="activate"&&Je&&(N.shiftKey&&Kt!==null?(N.preventDefault(),br&&br(Kt,j,We)):(Je(We[j]),kr(j)))},[Je,Kt,br,We,dr,cr,we,Z]),Po=p.useMemo(()=>We.length>0&&st.size>0&&We.every(j=>st.has(j==null?void 0:j.__urm_row_id__)),[We,st]),Nn=!Po&&We.some(j=>st.has(j==null?void 0:j.__urm_row_id__)),rr=!!(Je&&Bt&&!qt),Xr=p.useMemo(()=>!(h!=null&&h.enabled)||!(h!=null&&h.levels)?new Set:new Set(h.levels.map(j=>j.column)),[h]),ht=p.useMemo(()=>Gr,[Gr]),No=p.useMemo(()=>{const j=new Map;if(!(h!=null&&h.enabled)||!We)return j;let N=[];for(const ne of We)if(ne.__isGroupHeader||ne.isGroupHeader){const ze=ne.groupLevel??0;N[ze]=ne.groupKey,N=N.slice(0,ze+1),j.has(ne.groupKey)||j.set(ne.groupKey,[])}else if(ne.__urm_is_grouped_data_row__)for(const ze of N)ze&&j.has(ze)&&j.get(ze).push(ne);return j},[h,We]),Qr=p.useCallback(j=>{const N=j.groupLevel,ne=N===0?v.groupRowLevel0||"urm-group-level-0":N===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",ze=N===0?Be=>Be.palette.mode==="dark"?_(Be.palette.action.hover,.12):"#f1f5f9":Be=>Be.palette.mode==="dark"?_(Be.palette.action.hover,.06):"#f8fafc",Me=String(j.groupValue??"(empty)"),ot=`${j.rowCount} ${j.rowCount===1?"item":"items"}`,Qe=No.get(j.groupKey)||[],me=Qe.filter(Be=>st.has(Be==null?void 0:Be.__urm_row_id__)).length,Nt=Qe.length>0&&me===Qe.length,or=me>0&&me<Qe.length;return t.jsxs(o.TableRow,{onClick:()=>L==null?void 0:L(j.groupKey),className:`urm-group-header-row urm-group-level-${N} ${ne} ${v.groupRow||""}`,sx:{bgcolor:ze,"&:hover":{bgcolor:Be=>_(Be.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:Be=>Be.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Nt,indeterminate:or,onChange:()=>{if(!Je)return;const Be=!Nt;Qe.forEach(ft=>{const Vo=st.has(ft==null?void 0:ft.__urm_row_id__);Be!==Vo&&Je(ft)})}})}),t.jsxs(o.TableCell,{colSpan:ht.length,className:`urm-group-cell ${v.groupCellFirst||""} ${v.groupCell||""}`,sx:{pl:`${N*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[N>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${N*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:j.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:18}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Me}),!j.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Be=>_(Be.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:Be=>_(Be.palette.primary.main,.2),ml:.5},children:lt(j.groupColumn||"")}),!!j.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Be=>_(Be.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Be=>_(Be.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:ot}),Object.keys(j.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(j.aggregates).map(([Be,ft])=>Ts(ft)).filter(Boolean).join(" • "),")"]})]})]})]},j.groupKey)},[Xr,ht,rr,h,e,L,v,re,No,st,Je]),Lo=p.useCallback((j,N)=>{const ne=st.has(j==null?void 0:j.__urm_row_id__),ze=Xt===N,Me=vt&&(j==null?void 0:j.__urm_row_id__)===(Qt==null?void 0:Qt.__urm_row_id__),ot=!!(j!=null&&j.__urm_is_grouped_data_row__),Qe=ot?j.__urm_group_level__??(h==null?void 0:h.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:ot?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>pr(N),onMouseLeave:()=>pr(null),onClick:me=>{me.target.closest("[data-row-action-btn]")||yo(N,me)},onDoubleClick:()=>{tt!=null&&tt.includes("doubleClick")&&(we(j),Z(!0))},onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),bt==null||bt(j,N,me),it(null),Ve({mouseX:me.clientX,mouseY:me.clientY,row:j,rowIndex:N}),tt!=null&&tt.includes("rightClick")&&(we(j),Z(!0))},sx:{cursor:"pointer",bgcolor:ne?me=>at(me).bg:Me?me=>_(me.palette.info.main,.12):re!=null&&re.striped&&N%2===1?re.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ne?me=>at(me).hoverBg:Me?me=>_(me.palette.info.main,.2):me=>`var(--highlight-hover-row, ${_(at(me).main,.04)})`},borderBottom:(re==null?void 0:re.rowDivider)??"1px solid",borderColor:"divider"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:me=>me.stopPropagation(),sx:{borderBottom:(re==null?void 0:re.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(re==null?void 0:re.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:ne,onChange:()=>Je==null?void 0:Je(j)})}),ht.map((me,Nt)=>{const or=Nt===0,Be=Xr.has(me.name),ft=Yr.has(me.name);return t.jsxs(o.TableCell,{className:ot&&or?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(re==null?void 0:re.rowPaddingY)??"6px",px:Be&&ft?0:(re==null?void 0:re.cellPaddingX)??2,position:"relative",textAlign:(re==null?void 0:re.cellAlignH)??"left",verticalAlign:(re==null?void 0:re.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(re==null?void 0:re.rowDivider)??"1px solid",borderRight:re==null?void 0:re.colDivider,borderColor:"divider",width:Be&&ft?"32px":void 0,minWidth:Be&&ft?"32px":m[me.name]?`${m[me.name]}px`:`${me.type==="date"?Math.max(fs,180):fs}px`,maxWidth:Be&&ft?"32px":void 0,transition:"all 0.3s ease-in-out"},children:[ot&&or&&Qe>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!Be&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Pu(me,j[me.name],po,dt)})})]},me.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:ze?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:me=>{me.stopPropagation(),me.preventDefault(),it(null),Ve({anchorEl:me.currentTarget,row:j,rowIndex:N})},sx:{color:"text.secondary",opacity:ze?1:0,transition:"opacity 0.12s ease",pointerEvents:ze?"auto":"none","&:hover":{bgcolor:me=>_(me.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},N)},[nt,Pn,Xt,yo,Gr,m,dt,En,Ze,et,Wt,Je,rr,we,Z,Qt,vt,Ve,Kr,xo,bt,tt,Xr,Yr,st]);return t.jsxs(ir.DndProvider,{backend:si.HTML5Backend,children:[t.jsxs(o.Box,{sx:j=>{var ot,Qe,me;const N=((me=(Qe=(ot=j.components)==null?void 0:ot.MuiCard)==null?void 0:Qe.styleOverrides)==null?void 0:me.root)||{},ne=N.border&&N.border!=="none"?N.border:"1px solid",ze=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${j.shape.borderRadius}px`,Me=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:ge(j,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:ne,borderColor:ne!=="none"?"divider":void 0,borderRadius:ze,boxShadow:Me,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:j=>{var ot,Qe,me,Nt,or;const N=((me=(Qe=(ot=j.components)==null?void 0:ot.MuiCardHeader)==null?void 0:Qe.styleOverrides)==null?void 0:me.root)||{},ne=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Nt=j.tokens)==null?void 0:Nt.cardHdrHex)??((or=j.urmTable)==null?void 0:or.headerBg)??j.palette.background.paper,ze=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Me=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:ne,borderBottom:ze,borderColor:ze!=="none"?"divider":void 0,boxShadow:Me,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Ke&&t.jsx(Cu,{}),Ut&&Ot&&Mr&&Mt&&!(ke!=null&&ke.includes("search"))&&t.jsx(o.Tooltip,{open:Fr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:j=>j.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Hr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(iu,{value:ye||"",onChange:j=>{Fr&&Hr(),Ut(j)},searchHistory:Ht,onAddToHistory:Ot,onToggleFavourite:Mr,onDeleteHistory:Mt,disabled:Ke})})}),!(ke!=null&&ke.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Pt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:j=>_(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),T&&I&&C&&s.length>0&&t.jsx(su,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:T,onCreateView:I,onToggleDefault:E,onToggleFavorite:U,onRestoreView:G,onPermanentDelete:M,onEditView:y,onCloneView:k,onCopyLink:P,onDeleteView:oe,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:ee,isReadOnly:Ke}),c&&!Ke&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[C&&t.jsx(o.Button,{onClick:C,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-save-current-bg, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-current-color, ${j.palette.primary.contrastText})`,textTransform:"none",boxShadow:j=>ge(j,"restButton"),"&:hover":{bgcolor:j=>`var(--urm-btn-save-current-hover-bg, ${j.palette.primary.dark})`,boxShadow:j=>ge(j,"hoverButton")}},children:"Save current view"}),W&&t.jsx(o.Button,{onClick:W,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:j=>`var(--urm-btn-save-new-border, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-new-color, ${j.palette.primary.main})`,bgcolor:j=>`var(--urm-btn-save-new-bg, ${j.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:j=>`var(--urm-btn-save-new-hover-border, ${j.palette.primary.dark})`,bgcolor:j=>`var(--urm-btn-save-new-hover-bg, ${_(j.palette.primary.main,.08)})`}},children:"Save new view"}),K&&t.jsx(o.Button,{onClick:K,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-discard-bg, ${_(j.palette.text.primary,.12)})`,color:j=>`var(--urm-btn-discard-color, ${j.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:j=>`var(--urm-btn-discard-hover-bg, ${_(j.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),uo&&Ar&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Ar,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:j=>_(j.palette.text.secondary,.3),"&:hover":{bgcolor:j=>_(j.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx($.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Ke&&b&&!(ke!=null&&ke.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:b,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?j=>zt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx($.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ke&&f&&!(ke!=null&&ke.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:f,size:"small",sx:{position:"relative",color:tr>0?"primary.main":"text.secondary",bgcolor:tr>0?j=>zt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:tr>0?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:tr>0?"primary.main":"text.primary"}},children:[t.jsx($.FilterList,{sx:{fontSize:20}}),tr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:tr})]})}),!Ke&&V&&!(ke!=null&&ke.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:V,size:"small",sx:{position:"relative",color:hr>0||Jr?"primary.main":"text.secondary",bgcolor:hr>0||Jr?j=>zt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:hr>0||Jr?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:hr>0||Jr?"primary.main":"text.primary"}},children:[t.jsx($.ViewColumn,{sx:{fontSize:20}}),hr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:hr})]})}),Kr&&(de||he)&&(()=>{var ne;const j=(((ne=h==null?void 0:h.collapsedGroups)==null?void 0:ne.length)??0)>0,N=j?de:he;return N?t.jsx(o.Tooltip,{title:j?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ze=>_(ze.palette.text.primary,.06),color:"text.primary"}},children:j?t.jsx($.UnfoldMore,{sx:{fontSize:20}}):t.jsx($.UnfoldLess,{sx:{fontSize:20}})})}):null})(),He.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),He.map(j=>{const N=Ye===j,ne=j==="list"?t.jsx($.TableRows,{sx:{fontSize:20}}):t.jsx($.GridView,{sx:{fontSize:20}}),ze=j==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ze,children:t.jsx(o.IconButton,{size:"small",onClick:()=>pt(j),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Me=>zt(Me):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Me=>_(Me.palette.primary.main,.2):Me=>_(Me.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:ne})},j)})]}),!(ke!=null&&ke.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:j=>ve(j.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:j=>_(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!xe,anchorEl:xe,onClose:()=>ve(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&&!(ke!=null&&ke.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Se(),ve(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ke&&se&&!(ke!=null&&ke.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{se(),ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),Te&&!(ke!=null&&ke.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Te(),ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),Q&&!(ke!=null&&ke.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),lr==null?void 0:lr.map(j=>t.jsxs(o.MenuItem,{dense:!0,disabled:j.disabled,onClick:()=>{j.onClick(),ve(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[wr&&wr.length>0&&st.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:j=>at(j).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:j=>j.typography.body2.fontWeight||600,mr:1},children:[st.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>yt==null?void 0:yt(),children:"Clear"}),wr.map(j=>{var ne,ze;const N=Array.from(nt);return(ne=j.hidden)!=null&&ne.call(j,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:j.icon,disabled:(ze=j.disabled)==null?void 0:ze.call(j,N),onClick:()=>j.onClick(N),children:j.label},j.key)})]}),Ye!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(bu,{data:We,visibleColumns:Ur,grouping:h,selectedRowIds:nt,isGrouped:!!Kr,onToggleGroupCollapse:L,onCardClick:(j,N)=>yo(j,N),onCardDoubleClick:j=>{tt!=null&&tt.includes("doubleClick")&&(we(j),Z(!0))},onCardContextMenu:(j,N,ne)=>{bt==null||bt(j,N,ne),it(null),Ve({mouseX:ne.clientX,mouseY:ne.clientY,row:j,rowIndex:N}),tt!=null&&tt.includes("rightClick")&&(we(j),Z(!0))},onOpenRowMenu:(j,N,ne)=>Ve({anchorEl:ne,row:j,rowIndex:N}),onToggleSelection:j=>Je==null?void 0:Je(j),hideSelectionCheckboxes:qt})}),Ye==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Vr,onScroll:j=>{mo.current&&(mo.current.scrollLeft=j.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(qr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[rr&&t.jsx("col",{style:{width:"40px"}}),ht.map(j=>t.jsx("col",{style:{width:`${qr[j.name]}px`}},j.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(re==null?void 0:re.headerBg)??"action.hover",borderBottom:(re==null?void 0:re.rowDivider)??"1px solid",borderColor:"divider"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(re==null?void 0:re.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(re==null?void 0:re.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Po,indeterminate:Nn,onChange:j=>Bt==null?void 0:Bt(j.target.checked,We)})}),ht.map((j,N)=>{const ne=Xr.has(j.name),ze=Yr.has(j.name);return t.jsx(cu,{column:j,index:N,isGrouped:ne&&ze,sortRule:n.find(Me=>Me.column===j.name),hasFilters:Zn(i,j.name),isInSortStack:n.some(Me=>Me.column===j.name),isReadOnly:Ke,hasModifications:Rn,width:ne&&ze?32:m[j.name],onColumnClick:Dn,onMoveColumn:_n,onColumnDragEnd:$n,onResizeStart:In,onSortAscending:B||On,onSortDescending:S||Mn,onRemoveSort:An,onOpenFilterForColumn:g||(()=>{}),onClearFiltersForColumn:ie||(()=>{}),onGroupByColumn:R,onHideColumn:Wn,onManageColumns:V||(()=>{}),onResetLayout:te},j.name)})]})})]})}),t.jsx(o.Box,{ref:mo,onScroll:j=>{Vr.current&&(Vr.current.scrollLeft=j.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:j=>_(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>_(j.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(qr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[rr&&t.jsx("col",{style:{width:"40px"}}),ht.map(j=>t.jsx("col",{style:{width:`${qr[j.name]}px`}},j.name))]}),t.jsx(o.TableBody,{children:We.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:ht.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Kr?We.map((j,N)=>j.isGroupHeader?Qr(j):Lo(j,N)):We.map((j,N)=>Lo(j,N))})]})})]}),It&&vr&&t.jsx(Su,{currentPage:lo,pageSize:ar,totalRows:co,totalFields:e.length,onPageChange:It,onPageSizeChange:vr}),!(It&&vr)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!be,onClose:()=>{Ve(null),it(null)},anchorEl:(be==null?void 0:be.anchorEl)||null,anchorReference:be!=null&&be.anchorEl?"anchorEl":"anchorPosition",anchorPosition:be&&!be.anchorEl?{top:be.mouseY,left:be.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:be!=null&&be.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Fe!=null&&Fe.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(we(be.row),Z(!0)),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Fe!=null&&Fe.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(Zt(be.row),Lr(be.rowIndex),Pr(!0)),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Fe!=null&&Fe.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(et==null||et(be.rowIndex,be.row)),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),be&&(Sr==null?void 0:Sr.map(j=>{var N,ne;return(N=j.hidden)!=null&&N.call(j,be.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(ne=j.disabled)==null?void 0:ne.call(j,be.row),onClick:()=>{j.onClick(be.row,be.rowIndex),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key)})),st.size>0&&Gt&&!(Fe!=null&&Fe.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:j=>{Dt(),it(j.currentTarget)},onMouseLeave:Ir,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",st.size,")"]})]}),t.jsx($.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Br,anchorEl:Br,placement:"right-start",transition:!0,sx:{zIndex:j=>j.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:j})=>t.jsx(o.Grow,{...j,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:Dt,onMouseLeave:Ir,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Gt("csv"),it(null),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Gt("excel"),it(null),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Gt("json"),it(null),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),Jt.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Gt("pdf"),it(null),Ve(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Fe!=null&&Fe.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(Tr(be.row),Ce(!0)),Ve(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(ku,{open:vt,onClose:()=>{Z(!1),we(null)},row:Qt,schema:e,reportName:Yt}),t.jsx(Tu,{open:ho,onClose:()=>{Pr(!1),Zt(null),Lr(null)},onSave:j=>{Nr!==null&&(Ze==null||Ze(Nr,j))},row:fo,schema:e,reportName:Yt}),t.jsx(zu,{open:fe,onClose:()=>{Ce(!1),Tr(null)},onConfirm:()=>{zr!==null&&(Wt==null||Wt(zr))},row:zr,schema:e}),t.jsx(Js,{isOpen:St,onClose:()=>Pt(!1)})]})}function $r({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>_(s.palette.primary.main,.08)}},children:t.jsx($.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>_(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>_(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>_(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const Or={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},Qn=40;function Lu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Fu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),c=p.useMemo(()=>{const u=a?nn(a.type):[],x=i.filter.allowedOperators;return x.length>0?u.filter(m=>x.includes(m.value)):u},[a,i]),l=El(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var h;const x=r.find(v=>v.name===u.target.value),m=x?nn(x.type):[];s({column:u.target.value,operator:((h=m[0])==null?void 0:h.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:lt(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ta({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const u=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((x,m)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Qn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[m<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),m>0&&t.jsx(Lu,{operator:e.operator,onSelect:h=>l(v=>ci(v,e.id,h))}),m>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Qn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:m>0?1:0},children:qe(x)?t.jsx(Vu,{group:x,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Fu,{condition:x,schema:n,availableColumns:i,devConfig:s,onUpdate:h=>l(v=>li(v,x.id,h))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(h=>di(h,x.id)),sx:{mt:m>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx($.Close,{sx:{fontSize:16}})})]},x.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Qn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(x=>{var m,h,v;return ao(x,e.id,{id:so(),column:((m=i[0])==null?void 0:m.name)??"",operator:((v=nn(((h=i[0])==null?void 0:h.type)??"string")[0])==null?void 0:v.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(x=>ao(x,e.id,$t())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Vu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>_(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>_(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ta,{...e})})}function Hu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=p.useState(r??$t()),u=gr(),x=p.useMemo(()=>e.filter(b=>b.type!=="mixed"&&b.type!=="null"&&b.type!=="array"&&b.type!=="object"),[e]);p.useEffect(()=>{var g;const b=r??$t();if(s&&b.children.length===0){const T=e.find(I=>I.name===s);if(T){l(ao(b,b.id,{id:so(),column:s,operator:((g=nn(T.type)[0])==null?void 0:g.value)??"equals"}));return}}l(b)},[r,s,e]);const m=kt(c),h=u.filter.maxConditions,v=p.useCallback(b=>{l(g=>b(g))},[]),w=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??$t()),[c,r]),B=p.useCallback(()=>{n(c),i()},[c,n,i]),S=p.useCallback(()=>{l(r??$t()),i()},[r,i]),f=p.useCallback(()=>{n($t()),i()},[n,i]);return t.jsx(o.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:b=>_(b.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b=>b.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:b=>b.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:b=>rt(b),bgcolor:"background.paper",outline:"none",boxShadow:b=>ue(b).paper.boxShadow,border:b=>ue(b).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:b=>ue(b).header.backgroundColor,borderBottom:b=>ue(b).header.borderBottom,boxShadow:b=>ue(b).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:b=>b.typography.h6.fontSize||"1.125rem",fontWeight:b=>b.typography.h6.fontWeight||500,color:b=>b.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx($r,{content:Or.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:S,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:b=>_(b.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:b=>_(b.palette.text.primary,.3)}}},children:[m===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:b=>b.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${lt(s)}"`:"","."]}),t.jsx(ta,{group:c,depth:0,schema:e,availableColumns:x,devConfig:u,maxConditions:h,totalConditions:m,onChange:v}),m>=h&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:b=>b.typography.caption.fontSize||"0.75rem",fontWeight:b=>b.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",h," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:f,disabled:m===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:S,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,disabled:!w,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,boxShadow:b=>ge(b,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const ms="SORT_RULE";function Uu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:c},l]=ir.useDrop({accept:ms,collect(m){return{handlerId:m.getHandlerId()}},hover(m,h){var g;if(!a.current)return;const v=m.index,w=r;if(v===w)return;const B=(g=a.current)==null?void 0:g.getBoundingClientRect(),S=(B.bottom-B.top)/2,f=h.getClientOffset(),b=((f==null?void 0:f.y)??0)-B.top;v<w&&b<S||v>w&&b>S||(s(v,w),m.index=w)}}),[{isDragging:u},x]=ir.useDrag({type:ms,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});return x(l(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:m=>ge(m,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:m=>`0 1px 2px 0 ${_(m.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:m=>m.typography.body2.fontSize||"0.875rem",fontWeight:m=>m.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:m=>n(r,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>zt(m),"&:hover":{bgcolor:m=>_(m.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>zt(m),"&:hover":{bgcolor:m=>_(m.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:m=>_(m.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]})}function Gu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const x=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),m=gr(),h=p.useCallback(T=>{if(!T||l.length>=m.sort.maxLevels)return;const I={column:T,direction:"asc",priority:l.length+1};u([...l,I]),c(""),setTimeout(()=>{var C;return(C=document.activeElement)==null?void 0:C.blur()},0)},[l,m.sort.maxLevels]),v=p.useCallback(T=>{const C=l.filter((W,K)=>K!==T).map((W,K)=>({...W,priority:K+1}));u(C)},[l]),w=p.useCallback((T,I)=>{const C=[...l];C[T]={...C[T],direction:I},u(C)},[l]),B=p.useCallback((T,I)=>{const C=[...l],[W]=C.splice(T,1);C.splice(I,0,W);const K=C.map((E,U)=>({...E,priority:U+1}));u(K)},[l]),S=p.useCallback(()=>{n([]),i()},[n,i]),f=p.useCallback(()=>{n(l),i()},[l,n,i]),b=p.useCallback(()=>{u([...r]),c(""),i()},[r,i]),g=e.filter(T=>!l.some(I=>I.column===T.name));return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:T=>_(T.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:T=>T.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:T=>rt(T),bgcolor:"background.paper",outline:"none",boxShadow:T=>ue(T).paper.boxShadow,border:T=>ue(T).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:T=>ue(T).header.backgroundColor,borderBottom:T=>ue(T).header.borderBottom,boxShadow:T=>ue(T).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:T=>T.typography.h6.fontSize||"1.125rem",fontWeight:T=>T.typography.h6.fontWeight||500,color:T=>T.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx($r,{content:Or.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T=>_(T.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:T=>_(T.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=m.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:T=>h(T.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:g.map(T=>t.jsx(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:I=>zt(I),"&:hover":{bgcolor:I=>_(I.palette.primary.main,.2)}}},children:lt(T.name)},T.name))})]}),l.length>=m.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500},children:["Maximum ",m.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",m.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:S,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((T,I)=>t.jsx(Uu,{rule:T,index:I,onToggleDirection:w,onRemove:v,onMove:B},`${T.column}-${I}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:b,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:f,variant:"contained",disabled:!x||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ge(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ge(T,"hoverButton")},"&:active":{boxShadow:T=>ge(T,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Ko=50;function xs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[x,m]=p.useState(s),[h,v]=p.useState(!1),[w,B]=p.useState(a),[S,f]=p.useState(c),b=()=>{if(!x.trim()){v(!0);return}if(x.trim().length>Ko){v(!0);return}r(x.trim(),w.trim(),S),n()},g=I=>{I.key==="Enter"&&!I.shiftKey?b():I.key==="Escape"&&n()},T=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:I=>({mt:8,borderRadius:rt(I),...ue(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(I).header}),children:[T(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:x,onChange:I=>{I.target.value.length<=Ko&&m(I.target.value),h&&I.target.value.trim()&&v(!1)},onKeyDown:g,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Ko},error:h&&!x.trim(),helperText:h&&!x.trim()?"View name is required":`${x.length} / ${Ko}`}),t.jsx(o.TextField,{label:"Description (optional)",value:w,onChange:I=>B(I.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:I=>I.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[kt(e.filters)," filter",kt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ga(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:S,onChange:I=>f(I.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:b,variant:"contained",disabled:l&&!i,startIcon:t.jsx($.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>ge(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>ge(I,"hoverButton")},"&:active":{boxShadow:I=>ge(I,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Yu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:rt(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx($.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ge(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ge(i,"hoverButton")},"&:active":{boxShadow:i=>ge(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const gs="COLUMN";function qu({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:c,onToggleVisibility:l,onWidthChange:u,moveColumn:x}){const m=p.useRef(null),[h,v]=p.useState(i.toString());p.useEffect(()=>{v(i.toString())},[i]);const[{handlerId:w},B]=ir.useDrop({accept:gs,collect(C){return{handlerId:C.getHandlerId()}},hover(C,W){var k;if(!m.current)return;const K=C.index,E=r;if(K===E)return;const U=(k=m.current)==null?void 0:k.getBoundingClientRect(),G=(U.bottom-U.top)/2,M=W.getClientOffset(),y=((M==null?void 0:M.y)??0)-U.top;K<E&&y<G||K>E&&y>G||(x(K,E),C.index=E)}}),[{isDragging:S},f]=ir.useDrag({type:gs,item:()=>({index:r}),collect:C=>({isDragging:C.isDragging()})});f(B(m));const b=()=>{const C=parseInt(h);if(isNaN(C)){v(i.toString()),u(e.name,i);return}const W=Math.max(s,Math.min(a,C));v(W.toString()),u(e.name,W)},g=C=>{if(C===""||/^\d+$/.test(C)){v(C);const W=parseInt(C);if(!isNaN(W)&&W>=s){const K=Math.min(a,W);u(e.name,K)}}},T=C=>{C.key==="Enter"&&(C.preventDefault(),b(),C.target.blur())},I=C=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[C]||"text.secondary";return t.jsxs(o.TableRow,{ref:m,"data-handler-id":w,sx:{opacity:S?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx($.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||400,fontSize:C=>C.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:lt(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${I(e.type)}15`,color:I(e.type),border:`1px solid ${I(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:h,onChange:C=>g(C.target.value),onBlur:b,onKeyDown:T,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:C=>C.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>l(e.name,!n),disabled:!n&&!c,title:n?"Hide column":c?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx($.Visibility,{sx:{fontSize:20}}):t.jsx($.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?C=>_(C.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Ju({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:x,onClose:m}){const h=gr(),[v,w]=p.useState(!1),[B,S]=p.useState(n),[f,b]=p.useState(i),[g,T]=p.useState("all");p.useEffect(()=>{S(n)},[n]),p.useEffect(()=>{b(i)},[i]);const I=(k,P)=>{b(oe=>({...oe,[k]:P})),u==null||u(k,P)},C=(k,P)=>{const oe=[...B],[d]=oe.splice(k,1);oe.splice(P,0,d),S(oe),l(oe)},W=()=>{x(),w(!1)},E=B.map(k=>e.find(P=>P.name===k)).filter(k=>k!==void 0).filter(k=>{const P=r[k.name]??!0;return g==="active"?P:g==="hidden"?!P:!0}),U=Object.values(r).filter(k=>k).length,G=e.length,M=s.find(k=>k.id===a),y=p.useMemo(()=>{if(!M)return!1;const k=M.snapshot,P=k.columnVisibility??{},oe=JSON.stringify(r)!==JSON.stringify(P),d=k.columnOrder??[],J=n??[],ee=JSON.stringify(J)!==JSON.stringify(d)&&!(J.length===0&&d.length===0),Se=k.columnWidths??{},V=JSON.stringify(f)!==JSON.stringify(Se);return oe||ee||V},[M,r,n,f]);return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:m,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>_(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:k=>rt(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>ue(k).paper.boxShadow,border:k=>ue(k).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,flexShrink:0,bgcolor:k=>ue(k).header.backgroundColor,borderBottom:k=>ue(k).header.borderBottom,boxShadow:k=>ue(k).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:k=>k.typography.h6.fontSize||"1.125rem",fontWeight:k=>k.typography.h6.fontWeight||500,color:k=>k.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx($r,{content:Or.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:m,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:g,onChange:(k,P)=>T(P),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:k=>at(k).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:k=>at(k).hoverBg},"&:hover":{color:"text.primary",bgcolor:k=>at(k).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:k=>at(k).hoverBg},"&:hover":{color:"text.primary",bgcolor:k=>at(k).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:k=>at(k).hoverBg},"&:hover":{color:"text.primary",bgcolor:k=>at(k).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k=>_(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>_(k.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${h.columns.minColumnWidth}px, max: ${h.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx($.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:E.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:k=>k.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):E.map((k,P)=>{const oe=r[k.name]??!0,d=oe||U<h.columns.maxVisible;return t.jsx(qu,{column:k,index:P,isVisible:oe,width:f[k.name]||170,minColumnWidth:h.columns.minColumnWidth,maxColumnWidth:h.columns.maxColumnWidth,canToggleOn:d,onToggleVisibility:c,onWidthChange:I,moveColumn:C},k.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[U," of ",G," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>w(!0),disabled:!y,variant:"outlined",startIcon:t.jsx($.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),v&&t.jsx(o.Box,{onClick:()=>w(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>_(k.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:k=>Mo(k),bgcolor:"background.paper",boxShadow:k=>ue(k).paper.boxShadow,border:k=>ue(k).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>w(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:k=>`${k.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:W,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>ge(k,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:k=>ge(k,"hoverButton")},"&:active":{boxShadow:k=>ge(k,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Ku({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var K;const[a,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[x,m]=p.useState(null),h=p.useMemo(()=>Pa(e),[e]),v=p.useMemo(()=>h.filter(E=>!a.levels.some((U,G)=>U.column===E.name&&G!==x)),[h,a.levels,x]),w=gr(),B=a.levels.length<w.grouping.maxLevels&&v.length>0&&(w.grouping.allowNested||a.levels.length===0),S=p.useCallback(E=>{!B||!E||(c({...a,levels:[...a.levels,{column:E}],enabled:!0}),u(""),setTimeout(()=>{var U;return(U=document.activeElement)==null?void 0:U.blur()},0))},[B,a]),f=p.useCallback(E=>{const U=a.levels.filter((G,M)=>M!==E);if(U.length===0){n(null),i();return}c({...a,levels:U,enabled:U.length>0})},[a,n,i]),b=p.useCallback(E=>{m(E),u(a.levels[E].column)},[a.levels]),g=p.useCallback(()=>{if(x===null||!l)return;const E=[...a.levels];E[x]={column:l},c({...a,levels:E}),m(null),u("")},[x,l,a]),T=p.useCallback(()=>{m(null),u("")},[]),I=p.useCallback((E,U)=>{const G=U==="up"?E-1:E+1;if(G<0||G>=a.levels.length)return;const M=[...a.levels],[y]=M.splice(E,1);M.splice(G,0,y),c({...a,levels:M})},[a]),C=p.useCallback(()=>{n(null),i()},[n,i]),W=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:E=>_(E.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:E=>E.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:E=>E.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:E=>rt(E),bgcolor:"background.paper",outline:"none",boxShadow:E=>ue(E).paper.boxShadow,border:E=>ue(E).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:E=>ue(E).header.backgroundColor,borderBottom:E=>ue(E).header.borderBottom,boxShadow:E=>ue(E).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:E=>E.typography.h6.fontSize||"1.125rem",fontWeight:E=>E.typography.h6.fontWeight||500,color:E=>E.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx($r,{content:Or.grouping,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E=>_(E.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:E=>_(E.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[x===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:E=>S(E.target.value),disabled:!B,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),v.map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:U=>zt(U),"&:hover":{bgcolor:U=>_(U.palette.primary.main,.2)}}},children:[lt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),a.levels.length>=w.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),h.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),x!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:E=>`1px solid ${_(E.palette.warning.main,.5)}`,bgcolor:E=>_(E.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:E=>E.typography.body2.fontWeight||500,mb:1.5,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",x+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:E=>u(E.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[x].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:E=>zt(E)}},children:[a.levels[x].column," (",(K=e.find(E=>E.name===a.levels[x].column))==null?void 0:K.type.toUpperCase(),")"]}),v.filter(E=>E.name!==a.levels[x].column).map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:U=>zt(U)}},children:[lt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:g,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:E=>ge(E,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:T,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&x===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:C,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((E,U)=>{const G=e.find(M=>M.name===E.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:M=>ge(M,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${U+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:M=>`0 1px 2px 0 ${_(M.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:M=>M.typography.body2.fontWeight||500,fontSize:M=>M.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:E.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:M=>M.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:G==null?void 0:G.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>I(U,"up"),disabled:U===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>I(U,"down"),disabled:U===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>b(U),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx($.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>f(U),sx:{color:"text.secondary","&:hover":{bgcolor:M=>_(M.palette.error.main,.08),color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:18}})})]})]},U)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:W,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>ge(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>ge(E,"hoverButton")},"&:active":{boxShadow:E=>ge(E,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Xu({onExportAnyway:e,onSaveAndExport:r,onCancel:n}){return t.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx($.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx($.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx($.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const ys=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function Qu(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function Zu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function ep({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=ct(),s=i.palette,[a,c]=p.useState("1h"),[l,u]=p.useState(!1),x=[...e].sort((B,S)=>new Date(S.timestamp).getTime()-new Date(B.timestamp).getTime()),m=ys.find(B=>B.key===a),h=Qu(e,m.ms),v=()=>u(!0),w=()=>{n&&(n(Zu(e,m.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:_(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:rt(i),bgcolor:"background.paper",overflow:"hidden",...ue(i).paper,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...ue(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx($r,{content:Or.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[x.length," event",x.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:B=>c(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:_(s.text.primary,.3)}},children:ys.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:_(s.error.main,.5),"&:hover":{bgcolor:_(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:_(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(s.text.primary,.14),borderRadius:3}},children:x.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx($.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:x.map(B=>{const S=hu(i,B.feature),{summary:f,detail:b}=sl(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:_(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:cl(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:_(S,.1),color:S,border:`1px solid ${_(S,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:f}),b&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:b}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:dl(B.timestamp)})]}),B.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Mo(i),...ue(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:_(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[h," audit record",h!==1?"s":""]})," ",m.key==="all"?"from all time":`from the ${m.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:w,variant:"contained",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",h," Record",h!==1?"s":""]})]})]})]})}function tp({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[c,l]=p.useState(""),[u,x]=p.useState([]),[m,h]=p.useState(""),[v,w]=p.useState(""),B=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),S=()=>{const C=c.trim();if(C){if(!B(C)){w("Please enter a valid email address");return}if(u.includes(C)){w("This email is already added");return}x([...u,C]),l(""),w("")}},f=C=>{x(u.filter(W=>W!==C))},b=C=>{C.key==="Enter"&&(C.preventDefault(),S())},g=()=>{if(!n.trim()){h("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},T=C=>{i(C),m&&h("")},I=C=>{l(C),v&&w("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:C=>_(C.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:C=>C.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:C=>C.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:C=>rt(C),bgcolor:"background.paper",outline:"none",boxShadow:C=>ue(C).paper.boxShadow,border:C=>ue(C).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:C=>ue(C).header.backgroundColor,borderBottom:C=>ue(C).header.borderBottom,boxShadow:C=>ue(C).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:C=>C.typography.h6.fontSize||"1.125rem",fontWeight:C=>C.typography.h6.fontWeight||500,color:C=>C.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:C=>_(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>_(C.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx($.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:C=>`1px solid ${_(C.palette.primary.main,.3)}`,bgcolor:C=>zt(C),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:C=>C.typography.body2.fontSize||"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:C=>C.typography.caption.fontSize||"0.6875rem",fontWeight:C=>C.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:C=>T(C.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:C=>C.typography.caption.fontSize||"0.6875rem",fontWeight:C=>C.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:C=>a(C.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:C=>C.typography.caption.fontSize||"0.6875rem",fontWeight:C=>C.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:c,onChange:C=>I(C.target.value),onKeyPress:b,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),t.jsx(o.Button,{onClick:S,variant:"outlined",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:C=>`${C.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(C=>t.jsx(o.Chip,{label:C,onDelete:()=>f(C),deleteIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{bgcolor:W=>zt(W),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},C))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:g,variant:"contained",startIcon:t.jsx($.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,boxShadow:C=>ge(C,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:C=>ge(C,"hoverButton")},"&:active":{boxShadow:C=>ge(C,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function rp({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx($.Link,{sx:{fontSize:14}}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx($.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>_(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function op({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>_(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>rt(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>ue(c).paper.boxShadow,border:c=>ue(c).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:c=>ue(c).header.backgroundColor,borderBottom:c=>ue(c).header.borderBottom,boxShadow:c=>ue(c).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.h6.fontSize||"1.125rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:c=>c.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:c=>c.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:c=>_(c.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx($.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:c=>c.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(c=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>ge(l,"restButtonLight")}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:c.name}),c.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>_(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>ge(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ge(c,"hoverButton")},"&:active":{boxShadow:c=>ge(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ra={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},np=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],ip=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function sp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=ip.some(l=>l.test(i.name));let a=!1;const c=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(a=c.filter(u=>np.some(x=>x.test(u))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function zn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(c=>{const l=n.map(x=>String(x[c]??"")).filter(x=>x.length>0);if(l.length===0)return 5;const u=l.reduce((x,m)=>x+m.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function ap(e,r){const n=zn(e,r);return Math.ceil(n*3.5)}function lp(e,r){const n=zn(e,r);return Math.ceil(n*.7)}function cp(e,r){const n=zn(e,r);return Math.ceil(n*2)}function dp(e,r,n){switch(e){case"csv":return zn(r,n);case"excel":return lp(r,n);case"json":return ap(r,n);case"pdf":return cp(r,n)}}function bs(e,r){return Math.ceil(e/r)}function up(e,r,n,i,s=ra){const a=[],c=dp(e,r,n),l=r.length;if(l>s.maxRowsHard){const m=bs(l,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${m} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const m=bs(l,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${m} smaller export${m>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${zo(c)} exceeds the ${zo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${zo(c)}`,detail:`This exceeds the recommended ${zo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const m=sp(i.filter(h=>n.includes(h.name)),r);if(m.length>0){const h=m.length>s.maxImageColumns;a.push({type:"image_columns",severity:h?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:h?`Exporting ${m.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:m.length,limit:s.maxImageColumns})}}const u=a.some(m=>m.severity==="error"),x=a.some(m=>m.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:x,estimatedBytes:c}}function zo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pp({violation:e}){const n=ct().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=_(i?n.error.main:n.warning.main,.06),c=i?_(n.error.main,.25):_(n.warning.main,.3),l=i?$.ErrorOutline:$.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:c},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx($.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function hp({format:e}){const r=ct(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:_(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function vs({checked:e}){const r=ct();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function fp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:u=[],initialFormat:x,initialScope:m="visible",initialColumnScope:h="visible",classTokens:v={},onExport:w,onClose:B}){const S=ct(),f=S.palette,b=gr(),g=p.useMemo(()=>{var pe,ce,ie,te,se;const J=((ie=(ce=(pe=S.components)==null?void 0:pe.MuiCard)==null?void 0:ce.styleOverrides)==null?void 0:ie.root)||{},ee=J.border&&J.border!=="none"?J.border:(te=S.tokens)!=null&&te.cardBodyBorder&&S.tokens.cardBodyBorder!=="none"?S.tokens.cardBodyBorder:f.divider,Se=J.borderRadius!==void 0?typeof J.borderRadius=="number"?`${J.borderRadius}px`:J.borderRadius:`${S.shape.borderRadius}px`,V=J.boxShadow&&J.boxShadow!=="none"?J.boxShadow:((se=S.tokens)==null?void 0:se.cardBodyShadow)||ge(S,"menu"),X=at(S);return{sectionBorder:`var(--urm-export-section-border, ${ee})`,sectionTitleColor:`var(--urm-export-section-title-color, ${f.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${f.background.paper})`,cardBg:`var(--urm-export-card-bg, ${f.background.paper})`,cardBorder:`var(--urm-export-card-border, ${ee})`,cardRadius:Se,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${f.mode==="dark"?_(f.common.white,.08):_(f.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${_(X.main,f.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${X.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${f.mode==="dark"?f.primary.light:f.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${f.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${f.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${f.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${S.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${S.spacing(1.5)})`}},[f,S]),T=x||b.export.allowedFormats[0]||"csv",[I,C]=p.useState(T),[W,K]=p.useState(m),[E,U]=p.useState(h),G=W==="visible"?r:e,M=E==="visible"?i:s,y=p.useMemo(()=>W==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[W,r,e,u,l]),k=p.useMemo(()=>E==="all"?a.map(J=>J.name):a.map(J=>J.name).slice(0,i),[E,a,i]),P=p.useMemo(()=>up(I,y,k,a,ra),[I,y,k,a]),oe=()=>{P.hasBlockingViolation||(w({format:I,scope:W,columnScope:E}),B())},d={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:_(f.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:S.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:J=>J.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:rt(S),bgcolor:g.sectionTitleBg,overflow:"hidden",border:`1px solid ${g.cardBorder}`,boxShadow:g.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:J=>ue(J).header.backgroundColor,borderBottom:J=>ue(J).header.borderBottom,boxShadow:J=>ue(J).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:f.text.primary},children:"Export Report"}),t.jsx($r,{content:Or.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:f.text.secondary,borderRadius:"50%","&:hover":{bgcolor:f.action.hover,color:f.text.primary}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:g.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(f.text.primary,.15),borderRadius:3}},children:[P.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:P.violations.map((J,ee)=>t.jsx(pp,{violation:J},ee))}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${g.sectionBorder}`,borderRadius:"12px",p:g.sectionPadding,pt:2.25,bgcolor:g.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:g.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:g.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:g.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:b.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:b.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:b.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:b.export.allowedFormats.includes("pdf")}].filter(J=>J.allowed).map(J=>{const ee=I===J.id;return t.jsxs(o.Box,{onClick:()=>C(J.id),className:`urm-export-format-card ${ee?v.formatCardSelected||"":v.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:g.cardRadius,border:ee?`2px solid ${g.cardSelectedBorder}`:`1px solid ${g.cardBorder}`,boxShadow:ee?void 0:g.cardShadow,bgcolor:ee?g.cardSelectedBg:g.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?g.cardSelectedBorder:_(f.text.primary,.25),bgcolor:ee?g.cardSelectedBg:g.cardHoverBg}},children:[ee&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:g.cardSelectedBorder,color:f.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${_(f.primary.main,.3)}`},children:t.jsx($.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(hp,{format:J.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:ee?g.cardSelectedColor:f.text.primary},children:J.title}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:13}})})})]})]},J.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${g.sectionBorder}`,borderRadius:"12px",p:g.sectionPadding,pt:2.25,bgcolor:g.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:g.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:g.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:g.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx($.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(J=>{const ee=W===J.value;return t.jsxs(o.Box,{onClick:()=>K(J.value),className:`urm-export-row-card ${ee?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:g.cardRadius,border:ee?`2px solid ${g.cardSelectedBorder}`:`1px solid ${g.cardBorder}`,boxShadow:ee?void 0:g.cardShadow,bgcolor:ee?g.cardSelectedBg:g.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?g.cardSelectedBorder:_(f.text.primary,.25),bgcolor:ee?g.cardSelectedBg:g.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:ee}),t.jsx(o.Box,{sx:{color:ee?g.cardSelectedColor:f.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?g.cardSelectedColor:f.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${g.sectionBorder}`,borderRadius:"12px",p:g.sectionPadding,pt:2.25,bgcolor:g.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:g.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:g.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:g.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(J=>{const ee=E===J.value;return t.jsxs(o.Box,{onClick:()=>U(J.value),className:`urm-export-column-card ${ee?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:g.cardRadius,border:ee?`2px solid ${g.cardSelectedBorder}`:`1px solid ${g.cardBorder}`,boxShadow:ee?void 0:g.cardShadow,bgcolor:ee?g.cardSelectedBg:g.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?g.cardSelectedBorder:_(f.text.primary,.25),bgcolor:ee?g.cardSelectedBg:g.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:ee}),t.jsx(o.Box,{sx:{color:ee?g.cardSelectedColor:f.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?g.cardSelectedColor:f.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${g.sectionBorder}`,borderRadius:"12px",p:g.sectionPadding,pt:2.25,bgcolor:g.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:g.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:g.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Format",value:d[I]},{icon:t.jsx($.FormatListNumberedOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Rows to Export",value:G.toLocaleString()},{icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Columns to Export",value:String(M)},{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Estimated File Size",value:`~${zo(P.estimatedBytes)}`,highlight:P.hasBlockingViolation?"error.main":P.hasWarning?"warning.main":void 0}].map(({icon:J,label:ee,value:Se,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[J,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:f.text.secondary,fontWeight:500},children:ee})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??f.text.primary},children:Se})]},ee))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[P.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx($.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:J=>J.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:J=>J.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:B,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:f.text.primary,borderColor:g.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:g.cardHoverBg,borderColor:_(f.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:oe,disabled:P.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx($.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:g.primaryBtnBg,color:g.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${_(f.primary.main,.25)}`,"&:hover":{bgcolor:g.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:_(f.primary.main,.4),color:g.primaryBtnColor}},children:["Download ",d[I]]})]})]})})}function mp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx($.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function xp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx($.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx($.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Sl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx($.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:c}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class gp extends p.Component{constructor(n){super(n);ji(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Vt.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>_(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>_(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx($.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function yp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx($.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Xo({children:e,feature:r,onError:n}){return t.jsx(gp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(yp,{feature:r}),children:e})}const bp=[{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"}],vp=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}];function Co({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function Sp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),x=()=>l(mt),m=()=>{i(c),r()},h={sort:f=>l(b=>({...b,sort:{...b.sort,...f}})),filter:f=>l(b=>({...b,filter:{...b.filter,...f}})),columns:f=>l(b=>({...b,columns:{...b.columns,...f}})),grouping:f=>l(b=>({...b,grouping:{...b.grouping,...f}})),export:f=>l(b=>({...b,export:{...b.export,...f}}))},v=f=>{const b=c.filter.allowedOperators,g=b.includes(f)?b.filter(T=>T!==f):[...b,f];g.length!==0&&h.filter({allowedOperators:g})},w=f=>{const b=c.export.allowedFormats,g=b.includes(f)?b.filter(T=>T!==f):[...b,f];g.length!==0&&h.export({allowedFormats:g})},B=[{label:"Sort",icon:t.jsx($.SwapVert,{sx:{fontSize:f=>f.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx($.FilterList,{sx:{fontSize:f=>f.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx($.ViewColumn,{sx:{fontSize:f=>f.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx($.Layers,{sx:{fontSize:f=>f.typography.body1.fontSize}})},{label:"Export",icon:t.jsx($.Download,{sx:{fontSize:f=>f.typography.body1.fontSize}})}],S=f=>JSON.stringify(c[f])===JSON.stringify(mt[f]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:f=>rt(f),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:f=>f.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:f=>f.shape.borderRadius,bgcolor:f=>_(f.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:f=>f.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(f,b)=>a(b),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:f=>f.typography.caption.fontSize,textTransform:"none",fontWeight:f=>f.typography.button.fontWeight,gap:.5}},children:B.map((f,b)=>t.jsx(o.Tab,{label:f.label,icon:f.icon,iconPosition:"start"},b))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(Co,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!S("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(f,b)=>h.sort({maxLevels:b}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),t.jsxs(o.Alert,{severity:"info",sx:{borderRadius:f=>f.shape.borderRadius,fontSize:f=>f.typography.caption.fontSize},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(Co,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!S("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(f,b)=>h.filter({maxConditions:b}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(f=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:b=>b.typography.overline.fontSize,display:"block",mb:.5},children:f}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:bp.filter(b=>b.group===f).map(b=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(b.value),onChange:()=>v(b.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:b.label}),sx:{mr:1.5}},b.value))})]},f))]})]}),t.jsxs(Co,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!S("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(f,b)=>h.columns({maxVisible:b}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:c.columns.minColumnWidth,onChange:(f,b)=>h.columns({minColumnWidth:b}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:f=>`${f}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(f,b)=>h.columns({maxColumnWidth:b}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:f=>`${f}px`})]})]})]})]}),t.jsxs(Co,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!S("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(f=>t.jsxs(o.Box,{onClick:()=>h.grouping({maxLevels:f}),sx:{flex:1,py:2.5,borderRadius:b=>Number(b.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===f?"primary.main":"divider",bgcolor:c.grouping.maxLevels===f?b=>_(b.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:b=>_(b.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===f?"primary.main":"text.secondary"},children:f}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][f-1]})]},f))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:f=>h.grouping({allowNested:f.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:f=>h.grouping({allowCollapse:f.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:f=>f.shape.borderRadius,fontSize:f=>f.typography.caption.fontSize},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(Co,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!S("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:vp.map(f=>t.jsxs(o.Box,{onClick:()=>w(f.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:b=>b.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(f.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(f.value)?b=>_(b.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(f.value),onChange:()=>w(f.value),onClick:b=>b.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:f.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:f.desc})]})]},f.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:f=>_(f.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx($.RestartAlt,{sx:{fontSize:18}}),onClick:x,size:"small",sx:{fontSize:f=>f.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:f=>_(f.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:f=>f.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:f=>Number(f.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:m,size:"small",variant:"contained",sx:{fontSize:f=>f.typography.body2.fontSize,px:2.5,borderRadius:f=>Number(f.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const Cp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wp={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Zo(e,r,n,i,s=new Date){const[a,c]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,c,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,x=l.getDay();let m=u-x;return m<0&&(m+=7),m===0&&l<=s&&(m=7),l.setDate(l.getDate()+m),l.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return l.setDate(u),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(u)),l.toISOString()}return l.toISOString()}function jp(e){const r=oa(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Cp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${wp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function oa(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function kp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function zp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=oa(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function na(e){return`urm_schedules_${e}`}function ia(e){try{const r=localStorage.getItem(na(e));return r?JSON.parse(r).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function sa(e,r){try{localStorage.setItem(na(e),JSON.stringify(r))}catch{}}const Tp=[{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"}],Bp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,aa={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Dr={"& .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 Ip({initial:e=aa,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[c,l]=p.useState(!1),[u,x]=p.useState(!1),m=(w,B)=>a(S=>({...S,[w]:B})),h=s.email.trim().length>0&&!Bp.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!h;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:w=>_(w.palette.text.primary,.06)}},children:t.jsx($.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:w=>w.typography.body2.fontWeight||600,fontSize:w=>w.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:w=>{m("name",w.target.value),c&&w.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Dr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:w=>m("frequency",w.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:w=>m("dayOfWeek",Number(w.target.value)),children:Tp.map(w=>t.jsx(o.MenuItem,{value:w.value,children:w.label},w.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:w=>m("dayOfMonth",Number(w.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:Dr}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:w=>m("time",w.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Dr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:w=>m("format",w.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:w=>m("scope",w.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:w=>m("email",w.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:u&&h,helperText:u&&h?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Dr}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx($.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:w=>_(w.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Ep({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Mo(i),...ue(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>_(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Dp({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const c=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>_(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>_(l.palette.success.main,.1):l=>_(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:jp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>_(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx($.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",kp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",zp(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>_(l.palette.primary.main,.08)}},children:t.jsx($.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>_(l.palette.warning.main,.08):l=>_(l.palette.success.main,.08)}},children:c?t.jsx($.Pause,{sx:{fontSize:15}}):t.jsx($.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>_(l.palette.primary.main,.08)}},children:t.jsx($.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>_(l.palette.error.main,.08)}},children:t.jsx($.Delete,{sx:{fontSize:15}})})})]})]})]})}function _p({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,x]=p.useState([]),m=l?(a==null?void 0:a.schedules)??[]:u,[h,v]=p.useState({type:"list"}),[w,B]=p.useState(0),[S,f]=p.useState(null);p.useEffect(()=>{e&&(l||x(ia(n)),v({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const M=setInterval(()=>B(y=>y+1),3e4);return()=>clearInterval(M)},[e]);const b=p.useCallback(M=>{x(M),sa(n,M)},[n]),g=M=>{var P;const y=Zo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth),k={id:`sched-${Date.now()}`,reportId:n,name:M.name.trim(),frequency:M.frequency,dayOfWeek:M.frequency==="weekly"?M.dayOfWeek:void 0,dayOfMonth:M.frequency==="monthly"?M.dayOfMonth:void 0,time:M.time,format:M.format,scope:M.scope,email:M.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:y,runCount:0};l?(P=a==null?void 0:a.onScheduleCreate)==null||P.call(a,k):b([...m,k]),v({type:"list"})},T=M=>{var oe;if(h.type!=="edit")return;const y=h.schedule,k=Zo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth),P={...y,name:M.name.trim(),frequency:M.frequency,dayOfWeek:M.frequency==="weekly"?M.dayOfWeek:void 0,dayOfMonth:M.frequency==="monthly"?M.dayOfMonth:void 0,time:M.time,format:M.format,scope:M.scope,email:M.email.trim()||void 0,nextRunAt:k};l?(oe=a==null?void 0:a.onScheduleUpdate)==null||oe.call(a,P):b(m.map(d=>d.id===y.id?P:d)),v({type:"list"})},I=M=>{var d;const y=m.find(J=>J.id===M);if(!y)return;const k=!y.isActive,P=k?Zo(y.frequency,y.time,y.dayOfWeek,y.dayOfMonth):y.nextRunAt,oe={...y,isActive:k,nextRunAt:P};l?(d=a==null?void 0:a.onScheduleToggle)==null||d.call(a,M,k):b(m.map(J=>J.id===M?oe:J))},C=M=>{if(s(M),!l){const y=new Date().toISOString();b(m.map(k=>k.id===M.id?{...k,lastRunAt:y,runCount:k.runCount+1}:k))}},W=M=>{const y=m.find(k=>k.id===M)??null;f(y)},K=()=>{var M;S&&(l?(M=a==null?void 0:a.onScheduleDelete)==null||M.call(a,S.id):b(m.filter(y=>y.id!==S.id)),f(null))},E=M=>({name:M.name,frequency:M.frequency,dayOfWeek:M.dayOfWeek??1,dayOfMonth:M.dayOfMonth??1,time:M.time,format:M.format,scope:M.scope,email:M.email??""}),U=h.type!=="list",G=m.filter(M=>M.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:U,PaperProps:{sx:M=>({borderRadius:rt(M),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(M).paper})},children:[t.jsxs(o.DialogTitle,{sx:M=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ue(M).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:M=>_(M.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:M=>M.typography.h6.fontWeight||600,fontSize:M=>M.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx($r,{content:Or.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:M=>_(M.palette.text.primary,.06)}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[U&&t.jsx(Ip,{initial:h.type==="edit"?E(h.schedule):aa,isEditing:h.type==="edit",onSave:h.type==="edit"?T:g,onBack:()=>v({type:"list"})}),h.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:m.length===0?"No schedules yet":`${G} of ${m.length} active`}),t.jsx(o.Button,{startIcon:t.jsx($.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>v({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),m.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx($.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:M=>M.typography.body2.fontWeight||500,fontSize:M=>M.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:m.map(M=>t.jsx(Dp,{schedule:M,tick:w,onToggle:I,onRunNow:C,onEdit:y=>v({type:"edit",schedule:y}),onDelete:W},M.id))})]})]}),h.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:M=>_(M.palette.warning.main,.06),border:"1px solid",borderColor:M=>_(M.palette.warning.main,.2)},children:[t.jsx($.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:M=>_(M.palette.text.primary,.06)}},children:"Close"})]})]}),S&&t.jsx(Ep,{scheduleName:S.name,onConfirm:K,onCancel:()=>f(null)})]})}const $p=6e4;function Op({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:m,schedulerConfig:h}){const v=(h==null?void 0:h.mode)??"local",w=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:m,schedulerConfig:h,schedulerMode:v});p.useEffect(()=>{w.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:m,schedulerConfig:h,schedulerMode:v}});const B=p.useCallback(S=>{var M,y,k,P,oe;const{reportName:f,uploadedData:b,processedData:g,schema:T,activeView:I,columnVisibility:C,columnOrder:W,filters:K,sortStack:E,schedulerConfig:U,schedulerMode:G}=w.current;try{const d=S.scope==="all"?b:g;if(G==="api"){const Se=(W.length>0?W:T.map(X=>X.name)).filter(X=>C[X]!==!1),V={schedule:S,triggeredAt:new Date().toISOString(),rows:d,columns:Se,format:S.format,reportName:f};(M=U==null?void 0:U.onScheduleFire)==null||M.call(U,V),(k=(y=w.current).onFired)==null||k.call(y,S);return}const J=en(d,T,K,E,I,C,W),ee=`${S.name}_scheduled`;switch(S.format){case"csv":tn(J,ee,{scope:S.scope});break;case"excel":rn(J,ee,{scope:S.scope});break;case"json":on(J,ee,{scope:S.scope});break;case"pdf":hi(J,ee,{scope:S.scope});break}if(U!=null&&U.onScheduleFire){const Se=(W.length>0?W:T.map(V=>V.name)).filter(V=>C[V]!==!1);U.onScheduleFire({schedule:S,triggeredAt:new Date().toISOString(),rows:d,columns:Se,format:S.format,reportName:f})}if(S.email){const Se=encodeURIComponent(`Scheduled Report: ${S.name}`),V=encodeURIComponent(`Your scheduled report "${S.name}" has been generated.
191
+ ]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function eu({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[c,l]=p.useState(""),[u,g]=p.useState(!1),f=p.useRef(null),m=async x=>{if(!x.name.endsWith(".json")){r("Only .json files are allowed");return}const j=10*1024*1024;if(x.size>j){r("File size exceeds 10MB limit");return}l(x.name);try{const E=await x.text();let S;try{S=JSON.parse(E)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){r("JSON must be an array of objects");return}if(S.length===0){r("No data rows found in JSON file");return}e(S)}catch{r("Network error — please try again")}finally{l("")}},v=x=>{x.preventDefault(),a(!0)},C=x=>{x.preventDefault(),a(!1)},B=x=>{x.preventDefault(),a(!1);const j=x.dataTransfer.files[0];j&&m(j)},b=()=>{var x;(x=f.current)==null||x.click()},y=x=>{var E;const j=(E=x.target.files)==null?void 0:E[0];j&&m(j)},z=x=>{x.stopPropagation(),g(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:v,onDragLeave:C,onDrop:B,onPaste:x=>x.preventDefault(),onClick:b,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?x=>$(x.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:f,type:"file",accept:".json",onChange:y,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:x=>x.typography.body2.fontWeight||500,fontSize:x=>x.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),c&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:x=>$(x.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:z,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(Ys,{isOpen:u,onClose:()=>g(!1),content:i})]})}function tu({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&t.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?s=>$(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(O.Lock,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function ru({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>$(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>$(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(o.Button,{variant:"contained",color:"error",startIcon:t.jsx(O.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function qs({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>$(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(O.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function ou({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,u]=p.useState(!1),[g,f]=p.useState(!1),[m,v]=p.useState(-1),C=p.useRef(null),B=p.useRef(null);p.useEffect(()=>{function T(F){C.current&&!C.current.contains(F.target)&&(u(!1),f(!1))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const b=p.useCallback(()=>{f(!0),v(-1),n.length>0&&u(!0)},[n.length]),y=p.useCallback(T=>{r(T),v(-1)},[r]),z=p.useCallback(T=>{var F;r(T),i(T),u(!1),(F=B.current)==null||F.blur()},[r,i]),x=p.useCallback(T=>{v(-1),z(T)},[z]),j=p.useCallback(T=>{var F;T.key==="Enter"?m>=0&&m<n.length?(T.preventDefault(),x(n[m].query)):e.trim()&&z(e.trim()):T.key==="Escape"?(u(!1),v(-1),(F=B.current)==null||F.blur()):T.key==="ArrowDown"?(T.preventDefault(),n.length>0&&(l||u(!0),v(X=>X<n.length-1?X+1:X))):T.key==="ArrowUp"&&(T.preventDefault(),v(X=>X>0?X-1:-1))},[m,n,e,l,x,z]),E=p.useCallback(()=>{var T;r(""),(T=B.current)==null||T.focus()},[r]),S=p.useMemo(()=>n.filter(T=>T.isFavourite),[n]),R=p.useMemo(()=>n.filter(T=>!T.isFavourite),[n]),q=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:C,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:T=>y(T.target.value),onFocus:b,onKeyDown:j,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:T=>$(T.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:T=>$(T.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(O.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:E,edge:"end",sx:{mr:-.5},children:t.jsx(O.Close,{sx:{fontSize:16}})})}):null}}),q&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[S.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),S.map((T,F)=>t.jsx(cs,{entry:T,isSelected:m===F,onClick:()=>x(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`fav-${T.query}`))]}),R.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[S.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((T,F)=>{const X=S.length+F;return t.jsx(cs,{entry:T,isSelected:m===X,onClick:()=>x(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`recent-${T.query}`)})]})]})]})}const cs=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>$(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>$(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:c,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(O.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(O.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function nu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:u,onEditView:g,onCloneView:f,onCopyLink:m,onDeleteView:v,onPromoteToGlobal:C,isReadOnly:B,isAdmin:b=!1}){const y=ht(),[z,x]=p.useState(!1),[j,E]=p.useState(!1),[S,R]=p.useState({top:0,left:0}),[q,T]=p.useState(null),[F,X]=p.useState(null),W=p.useRef(null),h=p.useRef(null),I=e.find(D=>D.id===r),N=I==null?void 0:I.isDefault,d=(D,ee)=>D.name.localeCompare(ee.name),oe=e.filter(D=>D.scope==="global"&&!D.isDeleted).sort(d),G=e.filter(D=>D.scope!=="global"&&!D.isDeleted).sort(d),te=e.filter(D=>D.isFavorite&&!D.isDeleted).sort(d),ge=e.filter(D=>D.isDeleted);p.useEffect(()=>{if(z&&h.current){const D=h.current.getBoundingClientRect();R({top:D.bottom+window.scrollY+8,left:D.right+window.scrollX-320})}},[z]),p.useEffect(()=>{const D=ee=>{W.current&&!W.current.contains(ee.target)&&h.current&&!h.current.contains(ee.target)&&x(!1)};return z&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[z]);const V=D=>{if(n&&D!==r){T(D),x(!1);return}i(D),x(!1)},K=()=>{q&&(i(q),T(null))},ce=()=>{T(null)},de=(D,ee=!1)=>{const xe=D.scope==="global",ae=!B&&(!xe||b),Te=b&&!xe;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===D.id?$(y.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===D.id?$(y.palette.primary.main,.12):y.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>V(D.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===D.id&&t.jsx(O.Check,{sx:{fontSize:16,flexShrink:0}}),r!==D.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===D.id?y.palette.primary.dark:y.palette.text.primary,fontWeight:r===D.id?Y=>Y.typography.body2.fontWeight||500:400,fontSize:Y=>Y.typography.body2.fontSize||"0.875rem"},children:D.name}),ee&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:y.palette.text.secondary,backgroundColor:y.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[ae&&c&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),c(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:D.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(O.Star,{sx:{fontSize:16}})}),ae&&a&&!D.isDefault&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),a(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Set as default",children:t.jsx(O.RadioButtonUnchecked,{sx:{fontSize:16}})}),(ae||Te)&&(g||f||m||v||Te&&C)&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),X({el:Y.currentTarget,view:D})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"More actions",children:t.jsx(O.MoreVert,{sx:{fontSize:16}})})]})]},D.id)},ne=D=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:y.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:y.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:D.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),l(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Restore view",children:t.jsx(O.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),u(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Delete permanently",children:t.jsx(O.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},D.id),Q=n||!N,pe=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:h,onClick:()=>x(!z),variant:"outlined",size:"small",endIcon:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:Q?"warning.main":"text.primary",borderColor:Q?"warning.main":"divider",bgcolor:Q?$(y.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:Q?"warning.dark":"primary.main",bgcolor:Q?$(y.palette.warning.main,.2):$(y.palette.text.primary,.06),color:Q?"warning.dark":"text.primary"}},title:`View: ${(I==null?void 0:I.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(I==null?void 0:I.name)||"Default View"}),pe&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),z&&bs.createPortal(t.jsxs(o.Box,{ref:W,sx:{position:"fixed",width:"320px",backgroundColor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:1,boxShadow:y.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:S.top,left:S.left},children:[oe.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:D=>D.typography.caption.fontSize||"caption.fontSize",fontWeight:D=>D.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),oe.map(D=>de(D,D.isDefault))]}),te.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(O.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),te.map(D=>de(D))]})]}),G.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:D=>D.typography.caption.fontSize||"caption.fontSize",fontWeight:D=>D.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),G.map(D=>de(D))]})]}),ge.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>E(!j),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",ge.length,")"]}),t.jsx(O.ChevronRight,{sx:{fontSize:16}})]}),j&&t.jsx(o.Box,{sx:{backgroundColor:y.palette.action.hover},children:ge.map(D=>ne(D))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),x(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:y.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsx(O.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!F,anchorEl:(F==null?void 0:F.el)||null,onClose:()=>X(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(o.MenuItem,{onClick:()=>{F&&g(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Edit,{sx:{fontSize:18}}),"Edit"]}),m&&t.jsxs(o.MenuItem,{onClick:()=>{F&&m(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Link,{sx:{fontSize:18}}),"Copy Link"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{F&&f(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),C&&b&&(F==null?void 0:F.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{F&&C(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{F&&v(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:q!==null,onClose:ce,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(y)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(O.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:ce,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:K,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function iu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:g,onRemoveSort:f,onFilter:m,onClearFilter:v,onGroupByColumn:C,onHideColumn:B,onManageColumns:b,onResetLayout:y,onClose:z}){const x=ht(),j=x.palette,E=p.useRef(null);p.useEffect(()=>{if(!E.current)return;const X=E.current,W=X.getBoundingClientRect(),h=window.innerWidth,I=window.innerHeight;W.right>h-8&&(X.style.left=`${h-W.width-8}px`),W.bottom>I-8&&(X.style.top=`${I-W.height-8}px`)},[l]),p.useEffect(()=>{const X=h=>{E.current&&!E.current.contains(h.target)&&z()},W=h=>{h.key==="Escape"&&z()};return document.addEventListener("mousedown",X),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",W)}},[z]);const S=p.useCallback(X=>()=>{X(),z()},[z]),R=(n==null?void 0:n.direction)==="asc",q=(n==null?void 0:n.direction)==="desc",T=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",F=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return bs.createPortal(t.jsxs(o.Paper,{ref:E,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:x.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:_o(x),overflow:"hidden",boxShadow:`0 4px 20px ${$(j.common.black,.12)}, 0 1px 4px ${$(j.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:X=>X.typography.body2.fontSize||"0.8125rem",fontWeight:X=>X.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${T})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?$(j.primary.main,.1):"transparent","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${F})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:q?"primary.main":"text.secondary",bgcolor:q?$(j.primary.main,.1):"transparent","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:S(()=>f(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(j.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(O.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:S(()=>m(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:S(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(j.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&C&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:S(()=>C(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:S(()=>B(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(b),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:S(b),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&y&&t.jsxs(o.MenuItem,{onClick:S(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(j.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const su=176,ds="COLUMN_HEADER",au=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:u=!1,width:g,onColumnClick:f,onMoveColumn:m,onColumnDragEnd:v,onResizeStart:C,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onOpenFilterForColumn:z,onClearFiltersForColumn:x,onGroupByColumn:j,onHideColumn:E,onManageColumns:S,onResetLayout:R}){const T=ht().urmTable,F=p.useRef(null),[X,W]=p.useState(!1),[h,I]=p.useState({x:0,y:0}),[{handlerId:N,isOver:d},oe]=ir.useDrop({accept:ds,collect(Q){return{handlerId:Q.getHandlerId(),isOver:Q.isOver()}},hover(Q,pe){var Pe;if(!F.current)return;const D=Q.index,ee=n;if(D===ee)return;const xe=(Pe=F.current)==null?void 0:Pe.getBoundingClientRect(),ae=(xe.right-xe.left)/2,Te=pe.getClientOffset(),Y=((Te==null?void 0:Te.x)??0)-xe.left;D<ee&&Y<ae||D>ee&&Y>ae||(m(D,ee),Q.index=ee)}}),[{isDragging:G},te]=ir.useDrag({type:ds,item:()=>({index:n,columnName:r.name}),collect:Q=>({isDragging:Q.isDragging()}),end:()=>{v==null||v()}});te(oe(F));const ge=p.useCallback(Q=>{Q.preventDefault(),Q.stopPropagation(),I({x:Q.clientX,y:Q.clientY}),W(!0)},[]),V=p.useCallback(()=>W(!1),[]),K=p.useCallback(()=>{l||f(r.name)},[f,r.name,l]),ce=p.useCallback(Q=>{Q.stopPropagation(),z(r.name)},[z,r.name]),de=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(O.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),ne=p.useCallback(()=>s?t.jsx(O.FilterList,{onClick:ce,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,ce]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:F,"data-handler-id":N,"data-column-index":n,onClick:K,onContextMenu:ge,sx:{position:"sticky",top:0,zIndex:5,textAlign:(T==null?void 0:T.cellAlignH)??"left",verticalAlign:(T==null?void 0:T.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(T==null?void 0:T.headerColor)??"text.secondary",opacity:G?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease, width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease",bgcolor:d?Q=>$(Q.palette.primary.main,.08):(T==null?void 0:T.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${$(Q.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(T==null?void 0:T.rowDivider)??"1px solid",borderRight:T==null?void 0:T.colDivider,borderColor:"divider",py:0,px:l?0:(T==null?void 0:T.cellPaddingX)??2,"&:hover":{bgcolor:Q=>$(Q.palette.primary.main,.1),color:"text.primary"},width:l?"32px":g?`${g}px`:`${su}px`,minWidth:l?"32px":void 0,maxWidth:l?"32px":void 0},children:[!l&&t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[dt(r.name),de(),ne()]}),!l&&t.jsx(o.Box,{draggable:!1,onDragStart:Q=>Q.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),C(Q,r.name)},onClick:Q=>Q.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),d&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),X&&t.jsx(iu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:u,position:h,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onFilter:z,onClearFilter:x,onGroupByColumn:j,onHideColumn:E,onManageColumns:S,onResetLayout:R,onClose:V})]})}),lu={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function sn(e,r){const n=lu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:$(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function cu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const du={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"success",shade:"dark"}};function uu(e,r){const n=du[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Bt(e){return $(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function pu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>sn(n,r).bg,color:n=>sn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function hu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return pu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const c=cu(a,s);return c?{color:c,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function mu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function xu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:g}){const[f,m]=p.useState(!1),{primaryCol:v,idCol:C,bodyColumns:B}=p.useMemo(()=>mu(n),[n]),b=v?e[v.name]:null,y=C?e[C.name]:null,z=f||i;return t.jsxs(o.Box,{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),onClick:x=>s(r,x),onDoubleClick:x=>a(e,r,x),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),c(e,r,x)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.border;return i?"2px solid":j&&j!=="none"?j:"1px solid"},borderColor:i?x=>ct(x).main:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.border;return j&&j!=="none"?"inherit":$(x.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.borderRadius;return j!==void 0?typeof j=="number"?`${j}px`:j:`${x.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?x=>`0 0 0 3px ${$(ct(x).main,.15)}, 0 2px 8px ${$(x.palette.common.black,.08)}`:f?x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.boxShadow;return j&&j!=="none"?j:ye(x,"cardHover")}:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.boxShadow;return j&&j!=="none"?j:ye(x,"cardRest")},transform:f&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:x=>$(ct(x).main,.03)}},children:[t.jsxs(o.Box,{sx:x=>{var q,T,F,X;const j=((F=(T=(q=x.components)==null?void 0:q.MuiCardHeader)==null?void 0:T.styleOverrides)==null?void 0:F.root)||{},E=(j.backgroundColor&&j.backgroundColor!=="transparent"?j.backgroundColor:void 0)??((X=x.tokens)==null?void 0:X.cardHdrHex)??"transparent",S=j.borderBottom&&j.borderBottom!=="none"?j.borderBottom:void 0,R=j.boxShadow&&j.boxShadow!=="none"?j.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:E,borderBottom:S,boxShadow:R,display:"flex",alignItems:"center",gap:.5}},children:[!g&&z&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:x=>x.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:x=>x.typography.body2.fontWeight||600,fontSize:x=>x.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:b!=null&&b!==""?String(b):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:x=>{var S,R,q;const j=((q=(R=(S=x.components)==null?void 0:S.MuiCardHeader)==null?void 0:R.styleOverrides)==null?void 0:q.root)||{};return j.borderBottom&&j.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[B.map(x=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:j=>j.typography.body2.fontWeight||500,fontSize:j=>j.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:dt(x.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[x.name]??""),children:hu(x,e[x.name])})]},x.name)),B.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:x=>$(x.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:y?.85:0,userSelect:"none"},children:y?String(y):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:z?1:0,transition:"opacity 0.15s ease"},onClick:x=>x.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:x=>{x.stopPropagation(),l(e,r,x.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:x=>$(x.palette.text.primary,.08)}},children:t.jsx(O.MoreVert,{sx:{fontSize:17}})})})})]})]})}function fu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>ye(s,"flatHover"),"&:hover":{bgcolor:s=>$(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:La(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>$(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>ks(a)).filter(Boolean).join(" • ")})]})}function gu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:f,hideSelectionCheckboxes:m}){const v=p.useMemo(()=>{const C=new Set;return i.forEach(B=>{const b=B==null?void 0:B.__urm_row_id__;b!==void 0&&C.add(b)}),C},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:C=>C.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:C=>ls(C).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:C=>ls(C).cardGap,alignContent:"start"},children:e.map((C,B)=>s&&C.isGroupHeader?t.jsx(fu,{row:C,grouping:n,onToggleCollapse:a||(()=>{})},`group-${C.groupKey}`):t.jsx(xu,{row:C,rowIndex:B,visibleColumns:r,isSelected:v.has(C==null?void 0:C.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:f,hideCheckbox:m},`card-${B}`))})})}const us=[10,15,25,50,100];function yu(e,r){const n=e.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function bu({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=ht().palette,u=Math.ceil(n/r),[g,f]=p.useState(String(e)),[m,v]=p.useState(null),[C,B]=p.useState(!1),b=p.useRef(null);p.useEffect(()=>{C||(f(String(e)),v(null))},[e,C]);const y=p.useCallback(()=>{const I=yu(g,u);if(I){v(I);return}const N=parseInt(g.trim(),10);v(null),B(!1),N!==e&&s(N)},[g,u,e,s]),z=p.useCallback(I=>{var N;I.key==="Enter"?(I.preventDefault(),y()):I.key==="Escape"&&(f(String(e)),v(null),B(!1),(N=b.current)==null||N.blur())},[y,e]),x=p.useCallback(()=>{f(String(e)),v(null),B(!1)},[e]),j=p.useCallback(()=>{B(!0),v(null),setTimeout(()=>{var I;return(I=b.current)==null?void 0:I.select()},0)},[]);if(n<=Math.min(...us))return null;const E=()=>{f(String(e)),v(null),B(!1)},S=()=>{E(),s(1)},R=()=>{E(),e>1&&s(e-1)},q=()=>{E(),e<u&&s(e+1)},T=()=>{E(),s(u)},F=(e-1)*r+1,X=Math.min(e*r,n),W=`${Math.max(2,String(u).length+.5)}ch`,h={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:I=>a(Number(I.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:us.map(I=>t.jsx(o.MenuItem,{value:I,sx:{fontSize:"0.8125rem"},children:I},I))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[F,"–",X," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[m&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:$(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${$(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:$(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:m})}),t.jsx(o.InputBase,{inputRef:b,value:g,onChange:I=>{f(I.target.value),m&&v(null)},onKeyDown:z,onFocus:j,onBlur:x,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:W,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:m?"error.main":"text.primary",border:"1px solid",borderColor:m?"error.main":C?"primary.main":"divider",borderRadius:"4px",bgcolor:m?$(l.error.main,.04):C?$(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:m?"error.main":"text.secondary"},"&:focus-within":{boxShadow:m?`0 0 0 2px ${$(l.error.main,.2)}`:`0 0 0 2px ${$(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:S,disabled:e===1,size:"small",title:"First page",sx:h,children:t.jsx(O.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:R,disabled:e===1,size:"small",title:"Previous page",sx:h,children:t.jsx(O.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:q,disabled:e===u,size:"small",title:"Next page",sx:h,children:t.jsx(O.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:T,disabled:e===u,size:"small",title:"Last page",sx:h,children:t.jsx(O.LastPage,{sx:{fontSize:20}})})]})]})]})}function vu(){return t.jsx(o.Chip,{icon:t.jsx(O.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const Js="urm_hint_seen_";function Su(e){try{return localStorage.getItem(Js+e)==="true"}catch{return!1}}function Cu(e){try{localStorage.setItem(Js+e,"true")}catch{}}const Ks={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function ii(e,r){if(e==null||e==="")return"";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function Xs({row:e,schema:r}){const i=ht().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),c=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:dt(l.name),value:ii(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Ks},l.name)),c.map(l=>{const u=ii(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function wu({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=ht(),c=a.palette;if(!n)return null;const l=i.filter(g=>g.name in n).length,u=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:g=>g.typography.h6.fontSize||"1rem",fontWeight:g=>g.typography.h6.fontWeight||600,color:g=>g.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:$(c.text.primary,.015)},children:t.jsx(Xs,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:g=>`${g.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function ju({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=ht(),c=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>$(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(Xs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>$(l.palette.error.main,.1),border:l=>`1px solid ${$(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(O.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function ku({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var z;const c=ht(),l=c.palette,[u,g]=p.useState({});if(p.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const f=s.filter(x=>x.name in i),m=f.filter(x=>x.type!=="object"&&x.type!=="array"),v=f.filter(x=>x.type==="object"||x.type==="array"),C=(x,j)=>{g(E=>({...E,[x]:j}))},B=()=>{const x={...u};f.forEach(j=>{const E=u[j.name];if(j.type==="number"){const S=Number(E);x[j.name]=isNaN(S)?i[j.name]:S}else j.type==="boolean"&&(x[j.name]=!!E)}),n(x),r()},b=f.length,y=ue(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...y.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...y.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(((z=l.warning)==null?void 0:z.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:x=>x.typography.h6.fontSize||"1rem",fontWeight:x=>x.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",b," ",b===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:$(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[m.map(x=>{const j=u[x.name];return x.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:E=>E.typography.caption.fontWeight||500,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(x.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!j,onChange:E=>C(x.name,E.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:j?"Enabled":"Disabled"})]})]},x.name):t.jsx(o.TextField,{label:dt(x.name),value:j??"",onChange:E=>C(x.name,E.target.value),type:x.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Ks},x.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(x=>{const j=ii(i[x.name],x.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:E=>E.typography.caption.fontSize||"0.75rem",fontWeight:E=>E.typography.caption.fontWeight||500,color:"text.secondary"},children:dt(x.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:$(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(O.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:j||"No value"})]},x.name)})}),f.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(O.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:x=>`${x.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",startIcon:t.jsx(O.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:x=>`${x.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const zu=176,Tu=170,Bu=40,Iu=32;function Qs(e){return e.type==="date"?180:zu}function Eu(e,r){return r!=null&&r!==Tu&&r!==Qs(e)}function Du(e,r,n,i){return p.useMemo(()=>{const s=e.map(v=>i!=null&&i.has(v.name)?{name:v.name,width:Iu,explicit:!0}:{name:v.name,width:r[v.name]??Qs(v),explicit:Eu(v,r[v.name])}),a={};s.forEach(v=>{a[v.name]=v.width});const c=s.reduce((v,C)=>v+C.width,0),u=Math.max(0,n-Bu)-c;if(u<=0)return{widths:a,fillerWidth:0};const g=s.filter(v=>!v.explicit);if(g.length===0)return{widths:a,fillerWidth:u};const f=g.reduce((v,C)=>v+C.width,0)||1;let m=0;return g.forEach((v,C)=>{const b=C===g.length-1?v.width+u-m:Math.round(v.width+u*v.width/f);a[v.name]=b,m+=b-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const ps=176,_u=Rt(),$u={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Ou(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>sn(n,r).bg,color:n=>sn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Mu(e){const r=e.toLowerCase().trim(),n=$u[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Wu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,c)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},c):a)}function Au(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Ou(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Mu(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=Ea(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Wu(s,i)}function Ru({schema:e,data:r,sortStack:n=[],filters:i=_u,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:f={},grouping:m=null,classTokens:v={},onSort:C,onSortAscending:B,onSortDescending:b,onOpenFilters:y,onOpenSort:z,onOpenFilterForColumn:x,onSelectView:j,onCreateView:E,onUpdateCurrentView:S,onSaveAsNewView:R,onDiscardChanges:q,onToggleDefault:T,onToggleFavorite:F,onRestoreView:X,onPermanentDelete:W,onEditView:h,onCloneView:I,onCopyLink:N,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G=!1,onExport:te,onOpenColumns:ge,onUpdateColumnWidth:V,onUpdateColumnOrder:K,onUpdateColumnVisibility:ce,onClearFiltersForColumn:de,onResetLayout:ne,onOpenGroup:Q,onGroupByColumn:pe,onToggleGroupCollapse:D,onExpandAllGroups:ee,onCollapseAllGroups:xe,onOpenAuditHistory:ae,onOpenScheduledReports:Te,searchQuery:Y,highlightQuery:Pe="",searchHistory:Et=[],onAddToSearchHistory:mt,onToggleSearchFavourite:$r,onDeleteSearchHistory:Pt,selectedRowIds:it=new Set,onSearchChange:Yt,onToggleRowSelection:Ke,onToggleAllRows:Dt,onRangeSelection:Sr,onClearSelection:vt,onExportSelected:qt,currentPage:ao=1,pageSize:ar=15,totalRowsBeforePagination:lo=r.length,onPageChange:_t,onPageSizeChange:Cr,isReadOnly:Xe=!1,userRole:Nt,reportName:Jt,onEditRow:Ze,onDuplicateRow:et,onDeleteRow:Lt,showDevPanel:co=!1,onOpenDevConfig:Or,rowActions:wr,hideDefaultRowActions:He,hideToolbarActions:Se,customSettingsActions:lr,jsonGuideContent:Kt,viewOptions:cr,defaultViewMode:uo,bulkActions:Ft,hideSelectionCheckboxes:Mr,rowClickBehavior:dr="select",openModalOn:tt,onRowClick:Xt,onRowRightClick:xt}){var Lo;const he=ht().urmTable,[jr,$t]=p.useState(null),[H,St]=p.useState(0),[ie,ut]=p.useState(0),[Ot,Qt]=p.useState(null),Wr=br(),kr=((Lo=Wr.dates)==null?void 0:Lo.displayFormat)??null,[Zt,ur]=p.useState(null),[pr,Ar]=p.useState(null),[ze,Qe]=p.useState(null),[Z,se]=p.useState(!1),[be,Rr]=p.useState(!1),[hr,Pr]=p.useState(null),[po,Nr]=p.useState(!1),[mr,Lr]=p.useState(null),[Fr,Mt]=p.useState(null),[Ce,Ge]=p.useState(null),[zr,st]=p.useState(null),er=p.useRef(null),Wt=p.useCallback(()=>{er.current&&(clearTimeout(er.current),er.current=null)},[]),fe=p.useCallback(()=>{Wt(),er.current=setTimeout(()=>st(null),200)},[Wt]);p.useEffect(()=>Wt,[Wt]);const[je,We]=p.useState(null),qe=p.useMemo(()=>cr??["list","grid"],[cr]),[at,Ct]=p.useState(()=>uo??qe[0]??"list"),[tr,$o]=p.useState(!1),[Vr,zn]=p.useState(()=>!Su("toolbar_search")),Hr=p.useRef(null),ho=p.useRef(null),[Tn,Oo]=p.useState(0);p.useLayoutEffect(()=>{const w=Hr.current;if(!w)return;Oo(w.clientWidth);const P=new ResizeObserver(re=>{Oo(re[0].contentRect.width)});return P.observe(w),()=>P.disconnect()},[]);const Gr=p.useCallback(()=>{Cu("toolbar_search"),zn(!1)},[]);p.useEffect(()=>{if(!Vr)return;const w=setTimeout(Gr,2e3);return()=>clearTimeout(w)},[Vr,Gr]);const Mo=p.useMemo(()=>{const w=Ot??g;return w.length>0?w.map(P=>e.find(re=>re.name===P)).filter(P=>P!==void 0):e},[Ot,g,e]),Ur=p.useMemo(()=>Mo.filter(w=>u[w.name]!==!1),[Mo,u]),mo=p.useMemo(()=>new Set(((m==null?void 0:m.levels)??[]).map(w=>w.column)),[m]),Wo=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),Yr=p.useMemo(()=>{if(!Wo)return Ur;const w=((m==null?void 0:m.levels)??[]).map(re=>e.find(we=>we.name===re.column)).filter(re=>re!==void 0),P=Ur.filter(re=>!mo.has(re.name));return[...w,...P]},[Ur,Wo,mo,m,e]),qr=p.useMemo(()=>{const w=new Set;if(!(m!=null&&m.enabled)||!r)return w;for(const P of r)(P.isGroupHeader||P.__isGroupHeader)&&!P.isCollapsed&&P.groupColumn&&w.add(P.groupColumn);return w},[r,m]),{widths:Tr}=Du(Yr,f,Tn,qr),xr=p.useMemo(()=>e.filter(w=>u[w.name]===!1).length,[e,u]),Ao=p.useMemo(()=>e.map(w=>w.name),[e]),Jr=p.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(Ao),[g,Ao]),Bn=p.useCallback((w,P)=>{w.preventDefault(),w.stopPropagation(),$t(P),St(w.clientX),ut(f[P]||150)},[f]);p.useEffect(()=>{if(!jr)return;const w=re=>{const we=re.clientX-H,Me=Math.max(100,Math.min(600,ie+we));V==null||V(jr,Me)},P=()=>{$t(null)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",P),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",P)}},[jr,H,ie,V]);const In=p.useCallback(w=>w==null?"-":typeof w=="object"?JSON.stringify(w):typeof w=="boolean"?w?"true":"false":String(w),[]);p.useCallback(w=>{const P=n.find(re=>re.column===w);return P?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[P.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:14}}):t.jsx(O.ArrowDownward,{sx:{fontSize:14}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:P.priority})]}):null},[n]),p.useCallback(w=>Zn(i,w)?t.jsx(o.IconButton,{size:"small",onClick:re=>{re.stopPropagation(),x==null||x(w)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(O.FilterList,{sx:{fontSize:14}})}):null,[i,x]);const En=p.useCallback(w=>{C&&C(w)},[C]),Dn=p.useCallback((w,P)=>{Qt(re=>{const Me=[...re??(g.length>0?g:e.map(rt=>rt.name))],[nt]=Me.splice(w,1);return Me.splice(P,0,nt),Me})},[g,e]),_n=p.useCallback(()=>{Ot&&K&&K(Ot),Qt(null)},[Ot,K]),$n=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);(!P||P.direction!=="asc")&&C(w)},[C,n]),On=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);P?P.direction==="asc"&&C(w):(C(w),setTimeout(()=>C(w),0))},[C,n]),Mn=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);P&&(P.direction==="asc"?(C(w),setTimeout(()=>C(w),0)):P.direction==="desc"&&C(w))},[C,n]),Wn=p.useCallback(w=>{ce&&ce(w,!1)},[ce]),Kr=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),rr=p.useMemo(()=>Tt(i),[i]),An=n.length>0||rr>0||((m==null?void 0:m.enabled)??!1)||Object.values(u).some(w=>w===!1),Rn=(ao-1)*ar,Re=r,lt=p.useMemo(()=>{const w=new Set;return it.forEach(P=>{const re=P==null?void 0:P.__urm_row_id__;re!==void 0&&w.add(re)}),w},[it]);p.useEffect(()=>{const w=P=>{!Dt||!vt||P.target instanceof HTMLInputElement||P.target instanceof HTMLTextAreaElement||((P.ctrlKey||P.metaKey)&&P.key==="a"&&(P.preventDefault(),Dt(!0,Re)),P.key==="Escape"&&(P.preventDefault(),vt()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[Dt,vt,Re]);const xo=p.useCallback((w,P)=>{Xt==null||Xt(Re[w],w,P),(dr==="activate"||dr==="both")&&(Qe(Re[w]),se(!0)),dr!=="activate"&&Ke&&(P.shiftKey&&Zt!==null?(P.preventDefault(),Sr&&Sr(Zt,w,Re)):(Ke(Re[w]),ur(w)))},[Ke,Zt,Sr,Re,Xt,dr,Qe,se]),Ro=p.useMemo(()=>Re.length>0&&lt.size>0&&Re.every(w=>lt.has(w==null?void 0:w.__urm_row_id__)),[Re,lt]),Pn=!Ro&&Re.some(w=>lt.has(w==null?void 0:w.__urm_row_id__)),ft=!!(Ke&&Dt&&!Mr),Xr=p.useMemo(()=>!(m!=null&&m.enabled)||!(m!=null&&m.levels)?new Set:new Set(m.levels.map(w=>w.column)),[m]),wt=p.useMemo(()=>Yr,[Yr]),Po=p.useMemo(()=>{const w=new Map;if(!(m!=null&&m.enabled)||!Re)return w;let P=[];for(const re of Re)if(re.__isGroupHeader||re.isGroupHeader){const we=re.groupLevel??0;P[we]=re.groupKey,P=P.slice(0,we+1),w.has(re.groupKey)||w.set(re.groupKey,[])}else if(re.__urm_is_grouped_data_row__)for(const we of P)we&&w.has(we)&&w.get(we).push(re);return w},[m,Re]),Nn=p.useCallback(w=>{const P=w.groupLevel,re=P===0?v.groupRowLevel0||"urm-group-level-0":P===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",we=P===0?ke=>ke.palette.mode==="dark"?$(ke.palette.action.hover,.12):"#f1f5f9":ke=>ke.palette.mode==="dark"?$(ke.palette.action.hover,.06):"#f8fafc",Me=String(w.groupValue??"(empty)"),nt=`${w.rowCount} ${w.rowCount===1?"item":"items"}`,rt=Po.get(w.groupKey)||[],me=rt.filter(ke=>lt.has(ke==null?void 0:ke.__urm_row_id__)).length,Vt=rt.length>0&&me===rt.length,or=me>0&&me<rt.length;return t.jsxs(o.TableRow,{onClick:()=>D==null?void 0:D(w.groupKey),className:`urm-group-header-row urm-group-level-${P} ${re} ${v.groupRow||""}`,sx:{bgcolor:we,"&:hover":{bgcolor:ke=>$(ke.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ke=>ke.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Vt,indeterminate:or,onChange:()=>{if(!Ke)return;const ke=!Vt;rt.forEach(pt=>{const Fo=lt.has(pt==null?void 0:pt.__urm_row_id__);ke!==Fo&&Ke(pt)})}})}),t.jsxs(o.TableCell,{colSpan:wt.length,className:`urm-group-cell ${v.groupCellFirst||""} ${v.groupCell||""}`,sx:{pl:`${P*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[P>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${P*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:w.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:18}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:P===0?600:500,fontSize:P===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Me}),!w.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:ke=>$(ke.palette.primary.main,.2),ml:.5},children:dt(w.groupColumn||"")}),!!w.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:nt}),Object.keys(w.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(w.aggregates).map(([ke,pt])=>ks(pt)).filter(Boolean).join(" • "),")"]})]})]})]},w.groupKey)},[Xr,wt,ft,m,e,D,v,he,Po,lt,Ke]),No=p.useCallback((w,P)=>{const re=lt.has(w==null?void 0:w.__urm_row_id__),we=pr===P,Me=Z&&(w==null?void 0:w.__urm_row_id__)===(ze==null?void 0:ze.__urm_row_id__),nt=!!(w!=null&&w.__urm_is_grouped_data_row__),rt=nt?w.__urm_group_level__??(m==null?void 0:m.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":P,className:nt?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>Ar(P),onMouseLeave:()=>Ar(null),onClick:me=>{me.target.closest("[data-row-action-btn]")||xo(P,me)},onDoubleClick:()=>{tt!=null&&tt.includes("doubleClick")&&(Qe(w),se(!0))},onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),xt==null||xt(w,P,me),st(null),Ge({mouseX:me.clientX,mouseY:me.clientY,row:w,rowIndex:P}),tt!=null&&tt.includes("rightClick")&&(Qe(w),se(!0))},sx:{cursor:"pointer",bgcolor:re?me=>ct(me).bg:Me?me=>$(me.palette.info.main,.12):he!=null&&he.striped&&P%2===1?he.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:re?me=>ct(me).hoverBg:Me?me=>$(me.palette.info.main,.2):me=>`var(--highlight-hover-row, ${$(ct(me).main,.04)})`},borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",onClick:me=>me.stopPropagation(),sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:re,onChange:()=>Ke==null?void 0:Ke(w)})}),wt.map((me,Vt)=>{const or=Vt===0,ke=Xr.has(me.name),pt=qr.has(me.name);return t.jsxs(o.TableCell,{className:nt&&or?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(he==null?void 0:he.rowPaddingY)??"6px",px:ke&&pt?0:(he==null?void 0:he.cellPaddingX)??2,position:"relative",textAlign:(he==null?void 0:he.cellAlignH)??"left",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderRight:he==null?void 0:he.colDivider,borderColor:"divider",width:ke&&pt?"32px":void 0,minWidth:ke&&pt?"32px":f[me.name]?`${f[me.name]}px`:`${me.type==="date"?Math.max(ps,180):ps}px`,maxWidth:ke&&pt?"32px":void 0,transition:"all 0.3s ease-in-out"},children:[nt&&or&&rt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!ke&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Au(me,w[me.name],kr,Pe)})})]},me.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:we?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:me=>{me.stopPropagation(),me.preventDefault(),st(null),Ge({anchorEl:me.currentTarget,row:w,rowIndex:P})},sx:{color:"text.secondary",opacity:we?1:0,transition:"opacity 0.12s ease",pointerEvents:we?"auto":"none","&:hover":{bgcolor:me=>$(me.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(O.MoreVert,{sx:{fontSize:18}})})})})]},P)},[it,Rn,pr,xo,Yr,f,Pe,In,Ze,et,Lt,Ke,ft,Qe,se,ze,Z,Ge,Kr,mo,xt,tt,Xr,qr,lt]);return t.jsxs(ir.DndProvider,{backend:si.HTML5Backend,children:[t.jsxs(o.Box,{sx:w=>{var nt,rt,me;const P=((me=(rt=(nt=w.components)==null?void 0:nt.MuiCard)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},re=P.border&&P.border!=="none"?P.border:"1px solid",we=P.borderRadius!==void 0?typeof P.borderRadius=="number"?`${P.borderRadius}px`:P.borderRadius:`${w.shape.borderRadius}px`,Me=P.boxShadow&&P.boxShadow!=="none"?P.boxShadow:ye(w,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:re,borderColor:re!=="none"?"divider":void 0,borderRadius:we,boxShadow:Me,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:w=>{var nt,rt,me,Vt,or;const P=((me=(rt=(nt=w.components)==null?void 0:nt.MuiCardHeader)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},re=(P.backgroundColor&&P.backgroundColor!=="transparent"?P.backgroundColor:void 0)??((Vt=w.tokens)==null?void 0:Vt.cardHdrHex)??((or=w.urmTable)==null?void 0:or.headerBg)??w.palette.background.paper,we=P.borderBottom&&P.borderBottom!=="none"?P.borderBottom:"1px solid",Me=P.boxShadow&&P.boxShadow!=="none"?P.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:re,borderBottom:we,borderColor:we!=="none"?"divider":void 0,boxShadow:Me,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Xe&&t.jsx(vu,{}),Yt&&mt&&$r&&Pt&&!(Se!=null&&Se.includes("search"))&&t.jsx(o.Tooltip,{open:Vr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:w=>w.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Gr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(ou,{value:Y||"",onChange:w=>{Vr&&Gr(),Yt(w)},searchHistory:Et,onAddToHistory:mt,onToggleFavourite:$r,onDeleteHistory:Pt,disabled:Xe})})}),!(Se!=null&&Se.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>$o(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})})}),j&&E&&S&&s.length>0&&t.jsx(nu,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:j,onCreateView:E,onToggleDefault:T,onToggleFavorite:F,onRestoreView:X,onPermanentDelete:W,onEditView:h,onCloneView:I,onCopyLink:N,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G,isReadOnly:Xe}),c&&!Xe&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[S&&t.jsx(o.Button,{onClick:S,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-save-current-bg, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-current-color, ${w.palette.primary.contrastText})`,textTransform:"none",boxShadow:w=>ye(w,"restButton"),"&:hover":{bgcolor:w=>`var(--urm-btn-save-current-hover-bg, ${w.palette.primary.dark})`,boxShadow:w=>ye(w,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:w=>`var(--urm-btn-save-new-border, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-new-color, ${w.palette.primary.main})`,bgcolor:w=>`var(--urm-btn-save-new-bg, ${w.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:w=>`var(--urm-btn-save-new-hover-border, ${w.palette.primary.dark})`,bgcolor:w=>`var(--urm-btn-save-new-hover-bg, ${$(w.palette.primary.main,.08)})`}},children:"Save new view"}),q&&t.jsx(o.Button,{onClick:q,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-discard-bg, ${$(w.palette.text.primary,.12)})`,color:w=>`var(--urm-btn-discard-color, ${w.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:w=>`var(--urm-btn-discard-hover-bg, ${$(w.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),co&&Or&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Or,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:w=>$(w.palette.text.secondary,.3),"&:hover":{bgcolor:w=>$(w.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(O.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Xe&&z&&!(Se!=null&&Se.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:z,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(O.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Xe&&y&&!(Se!=null&&Se.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:rr>0?"primary.main":"text.secondary",bgcolor:rr>0?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:rr>0?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:rr>0?"primary.main":"text.primary"}},children:[t.jsx(O.FilterList,{sx:{fontSize:20}}),rr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:rr})]})}),!Xe&&ge&&!(Se!=null&&Se.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:ge,size:"small",sx:{position:"relative",color:xr>0||Jr?"primary.main":"text.secondary",bgcolor:xr>0||Jr?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:xr>0||Jr?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:xr>0||Jr?"primary.main":"text.primary"}},children:[t.jsx(O.ViewColumn,{sx:{fontSize:20}}),xr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:xr})]})}),Kr&&(ee||xe)&&(()=>{var re;const w=(((re=m==null?void 0:m.collapsedGroups)==null?void 0:re.length)??0)>0,P=w?ee:xe;return P?t.jsx(o.Tooltip,{title:w?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:P,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:we=>$(we.palette.text.primary,.06),color:"text.primary"}},children:w?t.jsx(O.UnfoldMore,{sx:{fontSize:20}}):t.jsx(O.UnfoldLess,{sx:{fontSize:20}})})}):null})(),qe.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),qe.map(w=>{const P=at===w,re=w==="list"?t.jsx(O.TableRows,{sx:{fontSize:20}}):t.jsx(O.GridView,{sx:{fontSize:20}}),we=w==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:we,children:t.jsx(o.IconButton,{size:"small",onClick:()=>Ct(w),sx:{borderRadius:1,color:P?"primary.main":"text.secondary",bgcolor:P?Me=>Bt(Me):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:P?Me=>$(Me.palette.primary.main,.2):Me=>$(Me.palette.text.primary,.06),color:P?"primary.main":"text.primary"}},children:re})},w)})]}),!(Se!=null&&Se.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:w=>We(w.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!je,anchorEl:je,onClose:()=>We(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[te&&!(Se!=null&&Se.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{te(),We(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Xe&&Q&&!(Se!=null&&Se.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),ae&&!(Se!=null&&Se.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ae(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),Te&&!(Se!=null&&Se.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Te(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),lr==null?void 0:lr.map(w=>t.jsxs(o.MenuItem,{dense:!0,disabled:w.disabled,onClick:()=>{w.onClick(),We(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Ft&&Ft.length>0&&lt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:w=>ct(w).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:w=>w.typography.body2.fontWeight||600,mr:1},children:[lt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>vt==null?void 0:vt(),children:"Clear"}),Ft.map(w=>{var re,we;const P=Array.from(it);return(re=w.hidden)!=null&&re.call(w,P)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:w.icon,disabled:(we=w.disabled)==null?void 0:we.call(w,P),onClick:()=>w.onClick(P),children:w.label},w.key)})]}),at!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(gu,{data:Re,visibleColumns:Ur,grouping:m,selectedRowIds:it,isGrouped:!!Kr,onToggleGroupCollapse:D,onCardClick:(w,P)=>xo(w,P),onCardDoubleClick:w=>{tt!=null&&tt.includes("doubleClick")&&(Qe(w),se(!0))},onCardContextMenu:(w,P,re)=>{xt==null||xt(w,P,re),st(null),Ge({mouseX:re.clientX,mouseY:re.clientY,row:w,rowIndex:P}),tt!=null&&tt.includes("rightClick")&&(Qe(w),se(!0))},onOpenRowMenu:(w,P,re)=>Ge({anchorEl:re,row:w,rowIndex:P}),onToggleSelection:w=>Ke==null?void 0:Ke(w),hideSelectionCheckboxes:Mr})}),at==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Hr,onScroll:w=>{ho.current&&(ho.current.scrollLeft=w.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Tr).reduce((w,P)=>w+P,0)}px`},children:[t.jsxs("colgroup",{children:[ft&&t.jsx("col",{style:{width:"40px"}}),wt.map(w=>t.jsx("col",{style:{width:`${Tr[w.name]}px`}},w.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(he==null?void 0:he.headerBg)??"action.hover",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Ro,indeterminate:Pn,onChange:w=>Dt==null?void 0:Dt(w.target.checked,Re)})}),wt.map((w,P)=>{const re=Xr.has(w.name),we=qr.has(w.name);return t.jsx(au,{column:w,index:P,isGrouped:re&&we,sortRule:n.find(Me=>Me.column===w.name),hasFilters:Zn(i,w.name),isInSortStack:n.some(Me=>Me.column===w.name),isReadOnly:Xe,hasModifications:An,width:re&&we?32:f[w.name],onColumnClick:En,onMoveColumn:Dn,onColumnDragEnd:_n,onResizeStart:Bn,onSortAscending:B||$n,onSortDescending:b||On,onRemoveSort:Mn,onOpenFilterForColumn:x||(()=>{}),onClearFiltersForColumn:de||(()=>{}),onGroupByColumn:pe,onHideColumn:Wn,onManageColumns:ge||(()=>{}),onResetLayout:ne},w.name)})]})})]})}),t.jsx(o.Box,{ref:ho,onScroll:w=>{Hr.current&&(Hr.current.scrollLeft=w.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>$(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Tr).reduce((w,P)=>w+P,0)}px`},children:[t.jsxs("colgroup",{children:[ft&&t.jsx("col",{style:{width:"40px"}}),wt.map(w=>t.jsx("col",{style:{width:`${Tr[w.name]}px`}},w.name))]}),t.jsx(o.TableBody,{children:Re.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:wt.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Kr?Re.map((w,P)=>w.isGroupHeader?Nn(w):No(w,P)):Re.map((w,P)=>No(w,P))})]})})]}),_t&&Cr&&t.jsx(bu,{currentPage:ao,pageSize:ar,totalRows:lo,totalFields:e.length,onPageChange:_t,onPageSizeChange:Cr}),!(_t&&Cr)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Re.length," ",Re.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!Ce,onClose:()=>{Ge(null),st(null)},anchorEl:(Ce==null?void 0:Ce.anchorEl)||null,anchorReference:Ce!=null&&Ce.anchorEl?"anchorEl":"anchorPosition",anchorPosition:Ce&&!Ce.anchorEl?{top:Ce.mouseY,left:Ce.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:Ce!=null&&Ce.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(He!=null&&He.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Qe(Ce.row),se(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(He!=null&&He.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Lr(Ce.row),Mt(Ce.rowIndex),Nr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(He!=null&&He.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(et==null||et(Ce.rowIndex,Ce.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),Ce&&(wr==null?void 0:wr.map(w=>{var P,re;return(P=w.hidden)!=null&&P.call(w,Ce.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(re=w.disabled)==null?void 0:re.call(w,Ce.row),onClick:()=>{w.onClick(Ce.row,Ce.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key)})),lt.size>0&&qt&&!(He!=null&&He.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:w=>{Wt(),st(w.currentTarget)},onMouseLeave:fe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",lt.size,")"]})]}),t.jsx(O.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!zr,anchorEl:zr,placement:"right-start",transition:!0,sx:{zIndex:w=>w.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:w})=>t.jsx(o.Grow,{...w,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:Wt,onMouseLeave:fe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("csv"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("excel"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("json"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),Wr.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("pdf"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(He!=null&&He.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Pr(Ce.row),Rr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(wu,{open:Z,onClose:()=>{se(!1),Qe(null)},row:ze,schema:e,reportName:Jt}),t.jsx(ku,{open:po,onClose:()=>{Nr(!1),Lr(null),Mt(null)},onSave:w=>{Fr!==null&&(Ze==null||Ze(Fr,w))},row:mr,schema:e,reportName:Jt}),t.jsx(ju,{open:be,onClose:()=>{Rr(!1),Pr(null)},onConfirm:()=>{hr!==null&&(Lt==null||Lt(hr))},row:hr,schema:e}),t.jsx(Ys,{isOpen:tr,onClose:()=>$o(!1),content:Kt})]})}function Dr({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>$(s.palette.primary.main,.08)}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>$(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>$(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>$(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const _r={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},Qn=40;function Pu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Nu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),c=p.useMemo(()=>{const u=a?on(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(f=>g.includes(f.value)):u},[a,i]),l=Bl(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var m;const g=r.find(v=>v.name===u.target.value),f=g?on(g.type):[];s({column:u.target.value,operator:((m=f[0])==null?void 0:m.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:dt(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function Zs({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const u=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,f)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Qn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[f<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),f>0&&t.jsx(Pu,{operator:e.operator,onSelect:m=>l(v=>ci(v,e.id,m))}),f>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Qn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:f>0?1:0},children:Je(g)?t.jsx(Lu,{group:g,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Nu,{condition:g,schema:n,availableColumns:i,devConfig:s,onUpdate:m=>l(v=>li(v,g.id,m))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(m=>di(m,g.id)),sx:{mt:f>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(O.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Qn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(g=>{var f,m,v;return so(g,e.id,{id:io(),column:((f=i[0])==null?void 0:f.name)??"",operator:((v=on(((m=i[0])==null?void 0:m.type)??"string")[0])==null?void 0:v.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(g=>so(g,e.id,Rt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Lu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>$(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>$(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(Zs,{...e})})}function Fu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=p.useState(r??Rt()),u=br(),g=p.useMemo(()=>e.filter(z=>z.type!=="mixed"&&z.type!=="null"&&z.type!=="array"&&z.type!=="object"),[e]);p.useEffect(()=>{var x;const z=r??Rt();if(s&&z.children.length===0){const j=e.find(E=>E.name===s);if(j){l(so(z,z.id,{id:io(),column:s,operator:((x=on(j.type)[0])==null?void 0:x.value)??"equals"}));return}}l(z)},[r,s,e]);const f=Tt(c),m=u.filter.maxConditions,v=p.useCallback(z=>{l(x=>z(x))},[]),C=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??Rt()),[c,r]),B=p.useCallback(()=>{n(c),i()},[c,n,i]),b=p.useCallback(()=>{l(r??Rt()),i()},[r,i]),y=p.useCallback(()=>{n(Rt()),i()},[n,i]);return t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:z=>$(z.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:z=>z.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:z=>z.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:z=>ot(z),bgcolor:"background.paper",outline:"none",boxShadow:z=>ue(z).paper.boxShadow,border:z=>ue(z).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:z=>ue(z).header.backgroundColor,borderBottom:z=>ue(z).header.borderBottom,boxShadow:z=>ue(z).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:z=>z.typography.h6.fontSize||"1.125rem",fontWeight:z=>z.typography.h6.fontWeight||500,color:z=>z.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Dr,{content:_r.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:z=>$(z.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:z=>$(z.palette.text.primary,.3)}}},children:[f===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:z=>z.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${dt(s)}"`:"","."]}),t.jsx(Zs,{group:c,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:m,totalConditions:f,onChange:v}),f>=m&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:z=>z.typography.caption.fontSize||"0.75rem",fontWeight:z=>z.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",m," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:y,disabled:f===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:b,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,disabled:!C,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,boxShadow:z=>ye(z,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const hs="SORT_RULE";function Vu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:c},l]=ir.useDrop({accept:hs,collect(f){return{handlerId:f.getHandlerId()}},hover(f,m){var x;if(!a.current)return;const v=f.index,C=r;if(v===C)return;const B=(x=a.current)==null?void 0:x.getBoundingClientRect(),b=(B.bottom-B.top)/2,y=m.getClientOffset(),z=((y==null?void 0:y.y)??0)-B.top;v<C&&z<b||v>C&&z>b||(s(v,C),f.index=C)}}),[{isDragging:u},g]=ir.useDrag({type:hs,item:()=>({index:r}),collect:f=>({isDragging:f.isDragging()})});return g(l(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:f=>ye(f,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:f=>`0 1px 2px 0 ${$(f.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:f=>f.typography.body2.fontSize||"0.875rem",fontWeight:f=>f.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:f=>n(r,f.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:f=>Bt(f),"&:hover":{bgcolor:f=>$(f.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:f=>Bt(f),"&:hover":{bgcolor:f=>$(f.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:f=>$(f.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]})}function Hu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const g=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),f=br(),m=p.useCallback(j=>{if(!j||l.length>=f.sort.maxLevels)return;const E={column:j,direction:"asc",priority:l.length+1};u([...l,E]),c(""),setTimeout(()=>{var S;return(S=document.activeElement)==null?void 0:S.blur()},0)},[l,f.sort.maxLevels]),v=p.useCallback(j=>{const S=l.filter((R,q)=>q!==j).map((R,q)=>({...R,priority:q+1}));u(S)},[l]),C=p.useCallback((j,E)=>{const S=[...l];S[j]={...S[j],direction:E},u(S)},[l]),B=p.useCallback((j,E)=>{const S=[...l],[R]=S.splice(j,1);S.splice(E,0,R);const q=S.map((T,F)=>({...T,priority:F+1}));u(q)},[l]),b=p.useCallback(()=>{n([]),i()},[n,i]),y=p.useCallback(()=>{n(l),i()},[l,n,i]),z=p.useCallback(()=>{u([...r]),c(""),i()},[r,i]),x=e.filter(j=>!l.some(E=>E.column===j.name));return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:z,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>$(j.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j=>j.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>ot(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>ue(j).paper.boxShadow,border:j=>ue(j).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:j=>ue(j).header.backgroundColor,borderBottom:j=>ue(j).header.borderBottom,boxShadow:j=>ue(j).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:j=>j.typography.h6.fontSize||"1.125rem",fontWeight:j=>j.typography.h6.fontWeight||500,color:j=>j.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Dr,{content:_r.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:z,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:j=>$(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>$(j.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=f.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:j=>m(j.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:x.map(j=>t.jsx(o.MenuItem,{value:j.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:E=>Bt(E),"&:hover":{bgcolor:E=>$(E.palette.primary.main,.2)}}},children:dt(j.name)},j.name))})]}),l.length>=f.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500},children:["Maximum ",f.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",f.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:b,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((j,E)=>t.jsx(Vu,{rule:j,index:E,onToggleDirection:C,onRemove:v,onMove:B},`${j.column}-${E}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:z,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:y,variant:"contained",disabled:!g||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>ye(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>ye(j,"hoverButton")},"&:active":{boxShadow:j=>ye(j,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Jo=50;function ms({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[g,f]=p.useState(s),[m,v]=p.useState(!1),[C,B]=p.useState(a),[b,y]=p.useState(c),z=()=>{if(!g.trim()){v(!0);return}if(g.trim().length>Jo){v(!0);return}r(g.trim(),C.trim(),b),n()},x=E=>{E.key==="Enter"&&!E.shiftKey?z():E.key==="Escape"&&n()},j=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:E=>({mt:8,borderRadius:ot(E),...ue(E).paper})},children:[t.jsxs(o.DialogTitle,{sx:E=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(E).header}),children:[j(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:g,onChange:E=>{E.target.value.length<=Jo&&f(E.target.value),m&&E.target.value.trim()&&v(!1)},onKeyDown:x,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Jo},error:m&&!g.trim(),helperText:m&&!g.trim()?"View name is required":`${g.length} / ${Jo}`}),t.jsx(o.TextField,{label:"Description (optional)",value:C,onChange:E=>B(E.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:E=>E.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ha(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:b,onChange:E=>y(E.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:z,variant:"contained",disabled:l&&!i,startIcon:t.jsx(O.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>ye(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>ye(E,"hoverButton")},"&:active":{boxShadow:E=>ye(E,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Gu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(O.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const xs="COLUMN";function Uu({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:c,onToggleVisibility:l,onWidthChange:u,moveColumn:g}){const f=p.useRef(null),[m,v]=p.useState(i.toString());p.useEffect(()=>{v(i.toString())},[i]);const[{handlerId:C},B]=ir.useDrop({accept:xs,collect(S){return{handlerId:S.getHandlerId()}},hover(S,R){var I;if(!f.current)return;const q=S.index,T=r;if(q===T)return;const F=(I=f.current)==null?void 0:I.getBoundingClientRect(),X=(F.bottom-F.top)/2,W=R.getClientOffset(),h=((W==null?void 0:W.y)??0)-F.top;q<T&&h<X||q>T&&h>X||(g(q,T),S.index=T)}}),[{isDragging:b},y]=ir.useDrag({type:xs,item:()=>({index:r}),collect:S=>({isDragging:S.isDragging()})});y(B(f));const z=()=>{const S=parseInt(m);if(isNaN(S)){v(i.toString()),u(e.name,i);return}const R=Math.max(s,Math.min(a,S));v(R.toString()),u(e.name,R)},x=S=>{if(S===""||/^\d+$/.test(S)){v(S);const R=parseInt(S);if(!isNaN(R)&&R>=s){const q=Math.min(a,R);u(e.name,q)}}},j=S=>{S.key==="Enter"&&(S.preventDefault(),z(),S.target.blur())},E=S=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[S]||"text.secondary";return t.jsxs(o.TableRow,{ref:f,"data-handler-id":C,sx:{opacity:b?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(O.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:S=>S.typography.body2.fontWeight||400,fontSize:S=>S.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:dt(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${E(e.type)}15`,color:E(e.type),border:`1px solid ${E(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:m,onChange:S=>x(S.target.value),onBlur:z,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>l(e.name,!n),disabled:!n&&!c,title:n?"Hide column":c?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(O.Visibility,{sx:{fontSize:20}}):t.jsx(O.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?S=>$(S.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Yu({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:g,onClose:f}){const m=br(),[v,C]=p.useState(!1),[B,b]=p.useState(n),[y,z]=p.useState(i),[x,j]=p.useState("all");p.useEffect(()=>{b(n)},[n]),p.useEffect(()=>{z(i)},[i]);const E=(I,N)=>{z(d=>({...d,[I]:N})),u==null||u(I,N)},S=(I,N)=>{const d=[...B],[oe]=d.splice(I,1);d.splice(N,0,oe),b(d),l(d)},R=()=>{g(),C(!1)},T=B.map(I=>e.find(N=>N.name===I)).filter(I=>I!==void 0).filter(I=>{const N=r[I.name]??!0;return x==="active"?N:x==="hidden"?!N:!0}),F=Object.values(r).filter(I=>I).length,X=e.length,W=s.find(I=>I.id===a),h=p.useMemo(()=>{if(!W)return!1;const I=W.snapshot,N=I.columnVisibility??{},d=JSON.stringify(r)!==JSON.stringify(N),oe=I.columnOrder??[],G=n??[],te=JSON.stringify(G)!==JSON.stringify(oe)&&!(G.length===0&&oe.length===0),ge=I.columnWidths??{},V=JSON.stringify(y)!==JSON.stringify(ge);return d||te||V},[W,r,n,y]);return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:f,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>$(I.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:I=>ot(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>ue(I).paper.boxShadow,border:I=>ue(I).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,flexShrink:0,bgcolor:I=>ue(I).header.backgroundColor,borderBottom:I=>ue(I).header.borderBottom,boxShadow:I=>ue(I).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:I=>I.typography.h6.fontSize||"1.125rem",fontWeight:I=>I.typography.h6.fontWeight||500,color:I=>I.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Dr,{content:_r.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:f,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:x,onChange:(I,N)=>j(N),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:I=>ct(I).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:I=>$(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>$(I.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${m.columns.minColumnWidth}px, max: ${m.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(O.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:T.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):T.map((I,N)=>{const d=r[I.name]??!0,oe=d||F<m.columns.maxVisible;return t.jsx(Uu,{column:I,index:N,isVisible:d,width:y[I.name]||170,minColumnWidth:m.columns.minColumnWidth,maxColumnWidth:m.columns.maxColumnWidth,canToggleOn:oe,onToggleVisibility:c,onWidthChange:E,moveColumn:S},I.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[F," of ",X," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>C(!0),disabled:!h,variant:"outlined",startIcon:t.jsx(O.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),v&&t.jsx(o.Box,{onClick:()=>C(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>$(I.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:I=>_o(I),bgcolor:"background.paper",boxShadow:I=>ue(I).paper.boxShadow,border:I=>ue(I).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>C(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:I=>`${I.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>ye(I,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:I=>ye(I,"hoverButton")},"&:active":{boxShadow:I=>ye(I,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function qu({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var q;const[a,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[g,f]=p.useState(null),m=p.useMemo(()=>Aa(e),[e]),v=p.useMemo(()=>m.filter(T=>!a.levels.some((F,X)=>F.column===T.name&&X!==g)),[m,a.levels,g]),C=br(),B=a.levels.length<C.grouping.maxLevels&&v.length>0&&(C.grouping.allowNested||a.levels.length===0),b=p.useCallback(T=>{!B||!T||(c({...a,levels:[...a.levels,{column:T}],enabled:!0}),u(""),setTimeout(()=>{var F;return(F=document.activeElement)==null?void 0:F.blur()},0))},[B,a]),y=p.useCallback(T=>{const F=a.levels.filter((X,W)=>W!==T);if(F.length===0){n(null),i();return}c({...a,levels:F,enabled:F.length>0})},[a,n,i]),z=p.useCallback(T=>{f(T),u(a.levels[T].column)},[a.levels]),x=p.useCallback(()=>{if(g===null||!l)return;const T=[...a.levels];T[g]={column:l},c({...a,levels:T}),f(null),u("")},[g,l,a]),j=p.useCallback(()=>{f(null),u("")},[]),E=p.useCallback((T,F)=>{const X=F==="up"?T-1:T+1;if(X<0||X>=a.levels.length)return;const W=[...a.levels],[h]=W.splice(T,1);W.splice(X,0,h),c({...a,levels:W})},[a]),S=p.useCallback(()=>{n(null),i()},[n,i]),R=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:T=>$(T.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:T=>T.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:T=>ot(T),bgcolor:"background.paper",outline:"none",boxShadow:T=>ue(T).paper.boxShadow,border:T=>ue(T).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:T=>ue(T).header.backgroundColor,borderBottom:T=>ue(T).header.borderBottom,boxShadow:T=>ue(T).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:T=>T.typography.h6.fontSize||"1.125rem",fontWeight:T=>T.typography.h6.fontWeight||500,color:T=>T.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Dr,{content:_r.grouping,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T=>$(T.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:T=>$(T.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[g===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:T=>b(T.target.value),disabled:!B,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),v.map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:F=>Bt(F),"&:hover":{bgcolor:F=>$(F.palette.primary.main,.2)}}},children:[dt(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),a.levels.length>=C.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:T=>`1px solid ${$(T.palette.warning.main,.5)}`,bgcolor:T=>$(T.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1.5,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:T=>u(T.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:T=>Bt(T)}},children:[a.levels[g].column," (",(q=e.find(T=>T.name===a.levels[g].column))==null?void 0:q.type.toUpperCase(),")"]}),v.filter(T=>T.name!==a.levels[g].column).map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:F=>Bt(F)}},children:[dt(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:x,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:T=>ye(T,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:j,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&g===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:S,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((T,F)=>{const X=e.find(W=>W.name===T.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:W=>ye(W,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${F+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:W=>`0 1px 2px 0 ${$(W.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:W=>W.typography.body2.fontWeight||500,fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:T.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:W=>W.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:X==null?void 0:X.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>E(F,"up"),disabled:F===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>E(F,"down"),disabled:F===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>z(F),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(O.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(F),sx:{color:"text.secondary","&:hover":{bgcolor:W=>$(W.palette.error.main,.08),color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:18}})})]})]},F)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ye(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ye(T,"hoverButton")},"&:active":{boxShadow:T=>ye(T,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Ju({onExportAnyway:e,onSaveAndExport:r,onCancel:n}){return t.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(O.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(O.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(O.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const fs=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function Ku(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function Xu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function Qu({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=ht(),s=i.palette,[a,c]=p.useState("1h"),[l,u]=p.useState(!1),g=[...e].sort((B,b)=>new Date(b.timestamp).getTime()-new Date(B.timestamp).getTime()),f=fs.find(B=>B.key===a),m=Ku(e,f.ms),v=()=>u(!0),C=()=>{n&&(n(Xu(e,f.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:$(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:ot(i),bgcolor:"background.paper",overflow:"hidden",...ue(i).paper,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...ue(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(Dr,{content:_r.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[g.length," event",g.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:B=>c(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:$(s.text.primary,.3)}},children:fs.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:$(s.error.main,.5),"&:hover":{bgcolor:$(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:$(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(s.text.primary,.14),borderRadius:3}},children:g.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(O.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(B=>{const b=uu(i,B.feature),{summary:y,detail:z}=nl(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:$(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:al(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:$(b,.1),color:b,border:`1px solid ${$(b,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:y}),z&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:z}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:ll(B.timestamp)})]}),B.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(i),...ue(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:$(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[m," audit record",m!==1?"s":""]})," ",f.key==="all"?"from all time":`from the ${f.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:C,variant:"contained",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",m," Record",m!==1?"s":""]})]})]})]})}function Zu({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[c,l]=p.useState(""),[u,g]=p.useState([]),[f,m]=p.useState(""),[v,C]=p.useState(""),B=S=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(S),b=()=>{const S=c.trim();if(S){if(!B(S)){C("Please enter a valid email address");return}if(u.includes(S)){C("This email is already added");return}g([...u,S]),l(""),C("")}},y=S=>{g(u.filter(R=>R!==S))},z=S=>{S.key==="Enter"&&(S.preventDefault(),b())},x=()=>{if(!n.trim()){m("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},j=S=>{i(S),f&&m("")},E=S=>{l(S),v&&C("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:S=>$(S.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:S=>S.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:S=>S.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:S=>ot(S),bgcolor:"background.paper",outline:"none",boxShadow:S=>ue(S).paper.boxShadow,border:S=>ue(S).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:S=>ue(S).header.backgroundColor,borderBottom:S=>ue(S).header.borderBottom,boxShadow:S=>ue(S).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:S=>S.typography.h6.fontSize||"1.125rem",fontWeight:S=>S.typography.h6.fontWeight||500,color:S=>S.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:S=>$(S.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:S=>$(S.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(O.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:S=>`1px solid ${$(S.palette.primary.main,.3)}`,bgcolor:S=>Bt(S),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:S=>S.typography.body2.fontSize||"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:S=>j(S.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!f,helperText:f,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:S=>a(S.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:c,onChange:S=>E(S.target.value),onKeyPress:z,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(O.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),t.jsx(o.Button,{onClick:b,variant:"outlined",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:S=>`${S.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(S=>t.jsx(o.Chip,{label:S,onDelete:()=>y(S),deleteIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>Bt(R),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},S))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:x,variant:"contained",startIcon:t.jsx(O.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>ye(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>ye(S,"hoverButton")},"&:active":{boxShadow:S=>ye(S,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function ep({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(O.Link,{sx:{fontSize:14}}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(O.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>$(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function tp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>$(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>ot(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>ue(c).paper.boxShadow,border:c=>ue(c).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:c=>ue(c).header.backgroundColor,borderBottom:c=>ue(c).header.borderBottom,boxShadow:c=>ue(c).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.h6.fontSize||"1.125rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:c=>c.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:c=>c.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:c=>$(c.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(O.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:c=>c.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(c=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>ye(l,"restButtonLight")}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:c.name}),c.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>$(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>ye(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ye(c,"hoverButton")},"&:active":{boxShadow:c=>ye(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ea={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},rp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],op=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function np(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=op.some(l=>l.test(i.name));let a=!1;const c=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(a=c.filter(u=>rp.some(g=>g.test(u))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function kn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(c=>{const l=n.map(g=>String(g[c]??"")).filter(g=>g.length>0);if(l.length===0)return 5;const u=l.reduce((g,f)=>g+f.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function ip(e,r){const n=kn(e,r);return Math.ceil(n*3.5)}function sp(e,r){const n=kn(e,r);return Math.ceil(n*.7)}function ap(e,r){const n=kn(e,r);return Math.ceil(n*2)}function lp(e,r,n){switch(e){case"csv":return kn(r,n);case"excel":return sp(r,n);case"json":return ip(r,n);case"pdf":return ap(r,n)}}function gs(e,r){return Math.ceil(e/r)}function cp(e,r,n,i,s=ea){const a=[],c=lp(e,r,n),l=r.length;if(l>s.maxRowsHard){const f=gs(l,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${f} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const f=gs(l,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${f} smaller export${f>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${wo(c)} exceeds the ${wo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${wo(c)}`,detail:`This exceeds the recommended ${wo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const f=np(i.filter(m=>n.includes(m.name)),r);if(f.length>0){const m=f.length>s.maxImageColumns;a.push({type:"image_columns",severity:m?"error":"warning",message:`Image column${f.length>1?"s":""} detected: ${f.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:m?`Exporting ${f.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:f.length,limit:s.maxImageColumns})}}const u=a.some(f=>f.severity==="error"),g=a.some(f=>f.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:c}}function wo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function dp({violation:e}){const n=ht().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=$(i?n.error.main:n.warning.main,.06),c=i?$(n.error.main,.25):$(n.warning.main,.3),l=i?O.ErrorOutline:O.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:c},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(O.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function up({format:e}){const r=ht(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:$(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function ys({checked:e}){const r=ht();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function pp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:u=[],initialFormat:g,initialScope:f="visible",initialColumnScope:m="visible",classTokens:v={},onExport:C,onClose:B}){const b=ht(),y=b.palette,z=br(),x=p.useMemo(()=>{var ce,de,ne,Q,pe;const G=((ne=(de=(ce=b.components)==null?void 0:ce.MuiCard)==null?void 0:de.styleOverrides)==null?void 0:ne.root)||{},te=G.border&&G.border!=="none"?G.border:(Q=b.tokens)!=null&&Q.cardBodyBorder&&b.tokens.cardBodyBorder!=="none"?b.tokens.cardBodyBorder:y.divider,ge=G.borderRadius!==void 0?typeof G.borderRadius=="number"?`${G.borderRadius}px`:G.borderRadius:`${b.shape.borderRadius}px`,V=G.boxShadow&&G.boxShadow!=="none"?G.boxShadow:((pe=b.tokens)==null?void 0:pe.cardBodyShadow)||ye(b,"menu"),K=ct(b);return{sectionBorder:`var(--urm-export-section-border, ${te})`,sectionTitleColor:`var(--urm-export-section-title-color, ${y.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${y.background.paper})`,cardBg:`var(--urm-export-card-bg, ${y.background.paper})`,cardBorder:`var(--urm-export-card-border, ${te})`,cardRadius:ge,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${y.mode==="dark"?$(y.common.white,.08):$(y.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${$(K.main,y.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${K.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${y.mode==="dark"?y.primary.light:y.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${y.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${y.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${y.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${b.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${b.spacing(1.5)})`}},[y,b]),j=g||z.export.allowedFormats[0]||"csv",[E,S]=p.useState(j),[R,q]=p.useState(f),[T,F]=p.useState(m),X=R==="visible"?r:e,W=T==="visible"?i:s,h=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[R,r,e,u,l]),I=p.useMemo(()=>T==="all"?a.map(G=>G.name):a.map(G=>G.name).slice(0,i),[T,a,i]),N=p.useMemo(()=>cp(E,h,I,a,ea),[E,h,I,a]),d=()=>{N.hasBlockingViolation||(C({format:E,scope:R,columnScope:T}),B())},oe={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:$(y.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:G=>G.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:ot(b),bgcolor:x.sectionTitleBg,overflow:"hidden",border:`1px solid ${x.cardBorder}`,boxShadow:x.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:G=>ue(G).header.backgroundColor,borderBottom:G=>ue(G).header.borderBottom,boxShadow:G=>ue(G).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:y.text.primary},children:"Export Report"}),t.jsx(Dr,{content:_r.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:y.text.secondary,borderRadius:"50%","&:hover":{bgcolor:y.action.hover,color:y.text.primary}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:x.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(y.text.primary,.15),borderRadius:3}},children:[N.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:N.violations.map((G,te)=>t.jsx(dp,{violation:G},te))}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:x.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:z.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:z.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:z.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:z.export.allowedFormats.includes("pdf")}].filter(G=>G.allowed).map(G=>{const te=E===G.id;return t.jsxs(o.Box,{onClick:()=>S(G.id),className:`urm-export-format-card ${te?v.formatCardSelected||"":v.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[te&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:x.cardSelectedBorder,color:y.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${$(y.primary.main,.3)}`},children:t.jsx(O.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(up,{format:G.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:te?x.cardSelectedColor:y.text.primary},children:G.title}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:13}})})})]})]},G.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(O.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(G=>{const te=R===G.value;return t.jsxs(o.Box,{onClick:()=>q(G.value),className:`urm-export-row-card ${te?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(ys,{checked:te}),t.jsx(o.Box,{sx:{color:te?x.cardSelectedColor:y.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?x.cardSelectedColor:y.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(G=>{const te=T===G.value;return t.jsxs(o.Box,{onClick:()=>F(G.value),className:`urm-export-column-card ${te?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(ys,{checked:te}),t.jsx(o.Box,{sx:{color:te?x.cardSelectedColor:y.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?x.cardSelectedColor:y.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Format",value:oe[E]},{icon:t.jsx(O.FormatListNumberedOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Rows to Export",value:X.toLocaleString()},{icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Columns to Export",value:String(W)},{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Estimated File Size",value:`~${wo(N.estimatedBytes)}`,highlight:N.hasBlockingViolation?"error.main":N.hasWarning?"warning.main":void 0}].map(({icon:G,label:te,value:ge,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[G,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:y.text.secondary,fontWeight:500},children:te})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??y.text.primary},children:ge})]},te))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[N.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:G=>G.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:G=>G.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:B,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:y.text.primary,borderColor:x.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:x.cardHoverBg,borderColor:$(y.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:d,disabled:N.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx(O.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:x.primaryBtnBg,color:x.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${$(y.primary.main,.25)}`,"&:hover":{bgcolor:x.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:$(y.primary.main,.4),color:x.primaryBtnColor}},children:["Download ",oe[E]]})]})]})})}function hp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(O.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function mp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(O.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})}}})(),c=bl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(O.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:c}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class xp extends p.Component{constructor(n){super(n);Ci(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Ut.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>$(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>$(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(O.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function fp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(O.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Ko({children:e,feature:r,onError:n}){return t.jsx(xp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(fp,{feature:r}),children:e})}const gp=[{value:"equals",label:"Equals",group:"Text"},{value:"contains",label:"Contains",group:"Text"},{value:"startsWith",label:"Starts with",group:"Text"},{value:"endsWith",label:"Ends with",group:"Text"},{value:"gt",label:"Greater than (>)",group:"Numeric"},{value:"lt",label:"Less than (<)",group:"Numeric"},{value:"gte",label:"At least (≥)",group:"Numeric"},{value:"lte",label:"At most (≤)",group:"Numeric"},{value:"isTrue",label:"Is true",group:"Boolean"},{value:"isFalse",label:"Is false",group:"Boolean"},{value:"NULL",label:"Is empty (NULL)",group:"Null checks"},{value:"NOT_NULL",label:"Is not empty",group:"Null checks"}],yp=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}];function bo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function bp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),g=()=>l(gt),f=()=>{i(c),r()},m={sort:y=>l(z=>({...z,sort:{...z.sort,...y}})),filter:y=>l(z=>({...z,filter:{...z.filter,...y}})),columns:y=>l(z=>({...z,columns:{...z.columns,...y}})),grouping:y=>l(z=>({...z,grouping:{...z.grouping,...y}})),export:y=>l(z=>({...z,export:{...z.export,...y}}))},v=y=>{const z=c.filter.allowedOperators,x=z.includes(y)?z.filter(j=>j!==y):[...z,y];x.length!==0&&m.filter({allowedOperators:x})},C=y=>{const z=c.export.allowedFormats,x=z.includes(y)?z.filter(j=>j!==y):[...z,y];x.length!==0&&m.export({allowedFormats:x})},B=[{label:"Sort",icon:t.jsx(O.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx(O.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx(O.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx(O.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx(O.Download,{sx:{fontSize:17}})}],b=y=>JSON.stringify(c[y])===JSON.stringify(gt[y]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:y=>ot(y),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:y=>`0 8px 32px ${$(y.palette.common.black,.2)}`}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:y=>$(y.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(y,z)=>a(z),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:B.map((y,z)=>t.jsx(o.Tab,{label:y.label,icon:y.icon,iconPosition:"start"},z))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(bo,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!b("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(y,z)=>m.sort({maxLevels:z}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),t.jsxs(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(bo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!b("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(y,z)=>m.filter({maxConditions:z}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(y=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:y}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:gp.filter(z=>z.group===y).map(z=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(z.value),onChange:()=>v(z.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:z.label}),sx:{mr:1.5}},z.value))})]},y))]})]}),t.jsxs(bo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!b("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(y,z)=>m.columns({maxVisible:z}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:c.columns.minColumnWidth,onChange:(y,z)=>m.columns({minColumnWidth:z}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(y,z)=>m.columns({maxColumnWidth:z}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]})]})]})]}),t.jsxs(bo,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!b("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(y=>t.jsxs(o.Box,{onClick:()=>m.grouping({maxLevels:y}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===y?"primary.main":"divider",bgcolor:c.grouping.maxLevels===y?z=>$(z.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:z=>$(z.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===y?"primary.main":"text.secondary"},children:y}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][y-1]})]},y))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:y=>m.grouping({allowNested:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:y=>m.grouping({allowCollapse:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(bo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!b("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:yp.map(y=>t.jsxs(o.Box,{onClick:()=>C(y.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(y.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(y.value)?z=>$(z.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(y.value),onChange:()=>C(y.value),onClick:z=>z.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:y.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:y.desc})]})]},y.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:y=>$(y.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(O.RestartAlt,{sx:{fontSize:18}}),onClick:g,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:y=>$(y.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:f,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const vp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Sp={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Qo(e,r,n,i,s=new Date){const[a,c]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,c,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,g=l.getDay();let f=u-g;return f<0&&(f+=7),f===0&&l<=s&&(f=7),l.setDate(l.getDate()+f),l.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return l.setDate(u),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(u)),l.toISOString()}return l.toISOString()}function Cp(e){const r=ta(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${vp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Sp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ta(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function wp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function jp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ta(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function ra(e){return`urm_schedules_${e}`}function oa(e){try{const r=localStorage.getItem(ra(e));return r?JSON.parse(r).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function na(e,r){try{localStorage.setItem(ra(e),JSON.stringify(r))}catch{}}const kp=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],zp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ia={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Ir={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function Tp({initial:e=ia,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[c,l]=p.useState(!1),[u,g]=p.useState(!1),f=(C,B)=>a(b=>({...b,[C]:B})),m=s.email.trim().length>0&&!zp.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!m;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:t.jsx(O.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,fontSize:C=>C.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:C=>{f("name",C.target.value),c&&C.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:C=>f("frequency",C.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:C=>f("dayOfWeek",Number(C.target.value)),children:kp.map(C=>t.jsx(o.MenuItem,{value:C.value,children:C.label},C.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:C=>f("dayOfMonth",Number(C.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:Ir}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:C=>f("time",C.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:C=>f("format",C.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:C=>f("scope",C.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:C=>f("email",C.target.value),onBlur:()=>g(!0),placeholder:"user@company.com",error:u&&m,helperText:u&&m?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(O.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Ir}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx(O.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Bp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:_o(i),...ue(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>$(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Ip({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const c=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>$(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>$(l.palette.success.main,.1):l=>$(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Cp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>$(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(O.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",wp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",jp(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>$(l.palette.warning.main,.08):l=>$(l.palette.success.main,.08)}},children:c?t.jsx(O.Pause,{sx:{fontSize:15}}):t.jsx(O.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>$(l.palette.error.main,.08)}},children:t.jsx(O.Delete,{sx:{fontSize:15}})})})]})]})]})}function Ep({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,g]=p.useState([]),f=l?(a==null?void 0:a.schedules)??[]:u,[m,v]=p.useState({type:"list"}),[C,B]=p.useState(0),[b,y]=p.useState(null);p.useEffect(()=>{e&&(l||g(oa(n)),v({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const W=setInterval(()=>B(h=>h+1),3e4);return()=>clearInterval(W)},[e]);const z=p.useCallback(W=>{g(W),na(n,W)},[n]),x=W=>{var N;const h=Qo(W.frequency,W.time,W.dayOfWeek,W.dayOfMonth),I={id:`sched-${Date.now()}`,reportId:n,name:W.name.trim(),frequency:W.frequency,dayOfWeek:W.frequency==="weekly"?W.dayOfWeek:void 0,dayOfMonth:W.frequency==="monthly"?W.dayOfMonth:void 0,time:W.time,format:W.format,scope:W.scope,email:W.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:h,runCount:0};l?(N=a==null?void 0:a.onScheduleCreate)==null||N.call(a,I):z([...f,I]),v({type:"list"})},j=W=>{var d;if(m.type!=="edit")return;const h=m.schedule,I=Qo(W.frequency,W.time,W.dayOfWeek,W.dayOfMonth),N={...h,name:W.name.trim(),frequency:W.frequency,dayOfWeek:W.frequency==="weekly"?W.dayOfWeek:void 0,dayOfMonth:W.frequency==="monthly"?W.dayOfMonth:void 0,time:W.time,format:W.format,scope:W.scope,email:W.email.trim()||void 0,nextRunAt:I};l?(d=a==null?void 0:a.onScheduleUpdate)==null||d.call(a,N):z(f.map(oe=>oe.id===h.id?N:oe)),v({type:"list"})},E=W=>{var oe;const h=f.find(G=>G.id===W);if(!h)return;const I=!h.isActive,N=I?Qo(h.frequency,h.time,h.dayOfWeek,h.dayOfMonth):h.nextRunAt,d={...h,isActive:I,nextRunAt:N};l?(oe=a==null?void 0:a.onScheduleToggle)==null||oe.call(a,W,I):z(f.map(G=>G.id===W?d:G))},S=W=>{if(s(W),!l){const h=new Date().toISOString();z(f.map(I=>I.id===W.id?{...I,lastRunAt:h,runCount:I.runCount+1}:I))}},R=W=>{const h=f.find(I=>I.id===W)??null;y(h)},q=()=>{var W;b&&(l?(W=a==null?void 0:a.onScheduleDelete)==null||W.call(a,b.id):z(f.filter(h=>h.id!==b.id)),y(null))},T=W=>({name:W.name,frequency:W.frequency,dayOfWeek:W.dayOfWeek??1,dayOfMonth:W.dayOfMonth??1,time:W.time,format:W.format,scope:W.scope,email:W.email??""}),F=m.type!=="list",X=f.filter(W=>W.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:F,PaperProps:{sx:W=>({borderRadius:ot(W),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ue(W).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:W=>$(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:W=>W.typography.h6.fontWeight||600,fontSize:W=>W.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(Dr,{content:_r.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:W=>$(W.palette.text.primary,.06)}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[F&&t.jsx(Tp,{initial:m.type==="edit"?T(m.schedule):ia,isEditing:m.type==="edit",onSave:m.type==="edit"?j:x,onBack:()=>v({type:"list"})}),m.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:f.length===0?"No schedules yet":`${X} of ${f.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(O.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>v({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),f.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(O.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:W=>W.typography.body2.fontWeight||500,fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:f.map(W=>t.jsx(Ip,{schedule:W,tick:C,onToggle:E,onRunNow:S,onEdit:h=>v({type:"edit",schedule:h}),onDelete:R},W.id))})]})]}),m.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:W=>$(W.palette.warning.main,.06),border:"1px solid",borderColor:W=>$(W.palette.warning.main,.2)},children:[t.jsx(O.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:W=>$(W.palette.text.primary,.06)}},children:"Close"})]})]}),b&&t.jsx(Bp,{scheduleName:b.name,onConfirm:q,onCancel:()=>y(null)})]})}const Dp=6e4;function _p({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m}){const v=(m==null?void 0:m.mode)??"local",C=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m,schedulerMode:v});p.useEffect(()=>{C.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m,schedulerMode:v}});const B=p.useCallback(b=>{var W,h,I,N,d;const{reportName:y,uploadedData:z,processedData:x,schema:j,activeView:E,columnVisibility:S,columnOrder:R,filters:q,sortStack:T,schedulerConfig:F,schedulerMode:X}=C.current;try{const oe=b.scope==="all"?z:x;if(X==="api"){const ge=(R.length>0?R:j.map(K=>K.name)).filter(K=>S[K]!==!1),V={schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:ge,format:b.format,reportName:y};(W=F==null?void 0:F.onScheduleFire)==null||W.call(F,V),(I=(h=C.current).onFired)==null||I.call(h,b);return}const G=Zo(oe,j,q,T,E,S,R),te=`${b.name}_scheduled`;switch(b.format){case"csv":en(G,te,{scope:b.scope});break;case"excel":tn(G,te,{scope:b.scope});break;case"json":rn(G,te,{scope:b.scope});break;case"pdf":hi(G,te,{scope:b.scope});break}if(F!=null&&F.onScheduleFire){const ge=(R.length>0?R:j.map(V=>V.name)).filter(V=>S[V]!==!1);F.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:ge,format:b.format,reportName:y})}if(b.email){const ge=encodeURIComponent(`Scheduled Report: ${b.name}`),V=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
192
192
 
193
- Report: ${f}
194
- Format: ${S.format.toUpperCase()}
193
+ Report: ${y}
194
+ Format: ${b.format.toUpperCase()}
195
195
  Generated: ${new Date().toLocaleString()}
196
196
 
197
- The file has been downloaded to your device.`);window.open(`mailto:${S.email}?subject=${Se}&body=${V}`,"_blank")}(oe=(P=w.current).onFired)==null||oe.call(P,S)}catch(d){Vt.error("urm:scheduler",`Export failed for schedule: ${S.name}`,d)}},[]);p.useEffect(()=>{if(!e)return;const S=()=>{const{reportId:b,schedulerMode:g,schedulerConfig:T}=w.current;if(!b)return;const I=g==="api"?(T==null?void 0:T.schedules)??[]:ia(b),C=new Date;let W=!1;const K=I.map(E=>{if(!E.isActive)return E;if(new Date(E.nextRunAt)<=C){B(E);const G=Zo(E.frequency,E.time,E.dayOfWeek,E.dayOfMonth,C);return W=!0,{...E,lastRunAt:C.toISOString(),nextRunAt:G,runCount:E.runCount+1}}return E});W&&g==="local"&&sa(b,K)};S();const f=setInterval(S,$p);return()=>clearInterval(f)},[e,B])}function la({reportEngine:e}){var Ve,Br,it,er,Dt,Ir;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:u,showFilterPanel:x,setShowFilterPanel:m,filterFocusColumn:h,handleReplaceFilters:v,handleOpenFilterForColumn:w,handleCloseFilterPanel:B,handleClearFiltersForColumn:S,showSortPanel:f,setShowSortPanel:b,handleSort:g,handleUpdateSortStack:T,handleSortAscending:I,handleSortDescending:C,showCreateViewModal:W,setShowCreateViewModal:K,showEditViewModal:E,setShowEditViewModal:U,showDeleteConfirmation:G,setShowDeleteConfirmation:M,editingView:y,deletingView:k,handleSelectView:P,handleCreateView:oe,handleUpdateCurrentView:d,handleSaveAsNewView:J,handleRevertChanges:ee,handleToggleDefault:Se,handleToggleFavorite:V,handleSoftDelete:X,handleRestoreView:pe,handlePermanentDelete:ce,handleEditView:ie,handleCloneView:te,handleCopyViewLink:se,handleSaveEditView:R,handleConfirmDelete:L,handlePromoteToGlobal:de,handleSetDefaultForAllUsers:he,showManageColumns:Te,setShowManageColumns:Q,handleUpdateColumnVisibility:ye,handleUpdateColumnOrder:dt,handleUpdateColumnWidth:Ht,handleResetColumnLayout:Ot,showGroupPanel:Mr,setShowGroupPanel:Mt,handleGroup:nt,handleToggleGroupCollapse:Ut,handleExpandAllGroups:Je,handleCollapseAllGroups:Bt,searchQuery:br,debouncedSearchQuery:yt,searchHistory:Gt,handleSearchChange:lo,handleAddToSearchHistory:ar,handleToggleSearchFavourite:co,handleDeleteSearchHistory:It,selectedRowIds:vr,handleToggleRowSelection:Ke,handleToggleAllRows:At,handleRangeSelection:Yt,handleClearSelection:Ze,handleUpdateSelectionAfterDelete:et,currentPage:Wt,pageSize:uo,paginationTotalRows:Ar,handlePageChange:Sr,handlePageSizeChange:Fe,isExporting:ke,showExportModal:lr,setShowExportModal:Rt,showDirtyExportWarning:Cr,handleExport:wr,handleExportWithConfig:qt,handleExportSelected:cr,handleExportAnyway:tt,handleSaveAndExport:dr,handleCancelExport:bt,showAuditHistory:Wr,setShowAuditHistory:re,showCreatePreset:jr,setShowCreatePreset:Rr,showManagePresets:Et,setShowManagePresets:H,activePreset:ut,handleCreatePreset:ae,handleClearActivePreset:Xe,handleOpenPresetById:ur,handleDeletePresetById:Jt,isViewerRole:po,userRole:Kt,featureLimitWarning:kr,setFeatureLimitWarning:Xt,reportError:pr,setReportError:Qt,handleError:we,updateReport:vt,showSnack:Z,config:fe,scheduler:Ce}=e,[zr,Tr]=p.useState(!1);Op({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:c,columnVisibility:(r==null?void 0:r.columnVisibility)||((Ve=c==null?void 0:c.snapshot)==null?void 0:Ve.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Br=c==null?void 0:c.snapshot)==null?void 0:Br.columnOrder)||[],filters:Ne(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:xe=>{Z(`Scheduled export "${xe.name}" completed`,"success")},schedulerConfig:Ce});const ho=p.useCallback((xe,ve)=>{if(!(r!=null&&r.uploadedData))return;const He=r.uploadedData[xe],Ye=[...r.uploadedData];Ye[xe]=ve;const pt=To(r.id,"user","rows","row_edited",He,ve),St=Bo(r.auditHistory||[],pt);vt(r.id,{uploadedData:Ye,auditHistory:St})},[r,vt]),Pr=p.useCallback(xe=>{if(!(r!=null&&r.uploadedData))return;const ve=r.uploadedData.indexOf(xe);if(ve===-1)return;const He=r.uploadedData.filter((St,Pt)=>Pt!==ve),Ye=To(r.id,"user","rows","row_deleted",xe,null),pt=Bo(r.auditHistory||[],Ye);vt(r.id,{uploadedData:He,auditHistory:pt}),et(xe)},[r,vt,et]),fo=p.useCallback((xe,ve)=>{if(!(r!=null&&r.uploadedData))return;const He=r.uploadedData.indexOf(ve),Ye=He!==-1?He+1:xe+1,pt=[...r.uploadedData];pt.splice(Ye,0,{...ve});const St=To(r.id,"user","rows","row_duplicated",ve,{...ve}),Pt=Bo(r.auditHistory||[],St);vt(r.id,{uploadedData:pt,auditHistory:Pt})},[r,vt]),Zt=gr(),{handleDevConfigChange:Nr}=un(),[Lr,be]=p.useState(!1);return p.useEffect(()=>{const xe=ve=>{ve.ctrlKey&&ve.shiftKey&&ve.key==="D"&&(ve.preventDefault(),be(!0))};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[kr&&t.jsx(mp,{warning:kr,onDismiss:()=>Xt(null)}),pr&&t.jsx(xp,{error:pr,onDismiss:()=>Qt(null)}),Cr&&t.jsx(Xu,{onExportAnyway:tt,onSaveAndExport:dr,onCancel:bt}),t.jsx(Nu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:ke,columnVisibility:r.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:r.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:r.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:r.grouping,onSort:g,onSortAscending:I,onSortDescending:C,onOpenFilters:()=>m(!0),onOpenSort:()=>b(!0),onOpenFilterForColumn:w,onSelectView:P,onCreateView:()=>K(!0),onUpdateCurrentView:d,onSaveAsNewView:J,onDiscardChanges:ee,onToggleDefault:Se,onToggleFavorite:V,onRestoreView:pe,onPermanentDelete:ce,onEditView:ie,onCloneView:te,onCopyLink:se,onDeleteView:X,onPromoteToGlobal:de,onSetDefaultForAllUsers:he,isAdmin:((it=Zt.views)==null?void 0:it.isAdmin)??!1,onExport:wr,onOpenColumns:()=>Q(!0),onUpdateColumnWidth:Ht,onUpdateColumnOrder:dt,onUpdateColumnVisibility:ye,onClearFiltersForColumn:S,onResetLayout:Ot,onOpenGroup:()=>Mt(!0),onGroupByColumn:(er=fe==null?void 0:fe.hideToolbarActions)!=null&&er.includes("grouping")?void 0:xe=>{nt({enabled:!0,levels:[{column:xe}],collapsedGroups:[]})},onToggleGroupCollapse:Ut,onExpandAllGroups:Je,onCollapseAllGroups:Bt,onOpenAuditHistory:()=>re(!0),onOpenScheduledReports:()=>Tr(!0),searchQuery:br,highlightQuery:yt,searchHistory:Gt,onAddToSearchHistory:ar,onToggleSearchFavourite:co,onDeleteSearchHistory:It,selectedRowIds:vr,onSearchChange:lo,onToggleRowSelection:Ke,onToggleAllRows:At,onRangeSelection:Yt,onClearSelection:Ze,onExportSelected:cr,currentPage:Wt,pageSize:uo,onPageChange:Sr,onPageSizeChange:Fe,totalRowsBeforePagination:Ar,isReadOnly:po,userRole:Kt,reportName:r.name,onEditRow:ho,onDeleteRow:Pr,onDuplicateRow:fo,rowActions:fe==null?void 0:fe.rowActions,hideDefaultRowActions:fe==null?void 0:fe.hideDefaultRowActions,hideToolbarActions:fe==null?void 0:fe.hideToolbarActions,customSettingsActions:fe==null?void 0:fe.customSettingsActions,viewOptions:fe==null?void 0:fe.viewOptions,defaultViewMode:fe==null?void 0:fe.defaultViewMode,bulkActions:fe==null?void 0:fe.bulkActions,hideSelectionCheckboxes:fe==null?void 0:fe.hideSelectionCheckboxes,rowClickBehavior:fe==null?void 0:fe.rowClickBehavior,openModalOn:fe==null?void 0:fe.openModalOn,onRowClick:fe==null?void 0:fe.onRowClick,onRowRightClick:fe==null?void 0:fe.onRowRightClick,showDevPanel:Zt.display.showDevPanel,onOpenDevConfig:()=>be(!0)})]}),x&&t.jsx(Xo,{feature:"Filters",onError:xe=>{const ve=mr("ui","filters",xe);we(ve)},children:t.jsx(Hu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:B,focusColumn:h,onOpenDevConfig:()=>be(!0)})}),f&&t.jsx(Xo,{feature:"Sorting",onError:xe=>{const ve=mr("ui","sorting",xe);we(ve)},children:t.jsx(Gu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:T,onClose:()=>b(!1),onOpenDevConfig:()=>be(!0)})}),W&&u&&(()=>{var He;const xe=(r.views??[]).filter(Ye=>!Ye.isDeleted).length,ve=((He=Zt.views)==null?void 0:He.maxViews)??10;return t.jsx(xs,{currentSnapshot:u,onSave:oe,onClose:()=>K(!1),atViewLimit:xe>=ve,maxViews:ve})})(),E&&y&&t.jsx(xs,{currentSnapshot:y.snapshot,onSave:R,onClose:()=>{U(!1)},isEditMode:!0,initialName:y.name,initialDescription:y.description,initialIsDefault:y.isDefault}),G&&k&&t.jsx(Yu,{viewName:k.name,onConfirm:L,onCancel:()=>{M(!1)}}),Te&&c&&t.jsx(Ju,{schema:r.schema,columnVisibility:r.columnVisibility||c.snapshot.columnVisibility,columnOrder:r.columnOrder||c.snapshot.columnOrder,columnWidths:r.columnWidths||c.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:ye,onUpdateColumnOrder:dt,onUpdateColumnWidth:Ht,onResetLayout:Ot,onClose:()=>Q(!1)}),Mr&&t.jsx(Xo,{feature:"Grouping",onError:xe=>{const ve=mr("ui","grouping",xe);we(ve)},children:t.jsx(Ku,{schema:r.schema,grouping:r.grouping||null,onApply:nt,onClose:()=>Mt(!1),onOpenDevConfig:()=>be(!0)})}),Wr&&t.jsx(ep,{auditHistory:r.auditHistory||[],onClose:()=>re(!1)}),jr&&t.jsx(tp,{onSave:ae,onClose:()=>Rr(!1)}),Et&&t.jsx(op,{presets:r.presets||[],reportId:r.id,onOpenPreset:ur,onDeletePreset:Jt,onClose:()=>H(!1)}),ut&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(rp,{presetName:ut.name,onClear:Xe})}),lr&&t.jsx(Xo,{feature:"Export",onError:xe=>{const ve=mr("ui","export",xe);we(ve)},children:t.jsx(fp,{totalRows:(s==null?void 0:s.totalRows)||((Dt=r.uploadedData)==null?void 0:Dt.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Ir=a==null?void 0:a.columnEngine)==null?void 0:Ir.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:qt,onClose:()=>{Rt(!1)}})}),r&&t.jsx(_p,{open:zr,onClose:()=>Tr(!1),reportId:r.id,reportName:r.name,schedulerConfig:Ce,onRunNow:xe=>{var pt;const ve=(Ce==null?void 0:Ce.mode)??"local",He=xe.scope==="all"?r.uploadedData||[]:i||[],Ye=en(He,r.schema||[],Ne(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(ve==="api"){const St=(r.columnOrder||[]).filter(Pt=>(r.columnVisibility??{})[Pt]!==!1);(pt=Ce==null?void 0:Ce.onScheduleFire)==null||pt.call(Ce,{schedule:xe,triggeredAt:new Date().toISOString(),rows:He,columns:St,format:xe.format,reportName:r.name})}else xe.format==="csv"&&tn(Ye,xe.name),xe.format==="excel"&&rn(Ye,xe.name),xe.format==="json"&&on(Ye,xe.name),xe.format==="pdf"&&hi(Ye,xe.name);Z(`"${xe.name}" exported successfully`,"success")}}),t.jsx(Sp,{open:Lr,onClose:()=>be(!1),config:Zt,onApply:Nr})]})}const Mp={error:"err",warning:"warn",info:"info",success:"suc"};function ca({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var T,I,C,W;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",u=(c==null?void 0:c.notifStyle)??"toast",x=(c==null?void 0:c.notifAccent)??"severity",m=(c==null?void 0:c.notifAutoDismiss)??!0,h=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",w=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",B=Mp[n],S=((T=c==null?void 0:c.status)==null?void 0:T[`${B}Soft`])??a.palette[n].light,f=((I=c==null?void 0:c.status)==null?void 0:I[`${B}Txt`])??a.palette[n].dark,b=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:f,g=u==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:S;return t.jsx(o.Snackbar,{open:e,autoHideDuration:m?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(K,E)=>{E!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:w},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((C=c==null?void 0:c.status)==null?void 0:C[`${B}Soft`])??a.palette[n].light,color:((W=c==null?void 0:c.status)==null?void 0:W[`${B}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[m&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:_(b,.14),color:b,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${c.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx($.Close,{sx:{fontSize:16}})})]}),sx:{width:h,alignItems:"flex-start",bgcolor:g,color:f,boxShadow:u==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${b}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:b}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function da({hasExternalData:e=!1}){const r=un(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:x,createReport:m,handleFileUpload:h,handleUploadError:v,handleRetry:w,handleConfirm:B,snack:S,handleSnackClose:f,snackDurationMs:b}=r,g=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Hl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:x}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:g?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(Ks,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(la,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(ou,{schema:s.schema,onConfirm:B,hasConflicts:c}):s.uploadError?t.jsx(nu,{error:s.uploadError,onRetry:w}):t.jsx(ru,{onFileUpload:h,onError:v,isUploading:a==="uploading"})})}):null}),!e&&t.jsx(tu,{isOpen:l,onClose:()=>u(!1),onCreate:m}),t.jsx(ca,{open:S.open,message:S.message,severity:S.severity,onClose:f,autoHideDurationMs:b})]})}function Ap({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(fi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(da,{hasExternalData:!!(e||r)})})}function ua(){const e=un(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(la,{reportEngine:e}):t.jsx(Ks,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ca,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Wp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(fi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ua,{})})}exports.URMBuilder=Ap;exports.URMBuilderRaw=da;exports.URMProvider=fi;exports.URMViewer=Wp;exports.URMViewerRaw=ua;exports.useURMContext=un;
197
+ The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${ge}&body=${V}`,"_blank")}(d=(N=C.current).onFired)==null||d.call(N,b)}catch(oe){Ut.error("urm:scheduler",`Export failed for schedule: ${b.name}`,oe)}},[]);p.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:z,schedulerMode:x,schedulerConfig:j}=C.current;if(!z)return;const E=x==="api"?(j==null?void 0:j.schedules)??[]:oa(z),S=new Date;let R=!1;const q=E.map(T=>{if(!T.isActive)return T;if(new Date(T.nextRunAt)<=S){B(T);const X=Qo(T.frequency,T.time,T.dayOfWeek,T.dayOfMonth,S);return R=!0,{...T,lastRunAt:S.toISOString(),nextRunAt:X,runCount:T.runCount+1}}return T});R&&x==="local"&&na(z,q)};b();const y=setInterval(b,Dp);return()=>clearInterval(y)},[e,B])}function sa({reportEngine:e}){var Ce,Ge,zr,st,er,Wt;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:u,showFilterPanel:g,setShowFilterPanel:f,filterFocusColumn:m,handleReplaceFilters:v,handleOpenFilterForColumn:C,handleCloseFilterPanel:B,handleClearFiltersForColumn:b,showSortPanel:y,setShowSortPanel:z,handleSort:x,handleUpdateSortStack:j,handleSortAscending:E,handleSortDescending:S,showCreateViewModal:R,setShowCreateViewModal:q,showEditViewModal:T,setShowEditViewModal:F,showDeleteConfirmation:X,setShowDeleteConfirmation:W,editingView:h,deletingView:I,handleSelectView:N,handleCreateView:d,handleUpdateCurrentView:oe,handleSaveAsNewView:G,handleRevertChanges:te,handleToggleDefault:ge,handleToggleFavorite:V,handleSoftDelete:K,handleRestoreView:ce,handlePermanentDelete:de,handleEditView:ne,handleCloneView:Q,handleCopyViewLink:pe,handleSaveEditView:D,handleConfirmDelete:ee,handlePromoteToGlobal:xe,showManageColumns:ae,setShowManageColumns:Te,handleUpdateColumnVisibility:Y,handleUpdateColumnOrder:Pe,handleUpdateColumnWidth:Et,handleResetColumnLayout:mt,showGroupPanel:$r,setShowGroupPanel:Pt,handleGroup:it,handleToggleGroupCollapse:Yt,handleExpandAllGroups:Ke,handleCollapseAllGroups:Dt,searchQuery:Sr,debouncedSearchQuery:vt,searchHistory:qt,handleSearchChange:ao,handleAddToSearchHistory:ar,handleToggleSearchFavourite:lo,handleDeleteSearchHistory:_t,selectedRowIds:Cr,handleToggleRowSelection:Xe,handleToggleAllRows:Nt,handleRangeSelection:Jt,handleClearSelection:Ze,handleUpdateSelectionAfterDelete:et,currentPage:Lt,pageSize:co,paginationTotalRows:Or,handlePageChange:wr,handlePageSizeChange:He,isExporting:Se,showExportModal:lr,setShowExportModal:Kt,showDirtyExportWarning:cr,handleExport:uo,handleExportWithConfig:Ft,handleExportSelected:Mr,handleExportAnyway:dr,handleSaveAndExport:tt,handleCancelExport:Xt,showAuditHistory:xt,setShowAuditHistory:Be,showCreatePreset:he,setShowCreatePreset:jr,showManagePresets:$t,setShowManagePresets:H,activePreset:St,handleCreatePreset:ie,handleClearActivePreset:ut,handleOpenPresetById:Ot,handleDeletePresetById:Qt,isViewerRole:Wr,userRole:kr,featureLimitWarning:Zt,setFeatureLimitWarning:ur,reportError:pr,setReportError:Ar,handleError:ze,updateReport:Qe,showSnack:Z,config:se,scheduler:be}=e,[Rr,hr]=p.useState(!1);_p({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:c,columnVisibility:(r==null?void 0:r.columnVisibility)||((Ce=c==null?void 0:c.snapshot)==null?void 0:Ce.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Ge=c==null?void 0:c.snapshot)==null?void 0:Ge.columnOrder)||[],filters:Fe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:fe=>{Z(`Scheduled export "${fe.name}" completed`,"success")},schedulerConfig:be});const Pr=p.useCallback((fe,je)=>{if(!(r!=null&&r.uploadedData))return;const We=r.uploadedData[fe],qe=[...r.uploadedData];qe[fe]=je;const at=jo(r.id,"user","rows","row_edited",We,je),Ct=ko(r.auditHistory||[],at);Qe(r.id,{uploadedData:qe,auditHistory:Ct})},[r,Qe]),po=p.useCallback(fe=>{if(!(r!=null&&r.uploadedData))return;const je=r.uploadedData.indexOf(fe);if(je===-1)return;const We=r.uploadedData.filter((Ct,tr)=>tr!==je),qe=jo(r.id,"user","rows","row_deleted",fe,null),at=ko(r.auditHistory||[],qe);Qe(r.id,{uploadedData:We,auditHistory:at}),et(fe)},[r,Qe,et]),Nr=p.useCallback((fe,je)=>{if(!(r!=null&&r.uploadedData))return;const We=r.uploadedData.indexOf(je),qe=We!==-1?We+1:fe+1,at=[...r.uploadedData];at.splice(qe,0,{...je});const Ct=jo(r.id,"user","rows","row_duplicated",je,{...je}),tr=ko(r.auditHistory||[],Ct);Qe(r.id,{uploadedData:at,auditHistory:tr})},[r,Qe]),mr=br(),{handleDevConfigChange:Lr}=dn(),[Fr,Mt]=p.useState(!1);return p.useEffect(()=>{const fe=je=>{je.ctrlKey&&je.shiftKey&&je.key==="D"&&(je.preventDefault(),Mt(!0))};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[Zt&&t.jsx(hp,{warning:Zt,onDismiss:()=>ur(null)}),pr&&t.jsx(mp,{error:pr,onDismiss:()=>Ar(null)}),cr&&t.jsx(Ju,{onExportAnyway:dr,onSaveAndExport:tt,onCancel:Xt}),t.jsx(Ru,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Se,columnVisibility:r.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:r.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:r.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:r.grouping,onSort:x,onSortAscending:E,onSortDescending:S,onOpenFilters:()=>f(!0),onOpenSort:()=>z(!0),onOpenFilterForColumn:C,onSelectView:N,onCreateView:()=>q(!0),onUpdateCurrentView:oe,onSaveAsNewView:G,onDiscardChanges:te,onToggleDefault:ge,onToggleFavorite:V,onRestoreView:ce,onPermanentDelete:de,onEditView:ne,onCloneView:Q,onCopyLink:pe,onDeleteView:K,onPromoteToGlobal:xe,isAdmin:((zr=mr.views)==null?void 0:zr.isAdmin)??!1,onExport:uo,onOpenColumns:()=>Te(!0),onUpdateColumnWidth:Et,onUpdateColumnOrder:Pe,onUpdateColumnVisibility:Y,onClearFiltersForColumn:b,onResetLayout:mt,onOpenGroup:()=>Pt(!0),onGroupByColumn:(st=se==null?void 0:se.hideToolbarActions)!=null&&st.includes("grouping")?void 0:fe=>{it({enabled:!0,levels:[{column:fe}],collapsedGroups:[]})},onToggleGroupCollapse:Yt,onExpandAllGroups:Ke,onCollapseAllGroups:Dt,onOpenAuditHistory:()=>Be(!0),onOpenScheduledReports:()=>hr(!0),searchQuery:Sr,highlightQuery:vt,searchHistory:qt,onAddToSearchHistory:ar,onToggleSearchFavourite:lo,onDeleteSearchHistory:_t,selectedRowIds:Cr,onSearchChange:ao,onToggleRowSelection:Xe,onToggleAllRows:Nt,onRangeSelection:Jt,onClearSelection:Ze,onExportSelected:Mr,currentPage:Lt,pageSize:co,onPageChange:wr,onPageSizeChange:He,totalRowsBeforePagination:Or,isReadOnly:Wr,userRole:kr,reportName:r.name,onEditRow:Pr,onDeleteRow:po,onDuplicateRow:Nr,rowActions:se==null?void 0:se.rowActions,hideDefaultRowActions:se==null?void 0:se.hideDefaultRowActions,hideToolbarActions:se==null?void 0:se.hideToolbarActions,customSettingsActions:se==null?void 0:se.customSettingsActions,jsonGuideContent:se==null?void 0:se.jsonGuideContent,viewOptions:se==null?void 0:se.viewOptions,defaultViewMode:se==null?void 0:se.defaultViewMode,bulkActions:se==null?void 0:se.bulkActions,hideSelectionCheckboxes:se==null?void 0:se.hideSelectionCheckboxes,rowClickBehavior:se==null?void 0:se.rowClickBehavior,openModalOn:se==null?void 0:se.openModalOn,onRowClick:se==null?void 0:se.onRowClick,onRowRightClick:se==null?void 0:se.onRowRightClick,showDevPanel:mr.display.showDevPanel,onOpenDevConfig:()=>Mt(!0)})]}),g&&t.jsx(Ko,{feature:"Filters",onError:fe=>{const je=gr("ui","filters",fe);ze(je)},children:t.jsx(Fu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:B,focusColumn:m,onOpenDevConfig:()=>Mt(!0)})}),y&&t.jsx(Ko,{feature:"Sorting",onError:fe=>{const je=gr("ui","sorting",fe);ze(je)},children:t.jsx(Hu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:j,onClose:()=>z(!1),onOpenDevConfig:()=>Mt(!0)})}),R&&u&&(()=>{var We;const fe=(r.views??[]).filter(qe=>!qe.isDeleted).length,je=((We=mr.views)==null?void 0:We.maxViews)??10;return t.jsx(ms,{currentSnapshot:u,onSave:d,onClose:()=>q(!1),atViewLimit:fe>=je,maxViews:je})})(),T&&h&&t.jsx(ms,{currentSnapshot:h.snapshot,onSave:D,onClose:()=>{F(!1)},isEditMode:!0,initialName:h.name,initialDescription:h.description,initialIsDefault:h.isDefault}),X&&I&&t.jsx(Gu,{viewName:I.name,onConfirm:ee,onCancel:()=>{W(!1)}}),ae&&c&&t.jsx(Yu,{schema:r.schema,columnVisibility:r.columnVisibility||c.snapshot.columnVisibility,columnOrder:r.columnOrder||c.snapshot.columnOrder,columnWidths:r.columnWidths||c.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:Y,onUpdateColumnOrder:Pe,onUpdateColumnWidth:Et,onResetLayout:mt,onClose:()=>Te(!1)}),$r&&t.jsx(Ko,{feature:"Grouping",onError:fe=>{const je=gr("ui","grouping",fe);ze(je)},children:t.jsx(qu,{schema:r.schema,grouping:r.grouping||null,onApply:it,onClose:()=>Pt(!1),onOpenDevConfig:()=>Mt(!0)})}),xt&&t.jsx(Qu,{auditHistory:r.auditHistory||[],onClose:()=>Be(!1)}),he&&t.jsx(Zu,{onSave:ie,onClose:()=>jr(!1)}),$t&&t.jsx(tp,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ot,onDeletePreset:Qt,onClose:()=>H(!1)}),St&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(ep,{presetName:St.name,onClear:ut})}),lr&&t.jsx(Ko,{feature:"Export",onError:fe=>{const je=gr("ui","export",fe);ze(je)},children:t.jsx(pp,{totalRows:(s==null?void 0:s.totalRows)||((er=r.uploadedData)==null?void 0:er.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Wt=a==null?void 0:a.columnEngine)==null?void 0:Wt.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:Ft,onClose:()=>{Kt(!1)}})}),r&&t.jsx(Ep,{open:Rr,onClose:()=>hr(!1),reportId:r.id,reportName:r.name,schedulerConfig:be,onRunNow:fe=>{var at;const je=(be==null?void 0:be.mode)??"local",We=fe.scope==="all"?r.uploadedData||[]:i||[],qe=Zo(We,r.schema||[],Fe(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(je==="api"){const Ct=(r.columnOrder||[]).filter(tr=>(r.columnVisibility??{})[tr]!==!1);(at=be==null?void 0:be.onScheduleFire)==null||at.call(be,{schedule:fe,triggeredAt:new Date().toISOString(),rows:We,columns:Ct,format:fe.format,reportName:r.name})}else fe.format==="csv"&&en(qe,fe.name),fe.format==="excel"&&tn(qe,fe.name),fe.format==="json"&&rn(qe,fe.name),fe.format==="pdf"&&hi(qe,fe.name);Z(`"${fe.name}" exported successfully`,"success")}}),t.jsx(bp,{open:Fr,onClose:()=>Mt(!1),config:mr,onApply:Lr})]})}const $p={error:"err",warning:"warn",info:"info",success:"suc"};function aa({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var j,E,S,R;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",u=(c==null?void 0:c.notifStyle)??"toast",g=(c==null?void 0:c.notifAccent)??"severity",f=(c==null?void 0:c.notifAutoDismiss)??!0,m=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",C=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",B=$p[n],b=((j=c==null?void 0:c.status)==null?void 0:j[`${B}Soft`])??a.palette[n].light,y=((E=c==null?void 0:c.status)==null?void 0:E[`${B}Txt`])??a.palette[n].dark,z=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:y,x=u==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:b;return t.jsx(o.Snackbar,{open:e,autoHideDuration:f?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(q,T)=>{T!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:C},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((S=c==null?void 0:c.status)==null?void 0:S[`${B}Soft`])??a.palette[n].light,color:((R=c==null?void 0:c.status)==null?void 0:R[`${B}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[f&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:$(z,.14),color:z,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${c.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(O.Close,{sx:{fontSize:16}})})]}),sx:{width:m,alignItems:"flex-start",bgcolor:x,color:y,boxShadow:u==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${z}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:z}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function la({hasExternalData:e=!1}){const r=dn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:g,createReport:f,handleFileUpload:m,handleUploadError:v,handleRetry:C,handleConfirm:B,snack:b,handleSnackClose:y,snackDurationMs:z,config:x}=r,j=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Fl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:g}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:j?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(qs,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(sa,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(tu,{schema:s.schema,onConfirm:B,hasConflicts:c}):s.uploadError?t.jsx(ru,{error:s.uploadError,onRetry:C}):t.jsx(eu,{onFileUpload:m,onError:v,isUploading:a==="uploading",jsonGuideContent:x==null?void 0:x.jsonGuideContent})})}):null}),!e&&t.jsx(Zd,{isOpen:l,onClose:()=>u(!1),onCreate:f}),t.jsx(aa,{open:b.open,message:b.message,severity:b.severity,onClose:y,autoHideDurationMs:z})]})}function Op({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(mi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(la,{hasExternalData:!!(e||r)})})}function ca(){const e=dn(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(sa,{reportEngine:e}):t.jsx(qs,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(aa,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Mp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(mi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ca,{})})}exports.URMBuilder=Op;exports.URMBuilderRaw=la;exports.URMProvider=mi;exports.URMViewer=Mp;exports.URMViewerRaw=ca;exports.useURMContext=dn;