react-semaphor 0.1.43 → 0.1.45

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.
@@ -704,7 +704,7 @@ Valid keys: `+JSON.stringify(Object.keys(I),null," "));var Q=ee(H,G,W,Y,Z+"."+G
704
704
  `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function Tue(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",s=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function H8(e,t,n,r,s,o){if(!e||e.length===0)return"";const i=[],a=[];if(n.forEach(l=>{a.push(l.label||l.name)}),r.forEach(l=>{l.isMetricColumn&&a.push(l.displayLabel||l.metricLabel||l.metricName||"")}),i.push(a.map(IS).join(",")),e.forEach(l=>{const c=[];if(l.isSubtotal&&!l.isGrandTotal){const d=l.subtotalLevel,f=n.findIndex(h=>h.alias===d);n.forEach((h,p)=>{var g,b,y,x;const m=h.alias||h.name;if(p===f){const v=l.aggregate||"SUM",w=(y=(b=(g=s==null?void 0:s.config)==null?void 0:g.rowAggregates)==null?void 0:b.find(S=>S.groupLevel===l.subtotalLevel&&S.function===v))==null?void 0:y.label;if(w)c.push(w);else{const N=(((x=l.subtotalContext)==null?void 0:x.groupByValues)||{})[m],k=v==="SUM"?"Total":v.charAt(0).toUpperCase()+v.slice(1).toLowerCase();N&&N!=="__TOTAL__"?c.push(`Subtotal (${N})`):c.push(`Subtotal ${k}`)}}else if(p<f){const v=l[m];c.push(v&&v!=="__TOTAL__"?String(v):"")}else c.push("")}),r.forEach(h=>{if(h.isMetricColumn){const p=l[h.alias],m=o==null?void 0:o[h.alias];c.push(RS(p,m))}})}else n.forEach(d=>{const f=d.alias||d.name,h=l[f];c.push(h?String(h):"")}),r.forEach(d=>{if(d.isMetricColumn){const f=l[d.alias],h=o==null?void 0:o[d.alias];c.push(RS(f,h))}});i.push(c.map(IS).join(","))}),t){const l=[];n.forEach((c,d)=>{var f,h;if(d===0){const p=(h=(f=s==null?void 0:s.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(m=>m.groupLevel==="ALL");if(p!=null&&p.label)l.push(p.label);else{const m=t.aggregate||"SUM",g=m==="SUM"?"Total":m.charAt(0).toUpperCase()+m.slice(1).toLowerCase();l.push(`Grand ${g}`)}}else l.push("")}),r.forEach(c=>{if(c.isMetricColumn){const d=t[c.alias],f=o==null?void 0:o[c.alias];l.push(RS(d,f))}}),i.push(l.map(IS).join(","))}return i.join(`
705
705
  `)}function RS(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const{numberFormat:n}=t;return n.style==="percent"?new Intl.NumberFormat(n.locale||"en-US",{style:"percent",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e/100):n.style==="currency"?new Intl.NumberFormat(n.locale||"en-US",{style:"currency",currency:n.currency||"USD",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e):new Intl.NumberFormat(n.locale||"en-US",{minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e)}return typeof e=="number"?e.toLocaleString():String(e)}function IS(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Qx(e,t){try{console.log("downloadCSV called with:",{contentLength:e.length,fileName:t,contentPreview:e.substring(0,100)});const n=new Blob([e],{type:"text/csv;charset=utf-8;"}),r=window.URL.createObjectURL(n);console.log("Blob URL created:",r);const s=document.createElement("a");s.href=r,s.download=t,s.download!==void 0?(document.body.appendChild(s),s.click(),document.body.removeChild(s),console.log("Download triggered via click")):(window.location.href=r,console.log("Download triggered via location.href")),setTimeout(()=>{window.URL.revokeObjectURL(r),console.log("Blob URL revoked")},100)}catch(n){console.error("Error in downloadCSV:",n);try{const r="data:text/csv;charset=utf-8,"+encodeURIComponent(e),s=document.createElement("a");s.href=r,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),console.log("Download triggered via data URI fallback")}catch(r){console.error("Fallback also failed:",r)}}}function g_(e,t){if(!e||e.length===0)return[];const n=e.filter(i=>!i.isSubtotal&&!i.isGrandTotal),r=e.filter(i=>i.isSubtotal&&!i.isGrandTotal);if(n.length===0)return e;const s=[],o=new Set;return n.forEach((i,a)=>{s.push(i);for(let l=t.length-1;l>=0;l--){let c=!1;if(a===n.length-1)c=!0;else{const d=n[a+1];for(let f=0;f<=l;f++){const h=t[f],p=h.alias||h.name;if(i[p]!==d[p]){c=!0;break}}}c&&Rue(i,r,t,l).forEach(f=>{const h=JSON.stringify({level:f.subtotalLevel,context:f.subtotalContext});o.has(h)||(s.push(f),o.add(h))})}}),s}function Rue(e,t,n,r){return t.filter(s=>{if(!s.subtotalContext)return!1;const o=s.subtotalContext.groupByValues||{};for(let i=0;i<=r;i++){const a=n[i],l=a.alias||a.name;if(o[l]!==e[l])return!1}if(r<n.length-1){const i=n[r+1],a=i.alias||i.name;if(o[a]!=="__TOTAL__")return!1}return!0})}function b_(e){return e.find(t=>t.isGrandTotal)}function U8(e,t,n,r){var a;if(r)return r;const o=(((a=e.subtotalContext)==null?void 0:a.groupByValues)||{})[t],i=n==="SUM"?"Total":n.charAt(0).toUpperCase()+n.slice(1).toLowerCase();return o&&o!=="__TOTAL__"?`Subtotal (${o})`:`Subtotal ${i}`}function W8(e,t){return t||`Grand ${e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}`}const q8=["table","aggregateTable","pivotTable"];function y_(e){return q8.includes(e)?["pdf","csv"]:["pdf","csv"]}function x_(e){return q8.includes(e)?"csv":"pdf"}function v_(e){const t=[],n=[];return e.rowData&&e.rowData.length>0?e.rowData.forEach((r,s)=>{const o=r.rowKey,i={};e.columnHeaders.forEach(a=>{var l,c;i[a]=((c=(l=e.cells)==null?void 0:l[o])==null?void 0:c[a])||{value:null}}),t.push({id:`row-${s}`,rowKey:o,fieldValues:r.fieldValues,isSubtotal:r.isSubtotal,subtotalLevel:r.subtotalLevel,aggregateFunction:r.aggregateFunction,cells:i})}):e.rowHeaders&&e.rowHeaders.forEach((r,s)=>{const o=r.split(" | "),i={};e.columnHeaders.forEach(a=>{var l,c;i[a]=((c=(l=e.cells)==null?void 0:l[r])==null?void 0:c[a])||{value:null}}),t.push({id:`row-${s}`,rowKey:r,fieldValues:o,cells:i})}),e.grandTotalRows&&e.grandTotalRows.length>0&&e.grandTotalRows.forEach((r,s)=>{const o={};e.columnHeaders.forEach(i=>{o[i]=r.data[i]||{value:null}}),n.push({id:`grand-total-${s}`,rowKey:`grand-total-${s}`,fieldValues:[r.aggregateDisplayLabel],isGrandTotal:!0,aggregateFunction:r.aggregateFunction,cells:o})}),{tableData:t,grandTotalRows:n}}function Iue(e){const t=new Set,n=new Set;return e?(e.forEach(r=>{r.subtotalLevel==="grandTotal"||r.subtotalLevel==="ALL"?n.add(r.columnName):r.subtotalLevel!=="grandTotal"&&r.subtotalLevel!=="ALL"&&t.add(r.columnName)}),{subtotalColumnKeys:t,grandTotalColumnKeys:n}):{subtotalColumnKeys:t,grandTotalColumnKeys:n}}function Y8(e,t){return t.reduce((n,r)=>{var o;const s=((o=e.cells[r])==null?void 0:o.value)||0;return n+(typeof s=="number"?s:0)},0)}function zt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Mo(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Jx(e,t){const n=zt(e);return isNaN(t)?Mo(e,NaN):(t&&n.setDate(n.getDate()+t),n)}function Em(e,t){const n=zt(e);if(isNaN(t))return Mo(e,NaN);if(!t)return n;const r=n.getDate(),s=Mo(e,n.getTime());s.setMonth(n.getMonth()+t+1,0);const o=s.getDate();return r>=o?s:(n.setFullYear(s.getFullYear(),s.getMonth(),r),n)}function Aue(e,t){const n=+zt(e);return Mo(e,n+t)}const G8=6048e5,Pue=864e5,Oue=36e5,ty=43200,AI=1440;function Ld(e,t){return Aue(e,t*Oue)}let Fue={};function td(){return Fue}function Ri(e,t){var a,l,c,d;const n=td(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,s=zt(e),o=s.getDay(),i=(o<r?7:0)+o-r;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function e0(e){return Ri(e,{weekStartsOn:1})}function Z8(e){const t=zt(e),n=t.getFullYear(),r=Mo(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=e0(r),o=Mo(e,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const i=e0(o);return t.getTime()>=s.getTime()?n+1:t.getTime()>=i.getTime()?n:n-1}function Ap(e){const t=zt(e);return t.setHours(0,0,0,0),t}function t0(e){const t=zt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function $ue(e,t){const n=Ap(e),r=Ap(t),s=+n-t0(n),o=+r-t0(r);return Math.round((s-o)/Pue)}function Lue(e){const t=Z8(e),n=Mo(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),e0(n)}function PN(e,t){const n=t*3;return Em(e,n)}function ON(e,t){const n=t*7;return Jx(e,n)}function FN(e,t){return Em(e,t*12)}function hx(e,t){const n=zt(e),r=zt(t),s=n.getTime()-r.getTime();return s<0?-1:s>0?1:s}function zue(e){return Mo(e,Date.now())}function Bue(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Vue(e){if(!Bue(e)&&typeof e!="number")return!1;const t=zt(e);return!isNaN(Number(t))}function Hue(e,t){const n=zt(e),r=zt(t),s=n.getFullYear()-r.getFullYear(),o=n.getMonth()-r.getMonth();return s*12+o}function Uue(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Wue(e,t){return+zt(e)-+zt(t)}function px(e){const t=zt(e);return t.setHours(23,59,59,999),t}function tf(e){const t=zt(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function que(e){const t=zt(e);return+px(t)==+tf(t)}function Yue(e,t){const n=zt(e),r=zt(t),s=hx(n,r),o=Math.abs(Hue(n,r));let i;if(o<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*o);let a=hx(n,r)===-s;que(zt(e))&&o===1&&hx(e,r)===1&&(a=!1),i=s*(o-Number(a))}return i===0?0:i}function Gue(e,t,n){const r=Wue(e,t)/1e3;return Uue(n==null?void 0:n.roundingMethod)(r)}function nf(e){const t=zt(e),n=t.getMonth(),r=n-n%3;return t.setMonth(r,1),t.setHours(0,0,0,0),t}function Pp(e){const t=zt(e);return t.setDate(1),t.setHours(0,0,0,0),t}function Op(e){const t=zt(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function rf(e){const t=zt(e),n=Mo(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Fp(e,t){var a,l,c,d;const n=td(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,s=zt(e),o=s.getDay(),i=(o<r?-7:0)+6-(o-r);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}function $p(e){const t=zt(e),n=t.getMonth(),r=n-n%3+3;return t.setMonth(r,0),t.setHours(23,59,59,999),t}const Zue={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Kue=(e,t,n)=>{let r;const s=Zue[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function AS(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Xue={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Que={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Jue={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ede={date:AS({formats:Xue,defaultWidth:"full"}),time:AS({formats:Que,defaultWidth:"full"}),dateTime:AS({formats:Jue,defaultWidth:"full"})},tde={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},nde=(e,t,n,r)=>tde[e];function Uh(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;s=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;s=e.values[a]||e.values[i]}const o=e.argumentCallback?e.argumentCallback(t):t;return s[o]}}const rde={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},sde={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ode={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ide={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ade={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},lde={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},cde=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},ude={ordinalNumber:cde,era:Uh({values:rde,defaultWidth:"wide"}),quarter:Uh({values:sde,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Uh({values:ode,defaultWidth:"wide"}),day:Uh({values:ide,defaultWidth:"wide"}),dayPeriod:Uh({values:ade,defaultWidth:"wide",formattingValues:lde,defaultFormattingWidth:"wide"})};function Wh(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(s);if(!o)return null;const i=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?fde(a,f=>f.test(i)):dde(a,f=>f.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const d=t.slice(i.length);return{value:c,rest:d}}}function dde(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function fde(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function hde(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],o=t.match(e.parsePattern);if(!o)return null;let i=e.valueCallback?e.valueCallback(o[0]):o[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(s.length);return{value:i,rest:a}}}const pde=/^(\d+)(th|st|nd|rd)?/i,mde=/\d+/i,gde={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bde={any:[/^b/i,/^(a|c)/i]},yde={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xde={any:[/1/i,/2/i,/3/i,/4/i]},vde={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},wde={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Sde={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Cde={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Nde={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},kde={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ede={ordinalNumber:hde({matchPattern:pde,parsePattern:mde,valueCallback:e=>parseInt(e,10)}),era:Wh({matchPatterns:gde,defaultMatchWidth:"wide",parsePatterns:bde,defaultParseWidth:"any"}),quarter:Wh({matchPatterns:yde,defaultMatchWidth:"wide",parsePatterns:xde,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Wh({matchPatterns:vde,defaultMatchWidth:"wide",parsePatterns:wde,defaultParseWidth:"any"}),day:Wh({matchPatterns:Sde,defaultMatchWidth:"wide",parsePatterns:Cde,defaultParseWidth:"any"}),dayPeriod:Wh({matchPatterns:Nde,defaultMatchWidth:"any",parsePatterns:kde,defaultParseWidth:"any"})},K8={code:"en-US",formatDistance:Kue,formatLong:ede,formatRelative:nde,localize:ude,match:Ede,options:{weekStartsOn:0,firstWeekContainsDate:1}};function jde(e){const t=zt(e);return $ue(t,rf(t))+1}function _de(e){const t=zt(e),n=+e0(t)-+Lue(t);return Math.round(n/G8)+1}function X8(e,t){var d,f,h,p;const n=zt(e),r=n.getFullYear(),s=td(),o=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((p=(h=s.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=Mo(e,0);i.setFullYear(r+1,0,o),i.setHours(0,0,0,0);const a=Ri(i,t),l=Mo(e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const c=Ri(l,t);return n.getTime()>=a.getTime()?r+1:n.getTime()>=c.getTime()?r:r-1}function Dde(e,t){var a,l,c,d;const n=td(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??1,s=X8(e,t),o=Mo(e,0);return o.setFullYear(s,0,r),o.setHours(0,0,0,0),Ri(o,t)}function Mde(e,t){const n=zt(e),r=+Ri(n,t)-+Dde(n,t);return Math.round(r/G8)+1}function on(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const ol={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return on(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):on(n+1,2)},d(e,t){return on(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return on(e.getHours()%12||12,t.length)},H(e,t){return on(e.getHours(),t.length)},m(e,t){return on(e.getMinutes(),t.length)},s(e,t){return on(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return on(s,t.length)}},bd={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},PI={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return ol.y(e,t)},Y:function(e,t,n,r){const s=X8(e,r),o=s>0?s:1-s;if(t==="YY"){const i=o%100;return on(i,2)}return t==="Yo"?n.ordinalNumber(o,{unit:"year"}):on(o,t.length)},R:function(e,t){const n=Z8(e);return on(n,t.length)},u:function(e,t){const n=e.getFullYear();return on(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return on(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return on(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return ol.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return on(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=Mde(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):on(s,t.length)},I:function(e,t,n){const r=_de(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):on(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):ol.d(e,t)},D:function(e,t,n){const r=jde(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):on(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return on(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return on(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return on(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=bd.noon:r===0?s=bd.midnight:s=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=bd.evening:r>=12?s=bd.afternoon:r>=4?s=bd.morning:s=bd.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ol.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):ol.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):on(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):on(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):ol.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):ol.s(e,t)},S:function(e,t){return ol.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return FI(r);case"XXXX":case"XX":return jc(r);case"XXXXX":case"XXX":default:return jc(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return FI(r);case"xxxx":case"xx":return jc(r);case"xxxxx":case"xxx":default:return jc(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+OI(r,":");case"OOOO":default:return"GMT"+jc(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+OI(r,":");case"zzzz":default:return"GMT"+jc(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return on(r,t.length)},T:function(e,t,n){const r=e.getTime();return on(r,t.length)}};function OI(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),o=r%60;return o===0?n+String(s):n+String(s)+t+on(o,2)}function FI(e,t){return e%60===0?(e>0?"-":"+")+on(Math.abs(e)/60,2):jc(e,t)}function jc(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=on(Math.trunc(r/60),2),o=on(r%60,2);return n+s+t+o}const $I=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Q8=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Tde=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return $I(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",$I(r,t)).replace("{{time}}",Q8(s,t))},Rde={p:Q8,P:Tde},Ide=/^D+$/,Ade=/^Y+$/,Pde=["D","DD","YY","YYYY"];function Ode(e){return Ide.test(e)}function Fde(e){return Ade.test(e)}function $de(e,t,n){const r=Lde(e,t,n);if(console.warn(r),Pde.includes(e))throw new RangeError(r)}function Lde(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const zde=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Bde=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vde=/^'([^]*?)'?$/,Hde=/''/g,Ude=/[a-zA-Z]/;function Yo(e,t,n){var d,f,h,p,m,g,b,y;const r=td(),s=(n==null?void 0:n.locale)??r.locale??K8,o=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(h=r.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??r.weekStartsOn??((y=(b=r.locale)==null?void 0:b.options)==null?void 0:y.weekStartsOn)??0,a=zt(e);if(!Vue(a))throw new RangeError("Invalid time value");let l=t.match(Bde).map(x=>{const v=x[0];if(v==="p"||v==="P"){const w=Rde[v];return w(x,s.formatLong)}return x}).join("").match(zde).map(x=>{if(x==="''")return{isToken:!1,value:"'"};const v=x[0];if(v==="'")return{isToken:!1,value:Wde(x)};if(PI[v])return{isToken:!0,value:x};if(v.match(Ude))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:x}});s.localize.preprocessor&&(l=s.localize.preprocessor(a,l));const c={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return l.map(x=>{if(!x.isToken)return x.value;const v=x.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Fde(v)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Ode(v))&&$de(v,t,String(e));const w=PI[v[0]];return w(a,v,s.localize,c)}).join("")}function Wde(e){const t=e.match(Vde);return t?t[1].replace(Hde,"'"):e}function qde(e,t,n){const r=td(),s=(n==null?void 0:n.locale)??r.locale??K8,o=2520,i=hx(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,c;i>0?(l=zt(t),c=zt(e)):(l=zt(e),c=zt(t));const d=Gue(c,l),f=(t0(c)-t0(l))/1e3,h=Math.round((d-f)/60);let p;if(h<2)return n!=null&&n.includeSeconds?d<5?s.formatDistance("lessThanXSeconds",5,a):d<10?s.formatDistance("lessThanXSeconds",10,a):d<20?s.formatDistance("lessThanXSeconds",20,a):d<40?s.formatDistance("halfAMinute",0,a):d<60?s.formatDistance("lessThanXMinutes",1,a):s.formatDistance("xMinutes",1,a):h===0?s.formatDistance("lessThanXMinutes",1,a):s.formatDistance("xMinutes",h,a);if(h<45)return s.formatDistance("xMinutes",h,a);if(h<90)return s.formatDistance("aboutXHours",1,a);if(h<AI){const m=Math.round(h/60);return s.formatDistance("aboutXHours",m,a)}else{if(h<o)return s.formatDistance("xDays",1,a);if(h<ty){const m=Math.round(h/AI);return s.formatDistance("xDays",m,a)}else if(h<ty*2)return p=Math.round(h/ty),s.formatDistance("aboutXMonths",p,a)}if(p=Yue(c,l),p<12){const m=Math.round(h/ty);return s.formatDistance("xMonths",m,a)}else{const m=p%12,g=Math.trunc(p/12);return m<3?s.formatDistance("aboutXYears",g,a):m<9?s.formatDistance("overXYears",g,a):s.formatDistance("almostXYears",g+1,a)}}function Yde(e,t){return qde(e,zue(e),t)}function Gde(){return Object.assign({},td())}function Ac(e,t){return Jx(e,-t)}function Lp(e,t){return Em(e,-t)}function zp(e,t){return PN(e,-t)}function LI(e,t){return ON(e,-t)}function n0(e,t){return FN(e,-t)}function zI(e,t,n){const r=Gde(),s=Xde(e,n.timeZone,n.locale??r.locale);return"formatToParts"in s?Zde(s,t):Kde(s,t)}function Zde(e,t){const n=e.formatToParts(t);for(let r=n.length-1;r>=0;--r)if(n[r].type==="timeZoneName")return n[r].value}function Kde(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(n);return r?r[0].substr(1):""}function Xde(e,t,n){return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}function Qde(e,t){const n=rfe(t);return"formatToParts"in n?efe(n,e):tfe(n,e)}const Jde={year:0,month:1,day:2,hour:3,minute:4,second:5};function efe(e,t){try{const n=e.formatToParts(t),r=[];for(let s=0;s<n.length;s++){const o=Jde[n[s].type];o!==void 0&&(r[o]=parseInt(n[s].value,10))}return r}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function tfe(e,t){const n=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)]}const PS={},BI=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),nfe=BI==="06/25/2014, 00:00:00"||BI==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";function rfe(e){return PS[e]||(PS[e]=nfe?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),PS[e]}function J8(e,t,n,r,s,o,i){const a=new Date(0);return a.setUTCFullYear(e,t,n),a.setUTCHours(r,s,o,i),a}const VI=36e5,sfe=6e4,OS={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function w_(e,t,n){if(!e)return 0;let r=OS.timezoneZ.exec(e);if(r)return 0;let s,o;if(r=OS.timezoneHH.exec(e),r)return s=parseInt(r[1],10),HI(s)?-(s*VI):NaN;if(r=OS.timezoneHHMM.exec(e),r){s=parseInt(r[2],10);const i=parseInt(r[3],10);return HI(s,i)?(o=Math.abs(s)*VI+i*sfe,r[1]==="+"?-o:o):NaN}if(afe(e)){t=new Date(t||Date.now());const i=n?t:ofe(t),a=$N(i,e);return-(n?a:ife(t,a,e))}return NaN}function ofe(e){return J8(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function $N(e,t){const n=Qde(e,t),r=J8(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime();let s=e.getTime();const o=s%1e3;return s-=o>=0?o:1e3+o,r-s}function ife(e,t,n){let s=e.getTime()-t;const o=$N(new Date(s),n);if(t===o)return t;s-=o-t;const i=$N(new Date(s),n);return o===i?o:Math.max(o,i)}function HI(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}const UI={};function afe(e){if(UI[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),UI[e]=!0,!0}catch{return!1}}const lfe=60*1e3,cfe={X:function(e,t,n){const r=FS(n.timeZone,e);if(r===0)return"Z";switch(t){case"X":return WI(r);case"XXXX":case"XX":return Md(r);case"XXXXX":case"XXX":default:return Md(r,":")}},x:function(e,t,n){const r=FS(n.timeZone,e);switch(t){case"x":return WI(r);case"xxxx":case"xx":return Md(r);case"xxxxx":case"xxx":default:return Md(r,":")}},O:function(e,t,n){const r=FS(n.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+ufe(r,":");case"OOOO":default:return"GMT"+Md(r,":")}},z:function(e,t,n){switch(t){case"z":case"zz":case"zzz":return zI("short",e,n);case"zzzz":default:return zI("long",e,n)}}};function FS(e,t){const n=e?w_(e,t,!0)/lfe:(t==null?void 0:t.getTimezoneOffset())??0;if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n}function r0(e,t){const n=e<0?"-":"";let r=Math.abs(e).toString();for(;r.length<t;)r="0"+r;return n+r}function Md(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=r0(Math.floor(r/60),2),o=r0(Math.floor(r%60),2);return n+s+t+o}function WI(e,t){return e%60===0?(e>0?"-":"+")+r0(Math.abs(e)/60,2):Md(e,t)}function ufe(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.floor(r/60),o=r%60;return o===0?n+String(s):n+String(s)+t+r0(o,2)}function qI(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const dfe=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,$S=36e5,YI=6e4,ffe=2,is={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:dfe};function e9(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);const n=t.additionalDigits==null?ffe:Number(t.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(Object.prototype.toString.call(e)!=="[object String]")return new Date(NaN);const r=hfe(e),{year:s,restDateString:o}=pfe(r.date,n),i=mfe(o,s);if(i===null||isNaN(i.getTime()))return new Date(NaN);if(i){const a=i.getTime();let l=0,c;if(r.time&&(l=gfe(r.time),l===null||isNaN(l)))return new Date(NaN);if(r.timeZone||t.timeZone){if(c=w_(r.timeZone||t.timeZone,new Date(a+l)),isNaN(c))return new Date(NaN)}else c=qI(new Date(a+l)),c=qI(new Date(a+l+c));return new Date(a+l+c)}else return new Date(NaN)}function hfe(e){const t={};let n=is.dateTimePattern.exec(e),r;if(n?(t.date=n[1],r=n[3]):(n=is.datePattern.exec(e),n?(t.date=n[1],r=n[2]):(t.date=null,r=e)),r){const s=is.timeZone.exec(r);s?(t.time=r.replace(s[1],""),t.timeZone=s[1].trim()):t.time=r}return t}function pfe(e,t){if(e){const n=is.YYY[t],r=is.YYYYY[t];let s=is.YYYY.exec(e)||r.exec(e);if(s){const o=s[1];return{year:parseInt(o,10),restDateString:e.slice(o.length)}}if(s=is.YY.exec(e)||n.exec(e),s){const o=s[1];return{year:parseInt(o,10)*100,restDateString:e.slice(o.length)}}}return{year:null}}function mfe(e,t){if(t===null)return null;let n,r,s;if(!e||!e.length)return n=new Date(0),n.setUTCFullYear(t),n;let o=is.MM.exec(e);if(o)return n=new Date(0),r=parseInt(o[1],10)-1,ZI(t,r)?(n.setUTCFullYear(t,r),n):new Date(NaN);if(o=is.DDD.exec(e),o){n=new Date(0);const i=parseInt(o[1],10);return xfe(t,i)?(n.setUTCFullYear(t,0,i),n):new Date(NaN)}if(o=is.MMDD.exec(e),o){n=new Date(0),r=parseInt(o[1],10)-1;const i=parseInt(o[2],10);return ZI(t,r,i)?(n.setUTCFullYear(t,r,i),n):new Date(NaN)}if(o=is.Www.exec(e),o)return s=parseInt(o[1],10)-1,KI(s)?GI(t,s):new Date(NaN);if(o=is.WwwD.exec(e),o){s=parseInt(o[1],10)-1;const i=parseInt(o[2],10)-1;return KI(s,i)?GI(t,s,i):new Date(NaN)}return null}function gfe(e){let t,n,r=is.HH.exec(e);if(r)return t=parseFloat(r[1].replace(",",".")),LS(t)?t%24*$S:NaN;if(r=is.HHMM.exec(e),r)return t=parseInt(r[1],10),n=parseFloat(r[2].replace(",",".")),LS(t,n)?t%24*$S+n*YI:NaN;if(r=is.HHMMSS.exec(e),r){t=parseInt(r[1],10),n=parseInt(r[2],10);const s=parseFloat(r[3].replace(",","."));return LS(t,n,s)?t%24*$S+n*YI+s*1e3:NaN}return null}function GI(e,t,n){t=t||0,n=n||0;const r=new Date(0);r.setUTCFullYear(e,0,4);const s=r.getUTCDay()||7,o=t*7+n+1-s;return r.setUTCDate(r.getUTCDate()+o),r}const bfe=[31,28,31,30,31,30,31,31,30,31,30,31],yfe=[31,29,31,30,31,30,31,31,30,31,30,31];function t9(e){return e%400===0||e%4===0&&e%100!==0}function ZI(e,t,n){if(t<0||t>11)return!1;if(n!=null){if(n<1)return!1;const r=t9(e);if(r&&n>yfe[t]||!r&&n>bfe[t])return!1}return!0}function xfe(e,t){if(t<1)return!1;const n=t9(e);return!(n&&t>366||!n&&t>365)}function KI(e,t){return!(e<0||e>52||t!=null&&(t<0||t>6))}function LS(e,t,n){return!(e<0||e>=25||t!=null&&(t<0||t>=60)||n!=null&&(n<0||n>=60))}const vfe=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function wfe(e,t,n={}){t=String(t);const r=t.match(vfe);if(r){const s=e9(n.originalDate||e,n);t=r.reduce(function(o,i){if(i[0]==="'")return o;const a=o.indexOf(i),l=o[a-1]==="'",c=o.replace(i,"'"+cfe[i[0]](s,i,n)+"'");return l?c.substring(0,a-1)+c.substring(a+1):c},t)}return Yo(e,t,n)}function n9(e,t,n){e=e9(e,n);const r=w_(t,e,!0),s=new Date(e.getTime()-r),o=new Date(0);return o.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),o.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),o}function LN(e,t,n,r){return r={...r,timeZone:t,originalDate:e},wfe(n9(e,t,{timeZone:r.timeZone}),n,r)}const S_=e=>{e=e.replace("#","");const t=Number.parseInt(e.substr(0,2),16),n=Number.parseInt(e.substr(2,2),16),r=Number.parseInt(e.substr(4,2),16);return(.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"},No=()=>({type:"none",textAlign:"left",width:150,minWidth:50,maxWidth:500,textOverflow:"ellipsis",textWrap:"nowrap",numberFormat:{style:"decimal",currency:"USD",locale:"en-US",minimumFractionDigits:0,maximumFractionDigits:2,showDataBar:!1,dataBarColor:"#3b82f6",dataBarMinValue:void 0,dataBarMaxValue:void 0},dateFormat:{format:"MM/dd/yyyy",useCustomFormat:!1,customFormat:"yyyy-MM-dd'T'HH:mm:ss",useRelativeTime:!1,timezone:"auto",sourceTimezone:"auto"},colorRanges:[]}),XI=()=>({min:0,max:100,color:"#ef4444",applyTo:"cell"}),Sfe=["#3b82f6","#22c55e","#ef4444","#eab308","#8b5cf6","#ec4899","#f97316","#6b7280","#000000","#ffffff"],Cfe=(e,t="auto")=>{const n=e.endsWith("Z"),r=/[+-]\d{2}:?\d{2}$/.test(e),s=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||r||s?new Date(e):new Date(e+"Z");if(t==="local"){if(n||r){const o=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(o)}return new Date(e)}else return t==="UTC"?n?new Date(e):r?new Date(e):new Date(e+"Z"):n||r?new Date(e):new Date(e+"Z")},zg=(e,t,n,r="auto")=>{try{const s=Cfe(e,r);if(isNaN(s.getTime()))return e;const o=t.replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?LN(s,n,o):Yo(s,o)}catch(s){return console.error("Date formatting error:",s),e}},dw=e=>{try{const t=new Date(e);return isNaN(t.getTime())?e:Yde(t,{addSuffix:!0})}catch(t){return console.error("Relative time formatting error:",t),e}},zd=(e,t)=>{try{if(!e||e==="auto")return"";const n=t||new Date,o=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"short"}).formatToParts(n).find(i=>i.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}},s0=e=>!e||e==="auto"?"local time":{"America/New_York":"Eastern Time","America/Chicago":"Central Time","America/Denver":"Mountain Time","America/Los_Angeles":"Pacific Time","Europe/London":"London Time","Europe/Paris":"Central European Time","Asia/Tokyo":"Japan Time","Asia/Shanghai":"China Time",UTC:"UTC"}[e]||e;function Na(e,t,n,r){if(!t)return QI(e);switch(typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0&&(e=e.formattedValue),t.type){case"number":return Nfe(e,t);case"date":return kfe(e,t,n,r);case"text":default:return QI(e)}}function Nfe(e,t){if(typeof e!="number"||e===null||e===void 0)return"-";try{return new Intl.NumberFormat(t.numberFormat.locale,{style:t.numberFormat.style,currency:t.numberFormat.style==="currency"?t.numberFormat.currency:void 0,minimumFractionDigits:t.numberFormat.minimumFractionDigits,maximumFractionDigits:t.numberFormat.maximumFractionDigits}).format(e)}catch{return e.toLocaleString()}}function kfe(e,t,n,r){if(!e)return"-";try{if(t.dateFormat.useRelativeTime)return dw(String(e));let s;t.dateFormat.timezone==="auto"||!t.dateFormat.timezone?s=n||r||"UTC":s=t.dateFormat.timezone;const o=t.dateFormat.useCustomFormat?t.dateFormat.customFormat:t.dateFormat.format;return zg(String(e),o,s,t.dateFormat.sourceTimezone||"auto")}catch{return String(e)}}function QI(e){return e==null?"-":typeof e=="number"?e===0?"-":e.toLocaleString():String(e)}function Efe(e,t){if(!t||t.type!=="number"||typeof e!="number"||!t.colorRanges||t.colorRanges.length===0)return null;const n=t.colorRanges.find(r=>e>=r.min&&e<=r.max);return!n||n.applyTo!=="cell"?null:{backgroundColor:n.color,color:jfe(n.color)}}function jfe(e){e=e.replace("#","");const t=parseInt(e.substr(0,2),16),n=parseInt(e.substr(2,2),16),r=parseInt(e.substr(4,2),16);return(.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"}function r9(e,t,n,r){const s=(r==null?void 0:r.delimiter)||",",o=(r==null?void 0:r.includeHeaders)!==!1,i=(r==null?void 0:r.includeSubtotals)!==!1,a=(r==null?void 0:r.includeGrandTotal)!==!1,l=[];if(o){const p=_fe(e,t,s,r==null?void 0:r.showRowTotals);l.push(...p)}const{tableData:c,grandTotalRows:d}=v_(e),f=Dfe(c,e,t,i,s,r==null?void 0:r.showRowTotals);if(l.push(...f),a&&d.length>0){const p=Mfe(d,e,t,s,r==null?void 0:r.showRowTotals);l.push(...p)}const h=l.join(`
706
706
  `);Tfe(h,n)}function _fe(e,t,n,r){var d,f;const s=[],i=(((d=t.config)==null?void 0:d.pivotByColumns)||[]).length,a=((f=e.groupByColumns)==null?void 0:f.length)||0;if(!e.columnGroups||e.columnGroups.length===0||i===0){const h=[];return e.groupByColumns&&e.groupByColumns.forEach(p=>{h.push(p.label||p.name)}),e.columnHeaders.forEach(p=>{var g;const m=((g=e.columnDisplayNames)==null?void 0:g[p])||p;h.push(m)}),[h.map(p=>o0(p,n)).join(n)]}for(let h=0;h<=i;h++)s.push([]);if(a>0&&e.groupByColumns){e.groupByColumns.forEach(h=>{const p=h.label||h.name;s[i].push(p)});for(let h=0;h<i;h++)for(let p=0;p<a;p++)s[h].push("")}const l=Array.from({length:i},()=>[]);e.columnGroups&&e.columnGroups.length>0&&s9(e.columnGroups,l,i);for(let h=0;h<i;h++)s[h].push(...l[h]);const c=[];if(e.columnGroups&&e.columnGroups.length>0?o9(e.columnGroups,c,e.columnDisplayNames||{}):e.columnHeaders.forEach(h=>{var m;const p=((m=e.columnDisplayNames)==null?void 0:m[h])||h;c.push(p)}),s[i].push(...c),r){s[i].push("Total");for(let h=0;h<i;h++)s[h].push("")}return s.map(h=>h.map(p=>o0(p,n)).join(n))}function s9(e,t,n){e.forEach(r=>{const s=r.level;if(s<n){t[s].push(r.name);for(let o=1;o<r.colspan;o++)t[s].push("");r.children&&s9(r.children,t,n)}})}function o9(e,t,n){e.forEach(r=>{if(r.columnKey){const s=n[r.columnKey]||r.name||"Metric";t.push(s)}else r.children&&o9(r.children,t,n)})}function Dfe(e,t,n,r,s,o){var l,c;const i=[],a=((c=(l=n.preferences)==null?void 0:l.tablePrefs)==null?void 0:c.columnSettingsMap)||{};return e.forEach(d=>{if(!r&&d.isSubtotal)return;const f=[];if(d.fieldValues.forEach((p,m)=>{d.isSubtotal&&m===0?f.push(`${p} Total`):d.isSubtotal?f.push(""):f.push(p||"")}),t.columnHeaders.forEach(p=>{const m=d.cells[p],g=m==null?void 0:m.value,b=a[p],y=Na(g,b,void 0,typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0);f.push(String(y))}),o){let p=0;t.columnHeaders.forEach(g=>{var y;const b=(y=d.cells[g])==null?void 0:y.value;typeof b=="number"&&(p+=b)});const m=Na(p,void 0,void 0,typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0);f.push(String(m))}const h=f.map(p=>o0(p,s)).join(s);i.push(h)}),i}function Mfe(e,t,n,r,s){var l,c,d;const o=[],i=((c=(l=n.preferences)==null?void 0:l.tablePrefs)==null?void 0:c.columnSettingsMap)||{},a=((d=t.groupByColumns)==null?void 0:d.length)||1;return e.forEach(f=>{const h=[];h.push(f.fieldValues[0]||"Total");for(let m=1;m<a;m++)h.push("");if(t.columnHeaders.forEach(m=>{const g=f.cells[m],b=g==null?void 0:g.value,y=i[m],x=Na(b,y,void 0,typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0);h.push(String(x))}),s){let m=0;t.columnHeaders.forEach(b=>{var x;const y=(x=f.cells[b])==null?void 0:x.value;typeof y=="number"&&(m+=y)});const g=Na(m,void 0,void 0,typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0);h.push(String(g))}const p=h.map(m=>o0(m,r)).join(r);o.push(p)}),o}function o0(e,t){const n=String(e||"");return n.includes(t)||n.includes('"')||n.includes(`
707
- `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function Tfe(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",s=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function cu(e,t="auto",n={}){switch(t==="auto"&&(t=Pfe(e,n)),t){case"number":return fw(e,n);case"currency":return i9(e,n);case"percent":return Rfe(e,n);case"date":return Ife(e,n);case"scientific":return Afe(e,n);default:return String(e)}}function fw(e,t={}){const{decimalPlaces:n=0,useSuffix:r=!1,prefix:s="",suffix:o="",locale:i="en-US",negativeInParentheses:a=!1}=t,l=e<0,c=Math.abs(e);let d=1,f="";if(r&&!o){const b=a9(c,i);d=b.divisor,f=b.suffix}const h=c/d;let p=i;try{new Intl.NumberFormat(i).format(0)}catch{p="en-US"}let g=new Intl.NumberFormat(p,{minimumFractionDigits:n,maximumFractionDigits:n}).format(h);return f&&(g+=f),o&&(g+=o),s&&(g=s+g),l&&(g=a?`(${g})`:`-${g}`),g}function i9(e,t={}){const{currency:n="USD",decimalPlaces:r=2,locale:s="en-US",useSuffix:o=!1,negativeInParentheses:i=!1}=t,a=e<0,l=Math.abs(e);let c=1,d="";if(o){const p=a9(l,s);c=p.divisor,d=p.suffix}const f=l/c;let h=s;try{new Intl.NumberFormat(s,{style:"currency",currency:n}).format(0)}catch{h="en-US"}try{let m=new Intl.NumberFormat(h,{style:"currency",currency:n,minimumFractionDigits:r,maximumFractionDigits:r}).format(f);return d&&(m+=d),a&&!m.includes("-")&&(m=i?`(${m})`:`-${m}`),m}catch{return`${n} ${fw(e,{...t,prefix:""})}`}}function Rfe(e,t={}){const{decimalPlaces:n=1,multiplyBy:r=100}=t,s=e*r;return fw(s,{...t,decimalPlaces:n,suffix:"%",useSuffix:!1})}function Ife(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function Afe(e,t={}){const{decimalPlaces:n=2}=t;try{const r=Number(e);return isNaN(r)?String(e):r.toExponential(n)}catch{return String(e)}}function a9(e,t){return e>=1e9?{suffix:"B",divisor:1e9}:e>=1e7&&t==="en-IN"?{suffix:"Cr",divisor:1e7}:e>=1e6?{suffix:"M",divisor:1e6}:e>=1e5&&t==="en-IN"?{suffix:"L",divisor:1e5}:e>=1e3?{suffix:"K",divisor:1e3}:{suffix:"",divisor:1}}function Pfe(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function Ofe(e,t={}){return n=>cu(n,e,t)}function zN({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:s="",locale:o="en-US"}){return s?i9(e,{currency:s,decimalPlaces:t,locale:o,useSuffix:n}):fw(e,{decimalPlaces:t,useSuffix:n,suffix:r,locale:o})}function hw(e){try{const n=new Function("getDatalabelColor",e)(A2);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Ffe(e){var t,n,r,s,o,i,a,l,c,d,f,h,p,m,g,b,y,x;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((i=(o=(s=e==null?void 0:e.scales)==null?void 0:s.y)==null?void 0:o.grid)==null?void 0:i.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(f=(d=e.scales)==null?void 0:d.y)==null?void 0:f.grid)!=null&&h.display?"y":((g=(m=(p=e.scales)==null?void 0:p.x)==null?void 0:m.grid)==null?void 0:g.display)===!1&&((x=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:x.display)===!1?"none":"xy"}function $fe(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return l9(t)}function l9(e){const[t,n,r]=e.split(" "),s=parseFloat(t),o=parseFloat(n),i=parseFloat(r),a=o/100,l=i/100,c=(1-Math.abs(2*l-1))*a,d=c*(1-Math.abs(s/60%2-1)),f=l-c/2;let h=0,p=0,m=0;0<=s&&s<60?(h=c,p=d,m=0):60<=s&&s<120?(h=d,p=c,m=0):120<=s&&s<180?(h=0,p=c,m=d):180<=s&&s<240?(h=0,p=d,m=c):240<=s&&s<300?(h=d,p=0,m=c):300<=s&&s<360&&(h=c,p=0,m=d),h=Math.round((h+f)*255),p=Math.round((p+f)*255),m=Math.round((m+f)*255);const g=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${g(h)}${g(p)}${g(m)}`}function Lfe(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([s])=>!t.some(o=>o.label===s))))}class Bg{formatAxis(t,n){var s;if(!t)return{};const r={display:t.enabled!==!1};return t.position&&t.position!=="auto"&&(r.position=t.position),t.name&&(r.title={display:t.name.enabled,text:t.name.text||""}),t.labels&&(r.ticks={display:t.labels.enabled!==!1},t.labels.rotation!==void 0&&t.labels.rotation!=="auto"&&(r.ticks.autoSkip=!1,r.ticks.maxRotation=t.labels.rotation,r.ticks.minRotation=t.labels.rotation)),n==="value"&&((s=t.formatOptions)!=null&&s.type)&&t.formatOptions.type!=="auto"&&(r.ticks||(r.ticks={}),r.ticks.callback=this.getFormatter(t.formatOptions.type,t.formatOptions)),n==="value"&&t.scale&&(t.scale.min!=="auto"&&t.scale.min!==void 0&&(r.min=t.scale.min),t.scale.max!=="auto"&&t.scale.max!==void 0&&(r.max=t.scale.max),t.scale.stepSize!=="auto"&&t.scale.stepSize!==void 0&&(r.ticks||(r.ticks={}),r.ticks.stepSize=t.scale.stepSize)),r}getFormatter(t,n){if(!(!t||t==="auto"))return Ofe(t,n||{})}}class qh extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class Yh extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class JI extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class zS extends Bg{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Pie and doughnut charts do not have axes"}}applyConfig(t){return t}}class zfe extends Bg{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Radar charts use a radial axis system"}}applyConfig(t,n){var r;return n!=null&&n.yAxisConfig?{...t,scales:{...t.scales,r:{...(r=t.scales)==null?void 0:r.r,...this.formatAxis(n.yAxisConfig,"value")}}}:t}}class C_{static getAxisInfo(t,n){return(this.handlers.get(t)||new qh).getAxisInfo(n)}static applyAxisConfig(t,n,r){return!(r!=null&&r.xAxisConfig)&&!(r!=null&&r.yAxisConfig)?t:(this.handlers.get(n)||new qh).applyConfig(t,r)}}je(C_,"handlers",new Map([["bar",new Yh],["horizontalBar",new Yh],["line",new JI],["stackedBar",new Yh],["stackedLine",new JI],["pie",new zS],["doughnut",new zS],["polarArea",new zS],["radar",new zfe],["bubble",new qh],["scatter",new qh],["funnel",new qh],["tornado",new Yh],["pyramid",new Yh]]));function Bfe(e,t){var r;if(!t)return e;const n={};return t.display!==void 0&&(n.display=t.display),t.position&&(n.position=t.position),t.align&&(n.align=t.align),{...e,plugins:{...e.plugins,legend:{...(r=e.plugins)==null?void 0:r.legend,...n}}}}function Vfe(e){return!["kpi","metric","text","table","pivotTable"].includes(e)}function Hfe(e,t=!1,n=!1){switch(e){case"bar":case"range":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"horizontalBar":return{anchor:"end",align:"right"};case"line":case"radar":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"pie":case"doughnut":case"polarArea":case"funnel":return{anchor:"center",align:"center"};case"stackedBar":case"stackedLine":return n?t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"}:{anchor:"center",align:"center"};default:return{anchor:"center",align:"center"}}}function eA(e,t,n,r){return function(s){var o,i;if(s==null)return"";if(r==="range"&&Array.isArray(s)){const a=(e==null?void 0:e.formatOptions)||(t==null?void 0:t.formatOptions)||{},l=(e==null?void 0:e.format)==="auto"?(o=t==null?void 0:t.formatOptions)==null?void 0:o.type:e==null?void 0:e.format;return s.slice(0,2).map(d=>l&&l!=="auto"&&l!=="none"?cu(Number(d),l,a):d).join(" - ")}return(e==null?void 0:e.format)==="none"?s:!(e!=null&&e.format)||e.format==="auto"?(i=t==null?void 0:t.formatOptions)!=null&&i.type&&t.formatOptions.type!=="auto"?cu(Number(s),t.formatOptions.type,t.formatOptions||{}):n?n(s):s:cu(Number(s),e.format,e.formatOptions||{})}}function ny(e,t,n,r,s){if(e!=null&&e.color&&e.color!=="auto")return e.color;const o=n==="end"&&r==="top"||n==="end"&&r==="right",i=n==="start"&&r==="bottom",a=n==="start"&&r==="left";if(o){const l=Ml();return Ra(l)}if(i||a){const l=Ml();return Ra(l)}return l=>{var d,f,h;const c=((f=(d=l.dataset)==null?void 0:d.backgroundColor)==null?void 0:f[l.dataIndex])||((h=l.dataset)==null?void 0:h.backgroundColor)||t||Ml();return Ra(c)}}function N_(e,t,n,r){var y,x,v,w,S,N,k,j,_,D,M,T;const s=(x=(y=n==null?void 0:n.chartOptions)==null?void 0:y.plugins)==null?void 0:x.datalabels,o=(s==null?void 0:s.display)!==!1&&((s==null?void 0:s.anchor)||(s==null?void 0:s.align));if((t==null?void 0:t.enabled)===!1)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};if(!t&&o)return e;if(!t)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};const i=r||e.type||"bar",a=((w=(v=e.scales)==null?void 0:v.x)==null?void 0:w.stacked)===!0||((N=(S=e.scales)==null?void 0:S.y)==null?void 0:N.stacked)===!0,l=((k=n==null?void 0:n.chartOptions)==null?void 0:k.indexAxis)==="y",c=l?n==null?void 0:n.xAxisConfig:n==null?void 0:n.yAxisConfig,d=Hfe(i,l,t.showTotal),f=a&&!t.showTotal?"center":t.anchor||d.anchor,h=a&&!t.showTotal?"center":t.align||d.align;let p=f,m=h;const g=i==="pie"||i==="doughnut"||i==="polarArea"||i==="funnel";a&&!t.showTotal&&(p="center",m="center");const b={display:t.display!==!1,anchor:p,align:m,clamp:t.clamp??!0,clip:t.clip??!1,formatter:eA(t,c,(_=(j=e.plugins)==null?void 0:j.datalabels)==null?void 0:_.formatter,i),color:ny(t,void 0,p,m),font:{size:((D=t.font)==null?void 0:D.size)||12,weight:((M=t.font)==null?void 0:M.weight)||"normal"},rotation:t.rotation||0,offset:0};if(g&&i!=="funnel"&&(delete b.anchor,delete b.align,Object.assign(b,{anchor:"center",align:"center",offset:0,clamp:!0,clip:!1,display:function(O){if(t.display===!1)return!1;const A=O.dataset.data[O.dataIndex],P=O.dataset.data.reduce((V,U)=>V+U,0);return A/P*100>5}})),i==="funnel"&&t.enabled&&(Object.assign(b,{anchor:function(O){return O.dataset.data[O.dataIndex]<.02?"end":"start"},align:function(O){return O.dataset.data[O.dataIndex]<.02?"end":"center"},textAlign:"center",offset:0,clamp:!0,clip:!1}),b.font||(b.font={}),b.font.size=b.font.size||14),a&&t.showTotal&&(b.display=function(O){const A=O.chart.data.datasets.length;return O.datasetIndex===A-1},b.formatter=function(O,A){var U,z;let P=0;const F=A.dataIndex;return A.chart.data.datasets.forEach(I=>{const B=I.data[F];B&&!isNaN(B)&&(P+=Number(B))}),eA(t,c,(z=(U=e.plugins)==null?void 0:U.datalabels)==null?void 0:z.formatter,i)(P)},b.anchor="end",b.align=l?"right":"top",b.color=ny(t,void 0,"end",l?"right":"top")),!a&&!g&&t.position&&t.position!=="auto"&&t.position!=="custom"){if(l)switch(t.position){case"left":b.anchor="start",b.align="left";break;case"right":b.anchor="end",b.align="right";break;case"center":b.anchor="center",b.align="center";break;case"top":case"bottom":b.anchor="center",b.align="center";break}else switch(t.position){case"top":b.anchor="end",b.align="top";break;case"bottom":b.anchor="start",b.align="bottom";break;case"center":b.anchor="center",b.align="center";break;case"left":case"right":b.anchor="center",b.align="center";break}b.color=ny(t,void 0,b.anchor,b.align)}else t.position==="custom"&&(b.color=ny(t,void 0,b.anchor,b.align));return g||i==="funnel"?{...e,plugins:{...e.plugins,datalabels:b}}:{...e,plugins:{...e.plugins,datalabels:{...(T=e.plugins)==null?void 0:T.datalabels,...b}}}}function Ufe(e){return!["kpi","metric","text","table","pivotTable","custom"].includes(e)}function Wfe(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!S3.includes(n))}function yd({data:e,cfg:t,customCfg:n,preferences:r,cardType:s,card:o}){var w,S;const i=s==="radar"?.2:1,{keys:a}=Qn(e),l=Wfe(a);let c="none";s=="bar"?c="bar":s=="line"&&(c="line");const d=a==null?void 0:a[0],f=Ag(e,d),p=X6(l,e,r,i,c,d,s==="stackedBar"||s==="stackedLine"),m=lu(p,n),{options:g,plugins:b}=Bp({cardType:s,cfg:t,preferences:r,customCfg:n,card:o}),y=(S=(w=o.interactionConfig)==null?void 0:w.interactions)==null?void 0:S.some(N=>N.mode==="clickFilter"),x=function(N,k){var _;const j=((_=N.native)==null?void 0:_.target)||N.target;k.length?j.style.cursor="pointer":j.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:f,datasets:m},options:{...g,onHover:y?x:void 0},plugins:b}}function qfe(e,t){var s,o,i;const n=((s=t==null?void 0:t.options)==null?void 0:s.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":n}function Yfe(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function c9(e,t){var i,a,l,c,d,f,h,p,m,g,b,y;const n=qfe(t,e),r=Yfe(t);return(t==null?void 0:t.xAxisConfig)||(t==null?void 0:t.yAxisConfig)?(e==null?void 0:e.options)||{}:{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(l=(a=e==null?void 0:e.options)==null?void 0:a.scales)==null?void 0:l[n],ticks:{...(f=(d=(c=e==null?void 0:e.options)==null?void 0:c.scales)==null?void 0:d[n])==null?void 0:f.ticks,callback:x=>{var v,w,S,N;return zN({number:Number(x),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((w=t==null?void 0:t.numberAxisFormat)!=null&&w.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((N=t==null?void 0:t.numberAxisFormat)==null?void 0:N.currency)||""})}}},[r]:{...(m=(p=(h=e==null?void 0:e.options)==null?void 0:h.scales)==null?void 0:p[r])==null?void 0:m.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(y=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:y.datalabels,formatter:function(x){var v,w,S,N;return zN({number:Number(x),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((w=t==null?void 0:t.numberAxisFormat)!=null&&w.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((N=t==null?void 0:t.numberAxisFormat)==null?void 0:N.currency)||""})}}}}}function Bp({cardType:e,cfg:t,preferences:n,customCfg:r,card:s}){var g,b,y,x,v,w,S,N,k,j,_,D,M,T,O,A,P,F,V,U,z,I,B,L,R,W,Y,Z,H,$,q,G,ee,Q,ne;const o=te.getState().themeStyle,i=c9(t,n),a=jr((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),l=jr(i,a),c=jr(l,(r==null?void 0:r.options)||{}),d=Gfe(e,n,c,s),f={...c,scales:{...c==null?void 0:c.scales,x:{...(g=c==null?void 0:c.scales)==null?void 0:g.x,grid:{...(y=(b=c==null?void 0:c.scales)==null?void 0:b.x)==null?void 0:y.grid,color:(N=(S=(w=(v=(x=o==null?void 0:o.chart)==null?void 0:x.options)==null?void 0:v.scales)==null?void 0:w.x)==null?void 0:S.grid)==null?void 0:N.color}},y:{...(k=c==null?void 0:c.scales)==null?void 0:k.y,grid:{...(_=(j=c==null?void 0:c.scales)==null?void 0:j.y)==null?void 0:_.grid,color:(A=(O=(T=(M=(D=o==null?void 0:o.chart)==null?void 0:D.options)==null?void 0:M.scales)==null?void 0:T.y)==null?void 0:O.grid)==null?void 0:A.color}}},plugins:{...c==null?void 0:c.plugins,tooltip:{filter:function(oe){return oe.raw!==void 0&&oe.raw!==null&&oe.raw!==0},footerColor:((U=(V=(F=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:F.plugins)==null?void 0:V.tooltip)==null?void 0:U.footerColor)||"#999",footerFont:{size:11,weight:"normal"},footerMarginTop:6,callbacks:d,...(z=c==null?void 0:c.plugins)==null?void 0:z.tooltip,backgroundColor:(R=(L=(B=(I=o==null?void 0:o.chart)==null?void 0:I.options)==null?void 0:B.plugins)==null?void 0:L.tooltip)==null?void 0:R.backgroundColor,bodyColor:(H=(Z=(Y=(W=o==null?void 0:o.chart)==null?void 0:W.options)==null?void 0:Y.plugins)==null?void 0:Z.tooltip)==null?void 0:H.bodyColor,titleColor:(ee=(G=(q=($=o==null?void 0:o.chart)==null?void 0:$.options)==null?void 0:q.plugins)==null?void 0:G.tooltip)==null?void 0:ee.titleColor}}},{plugins:h,options:p}=hw((n==null?void 0:n.customVisualCode)||"");let m=C_.applyAxisConfig(f,e||"bar",n);return m=Bfe(m,(ne=(Q=n==null?void 0:n.chartOptions)==null?void 0:Q.plugins)==null?void 0:ne.legend),m=N_(m,n==null?void 0:n.dataLabelsConfig,n,e),m=jr(m,p),{options:m,plugins:h}}function Gfe(e,t,n,r){var l,c,d,f,h,p,m;if(e==="map")return{};const o=((l=t==null?void 0:t.chartOptions)==null?void 0:l.indexAxis)==="y"?t==null?void 0:t.xAxisConfig:t==null?void 0:t.yAxisConfig,i=g=>{var b,y,x,v,w;return(b=o==null?void 0:o.formatOptions)!=null&&b.type&&o.formatOptions.type!=="auto"?cu(g,o.formatOptions.type,o.formatOptions||{}):zN({number:g,decimalPlaces:((y=t==null?void 0:t.numberAxisFormat)==null?void 0:y.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.locale)||"",currency:((w=t==null?void 0:t.numberAxisFormat)==null?void 0:w.currency)||""})},a=(((d=(c=r==null?void 0:r.interactionConfig)==null?void 0:c.drillHierarchies)==null?void 0:d.length)??0)>0||(((h=(f=r==null?void 0:r.interactionConfig)==null?void 0:f.interactions)==null?void 0:h.some(g=>g.mode==="drillDown"||g.mode==="drillToDetail"||g.mode==="drillThrough"||g.mode==="drillToURL"))??!1);return{title:function(g){var y;const b=((y=g==null?void 0:g[0])==null?void 0:y.label)||"";if(g.length>1&&["stackedBar","stackedLine"].includes(e||"")){const x=g.reduce((w,S)=>{const N=S.raw;return N!==void 0&&N!==0?w+N:w},0),v=i(x);return`${b} (${v})`}return b},label:function(g){var v;const b=((v=g==null?void 0:g.dataset)==null?void 0:v.label)||"",y=g==null?void 0:g.raw;if(y===void 0||y===0)return;const x=i(Number(y));return`${b}: ${x}`},footer:function(g){return a?["─────────────────","Click to drill"]:[]},...((m=(p=n==null?void 0:n.plugins)==null?void 0:p.tooltip)==null?void 0:m.callbacks)||{}}}/*!
707
+ `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function Tfe(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",s=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function cu(e,t="auto",n={}){switch(t==="auto"&&(t=Pfe(e,n)),t){case"number":return fw(e,n);case"currency":return i9(e,n);case"percent":return Rfe(e,n);case"date":return Ife(e,n);case"scientific":return Afe(e,n);default:return String(e)}}function fw(e,t={}){const{decimalPlaces:n=0,useSuffix:r=!1,prefix:s="",suffix:o="",locale:i="en-US",negativeInParentheses:a=!1}=t,l=e<0,c=Math.abs(e);let d=1,f="";if(r&&!o){const b=a9(c,i);d=b.divisor,f=b.suffix}const h=c/d;let p=i;try{new Intl.NumberFormat(i).format(0)}catch{p="en-US"}let g=new Intl.NumberFormat(p,{minimumFractionDigits:n,maximumFractionDigits:n}).format(h);return f&&(g+=f),o&&(g+=o),s&&(g=s+g),l&&(g=a?`(${g})`:`-${g}`),g}function i9(e,t={}){const{currency:n="USD",decimalPlaces:r=2,locale:s="en-US",useSuffix:o=!1,negativeInParentheses:i=!1}=t,a=e<0,l=Math.abs(e);let c=1,d="";if(o){const p=a9(l,s);c=p.divisor,d=p.suffix}const f=l/c;let h=s;try{new Intl.NumberFormat(s,{style:"currency",currency:n}).format(0)}catch{h="en-US"}try{let m=new Intl.NumberFormat(h,{style:"currency",currency:n,minimumFractionDigits:r,maximumFractionDigits:r}).format(f);return d&&(m+=d),a&&!m.includes("-")&&(m=i?`(${m})`:`-${m}`),m}catch{return`${n} ${fw(e,{...t,prefix:""})}`}}function Rfe(e,t={}){const{decimalPlaces:n=1,multiplyBy:r=100}=t,s=e*r;return fw(s,{...t,decimalPlaces:n,suffix:"%",useSuffix:!1})}function Ife(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function Afe(e,t={}){const{decimalPlaces:n=2}=t;try{const r=Number(e);return isNaN(r)?String(e):r.toExponential(n)}catch{return String(e)}}function a9(e,t){return e>=1e9?{suffix:"B",divisor:1e9}:e>=1e7&&t==="en-IN"?{suffix:"Cr",divisor:1e7}:e>=1e6?{suffix:"M",divisor:1e6}:e>=1e5&&t==="en-IN"?{suffix:"L",divisor:1e5}:e>=1e3?{suffix:"K",divisor:1e3}:{suffix:"",divisor:1}}function Pfe(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function Ofe(e,t={}){return n=>cu(n,e,t)}function zN({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:s="",locale:o="en-US"}){return s?i9(e,{currency:s,decimalPlaces:t,locale:o,useSuffix:n}):fw(e,{decimalPlaces:t,useSuffix:n,suffix:r,locale:o})}function hw(e){try{const n=new Function("getDatalabelColor",e)(A2);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Ffe(e){var t,n,r,s,o,i,a,l,c,d,f,h,p,m,g,b,y,x;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((i=(o=(s=e==null?void 0:e.scales)==null?void 0:s.y)==null?void 0:o.grid)==null?void 0:i.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(f=(d=e.scales)==null?void 0:d.y)==null?void 0:f.grid)!=null&&h.display?"y":((g=(m=(p=e.scales)==null?void 0:p.x)==null?void 0:m.grid)==null?void 0:g.display)===!1&&((x=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:x.display)===!1?"none":"xy"}function $fe(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return l9(t)}function l9(e){const[t,n,r]=e.split(" "),s=parseFloat(t),o=parseFloat(n),i=parseFloat(r),a=o/100,l=i/100,c=(1-Math.abs(2*l-1))*a,d=c*(1-Math.abs(s/60%2-1)),f=l-c/2;let h=0,p=0,m=0;0<=s&&s<60?(h=c,p=d,m=0):60<=s&&s<120?(h=d,p=c,m=0):120<=s&&s<180?(h=0,p=c,m=d):180<=s&&s<240?(h=0,p=d,m=c):240<=s&&s<300?(h=d,p=0,m=c):300<=s&&s<360&&(h=c,p=0,m=d),h=Math.round((h+f)*255),p=Math.round((p+f)*255),m=Math.round((m+f)*255);const g=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${g(h)}${g(p)}${g(m)}`}function Lfe(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([s])=>!t.some(o=>o.label===s))))}class Bg{formatAxis(t,n){var s;if(!t)return{};const r={display:t.enabled!==!1};return t.position&&t.position!=="auto"&&(r.position=t.position),t.name&&(r.title={display:t.name.enabled,text:t.name.text||""}),t.labels&&(r.ticks={display:t.labels.enabled!==!1},t.labels.rotation!==void 0&&t.labels.rotation!=="auto"&&(r.ticks.autoSkip=!1,r.ticks.maxRotation=t.labels.rotation,r.ticks.minRotation=t.labels.rotation)),n==="value"&&((s=t.formatOptions)!=null&&s.type)&&t.formatOptions.type!=="auto"&&(r.ticks||(r.ticks={}),r.ticks.callback=this.getFormatter(t.formatOptions.type,t.formatOptions)),n==="value"&&t.scale&&(t.scale.min!=="auto"&&t.scale.min!==void 0&&(r.min=t.scale.min),t.scale.max!=="auto"&&t.scale.max!==void 0&&(r.max=t.scale.max),t.scale.stepSize!=="auto"&&t.scale.stepSize!==void 0&&(r.ticks||(r.ticks={}),r.ticks.stepSize=t.scale.stepSize)),r}getFormatter(t,n){if(!(!t||t==="auto"))return Ofe(t,n||{})}}class qh extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class Yh extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class JI extends Bg{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var s,o,i,a,l;return((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(o=t.scales)==null?void 0:o.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(i=t.scales)==null?void 0:i.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class zS extends Bg{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Pie and doughnut charts do not have axes"}}applyConfig(t){return t}}class zfe extends Bg{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Radar charts use a radial axis system"}}applyConfig(t,n){var r;return n!=null&&n.yAxisConfig?{...t,scales:{...t.scales,r:{...(r=t.scales)==null?void 0:r.r,...this.formatAxis(n.yAxisConfig,"value")}}}:t}}class C_{static getAxisInfo(t,n){return(this.handlers.get(t)||new qh).getAxisInfo(n)}static applyAxisConfig(t,n,r){return!(r!=null&&r.xAxisConfig)&&!(r!=null&&r.yAxisConfig)?t:(this.handlers.get(n)||new qh).applyConfig(t,r)}}je(C_,"handlers",new Map([["bar",new Yh],["horizontalBar",new Yh],["line",new JI],["stackedBar",new Yh],["stackedLine",new JI],["pie",new zS],["doughnut",new zS],["polarArea",new zS],["radar",new zfe],["bubble",new qh],["scatter",new qh],["funnel",new qh],["tornado",new Yh],["pyramid",new Yh]]));function Bfe(e,t){var r;if(!t)return e;const n={};return t.display!==void 0&&(n.display=t.display),t.position&&(n.position=t.position),t.align&&(n.align=t.align),{...e,plugins:{...e.plugins,legend:{...(r=e.plugins)==null?void 0:r.legend,...n}}}}function Vfe(e){return!["kpi","metric","text","table","pivotTable"].includes(e)}function Hfe(e,t=!1,n=!1){switch(e){case"bar":case"range":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"horizontalBar":return{anchor:"end",align:"right"};case"line":case"radar":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"pie":case"doughnut":case"polarArea":case"funnel":return{anchor:"center",align:"center"};case"stackedBar":case"stackedLine":return n?t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"}:{anchor:"center",align:"center"};default:return{anchor:"center",align:"center"}}}function eA(e,t,n,r){return function(s){var o,i;if(s==null)return"";if(r==="range"&&Array.isArray(s)){const a=(e==null?void 0:e.formatOptions)||(t==null?void 0:t.formatOptions)||{},l=(e==null?void 0:e.format)==="auto"?(o=t==null?void 0:t.formatOptions)==null?void 0:o.type:e==null?void 0:e.format;return s.slice(0,2).map(d=>l&&l!=="auto"&&l!=="none"?cu(Number(d),l,a):d).join(" - ")}return(e==null?void 0:e.format)==="none"?s:!(e!=null&&e.format)||e.format==="auto"?(i=t==null?void 0:t.formatOptions)!=null&&i.type&&t.formatOptions.type!=="auto"?cu(Number(s),t.formatOptions.type,t.formatOptions||{}):n?n(s):s:cu(Number(s),e.format,e.formatOptions||{})}}function ny(e,t,n,r,s){if(e!=null&&e.color&&e.color!=="auto")return e.color;const o=n==="end"&&r==="top"||n==="end"&&r==="right",i=n==="start"&&r==="bottom",a=n==="start"&&r==="left";if(o){const l=Ml();return Ra(l)}if(i||a){const l=Ml();return Ra(l)}return l=>{var d,f,h;const c=((f=(d=l.dataset)==null?void 0:d.backgroundColor)==null?void 0:f[l.dataIndex])||((h=l.dataset)==null?void 0:h.backgroundColor)||t||Ml();return Ra(c)}}function N_(e,t,n,r){var y,x,v,w,S,N,k,j,_,D,M,T;const s=(x=(y=n==null?void 0:n.chartOptions)==null?void 0:y.plugins)==null?void 0:x.datalabels,o=(s==null?void 0:s.display)!==!1&&((s==null?void 0:s.anchor)||(s==null?void 0:s.align));if((t==null?void 0:t.enabled)===!1)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};if(!t&&o)return e;if(!t)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};const i=r||e.type||"bar",a=((w=(v=e.scales)==null?void 0:v.x)==null?void 0:w.stacked)===!0||((N=(S=e.scales)==null?void 0:S.y)==null?void 0:N.stacked)===!0,l=((k=n==null?void 0:n.chartOptions)==null?void 0:k.indexAxis)==="y",c=l?n==null?void 0:n.xAxisConfig:n==null?void 0:n.yAxisConfig,d=Hfe(i,l,t.showTotal),f=a&&!t.showTotal?"center":t.anchor||d.anchor,h=a&&!t.showTotal?"center":t.align||d.align;let p=f,m=h;const g=i==="pie"||i==="doughnut"||i==="polarArea"||i==="funnel";a&&!t.showTotal&&(p="center",m="center");const b={display:t.display!==!1,anchor:p,align:m,clamp:t.clamp??!0,clip:t.clip??!1,formatter:eA(t,c,(_=(j=e.plugins)==null?void 0:j.datalabels)==null?void 0:_.formatter,i),color:ny(t,void 0,p,m),font:{size:((D=t.font)==null?void 0:D.size)||12,weight:((M=t.font)==null?void 0:M.weight)||"normal"},rotation:t.rotation||0,offset:0};if(g&&i!=="funnel"&&(delete b.anchor,delete b.align,Object.assign(b,{anchor:"center",align:"center",offset:0,clamp:!0,clip:!1,display:function(O){if(t.display===!1)return!1;const A=O.dataset.data[O.dataIndex],P=O.dataset.data.reduce((V,U)=>V+U,0);return A/P*100>5}})),i==="funnel"&&t.enabled&&(Object.assign(b,{anchor:function(O){return O.dataset.data[O.dataIndex]<.02?"end":"start"},align:function(O){return O.dataset.data[O.dataIndex]<.02?"end":"center"},textAlign:"center",offset:0,clamp:!0,clip:!1}),b.font||(b.font={}),b.font.size=b.font.size||14),a&&t.showTotal&&(b.display=function(O){const A=O.chart.data.datasets.length;return O.datasetIndex===A-1},b.formatter=function(O,A){var U,z;let P=0;const F=A.dataIndex;return A.chart.data.datasets.forEach(I=>{const B=I.data[F];B&&!isNaN(B)&&(P+=Number(B))}),eA(t,c,(z=(U=e.plugins)==null?void 0:U.datalabels)==null?void 0:z.formatter,i)(P)},b.anchor="end",b.align=l?"right":"top",b.color=ny(t,void 0,"end",l?"right":"top")),!a&&!g&&t.position&&t.position!=="auto"&&t.position!=="custom"){if(l)switch(t.position){case"left":b.anchor="start",b.align="left";break;case"right":b.anchor="end",b.align="right";break;case"center":b.anchor="center",b.align="center";break;case"top":case"bottom":b.anchor="center",b.align="center";break}else switch(t.position){case"top":b.anchor="end",b.align="top";break;case"bottom":b.anchor="start",b.align="bottom";break;case"center":b.anchor="center",b.align="center";break;case"left":case"right":b.anchor="center",b.align="center";break}b.color=ny(t,void 0,b.anchor,b.align)}else t.position==="custom"&&(b.color=ny(t,void 0,b.anchor,b.align));return g||i==="funnel"?{...e,plugins:{...e.plugins,datalabels:b}}:{...e,plugins:{...e.plugins,datalabels:{...(T=e.plugins)==null?void 0:T.datalabels,...b}}}}function Ufe(e){return!["kpi","metric","text","table","pivotTable","custom"].includes(e)}function Wfe(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!S3.includes(n))}function yd({data:e,cfg:t,customCfg:n,preferences:r,cardType:s,card:o}){var w;const i=s==="radar"?.2:1,{keys:a}=Qn(e),l=Wfe(a);let c="none";s=="bar"?c="bar":s=="line"&&(c="line");const d=a==null?void 0:a[0],f=Ag(e,d),p=X6(l,e,r,i,c,d,s==="stackedBar"||s==="stackedLine"),m=lu(p,n),{options:g,plugins:b}=Bp({cardType:s,cfg:t,preferences:r,customCfg:n,card:o}),y=((w=o.interactionConfig)==null?void 0:w.interactions)&&o.interactionConfig.interactions.length>0,x=function(S,N){var j;const k=((j=S.native)==null?void 0:j.target)||S.target;N.length?k.style.cursor="pointer":k.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:f,datasets:m},options:{...g,onHover:y?x:void 0},plugins:b}}function qfe(e,t){var s,o,i;const n=((s=t==null?void 0:t.options)==null?void 0:s.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":n}function Yfe(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function c9(e,t){var i,a,l,c,d,f,h,p,m,g,b,y;const n=qfe(t,e),r=Yfe(t);return(t==null?void 0:t.xAxisConfig)||(t==null?void 0:t.yAxisConfig)?(e==null?void 0:e.options)||{}:{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(l=(a=e==null?void 0:e.options)==null?void 0:a.scales)==null?void 0:l[n],ticks:{...(f=(d=(c=e==null?void 0:e.options)==null?void 0:c.scales)==null?void 0:d[n])==null?void 0:f.ticks,callback:x=>{var v,w,S,N;return zN({number:Number(x),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((w=t==null?void 0:t.numberAxisFormat)!=null&&w.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((N=t==null?void 0:t.numberAxisFormat)==null?void 0:N.currency)||""})}}},[r]:{...(m=(p=(h=e==null?void 0:e.options)==null?void 0:h.scales)==null?void 0:p[r])==null?void 0:m.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(y=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:y.datalabels,formatter:function(x){var v,w,S,N;return zN({number:Number(x),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((w=t==null?void 0:t.numberAxisFormat)!=null&&w.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((N=t==null?void 0:t.numberAxisFormat)==null?void 0:N.currency)||""})}}}}}function Bp({cardType:e,cfg:t,preferences:n,customCfg:r,card:s}){var g,b,y,x,v,w,S,N,k,j,_,D,M,T,O,A,P,F,V,U,z,I,B,L,R,W,Y,Z,H,$,q,G,ee,Q,ne;const o=te.getState().themeStyle,i=c9(t,n),a=jr((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),l=jr(i,a),c=jr(l,(r==null?void 0:r.options)||{}),d=Gfe(e,n,c,s),f={...c,scales:{...c==null?void 0:c.scales,x:{...(g=c==null?void 0:c.scales)==null?void 0:g.x,grid:{...(y=(b=c==null?void 0:c.scales)==null?void 0:b.x)==null?void 0:y.grid,color:(N=(S=(w=(v=(x=o==null?void 0:o.chart)==null?void 0:x.options)==null?void 0:v.scales)==null?void 0:w.x)==null?void 0:S.grid)==null?void 0:N.color}},y:{...(k=c==null?void 0:c.scales)==null?void 0:k.y,grid:{...(_=(j=c==null?void 0:c.scales)==null?void 0:j.y)==null?void 0:_.grid,color:(A=(O=(T=(M=(D=o==null?void 0:o.chart)==null?void 0:D.options)==null?void 0:M.scales)==null?void 0:T.y)==null?void 0:O.grid)==null?void 0:A.color}}},plugins:{...c==null?void 0:c.plugins,tooltip:{filter:function(oe){return oe.raw!==void 0&&oe.raw!==null&&oe.raw!==0},footerColor:((U=(V=(F=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:F.plugins)==null?void 0:V.tooltip)==null?void 0:U.footerColor)||"#999",footerFont:{size:11,weight:"normal"},footerMarginTop:6,callbacks:d,...(z=c==null?void 0:c.plugins)==null?void 0:z.tooltip,backgroundColor:(R=(L=(B=(I=o==null?void 0:o.chart)==null?void 0:I.options)==null?void 0:B.plugins)==null?void 0:L.tooltip)==null?void 0:R.backgroundColor,bodyColor:(H=(Z=(Y=(W=o==null?void 0:o.chart)==null?void 0:W.options)==null?void 0:Y.plugins)==null?void 0:Z.tooltip)==null?void 0:H.bodyColor,titleColor:(ee=(G=(q=($=o==null?void 0:o.chart)==null?void 0:$.options)==null?void 0:q.plugins)==null?void 0:G.tooltip)==null?void 0:ee.titleColor}}},{plugins:h,options:p}=hw((n==null?void 0:n.customVisualCode)||"");let m=C_.applyAxisConfig(f,e||"bar",n);return m=Bfe(m,(ne=(Q=n==null?void 0:n.chartOptions)==null?void 0:Q.plugins)==null?void 0:ne.legend),m=N_(m,n==null?void 0:n.dataLabelsConfig,n,e),m=jr(m,p),{options:m,plugins:h}}function Gfe(e,t,n,r){var l,c,d,f,h,p,m;if(e==="map")return{};const o=((l=t==null?void 0:t.chartOptions)==null?void 0:l.indexAxis)==="y"?t==null?void 0:t.xAxisConfig:t==null?void 0:t.yAxisConfig,i=g=>{var b,y,x,v,w;return(b=o==null?void 0:o.formatOptions)!=null&&b.type&&o.formatOptions.type!=="auto"?cu(g,o.formatOptions.type,o.formatOptions||{}):zN({number:g,decimalPlaces:((y=t==null?void 0:t.numberAxisFormat)==null?void 0:y.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.locale)||"",currency:((w=t==null?void 0:t.numberAxisFormat)==null?void 0:w.currency)||""})},a=(((d=(c=r==null?void 0:r.interactionConfig)==null?void 0:c.drillHierarchies)==null?void 0:d.length)??0)>0||(((h=(f=r==null?void 0:r.interactionConfig)==null?void 0:f.interactions)==null?void 0:h.some(g=>g.mode==="drillDown"||g.mode==="drillToDetail"||g.mode==="drillThrough"||g.mode==="drillToURL"))??!1);return{title:function(g){var y;const b=((y=g==null?void 0:g[0])==null?void 0:y.label)||"";if(g.length>1&&["stackedBar","stackedLine"].includes(e||"")){const x=g.reduce((w,S)=>{const N=S.raw;return N!==void 0&&N!==0?w+N:w},0),v=i(x);return`${b} (${v})`}return b},label:function(g){var v;const b=((v=g==null?void 0:g.dataset)==null?void 0:v.label)||"",y=g==null?void 0:g.raw;if(y===void 0||y===0)return;const x=i(Number(y));return`${b}: ${x}`},footer:function(g){return a?["─────────────────","Click to drill"]:[]},...((m=(p=n==null?void 0:n.plugins)==null?void 0:p.tooltip)==null?void 0:m.callbacks)||{}}}/*!
708
708
  * @kurkle/color v0.3.4
709
709
  * https://github.com/kurkle/color#readme
710
710
  * (c) 2024 Jukka Kurkela
@@ -882,7 +882,7 @@ Valid keys: `+JSON.stringify(Object.keys(I),null," "));var Q=ee(H,G,W,Y,Z+"."+G
882
882
  * You can read more about the APCA Readability Criterion at
883
883
  * https://readtech.org/ARC/
884
884
  */const kO=.027,X2e=5e-4,Q2e=.1,EO=1.14,Oy=.022,jO=1.414,J2e=(e,t)=>{e=new Se(e),t=new Se(t),e.alpha()<1&&(e=Xf(t,e,e.alpha(),"rgb"));const n=_O(...e.rgb()),r=_O(...t.rgb()),s=n>=Oy?n:n+Math.pow(Oy-n,jO),o=r>=Oy?r:r+Math.pow(Oy-r,jO),i=Math.pow(o,.56)-Math.pow(s,.57),a=Math.pow(o,.65)-Math.pow(s,.62),l=Math.abs(o-s)<X2e?0:s<o?i*EO:a*EO;return(Math.abs(l)<Q2e?0:l>0?l-kO:l+kO)*100};function _O(e,t,n){return .2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(n/255,2.4)}const{sqrt:la,pow:tr,min:eNe,max:tNe,atan2:DO,abs:MO,cos:Fy,sin:TO,exp:nNe,PI:RO}=Math;function rNe(e,t,n=1,r=1,s=1){var o=function(R){return 360*R/(2*RO)},i=function(R){return 2*RO*R/360};e=new Se(e),t=new Se(t);const[a,l,c]=Array.from(e.lab()),[d,f,h]=Array.from(t.lab()),p=(a+d)/2,m=la(tr(l,2)+tr(c,2)),g=la(tr(f,2)+tr(h,2)),b=(m+g)/2,y=.5*(1-la(tr(b,7)/(tr(b,7)+tr(25,7)))),x=l*(1+y),v=f*(1+y),w=la(tr(x,2)+tr(c,2)),S=la(tr(v,2)+tr(h,2)),N=(w+S)/2,k=o(DO(c,x)),j=o(DO(h,v)),_=k>=0?k:k+360,D=j>=0?j:j+360,M=MO(_-D)>180?(_+D+360)/2:(_+D)/2,T=1-.17*Fy(i(M-30))+.24*Fy(i(2*M))+.32*Fy(i(3*M+6))-.2*Fy(i(4*M-63));let O=D-_;O=MO(O)<=180?O:D<=_?O+360:O-360,O=2*la(w*S)*TO(i(O)/2);const A=d-a,P=S-w,F=1+.015*tr(p-50,2)/la(20+tr(p-50,2)),V=1+.045*N,U=1+.015*N*T,z=30*nNe(-tr((M-275)/25,2)),B=-(2*la(tr(N,7)/(tr(N,7)+tr(25,7))))*TO(2*i(z)),L=la(tr(A/(n*F),2)+tr(P/(r*V),2)+tr(O/(s*U),2)+B*(P/(r*V))*(O/(s*U)));return tNe(0,eNe(100,L))}function sNe(e,t,n="lab"){e=new Se(e),t=new Se(t);const r=e.get(n),s=t.get(n);let o=0;for(let i in r){const a=(r[i]||0)-(s[i]||0);o+=a*a}return Math.sqrt(o)}const oNe=(...e)=>{try{return new Se(...e),!0}catch{return!1}},iNe={cool(){return A0([It.hsl(180,1,.9),It.hsl(250,.7,.4)])},hot(){return A0(["#000","#f00","#ff0","#fff"]).mode("rgb")}},Tk={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},NH=Object.keys(Tk),IO=new Map(NH.map(e=>[e.toLowerCase(),e])),aNe=typeof Proxy=="function"?new Proxy(Tk,{get(e,t){const n=t.toLowerCase();if(IO.has(n))return e[IO.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(NH)}}):Tk,lNe=(...e)=>{e=wt(e,"cmyk");const[t,n,r,s]=e,o=e.length>4?e[4]:1;return s===1?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-s),n>=1?0:255*(1-n)*(1-s),r>=1?0:255*(1-r)*(1-s),o]},{max:AO}=Math,cNe=(...e)=>{let[t,n,r]=wt(e,"rgb");t=t/255,n=n/255,r=r/255;const s=1-AO(t,AO(n,r)),o=s<1?1/(1-s):0,i=(1-t-s)*o,a=(1-n-s)*o,l=(1-r-s)*o;return[i,a,l,s]};Se.prototype.cmyk=function(){return cNe(this._rgb)};const uNe=(...e)=>new Se(...e,"cmyk");Object.assign(It,{cmyk:uNe});mt.format.cmyk=lNe;mt.autodetect.push({p:2,test:(...e)=>{if(e=wt(e,"cmyk"),Tt(e)==="array"&&e.length===4)return"cmyk"}});const dNe=(...e)=>{const t=wt(e,"hsla");let n=Nh(e)||"lsa";return t[0]=_o(t[0]||0)+"deg",t[1]=_o(t[1]*100)+"%",t[2]=_o(t[2]*100)+"%",n==="hsla"||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),n="hsla"):t.length=3,`${n.substr(0,3)}(${t.join(" ")})`},fNe=(...e)=>{const t=wt(e,"lab");let n=Nh(e)||"lab";return t[0]=_o(t[0])+"%",t[1]=_o(t[1]),t[2]=_o(t[2]),n==="laba"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`},hNe=(...e)=>{const t=wt(e,"lch");let n=Nh(e)||"lab";return t[0]=_o(t[0])+"%",t[1]=_o(t[1]),t[2]=isNaN(t[2])?"none":_o(t[2])+"deg",n==="lcha"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`},pNe=(...e)=>{const t=wt(e,"lab");return t[0]=_o(t[0]*100)+"%",t[1]=Dk(t[1]),t[2]=Dk(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`},kH=(...e)=>{const[t,n,r,...s]=wt(e,"rgb"),[o,i,a]=RD(t,n,r),[l,c,d]=yH(o,i,a);return[l,c,d,...s.length>0&&s[0]<1?[s[0]]:[]]},mNe=(...e)=>{const t=wt(e,"lch");return t[0]=_o(t[0]*100)+"%",t[1]=Dk(t[1]),t[2]=isNaN(t[2])?"none":_o(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`},{round:NC}=Math,gNe=(...e)=>{const t=wt(e,"rgba");let n=Nh(e)||"rgb";if(n.substr(0,3)==="hsl")return dNe(vH(t),n);if(n.substr(0,3)==="lab"){const r=Um();Da("d50");const s=fNe(_D(t),n);return Da(r),s}if(n.substr(0,3)==="lch"){const r=Um();Da("d50");const s=hNe(MD(t),n);return Da(r),s}return n.substr(0,5)==="oklab"?pNe(RD(t)):n.substr(0,5)==="oklch"?mNe(kH(t)):(t[0]=NC(t[0]),t[1]=NC(t[1]),t[2]=NC(t[2]),(n==="rgba"||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),n="rgba"),`${n.substr(0,3)}(${t.slice(0,n==="rgb"?3:4).join(" ")})`)},EH=(...e)=>{e=wt(e,"lch");const[t,n,r,...s]=e,[o,i,a]=bH(t,n,r),[l,c,d]=TD(o,i,a);return[l,c,d,...s.length>0&&s[0]<1?[s[0]]:[]]},Pa=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,Xo=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,P0=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,Ro=/\s*/.source,Eh=/\s+/.source,ID=/\s*,\s*/.source,$w=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,jh=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,jH=new RegExp("^rgba?\\("+Ro+[Pa,Pa,Pa].join(Eh)+jh+"\\)$"),_H=new RegExp("^rgb\\("+Ro+[Pa,Pa,Pa].join(ID)+Ro+"\\)$"),DH=new RegExp("^rgba\\("+Ro+[Pa,Pa,Pa,Xo].join(ID)+Ro+"\\)$"),MH=new RegExp("^hsla?\\("+Ro+[$w,P0,P0].join(Eh)+jh+"\\)$"),TH=new RegExp("^hsl?\\("+Ro+[$w,P0,P0].join(ID)+Ro+"\\)$"),RH=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,IH=new RegExp("^lab\\("+Ro+[Xo,Xo,Xo].join(Eh)+jh+"\\)$"),AH=new RegExp("^lch\\("+Ro+[Xo,Xo,$w].join(Eh)+jh+"\\)$"),PH=new RegExp("^oklab\\("+Ro+[Xo,Xo,Xo].join(Eh)+jh+"\\)$"),OH=new RegExp("^oklch\\("+Ro+[Xo,Xo,$w].join(Eh)+jh+"\\)$"),{round:FH}=Math,Cd=e=>e.map((t,n)=>n<=2?yu(FH(t),0,255):t),nr=(e,t=0,n=100,r=!1)=>(typeof e=="string"&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,r?e=t+(e+1)*.5*(n-t):e=t+e*(n-t)),+e),Jr=(e,t)=>e==="none"?t:e,AD=e=>{if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t;if(mt.format.named)try{return mt.format.named(e)}catch{}if((t=e.match(jH))||(t=e.match(_H))){let n=t.slice(1,4);for(let s=0;s<3;s++)n[s]=+nr(Jr(n[s],0),0,255);n=Cd(n);const r=t[4]!==void 0?+nr(t[4],0,1):1;return n[3]=r,n}if(t=e.match(DH)){const n=t.slice(1,5);for(let r=0;r<4;r++)n[r]=+nr(n[r],0,255);return n}if((t=e.match(MH))||(t=e.match(TH))){const n=t.slice(1,4);n[0]=+Jr(n[0].replace("deg",""),0),n[1]=+nr(Jr(n[1],0),0,100)*.01,n[2]=+nr(Jr(n[2],0),0,100)*.01;const r=Cd(Mk(n)),s=t[4]!==void 0?+nr(t[4],0,1):1;return r[3]=s,r}if(t=e.match(RH)){const n=t.slice(1,4);n[1]*=.01,n[2]*=.01;const r=Mk(n);for(let s=0;s<3;s++)r[s]=FH(r[s]);return r[3]=+t[4],r}if(t=e.match(IH)){const n=t.slice(1,4);n[0]=nr(Jr(n[0],0),0,100),n[1]=nr(Jr(n[1],0),-125,125,!0),n[2]=nr(Jr(n[2],0),-125,125,!0);const r=Um();Da("d50");const s=Cd(jD(n));Da(r);const o=t[4]!==void 0?+nr(t[4],0,1):1;return s[3]=o,s}if(t=e.match(AH)){const n=t.slice(1,4);n[0]=nr(n[0],0,100),n[1]=nr(Jr(n[1],0),0,150,!1),n[2]=+Jr(n[2].replace("deg",""),0);const r=Um();Da("d50");const s=Cd(DD(n));Da(r);const o=t[4]!==void 0?+nr(t[4],0,1):1;return s[3]=o,s}if(t=e.match(PH)){const n=t.slice(1,4);n[0]=nr(Jr(n[0],0),0,1),n[1]=nr(Jr(n[1],0),-.4,.4,!0),n[2]=nr(Jr(n[2],0),-.4,.4,!0);const r=Cd(TD(n)),s=t[4]!==void 0?+nr(t[4],0,1):1;return r[3]=s,r}if(t=e.match(OH)){const n=t.slice(1,4);n[0]=nr(Jr(n[0],0),0,1),n[1]=nr(Jr(n[1],0),0,.4,!1),n[2]=+Jr(n[2].replace("deg",""),0);const r=Cd(EH(n)),s=t[4]!==void 0?+nr(t[4],0,1):1;return r[3]=s,r}};AD.test=e=>jH.test(e)||MH.test(e)||IH.test(e)||AH.test(e)||PH.test(e)||OH.test(e)||_H.test(e)||DH.test(e)||TH.test(e)||RH.test(e)||e==="transparent";Se.prototype.css=function(e){return gNe(this._rgb,e)};const bNe=(...e)=>new Se(...e,"css");It.css=bNe;mt.format.css=AD;mt.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&Tt(e)==="string"&&AD.test(e))return"css"}});mt.format.gl=(...e)=>{const t=wt(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};const yNe=(...e)=>new Se(...e,"gl");It.gl=yNe;Se.prototype.gl=function(){const e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};Se.prototype.hex=function(e){return pH(this._rgb,e)};const xNe=(...e)=>new Se(...e,"hex");It.hex=xNe;mt.format.hex=hH;mt.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&Tt(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});const{log:$y}=Math,$H=e=>{const t=e/100;let n,r,s;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*$y(r),s=t<20?0:-254.76935184120902+.8274096064007395*(s=t-10)+115.67994401066147*$y(s)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*$y(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*$y(r),s=255),[n,r,s,1]},{round:vNe}=Math,wNe=(...e)=>{const t=wt(e,"rgb"),n=t[0],r=t[2];let s=1e3,o=4e4;const i=.4;let a;for(;o-s>i;){a=(o+s)*.5;const l=$H(a);l[2]/l[0]>=r/n?o=a:s=a}return vNe(a)};Se.prototype.temp=Se.prototype.kelvin=Se.prototype.temperature=function(){return wNe(this._rgb)};const kC=(...e)=>new Se(...e,"temp");Object.assign(It,{temp:kC,kelvin:kC,temperature:kC});mt.format.temp=mt.format.kelvin=mt.format.temperature=$H;Se.prototype.oklch=function(){return kH(this._rgb)};const SNe=(...e)=>new Se(...e,"oklch");Object.assign(It,{oklch:SNe});mt.format.oklch=EH;mt.autodetect.push({p:2,test:(...e)=>{if(e=wt(e,"oklch"),Tt(e)==="array"&&e.length===3)return"oklch"}});Object.assign(It,{analyze:SH,average:C2e,bezier:D2e,blend:oi,brewer:aNe,Color:Se,colors:Kf,contrast:K2e,contrastAPCA:J2e,cubehelix:V2e,deltaE:rNe,distance:sNe,input:mt,interpolate:Xf,limits:CH,mix:Xf,random:q2e,scale:A0,scales:iNe,valid:oNe});function PO(e,t,n,r=1e-5){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function EC(e){return{left:e.top,right:e.bottom,top:e.left,bottom:e.right,horizontal:!e.horizontal}}class _h extends Ai{constructor(){super(...arguments),this.align="center",this.next=void 0,this.previous=void 0}getBounds(t=!1){const{x:n,y:r,base:s,width:o,height:i,horizontal:a}=this.getProps(["x","y","base","width","height","horizontal"],t);if(a){const l=Math.abs(n-s),c=s-(this.align!=="left"?l:0),d=s+(this.align!=="right"?l:0),f=i/2,h=r-f,p=r+f;return{left:c,top:h,right:d,bottom:p,horizontal:a}}else{const l=Math.abs(r-s),c=o/2,d=n-c,f=n+c,h=s-(this.align!=="right"?l:0),p=s+(this.align!=="left"?l:0);return{left:d,top:h,right:f,bottom:p,horizontal:a}}}inRange(t,n,r){const s=this.getBounds(r),o=t==null||PO(t,s.left,s.right),i=n==null||PO(n,s.top,s.bottom);return o&&i}inXRange(t,n){return this.inRange(t,null,n)}inYRange(t,n){return this.inRange(null,t,n)}getCenterPoint(t){const{x:n,y:r,base:s,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{center:{x:o?s:n,y:o?r:s},left:{x:o?(s+n)/2:n,y:o?r:(s+r)/2},right:{x:o?s-(n-s)/2:n,y:o?r:s-(r+s)/2}}[this.align]}tooltipPosition(t){return this.getCenterPoint(t)}getRange(t){const{width:n,height:r}=this.getProps(["width","height"]);return t==="x"?n:r}computeWayPoints(t=!1){let n=this.options.shrinkAnchor,r=Math.max(Math.min(this.options.shrinkFraction,1),0);r===0&&(n="none",r=1);let s=this.getBounds(t);const o=s.horizontal;let i=this.next&&(n==="top"||n==="middle")?this.next.getBounds(t):s,a=this.previous&&(n==="bottom"||n==="middle")?this.previous.getBounds(t):s;o||(s=EC(s),i=EC(i),a=EC(a));const l=Math.floor((s.bottom-s.top)*(1-r)),c=Math.floor((s.bottom-s.top-l)/2),d=[],f=[];if(n==="none"||n==="top")d.push([s.left,s.top],[s.right,s.top]);else{let h=1;if(n==="middle"){const p=Math.floor((a.bottom-a.top)*r*.5);h=c/(p+c)}d.push([s.left+(a.left-s.left)*h,s.top],[s.right+(a.right-s.right)*h,s.top])}if(n==="middle"?(d.push([s.right,s.top+c]),d.push([s.right,s.bottom-c]),f.push([s.left,s.top+c]),f.push([s.left,s.bottom-c])):n==="top"&&r<1?(d.push([s.right,s.top+l]),f.push([s.left,s.top+l])):n==="bottom"&&r<1&&(d.push([s.right,s.bottom-l]),f.push([s.left,s.bottom-l])),n==="none"||n==="bottom")d.push([s.right,s.bottom],[s.left,s.bottom]);else{let h=1;if(n==="middle"){const p=Math.floor((i.bottom-i.top)*r*.5);h=c/(p+c)}d.push([s.right+(i.right-s.right)*h,s.bottom],[s.left+(i.left-s.left)*h,s.bottom])}return d.push(...f.reverse()),o?d:d.map(([h,p])=>[p,h])}draw(t){const{options:n}=this;t.save(),t.beginPath();const r=this.computeWayPoints();t.moveTo(r[0][0],r[0][1]);for(const s of r.slice(1))t.lineTo(s[0],s[1]);n.backgroundColor&&(t.fillStyle=n.backgroundColor,t.fill()),n.borderColor&&(t.strokeStyle=n.borderColor,t.lineWidth=n.borderWidth,t.stroke()),t.restore()}}_h.id="trapezoid";_h.defaults={...Ai.defaults,shrinkAnchor:"top",shrinkFraction:1};_h.defaultRoutes=Ai.defaultRoutes;function CNe(e,t="#000000",n="#ffffff"){return It(e).luminance()>.5?t:n}function NNe(e,t){return It.scale("Blues")(e/(t-1)).hex()}function kNe(e,t,n,r=[],s=[]){or.addControllers(n),Array.isArray(r)?or.addElements(...r):or.addElements(r),Array.isArray(s)?or.addScales(...s):or.addScales(s);const o=t;return o.type=e,o}class Dh extends pu{getMinMax(t,n){const{max:r}=super.getMinMax(t,n);return{center:{min:-r,max:r},left:{min:0,max:r},right:{min:-r,max:0}}[this.options.align]}update(t){super.update(t);const r=this._cachedMeta.data||[];for(let s=0;s<r.length;s++)r[s].align=this.options.align,r[s].next=r[s+1],r[s].previous=r[s-1]}}Dh.id="funnel";Dh.defaults=ur({},[pu.defaults,{dataElementType:_h.id,barPercentage:1,align:"center",categoryPercentage:.98}]);Dh.overrides=ur({},[pu.overrides,{plugins:{legend:{display:!1},colors:{enabled:!1},datalabels:{anchor:"start",textAlign:"center",font:{size:20},color:e=>{const t=e.chart.getDatasetMeta(e.datasetIndex).data[e.dataIndex].options.backgroundColor;return CNe(t,pn.defaults.color,"#ffffff")},formatter:(e,t)=>{var n,r;return`${(r=(n=t.chart.data.labels)===null||n===void 0?void 0:n[t.dataIndex])!==null&&r!==void 0?r:""}
885
- ${(e*100).toLocaleString()}%`}}},scales:{_index_:{display:!1,padding:10,grid:{display:!1}},_value_:{display:!1,beginAtZero:!1,grace:0,grid:{display:!1}}},elements:{trapezoid:{backgroundColor(e){const t=e.chart.data.datasets[e.datasetIndex].data.length;return NNe(e.dataIndex,t)}}}}]);class ENe extends pn{constructor(t,n){super(t,kNe("funnel",n,Dh,_h,[Tm,Iu]))}}ENe.id=Dh.id;pn.register(xCe);pn.register(mu);pn.register(wh);pn.register(Sh);pn.register(Ua);pn.register(nd);pn.register(Ul);pn.register(Wl);pn.register(Tm);pn.register(i7);pn.register(Dh);pn.register(_h);function Jg({cfg:e,onDatapointClick:t,onChartClick:n}){var p;const[r,s]=C.useState(""),o=te(m=>m.selectedLensId),i=C.useRef(null),[a,l]=C.useState(),c=te(m=>m.themeStyle);C.useEffect(()=>{if(i.current){const m=window.getComputedStyle(i.current);s(m.fontFamily)}},[]),C.useEffect(()=>{var y,x,v,w;if(!r)return;(x=(y=c==null?void 0:c.chart)==null?void 0:y.font)!=null&&x.family&&(pn.defaults.font={...pn.defaults.font,...(v=c==null?void 0:c.chart)==null?void 0:v.font,family:r});const m=bm(e);m.options={...e.options,responsive:!0,maintainAspectRatio:!1};const g=(w=i==null?void 0:i.current)==null?void 0:w.getContext("2d");if(!g)return;let b;try{const S=dve(m,g);b=new pn(g,S),l(b)}catch(S){console.log("error creating chart",S)}return()=>{b&&b.destroy()}},[(p=c==null?void 0:c.chart)==null?void 0:p.font,o,r,e]);function d(m){console.log("handleRightClick",m),a&&(n==null||n(m,a,i))}function f(m){var b,y;if(!a)return;n==null||n(m,a,i);const g=a==null?void 0:a.getElementsAtEventForMode(m.nativeEvent,"nearest",{intersect:!0},!0);if(g&&g.length>0){const x=g[0].datasetIndex,v=g[0].index,w=(y=(b=g[0].element)==null?void 0:b.$context)==null?void 0:y.raw;t==null||t(a,x,v,w)}}const h=e.type==="doughnut"||e.type==="pie";return u.jsx("div",{onClick:f,onContextMenu:d,className:K("relative h-[99%] min-w-0 grow",{"mx-14":h}),children:u.jsx("canvas",{ref:i})})}async function jNe(e,t){if(!e||e.trim()==="")throw new Error("URL is required to load component");const r=`${e.endsWith("/")?e:`${e}/`}index.js`;return{default:(await new Function("url","return import(url)")(r))[t]}}async function _Ne(e){try{const t=await import(e),n=Object.keys(t),r=[];return n.forEach(s=>{typeof t[s]=="function"&&(s==null?void 0:s[0])===(s==null?void 0:s[0].toUpperCase())&&r.push({name:s,component:s})}),r}catch(t){return console.error("Error loading the library:",t),[]}}async function LH(e){try{const t=e.endsWith("/")?e:`${e}/`,n=await fetch(`${t}manifest.json`);if(!n.ok)throw new Error(`Failed to fetch manifest: ${n.statusText}`);return await n.json()}catch(t){throw console.error("Error loading manifest:",t),t}}const zH=e=>{const[t,n]=C.useState([]),[r,s]=C.useState(!1),[o,i]=C.useState(null);C.useEffect(()=>{window.React=C,window.ReactDOM=_n,window.React.jsx=zT.jsx,window.React.jsxs=zT.jsxs,s(!0)},[]),C.useEffect(()=>{e&&e.trim()!==""&&r?LH(e).then(c=>{n(c.visuals),i(c)}).catch(()=>{_Ne(e).then(c=>{n(c)}).catch(c=>{console.error("Error loading manifest:",c)})}):(n([]),i(null))},[e,r]);const a=C.useMemo(()=>!e||e.trim()===""||t.length===0?[]:(t==null?void 0:t.map(c=>{const{name:d,component:f,dataInputs:h,chartType:p}=c;return{name:d,chartType:p,componentName:f,Component:C.lazy(()=>jNe(e,f)),type:h&&h.length>1?"multiple":"single"}}))||[],[t,e]);return{getCard:C.useCallback(c=>{const d=a==null?void 0:a.find(f=>f.name===c);return d?d.Component:null},[a]),components:a,manifest:o}};function BH({onLoadingStatus:e,onDataChange:t,card:n}){const{isFetching:r,isLoading:s,data:o,queryKey:i}=Ba(n),a=JSON.stringify(i);return C.useEffect(()=>{e==null||e(s)},[r,s,e]),C.useEffect(()=>{t(n.id,(o==null?void 0:o.records)||[])},[o==null?void 0:o.records,n.id,a,t]),u.jsx(u.Fragment,{})}function PD({card:e,frame:t}){var w,S,N,k,j,_,D,M,T,O,A,P;const[n,r]=C.useState([]),{theme:s}=qE(),{authToken:o}=Ye(),i=M3(o==null?void 0:o.accessToken),a=te(F=>F.themeStyle),l={colors:((S=(w=a==null?void 0:a.chart)==null?void 0:w.dataset)==null?void 0:S.backgroundColor)||[],mode:s||"system"},[c,d]=C.useState(!1),{getCard:f}=zH(((N=e.customCardPreferences)==null?void 0:N.url)||""),h=((k=e.customCardPreferences)==null?void 0:k.visualType)||"single",p=(j=e.customCardPreferences)==null?void 0:j.componentName,{data:m}=Ba(e),g=C.useCallback((F,V)=>{r(U=>({...U,[F]:V}))},[]);if(!p)return null;const b=f(p),y=Object.keys(((_=e.customCardPreferences)==null?void 0:_.dataInputCardIds)||{}).map(F=>{var z,I,B;const V=(I=(z=e.customCardPreferences)==null?void 0:z.dataInputCardIds)==null?void 0:I[F].cardId,U=(B=t==null?void 0:t.cards)==null?void 0:B.find(L=>L.id===V);return U||null});function x(F){d(F)}const v=((M=(D=e.preferences)==null?void 0:D.displayOptions)==null?void 0:M.allowScroll)??!0;return u.jsx("div",{className:K("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",v?"overflow-y-auto":"h-full overflow-hidden"),children:u.jsxs(C.Suspense,{fallback:u.jsx(u.Fragment,{}),children:[b&&h==="single"&&u.jsx(b,{params:i,theme:l,chartSettings:(T=e.customCardPreferences)==null?void 0:T.settings,settings:(O=e.customCardPreferences)==null?void 0:O.settings,onDataChange:g,data:(m==null?void 0:m.records)||[]}),b&&h==="multiple"&&u.jsxs("div",{children:[Object.keys(((A=e.customCardPreferences)==null?void 0:A.dataInputCardIds)||{}).map(F=>{var z,I,B;const V=(I=(z=e.customCardPreferences)==null?void 0:z.dataInputCardIds)==null?void 0:I[F].cardId,U=(B=t==null?void 0:t.cards)==null?void 0:B.find(L=>L.id===V);if(U)return u.jsx(BH,{onLoadingStatus:x,onDataChange:g,dataInputIndex:F,card:U},U.id+F)}),h==="multiple"&&u.jsx("div",{className:K("flex flex-col gap-2",{"opacity-50":c}),children:u.jsx(b,{params:i,theme:l,onDataChange:g,chartSettings:(P=e.customCardPreferences)==null?void 0:P.settings,settings:y.map(F=>{var V;return(V=F==null?void 0:F.customCardPreferences)==null?void 0:V.settings}),data:y.map(F=>F!=null&&F.id?n==null?void 0:n[F.id]:[])})})]})]},e.id)})}function Lw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return u.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[u.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:u.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),u.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),u.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[u.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),Sv]})}function OD({error:e}){return u.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:u.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[u.jsx("p",{className:"text-sm",children:"Something went wrong:"}),u.jsx("pre",{className:"text-xs",children:e.message})]})})}function DNe({error:e,frame:t}){return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[u.jsx(vW,{frame:t,isHovered:!1}),u.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),u.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[u.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),u.jsx("p",{className:"text-sm",children:"Something went wrong:"}),u.jsx("pre",{className:"text-xs",children:e.message})]})]})}const MNe=C.createContext(null),jC={didCatch:!1,error:null};class uc extends C.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=jC}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(jC)}}componentDidCatch(t,n){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&n.error!==null&&TNe(t.resetKeys,s)){var o,i;(o=(i=this.props).onReset)===null||o===void 0||o.call(i,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(jC)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:o,error:i}=this.state;let a=t;if(o){const l={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=C.createElement(r,l);else if(s!==void 0)a=s;else throw i}return C.createElement(MNe.Provider,{value:{didCatch:o,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function TNe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function RNe(e={},t){const{displayPreferences:n,shouldShowElement:r}=nc(),s=n.mode==="table-print",o=e.enabled??!0,i=e.serverSide??!1,a=s?Number.MAX_SAFE_INTEGER:e.pageSize||50,l=e.currentPage!==void 0,[c,d]=C.useState(0),[f,h]=C.useState(a),p=l?(e.currentPage||1)-1:c,m=l?e.pageSize||a:f,g=C.useMemo(()=>o&&r("showPagination")&&!s,[o,r,s]),b=C.useMemo(()=>i?e.pageCount:Math.ceil(t/m),[i,e.pageCount,t,m]),y=C.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),x=C.useMemo(()=>i?(e.currentPage||1)>1:p>0,[i,e.currentPage,p]),v=C.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):p<(b||1)-1,[i,e.currentPage,e.pageCount,p,b]);return{pageIndex:p,pageSize:m,isServerSidePagination:i,showPagination:g,paginationEnabled:o,isTablePrintDisplayMode:s,setPageIndex:j=>{var _;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},setPageSize:j=>{var _;l?(_=e.onPageChange)==null||_.call(e,1,j):(d(0),h(j))},canPreviousPage:x,canNextPage:v,previousPage:()=>{var _;if(!x)return;const j=p-1;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},nextPage:()=>{var _;if(!v)return;const j=p+1;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},pageCount:b,totalCount:y}}function INe(e,t,n){var l;if(!t.length)return e;const r=t[0].id,s=t[0].desc?-1:1,o=((l=n.groupByColumns)==null?void 0:l.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?ANe(e,a,s):PNe(e,r,s,o,n)}function ANe(e,t,n){const r=[...e],s=new Map,o=[];r.forEach(l=>{if(l.isGrandTotal)return;const c=t>0?l.fieldValues.slice(0,t).join("|||"):"root";s.has(c)||(s.set(c,[]),o.push(c)),s.get(c).push(l)});const i=[];o.forEach(l=>{const c=s.get(l),d=c.filter(h=>!h.isSubtotal),f=c.filter(h=>h.isSubtotal);d.sort((h,p)=>{const m=h.fieldValues[t],g=p.fieldValues[t];return m===g?0:m==null?1:g==null?-1:String(m).localeCompare(String(g))*n}),i.push(...d),i.push(...f)});const a=e.find(l=>l.isGrandTotal);return a&&i.push(a),i}function PNe(e,t,n,r,s){const o={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}if(f.isSubtotal){let h=o;for(let p=0;p<r-1;p++){const m=f.fieldValues[p];h.children.has(m)||h.children.set(m,{rows:[],children:new Map}),h=h.children.get(m)}h.subtotal=f}else{let h=o;for(let p=0;p<r-1;p++){const m=f.fieldValues[p];h.children.has(m)||h.children.set(m,{rows:[],children:new Map}),h=h.children.get(m)}h.rows.push(f)}});function a(f){var h;return t==="rowTotal"?s.columnHeaders.reduce((p,m)=>{var b;const g=(b=f.cells[m])==null?void 0:b.value;return p+(typeof g=="number"?g:0)},0):(h=f.cells[t])==null?void 0:h.value}function l(f){let h=0;return f.rows.forEach(p=>{const m=a(p);typeof m=="number"&&(h+=m)}),f.children.forEach(p=>{if(p.subtotal){const m=a(p.subtotal);typeof m=="number"&&(h+=m)}else h+=l(p)}),h}function c(f){const h=[],p=[...f.rows].sort((g,b)=>{const y=a(g),x=a(b);return y===x?0:y==null?1:x==null?-1:y>x?n:-n});return h.push(...p),Array.from(f.children.entries()).sort(([,g],[,b])=>{const y=g.subtotal?a(g.subtotal):l(g),x=b.subtotal?a(b.subtotal):l(b);return y===x?0:y==null?1:x==null?-1:y>x?n:-n}).forEach(([,g])=>{h.push(...c(g))}),f.subtotal&&h.push(f.subtotal),h}const d=c(o);return i&&d.push(i),d}function ONe(e,t){const[n,r]=C.useState([]),s=C.useMemo(()=>INe(e,n,t),[e,n,t]),o=C.useCallback(l=>{r(c=>{const d=c.find(f=>f.id===l);return d?d.desc?[]:[{id:l,desc:!0}]:[{id:l,desc:!1}]})},[]),i=C.useCallback(()=>{r([])},[]),a=C.useCallback(l=>{const c=n.find(d=>d.id===l);return c?c.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:s,toggleColumnSort:o,clearSorting:i,getSortDirection:a}}function Wm(e,t,n,r){if(t){const s=Na(e,t,n,r),o=Efe(e,t);return s==="-"||s===0?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):o?u.jsx("span",{style:{backgroundColor:o.backgroundColor,color:o.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})})}function FNe(e){return(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function $Ne(e,t){const n=(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(s=>s.columnName===e&&(s.subtotalLevel==="grandTotal"||s.subtotalLevel==="ALL")))??!1;return n||r}function LNe({data:e,card:t,table:n,sorting:r,setSorting:s,showRowTotals:o,onAggregationChange:i,onOpenColumnSettings:a}){const[l,c]=C.useState(null),d=te(p=>p.isVisualEditing),f=C.useCallback(p=>{var m;return(m=n.getHeaderGroups()[0])==null?void 0:m.headers.find(g=>g.column.id===p)},[n]);return{buildColumnHeaderRows:C.useCallback(()=>{var k,j;const p=((k=t.config)==null?void 0:k.pivotByColumns)||[],m=p.length,g=((j=e.groupByColumns)==null?void 0:j.length)||1,b=e.columnHeaders.length;function y(_,D,M,T=[]){_.forEach((O,A)=>{var F,V,U;const P=O.level;if(P<m){const z=O.columnKey||`${P}-${T.join("-")}-${O.name}-${A}`,I=O.children?1:m-P,B=`pivot-${z}`,L=l===B;if(M[P].push(u.jsx(ho,{colSpan:O.colspan,rowSpan:I,className:"h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-center text-xs font-medium",children:u.jsxs("div",{className:"group/pivot-header relative flex items-center justify-center",children:[i&&u.jsx("div",{className:K("absolute left-0 overflow-hidden transition-all duration-200",L?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/pivot-header:h-6 group-hover/pivot-header:w-6 group-hover/pivot-header:opacity-100"),children:u.jsx(Cp,{columnName:O.name,groupByFields:e.groupByColumns||[],pivotByFields:((F=t.config)==null?void 0:F.pivotByColumns)||[],currentAggregation:{rowAggregates:(V=t.config)==null?void 0:V.rowAggregates,columnAggregates:(U=t.config)==null?void 0:U.columnAggregates},onAggregationChange:i,onOpenChange:R=>c(R?B:null)})}),u.jsx("span",{className:"whitespace-nowrap",children:O.name})]})},z)),O.children){const R=[...T,O.name];y(O.children,P+1,M,R)}}})}function x(_,D=[]){const M=[];return _.forEach((T,O)=>{var A,P,F,V,U;if(T.columnKey){const z=T.columnKey||`metric-${D.join("-")}-${T.name}-${O}`,I=FNe(T.columnKey),B=$Ne(T.columnKey,e.columnSubtotalMeta),L=n.getColumn(T.columnKey),R=f(T.columnKey);M.push(u.jsx(ho,{"data-column-id":T.columnKey,className:K("group/header h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-right text-xs last:border-r-0",B?"bg-muted font-semibold":I?"bg-muted/70 font-medium":""),style:{width:R==null?void 0:R.getSize(),minWidth:R==null?void 0:R.getSize(),maxWidth:R==null?void 0:R.getSize(),position:"relative",transition:"none"},children:L?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const W=L.getIsSorted();s(W?W==="asc"?[{id:L.id,desc:!0}]:[]:[{id:L.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[T.columnKey])||T.name||"Metric"}`,children:[u.jsx(So,{className:K("mr-1 h-3 w-3",L.getIsSorted()==="asc"?"hidden group-hover/header:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",L.getIsSorted()==="desc"?"hidden group-hover/header:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",L.getIsSorted()?"hidden":"hidden group-hover/header:block")})]}),u.jsx("span",{className:"min-w-0 truncate text-xs font-medium",title:((P=e.columnDisplayNames)==null?void 0:P[T.columnKey])||T.name||"Metric",children:((F=e.columnDisplayNames)==null?void 0:F[T.columnKey])||T.name||"Metric"}),d&&a&&u.jsx(ie,{variant:"ghost",size:"icon",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover/header:opacity-100",onClick:W=>{W.stopPropagation(),a(T.columnKey)},children:u.jsx(ou,{className:"h-3 w-3"})}),R&&u.jsx(Oc,{header:R,isResizing:R.column.getIsResizing()})]}):u.jsx("span",{className:"block truncate px-2",title:((V=e.columnDisplayNames)==null?void 0:V[T.columnKey])||T.name||"Metric",children:((U=e.columnDisplayNames)==null?void 0:U[T.columnKey])||T.name||"Metric"})},z))}else if(T.children){const z=[...D,T.name];M.push(...x(T.children,z))}}),M}const v=u.jsxs(ls,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,D)=>{var P,F,V,U,z;const M=(P=n.getHeaderGroups()[0])==null?void 0:P.headers.find(I=>I.column.id===`rowLevel${D}`),T=M==null?void 0:M.getSize(),O=`row-header-${D}`,A=l===O;return u.jsx(ho,{rowSpan:m+2,"data-column-id":`rowLevel${D}`,className:"group/rowheader h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-left align-bottom text-xs font-medium",style:{width:T,minWidth:T,maxWidth:T,position:"relative",transition:"none"},children:u.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between pb-1",children:[u.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",A?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/rowheader:h-6 group-hover/rowheader:w-6 group-hover/rowheader:opacity-100"),children:u.jsx(Cp,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:p,currentAggregation:{rowAggregates:(F=t.config)==null?void 0:F.rowAggregates,columnAggregates:(V=t.config)==null?void 0:V.columnAggregates},onAggregationChange:i,onOpenChange:I=>c(I?O:null)})}),u.jsxs(ie,{variant:"ghost",className:K("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&(A?"pl-7":"group-hover/rowheader:pl-7")),onClick:I=>{I.stopPropagation(),I.preventDefault(),s(B=>{const L=B.find(R=>R.id===`rowLevel${D}`);return L?L.desc?[]:[{id:`rowLevel${D}`,desc:!0}]:[{id:`rowLevel${D}`,desc:!1}]})},children:[u.jsx("span",{className:"truncate text-xs font-medium",title:_.label||_.name,children:_.label||_.name}),u.jsx(So,{className:K("h-3 w-3 flex-shrink-0",((U=r.find(I=>I.id===`rowLevel${D}`))==null?void 0:U.desc)===!1?"hidden group-hover/rowheader:block":"hidden")}),u.jsx(Ni,{className:K("h-3 w-3 flex-shrink-0",((z=r.find(I=>I.id===`rowLevel${D}`))==null?void 0:z.desc)===!0?"hidden group-hover/rowheader:block":"hidden")}),u.jsx(Rc,{className:K("h-3 w-3 flex-shrink-0",r.find(I=>I.id===`rowLevel${D}`)?"hidden":"hidden group-hover/rowheader:block")})]})]}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]})},`row-header-corner-${D}`)}):u.jsx(ho,{colSpan:g,rowSpan:m+2,className:"h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-xs",children:""}),u.jsx(ho,{colSpan:b,className:"h-8 whitespace-nowrap border-b bg-muted px-3 py-1 text-xs font-bold",children:u.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var M,T;const _="pivot-main",D=l===_;return u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",D?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/pivot-main:h-6 group-hover/pivot-main:w-6 group-hover/pivot-main:opacity-100"),children:u.jsx(Cp,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:p,currentAggregation:{rowAggregates:(M=t.config)==null?void 0:M.rowAggregates,columnAggregates:(T=t.config)==null?void 0:T.columnAggregates},onAggregationChange:i,onOpenChange:O=>c(O?_:null)})})})(),u.jsx("div",{className:K("transition-all duration-200",i&&(l==="pivot-main"?"pl-7":"group-hover/pivot-main:pl-7")),children:p.map((_,D)=>u.jsxs("span",{className:"inline-flex items-center",children:[_.label,D<p.length-1&&u.jsx(La,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},_.id))})]})},"pivot-hierarchy"),o&&(()=>{var M;const _=(M=n.getHeaderGroups()[0])==null?void 0:M.headers.find(T=>T.column.id==="rowTotal"),D=_==null?void 0:_.getSize();return u.jsx(ho,{"data-column-id":"rowTotal",className:"group/total h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-center text-xs",rowSpan:m+2,style:{width:D,minWidth:D,maxWidth:D,position:"relative",transition:"none"},children:(()=>{const T=n.getColumn("rowTotal");return T?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const O=T.getIsSorted();s(O?O==="asc"?[{id:T.id,desc:!0}]:[]:[{id:T.id,desc:!1}])},"aria-label":"Sort Total",children:[u.jsx(So,{className:K("mr-1 h-3 w-3",T.getIsSorted()==="asc"?"hidden group-hover/total:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",T.getIsSorted()==="desc"?"hidden group-hover/total:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",T.getIsSorted()?"hidden":"hidden group-hover/total:block")})]}),u.jsx("span",{className:"truncate text-xs font-medium",title:"Total",children:"Total"}),_&&u.jsx(Oc,{header:_,isResizing:_.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),w=[];if(e.columnGroups&&e.columnGroups.length>0){const _=Array.from({length:m},()=>[]);y(e.columnGroups,0,_,[]);for(let D=0;D<m;D++)w.push(u.jsx(ls,{"data-header-type":"pivot-values","data-header-row-index":D+1,"data-repeat-header":"true",children:_[D]},`pivot-row-${D}`))}let S=[];e.columnGroups&&e.columnGroups.length>0?S=x(e.columnGroups,[]):e.columnHeaders.forEach(_=>{var T,O,A,P,F,V;const D=n.getColumn(_),M=(T=n.getHeaderGroups()[0])==null?void 0:T.headers.find(U=>U.column.id===_);S.push(u.jsx(ho,{"data-column-id":_,className:"group/colheader h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-right text-xs last:border-r-0",style:{width:M==null?void 0:M.getSize(),minWidth:M==null?void 0:M.getSize(),maxWidth:M==null?void 0:M.getSize(),position:"relative",transition:"none"},children:D?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const U=D.getIsSorted();s(U?U==="asc"?[{id:D.id,desc:!0}]:[]:[{id:D.id,desc:!1}])},"aria-label":`Sort ${((O=e.columnDisplayNames)==null?void 0:O[_])||_}`,children:[u.jsx(So,{className:K("mr-1 h-3 w-3",D.getIsSorted()==="asc"?"hidden group-hover/colheader:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",D.getIsSorted()==="desc"?"hidden group-hover/colheader:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",D.getIsSorted()?"hidden":"hidden group-hover/colheader:block")})]}),u.jsx("span",{className:"min-w-0 truncate text-xs font-medium",title:((A=e.columnDisplayNames)==null?void 0:A[_])||_,children:((P=e.columnDisplayNames)==null?void 0:P[_])||_}),d&&a&&u.jsx(ie,{variant:"ghost",size:"icon",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover/colheader:opacity-100",onClick:U=>{U.stopPropagation(),a(_)},children:u.jsx(ou,{className:"h-3 w-3"})}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]}):u.jsx("span",{className:"block truncate px-2",title:((F=e.columnDisplayNames)==null?void 0:F[_])||_,children:((V=e.columnDisplayNames)==null?void 0:V[_])||_})},_))});const N=u.jsxs(ls,{"data-header-type":"metrics","data-header-row-index":m>0?m+1:0,"data-repeat-header":"true",children:[m===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,D)=>{var P,F,V,U;const M=(P=n.getHeaderGroups()[0])==null?void 0:P.headers.find(z=>z.column.id===`rowLevel${D}`),T=M==null?void 0:M.getSize(),O=`metric-row-${D}`,A=l===O;return u.jsx(ho,{"data-column-id":`rowLevel${D}`,className:"group/metricrow h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-left text-xs font-medium",style:{width:T,minWidth:T,maxWidth:T,position:"relative",transition:"none"},children:u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",A?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/metricrow:h-6 group-hover/metricrow:w-6 group-hover/metricrow:opacity-100"),children:u.jsx(Cp,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:((F=t.config)==null?void 0:F.pivotByColumns)||[],currentAggregation:{rowAggregates:(V=t.config)==null?void 0:V.rowAggregates,columnAggregates:(U=t.config)==null?void 0:U.columnAggregates},onAggregationChange:i,onOpenChange:z=>c(z?O:null)})}),u.jsxs(ie,{variant:"ghost",className:K("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&(A?"pl-7":"group-hover/metricrow:pl-7")),onClick:()=>{s(z=>{const I=z.find(B=>B.id===`rowLevel${D}`);return I?I.desc===!1?[{id:`rowLevel${D}`,desc:!0}]:[]:[{id:`rowLevel${D}`,desc:!1}]})},children:[u.jsx("span",{className:"truncate text-xs font-medium",title:_.label||_.name,children:_.label||_.name}),(()=>{const z=r.find(I=>I.id===`rowLevel${D}`);return u.jsxs(u.Fragment,{children:[u.jsx(Rc,{className:K("h-3 w-3 flex-shrink-0",z?"hidden":"hidden group-hover/metricrow:block")}),u.jsx(Ni,{className:K("h-3 w-3 flex-shrink-0",(z==null?void 0:z.desc)===!0?"hidden group-hover/metricrow:block":"hidden")}),u.jsx(So,{className:K("h-3 w-3 flex-shrink-0",(z==null?void 0:z.desc)===!1?"hidden group-hover/metricrow:block":"hidden")})]})})()]})]}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]})},`row-header-title-${D}`)}):Array.from({length:g}).map((_,D)=>u.jsx(ho,{className:"h-8 whitespace-nowrap border-b border-r bg-muted py-1 text-left text-xs font-medium",children:`Level ${D+1}`},`empty-header-metric-${D}`))),S]},"metric-row");return m>0?[v,...w,N]:[N]},[e,t,n,r,s,o,i,f,l,c,d,a])}}function zNe(e,t,n){var v,w;const r=te(S=>S.isVisualEditing);te(S=>S.isDashboardEditing),te(S=>S.selectedSheetId);const{updateCurrentDashboardCard:s,updateFrame:o}=Qt(),i=Ae(S=>{var N;return(N=S.actions)==null?void 0:N.setCardPreferences}),a=Ae(S=>S.card),l=C.useMemo(()=>{var S,N;return((N=(S=e==null?void 0:e.preferences)==null?void 0:S.tablePrefs)==null?void 0:N.columnSettingsMap)||{}},[(w=(v=e==null?void 0:e.preferences)==null?void 0:v.tablePrefs)==null?void 0:w.columnSettingsMap]),[c,d]=C.useState(!1),[f,h]=C.useState(null),[p,m]=C.useState(No()),g=C.useCallback(S=>{h(S);let N=l[S];if(!N){const k=t==null?void 0:t.map(j=>{var _,D;return{[S]:(D=(_=j.cells)==null?void 0:_[S])==null?void 0:D.value}});N=k&&k.length>0?Vm(S,k,n):No()}m(N),d(!0)},[l,t,n]),b=C.useCallback(()=>{var S,N;if(f&&p){const k={...l,[f]:p};if(r&&i){const j={...a.preferences,tablePrefs:{...(S=a.preferences)==null?void 0:S.tablePrefs,columnSettingsMap:k}};i(j)}else if(s){const j={...e,preferences:{...e.preferences,tablePrefs:{...(N=e.preferences)==null?void 0:N.tablePrefs,columnSettingsMap:k}}};s(j)}}d(!1)},[f,p,l,r,i,a,s,e]),y=C.useCallback(()=>{f&&m(No())},[f]),x=C.useCallback(()=>{var S,N;if(r&&i){const k={...a.preferences,tablePrefs:{...(S=a.preferences)==null?void 0:S.tablePrefs,columnSettingsMap:{}}};i(k)}else if(s){const k={...e,preferences:{...e.preferences,tablePrefs:{...(N=e.preferences)==null?void 0:N.tablePrefs,columnSettingsMap:{}}}};s(k)}d(!1)},[r,i,a,s,e]);return{columnSettings:l,columnSettingsOpen:c,activeColumnId:f,tempColumnSettings:p,isVisualEditing:r,openColumnSettings:g,applyColumnSettings:b,resetColumnSettings:y,resetAllColumnSettings:x,setColumnSettingsOpen:d,setTempColumnSettings:m}}function BNe({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:s,isTablePrintDisplayMode:o=!1,columnSettings:i}){var c;const a=e.getRowModel().rows,l=((c=t.groupByColumns)==null?void 0:c.length)||1;return a!=null&&a.length?u.jsx(u.Fragment,{children:a.map((d,f)=>{const h=d.original,p=e.getRowModel().rows,m=f===p.length-1;return u.jsx(ls,{className:K("h-8 border-b-0",h.isSubtotal&&"border-t border-t-border/50 bg-muted/70 font-medium"),"data-row-type":h.isSubtotal?"subtotal":"data","data-row-index":f,...h.isSubtotal&&{"data-subtotal-level":h.subtotalLevel},children:d.getVisibleCells().map(g=>{var v;const b=g.column.id;if(b.startsWith("rowLevel")){const w=parseInt(b.replace("rowLevel",""));if(h.isSubtotal&&h.subtotalLevel){const N=((v=t.groupByColumns)==null?void 0:v.findIndex(k=>(k.alias||k.name)===h.subtotalLevel))??-1;return w===N?u.jsx(Ln,{colSpan:o?1:l-w,className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-medium",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id):w<N?u.jsx(Ln,{className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-medium",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id):o?u.jsx(Ln,{className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs",!m&&"border-b")},g.id):null}if(!o&&f>0)for(let N=f-1;N>=0;N--){const k=p[N].original;if(k.isSubtotal||k.isGrandTotal)break;let j=!0;for(let _=0;_<=w;_++)if(h.fieldValues[_]!==k.fieldValues[_]){j=!1;break}if(j)return null}let S=1;if(!o)for(let N=f+1;N<p.length;N++){const k=p[N].original;if(k.isSubtotal||k.isGrandTotal)break;let j=!0;for(let _=0;_<=w;_++)if(h.fieldValues[_]!==k.fieldValues[_]){j=!1;break}if(j)S++;else break}return u.jsx(Ln,{rowSpan:S,className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id)}const y=s.has(b),x=r.has(b);return u.jsx(Ln,{"data-column-id":b,className:K("h-8 border-r px-3 py-1 text-xs last:border-r-0",!m&&"border-b",y?"bg-muted/50":x?"bg-muted/30":void 0),style:{width:g.column.getSize(),minWidth:g.column.getSize(),maxWidth:g.column.getSize(),transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.isSubtotal&&(i!=null&&i[b])?Wm(g.getValue(),i[b]):Es(g.column.columnDef.cell,g.getContext())},g.id)})},d.id)})}):u.jsx(ls,{className:"h-8",children:u.jsx(Ln,{colSpan:n.length,className:"text-center",children:"No results."})})}function Do({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:s,displayClassName:o,isEditable:i=!0,isPending:a=!1}){const[l,c]=C.useState(!1),[d,f]=C.useState(e||""),h=()=>{c(!1),d!==e&&n(d)},p=m=>{m.key==="Enter"?(c(!1),n(d)):m.key==="Escape"&&(c(!1),f(e||""))};return l?u.jsx("div",{className:"flex",children:u.jsx("input",{type:"text",value:d,onChange:m=>f(m.target.value),onBlur:h,onKeyDown:p,className:K("w-full border-b border-dashed focus:border-primary focus:outline-none",s),autoFocus:!0})}):u.jsxs("div",{className:K("relative cursor-pointer truncate",o,{"cursor-default":!i,"hover:text-primary":i}),onClick:()=>{!i||a||(c(!0),f(e||""))},title:t?e||r:void 0,children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("span",{className:"truncate",children:e||u.jsx("span",{className:"text-muted-foreground",children:r})}),a&&u.jsx(cs,{className:"h-3 w-3 flex-shrink-0 animate-spin text-muted-foreground"})]}),a&&u.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function VNe({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:s,columnSettings:o,onAggregationLabelChange:i}){return e.length===0?null:u.jsx(u.Fragment,{children:e.map((a,l)=>{var c;return u.jsxs(ls,{className:"h-8 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":l,children:[u.jsx(Ln,{colSpan:((c=t.groupByColumns)==null?void 0:c.length)||1,className:"h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-semibold",children:i?u.jsx(Do,{value:(()=>{var h,p,m;const d=a.aggregateFunction||"SUM";return((m=(p=(h=n.config)==null?void 0:h.rowAggregates)==null?void 0:p.find(g=>g.function===d&&g.groupLevel==="ALL"))==null?void 0:m.label)||a.fieldValues[0]})(),placeholder:a.fieldValues[0],onSave:d=>{const f=a.aggregateFunction||"SUM";i({type:"row",level:"ALL",function:f,label:d})},displayClassName:"text-right"}):a.fieldValues[0]}),t.columnHeaders.map(d=>{var h,p;const f=(h=r.getHeaderGroups()[0])==null?void 0:h.headers.find(m=>m.column.id===d);return u.jsx(Ln,{"data-column-id":d,className:"h-8 border-r px-3 py-1 text-right text-xs last:border-r-0",style:{width:f==null?void 0:f.getSize(),minWidth:f==null?void 0:f.getSize(),maxWidth:f==null?void 0:f.getSize(),transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Wm((p=a.cells[d])==null?void 0:p.value,o==null?void 0:o[d])},d)}),s&&(()=>{var h;const d=(h=r.getHeaderGroups()[0])==null?void 0:h.headers.find(p=>p.column.id==="rowTotal"),f=d==null?void 0:d.getSize();return u.jsx(Ln,{className:"h-8 px-3 py-1 text-right text-xs font-medium","data-column-id":"rowTotal",style:{width:f,minWidth:f,maxWidth:f,transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Wm(Y8(a,t.columnHeaders))})})()]},a.id)})})}function HNe({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1}){const s=[];return e&&e.length>0?e.forEach((o,i)=>{s.push({id:`rowLevel${i}`,header:()=>u.jsx("div",{className:"group border border-border px-3 py-1 text-left font-medium text-muted-foreground",children:u.jsx("div",{className:"flex items-center gap-1",children:u.jsx("span",{className:"whitespace-nowrap",children:o.label||o.name})})}),accessorFn:a=>a.fieldValues[i],cell:({row:a,table:l})=>{const c=a.original;if(c.isSubtotal&&c.subtotalLevel){const p=(e==null?void 0:e.findIndex(m=>(m.alias||m.name)===c.subtotalLevel))??-1;if(i===p){const m=c.fieldValues[i];return u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs font-medium",style:{gridColumn:`span ${t-i}`},children:m.includes(" Total")&&n?u.jsx(Do,{value:m,placeholder:m,onSave:g=>{const b=c.aggregateFunction||"SUM";if(c.subtotalLevel&&e){const y=e.find(x=>(x.alias||x.name)===c.subtotalLevel);y&&n({type:"row",level:y.id,function:b,label:g})}},displayClassName:"text-left"}):m})}else if(i<p)return u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs font-medium",children:c.fieldValues[i]});return r?u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs"}):null}const d=l.getRowModel().rows,f=d.findIndex(p=>p.id===a.id);if(!r&&f>0)for(let p=f-1;p>=0;p--){const m=d[p].original;if(m.isSubtotal||m.isGrandTotal)break;let g=!0;for(let b=0;b<=i;b++)if(c.fieldValues[b]!==m.fieldValues[b]){g=!1;break}if(g)return null}let h=1;if(!r)for(let p=f+1;p<d.length;p++){const m=d[p].original;if(m.isSubtotal||m.isGrandTotal)break;let g=!0;for(let b=0;b<=i;b++)if(c.fieldValues[b]!==m.fieldValues[b]){g=!1;break}if(g)h++;else break}return u.jsx("div",{className:"whitespace-nowrap px-0 py-1 align-top text-xs",style:{gridRow:r?void 0:`span ${h}`},children:c.fieldValues[i]})}})}):s.push({id:"rowHeader",header:()=>u.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:o=>o.rowKey,cell:({getValue:o})=>u.jsx("div",{className:"min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",children:String(o())})}),s}function UNe({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,contextTimezone:s,browserTimezone:o}){return e.map(i=>({id:i,accessorFn:a=>{var l;return(l=a.cells[i])==null?void 0:l.value},header:({column:a})=>{const l=(t==null?void 0:t[i])||i;return u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsx(ie,{variant:"ghost",className:"h-auto p-0 hover:bg-transparent",onClick:()=>{const c=a.getIsSorted();n(c?c==="asc"?[{id:a.id,desc:!0}]:[]:[{id:a.id,desc:!1}])},"aria-label":`Sort ${l}`,children:a.getIsSorted()==="asc"?u.jsx(So,{className:"mr-1 h-3 w-3"}):a.getIsSorted()==="desc"?u.jsx(Ni,{className:"mr-1 h-3 w-3"}):u.jsx(Rc,{className:"mr-1 h-3 w-3 opacity-0 group-hover:opacity-100"})}),u.jsx("span",{className:"text-xs font-medium",children:l})]})},cell:({getValue:a})=>{const l=a(),c=r==null?void 0:r[i],d=(c==null?void 0:c.textAlign)||"right",f=d==="left"?"text-left":d==="center"?"text-center":"text-right";return u.jsx("div",{className:`text-xs ${f}`,children:Wm(l,c,s,o)})}}))}function WNe({columnHeaders:e,setSorting:t}){return{id:"rowTotal",header:({column:n})=>u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsx(ie,{variant:"ghost",className:"h-auto p-0 hover:bg-transparent",onClick:()=>{const r=n.getIsSorted();t(r?r==="asc"?[{id:n.id,desc:!0}]:[]:[{id:n.id,desc:!1}])},"aria-label":"Sort Total",children:n.getIsSorted()==="asc"?u.jsx(So,{className:"mr-1 h-3 w-3"}):n.getIsSorted()==="desc"?u.jsx(Ni,{className:"mr-1 h-3 w-3"}):u.jsx(Rc,{className:"mr-1 h-3 w-3 opacity-0 group-hover:opacity-100"})}),u.jsx("span",{className:"text-xs font-medium",children:"Total"})]}),cell:({row:n})=>{const r=n.original,s=Y8(r,e);return u.jsx("div",{className:"text-right text-xs font-medium",children:Wm(s)})}}}function eb({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:s}){var z,I,B;const o=te(L=>L.themeStyle),{displayPreferences:i,shouldShowElement:a}=nc(),l=i.mode==="table-print",c=n.showRowTotals??!1,{columnSizing:d,onColumnSizingChange:f}=kD({card:t}),{subtotalColumnKeys:h,grandTotalColumnKeys:p}=C.useMemo(()=>Iue(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:m,grandTotalRows:g}=C.useMemo(()=>v_(e),[e]),{sorting:b,setSorting:y,sortedTableData:x}=ONe(m,e),{columnSettings:v,columnSettingsOpen:w,activeColumnId:S,tempColumnSettings:N,openColumnSettings:k,applyColumnSettings:j,resetColumnSettings:_,resetAllColumnSettings:D,setColumnSettingsOpen:M,setTempColumnSettings:T}=zNe(t,x,e.columnMetadata),O={...n.pagination},A=RNe(O,x.length),P=C.useMemo(()=>{var Z;const L=[],R=((Z=e.groupByColumns)==null?void 0:Z.length)||1,W=HNe({groupByColumns:e.groupByColumns,numRowLevels:R,onAggregationLabelChange:s,isTablePrintDisplayMode:l});L.push(...W);const Y=UNe({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:y,columnSettings:v,contextTimezone:void 0,browserTimezone:typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0});if(L.push(...Y),c){const H=WNe({columnHeaders:e.columnHeaders,setSorting:y});L.push(H)}return L},[e,c,s,y,l,v]),F=dD({data:x,columns:P,state:{sorting:b,columnSizing:d,pagination:{pageIndex:A.pageIndex,pageSize:A.pageSize}},onSortingChange:y,onPaginationChange:void 0,getCoreRowModel:cD(),getPaginationRowModel:!A.isServerSidePagination&&!A.isTablePrintDisplayMode?uD():void 0,manualPagination:A.isServerSidePagination||A.isTablePrintDisplayMode,manualSorting:!0,pageCount:A.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f}),{buildColumnHeaderRows:V}=LNe({data:e,card:t,table:F,sorting:b,setSorting:y,showRowTotals:c,onAggregationChange:r,onOpenColumnSettings:k}),U=V();return u.jsxs("div",{className:"flex h-full w-full flex-col gap-4",children:[u.jsxs(rd,{style:{borderRadius:o==null?void 0:o.cardBorderRadius},className:"relative h-full rounded-none border",onMouseDown:L=>L.stopPropagation(),children:[u.jsxs("table",{className:"w-full border-separate border-spacing-0 bg-background text-sm",onMouseDown:L=>L.stopPropagation(),"data-pivot-table":"true","data-row-levels":((z=e.groupByColumns)==null?void 0:z.length)||1,"data-pivot-levels":e.columnGroups&&((B=(I=t.config)==null?void 0:I.pivotByColumns)==null?void 0:B.length)||0,children:[u.jsx(_w,{className:"sticky top-0 z-20 bg-background",children:U}),u.jsx(Lm,{children:u.jsx(BNe,{table:F,data:e,columns:P,subtotalColumnKeys:h,grandTotalColumnKeys:p,isTablePrintDisplayMode:l,columnSettings:v})}),g.length>0&&u.jsx("tfoot",{className:"sticky bottom-0 z-10 border-t-2 border-t-border bg-muted","data-grandtotal":"true",children:u.jsx(VNe,{grandTotalRows:g,data:e,card:t,table:F,showRowTotals:c,columnSettings:v,onAggregationLabelChange:s})})]}),u.jsx(Wa,{orientation:"horizontal"}),u.jsx(Wa,{orientation:"vertical"})]}),A.showPagination&&u.jsx(pD,{totalColumns:P.length,pageCount:A.pageCount||F.getPageCount(),pageIndex:A.pageIndex,pageSize:A.pageSize,rowCount:A.totalCount,selectedRowCount:0,setPageIndex:A.setPageIndex,setPageSize:A.setPageSize,canPreviousPage:A.canPreviousPage,canNextPage:A.canNextPage,previousPage:A.previousPage,nextPage:A.nextPage,onClearSelection:()=>{}}),S&&u.jsx(ND,{column:F.getColumn(S)||null,settings:N,onSettingsChange:T,onApply:j,onReset:_,onResetAll:D,open:w,onOpenChange:M})]})}function qNe({isOpen:e,onClose:t,frame:n,card:r,data:s}){var k;const[o,i]=C.useState(!1),a=te(j=>j.isDownloadingPdf),{isError:l,isLoading:c,isFetching:d,cfg:f,data:h,handleDatapointClick:p,pagination:m}=Wg(r),{customCards:g,placeholders:b}=Ye(),y=Ch(r,h),x=()=>{var _,D,M,T,O,A,P;const j=h||s;if(j!=null&&j.records&&j.records.length>0)if((r==null?void 0:r.type)==="aggregateTable"){const F=j.records.find(z=>z.isGrandTotal),V=j.records.filter(z=>!z.isGrandTotal),U=H8(V,F,j.groupByColumns||[],j.pivotSchema||[],r,(D=(_=r==null?void 0:r.preferences)==null?void 0:_.tablePrefs)==null?void 0:D.columnSettingsMap);Qx(U,`${(r==null?void 0:r.title)||"export"}.csv`)}else if((r==null?void 0:r.type)==="pivotTable"&&y)r9(y.data,r,`${(r==null?void 0:r.title)||"export"}.csv`,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0,showRowTotals:(M=y.options)==null?void 0:M.showRowTotals});else if((r==null?void 0:r.type)==="table"){const F=((O=(T=r==null?void 0:r.preferences)==null?void 0:T.tablePrefs)==null?void 0:O.columnSettingsMap)||{},V=((P=(A=r==null?void 0:r.preferences)==null?void 0:A.tablePrefs)==null?void 0:P.columnVisibility)||{},z=Object.keys(j.records[0]||{}).filter(I=>V[I]!==!1);Ave(j.records,F,z,`${(r==null?void 0:r.title)||"export"}.csv`,void 0,Intl.DateTimeFormat().resolvedOptions().timeZone)}else{const F=[],V=Object.keys(j.records[0]);F.push(V.join(","));for(const z of j.records){const I=V.map(B=>`"${(""+z[B]).replace(/"/g,'""')}"`);F.push(I.join(","))}const U=F.join(`
885
+ ${(e*100).toLocaleString()}%`}}},scales:{_index_:{display:!1,padding:10,grid:{display:!1}},_value_:{display:!1,beginAtZero:!1,grace:0,grid:{display:!1}}},elements:{trapezoid:{backgroundColor(e){const t=e.chart.data.datasets[e.datasetIndex].data.length;return NNe(e.dataIndex,t)}}}}]);class ENe extends pn{constructor(t,n){super(t,kNe("funnel",n,Dh,_h,[Tm,Iu]))}}ENe.id=Dh.id;pn.register(xCe);pn.register(mu);pn.register(wh);pn.register(Sh);pn.register(Ua);pn.register(nd);pn.register(Ul);pn.register(Wl);pn.register(Tm);pn.register(i7);pn.register(Dh);pn.register(_h);function Jg({cfg:e,onDatapointClick:t,onChartClick:n}){var p;const[r,s]=C.useState(""),o=te(m=>m.selectedLensId),i=C.useRef(null),[a,l]=C.useState(),c=te(m=>m.themeStyle);C.useEffect(()=>{if(i.current){const m=window.getComputedStyle(i.current);s(m.fontFamily)}},[]),C.useEffect(()=>{var y,x,v,w;if(!r)return;(x=(y=c==null?void 0:c.chart)==null?void 0:y.font)!=null&&x.family&&(pn.defaults.font={...pn.defaults.font,...(v=c==null?void 0:c.chart)==null?void 0:v.font,family:r});const m=bm(e);m.options={...e.options,responsive:!0,maintainAspectRatio:!1};const g=(w=i==null?void 0:i.current)==null?void 0:w.getContext("2d");if(!g)return;let b;try{const S=dve(m,g);b=new pn(g,S),l(b)}catch(S){console.log("error creating chart",S)}return()=>{b&&b.destroy()}},[(p=c==null?void 0:c.chart)==null?void 0:p.font,o,r,e]);function d(m){console.log("handleRightClick",m),a&&(n==null||n(m,a,i))}function f(m){var b,y;if(!a)return;n==null||n(m,a,i);const g=a==null?void 0:a.getElementsAtEventForMode(m.nativeEvent,"nearest",{intersect:!0},!0);if(g&&g.length>0){const x=g[0].datasetIndex,v=g[0].index,w=(y=(b=g[0].element)==null?void 0:b.$context)==null?void 0:y.raw;t==null||t(a,x,v,w)}}const h=e.type==="doughnut"||e.type==="pie";return u.jsx("div",{onClick:f,onContextMenu:d,className:K("relative h-[99%] min-w-0 grow",{"mx-14":h}),children:u.jsx("canvas",{ref:i})})}async function jNe(e,t){if(!e||e.trim()==="")throw new Error("URL is required to load component");const r=`${e.endsWith("/")?e:`${e}/`}index.js`;return{default:(await new Function("url","return import(url)")(r))[t]}}async function _Ne(e){try{const t=await import(e),n=Object.keys(t),r=[];return n.forEach(s=>{typeof t[s]=="function"&&(s==null?void 0:s[0])===(s==null?void 0:s[0].toUpperCase())&&r.push({name:s,component:s})}),r}catch(t){return console.error("Error loading the library:",t),[]}}async function LH(e){try{const t=e.endsWith("/")?e:`${e}/`,n=await fetch(`${t}manifest.json`);if(!n.ok)throw new Error(`Failed to fetch manifest: ${n.statusText}`);return await n.json()}catch(t){throw console.error("Error loading manifest:",t),t}}const zH=e=>{const[t,n]=C.useState([]),[r,s]=C.useState(!1),[o,i]=C.useState(null);C.useEffect(()=>{window.React=C,window.ReactDOM=_n,window.React.jsx=zT.jsx,window.React.jsxs=zT.jsxs,s(!0)},[]),C.useEffect(()=>{e&&e.trim()!==""&&r?LH(e).then(c=>{n(c.visuals),i(c)}).catch(()=>{_Ne(e).then(c=>{n(c)}).catch(c=>{console.error("Error loading manifest:",c)})}):(n([]),i(null))},[e,r]);const a=C.useMemo(()=>!e||e.trim()===""||t.length===0?[]:(t==null?void 0:t.map(c=>{const{name:d,component:f,dataInputs:h,chartType:p}=c;return{name:d,chartType:p,componentName:f,Component:C.lazy(()=>jNe(e,f)),type:h&&h.length>1?"multiple":"single"}}))||[],[t,e]);return{getCard:C.useCallback(c=>{const d=a==null?void 0:a.find(f=>f.name===c);return d?d.Component:null},[a]),components:a,manifest:o}};function BH({onLoadingStatus:e,onDataChange:t,card:n}){const{isFetching:r,isLoading:s,data:o,queryKey:i}=Ba(n),a=JSON.stringify(i);return C.useEffect(()=>{e==null||e(s)},[r,s,e]),C.useEffect(()=>{t(n.id,(o==null?void 0:o.records)||[])},[o==null?void 0:o.records,n.id,a,t]),u.jsx(u.Fragment,{})}function PD({card:e,frame:t}){var w,S,N,k,j,_,D,M,T,O,A,P;const[n,r]=C.useState([]),{theme:s}=qE(),{authToken:o}=Ye(),i=M3(o==null?void 0:o.accessToken),a=te(F=>F.themeStyle),l={colors:((S=(w=a==null?void 0:a.chart)==null?void 0:w.dataset)==null?void 0:S.backgroundColor)||[],mode:s||"system"},[c,d]=C.useState(!1),{getCard:f}=zH(((N=e.customCardPreferences)==null?void 0:N.url)||""),h=((k=e.customCardPreferences)==null?void 0:k.visualType)||"single",p=(j=e.customCardPreferences)==null?void 0:j.componentName,{data:m}=Ba(e),g=C.useCallback((F,V)=>{r(U=>({...U,[F]:V}))},[]);if(!p)return null;const b=f(p),y=Object.keys(((_=e.customCardPreferences)==null?void 0:_.dataInputCardIds)||{}).map(F=>{var z,I,B;const V=(I=(z=e.customCardPreferences)==null?void 0:z.dataInputCardIds)==null?void 0:I[F].cardId,U=(B=t==null?void 0:t.cards)==null?void 0:B.find(L=>L.id===V);return U||null});function x(F){d(F)}const v=((M=(D=e.preferences)==null?void 0:D.displayOptions)==null?void 0:M.allowScroll)??!0;return u.jsx("div",{className:K("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",v?"overflow-y-auto":"h-full overflow-hidden"),children:u.jsxs(C.Suspense,{fallback:u.jsx(u.Fragment,{}),children:[b&&h==="single"&&u.jsx(b,{params:i,theme:l,chartSettings:(T=e.customCardPreferences)==null?void 0:T.settings,settings:(O=e.customCardPreferences)==null?void 0:O.settings,onDataChange:g,data:(m==null?void 0:m.records)||[]}),b&&h==="multiple"&&u.jsxs("div",{children:[Object.keys(((A=e.customCardPreferences)==null?void 0:A.dataInputCardIds)||{}).map(F=>{var z,I,B;const V=(I=(z=e.customCardPreferences)==null?void 0:z.dataInputCardIds)==null?void 0:I[F].cardId,U=(B=t==null?void 0:t.cards)==null?void 0:B.find(L=>L.id===V);if(U)return u.jsx(BH,{onLoadingStatus:x,onDataChange:g,dataInputIndex:F,card:U},U.id+F)}),h==="multiple"&&u.jsx("div",{className:K("flex flex-col gap-2",{"opacity-50":c}),children:u.jsx(b,{params:i,theme:l,onDataChange:g,chartSettings:(P=e.customCardPreferences)==null?void 0:P.settings,settings:y.map(F=>{var V;return(V=F==null?void 0:F.customCardPreferences)==null?void 0:V.settings}),data:y.map(F=>F!=null&&F.id?n==null?void 0:n[F.id]:[])})})]})]},e.id)})}function Lw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return u.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[u.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:u.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),u.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),u.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[u.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),Sv]})}function OD({error:e}){return u.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:u.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[u.jsx("p",{className:"text-sm",children:"Something went wrong:"}),u.jsx("pre",{className:"text-xs",children:e.message})]})})}function DNe({error:e,frame:t}){return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[u.jsx(vW,{frame:t,isHovered:!1}),u.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),u.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[u.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),u.jsx("p",{className:"text-sm",children:"Something went wrong:"}),u.jsx("pre",{className:"text-xs",children:e.message})]})]})}const MNe=C.createContext(null),jC={didCatch:!1,error:null};class uc extends C.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=jC}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(jC)}}componentDidCatch(t,n){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&n.error!==null&&TNe(t.resetKeys,s)){var o,i;(o=(i=this.props).onReset)===null||o===void 0||o.call(i,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(jC)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:o,error:i}=this.state;let a=t;if(o){const l={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=C.createElement(r,l);else if(s!==void 0)a=s;else throw i}return C.createElement(MNe.Provider,{value:{didCatch:o,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function TNe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function RNe(e={},t){const{displayPreferences:n,shouldShowElement:r}=nc(),s=n.mode==="table-print",o=e.enabled??!0,i=e.serverSide??!1,a=s?Number.MAX_SAFE_INTEGER:e.pageSize||50,l=e.currentPage!==void 0,[c,d]=C.useState(0),[f,h]=C.useState(a),p=l?(e.currentPage||1)-1:c,m=l?e.pageSize||a:f,g=C.useMemo(()=>o&&r("showPagination")&&!s,[o,r,s]),b=C.useMemo(()=>i?e.pageCount:Math.ceil(t/m),[i,e.pageCount,t,m]),y=C.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),x=C.useMemo(()=>i?(e.currentPage||1)>1:p>0,[i,e.currentPage,p]),v=C.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):p<(b||1)-1,[i,e.currentPage,e.pageCount,p,b]);return{pageIndex:p,pageSize:m,isServerSidePagination:i,showPagination:g,paginationEnabled:o,isTablePrintDisplayMode:s,setPageIndex:j=>{var _;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},setPageSize:j=>{var _;l?(_=e.onPageChange)==null||_.call(e,1,j):(d(0),h(j))},canPreviousPage:x,canNextPage:v,previousPage:()=>{var _;if(!x)return;const j=p-1;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},nextPage:()=>{var _;if(!v)return;const j=p+1;l?(_=e.onPageChange)==null||_.call(e,j+1,m):d(j)},pageCount:b,totalCount:y}}function INe(e,t,n){var l;if(!t.length)return e;const r=t[0].id,s=t[0].desc?-1:1,o=((l=n.groupByColumns)==null?void 0:l.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?ANe(e,a,s):PNe(e,r,s,o,n)}function ANe(e,t,n){const r=[...e],s=new Map,o=[];r.forEach(l=>{if(l.isGrandTotal)return;const c=t>0?l.fieldValues.slice(0,t).join("|||"):"root";s.has(c)||(s.set(c,[]),o.push(c)),s.get(c).push(l)});const i=[];o.forEach(l=>{const c=s.get(l),d=c.filter(h=>!h.isSubtotal),f=c.filter(h=>h.isSubtotal);d.sort((h,p)=>{const m=h.fieldValues[t],g=p.fieldValues[t];return m===g?0:m==null?1:g==null?-1:String(m).localeCompare(String(g))*n}),i.push(...d),i.push(...f)});const a=e.find(l=>l.isGrandTotal);return a&&i.push(a),i}function PNe(e,t,n,r,s){const o={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}if(f.isSubtotal){let h=o;for(let p=0;p<r-1;p++){const m=f.fieldValues[p];h.children.has(m)||h.children.set(m,{rows:[],children:new Map}),h=h.children.get(m)}h.subtotal=f}else{let h=o;for(let p=0;p<r-1;p++){const m=f.fieldValues[p];h.children.has(m)||h.children.set(m,{rows:[],children:new Map}),h=h.children.get(m)}h.rows.push(f)}});function a(f){var h;return t==="rowTotal"?s.columnHeaders.reduce((p,m)=>{var b;const g=(b=f.cells[m])==null?void 0:b.value;return p+(typeof g=="number"?g:0)},0):(h=f.cells[t])==null?void 0:h.value}function l(f){let h=0;return f.rows.forEach(p=>{const m=a(p);typeof m=="number"&&(h+=m)}),f.children.forEach(p=>{if(p.subtotal){const m=a(p.subtotal);typeof m=="number"&&(h+=m)}else h+=l(p)}),h}function c(f){const h=[],p=[...f.rows].sort((g,b)=>{const y=a(g),x=a(b);return y===x?0:y==null?1:x==null?-1:y>x?n:-n});return h.push(...p),Array.from(f.children.entries()).sort(([,g],[,b])=>{const y=g.subtotal?a(g.subtotal):l(g),x=b.subtotal?a(b.subtotal):l(b);return y===x?0:y==null?1:x==null?-1:y>x?n:-n}).forEach(([,g])=>{h.push(...c(g))}),f.subtotal&&h.push(f.subtotal),h}const d=c(o);return i&&d.push(i),d}function ONe(e,t){const[n,r]=C.useState([]),s=C.useMemo(()=>INe(e,n,t),[e,n,t]),o=C.useCallback(l=>{r(c=>{const d=c.find(f=>f.id===l);return d?d.desc?[]:[{id:l,desc:!0}]:[{id:l,desc:!1}]})},[]),i=C.useCallback(()=>{r([])},[]),a=C.useCallback(l=>{const c=n.find(d=>d.id===l);return c?c.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:s,toggleColumnSort:o,clearSorting:i,getSortDirection:a}}function Wm(e,t,n,r){if(t){const s=Na(e,t,n,r),o=Efe(e,t);return s==="-"||s===0?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):o?u.jsx("span",{style:{backgroundColor:o.backgroundColor,color:o.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||u.jsx("div",{className:"flex justify-end",children:u.jsx(Ic,{className:"h-3 w-3 text-muted-foreground"})})}function FNe(e){return(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function $Ne(e,t){const n=(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(s=>s.columnName===e&&(s.subtotalLevel==="grandTotal"||s.subtotalLevel==="ALL")))??!1;return n||r}function LNe({data:e,card:t,table:n,sorting:r,setSorting:s,showRowTotals:o,onAggregationChange:i,onOpenColumnSettings:a}){const[l,c]=C.useState(null),d=te(p=>p.isVisualEditing),f=C.useCallback(p=>{var m;return(m=n.getHeaderGroups()[0])==null?void 0:m.headers.find(g=>g.column.id===p)},[n]);return{buildColumnHeaderRows:C.useCallback(()=>{var k,j;const p=((k=t.config)==null?void 0:k.pivotByColumns)||[],m=p.length,g=((j=e.groupByColumns)==null?void 0:j.length)||1,b=e.columnHeaders.length;function y(_,D,M,T=[]){_.forEach((O,A)=>{var F,V,U;const P=O.level;if(P<m){const z=O.columnKey||`${P}-${T.join("-")}-${O.name}-${A}`,I=O.children?1:m-P,B=`pivot-${z}`,L=l===B;if(M[P].push(u.jsx(ho,{colSpan:O.colspan,rowSpan:I,className:"h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-center text-xs font-medium",children:u.jsxs("div",{className:"group/pivot-header relative flex items-center justify-center",children:[i&&u.jsx("div",{className:K("absolute left-0 overflow-hidden transition-all duration-200",L?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/pivot-header:h-6 group-hover/pivot-header:w-6 group-hover/pivot-header:opacity-100"),children:u.jsx(Cp,{columnName:O.name,groupByFields:e.groupByColumns||[],pivotByFields:((F=t.config)==null?void 0:F.pivotByColumns)||[],currentAggregation:{rowAggregates:(V=t.config)==null?void 0:V.rowAggregates,columnAggregates:(U=t.config)==null?void 0:U.columnAggregates},onAggregationChange:i,onOpenChange:R=>c(R?B:null)})}),u.jsx("span",{className:"whitespace-nowrap",children:O.name})]})},z)),O.children){const R=[...T,O.name];y(O.children,P+1,M,R)}}})}function x(_,D=[]){const M=[];return _.forEach((T,O)=>{var A,P,F,V,U;if(T.columnKey){const z=T.columnKey||`metric-${D.join("-")}-${T.name}-${O}`,I=FNe(T.columnKey),B=$Ne(T.columnKey,e.columnSubtotalMeta),L=n.getColumn(T.columnKey),R=f(T.columnKey);M.push(u.jsx(ho,{"data-column-id":T.columnKey,className:K("group/header h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-right text-xs last:border-r-0",B?"bg-muted font-semibold":I?"bg-muted/70 font-medium":""),style:{width:R==null?void 0:R.getSize(),minWidth:R==null?void 0:R.getSize(),maxWidth:R==null?void 0:R.getSize(),position:"relative",transition:"none"},children:L?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const W=L.getIsSorted();s(W?W==="asc"?[{id:L.id,desc:!0}]:[]:[{id:L.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[T.columnKey])||T.name||"Metric"}`,children:[u.jsx(So,{className:K("mr-1 h-3 w-3",L.getIsSorted()==="asc"?"hidden group-hover/header:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",L.getIsSorted()==="desc"?"hidden group-hover/header:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",L.getIsSorted()?"hidden":"hidden group-hover/header:block")})]}),u.jsx("span",{className:"min-w-0 truncate text-xs font-medium",title:((P=e.columnDisplayNames)==null?void 0:P[T.columnKey])||T.name||"Metric",children:((F=e.columnDisplayNames)==null?void 0:F[T.columnKey])||T.name||"Metric"}),d&&a&&u.jsx(ie,{variant:"ghost",size:"icon",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover/header:opacity-100",onClick:W=>{W.stopPropagation(),a(T.columnKey)},children:u.jsx(ou,{className:"h-3 w-3"})}),R&&u.jsx(Oc,{header:R,isResizing:R.column.getIsResizing()})]}):u.jsx("span",{className:"block truncate px-2",title:((V=e.columnDisplayNames)==null?void 0:V[T.columnKey])||T.name||"Metric",children:((U=e.columnDisplayNames)==null?void 0:U[T.columnKey])||T.name||"Metric"})},z))}else if(T.children){const z=[...D,T.name];M.push(...x(T.children,z))}}),M}const v=u.jsxs(ls,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,D)=>{var P,F,V,U,z;const M=(P=n.getHeaderGroups()[0])==null?void 0:P.headers.find(I=>I.column.id===`rowLevel${D}`),T=M==null?void 0:M.getSize(),O=`row-header-${D}`,A=l===O;return u.jsx(ho,{rowSpan:m+2,"data-column-id":`rowLevel${D}`,className:"group/rowheader h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-left align-bottom text-xs font-medium",style:{width:T,minWidth:T,maxWidth:T,position:"relative",transition:"none"},children:u.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between pb-1",children:[u.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",A?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/rowheader:h-6 group-hover/rowheader:w-6 group-hover/rowheader:opacity-100"),children:u.jsx(Cp,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:p,currentAggregation:{rowAggregates:(F=t.config)==null?void 0:F.rowAggregates,columnAggregates:(V=t.config)==null?void 0:V.columnAggregates},onAggregationChange:i,onOpenChange:I=>c(I?O:null)})}),u.jsxs(ie,{variant:"ghost",className:K("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&(A?"pl-7":"group-hover/rowheader:pl-7")),onClick:I=>{I.stopPropagation(),I.preventDefault(),s(B=>{const L=B.find(R=>R.id===`rowLevel${D}`);return L?L.desc?[]:[{id:`rowLevel${D}`,desc:!0}]:[{id:`rowLevel${D}`,desc:!1}]})},children:[u.jsx("span",{className:"truncate text-xs font-medium",title:_.label||_.name,children:_.label||_.name}),u.jsx(So,{className:K("h-3 w-3 flex-shrink-0",((U=r.find(I=>I.id===`rowLevel${D}`))==null?void 0:U.desc)===!1?"hidden group-hover/rowheader:block":"hidden")}),u.jsx(Ni,{className:K("h-3 w-3 flex-shrink-0",((z=r.find(I=>I.id===`rowLevel${D}`))==null?void 0:z.desc)===!0?"hidden group-hover/rowheader:block":"hidden")}),u.jsx(Rc,{className:K("h-3 w-3 flex-shrink-0",r.find(I=>I.id===`rowLevel${D}`)?"hidden":"hidden group-hover/rowheader:block")})]})]}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]})},`row-header-corner-${D}`)}):u.jsx(ho,{colSpan:g,rowSpan:m+2,className:"h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-xs",children:""}),u.jsx(ho,{colSpan:b,className:"h-8 whitespace-nowrap border-b bg-muted px-3 py-1 text-xs font-bold",children:u.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var M,T;const _="pivot-main",D=l===_;return u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",D?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/pivot-main:h-6 group-hover/pivot-main:w-6 group-hover/pivot-main:opacity-100"),children:u.jsx(Cp,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:p,currentAggregation:{rowAggregates:(M=t.config)==null?void 0:M.rowAggregates,columnAggregates:(T=t.config)==null?void 0:T.columnAggregates},onAggregationChange:i,onOpenChange:O=>c(O?_:null)})})})(),u.jsx("div",{className:K("transition-all duration-200",i&&(l==="pivot-main"?"pl-7":"group-hover/pivot-main:pl-7")),children:p.map((_,D)=>u.jsxs("span",{className:"inline-flex items-center",children:[_.label,D<p.length-1&&u.jsx(La,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},_.id))})]})},"pivot-hierarchy"),o&&(()=>{var M;const _=(M=n.getHeaderGroups()[0])==null?void 0:M.headers.find(T=>T.column.id==="rowTotal"),D=_==null?void 0:_.getSize();return u.jsx(ho,{"data-column-id":"rowTotal",className:"group/total h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-center text-xs",rowSpan:m+2,style:{width:D,minWidth:D,maxWidth:D,position:"relative",transition:"none"},children:(()=>{const T=n.getColumn("rowTotal");return T?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const O=T.getIsSorted();s(O?O==="asc"?[{id:T.id,desc:!0}]:[]:[{id:T.id,desc:!1}])},"aria-label":"Sort Total",children:[u.jsx(So,{className:K("mr-1 h-3 w-3",T.getIsSorted()==="asc"?"hidden group-hover/total:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",T.getIsSorted()==="desc"?"hidden group-hover/total:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",T.getIsSorted()?"hidden":"hidden group-hover/total:block")})]}),u.jsx("span",{className:"truncate text-xs font-medium",title:"Total",children:"Total"}),_&&u.jsx(Oc,{header:_,isResizing:_.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),w=[];if(e.columnGroups&&e.columnGroups.length>0){const _=Array.from({length:m},()=>[]);y(e.columnGroups,0,_,[]);for(let D=0;D<m;D++)w.push(u.jsx(ls,{"data-header-type":"pivot-values","data-header-row-index":D+1,"data-repeat-header":"true",children:_[D]},`pivot-row-${D}`))}let S=[];e.columnGroups&&e.columnGroups.length>0?S=x(e.columnGroups,[]):e.columnHeaders.forEach(_=>{var T,O,A,P,F,V;const D=n.getColumn(_),M=(T=n.getHeaderGroups()[0])==null?void 0:T.headers.find(U=>U.column.id===_);S.push(u.jsx(ho,{"data-column-id":_,className:"group/colheader h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-right text-xs last:border-r-0",style:{width:M==null?void 0:M.getSize(),minWidth:M==null?void 0:M.getSize(),maxWidth:M==null?void 0:M.getSize(),position:"relative",transition:"none"},children:D?u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs(ie,{variant:"ghost",className:"h-auto flex-shrink-0 p-0 hover:bg-transparent",onClick:()=>{const U=D.getIsSorted();s(U?U==="asc"?[{id:D.id,desc:!0}]:[]:[{id:D.id,desc:!1}])},"aria-label":`Sort ${((O=e.columnDisplayNames)==null?void 0:O[_])||_}`,children:[u.jsx(So,{className:K("mr-1 h-3 w-3",D.getIsSorted()==="asc"?"hidden group-hover/colheader:block":"hidden")}),u.jsx(Ni,{className:K("mr-1 h-3 w-3",D.getIsSorted()==="desc"?"hidden group-hover/colheader:block":"hidden")}),u.jsx(Rc,{className:K("mr-1 h-3 w-3",D.getIsSorted()?"hidden":"hidden group-hover/colheader:block")})]}),u.jsx("span",{className:"min-w-0 truncate text-xs font-medium",title:((A=e.columnDisplayNames)==null?void 0:A[_])||_,children:((P=e.columnDisplayNames)==null?void 0:P[_])||_}),d&&a&&u.jsx(ie,{variant:"ghost",size:"icon",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover/colheader:opacity-100",onClick:U=>{U.stopPropagation(),a(_)},children:u.jsx(ou,{className:"h-3 w-3"})}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]}):u.jsx("span",{className:"block truncate px-2",title:((F=e.columnDisplayNames)==null?void 0:F[_])||_,children:((V=e.columnDisplayNames)==null?void 0:V[_])||_})},_))});const N=u.jsxs(ls,{"data-header-type":"metrics","data-header-row-index":m>0?m+1:0,"data-repeat-header":"true",children:[m===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,D)=>{var P,F,V,U;const M=(P=n.getHeaderGroups()[0])==null?void 0:P.headers.find(z=>z.column.id===`rowLevel${D}`),T=M==null?void 0:M.getSize(),O=`metric-row-${D}`,A=l===O;return u.jsx(ho,{"data-column-id":`rowLevel${D}`,className:"group/metricrow h-8 whitespace-nowrap border-b border-r bg-muted px-3 py-1 text-left text-xs font-medium",style:{width:T,minWidth:T,maxWidth:T,position:"relative",transition:"none"},children:u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&u.jsx("div",{className:K("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200",A?"h-6 w-6 opacity-100":"h-0 w-0 opacity-0 group-hover/metricrow:h-6 group-hover/metricrow:w-6 group-hover/metricrow:opacity-100"),children:u.jsx(Cp,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:((F=t.config)==null?void 0:F.pivotByColumns)||[],currentAggregation:{rowAggregates:(V=t.config)==null?void 0:V.rowAggregates,columnAggregates:(U=t.config)==null?void 0:U.columnAggregates},onAggregationChange:i,onOpenChange:z=>c(z?O:null)})}),u.jsxs(ie,{variant:"ghost",className:K("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&(A?"pl-7":"group-hover/metricrow:pl-7")),onClick:()=>{s(z=>{const I=z.find(B=>B.id===`rowLevel${D}`);return I?I.desc===!1?[{id:`rowLevel${D}`,desc:!0}]:[]:[{id:`rowLevel${D}`,desc:!1}]})},children:[u.jsx("span",{className:"truncate text-xs font-medium",title:_.label||_.name,children:_.label||_.name}),(()=>{const z=r.find(I=>I.id===`rowLevel${D}`);return u.jsxs(u.Fragment,{children:[u.jsx(Rc,{className:K("h-3 w-3 flex-shrink-0",z?"hidden":"hidden group-hover/metricrow:block")}),u.jsx(Ni,{className:K("h-3 w-3 flex-shrink-0",(z==null?void 0:z.desc)===!0?"hidden group-hover/metricrow:block":"hidden")}),u.jsx(So,{className:K("h-3 w-3 flex-shrink-0",(z==null?void 0:z.desc)===!1?"hidden group-hover/metricrow:block":"hidden")})]})})()]})]}),M&&u.jsx(Oc,{header:M,isResizing:M.column.getIsResizing()})]})},`row-header-title-${D}`)}):Array.from({length:g}).map((_,D)=>u.jsx(ho,{className:"h-8 whitespace-nowrap border-b border-r bg-muted py-1 text-left text-xs font-medium",children:`Level ${D+1}`},`empty-header-metric-${D}`))),S]},"metric-row");return m>0?[v,...w,N]:[N]},[e,t,n,r,s,o,i,f,l,c,d,a])}}function zNe(e,t,n){var v,w;const r=te(S=>S.isVisualEditing);te(S=>S.isDashboardEditing),te(S=>S.selectedSheetId);const{updateCurrentDashboardCard:s,updateFrame:o}=Qt(),i=Ae(S=>{var N;return(N=S.actions)==null?void 0:N.setCardPreferences}),a=Ae(S=>S.card),l=C.useMemo(()=>{var S,N;return((N=(S=e==null?void 0:e.preferences)==null?void 0:S.tablePrefs)==null?void 0:N.columnSettingsMap)||{}},[(w=(v=e==null?void 0:e.preferences)==null?void 0:v.tablePrefs)==null?void 0:w.columnSettingsMap]),[c,d]=C.useState(!1),[f,h]=C.useState(null),[p,m]=C.useState(No()),g=C.useCallback(S=>{h(S);let N=l[S];if(!N){const k=t==null?void 0:t.map(j=>{var _,D;return{[S]:(D=(_=j.cells)==null?void 0:_[S])==null?void 0:D.value}});N=k&&k.length>0?Vm(S,k,n):No()}m(N),d(!0)},[l,t,n]),b=C.useCallback(()=>{var S,N;if(f&&p){const k={...l,[f]:p};if(r&&i){const j={...a.preferences,tablePrefs:{...(S=a.preferences)==null?void 0:S.tablePrefs,columnSettingsMap:k}};i(j)}else if(s){const j={...e,preferences:{...e.preferences,tablePrefs:{...(N=e.preferences)==null?void 0:N.tablePrefs,columnSettingsMap:k}}};s(j)}}d(!1)},[f,p,l,r,i,a,s,e]),y=C.useCallback(()=>{f&&m(No())},[f]),x=C.useCallback(()=>{var S,N;if(r&&i){const k={...a.preferences,tablePrefs:{...(S=a.preferences)==null?void 0:S.tablePrefs,columnSettingsMap:{}}};i(k)}else if(s){const k={...e,preferences:{...e.preferences,tablePrefs:{...(N=e.preferences)==null?void 0:N.tablePrefs,columnSettingsMap:{}}}};s(k)}d(!1)},[r,i,a,s,e]);return{columnSettings:l,columnSettingsOpen:c,activeColumnId:f,tempColumnSettings:p,isVisualEditing:r,openColumnSettings:g,applyColumnSettings:b,resetColumnSettings:y,resetAllColumnSettings:x,setColumnSettingsOpen:d,setTempColumnSettings:m}}function BNe({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:s,isTablePrintDisplayMode:o=!1,columnSettings:i}){var c;const a=e.getRowModel().rows,l=((c=t.groupByColumns)==null?void 0:c.length)||1;return a!=null&&a.length?u.jsx(u.Fragment,{children:a.map((d,f)=>{const h=d.original,p=e.getRowModel().rows,m=f===p.length-1;return u.jsx(ls,{className:K("h-8 border-b-0",h.isSubtotal&&"border-t border-t-border/50 bg-muted/70 font-medium"),"data-row-type":h.isSubtotal?"subtotal":"data","data-row-index":f,...h.isSubtotal&&{"data-subtotal-level":h.subtotalLevel},children:d.getVisibleCells().map(g=>{var v;const b=g.column.id;if(b.startsWith("rowLevel")){const w=parseInt(b.replace("rowLevel",""));if(h.isSubtotal&&h.subtotalLevel){const N=((v=t.groupByColumns)==null?void 0:v.findIndex(k=>(k.alias||k.name)===h.subtotalLevel))??-1;return w===N?u.jsx(Ln,{colSpan:o?1:l-w,className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-medium",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id):w<N?u.jsx(Ln,{className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-medium",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id):o?u.jsx(Ln,{className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs",!m&&"border-b")},g.id):null}if(!o&&f>0)for(let N=f-1;N>=0;N--){const k=p[N].original;if(k.isSubtotal||k.isGrandTotal)break;let j=!0;for(let _=0;_<=w;_++)if(h.fieldValues[_]!==k.fieldValues[_]){j=!1;break}if(j)return null}let S=1;if(!o)for(let N=f+1;N<p.length;N++){const k=p[N].original;if(k.isSubtotal||k.isGrandTotal)break;let j=!0;for(let _=0;_<=w;_++)if(h.fieldValues[_]!==k.fieldValues[_]){j=!1;break}if(j)S++;else break}return u.jsx(Ln,{rowSpan:S,className:K("h-8 whitespace-nowrap border-r px-3 py-1 text-xs",!m&&"border-b"),children:Es(g.column.columnDef.cell,g.getContext())},g.id)}const y=s.has(b),x=r.has(b);return u.jsx(Ln,{"data-column-id":b,className:K("h-8 border-r px-3 py-1 text-xs last:border-r-0",!m&&"border-b",y?"bg-muted/50":x?"bg-muted/30":void 0),style:{width:g.column.getSize(),minWidth:g.column.getSize(),maxWidth:g.column.getSize(),transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.isSubtotal&&(i!=null&&i[b])?Wm(g.getValue(),i[b]):Es(g.column.columnDef.cell,g.getContext())},g.id)})},d.id)})}):u.jsx(ls,{className:"h-8",children:u.jsx(Ln,{colSpan:n.length,className:"text-center",children:"No results."})})}function Do({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:s,displayClassName:o,isEditable:i=!0,isPending:a=!1}){const[l,c]=C.useState(!1),[d,f]=C.useState(e||""),h=()=>{c(!1),d!==e&&n(d)},p=m=>{m.key==="Enter"?(c(!1),n(d)):m.key==="Escape"&&(c(!1),f(e||""))};return l?u.jsx("div",{className:"flex",children:u.jsx("input",{type:"text",value:d,onChange:m=>f(m.target.value),onBlur:h,onKeyDown:p,onMouseDown:m=>m.stopPropagation(),className:K("w-full border-b border-dashed focus:border-primary focus:outline-none",s),autoFocus:!0})}):u.jsxs("div",{className:K("relative cursor-pointer truncate",o,{"cursor-default":!i,"hover:text-primary":i}),onClick:()=>{!i||a||(c(!0),f(e||""))},title:t?e||r:void 0,children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("span",{className:"truncate",children:e||u.jsx("span",{className:"text-muted-foreground",children:r})}),a&&u.jsx(cs,{className:"h-3 w-3 flex-shrink-0 animate-spin text-muted-foreground"})]}),a&&u.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function VNe({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:s,columnSettings:o,onAggregationLabelChange:i}){return e.length===0?null:u.jsx(u.Fragment,{children:e.map((a,l)=>{var c;return u.jsxs(ls,{className:"h-8 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":l,children:[u.jsx(Ln,{colSpan:((c=t.groupByColumns)==null?void 0:c.length)||1,className:"h-8 whitespace-nowrap border-r px-3 py-1 text-xs font-semibold",children:i?u.jsx(Do,{value:(()=>{var h,p,m;const d=a.aggregateFunction||"SUM";return((m=(p=(h=n.config)==null?void 0:h.rowAggregates)==null?void 0:p.find(g=>g.function===d&&g.groupLevel==="ALL"))==null?void 0:m.label)||a.fieldValues[0]})(),placeholder:a.fieldValues[0],onSave:d=>{const f=a.aggregateFunction||"SUM";i({type:"row",level:"ALL",function:f,label:d})},displayClassName:"text-right"}):a.fieldValues[0]}),t.columnHeaders.map(d=>{var h,p;const f=(h=r.getHeaderGroups()[0])==null?void 0:h.headers.find(m=>m.column.id===d);return u.jsx(Ln,{"data-column-id":d,className:"h-8 border-r px-3 py-1 text-right text-xs last:border-r-0",style:{width:f==null?void 0:f.getSize(),minWidth:f==null?void 0:f.getSize(),maxWidth:f==null?void 0:f.getSize(),transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Wm((p=a.cells[d])==null?void 0:p.value,o==null?void 0:o[d])},d)}),s&&(()=>{var h;const d=(h=r.getHeaderGroups()[0])==null?void 0:h.headers.find(p=>p.column.id==="rowTotal"),f=d==null?void 0:d.getSize();return u.jsx(Ln,{className:"h-8 px-3 py-1 text-right text-xs font-medium","data-column-id":"rowTotal",style:{width:f,minWidth:f,maxWidth:f,transition:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Wm(Y8(a,t.columnHeaders))})})()]},a.id)})})}function HNe({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1}){const s=[];return e&&e.length>0?e.forEach((o,i)=>{s.push({id:`rowLevel${i}`,header:()=>u.jsx("div",{className:"group border border-border px-3 py-1 text-left font-medium text-muted-foreground",children:u.jsx("div",{className:"flex items-center gap-1",children:u.jsx("span",{className:"whitespace-nowrap",children:o.label||o.name})})}),accessorFn:a=>a.fieldValues[i],cell:({row:a,table:l})=>{const c=a.original;if(c.isSubtotal&&c.subtotalLevel){const p=(e==null?void 0:e.findIndex(m=>(m.alias||m.name)===c.subtotalLevel))??-1;if(i===p){const m=c.fieldValues[i];return u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs font-medium",style:{gridColumn:`span ${t-i}`},children:m.includes(" Total")&&n?u.jsx(Do,{value:m,placeholder:m,onSave:g=>{const b=c.aggregateFunction||"SUM";if(c.subtotalLevel&&e){const y=e.find(x=>(x.alias||x.name)===c.subtotalLevel);y&&n({type:"row",level:y.id,function:b,label:g})}},displayClassName:"text-left"}):m})}else if(i<p)return u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs font-medium",children:c.fieldValues[i]});return r?u.jsx("div",{className:"whitespace-nowrap px-3 py-1 align-top text-xs"}):null}const d=l.getRowModel().rows,f=d.findIndex(p=>p.id===a.id);if(!r&&f>0)for(let p=f-1;p>=0;p--){const m=d[p].original;if(m.isSubtotal||m.isGrandTotal)break;let g=!0;for(let b=0;b<=i;b++)if(c.fieldValues[b]!==m.fieldValues[b]){g=!1;break}if(g)return null}let h=1;if(!r)for(let p=f+1;p<d.length;p++){const m=d[p].original;if(m.isSubtotal||m.isGrandTotal)break;let g=!0;for(let b=0;b<=i;b++)if(c.fieldValues[b]!==m.fieldValues[b]){g=!1;break}if(g)h++;else break}return u.jsx("div",{className:"whitespace-nowrap px-0 py-1 align-top text-xs",style:{gridRow:r?void 0:`span ${h}`},children:c.fieldValues[i]})}})}):s.push({id:"rowHeader",header:()=>u.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:o=>o.rowKey,cell:({getValue:o})=>u.jsx("div",{className:"min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",children:String(o())})}),s}function UNe({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,contextTimezone:s,browserTimezone:o}){return e.map(i=>({id:i,accessorFn:a=>{var l;return(l=a.cells[i])==null?void 0:l.value},header:({column:a})=>{const l=(t==null?void 0:t[i])||i;return u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsx(ie,{variant:"ghost",className:"h-auto p-0 hover:bg-transparent",onClick:()=>{const c=a.getIsSorted();n(c?c==="asc"?[{id:a.id,desc:!0}]:[]:[{id:a.id,desc:!1}])},"aria-label":`Sort ${l}`,children:a.getIsSorted()==="asc"?u.jsx(So,{className:"mr-1 h-3 w-3"}):a.getIsSorted()==="desc"?u.jsx(Ni,{className:"mr-1 h-3 w-3"}):u.jsx(Rc,{className:"mr-1 h-3 w-3 opacity-0 group-hover:opacity-100"})}),u.jsx("span",{className:"text-xs font-medium",children:l})]})},cell:({getValue:a})=>{const l=a(),c=r==null?void 0:r[i],d=(c==null?void 0:c.textAlign)||"right",f=d==="left"?"text-left":d==="center"?"text-center":"text-right";return u.jsx("div",{className:`text-xs ${f}`,children:Wm(l,c,s,o)})}}))}function WNe({columnHeaders:e,setSorting:t}){return{id:"rowTotal",header:({column:n})=>u.jsxs("div",{className:"flex w-full items-center justify-between",children:[u.jsx(ie,{variant:"ghost",className:"h-auto p-0 hover:bg-transparent",onClick:()=>{const r=n.getIsSorted();t(r?r==="asc"?[{id:n.id,desc:!0}]:[]:[{id:n.id,desc:!1}])},"aria-label":"Sort Total",children:n.getIsSorted()==="asc"?u.jsx(So,{className:"mr-1 h-3 w-3"}):n.getIsSorted()==="desc"?u.jsx(Ni,{className:"mr-1 h-3 w-3"}):u.jsx(Rc,{className:"mr-1 h-3 w-3 opacity-0 group-hover:opacity-100"})}),u.jsx("span",{className:"text-xs font-medium",children:"Total"})]}),cell:({row:n})=>{const r=n.original,s=Y8(r,e);return u.jsx("div",{className:"text-right text-xs font-medium",children:Wm(s)})}}}function eb({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:s}){var z,I,B;const o=te(L=>L.themeStyle),{displayPreferences:i,shouldShowElement:a}=nc(),l=i.mode==="table-print",c=n.showRowTotals??!1,{columnSizing:d,onColumnSizingChange:f}=kD({card:t}),{subtotalColumnKeys:h,grandTotalColumnKeys:p}=C.useMemo(()=>Iue(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:m,grandTotalRows:g}=C.useMemo(()=>v_(e),[e]),{sorting:b,setSorting:y,sortedTableData:x}=ONe(m,e),{columnSettings:v,columnSettingsOpen:w,activeColumnId:S,tempColumnSettings:N,openColumnSettings:k,applyColumnSettings:j,resetColumnSettings:_,resetAllColumnSettings:D,setColumnSettingsOpen:M,setTempColumnSettings:T}=zNe(t,x,e.columnMetadata),O={...n.pagination},A=RNe(O,x.length),P=C.useMemo(()=>{var Z;const L=[],R=((Z=e.groupByColumns)==null?void 0:Z.length)||1,W=HNe({groupByColumns:e.groupByColumns,numRowLevels:R,onAggregationLabelChange:s,isTablePrintDisplayMode:l});L.push(...W);const Y=UNe({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:y,columnSettings:v,contextTimezone:void 0,browserTimezone:typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0});if(L.push(...Y),c){const H=WNe({columnHeaders:e.columnHeaders,setSorting:y});L.push(H)}return L},[e,c,s,y,l,v]),F=dD({data:x,columns:P,state:{sorting:b,columnSizing:d,pagination:{pageIndex:A.pageIndex,pageSize:A.pageSize}},onSortingChange:y,onPaginationChange:void 0,getCoreRowModel:cD(),getPaginationRowModel:!A.isServerSidePagination&&!A.isTablePrintDisplayMode?uD():void 0,manualPagination:A.isServerSidePagination||A.isTablePrintDisplayMode,manualSorting:!0,pageCount:A.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f}),{buildColumnHeaderRows:V}=LNe({data:e,card:t,table:F,sorting:b,setSorting:y,showRowTotals:c,onAggregationChange:r,onOpenColumnSettings:k}),U=V();return u.jsxs("div",{className:"flex h-full w-full flex-col gap-4",children:[u.jsxs(rd,{style:{borderRadius:o==null?void 0:o.cardBorderRadius},className:"relative h-full rounded-none border",onMouseDown:L=>L.stopPropagation(),children:[u.jsxs("table",{className:"w-full border-separate border-spacing-0 bg-background text-sm",onMouseDown:L=>L.stopPropagation(),"data-pivot-table":"true","data-row-levels":((z=e.groupByColumns)==null?void 0:z.length)||1,"data-pivot-levels":e.columnGroups&&((B=(I=t.config)==null?void 0:I.pivotByColumns)==null?void 0:B.length)||0,children:[u.jsx(_w,{className:"sticky top-0 z-20 bg-background",children:U}),u.jsx(Lm,{children:u.jsx(BNe,{table:F,data:e,columns:P,subtotalColumnKeys:h,grandTotalColumnKeys:p,isTablePrintDisplayMode:l,columnSettings:v})}),g.length>0&&u.jsx("tfoot",{className:"sticky bottom-0 z-10 border-t-2 border-t-border bg-muted","data-grandtotal":"true",children:u.jsx(VNe,{grandTotalRows:g,data:e,card:t,table:F,showRowTotals:c,columnSettings:v,onAggregationLabelChange:s})})]}),u.jsx(Wa,{orientation:"horizontal"}),u.jsx(Wa,{orientation:"vertical"})]}),A.showPagination&&u.jsx(pD,{totalColumns:P.length,pageCount:A.pageCount||F.getPageCount(),pageIndex:A.pageIndex,pageSize:A.pageSize,rowCount:A.totalCount,selectedRowCount:0,setPageIndex:A.setPageIndex,setPageSize:A.setPageSize,canPreviousPage:A.canPreviousPage,canNextPage:A.canNextPage,previousPage:A.previousPage,nextPage:A.nextPage,onClearSelection:()=>{}}),S&&u.jsx(ND,{column:F.getColumn(S)||null,settings:N,onSettingsChange:T,onApply:j,onReset:_,onResetAll:D,open:w,onOpenChange:M})]})}function qNe({isOpen:e,onClose:t,frame:n,card:r,data:s}){var k;const[o,i]=C.useState(!1),a=te(j=>j.isDownloadingPdf),{isError:l,isLoading:c,isFetching:d,cfg:f,data:h,handleDatapointClick:p,pagination:m}=Wg(r),{customCards:g,placeholders:b}=Ye(),y=Ch(r,h),x=()=>{var _,D,M,T,O,A,P;const j=h||s;if(j!=null&&j.records&&j.records.length>0)if((r==null?void 0:r.type)==="aggregateTable"){const F=j.records.find(z=>z.isGrandTotal),V=j.records.filter(z=>!z.isGrandTotal),U=H8(V,F,j.groupByColumns||[],j.pivotSchema||[],r,(D=(_=r==null?void 0:r.preferences)==null?void 0:_.tablePrefs)==null?void 0:D.columnSettingsMap);Qx(U,`${(r==null?void 0:r.title)||"export"}.csv`)}else if((r==null?void 0:r.type)==="pivotTable"&&y)r9(y.data,r,`${(r==null?void 0:r.title)||"export"}.csv`,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0,showRowTotals:(M=y.options)==null?void 0:M.showRowTotals});else if((r==null?void 0:r.type)==="table"){const F=((O=(T=r==null?void 0:r.preferences)==null?void 0:T.tablePrefs)==null?void 0:O.columnSettingsMap)||{},V=((P=(A=r==null?void 0:r.preferences)==null?void 0:A.tablePrefs)==null?void 0:P.columnVisibility)||{},z=Object.keys(j.records[0]||{}).filter(I=>V[I]!==!1);Ave(j.records,F,z,`${(r==null?void 0:r.title)||"export"}.csv`,void 0,Intl.DateTimeFormat().resolvedOptions().timeZone)}else{const F=[],V=Object.keys(j.records[0]);F.push(V.join(","));for(const z of j.records){const I=V.map(B=>`"${(""+z[B]).replace(/"/g,'""')}"`);F.push(I.join(","))}const U=F.join(`
886
886
  `);Qx(U,`${(r==null?void 0:r.title)||"export"}.csv`)}},v=()=>{i(!0)},w=(r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable",S=((k=r==null?void 0:r.preferences)==null?void 0:k.allowDownload)!==!1,N=()=>{if(!r)return null;if(l)return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(Rv,{className:"size-8 text-destructive"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if(c||d)return u.jsx("div",{className:"flex h-full w-full items-center justify-center",children:u.jsx(Ou,{size:"md",color:"muted","aria-label":"Loading data"})});if(h!=null&&h.records&&(h==null?void 0:h.records.length)===0)return b!=null&&b.NoRecords?u.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:b.NoRecords}):u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(aj,{className:"size-8 text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(r.type==="table")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:r,data:(h==null?void 0:h.records)||[],paginationMetadata:m,onPaginationChange:()=>{},isLoading:c||d})});if(r.type==="pivotTable"&&y)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:r,data:y.data,options:y.options,onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})});if(r.type==="aggregateTable")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:r,data:(h==null?void 0:h.records)||[],groupByColumns:h==null?void 0:h.groupByColumns,pivotSchema:h==null?void 0:h.pivotSchema,paginationMetadata:m,onPaginationChange:()=>{},onAggregationChange:()=>{},isLoading:c||d})});if(r.type==="text")return u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:c||d,card:r,data:(h==null?void 0:h.records)||[]})});if(r.type==="custom")return u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:n,card:r})});if(f)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Jg,{cfg:f,onChartClick:()=>{},onDatapointClick:p})});if(g&&g.length>0){const j=g.find(_=>_.cardId===r.id);if(j&&j.content){const _=j.content;return u.jsx(_,{card:r})}}return null};return u.jsxs(u.Fragment,{children:[u.jsx(ao,{open:e,onOpenChange:t,children:u.jsxs(Is,{className:"flex h-[80vh] w-[80vw] max-w-[80vw] flex-col gap-0 p-0 [&>button]:hidden",children:[u.jsxs(As,{className:"shrink-0 border-b px-6 py-4",children:[u.jsx(Ps,{className:"text-lg font-semibold",children:(r==null?void 0:r.title)||"Visual"}),u.jsxs(Ao,{className:"sr-only",children:["Expanded view of ",(r==null?void 0:r.title)||"visual"," card showing detailed data and export options"]})]}),u.jsxs("div",{className:"flex items-center gap-2 border-b px-6 py-3",children:[S&&u.jsxs(ie,{variant:"ghost",size:"sm",onClick:x,title:"Download CSV",children:[u.jsx(no,{className:"mr-2 h-4 w-4"}),"CSV"]}),w&&u.jsxs(ie,{variant:"ghost",size:"sm",onClick:v,disabled:a,title:"Download PDF",children:[u.jsx(jv,{className:"mr-2 h-4 w-4"}),"PDF"]}),u.jsx(ie,{variant:"ghost",size:"icon",onClick:t,className:"ml-auto h-8 w-8",children:u.jsx(Xt,{className:"h-4 w-4"})})]}),u.jsx("div",{className:"flex flex-1 overflow-hidden p-6",children:N()})]})}),o&&u.jsx(pB,{isOpen:o,onClose:()=>i(!1),frame:n,card:r,data:h||s})]})}var VH=E.forwardRef((e,t)=>{const{children:n,...r}=e,s=E.Children.toArray(n),o=s.find(GNe);if(o){const i=o.props.children,a=s.map(l=>l===o?E.Children.count(i)>1?E.Children.only(null):E.isValidElement(i)?i.props.children:null:l);return u.jsx(Rk,{...r,ref:t,children:E.isValidElement(i)?E.cloneElement(i,void 0,a):null})}return u.jsx(Rk,{...r,ref:t,children:n})});VH.displayName="Slot";var Rk=E.forwardRef((e,t)=>{const{children:n,...r}=e;if(E.isValidElement(n)){const s=KNe(n),o=ZNe(r,n.props);return n.type!==E.Fragment&&(o.ref=t?us(t,s):s),E.cloneElement(n,o)}return E.Children.count(n)>1?E.Children.only(null):null});Rk.displayName="SlotClone";var YNe=({children:e})=>u.jsx(u.Fragment,{children:e});function GNe(e){return E.isValidElement(e)&&e.type===YNe}function ZNe(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...a)=>{o(...a),s(...a)}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function KNe(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var FD="Popover",[HH,fGe]=yr(FD,[ta]),tb=ta(),[XNe,dc]=HH(FD),UH=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!1}=e,a=tb(t),l=E.useRef(null),[c,d]=E.useState(!1),[f=!1,h]=Mr({prop:r,defaultProp:s,onChange:o});return u.jsx(gh,{...a,children:u.jsx(XNe,{scope:t,contentId:Gn(),triggerRef:l,open:f,onOpenChange:h,onOpenToggle:E.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:E.useCallback(()=>d(!0),[]),onCustomAnchorRemove:E.useCallback(()=>d(!1),[]),modal:i,children:n})})};UH.displayName=FD;var WH="PopoverAnchor",QNe=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=dc(WH,n),o=tb(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=s;return E.useEffect(()=>(i(),()=>a()),[i,a]),u.jsx(bh,{...o,...r,ref:t})});QNe.displayName=WH;var qH="PopoverTrigger",YH=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=dc(qH,n),o=tb(n),i=at(t,s.triggerRef),a=u.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":JH(s.open),...r,ref:i,onClick:we(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:u.jsx(bh,{asChild:!0,...o,children:a})});YH.displayName=qH;var $D="PopoverPortal",[JNe,eke]=HH($D,{forceMount:void 0}),GH=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,o=dc($D,t);return u.jsx(JNe,{scope:t,forceMount:n,children:u.jsx(Zn,{present:n||o.open,children:u.jsx(ed,{asChild:!0,container:s,children:r})})})};GH.displayName=$D;var Qf="PopoverContent",ZH=E.forwardRef((e,t)=>{const n=eke(Qf,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,o=dc(Qf,e.__scopePopover);return u.jsx(Zn,{present:r||o.open,children:o.modal?u.jsx(tke,{...s,ref:t}):u.jsx(nke,{...s,ref:t})})});ZH.displayName=Qf;var tke=E.forwardRef((e,t)=>{const n=dc(Qf,e.__scopePopover),r=E.useRef(null),s=at(t,r),o=E.useRef(!1);return E.useEffect(()=>{const i=r.current;if(i)return Mg(i)},[]),u.jsx(lh,{as:VH,allowPinchZoom:!0,children:u.jsx(KH,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:we(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),o.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:we(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:we(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),nke=E.forwardRef((e,t)=>{const n=dc(Qf,e.__scopePopover),r=E.useRef(!1),s=E.useRef(!1);return u.jsx(KH,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,o),o.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),o.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:o=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),KH=E.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...f}=e,h=dc(Qf,n),p=tb(n);return sw(),u.jsx(hh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:o,children:u.jsx(Ju,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:u.jsx(Fg,{"data-state":JH(h.open),role:"dialog",id:h.contentId,...p,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),XH="PopoverClose",rke=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=dc(XH,n);return u.jsx(Re.button,{type:"button",...r,ref:t,onClick:we(e.onClick,()=>s.onOpenChange(!1))})});rke.displayName=XH;var ske="PopoverArrow",QH=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=tb(n);return u.jsx($g,{...s,...r,ref:t})});QH.displayName=ske;function JH(e){return e?"open":"closed"}var oke=UH,ike=YH,ake=GH,zw=ZH,lke=QH;const Ds=oke,Ms=ike,Ts=E.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>u.jsx(ake,{children:u.jsx(Zi,{children:u.jsx(zw,{ref:s,align:t,sideOffset:n,className:K("z-49 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})})}));Ts.displayName=zw.displayName;function cke({emails:e,onChange:t}){const[n,r]=C.useState(""),[s,o]=C.useState(null),i=d=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d),a=()=>{if(o(null),!n.trim()){o("Please enter at least one email address");return}const d=n.split(/[,;]/).map(p=>p.trim()).filter(p=>p),f=d.filter(p=>!i(p));if(f.length>0){o(`Invalid email${f.length>1?"s":""}: ${f.join(", ")}`);return}const h=d.filter(p=>!e.includes(p));if(h.length===0){o("Email address already added");return}t([...e,...h]),r("")},l=d=>{t(e.filter(f=>f!==d))},c=d=>{d.key==="Enter"&&(d.preventDefault(),a())};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx(bn,{type:"text",placeholder:"email@company.com, team@company.com",value:n,onChange:d=>{r(d.target.value),o(null)},onKeyPress:c,className:K(s&&"border-destructive")}),u.jsxs(ie,{type:"button",size:"sm",onClick:a,disabled:!n.trim(),children:[u.jsx(gr,{className:"h-4 w-4 mr-1"}),"Add"]})]}),s&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[u.jsx(Tf,{className:"h-4 w-4"}),s]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter email addresses for external recipients. Separate multiple emails with commas."})]}),e.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"text-sm font-medium",children:["Added Emails (",e.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(d=>u.jsxs(jt,{variant:"secondary",className:"pl-3 pr-1 py-1 flex items-center gap-1",children:[u.jsx("span",{className:"text-xs",children:d}),u.jsx("button",{type:"button",onClick:()=>l(d),className:"ml-1 rounded-full p-0.5 hover:bg-muted-foreground/20",children:u.jsx(Xt,{className:"h-3 w-3"})})]},d))})]})]})}const uke=async(e,t,n={})=>{const r={};n.search&&(r.search=n.search),n.type&&(r.type=n.type),n.active!==void 0&&(r.active=n.active.toString()),n.tenantId&&(r.tenantId=n.tenantId),n.limit&&(r.limit=n.limit.toString()),n.offset&&(r.offset=n.offset.toString()),n.page&&(r.page=n.page.toString()),n.pageSize&&(r.pageSize=n.pageSize.toString());const s=`${e}/management/v1/unified-users`;return await zn(s,t,r)};function eU(e={}){var o,i,a;const{authToken:t,tokenProps:n}=Ye(),r=(n==null?void 0:n.endUserId)||(n==null?void 0:n.orgUserId),s=Sn({queryKey:["unified-users",e],queryFn:()=>uke(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",e),enabled:!!(t!=null&&t.accessToken)&&!!r,retry:(l,c)=>c instanceof Error&&c.message.includes("401")||c instanceof Error&&c.message.includes("403")?!1:l<2,retryDelay:l=>Math.min(1e3*2**l,3e4)});return{users:((o=s.data)==null?void 0:o.users)||[],userContext:(i=s.data)==null?void 0:i.userContext,total:((a=s.data)==null?void 0:a.total)||0,isLoading:s.isLoading,isError:s.isError,isFetching:s.isFetching,error:s.error,refetch:s.refetch}}function dke({tenantUserIds:e,orgUserIds:t,onChangeTenantUsers:n,onChangeOrgUsers:r}){const[s,o]=C.useState(""),[i,a]=C.useState("");C.useEffect(()=>{const b=setTimeout(()=>{a(s)},300);return()=>clearTimeout(b)},[s]);const{users:l,isLoading:c,error:d}=eU({search:i,limit:50}),f=new Set([...e,...t]),h=l.map(b=>({id:b.id,name:b.name,email:b.email,type:b.type})),p=h.filter(b=>f.has(b.id)),m=b=>{const y=f.has(b.id);b.type==="tenant"?n(y?e.filter(x=>x!==b.id):[...e,b.id]):b.type==="organization"&&r(y?t.filter(x=>x!==b.id):[...t,b.id])},g=(b,y)=>{y==="tenant"?n(e.filter(x=>x!==b)):y==="organization"&&r(t.filter(x=>x!==b))};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{type:"text",placeholder:"Search users by name or email...",value:s,onChange:b=>o(b.target.value),className:"pl-9"})]}),f.size>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"text-sm font-medium",children:["Selected Users (",f.size,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(b=>u.jsxs(jt,{variant:"secondary",className:"pl-2 pr-1 py-1 flex items-center gap-1",children:[b.type==="organization"?u.jsx(ym,{className:"h-3 w-3"}):u.jsx(rN,{className:"h-3 w-3"}),u.jsx("span",{className:"text-xs",children:b.name}),u.jsx("button",{type:"button",onClick:()=>g(b.id,b.type),className:"ml-1 rounded-full p-0.5 hover:bg-muted-foreground/20",children:u.jsx(Xt,{className:"h-3 w-3"})})]},b.id))})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm text-muted-foreground",children:s?"Search Results":"Available Users"}),c?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(cs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d?u.jsx("div",{className:"text-sm text-destructive py-4 text-center",children:"Failed to load users. Please try again."}):h.length===0?u.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:s?"No users found":"No users available"}):u.jsx(Rs,{className:"h-[300px] rounded-md border p-2",children:u.jsx("div",{className:"space-y-1",children:h.map(b=>{const y=f.has(b.id);return u.jsxs("div",{className:K("flex items-center gap-3 rounded-md p-2 hover:bg-muted/50 cursor-pointer",y&&"bg-primary/10"),onClick:()=>m(b),children:[u.jsx(gn,{checked:y,onCheckedChange:()=>m(b),onClick:x=>x.stopPropagation()}),u.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[b.type==="organization"?u.jsx(ym,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}):u.jsx(rN,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"text-sm font-medium truncate",children:b.name}),u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:b.email})]}),u.jsx(jt,{variant:"outline",className:"text-xs",children:b.type==="organization"?"Org":"Tenant"})]})]},b.id)})})})]})]})}const fke=async(e,t,n={})=>{const r={};n.search&&(r.search=n.search),n.type&&n.type!=="all"&&(r.type=n.type),n.tenantId&&(r.tenantId=n.tenantId),n.organizationId&&(r.organizationId=n.organizationId),n.includeMembers!==void 0&&(r.includeMembers=n.includeMembers.toString()),n.page&&(r.page=n.page.toString()),n.limit&&(r.limit=n.limit.toString());const s=`${e}/management/v1/groups`;return await zn(s,t,r)},hke=async(e,t,n)=>{const r=`${e}/management/v1/groups/${n}/members`;return await zn(r,t)};function LD(e={}){var o,i,a;const{authToken:t,tokenProps:n}=Ye(),r=(n==null?void 0:n.endUserId)||(n==null?void 0:n.orgUserId),s=Sn({queryKey:["groups",e],queryFn:()=>fke(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",e),enabled:!!(t!=null&&t.accessToken)&&!!r,retry:(l,c)=>c instanceof Error&&c.message.includes("401")||c instanceof Error&&c.message.includes("403")?!1:l<2,retryDelay:l=>Math.min(1e3*2**l,3e4),staleTime:6e4});return{groups:((o=s.data)==null?void 0:o.groups)||[],total:((i=s.data)==null?void 0:i.total)||0,hasMore:((a=s.data)==null?void 0:a.hasMore)||!1,isLoading:s.isLoading,isError:s.isError,error:s.error,isFetching:s.isFetching,refetch:s.refetch}}function pke(e){const{authToken:t,tokenProps:n}=Ye(),r=(n==null?void 0:n.endUserId)||(n==null?void 0:n.orgUserId);return Sn({queryKey:["group-members",e],queryFn:()=>hke(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",e),enabled:!!(t!=null&&t.accessToken)&&!!r&&!!e,retry:1,staleTime:6e4})}function mke(e,t){const{tokenProps:n}=Ye(),r={limit:100};return e==="organization"||n!=null&&n.orgUserId?(r.type="all",t&&(r.tenantId=t)):(e==="tenant"||n!=null&&n.endUserId)&&(r.type="TENANT_GROUP",(t||n!=null&&n.tenantId)&&(r.tenantId=t||n.tenantId)),LD(r)}function gke({groupIds:e,onChange:t}){const[n,r]=C.useState(""),{currentUser:s}=Io(),{groups:o,isLoading:i,error:a}=LD({search:n,type:"all",limit:50}),l=o.filter(p=>(s==null?void 0:s.type)==="organization"?!0:(s==null?void 0:s.type)==="tenant"?p.type==="TENANT_GROUP"&&p.tenantId===s.tenantId:!1).map(p=>({id:p.id,name:p.name,description:p.description,type:p.type,memberCount:p.memberCount})),c=l.filter(p=>p.name.toLowerCase().includes(n.toLowerCase())||p.description&&p.description.toLowerCase().includes(n.toLowerCase())),d=l.filter(p=>e.includes(p.id)),f=p=>{e.includes(p)?t(e.filter(m=>m!==p)):t([...e,p])},h=p=>{t(e.filter(m=>m!==p))};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{type:"text",placeholder:"Search groups by name...",value:n,onChange:p=>r(p.target.value),className:"pl-9"})]}),d.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"text-sm font-medium",children:["Selected Groups (",d.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(p=>u.jsxs(jt,{variant:"secondary",className:"pl-2 pr-1 py-1 flex items-center gap-1",children:[p.type==="ORG_GROUP"?u.jsx(ym,{className:"h-3 w-3"}):u.jsx(Rf,{className:"h-3 w-3"}),u.jsx("span",{className:"text-xs",children:p.name}),p.memberCount!==void 0&&u.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",p.memberCount,")"]}),u.jsx("button",{type:"button",onClick:()=>h(p.id),className:"ml-1 rounded-full p-0.5 hover:bg-muted-foreground/20",children:u.jsx(Xt,{className:"h-3 w-3"})})]},p.id))})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm text-muted-foreground",children:n?"Search Results":"Available Groups"}),i?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(cs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a?u.jsx("div",{className:"text-sm text-destructive py-4 text-center",children:"Failed to load groups. Please try again."}):c.length===0?u.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:n?"No groups found":"No groups available"}):u.jsx(Rs,{className:"h-[300px] rounded-md border p-2",children:u.jsx("div",{className:"space-y-1",children:c.map(p=>{const m=e.includes(p.id);return u.jsxs("div",{className:K("flex items-center gap-3 rounded-md p-2 hover:bg-muted/50 cursor-pointer",m&&"bg-primary/10"),onClick:()=>f(p.id),children:[u.jsx(gn,{checked:m,onCheckedChange:()=>f(p.id),onClick:g=>g.stopPropagation()}),u.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p.type==="ORG_GROUP"?u.jsx(ym,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}):u.jsx(Rf,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"text-sm font-medium truncate",children:p.name}),p.description&&u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:p.description})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[p.memberCount!==void 0&&u.jsxs(jt,{variant:"outline",className:"text-xs",children:[p.memberCount," members"]}),u.jsx(jt,{variant:"outline",className:"text-xs",children:p.type==="ORG_GROUP"?"Org":"Tenant"})]})]})]},p.id)})})})]})]})}const zD=C.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>u.jsx(Zi,{children:u.jsx(zw,{ref:s,align:t,sideOffset:n,className:K("w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));zD.displayName=zw.displayName;function bke({value:e,onChange:t,className:n}){const[r,s]=C.useState(!1),[o,i]=C.useState("emails"),a=e.emails.length+e.tenantUserIds.length+e.orgUserIds.length+e.groupIds.length,l=f=>{t({...e,...f})},c=(f,h)=>{switch(h){case"email":l({emails:e.emails.filter(p=>p!==f)});break;case"tenantUser":l({tenantUserIds:e.tenantUserIds.filter(p=>p!==f)});break;case"orgUser":l({orgUserIds:e.orgUserIds.filter(p=>p!==f)});break;case"group":l({groupIds:e.groupIds.filter(p=>p!==f)});break}},d=()=>{const f=[];e.emails.length>0&&f.push(`${e.emails.length} email${e.emails.length!==1?"s":""}`);const h=e.tenantUserIds.length+e.orgUserIds.length;return h>0&&f.push(`${h} user${h!==1?"s":""}`),e.groupIds.length>0&&f.push(`${e.groupIds.length} group${e.groupIds.length!==1?"s":""}`),f.join(", ")};return u.jsxs("div",{className:K("space-y-2",n),children:[a>0&&u.jsx("div",{className:"space-y-2",children:u.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.emails.map(f=>u.jsxs(jt,{variant:"secondary",className:"gap-1 pr-1",children:[u.jsx(Vx,{className:"h-3 w-3"}),u.jsx("span",{className:"max-w-[150px] truncate text-xs",children:f}),u.jsx("button",{onClick:h=>{h.stopPropagation(),c(f,"email")},className:"ml-1 rounded-sm hover:bg-secondary-foreground/20",children:u.jsx(Xt,{className:"h-3 w-3"})})]},f)),e.tenantUserIds.length+e.orgUserIds.length>0&&u.jsxs(jt,{variant:"secondary",className:"gap-1",children:[u.jsx(Rf,{className:"h-3 w-3"}),e.tenantUserIds.length+e.orgUserIds.length," users"]}),e.groupIds.length>0&&u.jsxs(jt,{variant:"secondary",className:"gap-1",children:[u.jsx(SR,{className:"h-3 w-3"}),e.groupIds.length," groups"]})]})}),u.jsxs(Ds,{open:r,onOpenChange:s,modal:!0,children:[u.jsx(Ms,{asChild:!0,children:u.jsxs(ie,{variant:"outline",size:"sm",className:"w-full justify-start",children:[u.jsx(V$,{className:"mr-2 h-4 w-4"}),a>0?u.jsxs("span",{children:["Add more recipients (",d(),")"]}):"Add recipients"]})}),u.jsx(zD,{className:"z-[51] w-[500px] p-0",align:"start",side:"bottom",sideOffset:4,children:u.jsxs("div",{className:"p-4",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h4",{className:"text-sm font-medium",children:"Select Recipients"}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Choose who should receive the scheduled reports"})]}),u.jsxs(lo,{value:o,onValueChange:f=>i(f),children:[u.jsxs(Os,{className:"grid w-full grid-cols-3",children:[u.jsxs(mn,{value:"emails",className:"flex items-center gap-2 text-xs",children:[u.jsx(Vx,{className:"h-3 w-3"}),u.jsx("span",{children:"Emails"}),e.emails.length>0&&u.jsx(jt,{variant:"secondary",className:"ml-1 h-4 px-1 text-xs",children:e.emails.length})]}),u.jsxs(mn,{value:"users",className:"flex items-center gap-2 text-xs",children:[u.jsx(Rf,{className:"h-3 w-3"}),u.jsx("span",{children:"Users"}),e.tenantUserIds.length+e.orgUserIds.length>0&&u.jsx(jt,{variant:"secondary",className:"ml-1 h-4 px-1 text-xs",children:e.tenantUserIds.length+e.orgUserIds.length})]}),u.jsxs(mn,{value:"groups",className:"flex items-center gap-2 text-xs",children:[u.jsx(SR,{className:"h-3 w-3"}),u.jsx("span",{children:"Groups"}),e.groupIds.length>0&&u.jsx(jt,{variant:"secondary",className:"ml-1 h-4 px-1 text-xs",children:e.groupIds.length})]})]}),u.jsxs("div",{className:"mt-4 max-h-[300px] overflow-y-auto",children:[u.jsx(lr,{value:"emails",className:"mt-0",children:u.jsx(cke,{emails:e.emails,onChange:f=>l({emails:f})})}),u.jsx(lr,{value:"users",className:"mt-0",children:u.jsx(dke,{tenantUserIds:e.tenantUserIds,orgUserIds:e.orgUserIds,onChangeTenantUsers:f=>l({tenantUserIds:f}),onChangeOrgUsers:f=>l({orgUserIds:f})})}),u.jsx(lr,{value:"groups",className:"mt-0",children:u.jsx(gke,{groupIds:e.groupIds,onChange:f=>l({groupIds:f})})})]})]}),u.jsx("div",{className:"mt-4 border-t pt-4",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:a>0?`${a} recipient${a!==1?"s":""} selected`:"No recipients selected"}),u.jsx(ie,{size:"sm",onClick:()=>s(!1),className:"h-7",children:"Done"})]})})]})})]})]})}var tU={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},OO=C.createContext&&C.createContext(tU),yke=["attr","size","title"];function xke(e,t){if(e==null)return{};var n=vke(e,t),r,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)r=o[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function vke(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function O0(){return O0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O0.apply(this,arguments)}function FO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function F0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?FO(Object(n),!0).forEach(function(r){wke(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FO(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function wke(e,t,n){return t=Ske(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ske(e){var t=Cke(e,"string");return typeof t=="symbol"?t:t+""}function Cke(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function nU(e){return e&&e.map((t,n)=>C.createElement(t.tag,F0({key:n},t.attr),nU(t.child)))}function od(e){return t=>C.createElement(Nke,O0({attr:F0({},e.attr)},t),nU(e.child))}function Nke(e){var t=n=>{var{attr:r,size:s,title:o}=e,i=xke(e,yke),a=s||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),C.createElement("svg",O0({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:l,style:F0(F0({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&C.createElement("title",null,o),e.children)};return OO!==void 0?C.createElement(OO.Consumer,null,n=>t(n)):t(tU)}function rU(e){return od({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(e)}function kke(e){return od({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(e)}function sU(e){return od({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(e)}function oU(e){return od({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4.387 3h15.226a1 1 0 0 1 .948 1.316l-5.105 15.316a2 2 0 0 1 -1.898 1.368h-3.116a2 2 0 0 1 -1.898 -1.368l-5.104 -15.316a1 1 0 0 1 .947 -1.316"},child:[]},{tag:"path",attr:{d:"M5 9h14"},child:[]},{tag:"path",attr:{d:"M7 15h10"},child:[]}]})(e)}function iU(e){return od({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(e)}function aU(e){return od({attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(e)}const Bw=[{id:"table",icon:lx,label:"Table"},{id:"pivotTable",icon:lx,label:"Pivot Table"},{id:"aggregateTable",icon:lx,label:"Aggregate Table"},{id:"bar",icon:u$,label:"Bar Chart"},{id:"line",icon:f$,label:"Line Chart"},{id:"area",icon:c$,label:"Area Chart"},{id:"stackedBar",icon:d$,label:"Stacked Bar Chart"},{id:"combo",icon:p$,label:"Combo Chart"},{id:"stackedLine",icon:iU,label:"Stacked Line Chart"},{id:"scatter",icon:b$,label:"Scatter Chart"},{id:"bubble",icon:sU,label:"Bubble Chart"},{id:"pie",icon:g$,label:"Pie Chart"},{id:"doughnut",icon:C$,label:"Doughnut Chart"},{id:"funnel",icon:oU,label:"Funnel Chart"},{id:"radar",icon:P$,label:"Radar Chart"},{id:"polarArea",icon:rU,label:"Polar Area Chart"},{id:"tornado",icon:z$,label:"Tornado Chart"},{id:"range",icon:m$,label:"Range Chart"},{id:"kpi",icon:aU,label:"KPI"},{id:"text",icon:a$,label:"Text"},{id:"map",icon:I$,label:"Map"}],Eke=e=>{const t=e.toLowerCase();for(const n of Bw)if(n.id==="doughnut"){if(t.includes("doughnut")||t.includes("donut")){const r=n.icon;return C.createElement(r,{className:"h-4 w-4"})}}else if(t.includes(n.id.toLowerCase())){const r=n.icon;return C.createElement(r,{className:"h-4 w-4"})}return null},jke=(e,t="h-4 w-4")=>{const n=Bw.find(r=>r.id===e);if(n){const r=n.icon;return C.createElement(r,{className:t})}return C.createElement(p$,{className:t})};function _ke({open:e,onOpenChange:t,dashboardId:n,onSelect:r,existingAttachments:s}){const[o,i]=C.useState(new Map),a=te(g=>g.dashboard),l=C.useMemo(()=>(a==null?void 0:a.sheets)||[],[a]),c=te(g=>g.selectedSheetId),d=l.find(g=>g.id===c),f=C.useMemo(()=>{var b;const g=[];if(g.push({id:"dashboard-full",title:`${(a==null?void 0:a.title)||"Dashboard"} (All Sheets)`,type:"dashboard",icon:u.jsx(nN,{className:"h-4 w-4"}),supportedFormats:["pdf"]}),l.length>1&&d&&g.push({id:`dashboard-${d.id}`,title:`${(a==null?void 0:a.title)||"Dashboard"} (${d.title})`,type:"dashboard",icon:u.jsx(no,{className:"h-4 w-4"}),supportedFormats:["pdf"]}),d){const y=[];(b=d.frames)==null||b.forEach(x=>{var v;(v=x.cards)==null||v.forEach(w=>{if(w.type==="text")return;const S=jke(w.type),N=y_(w.type);y.push({id:w.id,title:w.title||`${w.type} Chart`,type:"visual",visualId:w.id,cardType:w.type,icon:S,supportedFormats:N})})}),g.push(...y)}return g},[a,l,d]);C.useEffect(()=>{if(!e){i(new Map);return}if(s.length>0&&f.length>0){const g=new Map;s.forEach(b=>{const y=f.find(x=>{var v,w;if(b.type==="visual"&&b.visualId)return x.visualId===b.visualId;if(b.type==="dashboard"){if(((v=b.settings)==null?void 0:v.sheetSelection)==="all")return x.id==="dashboard-full";if((w=b.settings)!=null&&w.currentSheetId)return x.id===`dashboard-${b.settings.currentSheetId}`}return!1});y&&g.set(y.id,{item:y,format:b.format||"pdf"})}),i(g)}},[e,s,f]);const h=g=>{const b=new Map(o);if(b.has(g.id))b.delete(g.id);else{let y="pdf";g.type==="dashboard"?y="pdf":g.cardType?y=x_(g.cardType):y=g.supportedFormats.includes("csv")?"csv":"pdf",b.set(g.id,{item:g,format:y})}i(b)},p=(g,b)=>{const y=o.get(g);if(y){const x=new Map(o);x.set(g,{...y,format:b}),i(x)}},m=()=>{const g=[];o.forEach(({item:b,format:y})=>{const x={type:b.type,visualId:b.visualId,title:b.title,format:y,supportedFormats:b.supportedFormats,settings:{pageSize:"letter",orientation:"portrait",includeFilters:!0,includeTimestamp:!0}};b.type==="dashboard"&&(b.id==="dashboard-full"?x.settings.sheetSelection="all":d&&(x.settings.sheetSelection="current",x.settings.currentSheetId=d.id,x.settings.currentSheetName=d.title)),y==="csv"&&(x.settings.delimiter=",",x.settings.includeHeaders=!0,x.settings.useFormattedValues=!0),g.push(x)}),r(g),t(!1)};return u.jsx(ao,{open:e,onOpenChange:t,children:u.jsxs(Is,{className:"max-w-2xl",children:[u.jsx(As,{children:u.jsx(Ps,{children:"Select Attachment"})}),u.jsx("div",{className:"space-y-4",children:u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(ae,{children:"Select items to attach:"}),o.size>0&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.size," selected"]})]}),u.jsx("div",{className:"max-h-[400px] space-y-2 overflow-y-auto",children:f.map(g=>{var x;const b=o.has(g.id),y=((x=o.get(g.id))==null?void 0:x.format)||"pdf";return u.jsxs("div",{className:K("flex items-center gap-3 rounded-lg border p-3 transition-colors",b?"border-primary bg-primary/5":"border-border hover:bg-muted/50"),children:[u.jsx(gn,{checked:b,onCheckedChange:()=>h(g)}),u.jsx("div",{className:"flex-shrink-0",children:g.icon}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"truncate text-sm font-medium",children:g.title}),u.jsx("div",{className:"text-xs text-muted-foreground",children:g.type==="dashboard"?"Dashboard":"Visual"})]}),b&&u.jsxs(pt,{value:y,onValueChange:v=>p(g.id,v),children:[u.jsx(dt,{className:"h-7 w-20 text-xs",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[g.supportedFormats.includes("pdf")&&u.jsx(be,{value:"pdf",children:"PDF"}),g.supportedFormats.includes("csv")&&u.jsx(be,{value:"csv",children:"CSV"})]})]})]},g.id)})})]})}),u.jsxs(ci,{children:[u.jsx(ie,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),u.jsxs(ie,{onClick:m,disabled:o.size===0,children:[u.jsx(_r,{className:"mr-2 h-4 w-4"}),"Add"," ",o.size>1?`${o.size} Attachments`:"Attachment"]})]})]})})}function Dke({open:e,onOpenChange:t,attachment:n,onSave:r}){const[s,o]=C.useState(n.settings);C.useEffect(()=>{o(n.settings)},[n]);const i=()=>{r({...n,settings:s}),t(!1)};return u.jsx(ao,{open:e,onOpenChange:t,children:u.jsxs(Is,{className:"max-w-md",children:[u.jsx(As,{children:u.jsx(Ps,{children:"Export Settings"})}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-sm font-medium",children:n.title}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.type==="dashboard"?"Dashboard":"Visual"," • ",n.format.toUpperCase()]})]}),u.jsx(ri,{}),n.format==="pdf"&&u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{htmlFor:"page-size",children:"Page Size"}),u.jsxs(pt,{value:s.pageSize||"letter",onValueChange:a=>o({...s,pageSize:a}),children:[u.jsx(dt,{id:"page-size",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[u.jsx(be,{value:"letter",children:'Letter (8.5" × 11")'}),u.jsx(be,{value:"a4",children:"A4 (210mm × 297mm)"}),u.jsx(be,{value:"legal",children:'Legal (8.5" × 14")'}),u.jsx(be,{value:"a3",children:"A3 (297mm × 420mm)"}),u.jsx(be,{value:"tabloid",children:'Tabloid (11" × 17")'})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{htmlFor:"orientation",children:"Orientation"}),u.jsxs(pt,{value:s.orientation||"portrait",onValueChange:a=>o({...s,orientation:a}),children:[u.jsx(dt,{id:"orientation",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[u.jsx(be,{value:"portrait",children:"Portrait"}),u.jsx(be,{value:"landscape",children:"Landscape"})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{id:"include-filters",checked:s.includeFilters!==!1,onCheckedChange:a=>o({...s,includeFilters:a})}),u.jsx(ae,{htmlFor:"include-filters",className:"text-sm font-normal cursor-pointer",children:"Include applied filters"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{id:"include-timestamp",checked:s.includeTimestamp!==!1,onCheckedChange:a=>o({...s,includeTimestamp:a})}),u.jsx(ae,{htmlFor:"include-timestamp",className:"text-sm font-normal cursor-pointer",children:"Include timestamp"})]})]})]}),n.format==="csv"&&u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{htmlFor:"delimiter",children:"Delimiter"}),u.jsxs(pt,{value:s.delimiter||",",onValueChange:a=>o({...s,delimiter:a}),children:[u.jsx(dt,{id:"delimiter",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[u.jsx(be,{value:",",children:"Comma (,)"}),u.jsx(be,{value:";",children:"Semicolon (;)"}),u.jsx(be,{value:"\\t",children:"Tab"})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{id:"include-headers",checked:s.includeHeaders!==!1,onCheckedChange:a=>o({...s,includeHeaders:a})}),u.jsx(ae,{htmlFor:"include-headers",className:"text-sm font-normal cursor-pointer",children:"Include column headers"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{id:"use-formatted",checked:s.useFormattedValues!==!1,onCheckedChange:a=>o({...s,useFormattedValues:a})}),u.jsx(ae,{htmlFor:"use-formatted",className:"text-sm font-normal cursor-pointer",children:"Use formatted values"})]})]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Formatted values preserve number formatting, dates, and currency symbols. Raw values export the underlying data."})]})]}),u.jsxs(ci,{children:[u.jsx(ie,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),u.jsx(ie,{onClick:i,children:"Save Settings"})]})]})})}function Mke({attachments:e,onRemove:t,onUpdate:n}){const[r,s]=C.useState({open:!1,index:null}),o=(d,f)=>{const h=e[d],p={...h,format:f,settings:{...h.settings,...f==="csv"?{delimiter:",",includeHeaders:!0,useFormattedValues:!0}:{}}};n(d,p)},i=d=>d==="csv"?u.jsx(k$,{className:"h-4 w-4"}):u.jsx(no,{className:"h-4 w-4"}),a=d=>d==="csv"?"text-green-600":"text-red-600",l=d=>{s({open:!0,index:d})},c=d=>{r.index!==null&&n(r.index,d),s({open:!1,index:null})};return u.jsxs("div",{className:"space-y-2",children:[e.map((d,f)=>{var h,p,m;return u.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-muted/30",children:[u.jsx("div",{className:K("flex-shrink-0",a(d.format)),children:i(d.format)}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium text-sm truncate",children:d.title}),u.jsxs("div",{className:"text-xs text-muted-foreground",children:[d.type==="dashboard"?"Dashboard":"Visual",((h=d.settings)==null?void 0:h.sheetSelection)==="all"&&" • All sheets",((p=d.settings)==null?void 0:p.sheetSelection)==="current"&&((m=d.settings)==null?void 0:m.currentSheetName)&&` • ${d.settings.currentSheetName}`]})]}),d.supportedFormats&&d.supportedFormats.length>1?u.jsxs(pt,{value:d.format,onValueChange:g=>o(f,g),children:[u.jsx(dt,{className:"w-24 h-8",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[d.supportedFormats.includes("pdf")&&u.jsx(be,{value:"pdf",children:"PDF"}),d.supportedFormats.includes("csv")&&u.jsx(be,{value:"csv",children:"CSV"})]})]}):u.jsx(jt,{variant:"secondary",className:"uppercase",children:d.format}),u.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>l(f),children:u.jsx(ih,{className:"h-4 w-4"})}),u.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",onClick:()=>t(f),children:u.jsx(Xt,{className:"h-4 w-4"})})]},f)}),r.open&&r.index!==null&&u.jsx(Dke,{open:r.open,onOpenChange:d=>s({...r,open:d}),attachment:e[r.index],onSave:c})]})}const BD=[{value:0,label:"Sun",shortLabel:"S"},{value:1,label:"Mon",shortLabel:"M"},{value:2,label:"Tue",shortLabel:"T"},{value:3,label:"Wed",shortLabel:"W"},{value:4,label:"Thu",shortLabel:"T"},{value:5,label:"Fri",shortLabel:"F"},{value:6,label:"Sat",shortLabel:"S"}],Ik=[{value:"America/New_York",label:"Eastern Time (ET)",offset:"UTC-5"},{value:"America/Chicago",label:"Central Time (CT)",offset:"UTC-6"},{value:"America/Denver",label:"Mountain Time (MT)",offset:"UTC-7"},{value:"America/Los_Angeles",label:"Pacific Time (PT)",offset:"UTC-8"},{value:"Europe/London",label:"London (GMT)",offset:"UTC+0"},{value:"Europe/Paris",label:"Paris (CET)",offset:"UTC+1"},{value:"Asia/Tokyo",label:"Tokyo (JST)",offset:"UTC+9"},{value:"Asia/Shanghai",label:"Shanghai (CST)",offset:"UTC+8"},{value:"Australia/Sydney",label:"Sydney (AEDT)",offset:"UTC+11"},{value:"UTC",label:"UTC",offset:"UTC+0"}],Ly=[...Ik,{value:"America/Phoenix",label:"Phoenix (MST)",offset:"UTC-7"},{value:"America/Toronto",label:"Toronto (ET)",offset:"UTC-5"},{value:"America/Vancouver",label:"Vancouver (PT)",offset:"UTC-8"},{value:"America/Mexico_City",label:"Mexico City (CST)",offset:"UTC-6"},{value:"America/Sao_Paulo",label:"São Paulo (BRT)",offset:"UTC-3"},{value:"Europe/Berlin",label:"Berlin (CET)",offset:"UTC+1"},{value:"Europe/Moscow",label:"Moscow (MSK)",offset:"UTC+3"},{value:"Asia/Dubai",label:"Dubai (GST)",offset:"UTC+4"},{value:"Asia/Mumbai",label:"Mumbai (IST)",offset:"UTC+5:30"},{value:"Asia/Singapore",label:"Singapore (SGT)",offset:"UTC+8"},{value:"Asia/Hong_Kong",label:"Hong Kong (HKT)",offset:"UTC+8"},{value:"Australia/Melbourne",label:"Melbourne (AEDT)",offset:"UTC+11"},{value:"Pacific/Auckland",label:"Auckland (NZDT)",offset:"UTC+13"}];function Tke({value:e,onChange:t,className:n}){var i;const r=C.useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone,[]),s=C.useMemo(()=>{var l;const a=Ly.find(c=>c.value===e);return a?a.label:e===r?`${(l=e.split("/").pop())==null?void 0:l.replace(/_/g," ")}`:e},[e,r]),o=C.useMemo(()=>{var l;const a=Ly.find(c=>c.value===e);return a?`${a.label} (${a.offset})`:e===r?`${(l=e.split("/").pop())==null?void 0:l.replace(/_/g," ")} (Browser)`:e},[e,r]);return u.jsx("div",{className:K("relative",n),children:u.jsxs(pt,{value:e||r,onValueChange:t,children:[u.jsx(dt,{className:"w-full",title:o,children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(_g,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"truncate",children:s})]})}),u.jsxs(ft,{className:"w-full max-h-[300px]",children:[r&&!Ly.find(a=>a.value===r)&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Your timezone"}),u.jsx(be,{value:r,children:u.jsxs("div",{className:"flex items-center justify-between w-full",children:[u.jsx("span",{children:(i=r.split("/").pop())==null?void 0:i.replace(/_/g," ")}),u.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:"(Browser)"})]})}),u.jsx("div",{className:"my-1 h-px bg-border"})]}),u.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Common timezones"}),Ik.map(a=>u.jsx(be,{value:a.value,children:u.jsxs("div",{className:"flex items-center justify-between w-full",children:[u.jsx("span",{children:a.label}),u.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:a.offset})]})},a.value)),u.jsx("div",{className:"my-1 h-px bg-border"}),u.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Other timezones"}),Ly.filter(a=>!Ik.find(l=>l.value===a.value)).map(a=>u.jsx(be,{value:a.value,children:u.jsxs("div",{className:"flex items-center justify-between w-full",children:[u.jsx("span",{children:a.label}),u.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:a.offset})]})},a.value))]})]})})}function Rke({value:e,onChange:t,className:n}){const r=C.useMemo(()=>{const o=[];for(let i=0;i<24;i++)for(let a=0;a<60;a+=30){const l=`${i.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;let c;i===0?c=12:i>12?c=i-12:c=i;const d=i<12?"AM":"PM",f=`${c}:${a.toString().padStart(2,"0")} ${d}`;o.push({value:l,label:f})}return o},[]),s=C.useMemo(()=>{const o=r.find(i=>i.value===e);return(o==null?void 0:o.label)||e},[e,r]);return u.jsxs(pt,{value:e,onValueChange:t,children:[u.jsx(dt,{className:K("w-full",n),children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(za,{className:"h-4 w-4 text-muted-foreground"}),u.jsx(bt,{placeholder:"Select time",children:s})]})}),u.jsx(ft,{className:"max-h-[300px]",children:r.map(o=>u.jsx(be,{className:"hover:bg-muted",value:o.value,children:o.label},o.value))})]})}function Ike({value:e=[],onChange:t,disabled:n=!1,className:r}){const s=h=>{if(n)return;const p=e.includes(h)?e.filter(m=>m!==h):[...e,h];t(p.sort())},o=()=>{n||t([1,2,3,4,5])},i=()=>{n||t([0,6])},a=()=>{n||t([0,1,2,3,4,5,6])},l=()=>{n||t([])},c=[1,2,3,4,5].every(h=>e.includes(h))&&e.length===5,d=e.includes(0)&&e.includes(6)&&e.length===2,f=e.length===7;return u.jsxs("div",{className:K("space-y-3",r),children:[u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx(ie,{type:"button",variant:c?"default":"outline",size:"sm",onClick:o,disabled:n,className:"h-7 text-xs",children:"Weekdays"}),u.jsx(ie,{type:"button",variant:d?"default":"outline",size:"sm",onClick:i,disabled:n,className:"h-7 text-xs",children:"Weekends"}),u.jsx(ie,{type:"button",variant:f?"default":"outline",size:"sm",onClick:a,disabled:n,className:"h-7 text-xs",children:"Every day"}),e.length>0&&u.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:l,disabled:n,className:"h-7 text-xs",children:"Clear"})]}),u.jsx("div",{className:"grid grid-cols-7 gap-2",children:BD.map(h=>u.jsxs("div",{className:K("flex flex-col items-center space-y-2",n&&"opacity-50"),children:[u.jsx(ae,{htmlFor:`weekday-${h.value}`,className:K("text-xs font-medium cursor-pointer select-none",n&&"cursor-not-allowed"),children:h.shortLabel}),u.jsx(gn,{id:`weekday-${h.value}`,checked:e.includes(h.value),onCheckedChange:()=>s(h.value),disabled:n,className:"h-5 w-5"}),u.jsx("span",{className:"text-[10px] text-muted-foreground",children:h.label.slice(0,3)})]},h.value))}),e.length>0&&u.jsxs("div",{className:"text-xs text-muted-foreground",children:["Selected: ",Ake(e)]})]})}function Ake(e){if(e.length===0)return"None";if(e.length===7)return"Every day";const t=new Set(e),n=[1,2,3,4,5].every(a=>t.has(a))&&e.length===5,r=t.has(0)&&t.has(6)&&e.length===2;if(n)return"Monday through Friday";if(r)return"Saturday and Sunday";const o=[...e].sort().map(a=>BD[a].label);if(o.length===1)return o[0];if(o.length===2)return`${o[0]} and ${o[1]}`;const i=o.pop();return`${o.join(", ")}, and ${i}`}function Pke(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const _C={},Np={};function Hc(e,t){try{const r=(_C[e]||(_C[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in Np?Np[r]:$O(r,r.split(":"))}catch{if(e in Np)return Np[e];const n=e==null?void 0:e.match(Oke);return n?$O(e,n.slice(1)):NaN}}const Oke=/([+-]\d\d):?(\d\d)?/;function $O(e,t){const n=+(t[0]||0),r=+(t[1]||0),s=+(t[2]||0)/60;return Np[e]=n*60+r>0?n*60+r+s:n*60-r-s}class Mi extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Hc(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),lU(this),Ak(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Mi(...n,t):new Mi(Date.now(),t)}withTimeZone(t){return new Mi(+this,t)}getTimezoneOffset(){const t=-Hc(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),Ak(this),+this}[Symbol.for("constructDateFrom")](t){return new Mi(+new Date(t),this.timeZone)}}const LO=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!LO.test(e))return;const t=e.replace(LO,"$1UTC");Mi.prototype[t]&&(e.startsWith("get")?Mi.prototype[e]=function(){return this.internal[t]()}:(Mi.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Fke(this),+this},Mi.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Ak(this),+this}))});function Ak(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Hc(e.timeZone,e)*60))}function Fke(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),lU(e)}function lU(e){const t=Hc(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const s=-new Date(+e).getTimezoneOffset(),o=-new Date(+r).getTimezoneOffset(),i=s-o,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const l=s-n;l&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+l);const c=new Date(+e);c.setUTCSeconds(0);const d=s>0?c.getSeconds():(c.getSeconds()-60)%60,f=Math.round(-(Hc(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=Hc(e.timeZone,e),p=h>0?Math.floor(h):Math.ceil(h),g=-new Date(+e).getTimezoneOffset()-p,b=p!==n,y=g-l;if(b&&y){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const x=Hc(e.timeZone,e),v=x>0?Math.floor(x):Math.ceil(x),w=p-v;w&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+w),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+w))}}class Lr extends Mi{static tz(t,...n){return n.length?new Lr(...n,t):new Lr(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),s=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+s}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,s]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${s}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,s]=this.tzComponents();return`${t} GMT${n}${r}${s} (${Pke(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),s=String(Math.abs(t)%60).padStart(2,"0");return[n,r,s]}withTimeZone(t){return new Lr(+this,t)}[Symbol.for("constructDateFrom")](t){return new Lr(+new Date(t),this.timeZone)}}const cU=6048e5,$ke=864e5,zO=Symbol.for("constructDateFrom");function br(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&zO in e?e[zO](t):e instanceof Date?new e.constructor(t):new Date(t)}function dn(e,t){return br(t||e,e)}function uU(e,t,n){const r=dn(e,n==null?void 0:n.in);return isNaN(t)?br(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function dU(e,t,n){const r=dn(e,n==null?void 0:n.in);if(isNaN(t))return br(e,NaN);if(!t)return r;const s=r.getDate(),o=br(e,r.getTime());o.setMonth(r.getMonth()+t+1,0);const i=o.getDate();return s>=i?o:(r.setFullYear(o.getFullYear(),o.getMonth(),s),r)}let Lke={};function nb(){return Lke}function Jf(e,t){var a,l,c,d;const n=nb(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,s=dn(e,t==null?void 0:t.in),o=s.getDay(),i=(o<r?7:0)+o-r;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function qm(e,t){return Jf(e,{...t,weekStartsOn:1})}function fU(e,t){const n=dn(e,t==null?void 0:t.in),r=n.getFullYear(),s=br(n,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const o=qm(s),i=br(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=qm(i);return n.getTime()>=o.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function BO(e){const t=dn(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Mh(e,...t){const n=br.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function Ym(e,t){const n=dn(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function hU(e,t,n){const[r,s]=Mh(n==null?void 0:n.in,e,t),o=Ym(r),i=Ym(s),a=+o-BO(o),l=+i-BO(i);return Math.round((a-l)/$ke)}function zke(e,t){const n=fU(e,t),r=br(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),qm(r)}function Bke(e,t,n){return uU(e,t*7,n)}function Vke(e,t,n){return dU(e,t*12,n)}function Hke(e,t){let n,r=t==null?void 0:t.in;return e.forEach(s=>{!r&&typeof s=="object"&&(r=br.bind(null,s));const o=dn(s,r);(!n||n<o||isNaN(+o))&&(n=o)}),br(r,n||NaN)}function Uke(e,t){let n,r=t==null?void 0:t.in;return e.forEach(s=>{!r&&typeof s=="object"&&(r=br.bind(null,s));const o=dn(s,r);(!n||n>o||isNaN(+o))&&(n=o)}),br(r,n||NaN)}function Wke(e,t,n){const[r,s]=Mh(n==null?void 0:n.in,e,t);return+Ym(r)==+Ym(s)}function pU(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function qke(e){return!(!pU(e)&&typeof e!="number"||isNaN(+dn(e)))}function Yke(e,t,n){const[r,s]=Mh(n==null?void 0:n.in,e,t),o=r.getFullYear()-s.getFullYear(),i=r.getMonth()-s.getMonth();return o*12+i}function Gke(e,t){const n=dn(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Zke(e,t){const[n,r]=Mh(e,t.start,t.end);return{start:n,end:r}}function Kke(e,t){const{start:n,end:r}=Zke(t==null?void 0:t.in,e);let s=+n>+r;const o=s?+n:+r,i=s?r:n;i.setHours(0,0,0,0),i.setDate(1);let a=1;const l=[];for(;+i<=o;)l.push(br(n,i)),i.setMonth(i.getMonth()+a);return s?l.reverse():l}function Xke(e,t){const n=dn(e,t==null?void 0:t.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Qke(e,t){const n=dn(e,t==null?void 0:t.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function mU(e,t){const n=dn(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function gU(e,t){var a,l,c,d;const n=nb(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,s=dn(e,t==null?void 0:t.in),o=s.getDay(),i=(o<r?-7:0)+6-(o-r);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}function Jke(e,t){return gU(e,{...t,weekStartsOn:1})}const eEe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},tEe=(e,t,n)=>{let r;const s=eEe[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function DC(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const nEe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},rEe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},sEe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},oEe={date:DC({formats:nEe,defaultWidth:"full"}),time:DC({formats:rEe,defaultWidth:"full"}),dateTime:DC({formats:sEe,defaultWidth:"full"})},iEe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},aEe=(e,t,n,r)=>iEe[e];function tp(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;s=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;s=e.values[a]||e.values[i]}const o=e.argumentCallback?e.argumentCallback(t):t;return s[o]}}const lEe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},cEe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},uEe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dEe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},fEe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},hEe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},pEe=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},mEe={ordinalNumber:pEe,era:tp({values:lEe,defaultWidth:"wide"}),quarter:tp({values:cEe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:tp({values:uEe,defaultWidth:"wide"}),day:tp({values:dEe,defaultWidth:"wide"}),dayPeriod:tp({values:fEe,defaultWidth:"wide",formattingValues:hEe,defaultFormattingWidth:"wide"})};function np(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(s);if(!o)return null;const i=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?bEe(a,f=>f.test(i)):gEe(a,f=>f.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const d=t.slice(i.length);return{value:c,rest:d}}}function gEe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function bEe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function yEe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],o=t.match(e.parsePattern);if(!o)return null;let i=e.valueCallback?e.valueCallback(o[0]):o[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(s.length);return{value:i,rest:a}}}const xEe=/^(\d+)(th|st|nd|rd)?/i,vEe=/\d+/i,wEe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},SEe={any:[/^b/i,/^(a|c)/i]},CEe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},NEe={any:[/1/i,/2/i,/3/i,/4/i]},kEe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},EEe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},jEe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},_Ee={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},DEe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},MEe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},TEe={ordinalNumber:yEe({matchPattern:xEe,parsePattern:vEe,valueCallback:e=>parseInt(e,10)}),era:np({matchPatterns:wEe,defaultMatchWidth:"wide",parsePatterns:SEe,defaultParseWidth:"any"}),quarter:np({matchPatterns:CEe,defaultMatchWidth:"wide",parsePatterns:NEe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:np({matchPatterns:kEe,defaultMatchWidth:"wide",parsePatterns:EEe,defaultParseWidth:"any"}),day:np({matchPatterns:jEe,defaultMatchWidth:"wide",parsePatterns:_Ee,defaultParseWidth:"any"}),dayPeriod:np({matchPatterns:DEe,defaultMatchWidth:"any",parsePatterns:MEe,defaultParseWidth:"any"})},VD={code:"en-US",formatDistance:tEe,formatLong:oEe,formatRelative:aEe,localize:mEe,match:TEe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function REe(e,t){const n=dn(e,t==null?void 0:t.in);return hU(n,mU(n))+1}function bU(e,t){const n=dn(e,t==null?void 0:t.in),r=+qm(n)-+zke(n);return Math.round(r/cU)+1}function yU(e,t){var d,f,h,p;const n=dn(e,t==null?void 0:t.in),r=n.getFullYear(),s=nb(),o=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((p=(h=s.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=br((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,o),i.setHours(0,0,0,0);const a=Jf(i,t),l=br((t==null?void 0:t.in)||e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const c=Jf(l,t);return+n>=+a?r+1:+n>=+c?r:r-1}function IEe(e,t){var a,l,c,d;const n=nb(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??1,s=yU(e,t),o=br((t==null?void 0:t.in)||e,0);return o.setFullYear(s,0,r),o.setHours(0,0,0,0),Jf(o,t)}function xU(e,t){const n=dn(e,t==null?void 0:t.in),r=+Jf(n,t)-+IEe(n,t);return Math.round(r/cU)+1}function an(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const il={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return an(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):an(n+1,2)},d(e,t){return an(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return an(e.getHours()%12||12,t.length)},H(e,t){return an(e.getHours(),t.length)},m(e,t){return an(e.getMinutes(),t.length)},s(e,t){return an(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return an(s,t.length)}},Nd={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},VO={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return il.y(e,t)},Y:function(e,t,n,r){const s=yU(e,r),o=s>0?s:1-s;if(t==="YY"){const i=o%100;return an(i,2)}return t==="Yo"?n.ordinalNumber(o,{unit:"year"}):an(o,t.length)},R:function(e,t){const n=fU(e);return an(n,t.length)},u:function(e,t){const n=e.getFullYear();return an(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return an(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return an(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return il.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return an(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=xU(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):an(s,t.length)},I:function(e,t,n){const r=bU(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):an(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):il.d(e,t)},D:function(e,t,n){const r=REe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):an(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return an(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return an(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return an(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=Nd.noon:r===0?s=Nd.midnight:s=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=Nd.evening:r>=12?s=Nd.afternoon:r>=4?s=Nd.morning:s=Nd.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return il.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):il.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):an(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):an(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):il.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):il.s(e,t)},S:function(e,t){return il.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return UO(r);case"XXXX":case"XX":return Mc(r);case"XXXXX":case"XXX":default:return Mc(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return UO(r);case"xxxx":case"xx":return Mc(r);case"xxxxx":case"xxx":default:return Mc(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+HO(r,":");case"OOOO":default:return"GMT"+Mc(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+HO(r,":");case"zzzz":default:return"GMT"+Mc(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return an(r,t.length)},T:function(e,t,n){return an(+e,t.length)}};function HO(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),o=r%60;return o===0?n+String(s):n+String(s)+t+an(o,2)}function UO(e,t){return e%60===0?(e>0?"-":"+")+an(Math.abs(e)/60,2):Mc(e,t)}function Mc(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=an(Math.trunc(r/60),2),o=an(r%60,2);return n+s+t+o}const WO=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},vU=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},AEe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return WO(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",WO(r,t)).replace("{{time}}",vU(s,t))},PEe={p:vU,P:AEe},OEe=/^D+$/,FEe=/^Y+$/,$Ee=["D","DD","YY","YYYY"];function LEe(e){return OEe.test(e)}function zEe(e){return FEe.test(e)}function BEe(e,t,n){const r=VEe(e,t,n);if(console.warn(r),$Ee.includes(e))throw new RangeError(r)}function VEe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const HEe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,UEe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,WEe=/^'([^]*?)'?$/,qEe=/''/g,YEe=/[a-zA-Z]/;function GEe(e,t,n){var d,f,h,p,m,g,b,y;const r=nb(),s=(n==null?void 0:n.locale)??r.locale??VD,o=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(h=r.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??r.weekStartsOn??((y=(b=r.locale)==null?void 0:b.options)==null?void 0:y.weekStartsOn)??0,a=dn(e,n==null?void 0:n.in);if(!qke(a))throw new RangeError("Invalid time value");let l=t.match(UEe).map(x=>{const v=x[0];if(v==="p"||v==="P"){const w=PEe[v];return w(x,s.formatLong)}return x}).join("").match(HEe).map(x=>{if(x==="''")return{isToken:!1,value:"'"};const v=x[0];if(v==="'")return{isToken:!1,value:ZEe(x)};if(VO[v])return{isToken:!0,value:x};if(v.match(YEe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:x}});s.localize.preprocessor&&(l=s.localize.preprocessor(a,l));const c={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return l.map(x=>{if(!x.isToken)return x.value;const v=x.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&zEe(v)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&LEe(v))&&BEe(v,t,String(e));const w=VO[v[0]];return w(a,v,s.localize,c)}).join("")}function ZEe(e){const t=e.match(WEe);return t?t[1].replace(qEe,"'"):e}function KEe(e,t){const n=dn(e,t==null?void 0:t.in),r=n.getFullYear(),s=n.getMonth(),o=br(n,0);return o.setFullYear(r,s+1,0),o.setHours(0,0,0,0),o.getDate()}function XEe(e,t){return dn(e,t==null?void 0:t.in).getMonth()}function QEe(e,t){return dn(e,t==null?void 0:t.in).getFullYear()}function JEe(e,t){return+dn(e)>+dn(t)}function eje(e,t){return+dn(e)<+dn(t)}function tje(e,t,n){const[r,s]=Mh(n==null?void 0:n.in,e,t);return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()}function nje(e,t,n){const[r,s]=Mh(n==null?void 0:n.in,e,t);return r.getFullYear()===s.getFullYear()}function rje(e,t,n){const r=dn(e,n==null?void 0:n.in),s=r.getFullYear(),o=r.getDate(),i=br(e,0);i.setFullYear(s,t,15),i.setHours(0,0,0,0);const a=KEe(i);return r.setMonth(t,Math.min(o,a)),r}function sje(e,t,n){const r=dn(e,n==null?void 0:n.in);return isNaN(+r)?br(e,NaN):(r.setFullYear(t),r)}const qO=5,oje=4;function ije(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,s=t.addDays(e,-r+1),o=t.addDays(s,qO*7-1);return t.getMonth(e)===t.getMonth(o)?qO:oje}function wU(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-1*6):t.addDays(n,-1*(r-1))}function aje(e,t){const n=wU(e,t),r=ije(e,t);return t.addDays(n,r*7-1)}class Ka{constructor(t,n){this.Date=Date,this.today=()=>{var r;return(r=this.overrides)!=null&&r.today?this.overrides.today():this.options.timeZone?Lr.tz(this.options.timeZone):new this.Date},this.newDate=(r,s,o)=>{var i;return(i=this.overrides)!=null&&i.newDate?this.overrides.newDate(r,s,o):this.options.timeZone?new Lr(r,s,o,this.options.timeZone):new Date(r,s,o)},this.addDays=(r,s)=>{var o;return(o=this.overrides)!=null&&o.addDays?this.overrides.addDays(r,s):uU(r,s)},this.addMonths=(r,s)=>{var o;return(o=this.overrides)!=null&&o.addMonths?this.overrides.addMonths(r,s):dU(r,s)},this.addWeeks=(r,s)=>{var o;return(o=this.overrides)!=null&&o.addWeeks?this.overrides.addWeeks(r,s):Bke(r,s)},this.addYears=(r,s)=>{var o;return(o=this.overrides)!=null&&o.addYears?this.overrides.addYears(r,s):Vke(r,s)},this.differenceInCalendarDays=(r,s)=>{var o;return(o=this.overrides)!=null&&o.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,s):hU(r,s)},this.differenceInCalendarMonths=(r,s)=>{var o;return(o=this.overrides)!=null&&o.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,s):Yke(r,s)},this.eachMonthOfInterval=r=>{var s;return(s=this.overrides)!=null&&s.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):Kke(r)},this.endOfBroadcastWeek=r=>{var s;return(s=this.overrides)!=null&&s.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):aje(r,this)},this.endOfISOWeek=r=>{var s;return(s=this.overrides)!=null&&s.endOfISOWeek?this.overrides.endOfISOWeek(r):Jke(r)},this.endOfMonth=r=>{var s;return(s=this.overrides)!=null&&s.endOfMonth?this.overrides.endOfMonth(r):Gke(r)},this.endOfWeek=(r,s)=>{var o;return(o=this.overrides)!=null&&o.endOfWeek?this.overrides.endOfWeek(r,s):gU(r,this.options)},this.endOfYear=r=>{var s;return(s=this.overrides)!=null&&s.endOfYear?this.overrides.endOfYear(r):Qke(r)},this.format=(r,s,o)=>{var a;const i=(a=this.overrides)!=null&&a.format?this.overrides.format(r,s,this.options):GEe(r,s,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=r=>{var s;return(s=this.overrides)!=null&&s.getISOWeek?this.overrides.getISOWeek(r):bU(r)},this.getMonth=(r,s)=>{var o;return(o=this.overrides)!=null&&o.getMonth?this.overrides.getMonth(r,this.options):XEe(r,this.options)},this.getYear=(r,s)=>{var o;return(o=this.overrides)!=null&&o.getYear?this.overrides.getYear(r,this.options):QEe(r,this.options)},this.getWeek=(r,s)=>{var o;return(o=this.overrides)!=null&&o.getWeek?this.overrides.getWeek(r,this.options):xU(r,this.options)},this.isAfter=(r,s)=>{var o;return(o=this.overrides)!=null&&o.isAfter?this.overrides.isAfter(r,s):JEe(r,s)},this.isBefore=(r,s)=>{var o;return(o=this.overrides)!=null&&o.isBefore?this.overrides.isBefore(r,s):eje(r,s)},this.isDate=r=>{var s;return(s=this.overrides)!=null&&s.isDate?this.overrides.isDate(r):pU(r)},this.isSameDay=(r,s)=>{var o;return(o=this.overrides)!=null&&o.isSameDay?this.overrides.isSameDay(r,s):Wke(r,s)},this.isSameMonth=(r,s)=>{var o;return(o=this.overrides)!=null&&o.isSameMonth?this.overrides.isSameMonth(r,s):tje(r,s)},this.isSameYear=(r,s)=>{var o;return(o=this.overrides)!=null&&o.isSameYear?this.overrides.isSameYear(r,s):nje(r,s)},this.max=r=>{var s;return(s=this.overrides)!=null&&s.max?this.overrides.max(r):Hke(r)},this.min=r=>{var s;return(s=this.overrides)!=null&&s.min?this.overrides.min(r):Uke(r)},this.setMonth=(r,s)=>{var o;return(o=this.overrides)!=null&&o.setMonth?this.overrides.setMonth(r,s):rje(r,s)},this.setYear=(r,s)=>{var o;return(o=this.overrides)!=null&&o.setYear?this.overrides.setYear(r,s):sje(r,s)},this.startOfBroadcastWeek=(r,s)=>{var o;return(o=this.overrides)!=null&&o.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):wU(r,this)},this.startOfDay=r=>{var s;return(s=this.overrides)!=null&&s.startOfDay?this.overrides.startOfDay(r):Ym(r)},this.startOfISOWeek=r=>{var s;return(s=this.overrides)!=null&&s.startOfISOWeek?this.overrides.startOfISOWeek(r):qm(r)},this.startOfMonth=r=>{var s;return(s=this.overrides)!=null&&s.startOfMonth?this.overrides.startOfMonth(r):Xke(r)},this.startOfWeek=(r,s)=>{var o;return(o=this.overrides)!=null&&o.startOfWeek?this.overrides.startOfWeek(r,this.options):Jf(r,this.options)},this.startOfYear=r=>{var s;return(s=this.overrides)!=null&&s.startOfYear?this.overrides.startOfYear(r):mU(r)},this.options={locale:VD,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let s=0;s<10;s++)r[s.toString()]=n.format(s);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}}const sa=new Ka;class SU{constructor(t,n,r=sa){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class lje{constructor(t,n){this.date=t,this.weeks=n}}class cje{constructor(t,n){this.days=n,this.weekNumber=t}}function uje(e){return C.createElement("button",{...e})}function dje(e){return C.createElement("span",{...e})}function fje(e){const{size:t=24,orientation:n="left",className:r}=e;return C.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&C.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&C.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&C.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&C.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function hje(e){const{day:t,modifiers:n,...r}=e;return C.createElement("td",{...r})}function pje(e){const{day:t,modifiers:n,...r}=e,s=C.useRef(null);return C.useEffect(()=>{var o;n.focused&&((o=s.current)==null||o.focus())},[n.focused]),C.createElement("button",{ref:s,...r})}var Ue;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(Ue||(Ue={}));var $n;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})($n||($n={}));var Zo;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Zo||(Zo={}));var Us;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Us||(Us={}));function mje(e){const{options:t,className:n,components:r,classNames:s,...o}=e,i=[s[Ue.Dropdown],n].join(" "),a=t==null?void 0:t.find(({value:l})=>l===o.value);return C.createElement("span",{"data-disabled":o.disabled,className:s[Ue.DropdownRoot]},C.createElement(r.Select,{className:i,...o},t==null?void 0:t.map(({value:l,label:c,disabled:d})=>C.createElement(r.Option,{key:l,value:l,disabled:d},c))),C.createElement("span",{className:s[Ue.CaptionLabel],"aria-hidden":!0},a==null?void 0:a.label,C.createElement(r.Chevron,{orientation:"down",size:18,className:s[Ue.Chevron]})))}function gje(e){return C.createElement("div",{...e})}function bje(e){return C.createElement("div",{...e})}function yje(e){const{calendarMonth:t,displayIndex:n,...r}=e;return C.createElement("div",{...r},e.children)}function xje(e){const{calendarMonth:t,displayIndex:n,...r}=e;return C.createElement("div",{...r})}function vje(e){return C.createElement("table",{...e})}function wje(e){return C.createElement("div",{...e})}const CU=C.createContext(void 0);function rb(){const e=C.useContext(CU);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Sje(e){const{components:t}=rb();return C.createElement(t.Dropdown,{...e})}function Cje(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:s,...o}=e,{components:i,classNames:a,labels:{labelPrevious:l,labelNext:c}}=rb(),d=C.useCallback(h=>{s&&(n==null||n(h))},[s,n]),f=C.useCallback(h=>{r&&(t==null||t(h))},[r,t]);return C.createElement("nav",{...o},C.createElement(i.PreviousMonthButton,{type:"button",className:a[Ue.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":l(r),onClick:f},C.createElement(i.Chevron,{disabled:r?void 0:!0,className:a[Ue.Chevron],orientation:"left"})),C.createElement(i.NextMonthButton,{type:"button",className:a[Ue.NextMonthButton],tabIndex:s?void 0:-1,"aria-disabled":s?void 0:!0,"aria-label":c(s),onClick:d},C.createElement(i.Chevron,{disabled:s?void 0:!0,orientation:"right",className:a[Ue.Chevron]})))}function Nje(e){const{components:t}=rb();return C.createElement(t.Button,{...e})}function kje(e){return C.createElement("option",{...e})}function Eje(e){const{components:t}=rb();return C.createElement(t.Button,{...e})}function jje(e){const{rootRef:t,...n}=e;return C.createElement("div",{...n,ref:t})}function _je(e){return C.createElement("select",{...e})}function Dje(e){const{week:t,...n}=e;return C.createElement("tr",{...n})}function Mje(e){return C.createElement("th",{...e})}function Tje(e){return C.createElement("thead",{"aria-hidden":!0},C.createElement("tr",{...e}))}function Rje(e){const{week:t,...n}=e;return C.createElement("th",{...n})}function Ije(e){return C.createElement("th",{...e})}function Aje(e){return C.createElement("tbody",{...e})}function Pje(e){const{components:t}=rb();return C.createElement(t.Dropdown,{...e})}const Oje=Object.freeze(Object.defineProperty({__proto__:null,Button:uje,CaptionLabel:dje,Chevron:fje,Day:hje,DayButton:pje,Dropdown:mje,DropdownNav:gje,Footer:bje,Month:yje,MonthCaption:xje,MonthGrid:vje,Months:wje,MonthsDropdown:Sje,Nav:Cje,NextMonthButton:Nje,Option:kje,PreviousMonthButton:Eje,Root:jje,Select:_je,Week:Dje,WeekNumber:Rje,WeekNumberHeader:Ije,Weekday:Mje,Weekdays:Tje,Weeks:Aje,YearsDropdown:Pje},Symbol.toStringTag,{value:"Module"}));function Ma(e,t,n=!1,r=sa){let{from:s,to:o}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;return s&&o?(i(o,s)<0&&([s,o]=[o,s]),i(t,s)>=(n?1:0)&&i(o,t)>=(n?1:0)):!n&&o?a(o,t):!n&&s?a(s,t):!1}function NU(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function HD(e){return!!(e&&typeof e=="object"&&"from"in e)}function kU(e){return!!(e&&typeof e=="object"&&"after"in e)}function EU(e){return!!(e&&typeof e=="object"&&"before"in e)}function jU(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function _U(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Ta(e,t,n=sa){const r=Array.isArray(t)?t:[t],{isSameDay:s,differenceInCalendarDays:o,isAfter:i}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return s(e,a);if(_U(a,n))return a.includes(e);if(HD(a))return Ma(a,e,!1,n);if(jU(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(NU(a)){const l=o(a.before,e),c=o(a.after,e),d=l>0,f=c<0;return i(a.before,a.after)?f&&d:d||f}return kU(a)?o(e,a.after)>0:EU(a)?o(a.before,e)>0:typeof a=="function"?a(e):!1})}function Fje(e,t,n,r,s){const{disabled:o,hidden:i,modifiers:a,showOutsideDays:l,broadcastCalendar:c,today:d}=t,{isSameDay:f,isSameMonth:h,startOfMonth:p,isBefore:m,endOfMonth:g,isAfter:b}=s,y=n&&p(n),x=r&&g(r),v={[$n.focused]:[],[$n.outside]:[],[$n.disabled]:[],[$n.hidden]:[],[$n.today]:[]},w={};for(const S of e){const{date:N,displayMonth:k}=S,j=!!(k&&!h(N,k)),_=!!(y&&m(N,y)),D=!!(x&&b(N,x)),M=!!(o&&Ta(N,o,s)),T=!!(i&&Ta(N,i,s))||_||D||!c&&!l&&j||c&&l===!1&&j,O=f(N,d??s.today());j&&v.outside.push(S),M&&v.disabled.push(S),T&&v.hidden.push(S),O&&v.today.push(S),a&&Object.keys(a).forEach(A=>{const P=a==null?void 0:a[A];P&&Ta(N,P,s)&&(w[A]?w[A].push(S):w[A]=[S])})}return S=>{const N={[$n.focused]:!1,[$n.disabled]:!1,[$n.hidden]:!1,[$n.outside]:!1,[$n.today]:!1},k={};for(const j in v){const _=v[j];N[j]=_.some(D=>D===S)}for(const j in w)k[j]=w[j].some(_=>_===S);return{...N,...k}}}function $je(e,t,n={}){return Object.entries(e).filter(([,s])=>s===!0).reduce((s,[o])=>(n[o]?s.push(n[o]):t[$n[o]]?s.push(t[$n[o]]):t[Zo[o]]&&s.push(t[Zo[o]]),s),[t[Ue.Day]])}function Lje(e){return{...Oje,...e}}function zje(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function UD(){const e={};for(const t in Ue)e[Ue[t]]=`rdp-${Ue[t]}`;for(const t in $n)e[$n[t]]=`rdp-${$n[t]}`;for(const t in Zo)e[Zo[t]]=`rdp-${Zo[t]}`;for(const t in Us)e[Us[t]]=`rdp-${Us[t]}`;return e}function DU(e,t,n){return(n??new Ka(t)).format(e,"LLLL y")}const Bje=DU;function Vje(e,t,n){return(n??new Ka(t)).format(e,"d")}function Hje(e,t=sa){return t.format(e,"LLLL")}function Uje(e,t,n){return(n??new Ka(t)).format(e,"cccccc")}function Wje(e,t=sa){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function qje(){return""}function MU(e,t=sa){return t.format(e,"yyyy")}const Yje=MU,Gje=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:DU,formatDay:Vje,formatMonthCaption:Bje,formatMonthDropdown:Hje,formatWeekNumber:Wje,formatWeekNumberHeader:qje,formatWeekdayName:Uje,formatYearCaption:Yje,formatYearDropdown:MU},Symbol.toStringTag,{value:"Module"}));function Zje(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...Gje,...e}}function Kje(e,t,n,r,s){const{startOfMonth:o,startOfYear:i,endOfYear:a,eachMonthOfInterval:l,getMonth:c}=s;return l({start:i(e),end:a(e)}).map(h=>{const p=r.formatMonthDropdown(h,s),m=c(h),g=t&&h<o(t)||n&&h>o(n)||!1;return{value:m,label:p,disabled:g}})}function Xje(e,t={},n={}){let r={...t==null?void 0:t[Ue.Day]};return Object.entries(e).filter(([,s])=>s===!0).forEach(([s])=>{r={...r,...n==null?void 0:n[s]}}),r}function Qje(e,t,n){const r=e.today(),s=t?e.startOfISOWeek(r):e.startOfWeek(r),o=[];for(let i=0;i<7;i++){const a=e.addDays(s,i);o.push(a)}return o}function Jje(e,t,n,r,s=!1){if(!e||!t)return;const{startOfYear:o,endOfYear:i,addYears:a,getYear:l,isBefore:c,isSameYear:d}=r,f=o(e),h=i(t),p=[];let m=f;for(;c(m,h)||d(m,h);)p.push(m),m=a(m,1);return s&&p.reverse(),p.map(g=>{const b=n.formatYearDropdown(g,r);return{value:l(g),label:b,disabled:!1}})}function TU(e,t,n,r){let s=(r??new Ka(n)).format(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s}const e_e=TU;function RU(e,t,n){return(n??new Ka(t)).format(e,"LLLL y")}const t_e=RU;function n_e(e,t,n,r){let s=(r??new Ka(n)).format(e,"PPPP");return t!=null&&t.today&&(s=`Today, ${s}`),s}function r_e(e){return"Choose the Month"}function s_e(){return""}function o_e(e){return"Go to the Next Month"}function i_e(e){return"Go to the Previous Month"}function a_e(e,t,n){return(n??new Ka(t)).format(e,"cccc")}function l_e(e,t){return`Week ${e}`}function c_e(e){return"Week Number"}function u_e(e){return"Choose the Year"}const d_e=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:t_e,labelDay:e_e,labelDayButton:TU,labelGrid:RU,labelGridcell:n_e,labelMonthDropdown:r_e,labelNav:s_e,labelNext:o_e,labelPrevious:i_e,labelWeekNumber:l_e,labelWeekNumberHeader:c_e,labelWeekday:a_e,labelYearDropdown:u_e},Symbol.toStringTag,{value:"Module"})),sb=e=>e instanceof HTMLElement?e:null,MC=e=>[...e.querySelectorAll("[data-animated-month]")??[]],f_e=e=>sb(e.querySelector("[data-animated-month]")),TC=e=>sb(e.querySelector("[data-animated-caption]")),RC=e=>sb(e.querySelector("[data-animated-weeks]")),h_e=e=>sb(e.querySelector("[data-animated-nav]")),p_e=e=>sb(e.querySelector("[data-animated-weekdays]"));function m_e(e,t,{classNames:n,months:r,focused:s,dateLib:o}){const i=C.useRef(null),a=C.useRef(r),l=C.useRef(!1);C.useLayoutEffect(()=>{const c=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||c.length===0||r.length!==c.length)return;const d=o.isSameMonth(r[0].date,c[0].date),f=o.isAfter(r[0].date,c[0].date),h=f?n[Us.caption_after_enter]:n[Us.caption_before_enter],p=f?n[Us.weeks_after_enter]:n[Us.weeks_before_enter],m=i.current,g=e.current.cloneNode(!0);if(g instanceof HTMLElement?(MC(g).forEach(v=>{if(!(v instanceof HTMLElement))return;const w=f_e(v);w&&v.contains(w)&&v.removeChild(w);const S=TC(v);S&&S.classList.remove(h);const N=RC(v);N&&N.classList.remove(p)}),i.current=g):i.current=null,l.current||d||s)return;const b=m instanceof HTMLElement?MC(m):[],y=MC(e.current);if(y!=null&&y.every(x=>x instanceof HTMLElement)&&b&&b.every(x=>x instanceof HTMLElement)){l.current=!0,e.current.style.isolation="isolate";const x=h_e(e.current);x&&(x.style.zIndex="1"),y.forEach((v,w)=>{const S=b[w];if(!S)return;v.style.position="relative",v.style.overflow="hidden";const N=TC(v);N&&N.classList.add(h);const k=RC(v);k&&k.classList.add(p);const j=()=>{l.current=!1,e.current&&(e.current.style.isolation=""),x&&(x.style.zIndex=""),N&&N.classList.remove(h),k&&k.classList.remove(p),v.style.position="",v.style.overflow="",v.contains(S)&&v.removeChild(S)};S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");const _=p_e(S);_&&(_.style.opacity="0");const D=TC(S);D&&(D.classList.add(f?n[Us.caption_before_exit]:n[Us.caption_after_exit]),D.addEventListener("animationend",j));const M=RC(S);M&&M.classList.add(f?n[Us.weeks_before_exit]:n[Us.weeks_after_exit]),v.insertBefore(S,v.firstChild)})}})}function g_e(e,t,n,r){const s=e[0],o=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:l}=n??{},{addDays:c,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:p,endOfMonth:m,endOfWeek:g,isAfter:b,startOfBroadcastWeek:y,startOfISOWeek:x,startOfWeek:v}=r,w=l?y(s,r):i?x(s):v(s),S=l?h(o):i?p(m(o)):g(m(o)),N=d(S,w),k=f(o,s)+1,j=[];for(let M=0;M<=N;M++){const T=c(w,M);if(t&&b(T,t))break;j.push(T)}const D=(l?35:42)*k;if(a&&j.length<D){const M=D-j.length;for(let T=0;T<M;T++){const O=c(j[j.length-1],1);j.push(O)}}return j}function b_e(e){const t=[];return e.reduce((n,r)=>{const s=r.weeks.reduce((o,i)=>o.concat(i.days.slice()),t.slice());return n.concat(s.slice())},t.slice())}function y_e(e,t,n,r){const{numberOfMonths:s=1}=n,o=[];for(let i=0;i<s;i++){const a=r.addMonths(e,i);if(t&&a>t)break;o.push(a)}return o}function YO(e,t,n,r){const{month:s,defaultMonth:o,today:i=r.today(),numberOfMonths:a=1}=e;let l=s||o||i;const{differenceInCalendarMonths:c,addMonths:d,startOfMonth:f}=r;if(n&&c(n,l)<a-1){const h=-1*(a-1);l=d(n,h)}return t&&c(l,t)<0&&(l=t),f(l)}function x_e(e,t,n,r){const{addDays:s,endOfBroadcastWeek:o,endOfISOWeek:i,endOfMonth:a,endOfWeek:l,getISOWeek:c,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:p}=r,m=e.reduce((g,b)=>{const y=n.broadcastCalendar?f(b,r):n.ISOWeek?h(b):p(b),x=n.broadcastCalendar?o(b):n.ISOWeek?i(a(b)):l(a(b)),v=t.filter(k=>k>=y&&k<=x),w=n.broadcastCalendar?35:42;if(n.fixedWeeks&&v.length<w){const k=t.filter(j=>{const _=w-v.length;return j>x&&j<=s(x,_)});v.push(...k)}const S=v.reduce((k,j)=>{const _=n.ISOWeek?c(j):d(j),D=k.find(T=>T.weekNumber===_),M=new SU(j,b,r);return D?D.days.push(M):k.push(new cje(_,[M])),k},[]),N=new lje(b,S);return g.push(N),g},[]);return n.reverseMonths?m.reverse():m}function v_e(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:s,startOfDay:o,startOfMonth:i,endOfMonth:a,addYears:l,endOfYear:c,newDate:d,today:f}=t,{fromYear:h,toYear:p,fromMonth:m,toMonth:g}=e;!n&&m&&(n=m),!n&&h&&(n=t.newDate(h,0,1)),!r&&g&&(r=g),!r&&p&&(r=d(p,11,31));const b=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):h?n=d(h,0,1):!n&&b&&(n=s(l(e.today??f(),-100))),r?r=a(r):p?r=d(p,11,31):!r&&b&&(r=c(e.today??f())),[n&&o(n),r&&o(r)]}function w_e(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:s,numberOfMonths:o=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:l}=r,c=s?o:1,d=i(e);if(!t)return a(d,c);if(!(l(t,e)<o))return a(d,c)}function S_e(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:s,numberOfMonths:o}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:l}=r,c=s?o??1:1,d=i(e);if(!t)return a(d,-c);if(!(l(d,t)<=0))return a(d,-c)}function C_e(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function Vw(e,t){const[n,r]=C.useState(e);return[t===void 0?n:t,r]}function N_e(e,t){const[n,r]=v_e(e,t),{startOfMonth:s,endOfMonth:o}=t,i=YO(e,n,r,t),[a,l]=Vw(i,e.month?i:void 0);C.useEffect(()=>{const N=YO(e,n,r,t);l(N)},[e.timeZone]);const c=y_e(a,r,e,t),d=g_e(c,e.endMonth?o(e.endMonth):void 0,e,t),f=x_e(c,d,e,t),h=C_e(f),p=b_e(f),m=S_e(a,n,e,t),g=w_e(a,r,e,t),{disableNavigation:b,onMonthChange:y}=e,x=N=>h.some(k=>k.days.some(j=>j.isEqualTo(N))),v=N=>{if(b)return;let k=s(N);n&&k<s(n)&&(k=s(n)),r&&k>s(r)&&(k=s(r)),l(k),y==null||y(k)};return{months:f,weeks:h,days:p,navStart:n,navEnd:r,previousMonth:m,nextMonth:g,goToMonth:v,goToDay:N=>{x(N)||v(N.date)}}}var yi;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(yi||(yi={}));function GO(e){return!e[$n.disabled]&&!e[$n.hidden]&&!e[$n.outside]}function k_e(e,t,n,r){let s,o=-1;for(const i of e){const a=t(i);GO(a)&&(a[$n.focused]&&o<yi.FocusedModifier?(s=i,o=yi.FocusedModifier):r!=null&&r.isEqualTo(i)&&o<yi.LastFocused?(s=i,o=yi.LastFocused):n(i.date)&&o<yi.Selected?(s=i,o=yi.Selected):a[$n.today]&&o<yi.Today&&(s=i,o=yi.Today))}return s||(s=e.find(i=>GO(t(i)))),s}function E_e(e,t,n,r,s,o,i){const{ISOWeek:a,broadcastCalendar:l}=o,{addDays:c,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:g,max:b,min:y,startOfBroadcastWeek:x,startOfISOWeek:v,startOfWeek:w}=i;let N={day:c,week:f,month:d,year:h,startOfWeek:k=>l?x(k,i):a?v(k):w(k),endOfWeek:k=>l?p(k):a?m(k):g(k)}[e](n,t==="after"?1:-1);return t==="before"&&r?N=b([r,N]):t==="after"&&s&&(N=y([s,N])),N}function IU(e,t,n,r,s,o,i,a=0){if(a>365)return;const l=E_e(e,t,n.date,r,s,o,i),c=!!(o.disabled&&Ta(l,o.disabled,i)),d=!!(o.hidden&&Ta(l,o.hidden,i)),f=l,h=new SU(l,f,i);return!c&&!d?h:IU(e,t,h,r,s,o,i,a+1)}function j_e(e,t,n,r,s){const{autoFocus:o}=e,[i,a]=C.useState(),l=k_e(t.days,n,r||(()=>!1),i),[c,d]=C.useState(o?l:void 0);return{isFocusTarget:g=>!!(l!=null&&l.isEqualTo(g)),setFocused:d,focused:c,blur:()=>{a(c),d(void 0)},moveFocus:(g,b)=>{if(!c)return;const y=IU(g,b,c,t.navStart,t.navEnd,e,s);y&&(t.goToDay(y),d(y))}}}function __e(e,t){const{selected:n,required:r,onSelect:s}=e,[o,i]=Vw(n,s?n:void 0),a=s?n:o,{isSameDay:l}=t,c=p=>(a==null?void 0:a.some(m=>l(m,p)))??!1,{min:d,max:f}=e;return{selected:a,select:(p,m,g)=>{let b=[...a??[]];if(c(p)){if((a==null?void 0:a.length)===d||r&&(a==null?void 0:a.length)===1)return;b=a==null?void 0:a.filter(y=>!l(y,p))}else(a==null?void 0:a.length)===f?b=[p]:b=[...b,p];return s||i(b),s==null||s(b,p,m,g),b},isSelected:c}}function D_e(e,t,n=0,r=0,s=!1,o=sa){const{from:i,to:a}=t||{},{isSameDay:l,isAfter:c,isBefore:d}=o;let f;if(!i&&!a)f={from:e,to:n>0?void 0:e};else if(i&&!a)l(i,e)?n===0?f={from:i,to:e}:s?f={from:i,to:void 0}:f=void 0:d(e,i)?f={from:e,to:i}:f={from:i,to:e};else if(i&&a)if(l(i,e)&&l(a,e))s?f={from:i,to:a}:f=void 0;else if(l(i,e))f={from:i,to:n>0?void 0:e};else if(l(a,e))f={from:e,to:n>0?void 0:e};else if(d(e,i))f={from:e,to:a};else if(c(e,i))f={from:i,to:e};else if(c(e,a))f={from:i,to:e};else throw new Error("Invalid range");if(f!=null&&f.from&&(f!=null&&f.to)){const h=o.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function M_e(e,t,n=sa){const r=Array.isArray(t)?t:[t];let s=e.from;const o=n.differenceInCalendarDays(e.to,e.from),i=Math.min(o,6);for(let a=0;a<=i;a++){if(r.includes(s.getDay()))return!0;s=n.addDays(s,1)}return!1}function ZO(e,t,n=sa){return Ma(e,t.from,!1,n)||Ma(e,t.to,!1,n)||Ma(t,e.from,!1,n)||Ma(t,e.to,!1,n)}function T_e(e,t,n=sa){const r=Array.isArray(t)?t:[t];if(r.filter(a=>typeof a!="function").some(a=>typeof a=="boolean"?a:n.isDate(a)?Ma(e,a,!1,n):_U(a,n)?a.some(l=>Ma(e,l,!1,n)):HD(a)?a.from&&a.to?ZO(e,{from:a.from,to:a.to},n):!1:jU(a)?M_e(e,a.dayOfWeek,n):NU(a)?n.isAfter(a.before,a.after)?ZO(e,{from:n.addDays(a.after,1),to:n.addDays(a.before,-1)},n):Ta(e.from,a,n)||Ta(e.to,a,n):kU(a)||EU(a)?Ta(e.from,a,n)||Ta(e.to,a,n):!1))return!0;const i=r.filter(a=>typeof a=="function");if(i.length){let a=e.from;const l=n.differenceInCalendarDays(e.to,e.from);for(let c=0;c<=l;c++){if(i.some(d=>d(a)))return!0;a=n.addDays(a,1)}}return!1}function R_e(e,t){const{disabled:n,excludeDisabled:r,selected:s,required:o,onSelect:i}=e,[a,l]=Vw(s,i?s:void 0),c=i?s:a;return{selected:c,select:(h,p,m)=>{const{min:g,max:b}=e,y=h?D_e(h,c,g,b,o,t):void 0;return r&&n&&(y!=null&&y.from)&&y.to&&T_e({from:y.from,to:y.to},n,t)&&(y.from=h,y.to=void 0),i||l(y),i==null||i(y,h,p,m),y},isSelected:h=>c&&Ma(c,h,!1,t)}}function I_e(e,t){const{selected:n,required:r,onSelect:s}=e,[o,i]=Vw(n,s?n:void 0),a=s?n:o,{isSameDay:l}=t;return{selected:a,select:(f,h,p)=>{let m=f;return!r&&a&&a&&l(f,a)&&(m=void 0),s||i(m),s==null||s(m,f,h,p),m},isSelected:f=>a?l(a,f):!1}}function A_e(e,t){const n=I_e(e,t),r=__e(e,t),s=R_e(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return s;default:return}}function P_e(e){var he;let t=e;t.timeZone&&(t={...e},t.today&&(t.today=new Lr(t.today,t.timeZone)),t.month&&(t.month=new Lr(t.month,t.timeZone)),t.defaultMonth&&(t.defaultMonth=new Lr(t.defaultMonth,t.timeZone)),t.startMonth&&(t.startMonth=new Lr(t.startMonth,t.timeZone)),t.endMonth&&(t.endMonth=new Lr(t.endMonth,t.timeZone)),t.mode==="single"&&t.selected?t.selected=new Lr(t.selected,t.timeZone):t.mode==="multiple"&&t.selected?t.selected=(he=t.selected)==null?void 0:he.map(xe=>new Lr(xe,t.timeZone)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?new Lr(t.selected.from,t.timeZone):void 0,to:t.selected.to?new Lr(t.selected.to,t.timeZone):void 0}));const{components:n,formatters:r,labels:s,dateLib:o,locale:i,classNames:a}=C.useMemo(()=>{const xe={...VD,...t.locale};return{dateLib:new Ka({locale:xe,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:Lje(t.components),formatters:Zje(t.formatters),labels:{...d_e,...t.labels},locale:xe,classNames:{...UD(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]),{captionLayout:l,mode:c,navLayout:d,numberOfMonths:f=1,onDayBlur:h,onDayClick:p,onDayFocus:m,onDayKeyDown:g,onDayMouseEnter:b,onDayMouseLeave:y,onNextClick:x,onPrevClick:v,showWeekNumber:w,styles:S}=t,{formatCaption:N,formatDay:k,formatMonthDropdown:j,formatWeekNumber:_,formatWeekNumberHeader:D,formatWeekdayName:M,formatYearDropdown:T}=r,O=N_e(t,o),{days:A,months:P,navStart:F,navEnd:V,previousMonth:U,nextMonth:z,goToMonth:I}=O,B=Fje(A,t,F,V,o),{isSelected:L,select:R,selected:W}=A_e(t,o)??{},{blur:Y,focused:Z,isFocusTarget:H,moveFocus:$,setFocused:q}=j_e(t,O,B,L??(()=>!1),o),{labelDayButton:G,labelGridcell:ee,labelGrid:Q,labelMonthDropdown:ne,labelNav:oe,labelPrevious:de,labelNext:le,labelWeekday:ke,labelWeekNumber:ye,labelWeekNumberHeader:Pe,labelYearDropdown:Ve}=s,lt=C.useMemo(()=>Qje(o,t.ISOWeek),[o,t.ISOWeek]),ue=c!==void 0||p!==void 0,Ne=C.useCallback(()=>{U&&(I(U),v==null||v(U))},[U,I,v]),Je=C.useCallback(()=>{z&&(I(z),x==null||x(z))},[I,z,x]),We=C.useCallback((xe,Ie)=>_e=>{_e.preventDefault(),_e.stopPropagation(),q(xe),R==null||R(xe.date,Ie,_e),p==null||p(xe.date,Ie,_e)},[R,p,q]),re=C.useCallback((xe,Ie)=>_e=>{q(xe),m==null||m(xe.date,Ie,_e)},[m,q]),fe=C.useCallback((xe,Ie)=>_e=>{Y(),h==null||h(xe.date,Ie,_e)},[Y,h]),De=C.useCallback((xe,Ie)=>_e=>{const He={ArrowLeft:[_e.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[_e.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[_e.shiftKey?"year":"week","after"],ArrowUp:[_e.shiftKey?"year":"week","before"],PageUp:[_e.shiftKey?"year":"month","before"],PageDown:[_e.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(He[_e.key]){_e.preventDefault(),_e.stopPropagation();const[et,qe]=He[_e.key];$(et,qe)}g==null||g(xe.date,Ie,_e)},[$,g,t.dir]),Oe=C.useCallback((xe,Ie)=>_e=>{b==null||b(xe.date,Ie,_e)},[b]),Me=C.useCallback((xe,Ie)=>_e=>{y==null||y(xe.date,Ie,_e)},[y]),nt=C.useCallback(xe=>Ie=>{const _e=Number(Ie.target.value),He=o.setMonth(o.startOfMonth(xe),_e);I(He)},[o,I]),Dt=C.useCallback(xe=>Ie=>{const _e=Number(Ie.target.value),He=o.setYear(o.startOfMonth(xe),_e);I(He)},[o,I]),{className:ct,style:Ot}=C.useMemo(()=>({className:[a[Ue.Root],t.className].filter(Boolean).join(" "),style:{...S==null?void 0:S[Ue.Root],...t.style}}),[a,t.className,t.style,S]),ve=zje(t),_t=C.useRef(null);m_e(_t,!!t.animate,{classNames:a,months:P,focused:Z,dateLib:o});const vn={dayPickerProps:t,selected:W,select:R,isSelected:L,months:P,nextMonth:z,previousMonth:U,goToMonth:I,getModifiers:B,components:n,classNames:a,styles:S,labels:s,formatters:r};return C.createElement(CU.Provider,{value:vn},C.createElement(n.Root,{rootRef:t.animate?_t:void 0,className:ct,style:Ot,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],...ve},C.createElement(n.Months,{className:a[Ue.Months],style:S==null?void 0:S[Ue.Months]},!t.hideNavigation&&!d&&C.createElement(n.Nav,{"data-animated-nav":t.animate?"true":void 0,className:a[Ue.Nav],style:S==null?void 0:S[Ue.Nav],"aria-label":oe(),onPreviousClick:Ne,onNextClick:Je,previousMonth:U,nextMonth:z}),P.map((xe,Ie)=>C.createElement(n.Month,{"data-animated-month":t.animate?"true":void 0,className:a[Ue.Month],style:S==null?void 0:S[Ue.Month],key:Ie,displayIndex:Ie,calendarMonth:xe},d==="around"&&!t.hideNavigation&&Ie===0&&C.createElement(n.PreviousMonthButton,{type:"button",className:a[Ue.PreviousMonthButton],tabIndex:U?void 0:-1,"aria-disabled":U?void 0:!0,"aria-label":de(U),onClick:Ne,"data-animated-button":t.animate?"true":void 0},C.createElement(n.Chevron,{disabled:U?void 0:!0,className:a[Ue.Chevron],orientation:t.dir==="rtl"?"right":"left"})),C.createElement(n.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:a[Ue.MonthCaption],style:S==null?void 0:S[Ue.MonthCaption],calendarMonth:xe,displayIndex:Ie},l!=null&&l.startsWith("dropdown")?C.createElement(n.DropdownNav,{className:a[Ue.Dropdowns],style:S==null?void 0:S[Ue.Dropdowns]},l==="dropdown"||l==="dropdown-months"?C.createElement(n.MonthsDropdown,{className:a[Ue.MonthsDropdown],"aria-label":ne(),classNames:a,components:n,disabled:!!t.disableNavigation,onChange:nt(xe.date),options:Kje(xe.date,F,V,r,o),style:S==null?void 0:S[Ue.Dropdown],value:o.getMonth(xe.date)}):C.createElement("span",null,j(xe.date,o)),l==="dropdown"||l==="dropdown-years"?C.createElement(n.YearsDropdown,{className:a[Ue.YearsDropdown],"aria-label":Ve(o.options),classNames:a,components:n,disabled:!!t.disableNavigation,onChange:Dt(xe.date),options:Jje(F,V,r,o,!!t.reverseYears),style:S==null?void 0:S[Ue.Dropdown],value:o.getYear(xe.date)}):C.createElement("span",null,T(xe.date,o)),C.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},N(xe.date,o.options,o))):C.createElement(n.CaptionLabel,{className:a[Ue.CaptionLabel],role:"status","aria-live":"polite"},N(xe.date,o.options,o))),d==="around"&&!t.hideNavigation&&Ie===f-1&&C.createElement(n.NextMonthButton,{type:"button",className:a[Ue.NextMonthButton],tabIndex:z?void 0:-1,"aria-disabled":z?void 0:!0,"aria-label":le(z),onClick:Je,"data-animated-button":t.animate?"true":void 0},C.createElement(n.Chevron,{disabled:z?void 0:!0,className:a[Ue.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Ie===f-1&&d==="after"&&!t.hideNavigation&&C.createElement(n.Nav,{"data-animated-nav":t.animate?"true":void 0,className:a[Ue.Nav],style:S==null?void 0:S[Ue.Nav],"aria-label":oe(),onPreviousClick:Ne,onNextClick:Je,previousMonth:U,nextMonth:z}),C.createElement(n.MonthGrid,{role:"grid","aria-multiselectable":c==="multiple"||c==="range","aria-label":Q(xe.date,o.options,o)||void 0,className:a[Ue.MonthGrid],style:S==null?void 0:S[Ue.MonthGrid]},!t.hideWeekdays&&C.createElement(n.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:a[Ue.Weekdays],style:S==null?void 0:S[Ue.Weekdays]},w&&C.createElement(n.WeekNumberHeader,{"aria-label":Pe(o.options),className:a[Ue.WeekNumberHeader],style:S==null?void 0:S[Ue.WeekNumberHeader],scope:"col"},D()),lt.map(_e=>C.createElement(n.Weekday,{"aria-label":ke(_e,o.options,o),className:a[Ue.Weekday],key:String(_e),style:S==null?void 0:S[Ue.Weekday],scope:"col"},M(_e,o.options,o)))),C.createElement(n.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:a[Ue.Weeks],style:S==null?void 0:S[Ue.Weeks]},xe.weeks.map(_e=>C.createElement(n.Week,{className:a[Ue.Week],key:_e.weekNumber,style:S==null?void 0:S[Ue.Week],week:_e},w&&C.createElement(n.WeekNumber,{week:_e,style:S==null?void 0:S[Ue.WeekNumber],"aria-label":ye(_e.weekNumber,{locale:i}),className:a[Ue.WeekNumber],scope:"row",role:"rowheader"},_(_e.weekNumber,o)),_e.days.map(He=>{const{date:et}=He,qe=B(He);if(qe[$n.focused]=!qe.hidden&&!!(Z!=null&&Z.isEqualTo(He)),qe[Zo.selected]=(L==null?void 0:L(et))||qe.selected,HD(W)){const{from:qt,to:Ft}=W;qe[Zo.range_start]=!!(qt&&Ft&&o.isSameDay(et,qt)),qe[Zo.range_end]=!!(qt&&Ft&&o.isSameDay(et,Ft)),qe[Zo.range_middle]=Ma(W,et,!0,o)}const $e=Xje(qe,S,t.modifiersStyles),Ze=$je(qe,a,t.modifiersClassNames),rt=!ue&&!qe.hidden?ee(et,qe,o.options,o):void 0;return C.createElement(n.Day,{key:`${o.format(et,"yyyy-MM-dd")}_${o.format(He.displayMonth,"yyyy-MM")}`,day:He,modifiers:qe,className:Ze.join(" "),style:$e,role:"gridcell","aria-selected":qe.selected||void 0,"aria-label":rt,"data-day":o.format(et,"yyyy-MM-dd"),"data-month":He.outside?o.format(et,"yyyy-MM"):void 0,"data-selected":qe.selected||void 0,"data-disabled":qe.disabled||void 0,"data-hidden":qe.hidden||void 0,"data-outside":He.outside||void 0,"data-focused":qe.focused||void 0,"data-today":qe.today||void 0},!qe.hidden&&ue?C.createElement(n.DayButton,{className:a[Ue.DayButton],style:S==null?void 0:S[Ue.DayButton],type:"button",day:He,modifiers:qe,disabled:qe.disabled||void 0,tabIndex:H(He)?0:-1,"aria-label":G(et,qe,o.options,o),onClick:We(He,qe),onBlur:fe(He,qe),onFocus:re(He,qe),onKeyDown:De(He,qe),onMouseEnter:Oe(He,qe),onMouseLeave:Me(He,qe)},k(et,o.options,o)):!qe.hidden&&k(He.date,o.options,o))})))))))),t.footer&&C.createElement(n.Footer,{className:a[Ue.Footer],style:S==null?void 0:S[Ue.Footer],role:"status","aria-live":"polite"},t.footer)))}function $0({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:s="ghost",formatters:o,components:i,...a}){const l=UD();return u.jsx(P_e,{showOutsideDays:n,className:K("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:c=>c.toLocaleString("default",{month:"short"}),...o},classNames:{root:K("w-fit",l.root),months:K("relative flex flex-col gap-4 md:flex-row",l.months),month:K("flex w-full flex-col gap-4",l.month),nav:K("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",l.nav),button_previous:K(vm({variant:s}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",l.button_previous),button_next:K(vm({variant:s}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",l.button_next),month_caption:K("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",l.month_caption),dropdowns:K("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",l.dropdowns),dropdown_root:K("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",l.dropdown_root),dropdown:K("bg-popover absolute inset-0 opacity-0",l.dropdown),caption_label:K("select-none font-medium",r==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",l.caption_label),table:"w-full border-collapse",weekdays:K("flex",l.weekdays),weekday:K("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",l.weekday),week:K("mt-2 flex w-full",l.week),week_number_header:K("w-[--cell-size] select-none",l.week_number_header),week_number:K("text-muted-foreground select-none text-[0.8rem]",l.week_number),day:K("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",l.day),range_start:K("bg-accent rounded-l-md",l.range_start),range_middle:K("rounded-none",l.range_middle),range_end:K("bg-accent rounded-r-md",l.range_end),today:K("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",l.today),outside:K("text-muted-foreground aria-selected:text-muted-foreground",l.outside),disabled:K("text-muted-foreground opacity-50",l.disabled),hidden:K("invisible",l.hidden),...t},components:{Root:({className:c,rootRef:d,...f})=>u.jsx("div",{"data-slot":"calendar",ref:d,className:K(c),...f}),Chevron:({className:c,orientation:d,...f})=>d==="left"?u.jsx(y$,{className:K("size-4",c),...f}):d==="right"?u.jsx(La,{className:K("size-4",c),...f}):u.jsx(js,{className:K("size-4",c),...f}),DayButton:O_e,WeekNumber:({children:c,...d})=>u.jsx("td",{...d,children:u.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:c})}),...i},...a})}function O_e({className:e,day:t,modifiers:n,...r}){const s=UD(),o=E.useRef(null);return E.useEffect(()=>{var i;n.focused&&((i=o.current)==null||i.focus())},[n.focused]),u.jsx(ie,{ref:o,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:K("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",s.day,e),...r})}var AU=E.forwardRef((e,t)=>{const{children:n,...r}=e,s=E.Children.toArray(n),o=s.find(F_e);if(o){const i=o.props.children,a=s.map(l=>l===o?E.Children.count(i)>1?E.Children.only(null):E.isValidElement(i)?i.props.children:null:l);return u.jsx(Pk,{...r,ref:t,children:E.isValidElement(i)?E.cloneElement(i,void 0,a):null})}return u.jsx(Pk,{...r,ref:t,children:n})});AU.displayName="Slot";var Pk=E.forwardRef((e,t)=>{const{children:n,...r}=e;if(E.isValidElement(n)){const s=L_e(n),o=$_e(r,n.props);return n.type!==E.Fragment&&(o.ref=t?us(t,s):s),E.cloneElement(n,o)}return E.Children.count(n)>1?E.Children.only(null):null});Pk.displayName="SlotClone";var PU=({children:e})=>u.jsx(u.Fragment,{children:e});function F_e(e){return E.isValidElement(e)&&e.type===PU}function $_e(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...a)=>{o(...a),s(...a)}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function L_e(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var WD="Dialog",[OU,FU]=yr(WD),[z_e,di]=OU(WD),$U=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!0}=e,a=E.useRef(null),l=E.useRef(null),[c=!1,d]=Mr({prop:r,defaultProp:s,onChange:o});return u.jsx(z_e,{scope:t,triggerRef:a,contentRef:l,contentId:Gn(),titleId:Gn(),descriptionId:Gn(),open:c,onOpenChange:d,onOpenToggle:E.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};$U.displayName=WD;var LU="DialogTrigger",zU=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=di(LU,n),o=at(t,s.triggerRef);return u.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":GD(s.open),...r,ref:o,onClick:we(e.onClick,s.onOpenToggle)})});zU.displayName=LU;var qD="DialogPortal",[B_e,BU]=OU(qD,{forceMount:void 0}),VU=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,o=di(qD,t);return u.jsx(B_e,{scope:t,forceMount:n,children:E.Children.map(r,i=>u.jsx(Zn,{present:n||o.open,children:u.jsx(ed,{asChild:!0,container:s,children:i})}))})};VU.displayName=qD;var L0="DialogOverlay",HU=E.forwardRef((e,t)=>{const n=BU(L0,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,o=di(L0,e.__scopeDialog);return o.modal?u.jsx(Zn,{present:r||o.open,children:u.jsx(V_e,{...s,ref:t})}):null});HU.displayName=L0;var V_e=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=di(L0,n);return u.jsx(lh,{as:AU,allowPinchZoom:!0,shards:[s.contentRef],children:u.jsx(Re.div,{"data-state":GD(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Fu="DialogContent",UU=E.forwardRef((e,t)=>{const n=BU(Fu,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,o=di(Fu,e.__scopeDialog);return u.jsx(Zn,{present:r||o.open,children:o.modal?u.jsx(H_e,{...s,ref:t}):u.jsx(U_e,{...s,ref:t})})});UU.displayName=Fu;var H_e=E.forwardRef((e,t)=>{const n=di(Fu,e.__scopeDialog),r=E.useRef(null),s=at(t,n.contentRef,r);return E.useEffect(()=>{const o=r.current;if(o)return Mg(o)},[]),u.jsx(WU,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:we(e.onCloseAutoFocus,o=>{var i;o.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:we(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&o.preventDefault()}),onFocusOutside:we(e.onFocusOutside,o=>o.preventDefault())})}),U_e=E.forwardRef((e,t)=>{const n=di(Fu,e.__scopeDialog),r=E.useRef(!1),s=E.useRef(!1);return u.jsx(WU,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,o),o.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),o.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:o=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),WU=E.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,...i}=e,a=di(Fu,n),l=E.useRef(null),c=at(t,l);return sw(),u.jsxs(u.Fragment,{children:[u.jsx(hh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:o,children:u.jsx(Ju,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":GD(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(q_e,{titleId:a.titleId}),u.jsx(G_e,{contentRef:l,descriptionId:a.descriptionId})]})]})}),YD="DialogTitle",qU=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=di(YD,n);return u.jsx(Re.h2,{id:s.titleId,...r,ref:t})});qU.displayName=YD;var YU="DialogDescription",GU=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=di(YU,n);return u.jsx(Re.p,{id:s.descriptionId,...r,ref:t})});GU.displayName=YU;var ZU="DialogClose",KU=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=di(ZU,n);return u.jsx(Re.button,{type:"button",...r,ref:t,onClick:we(e.onClick,()=>s.onOpenChange(!1))})});KU.displayName=ZU;function GD(e){return e?"open":"closed"}var XU="DialogTitleWarning",[W_e,QU]=wse(XU,{contentName:Fu,titleName:YD,docsSlug:"dialog"}),q_e=({titleId:e})=>{const t=QU(XU),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
887
887
 
888
888
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
@@ -907,11 +907,11 @@ Defaulting to \`null\`.`}const DW=EW,XDe=YDe,XD=E.forwardRef(({className:e,value
907
907
  font-size: .6rem;
908
908
  font-weight: bold;
909
909
  color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,s),s}}function $C(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const yTe=(e,t)=>Math.abs(e-t)<1,xTe=(e,t,n)=>{let r;return function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)}},vTe=e=>e,wTe=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let s=t;s<=n;s++)r.push(s);return r},STe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=i=>{const{width:a,height:l}=i;t({width:Math.round(a),height:Math.round(l)})};if(s(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const a=()=>{const l=i[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){s({width:c.inlineSize,height:c.blockSize});return}}s(n.getBoundingClientRect())};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},sF={passive:!0},oF=typeof window>"u"?!0:"onscrollend"in window,CTe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let s=0;const o=e.options.useScrollendEvent&&oF?()=>{}:xTe(r,()=>{t(s,!1)},e.options.isScrollingResetDelay),i=d=>()=>{const{horizontal:f,isRtl:h}=e.options;s=f?n.scrollLeft*(h&&-1||1):n.scrollTop,o(),t(s,d)},a=i(!0),l=i(!1);l(),n.addEventListener("scroll",a,sF);const c=e.options.useScrollendEvent&&oF;return c&&n.addEventListener("scrollend",l,sF),()=>{n.removeEventListener("scroll",a),c&&n.removeEventListener("scrollend",l)}},NTe=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(e.getBoundingClientRect()[n.options.horizontal?"width":"height"])},kTe=(e,{adjustments:t=0,behavior:n},r)=>{var s,o;const i=e+t;(o=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||o.call(s,{[r.options.horizontal?"left":"top"]:i,behavior:n})};class ETe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(s=>{s.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),n=null},observe:s=>{var o;return(o=r())==null?void 0:o.observe(s,{box:"border-box"})},unobserve:s=>{var o;return(o=r())==null?void 0:o.unobserve(s)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,s])=>{typeof s>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:vTe,rangeExtractor:wTe,onChange:()=>{},measureElement:NTe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,n)},this.maybeNotify=kd(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const s=new Map,o=new Map;for(let i=r-1;i>=0;i--){const a=n[i];if(s.has(a.lane))continue;const l=o.get(a.lane);if(l==null||a.end>l.end?o.set(a.lane,a):a.end<l.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=kd(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,s,o,i)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i}),{key:!1}),this.getMeasurements=kd(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const c=this.measurementsCache.slice(0,l);for(let d=l;d<n;d++){const f=o(d),h=this.options.lanes===1?c[d-1]:this.getFurthestMeasurement(c,d),p=h?h.end+this.options.gap:r+s,m=a.get(f),g=typeof m=="number"?m:this.options.estimateSize(d),b=p+g,y=h?h.lane:d%this.options.lanes;c[d]={index:d,start:p,size:g,end:b,key:f,lane:y}}return this.measurementsCache=c,c},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=kd(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,s,o)=>this.range=n.length>0&&r>0?jTe({measurements:n,outerSize:r,scrollOffset:s,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=kd(()=>{let n=null,r=null;const s=this.calculateRange();return s&&(n=s.startIndex,r=s.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,s,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:r,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,s=n.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const s=this.indexFromElement(n),o=this.measurementsCache[s];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(i,n)),n.isConnected&&this.resizeItem(s,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const s=this.measurementsCache[n];if(!s)return;const o=this.itemSizeCache.get(s.key)??s.size,i=r-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,i,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(n,void 0)},this.getVirtualItems=kd(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const s=[];for(let o=0,i=n.length;o<i;o++){const a=n[o],l=r[a];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return $C(r[uq(0,r.length-1,s=>$C(r[s]).start,n)])},this.getOffsetForAlignment=(n,r,s=0)=>{const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+o?"end":"start"),r==="center"?n+=(s-o)/2:r==="end"&&(n-=o);const a=this.options.horizontal?"scrollWidth":"scrollHeight",c=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[a]:this.scrollElement[a]:0)-o;return Math.max(Math.min(c,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.measurementsCache[n];if(!s)return;const o=this.getSize(),i=this.getScrollOffset();if(r==="auto")if(s.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(s.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];const a=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:s}={})=>{this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(n,{align:r="auto",behavior:s}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const o=this.getOffsetForIndex(n,r);if(!o)return;const[i,a]=o;this._scrollToOffset(i,{adjustments:void 0,behavior:s}),s!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[c]=$C(this.getOffsetForIndex(n,a));yTe(c,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:s})}else this.scrollToIndex(n,{align:a,behavior:s})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let s;return r.length===0?s=this.options.paddingStart:s=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(o=>o.end)),Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:s})=>{this.options.scrollToFn(n,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const uq=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,o=n(s);if(o<r)e=s+1;else if(o>r)t=s-1;else return s}return e>0?e-1:0};function jTe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const s=e.length-1;let i=uq(0,s,l=>e[l].start,n),a=i;for(;a<s&&e[a].end<n+t;)a++;return r>1&&(i=Math.max(0,i-i%r),a=Math.min(s,a+(r-1-a%r))),{startIndex:i,endIndex:a}}const iF=typeof document<"u"?E.useLayoutEffect:E.useEffect;function _Te(e){const t=E.useReducer(()=>({}),{})[1],n={...e,onChange:(s,o)=>{var i;o?_n.flushSync(t):t(),(i=e.onChange)==null||i.call(e,s,o)}},[r]=E.useState(()=>new ETe(n));return r.setOptions(n),iF(()=>r._didMount(),[]),iF(()=>r._willUpdate()),r}function DTe(e){return _Te({observeElementRect:STe,observeElementOffset:CTe,scrollToFn:kTe,...e})}function MTe(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function TTe(e=MTe){return C.useCallback((t,n)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(n==null?void 0:n[r])}return e(t,n)},[e])}function RTe(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function aF(e,t=!1){let[n,r]=C.useReducer(()=>({}),{}),s=C.useMemo(()=>RTe(e),[e,n]);return Bn(()=>{if(!e)return;let o=new ResizeObserver(r);return o.observe(e),()=>{o.disconnect()}},[e]),t?{width:`${s.width}px`,height:`${s.height}px`}:s}let ITe=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function dq(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(s){return r.add(s),()=>r.delete(s)},dispatch(s,...o){let i=t[s].call(n,...o);i&&(n=i,r.forEach(a=>a()))}}}function fq(e){return C.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let ATe=new ITe(()=>dq(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function lM(e,t){let n=ATe.get(t),r=C.useId(),s=fq(n);if(Bn(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let o=s.indexOf(r),i=s.length;return o===-1&&(o=i,i+=1),o===i-1}let qk=new Map,rm=new Map;function lF(e){var t;let n=(t=rm.get(e))!=null?t:0;return rm.set(e,n+1),n!==0?()=>cF(e):(qk.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>cF(e))}function cF(e){var t;let n=(t=rm.get(e))!=null?t:1;if(n===1?rm.delete(e):rm.set(e,n-1),n!==1)return;let r=qk.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,qk.delete(e))}function PTe(e,{allowed:t,disallowed:n}={}){let r=lM(e,"inert-others");Bn(()=>{var s,o;if(!r)return;let i=qi();for(let l of(s=n==null?void 0:n())!=null?s:[])l&&i.add(lF(l));let a=(o=t==null?void 0:t())!=null?o:[];for(let l of a){if(!l)continue;let c=lb(l);if(!c)continue;let d=l.parentElement;for(;d&&d!==c.body;){for(let f of d.children)a.some(h=>f.contains(h))||i.add(lF(f));d=d.parentElement}}return i.dispose},[r,t,n])}function OTe(e,t,n){let r=id(s=>{let o=s.getBoundingClientRect();o.x===0&&o.y===0&&o.width===0&&o.height===0&&n()});C.useEffect(()=>{if(!e)return;let s=t===null?null:t instanceof HTMLElement?t:t.current;if(!s)return;let o=qi();if(typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}if(typeof IntersectionObserver<"u"){let i=new IntersectionObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}return()=>o.dispose()},[t,r,e])}let Yk=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var FTe=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(FTe||{}),$Te=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))($Te||{}),LTe=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(LTe||{}),hq=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(hq||{});function zTe(e,t=0){var n;return e===((n=lb(e))==null?void 0:n.body)?!1:Oa(t,{0(){return e.matches(Yk)},1(){let r=e;for(;r!==null;){if(r.matches(Yk))return!0;r=r.parentElement}return!1}})}var BTe=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(BTe||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function VTe(e,t=n=>n){return e.slice().sort((n,r)=>{let s=t(n),o=t(r);if(s===null||o===null)return 0;let i=s.compareDocumentPosition(o);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pq(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function HTe(){return/Android/gi.test(window.navigator.userAgent)}function mq(){return pq()||HTe()}function rp(e,t,n,r){let s=id(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return document.addEventListener(t,o,r),()=>document.removeEventListener(t,o,r)},[e,t,r])}function UTe(e,t,n,r){let s=id(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return window.addEventListener(t,o,r),()=>window.removeEventListener(t,o,r)},[e,t,r])}const uF=30;function WTe(e,t,n){let r=lM(e,"outside-click"),s=id(n),o=C.useCallback(function(l,c){if(l.defaultPrevented)return;let d=c(l);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let f=function h(p){return typeof p=="function"?h(p()):Array.isArray(p)||p instanceof Set?p:[p]}(t);for(let h of f)if(h!==null&&(h.contains(d)||l.composed&&l.composedPath().includes(h)))return;return!zTe(d,hq.Loose)&&d.tabIndex!==-1&&l.preventDefault(),s.current(l,d)},[s,t]),i=C.useRef(null);rp(r,"pointerdown",l=>{var c,d;i.current=((d=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:d[0])||l.target},!0),rp(r,"mousedown",l=>{var c,d;i.current=((d=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:d[0])||l.target},!0),rp(r,"click",l=>{mq()||i.current&&(o(l,()=>i.current),i.current=null)},!0);let a=C.useRef({x:0,y:0});rp(r,"touchstart",l=>{a.current.x=l.touches[0].clientX,a.current.y=l.touches[0].clientY},!0),rp(r,"touchend",l=>{let c={x:l.changedTouches[0].clientX,y:l.changedTouches[0].clientY};if(!(Math.abs(c.x-a.current.x)>=uF||Math.abs(c.y-a.current.y)>=uF))return o(l,()=>l.target instanceof HTMLElement?l.target:null)},!0),UTe(r,"blur",l=>o(l,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function r1(...e){return C.useMemo(()=>lb(...e),[...e])}function qTe(e,t,n,r){let s=id(n);C.useEffect(()=>{e=e??window;function o(i){s.current(i)}return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)},[e,t,r])}function gq(e){let t=C.useRef({value:"",selectionStart:null,selectionEnd:null});return qTe(e,"blur",n=>{let r=n.target;r instanceof HTMLInputElement&&(t.current={value:r.value,selectionStart:r.selectionStart,selectionEnd:r.selectionEnd})}),yt(()=>{if(document.activeElement!==e&&e instanceof HTMLInputElement&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:"",selectionStart:null,selectionEnd:null}}})}function YTe(e,t){return C.useMemo(()=>{var n;if(e.type)return e.type;let r=(n=e.as)!=null?n:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function GTe(){let e;return{before({doc:t}){var n;let r=t.documentElement,s=(n=t.defaultView)!=null?n:window;e=Math.max(0,s.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,s=Math.max(0,r.clientWidth-r.offsetWidth),o=Math.max(0,e-s);n.style(r,"paddingRight",`${o}px`)}}}function ZTe(){return pq()?{before({doc:e,d:t,meta:n}){function r(s){return n.containers.flatMap(o=>o()).some(o=>o.contains(s))}t.microTask(()=>{var s;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=qi();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let o=(s=window.scrollY)!=null?s:window.pageYOffset,i=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let l=a.target.closest("a");if(!l)return;let{hash:c}=new URL(l.href),d=e.querySelector(c);d&&!r(d)&&(i=d)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let l=a.target;for(;l.parentElement&&r(l.parentElement);)l=l.parentElement;t.style(l,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let l=a.target;for(;l.parentElement&&l.dataset.headlessuiPortal!==""&&!(l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth);)l=l.parentElement;l.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let l=(a=window.scrollY)!=null?a:window.pageYOffset;o!==l&&window.scrollTo(0,o),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{}}function KTe(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function XTe(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let Wc=dq(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:qi(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:XTe(n)},s=[ZTe(),GTe(),KTe()];s.forEach(({before:o})=>o==null?void 0:o(r)),s.forEach(({after:o})=>o==null?void 0:o(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Wc.subscribe(()=>{let e=Wc.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",s=n.count!==0;(s&&!r||!s&&r)&&Wc.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&Wc.dispatch("TEARDOWN",n)}});function QTe(e,t,n=()=>({containers:[]})){let r=fq(Wc),s=t?r.get(t):void 0,o=s?s.count>0:!1;return Bn(()=>{if(!(!t||!e))return Wc.dispatch("PUSH",t,n),()=>Wc.dispatch("POP",t,n)},[e,t]),o}function JTe(e,t,n=()=>[document.body]){let r=lM(e,"scroll-lock");QTe(r,t,s=>{var o;return{containers:[...(o=s.containers)!=null?o:[],n]}})}function dF(e){return[e.screenX,e.screenY]}function eRe(){let e=C.useRef([-1,-1]);return{wasMoved(t){let n=dF(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=dF(t)}}}function tRe(e=0){let[t,n]=C.useState(e),r=C.useCallback(l=>n(l),[t]),s=C.useCallback(l=>n(c=>c|l),[t]),o=C.useCallback(l=>(t&l)===l,[t]),i=C.useCallback(l=>n(c=>c&~l),[n]),a=C.useCallback(l=>n(c=>c^l),[n]);return{flags:t,setFlag:r,addFlag:s,hasFlag:o,removeFlag:i,toggleFlag:a}}var fF,hF;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((fF=process==null?void 0:process.env)==null?void 0:fF.NODE_ENV)==="test"&&typeof((hF=Element==null?void 0:Element.prototype)==null?void 0:hF.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
910
- `)),[]});var nRe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nRe||{});function rRe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function sRe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=tRe(e&&s?3:0),c=C.useRef(!1),d=C.useRef(!1),f=cb();return Bn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),oRe(t,{inFlight:c,prepare(){d.current?d.current=!1:d.current=c.current,c.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function oRe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=qi();return aRe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(iRe(e,r))})}),o.dispose}function iRe(e,t){var n,r;let s=qi();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function aRe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lRe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Bn(()=>{if(!t||!e)return;let i=lb(t);if(!i)return;let a=s.current,l=o.current,c=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,c,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function pF(e,t){let n=C.useRef([]),r=yt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function cRe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const bq={...E},uRe=bq.useInsertionEffect,dRe=uRe||(e=>e());function yq(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return dRe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Gk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let mF=!1,fRe=0;const gF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+fRe++;function hRe(){const[e,t]=E.useState(()=>mF?gF():void 0);return Gk(()=>{e==null&&t(gF())},[]),E.useEffect(()=>{mF=!0},[]),e}const pRe=bq.useId,mRe=pRe||hRe;let Km;process.env.NODE_ENV!=="production"&&(Km=new Set);function gRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.warn(s)}}function bRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.error(s)}}function yRe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const xRe=E.createContext(null),vRe=E.createContext(null),wRe=()=>{var e;return((e=E.useContext(xRe))==null?void 0:e.id)||null},SRe=()=>E.useContext(vRe),CRe="data-floating-ui-focusable";function NRe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=mRe(),o=E.useRef({}),[i]=E.useState(()=>yRe()),a=wRe()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Br(p)&&bRe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,c]=E.useState(r.reference),d=yq((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:c}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function kRe(e){e===void 0&&(e={});const{nodeId:t}=e,n=NRe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=SRe();Gk(()=>{d&&(f.current=d)},[d]);const p=Ez({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Br(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Br(v)||v===null)&&(f.current=v,i(v)),(Br(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Br(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),y=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),x=E.useMemo(()=>({...p,...r,refs:b,elements:y,nodeId:t}),[p,b,y,t,r]);return Gk(()=>{r.dataRef.current.floatingContext=x;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=x)}),E.useMemo(()=>({...p,context:x,refs:b,elements:y}),[p,b,y,x])}const bF="active",yF="selected";function LC(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[bF]:i,[yF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[CRe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[c,d]=l;if(!(s&&[bF,yF].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof d=="function"){var f;(f=r.get(c))==null||f.push(d),i[c]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(c))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[c]=d}),i),{})}}function ERe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>LC(a,e,"reference"),t),o=E.useCallback(a=>LC(a,e,"floating"),n),i=E.useCallback(a=>LC(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const jRe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:c,...d}=Vi(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(c==null?void 0:c.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,y=m.clientTop!==0,x=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||gRe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await l_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await MS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await MS(v,{...d,elementContext:"reference"}),N=zr(0,w.top),k=v.y+N,D=(m.scrollHeight>m.clientHeight?M=>M:Nm)(zr(0,m.scrollHeight+(b&&x||y?g*2:0)-N-zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const M=m.offsetHeight<p.offsetHeight*Va(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Fl.flushSync(()=>s(M))}return r&&(r.current=await MS(xF({...v,y:k},m.offsetHeight+g+h.clientTop),d)),{y:k}}});function _Re(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=yq(a),c=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,y=o.current.top>=-.5,x=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!y&&b>0||!x&&b<0?(g.preventDefault(),Fl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(cRe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){c.current=!0},onWheel(){c.current=!1},onPointerMove(){c.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!c.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Fl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let ub=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});ub.displayName="FloatingContext";let cM=C.createContext(null);cM.displayName="PlacementContext";function DRe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function MRe(){return C.useContext(ub).setReference}function TRe(){let{getFloatingProps:e,slot:t}=C.useContext(ub);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RRe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(cM),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Bn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(ub);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let vF=4;function IRe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);ARe(a);let c=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=PRe(n,a),[g,b="center"]=d.split(" ");Bn(()=>{c&&o(0)},[c]);let{refs:y,floatingStyles:x,context:v}=kRe({open:c,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[l_({mainAxis:g==="selection"?0:f,crossAxis:h}),jz({padding:p}),g!=="selection"&&_z({padding:p}),g==="selection"&&m?jRe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:vF,referenceOverflowThreshold:p,onFallbackChange(M){var T,O;if(!M)return;let A=v.elements.floating;if(!A)return;let P=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,F=Math.min(vF,A.childElementCount),V=0,U=0;for(let z of(O=(T=v.elements.floating)==null?void 0:T.childNodes)!=null?O:[])if(z instanceof HTMLElement){let I=z.offsetTop,B=I+z.clientHeight+P,L=A.scrollTop,R=L+A.clientHeight;if(I>=L&&B<=R)F--;else{U=Math.max(0,Math.min(B,R)-Math.max(I,L)),V=z.clientHeight;break}}F>=1&&o(z=>{let I=V*F-U+P;return z>=I?z:I})}}):null,Dz({padding:p,apply({availableWidth:M,availableHeight:T,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${M}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${T}px)`})}})].filter(Boolean),whileElementsMounted:Nz}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),k=_Re(v,{overflowRef:i,onChange:o}),{getReferenceProps:j,getFloatingProps:_}=ERe([k]),D=yt(M=>{l(M),y.setFloating(M)});return E.createElement(cM.Provider,{value:r},E.createElement(ub.Provider,{value:{setFloating:D,setReference:y.setReference,styles:x,getReferenceProps:j,getFloatingProps:_,slot:N}},e))}function ARe(e){Bn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function PRe(e,t){var n,r,s;let o=zC((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=zC((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=zC((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function zC(e,t,n=void 0){let r=cb(),s=yt((l,c)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!c)return[n,null];let d=wF(l,c);return[d,f=>{let h=xq(l);{let p=h.map(m=>window.getComputedStyle(c).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[y,x]of h.entries()){let v=window.getComputedStyle(c).getPropertyValue(x);if(p[y]!==v){p[y]=v,g=!0;break}}if(!g)return;let b=wF(l,c);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Bn(()=>{let[l,c]=s(e,t);if(a(l),!!c)return c(a)},[e,t]),i}function xq(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...xq(s)]:[r]}return[]}function wF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ORe({children:e,freeze:t}){let n=Zk(t,e);return C.createElement(C.Fragment,null,n)}function Zk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let uM=C.createContext(null);uM.displayName="OpenClosedContext";var Xm=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xm||{});function FRe(){return C.useContext(uM)}function $Re({value:e,children:t}){return C.createElement(uM.Provider,{value:e},t)}function LRe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Fc=[];LRe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Fc[0]===t.target)return;let n=t.target;n=n.closest(Yk),Fc.unshift(n??t.target),Fc=Fc.filter(r=>r!=null&&r.isConnected),Fc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function zRe(e){throw new Error("Unexpected object: "+e)}var ir=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ir||{});function SF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:zRe(e)}}var dM=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(dM||{});function BRe(e){let t=yt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,eq(()=>{n.current&&t()})}),[t])}function VRe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function HRe(){let e=VRe(),[t,n]=E.useState(xu.isHandoffComplete);return t&&xu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>xu.handoff(),[]),e?!1:t}let URe=C.createContext(!1);function WRe(){return C.useContext(URe)}function qRe(e){let t=WRe(),n=C.useContext(wq),r=r1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(xu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let vq=C.Fragment,YRe=hi(function(e,t){let n=e,r=C.useRef(null),s=Qa(lTe(f=>{r.current=f}),t),o=r1(r),i=qRe(r),[a]=C.useState(()=>{var f;return xu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(XRe),c=HRe();Bn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Bn(()=>{if(a&&l)return l.register(a)},[l,a]),BRe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=fi();return c?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:vq,name:"Portal"}),a):null});function GRe(e,t){let n=Qa(t),{enabled:r=!0,...s}=e,o=fi();return r?C.createElement(YRe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:vq,name:"Portal"})}let ZRe=C.Fragment,wq=C.createContext(null);function KRe(e,t){let{target:n,...r}=e,s={ref:Qa(t)},o=fi();return C.createElement(wq.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:ZRe,name:"Popover.Group"}))}let XRe=C.createContext(null),QRe=hi(GRe),JRe=hi(KRe),eIe=Object.assign(QRe,{Group:JRe});var tIe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(tIe||{}),nIe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(nIe||{}),rIe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rIe||{}),sIe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(sIe||{});function BC(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):VTe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let oIe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:c,disabled:d}=e.virtual,f=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>c,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:c.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=BC(e);if(i.activeOptionIndex===null){let c=i.options.findIndex(d=>!d.dataRef.current.disabled);c!==-1&&(i.activeOptionIndex=c)}let a=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=BC(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=BC(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},fM=C.createContext(null);fM.displayName="ComboboxActionsContext";function db(e){let t=C.useContext(fM);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,db),n}return t}let Sq=C.createContext(null);function iIe(e){let t=Th("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let c=t.optionsElement;if(!c)return[0,0];let d=window.getComputedStyle(c);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=DTe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Bn(()=>{a(c=>c+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(Sq.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:c=>{c&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(c=>{var d;return C.createElement(C.Fragment,{key:c.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[c.index]}),{key:`${i}-${c.key}`,"data-index":c.index,"aria-setsize":n.length,"aria-posinset":c.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${c.start}px)`,overflowAnchor:"none"}}))})))}let Qm=C.createContext(null);Qm.displayName="ComboboxDataContext";function Th(e){let t=C.useContext(Qm);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Th),n}return t}function aIe(e,t){return Oa(t.type,oIe,e,t)}let lIe=C.Fragment;function cIe(e,t){var n,r;let s=sM(),{value:o,defaultValue:i,onChange:a,form:l,name:c,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:y,...x}=e,v=QMe(i),[w=m?[]:void 0,S]=XMe(o,a,v),[N,k]=C.useReducer(aIe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),j=C.useRef(!1),_=C.useRef({static:!1,hold:!1}),D=TTe(d),M=yt(oe=>b?d===null?b.options.indexOf(oe):b.options.findIndex(de=>D(de,oe)):N.options.findIndex(de=>D(de.dataRef.current.value,oe))),T=C.useCallback(oe=>Oa(A.mode,{1:()=>w.some(de=>D(de,oe)),0:()=>D(w,oe)}),[w]),O=yt(oe=>N.activeOptionIndex===M(oe)),A=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:_,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(j.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let de=b.options.findIndex(le=>{var ke,ye;return!((ye=(ke=b.disabled)==null?void 0:ke.call(b,le))!=null&&ye)});if(de!==-1)return de}let oe=N.options.findIndex(de=>!de.dataRef.current.disabled);if(oe!==-1)return oe}return N.activeOptionIndex},calculateIndex:M,compare:D,isSelected:T,isActive:O}),[w,v,f,m,p,N,b]);Bn(()=>{var oe;b&&k({type:7,options:b.options,disabled:(oe=b.disabled)!=null?oe:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Bn(()=>{N.dataRef.current=A},[A]);let P=A.comboboxState===0;WTe(P,[A.buttonElement,A.inputElement,A.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var oe,de,le;return{open:A.comboboxState===0,disabled:f,activeIndex:A.activeOptionIndex,activeOption:A.activeOptionIndex===null?null:A.virtual?A.virtual.options[(oe=A.activeOptionIndex)!=null?oe:0]:(le=(de=A.options[A.activeOptionIndex])==null?void 0:de.dataRef.current.value)!=null?le:null,value:w}},[A,f,w]),V=yt(()=>{if(A.activeOptionIndex!==null){if($.setIsTyping(!1),A.virtual)R(A.virtual.options[A.activeOptionIndex]);else{let{dataRef:oe}=A.options[A.activeOptionIndex];R(oe.current.value)}$.goToOption(ir.Specific,A.activeOptionIndex)}}),U=yt(()=>{k({type:0}),j.current=!0}),z=yt(()=>{k({type:1}),j.current=!1,h==null||h()}),I=yt(oe=>{k({type:3,isTyping:oe})}),B=yt((oe,de,le)=>(j.current=!1,oe===ir.Specific?k({type:2,focus:ir.Specific,idx:de,trigger:le}):k({type:2,focus:oe,trigger:le}))),L=yt((oe,de)=>(k({type:4,payload:{id:oe,dataRef:de}}),()=>{A.isActive(de.current.value)&&(j.current=!0),k({type:5,id:oe})})),R=yt(oe=>Oa(A.mode,{0(){return S==null?void 0:S(oe)},1(){let de=A.value.slice(),le=de.findIndex(ke=>D(ke,oe));return le===-1?de.push(oe):de.splice(le,1),S==null?void 0:S(de)}})),W=yt(oe=>{k({type:6,trigger:oe})}),Y=yt(oe=>{k({type:8,element:oe})}),Z=yt(oe=>{k({type:9,element:oe})}),H=yt(oe=>{k({type:10,element:oe})}),$=C.useMemo(()=>({onChange:R,registerOption:L,goToOption:B,setIsTyping:I,closeCombobox:z,openCombobox:U,setActivationTrigger:W,selectActiveOption:V,setInputElement:Y,setButtonElement:Z,setOptionsElement:H}),[]),[q,G]=hTe(),ee=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=fi();return C.createElement(G,{value:q,props:{htmlFor:(r=A.inputElement)==null?void 0:r.id},slot:{open:A.comboboxState===0,disabled:f}},C.createElement(IRe,null,C.createElement(fM.Provider,{value:$},C.createElement(Qm.Provider,{value:A},C.createElement($Re,{value:Oa(A.comboboxState,{0:Xm.Open,1:Xm.Closed})},c!=null&&C.createElement(rTe,{disabled:f,data:w!=null?{[c]:w}:{},form:l,onReset:Q}),ne({ourProps:ee,theirProps:x,slot:F,defaultTag:lIe,name:"Combobox"}))))))}let uIe="input";function dIe(e,t){var n,r,s,o,i;let a=Th("Combobox.Input"),l=db("Combobox.Input"),c=C.useId(),d=iq(),{id:f=d||`headlessui-combobox-input-${c}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...y}=e,x=C.useRef(null),v=Qa(x,t,MRe(),l.setInputElement),w=r1(a.inputElement),S=cb(),N=yt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ir.Nothing)}),k=C.useMemo(()=>{var R;return typeof p=="function"&&a.value!==void 0?(R=p(a.value))!=null?R:"":typeof a.value=="string"?a.value:""},[a.value,p]);pF(([R,W],[Y,Z])=>{if(a.isTyping)return;let H=x.current;H&&((Z===0&&W===1||R!==Y)&&(H.value=R),requestAnimationFrame(()=>{if(a.isTyping||!H||(w==null?void 0:w.activeElement)!==H)return;let{selectionStart:$,selectionEnd:q}=H;Math.abs((q??0)-($??0))===0&&$===0&&H.setSelectionRange(H.value.length,H.value.length)}))},[k,a.comboboxState,w,a.isTyping]),pF(([R],[W])=>{if(R===0&&W===1){if(a.isTyping)return;let Y=x.current;if(!Y)return;let Z=Y.value,{selectionStart:H,selectionEnd:$,selectionDirection:q}=Y;Y.value="",Y.value=Z,q!==null?Y.setSelectionRange(H,$,q):Y.setSelectionRange(H,$)}},[a.comboboxState]);let j=C.useRef(!1),_=yt(()=>{j.current=!0}),D=yt(()=>{S.nextFrame(()=>{j.current=!1})}),M=yt(R=>{switch(l.setIsTyping(!0),R.key){case os.Enter:if(a.comboboxState!==0||j.current)return;if(R.preventDefault(),R.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case os.ArrowDown:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Next),1:()=>l.openCombobox()});case os.ArrowUp:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ir.Last)}});case os.Home:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.PageUp:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.End:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.PageDown:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.Escape:return a.comboboxState!==0?void 0:(R.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&R.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case os.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),T=yt(R=>{h==null||h(R),a.mode===0&&R.target.value===""&&N(),l.openCombobox()}),O=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);if(!((Y=a.optionsElement)!=null&&Y.contains(H))&&!((Z=a.buttonElement)!=null&&Z.contains(H))&&a.comboboxState===0)return R.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),A=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);(Y=a.buttonElement)!=null&&Y.contains(H)||(Z=a.optionsElement)!=null&&Z.contains(H)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=n1(),F=cTe(),{isFocused:V,focusProps:U}=JW({autoFocus:g}),{isHovered:z,hoverProps:I}=QW({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:z,focus:V,autofocus:g}),[a,z,V,g,m]),L=oM({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(R=>!R.dataRef.current.disabled&&a.compare(R.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:_,onCompositionEnd:D,onKeyDown:M,onChange:T,onFocus:A,onBlur:O},U,I);return fi()({ourProps:L,theirProps:y,slot:B,defaultTag:uIe,name:"Combobox.Input"})}let fIe="button";function hIe(e,t){var n;let r=Th("Combobox.Button"),s=db("Combobox.Button"),o=Qa(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:c=!1,...d}=e,f=gq(r.inputElement),h=yt(k=>{switch(k.key){case os.Space:case os.Enter:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case os.ArrowDown:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.First)),f();return;case os.ArrowUp:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.Last)),f();return;case os.Escape:if(r.comboboxState!==0)return;k.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&k.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=yt(k=>{k.preventDefault(),!iTe(k.currentTarget)&&(k.button===dM.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=n1([a]),{isFocusVisible:g,focusProps:b}=JW({autoFocus:c}),{isHovered:y,hoverProps:x}=QW({isDisabled:l}),{pressed:v,pressProps:w}=UMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:y,focus:g}),[r,y,g,v,l]),N=oM({ref:o,id:a,type:YTe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:c,onMouseDown:p,onKeyDown:h},b,x,w);return fi()({ourProps:N,theirProps:d,slot:S,defaultTag:fIe,name:"Combobox.Button"})}let pIe="div",mIe=Wk.RenderStrategy|Wk.Static;function gIe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:c=!1,modal:d=!0,transition:f=!1,...h}=e,p=Th("Combobox.Options"),m=db("Combobox.Options"),g=DRe(l);g&&(c=!0);let[b,y]=RRe(g),[x,v]=C.useState(null),w=TRe(),S=Qa(t,g?b:null,m.setOptionsElement,v),N=r1(p.optionsElement),k=FRe(),[j,_]=sRe(f,x,k!==null?(k&Xm.Open)===Xm.Open:p.comboboxState===0);OTe(j,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;JTe(D,N);let M=p.__demoMode?!1:d&&p.comboboxState===0;PTe(M,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Bn(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),Bn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),lRe(p.comboboxState===0,{container:p.optionsElement,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let T=n1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),A=yt(()=>{m.setActivationTrigger(0)}),P=yt(L=>{L.preventDefault(),m.setActivationTrigger(0)}),F=oM(g?w():{},{"aria-labelledby":T,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":aF(p.inputElement,!0).width,"--button-width":aF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:A,onMouseDown:P,...rRe(_)}),V=j&&p.comboboxState===1,U=Zk(V,(r=p.virtual)==null?void 0:r.options),z=Zk(V,p.value),I=yt(L=>p.compare(z,L));if(p.virtual){if(U===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(Qm.Provider,{value:U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},C.createElement(iIe,{slot:O},h.children))})}let B=fi();return C.createElement(eIe,{enabled:c?e.static||j:!1},C.createElement(Qm.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(ORe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:pIe,features:mIe,visible:j,name:"Combobox.Options"})))}let bIe="div";function yIe(e,t){var n,r,s,o;let i=Th("Combobox.Option"),a=db("Combobox.Option"),l=C.useId(),{id:c=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=gq(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===c,b=i.isSelected(d),y=C.useRef(null),x=id({disabled:f,value:d,domRef:y,order:h}),v=C.useContext(Sq),w=Qa(t,y,v?v.measureElement:null),S=yt(()=>{a.setIsTyping(!1),a.onChange(d)});Bn(()=>a.registerOption(c,x),[x,c]);let N=C.useRef(!(i.virtual||i.__demoMode));Bn(()=>{if(!i.virtual&&!i.__demoMode)return qi().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Bn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return qi().requestAnimationFrame(()=>{var P,F;(F=(P=y.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[y,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let k=yt(P=>{P.preventDefault(),P.button===dM.Left&&(f||(S(),mq()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),j=yt(()=>{if(f)return a.goToOption(ir.Nothing);let P=i.calculateIndex(d);a.goToOption(ir.Specific,P)}),_=eRe(),D=yt(P=>_.update(P)),M=yt(P=>{if(!_.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ir.Specific,F,0)}),T=yt(P=>{_.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ir.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),A={id:c,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:k,onFocus:j,onPointerEnter:D,onMouseEnter:D,onPointerMove:M,onMouseMove:M,onPointerLeave:T,onMouseLeave:T};return fi()({ourProps:A,theirProps:p,slot:O,defaultTag:bIe,name:"Combobox.Option"})}let xIe=hi(cIe),Cq=hi(hIe),Nq=hi(dIe),vIe=bTe,kq=hi(gIe),Eq=hi(yIe),wIe=Object.assign(xIe,{Input:Nq,Button:Cq,Label:vIe,Options:kq,Option:Eq});function SIe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const CIe=C.memo(({option:e,currentStyle:t})=>u.jsxs(Eq,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[u.jsx(_r,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function NIe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:c}){const[d,f]=C.useState(""),h=te(x=>x.themeStyle),p=C.useMemo(()=>{const x=s||e;return d===""?x:x==null?void 0:x.filter(v=>{var w;return v!=null&&v.value?(w=v.value)==null?void 0:w.toLowerCase().includes(d==null?void 0:d.toLowerCase()):!1})},[e,s,d]);function m(x){return x!=null&&x.length?x==null?void 0:x.map(v=>v.value).join(", "):""}function g(x){Array.isArray(x)||(x=[x]),t(x)}function b(){return p&&p.length>0?null:u.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function y(){return!r||!(p!=null&&p.length)?null:u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{children:"All"}),u.jsx(gn,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return u.jsx(wIe,{multiple:r,value:n,onChange:g,onClose:()=>f(""),children:({open:x})=>u.jsxs("div",{children:[u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[c&&u.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),u.jsx(Nq,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:h==null?void 0:h.controlInputRadius},displayValue:m,onChange:v=>f(v.target.value)}),u.jsx(Cq,{className:"group absolute inset-y-0 right-0 px-2.5",children:u.jsx(js,{className:"size-4 text-muted-foreground hover:text-foreground"})})]}),u.jsxs(kq,{anchor:"bottom",transition:!0,style:{borderRadius:h==null?void 0:h.controlInputRadius},className:Su("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[x&&u.jsx(SIe,{elementId:"headlessui-portal-root"}),b(),y(),p==null?void 0:p.map(v=>u.jsx(CIe,{option:v,currentStyle:h},v.id))]})]})})}function kIe({filter:e}){const t=te(f=>f.themeStyle),{filteredRecords:n,isSingleSelect:r,allSelected:s,handleChange:o,handleSelectAll:i,isLoading:a,isFetching:l,isError:c,selectedRecords:d}=nM(e);return a||l?u.jsx(Ia,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):c?u.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):u.jsx(NIe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>u.jsx(EIe,{filter:e}),inputClassName:"h-8",options:n,selectedOptions:d,onChange:o,multiple:!r,selectAllChecked:s,onSelectAllCheckedChange:i})}function EIe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n}=Qt();function r(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}return u.jsx(ie,{onClick:r,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:kv(t)})}function jIe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=nM(e);function s(i){n([{value:i,id:i}])}return u.jsx(ni,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Wn,{value:i.value,id:"r1"}),u.jsx(ae,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function hM({filter:e}){return Yu(e.dataType)?u.jsx(xMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?u.jsx(jIe,{filter:e}):u.jsx(kIe,{filter:e})}function _Ie({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Ba(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:c,isFetching:d}=Ba(a);return(a==null?void 0:a.type)!=="text"?u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):u.jsxs(Rs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?u.jsx("div",{className:"overflow-y-auto break-words p-1",children:u.jsx(Zf,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),u.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:u.jsx(ob,{disabled:c||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?u.jsx(cte,{className:"size-4 text-muted-foreground/70"}):u.jsx(ute,{className:"size-4 text-muted-foreground/70"})})})]})}function q0(e){return{clickFilter:Ca,drillToDetail:Dg,drillThrough:ej,drillToURL:_g,drillDown:hte,drillUp:pte,dynamicDrill:ec,inlineDrill:Mv}[e]||Ca}function ad(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function DIe(e,t,n,r,s){const o=q0(e.mode),i=e.label||ad(e.mode),a=MIe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function MIe(e,t,n=0,r,s){var o,i,a,l,c,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=OE(f,r,s),m=PE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(c=f.steps[n-2])==null?void 0:c.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function TIe(e,t,n,r,s){return e.map(o=>DIe(o,t,n,r,s))}function RIe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:c,breadcrumbs:d}=Kt(w=>{var S,N,k;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((k=w.interactionStates[a])==null?void 0:k.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>TIe(r,i,c,l,d),[r,i,c,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let y=n.x,x=n.y+8;y+p>g&&(y=Math.max(8,g-p-8)),x+m>b&&(x=Math.max(8,n.y-m-8));const v=u.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[u.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),u.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${y}px`,top:`${x}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&u.jsxs("div",{className:"border-b px-4 py-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),u.jsx("p",{className:"text-sm font-medium",children:h})]}),u.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var j;const N=w.icon,k=w.interaction.mode==="dynamicDrill"&&(S===0||((j=f[S-1])==null?void 0:j.interaction.mode)!=="dynamicDrill");return u.jsxs(E.Fragment,{children:[k&&u.jsx("div",{className:"border-t px-4 py-2",children:u.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),u.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[u.jsx("div",{className:"mt-0.5 flex-shrink-0",children:u.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&u.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function IIe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=_i(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=Rp(h=>h.registerClearBlurCallback),a=Rp(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((y,x)=>h.getDatasetMeta(x).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((y,x)=>{const v=b[x];if(p.length===0){y.backgroundColor=[...v];return}y.backgroundColor=v.map((w,S)=>p.some(k=>k.datasetIndex===x&&k.dataIndex===S)?w:c(w,.2))});try{h.update()}catch(y){console.warn("Failed to update chart during blur toggle:",y)}}function c(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],y={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(y)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[y]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function AIe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var c,d,f,h,p,m,g,b,y,x;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(c=o[0].element)==null?void 0:c.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=Qn(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,k=j=>w.find(_=>_.label===j)||S.find(_=>_.label===j)||N.find(_=>_.label===j);if(t.type==="map"){const j=v[0],_=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=k(j);return!D||_==null?void 0:{conditions:[{field:D,operator:"=",value:_}]}}if(["pie","funnel","doughnut"].includes(t.type)){const j=v[0],_=v==null?void 0:v[1+i],D=k(j),M=k(_),T=(g=n==null?void 0:n[a])==null?void 0:g[j];if(!D||T==null){console.log("no dim field or value",j,T);return}return{conditions:[{field:D,operator:"=",value:T}],metrics:M?[{field:M,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const j=v[0],_=k(j),D=(b=n==null?void 0:n[a])==null?void 0:b[j];if(!_||D==null){console.log("no dim field or value for stacked bar",j,D);return}const M=N[i]||N[0];if(!M){console.log("no metric field found");return}const T=S[0],A=Object.keys(n[0]).filter(U=>U!==j)[i],F=(A?(y=n==null?void 0:n[a])==null?void 0:y[A]:(x=n==null?void 0:n[a])==null?void 0:x[M.label])??l,V=[{field:_,operator:"=",value:D}];return T&&A&&V.push({field:T,operator:"=",value:A}),{conditions:V,metrics:[{field:M,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function PIe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function OIe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function jq({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?u.jsx("div",{className:"px-6 pb-4",children:u.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(c=>{var d,f;if(PIe(c))return{fieldName:((d=c.field)==null?void 0:d.label)||((f=c.field)==null?void 0:f.name)||"Unknown",operator:c.operator,value:$Ie(c)};if(OIe(c)){const h=t==null?void 0:t.find(p=>p.id===c.filterId);return{fieldName:(h==null?void 0:h.title)||c.name,operator:c.operation,value:FIe(c)}}else return{fieldName:"Unknown",operator:"=",value:String(c)}}).reduce((c,d)=>(c[d.fieldName]||(c[d.fieldName]=[]),c[d.fieldName].push(d),c),{});return u.jsxs("div",{className:r||"px-6 pb-4 border-b",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&i&&u.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,u.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:o})]}),s&&!i&&u.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:o}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([c,d])=>u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("span",{className:"text-sm font-medium",children:[c,":"]}),d.map((f,h)=>u.jsx(jt,{variant:"secondary",className:"border border-primary/20 bg-primary/10 text-primary",children:f.value},`${c}-${h}`))]},c))})]}),n&&u.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&u.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&u.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&u.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function FIe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function $Ie(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function LIe({cardId:e,className:t}){const n=Kt(d=>d.interactionStates[e]),r=Kt(d=>d.popInteractionStep),s=Kt(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),c=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return u.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&u.jsx(jq,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:u.jsx(gte,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(to,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(nte,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return u.jsx(si,{children:u.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[u.jsx(qr,{children:u.jsx(Yr,{asChild:!0,children:u.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:u.jsx(D$,{className:"h-3.5 w-3.5"})})})}),u.jsx(La,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),u.jsx("div",{className:"flex items-center",children:o.map((d,f)=>u.jsxs("div",{className:"flex items-center",children:[f>0&&u.jsx(La,{className:"mx-1 h-3 w-3 text-muted-foreground"}),u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(ie,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),u.jsx(KD,{className:"ml-4",side:"bottom",children:c(d)})]})]},f))})]})})}function zIe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function pM({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=zIe(s),i=ez(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:c=>{var d;return((d=a.overrides)==null?void 0:d[c])??!0}}},[t,n]);return u.jsx(Z6.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ne,oe,de,le,ke,ye,Pe,Ve,lt;const{customCards:n,placeholders:r,tokenProps:s}=Ye(),{shouldShowElement:o}=nc(),i=Kt(ue=>ue.interactionStates[e.id]),a=((ne=i==null?void 0:i.breadcrumbs)==null?void 0:ne.length)>0,l=te(ue=>ue.themeStyle),c=te(ue=>ue.selectedSheetId),d=te(ue=>ue.isDashboardEditing);te(ue=>ue.selectedLensId);const f=te(ue=>ue.dashboard.filters),h=f==null?void 0:f.find(ue=>ue.id===t.filterId&&!ue.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Qt(),{updateFrame:y}=Qt(),{handleChartClick:x}=IIe(e),v=o("showHeader")&&(((oe=e.customCardPreferences)==null?void 0:oe.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:k,isPending:j,data:_,handleDatapointClick:D,pagination:M}=Wg(e),[T,O]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:A,hierarchyId:P}=Kt(ue=>{var Ne,Je;return{breadcrumbs:((Ne=ue.interactionStates[e.id])==null?void 0:Ne.breadcrumbs)??[],hierarchyId:(Je=ue.interactionStates[e.id])==null?void 0:Je.hierarchyId}}),F=(ue,Ne,Je)=>{var Oe;const We=A.length>0?[{mode:"drillUp",trigger:(Oe=ue[0])==null?void 0:Oe.trigger,label:"Drill Up",hierarchyId:P}]:[],re=[];for(const Me of ue)if(Me.mode==="dynamicDrill"&&Me.availableFields){const nt=Me.availableFields.filter(Dt=>!A.some(ct=>{var Ot;return((Ot=ct.toField)==null?void 0:Ot.id)===Dt.id}));for(const Dt of nt)re.push({mode:"dynamicDrill",trigger:Me.trigger,drillField:Dt,label:Dt.label,availableFields:Me.availableFields})}const fe=ue.filter(Me=>Me.mode!=="dynamicDrill"),De=[...We,...fe,...re];O({open:!0,position:Je||{x:0,y:0},interactions:De,context:Ne})},{handlePointerInteraction:V,applySelectedInteraction:U}=UJ(e,F),z=b3(e),I=C.useMemo(()=>{var ue;return e.type!=="pivotTable"||!((ue=_==null?void 0:_.records)!=null&&ue.length)?null:{records:_.records,columnSubtotalMeta:_.columnSubtotalMeta,subtotalColumns:_.subtotalColumns||[],pivotSchema:_.pivotSchema||[],groupByColumns:_.groupByColumns}},[e.type,_==null?void 0:_.records,_==null?void 0:_.columnSubtotalMeta,_==null?void 0:_.subtotalColumns,_==null?void 0:_.pivotSchema,_==null?void 0:_.groupByColumns]),B=Ch(e,I),L=(ue,Ne)=>{const Je={...e,paginationConfig:{page:ue+1,pageSize:Ne}},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)};function R(ue,Ne){ue.stopPropagation();const Je=AIe({resolvedCardConfig:z,card:e,records:(_==null?void 0:_.records)||[],chart:Ne,clickEvent:ue.nativeEvent});if(!Je)return;const We=_i(e.interactionConfig),re=FE(We,Je),fe=re.length===1&&re[0].mode==="clickFilter",De=re.some(nt=>nt.mode==="dynamicDrill"),Oe=re.length>1||De;ue.button===0&&fe&&!Oe&&x(ue.nativeEvent,Ne);const Me={shift:ue.shiftKey,ctrl:ue.ctrlKey,meta:ue.metaKey};ue.button===0?V({context:Je,gesture:"leftClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}}):ue.button===2&&V({context:Je,gesture:"rightClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}})}function W(){var ue,Ne,Je;if(n&&n.length>0){const We=n.find(re=>re.cardId===e.id);if(We&&We.replaceDefault){const re=We.content;if(re)return u.jsx(re,{card:e})}}if(e.type==="kpi"){if(((ue=t==null?void 0:t.cards)==null?void 0:ue.length)===1)return u.jsx(Zm,{card:e,data:w?[]:(_==null?void 0:_.records)||[],isPending:j,isError:w});if(((Ne=t==null?void 0:t.cards)==null?void 0:Ne.length)>1)return u.jsx(_Ie,{frame:t})}return e.type==="text"&&((Je=t==null?void 0:t.cards)==null?void 0:Je.length)===1?u.jsx(Rs,{className:"my-4 overflow-y-auto break-words px-4",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})}):ee}function Y(){if(w)return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(Rv,{className:"size-8 text-destructive"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return u.jsx("div",{className:"flex h-full w-full items-center justify-center",children:u.jsx(Ou,{size:"md",color:"muted","aria-label":"Loading data"})});if(_!=null&&_.records&&(_==null?void 0:_.records.length)===0)return r!=null&&r.NoRecords?u.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(aj,{className:"size-8 text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(_==null?void 0:_.records)||[],paginationMetadata:M,onPaginationChange:L,isLoading:S||N})});if(e.type==="pivotTable"&&B)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:B.data,options:B.options,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},onAggregationLabelChange:ue=>{const Ne=zW(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)}})});if(e.type==="aggregateTable")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(_==null?void 0:_.records)||[],groupByColumns:_==null?void 0:_.groupByColumns,pivotSchema:_==null?void 0:_.pivotSchema,paginationMetadata:M,onPaginationChange:L,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},isLoading:S||N})});if(e.type==="text")return u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})});if(e.type==="custom")return u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})});if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.content){const Ne=ue.content;return u.jsx(Ne,{card:e})}}if(k)return u.jsx(Jg,{cfg:k,onChartClick:R,onDatapointClick:D})}function Z(){if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.footer){const Ne=ue.footer;if(Ne)return u.jsx(Ne,{card:e})}}return null}function H(){var Je;const ue=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}),Ne=l==null?void 0:l.controlInputRadius;return u.jsx(lo,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:We=>{const re={...t,activeCardId:We};y(c,re)},children:u.jsx(Os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(Je=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}))==null?void 0:Je.map((We,re)=>u.jsx(mn,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":re!==ue.length-1}),style:{borderTopLeftRadius:re===0?Ne:0,borderTopRightRadius:re===ue.length-1?Ne:0,borderBottomLeftRadius:re===0?Ne:0,borderBottomRightRadius:re===ue.length-1?Ne:0},value:We.id,children:We.tabTitle||We.title},We.id))})})}function $(){var Ne,Je,We,re;let ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle===`${e.tabTitle}__Header`);return ue||(ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle==="All__Header")),ue?u.jsx("div",{className:"flex items-end gap-2",children:u.jsx(fMe,{renderFilterInfo:()=>{var fe,De,Oe,Me;return o("showFilterInfo")&&((De=(fe=e.preferences)==null?void 0:fe.displayOptions)==null?void 0:De.showFilterInfo)!==!1?u.jsx(Lk,{cardId:e.id,cardFilters:(Oe=e.config)==null?void 0:Oe.filters,cardFilterCount:H0(((Me=e.config)==null?void 0:Me.filters)||null)}):null},card:ue})}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&u.jsx(zi,{className:K("text-base",{}),children:u.jsx(Do,{value:e.title,onSave:fe=>p(c,e.id,fe),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&u.jsx(LW,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&u.jsxs(qr,{children:[u.jsx(Yr,{className:"pr-1",children:u.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),u.jsx(fs,{side:"right",align:"center",children:u.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((Je=(Ne=e.preferences)==null?void 0:Ne.displayOptions)==null?void 0:Je.showFilterInfo)!==!1&&u.jsx(Lk,{cardId:e.id,cardFilters:(We=e.config)==null?void 0:We.filters,cardFilterCount:H0(((re=e.config)==null?void 0:re.filters)||null)})]}),u.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&u.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:u.jsx(Do,{value:(e==null?void 0:e.description)||"",onSave:fe=>m(c,e.id,fe),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&u.jsx(LIe,{cardId:e.id})]})]})}if(!e.id)return null;const q=((le=(de=e.preferences)==null?void 0:de.displayOptions)==null?void 0:le.showChrome)??!0,G=((ye=(ke=e.preferences)==null?void 0:ke.displayOptions)==null?void 0:ye.allowScroll)??!0,ee=q?u.jsxs(u.Fragment,{children:[v?u.jsx(Li,{children:u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:$()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx("div",{children:h&&o("showFilters")&&u.jsxs("div",{style:{borderRadius:(Ve=(Pe=l==null?void 0:l.chart)==null?void 0:Pe.options)==null?void 0:Ve.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!Yu(h.dataType)&&u.jsx(ae,{className:"my-1 shrink-0 px-3",children:u.jsx(Do,{value:h.title||h.column,onSave:ue=>b({...h,title:ue}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),u.jsx(hM,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&H()]})]})}):u.jsx("div",{className:"h-8"}),u.jsx($a,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:Y()}),o("showFooter")&&u.jsx(r$,{children:Z()})]}):Y(),Q=()=>q&&G?"flex h-full flex-col":q&&!G?"flex h-full flex-col overflow-hidden":!q&&!G?"h-full":"h-full overflow-auto";return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:K(Q(),{"animate-pulse":S||N}),children:W()}),T.context&&u.jsx(RIe,{open:T.open,onOpenChange:ue=>{O(Ne=>({...Ne,open:ue}))},position:T.position,interactions:T.interactions,selectedConditions:T.context.conditions,drillHierarchies:(lt=e.interactionConfig)==null?void 0:lt.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ue=>{T.context&&U(ue,T.context),O({open:!1,position:null,interactions:[],context:null})}})]})}function _q({card:e,frame:t}){return e.displayPreferences?u.jsx(pM,{displayPreferences:e.displayPreferences,children:u.jsx(CF,{card:e,frame:t})}):u.jsx(CF,{card:e,frame:t})}function BIe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Wg(e),c=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Ch(e,c);if(s||o)return u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return u.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?u.jsx(Zm,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})}):i?u.jsx(Jg,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return u.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&u.jsxs("div",{className:"border-b px-4 py-2",children:[u.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&u.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),u.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function Dq({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=dj(e,{enabled:!!e}),a=Kt(f=>f.setInteractionState),l=Kt(f=>f.resetInteractionState),c=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=c==null?void 0:c.cards)!=null&&f.length?c.activeCardId&&c.cards.find(h=>h.id===c.activeCardId)||c.cards[0]:null},[c]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...Wo(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...Wo(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!c||!d?u.jsx("div",{className:"flex items-center justify-center p-12",children:u.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):u.jsx("div",{className:"h-full w-full",children:u.jsx(BIe,{card:d,frame:c,showTitle:!1})})}function VIe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?u.jsxs(jt,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[u.jsx(Ca,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return u.jsx(si,{children:u.jsxs(qr,{delayDuration:200,children:[u.jsx(Yr,{asChild:!0,children:u.jsxs(jt,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[u.jsx(Ca,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),u.jsx(fs,{side:"bottom",align:"start",className:"max-w-md",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),u.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>u.jsxs("div",{className:"text-xs",children:[u.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>u.jsxs("span",{children:[HIe(i),a<o.length-1?", ":""]},a))]},s))}),t&&u.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:UIe(t)})]})})]})})}function HIe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function UIe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function Mq(e,t={}){const{enabled:n=!0}=t,{data:r}=dj(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,c;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((c=i==null?void 0:i.cards)!=null&&c.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function WIe({cardId:e,children:t}){const n=Kt(o=>o.replacedCards[e]),r=Kt(o=>o.restoreCard),s=Mq((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?u.jsxs("div",{className:"flex h-full w-full flex-col",children:[u.jsxs("div",{className:"border-b bg-muted/30",children:[u.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-muted-foreground",children:"-"}),u.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),u.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[u.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[u.jsx(o$,{className:"h-4 w-4"}),"Back"]}),u.jsx(VIe,{filters:n.filters,contextMode:n.contextMode})]})]}),u.jsx("div",{className:"min-h-0 flex-1",children:u.jsx(Dq,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):u.jsx(u.Fragment,{children:t})}function qIe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=te(N=>N.themeStyle),l=te(N=>N.isVisualEditing),c=te(N=>N.selectedFrameId),d=te(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Qt(),{clearSelectedVisual:h}=Eg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:y}=Gr();C.useEffect(()=>{if(c===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[c,e.id,d,l,s]);const x=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),x&&y(x),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&m(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&g(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable)}return u.jsx(uc,{FallbackComponent:OD,children:u.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":x==null?void 0:x.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":c===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=x==null?void 0:x.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&u.jsx(vW,{frame:e,isHovered:o}),x&&u.jsx(WIe,{cardId:x.id,children:u.jsx(_q,{card:x,frame:e},x.id)})]})})}function YIe({label:e,onCheckedChange:t,checked:n}){return u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{onCheckedChange:t,id:"terms",checked:n}),u.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function mM(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var GIe=["color"],ZIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,GIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KIe=["color"],Tq=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,KIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),XIe=["color"],QIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,XIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function eh({text:e,className:t}){const[n,r]=C.useState(!1);return u.jsx(ie,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?u.jsx(Tq,{className:"size-3.5"}):u.jsx(JE,{className:"size-3.5"})})}function JIe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=te(y=>y.dashboard.sheets)||[],o=C.useMemo(()=>{const y=[];return s==null||s.forEach(x=>{var v;(v=x.frames)==null||v.forEach(w=>{var S;(S=w.cards)==null||S.forEach(N=>{y.push({...N,sheetId:x.id,sheetTitle:x.title||x.id})})})}),y},[s]),i=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",a=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",l=y=>{const x={};switch(y){case"all-sheets":x.applyToSheetIds=void 0,x.excludeSheetIds=void 0;break;case"specific-sheets":x.applyToSheetIds=[],x.excludeSheetIds=void 0;break;case"all-except-specific":x.applyToSheetIds=void 0,x.excludeSheetIds=[];break}t(x)},c=y=>{const x={};switch(y){case"all-cards":x.applyToCardIds=void 0,x.excludeCardIds=void 0;break;case"specific-cards":x.applyToCardIds=[],x.excludeCardIds=void 0;break;case"all-except-specific":x.applyToCardIds=void 0,x.excludeCardIds=[];break}t(x)},d=(y,x)=>{if(x==="specific-sheets"){const v=e.applyToSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToSheetIds:w})}else if(x==="all-except-specific"){const v=e.excludeSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeSheetIds:w})}},f=(y,x)=>{if(x==="specific-cards"){const v=e.applyToCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToCardIds:w})}else if(x==="all-except-specific"){const v=e.excludeCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeCardIds:w})}},h=()=>{const y=i();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(x=>{var v;return!((v=e.excludeSheetIds)!=null&&v.includes(x.id))}).map(x=>x.id))||[]:(s==null?void 0:s.map(x=>x.id))||[]},p=C.useMemo(()=>{const y=h();return o.filter(x=>y.includes(x.sheetId))},[o,e.applyToSheetIds,e.excludeSheetIds]),m=C.useMemo(()=>{if(!n.trim())return p;const y=n.toLowerCase();return p.filter(x=>{var v;return(v=x==null?void 0:x.title)==null?void 0:v.toLowerCase().includes(y)})},[n,p]),g=i(),b=a();return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Sheet Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),u.jsxs(ni,{value:g,onValueChange:y=>l(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),g==="specific-sheets"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.applyToSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"specific-sheets")}),u.jsx(ae,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),g==="all-except-specific"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.excludeSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-exclude-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"all-except-specific")}),u.jsx(ae,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})})]})]}),u.jsxs("div",{className:"space-y-3 border-t pt-4",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Card Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),u.jsxs(ni,{value:b,onValueChange:y=>c(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",p.length," cards)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),b==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.applyToCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),b==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.excludeCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),u.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function eAe({filter:e}){const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[c,d]=C.useState(e.column),f=te(y=>y.selectedSheetId),{updateFilter:h}=Qt();function p(){const y=a.trim(),x=c.trim(),v={sql:t,...o},w=x||e.column;x&&x!==e.column&&(v.column=w),v.title=y||w;const S={...e,...v};h(S),i({}),s(!1)}C.useEffect(()=>{r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column))},[r,e.sql,e.title,e.column]);function m(y){const x={...e,type:y};h(x)}function g(y){const x={...e,uiType:y};h(x)}function b(y){if(!f)return;const x={...e,sheetId:y?f:void 0};h(x)}return u.jsxs(Ds,{open:r,onOpenChange:s,children:[u.jsx(Ms,{children:u.jsx(ou,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),u.jsx(Ts,{onMouseDown:y=>y.stopPropagation(),onDoubleClick:y=>y.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px] overflow-hidden",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),u.jsx(jt,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),u.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),u.jsxs(lo,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[u.jsxs(Os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[u.jsx(mn,{value:"scope",children:"Scope"}),u.jsx(mn,{value:"advanced",children:"Configuration"})]}),u.jsx(lr,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:u.jsx(JIe,{filter:{...e,...o},onUpdate:y=>{i(x=>({...x,...y}))}})}),u.jsxs(lr,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Custom Title (optional)"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),u.jsxs("div",{className:"space-y-1 border-t pt-2",children:[u.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),u.jsx(eh,{text:e.id})]})]})]})})]})})]}),u.jsx(pr,{value:a,onChange:y=>l(y.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Column Name"}),u.jsx(pr,{value:c,onChange:y=>d(y.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Selection Type"}),u.jsxs(ni,{onValueChange:m,value:e.type||"multiple",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"multiple",id:"r1"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r1",children:"Multiple"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"single",id:"r2"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r2",children:"Single"})]})]})]}),e.type==="single"&&u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"UI Component"}),u.jsxs(ni,{onValueChange:g,value:e.uiType||"dropdown",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"dropdown",id:"dropdown"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"dropdown",children:"Dropdown"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"radio",id:"radio"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"radio",children:"Radio"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"SQL"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),u.jsx(ch,{onKeyDown:y=>{y.stopPropagation()},value:t,onChange:y=>n(y.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${Kd}`,placeholder:"SELECT column FROM table..."})]}),u.jsx("div",{className:"border-t pt-2",children:u.jsx(YIe,{label:"Local to sheet",onCheckedChange:b,checked:!!e.sheetId})})]})]}),u.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:u.jsxs(ie,{onClick:p,size:"sm",variant:"outline",children:[u.jsx(_r,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}const Rq=C.createContext(void 0);function fb(){const e=C.useContext(Rq);return e||{preferences:{},isLocalDev:!1,isConsoleMode:!1}}function Iq({filter:e}){var c;const t=te(d=>d.isDashboardEditing),{preferences:n}=fb(),r=((c=n==null?void 0:n.cardDisplay)==null?void 0:c.mode)==="print",s=te(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Qt();return u.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[u.jsxs("div",{className:"flex grow items-center gap-2",children:[u.jsx(ae,{className:"my-1 inline-block text-sm",children:u.jsx(Do,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&u.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:u.jsx(lte,{className:"size-3.5"})}),t&&u.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?u.jsx(oh,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):u.jsx(Dv,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&u.jsx(eAe,{filter:e})]}),u.jsx("div",{className:"flex items-center gap-2",children:t&&u.jsx(Xt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function Aq(){var g;const e=te(b=>b.isDashboardEditing),t=te(b=>b.selectedSheetId),n=te(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=Ae(b=>b.card),i=Ae(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:c}=Qt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=Gr();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const y=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],x=y==null?void 0:y.type;if(y)return{connectionId:y.connectionId,connectionType:y.connectionType,type:x,selectedEntities:[y]}}function m(b){const y=(b==null?void 0:b.sheetId)||t,x=r==null?void 0:r.find(k=>k.id===y);if(!x){console.warn("Cannot add frame: No sheet found");return}if(!(!x.frames||x.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:wr(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:wr(),cards:[S],activeCardId:S.id};return y&&(a(y,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),c(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function tAe({sheetId:e}){const{handleAddNewFrame:t}=Aq(),n=te(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return u.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:u.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[u.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:u.jsx(gr,{className:"h-6 w-6 text-primary"})}),u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Y0(e){const t=(e||"").toLowerCase(),n=Jl(t);return n==="string"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-blue-100 text-xs text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:u.jsx(B$,{className:"h-3 w-3"})}):n==="number"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-green-100 text-xs text-green-700 dark:bg-green-950 dark:text-green-300",children:u.jsx(_$,{className:"h-3 w-3"})}):n==="date"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-purple-100 text-xs text-purple-700 dark:bg-purple-950 dark:text-purple-300",children:u.jsx(to,{className:"h-3 w-3"})}):n==="boolean"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(L$,{className:"h-3 w-3"})}):n==="json"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(w$,{className:"h-3 w-3"})}):n==="geo"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(dte,{className:"h-3 w-3"})}):n==="calculated"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(l$,{className:"h-3 w-3"})}):null}function nAe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return u.jsx(si,{children:u.jsxs("div",{className:"space-y-4",children:[n.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),u.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),u.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&u.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function rAe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return u.jsx("div",{className:"space-y-2",children:u.jsxs(pt,{value:e,onValueChange:t,children:[u.jsx(dt,{className:"w-full",children:u.jsx(bt,{placeholder:"Choose action...",children:n&&u.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=q0(n.value);return u.jsx(r,{className:"h-4 w-4"})})(),u.jsx("span",{children:n.label})]})})}),u.jsx(ft,{children:NF.map(r=>{const s=q0(r.value);return u.jsx(be,{value:r.value,children:u.jsxs("div",{className:"flex items-start gap-2 py-1",children:[u.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:r.label}),u.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function sAe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=E3(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),c=o();return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Filter scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),u.jsxs(ni,{value:c,onValueChange:d=>i(d),className:"space-y-2",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),c==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to filter"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),c==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to exclude"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var gM="Collapsible",[oAe,Pq]=yr(gM),[iAe,bM]=oAe(gM),Oq=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,c]=Mr({prop:r,defaultProp:s,onChange:i});return u.jsx(iAe,{scope:n,disabled:o,contentId:Gn(),open:l,onOpenToggle:E.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Re.div,{"data-state":wM(l),"data-disabled":o?"":void 0,...a,ref:t})})});Oq.displayName=gM;var Fq="CollapsibleTrigger",yM=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=bM(Fq,n);return u.jsx(Re.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":wM(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:we(e.onClick,s.onOpenToggle)})});yM.displayName=Fq;var xM="CollapsibleContent",vM=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=bM(xM,e.__scopeCollapsible);return u.jsx(Zn,{present:n||s.open,children:({present:o})=>u.jsx(aAe,{...r,ref:t,present:o})})});vM.displayName=xM;var aAe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=bM(xM,n),[a,l]=E.useState(r),c=E.useRef(null),d=at(t,c),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),Dr(()=>{const x=c.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(Re.div,{"data-state":wM(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function wM(e){return e?"open":"closed"}var $q=Oq,lAe=yM,cAe=vM;const zu=$q,Bu=yM,Vu=vM;function uAe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const s1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rh(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function SM(e){return"nodeType"in e}function hs(e){var t,n;return e?Rh(e)?e:SM(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function CM(e){const{Document:t}=hs(e);return e instanceof t}function hb(e){return Rh(e)?!1:e instanceof hs(e).HTMLElement}function Lq(e){return e instanceof hs(e).SVGElement}function Ih(e){return e?Rh(e)?e.document:SM(e)?CM(e)?e:hb(e)||Lq(e)?e.ownerDocument:document:document:document}const ii=s1?C.useLayoutEffect:C.useEffect;function o1(e){const t=C.useRef(e);return ii(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function dAe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Jm(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return ii(()=>{n.current!==e&&(n.current=e)},t),n}function pb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function G0(e){const t=o1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Z0(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let VC={};function mb(e,t){return C.useMemo(()=>{if(t)return t;const n=VC[e]==null?0:VC[e]+1;return VC[e]=n,e+"-"+n},[e,t])}function zq(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,c]of a){const d=o[l];d!=null&&(o[l]=d+e*c)}return o},{...t})}}const uf=zq(1),eg=zq(-1);function fAe(e){return"clientX"in e&&"clientY"in e}function i1(e){if(!e)return!1;const{KeyboardEvent:t}=hs(e.target);return t&&e instanceof t}function hAe(e){if(!e)return!1;const{TouchEvent:t}=hs(e.target);return t&&e instanceof t}function K0(e){if(hAe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return fAe(e)?{x:e.clientX,y:e.clientY}:null}const Yi=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Yi.Translate.toString(e),Yi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),kF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pAe(e){return e.matches(kF)?e:e.querySelector(kF)}const mAe={display:"none"};function gAe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:mAe},n)}function bAe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function yAe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Bq=C.createContext(null);function xAe(e){const t=C.useContext(Bq);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function vAe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const wAe={draggable:`
910
+ `)),[]});var nRe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nRe||{});function rRe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function sRe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=tRe(e&&s?3:0),c=C.useRef(!1),d=C.useRef(!1),f=cb();return Bn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),oRe(t,{inFlight:c,prepare(){d.current?d.current=!1:d.current=c.current,c.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function oRe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=qi();return aRe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(iRe(e,r))})}),o.dispose}function iRe(e,t){var n,r;let s=qi();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function aRe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lRe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Bn(()=>{if(!t||!e)return;let i=lb(t);if(!i)return;let a=s.current,l=o.current,c=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,c,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function pF(e,t){let n=C.useRef([]),r=yt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function cRe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const bq={...E},uRe=bq.useInsertionEffect,dRe=uRe||(e=>e());function yq(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return dRe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Gk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let mF=!1,fRe=0;const gF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+fRe++;function hRe(){const[e,t]=E.useState(()=>mF?gF():void 0);return Gk(()=>{e==null&&t(gF())},[]),E.useEffect(()=>{mF=!0},[]),e}const pRe=bq.useId,mRe=pRe||hRe;let Km;process.env.NODE_ENV!=="production"&&(Km=new Set);function gRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.warn(s)}}function bRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.error(s)}}function yRe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const xRe=E.createContext(null),vRe=E.createContext(null),wRe=()=>{var e;return((e=E.useContext(xRe))==null?void 0:e.id)||null},SRe=()=>E.useContext(vRe),CRe="data-floating-ui-focusable";function NRe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=mRe(),o=E.useRef({}),[i]=E.useState(()=>yRe()),a=wRe()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Br(p)&&bRe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,c]=E.useState(r.reference),d=yq((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:c}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function kRe(e){e===void 0&&(e={});const{nodeId:t}=e,n=NRe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=SRe();Gk(()=>{d&&(f.current=d)},[d]);const p=Ez({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Br(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Br(v)||v===null)&&(f.current=v,i(v)),(Br(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Br(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),y=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),x=E.useMemo(()=>({...p,...r,refs:b,elements:y,nodeId:t}),[p,b,y,t,r]);return Gk(()=>{r.dataRef.current.floatingContext=x;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=x)}),E.useMemo(()=>({...p,context:x,refs:b,elements:y}),[p,b,y,x])}const bF="active",yF="selected";function LC(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[bF]:i,[yF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[CRe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[c,d]=l;if(!(s&&[bF,yF].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof d=="function"){var f;(f=r.get(c))==null||f.push(d),i[c]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(c))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[c]=d}),i),{})}}function ERe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>LC(a,e,"reference"),t),o=E.useCallback(a=>LC(a,e,"floating"),n),i=E.useCallback(a=>LC(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const jRe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:c,...d}=Vi(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(c==null?void 0:c.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,y=m.clientTop!==0,x=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||gRe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await l_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await MS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await MS(v,{...d,elementContext:"reference"}),N=zr(0,w.top),k=v.y+N,D=(m.scrollHeight>m.clientHeight?M=>M:Nm)(zr(0,m.scrollHeight+(b&&x||y?g*2:0)-N-zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const M=m.offsetHeight<p.offsetHeight*Va(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Fl.flushSync(()=>s(M))}return r&&(r.current=await MS(xF({...v,y:k},m.offsetHeight+g+h.clientTop),d)),{y:k}}});function _Re(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=yq(a),c=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,y=o.current.top>=-.5,x=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!y&&b>0||!x&&b<0?(g.preventDefault(),Fl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(cRe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){c.current=!0},onWheel(){c.current=!1},onPointerMove(){c.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!c.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Fl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let ub=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});ub.displayName="FloatingContext";let cM=C.createContext(null);cM.displayName="PlacementContext";function DRe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function MRe(){return C.useContext(ub).setReference}function TRe(){let{getFloatingProps:e,slot:t}=C.useContext(ub);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RRe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(cM),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Bn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(ub);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let vF=4;function IRe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);ARe(a);let c=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=PRe(n,a),[g,b="center"]=d.split(" ");Bn(()=>{c&&o(0)},[c]);let{refs:y,floatingStyles:x,context:v}=kRe({open:c,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[l_({mainAxis:g==="selection"?0:f,crossAxis:h}),jz({padding:p}),g!=="selection"&&_z({padding:p}),g==="selection"&&m?jRe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:vF,referenceOverflowThreshold:p,onFallbackChange(M){var T,O;if(!M)return;let A=v.elements.floating;if(!A)return;let P=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,F=Math.min(vF,A.childElementCount),V=0,U=0;for(let z of(O=(T=v.elements.floating)==null?void 0:T.childNodes)!=null?O:[])if(z instanceof HTMLElement){let I=z.offsetTop,B=I+z.clientHeight+P,L=A.scrollTop,R=L+A.clientHeight;if(I>=L&&B<=R)F--;else{U=Math.max(0,Math.min(B,R)-Math.max(I,L)),V=z.clientHeight;break}}F>=1&&o(z=>{let I=V*F-U+P;return z>=I?z:I})}}):null,Dz({padding:p,apply({availableWidth:M,availableHeight:T,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${M}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${T}px)`})}})].filter(Boolean),whileElementsMounted:Nz}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),k=_Re(v,{overflowRef:i,onChange:o}),{getReferenceProps:j,getFloatingProps:_}=ERe([k]),D=yt(M=>{l(M),y.setFloating(M)});return E.createElement(cM.Provider,{value:r},E.createElement(ub.Provider,{value:{setFloating:D,setReference:y.setReference,styles:x,getReferenceProps:j,getFloatingProps:_,slot:N}},e))}function ARe(e){Bn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function PRe(e,t){var n,r,s;let o=zC((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=zC((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=zC((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function zC(e,t,n=void 0){let r=cb(),s=yt((l,c)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!c)return[n,null];let d=wF(l,c);return[d,f=>{let h=xq(l);{let p=h.map(m=>window.getComputedStyle(c).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[y,x]of h.entries()){let v=window.getComputedStyle(c).getPropertyValue(x);if(p[y]!==v){p[y]=v,g=!0;break}}if(!g)return;let b=wF(l,c);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Bn(()=>{let[l,c]=s(e,t);if(a(l),!!c)return c(a)},[e,t]),i}function xq(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...xq(s)]:[r]}return[]}function wF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ORe({children:e,freeze:t}){let n=Zk(t,e);return C.createElement(C.Fragment,null,n)}function Zk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let uM=C.createContext(null);uM.displayName="OpenClosedContext";var Xm=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xm||{});function FRe(){return C.useContext(uM)}function $Re({value:e,children:t}){return C.createElement(uM.Provider,{value:e},t)}function LRe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Fc=[];LRe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Fc[0]===t.target)return;let n=t.target;n=n.closest(Yk),Fc.unshift(n??t.target),Fc=Fc.filter(r=>r!=null&&r.isConnected),Fc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function zRe(e){throw new Error("Unexpected object: "+e)}var ir=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ir||{});function SF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:zRe(e)}}var dM=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(dM||{});function BRe(e){let t=yt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,eq(()=>{n.current&&t()})}),[t])}function VRe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function HRe(){let e=VRe(),[t,n]=E.useState(xu.isHandoffComplete);return t&&xu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>xu.handoff(),[]),e?!1:t}let URe=C.createContext(!1);function WRe(){return C.useContext(URe)}function qRe(e){let t=WRe(),n=C.useContext(wq),r=r1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(xu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let vq=C.Fragment,YRe=hi(function(e,t){let n=e,r=C.useRef(null),s=Qa(lTe(f=>{r.current=f}),t),o=r1(r),i=qRe(r),[a]=C.useState(()=>{var f;return xu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(XRe),c=HRe();Bn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Bn(()=>{if(a&&l)return l.register(a)},[l,a]),BRe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=fi();return c?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:vq,name:"Portal"}),a):null});function GRe(e,t){let n=Qa(t),{enabled:r=!0,...s}=e,o=fi();return r?C.createElement(YRe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:vq,name:"Portal"})}let ZRe=C.Fragment,wq=C.createContext(null);function KRe(e,t){let{target:n,...r}=e,s={ref:Qa(t)},o=fi();return C.createElement(wq.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:ZRe,name:"Popover.Group"}))}let XRe=C.createContext(null),QRe=hi(GRe),JRe=hi(KRe),eIe=Object.assign(QRe,{Group:JRe});var tIe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(tIe||{}),nIe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(nIe||{}),rIe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rIe||{}),sIe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(sIe||{});function BC(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):VTe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let oIe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:c,disabled:d}=e.virtual,f=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>c,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:c.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=BC(e);if(i.activeOptionIndex===null){let c=i.options.findIndex(d=>!d.dataRef.current.disabled);c!==-1&&(i.activeOptionIndex=c)}let a=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=BC(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=BC(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},fM=C.createContext(null);fM.displayName="ComboboxActionsContext";function db(e){let t=C.useContext(fM);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,db),n}return t}let Sq=C.createContext(null);function iIe(e){let t=Th("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let c=t.optionsElement;if(!c)return[0,0];let d=window.getComputedStyle(c);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=DTe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Bn(()=>{a(c=>c+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(Sq.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:c=>{c&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(c=>{var d;return C.createElement(C.Fragment,{key:c.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[c.index]}),{key:`${i}-${c.key}`,"data-index":c.index,"aria-setsize":n.length,"aria-posinset":c.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${c.start}px)`,overflowAnchor:"none"}}))})))}let Qm=C.createContext(null);Qm.displayName="ComboboxDataContext";function Th(e){let t=C.useContext(Qm);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Th),n}return t}function aIe(e,t){return Oa(t.type,oIe,e,t)}let lIe=C.Fragment;function cIe(e,t){var n,r;let s=sM(),{value:o,defaultValue:i,onChange:a,form:l,name:c,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:y,...x}=e,v=QMe(i),[w=m?[]:void 0,S]=XMe(o,a,v),[N,k]=C.useReducer(aIe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),j=C.useRef(!1),_=C.useRef({static:!1,hold:!1}),D=TTe(d),M=yt(oe=>b?d===null?b.options.indexOf(oe):b.options.findIndex(de=>D(de,oe)):N.options.findIndex(de=>D(de.dataRef.current.value,oe))),T=C.useCallback(oe=>Oa(A.mode,{1:()=>w.some(de=>D(de,oe)),0:()=>D(w,oe)}),[w]),O=yt(oe=>N.activeOptionIndex===M(oe)),A=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:_,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(j.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let de=b.options.findIndex(le=>{var ke,ye;return!((ye=(ke=b.disabled)==null?void 0:ke.call(b,le))!=null&&ye)});if(de!==-1)return de}let oe=N.options.findIndex(de=>!de.dataRef.current.disabled);if(oe!==-1)return oe}return N.activeOptionIndex},calculateIndex:M,compare:D,isSelected:T,isActive:O}),[w,v,f,m,p,N,b]);Bn(()=>{var oe;b&&k({type:7,options:b.options,disabled:(oe=b.disabled)!=null?oe:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Bn(()=>{N.dataRef.current=A},[A]);let P=A.comboboxState===0;WTe(P,[A.buttonElement,A.inputElement,A.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var oe,de,le;return{open:A.comboboxState===0,disabled:f,activeIndex:A.activeOptionIndex,activeOption:A.activeOptionIndex===null?null:A.virtual?A.virtual.options[(oe=A.activeOptionIndex)!=null?oe:0]:(le=(de=A.options[A.activeOptionIndex])==null?void 0:de.dataRef.current.value)!=null?le:null,value:w}},[A,f,w]),V=yt(()=>{if(A.activeOptionIndex!==null){if($.setIsTyping(!1),A.virtual)R(A.virtual.options[A.activeOptionIndex]);else{let{dataRef:oe}=A.options[A.activeOptionIndex];R(oe.current.value)}$.goToOption(ir.Specific,A.activeOptionIndex)}}),U=yt(()=>{k({type:0}),j.current=!0}),z=yt(()=>{k({type:1}),j.current=!1,h==null||h()}),I=yt(oe=>{k({type:3,isTyping:oe})}),B=yt((oe,de,le)=>(j.current=!1,oe===ir.Specific?k({type:2,focus:ir.Specific,idx:de,trigger:le}):k({type:2,focus:oe,trigger:le}))),L=yt((oe,de)=>(k({type:4,payload:{id:oe,dataRef:de}}),()=>{A.isActive(de.current.value)&&(j.current=!0),k({type:5,id:oe})})),R=yt(oe=>Oa(A.mode,{0(){return S==null?void 0:S(oe)},1(){let de=A.value.slice(),le=de.findIndex(ke=>D(ke,oe));return le===-1?de.push(oe):de.splice(le,1),S==null?void 0:S(de)}})),W=yt(oe=>{k({type:6,trigger:oe})}),Y=yt(oe=>{k({type:8,element:oe})}),Z=yt(oe=>{k({type:9,element:oe})}),H=yt(oe=>{k({type:10,element:oe})}),$=C.useMemo(()=>({onChange:R,registerOption:L,goToOption:B,setIsTyping:I,closeCombobox:z,openCombobox:U,setActivationTrigger:W,selectActiveOption:V,setInputElement:Y,setButtonElement:Z,setOptionsElement:H}),[]),[q,G]=hTe(),ee=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=fi();return C.createElement(G,{value:q,props:{htmlFor:(r=A.inputElement)==null?void 0:r.id},slot:{open:A.comboboxState===0,disabled:f}},C.createElement(IRe,null,C.createElement(fM.Provider,{value:$},C.createElement(Qm.Provider,{value:A},C.createElement($Re,{value:Oa(A.comboboxState,{0:Xm.Open,1:Xm.Closed})},c!=null&&C.createElement(rTe,{disabled:f,data:w!=null?{[c]:w}:{},form:l,onReset:Q}),ne({ourProps:ee,theirProps:x,slot:F,defaultTag:lIe,name:"Combobox"}))))))}let uIe="input";function dIe(e,t){var n,r,s,o,i;let a=Th("Combobox.Input"),l=db("Combobox.Input"),c=C.useId(),d=iq(),{id:f=d||`headlessui-combobox-input-${c}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...y}=e,x=C.useRef(null),v=Qa(x,t,MRe(),l.setInputElement),w=r1(a.inputElement),S=cb(),N=yt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ir.Nothing)}),k=C.useMemo(()=>{var R;return typeof p=="function"&&a.value!==void 0?(R=p(a.value))!=null?R:"":typeof a.value=="string"?a.value:""},[a.value,p]);pF(([R,W],[Y,Z])=>{if(a.isTyping)return;let H=x.current;H&&((Z===0&&W===1||R!==Y)&&(H.value=R),requestAnimationFrame(()=>{if(a.isTyping||!H||(w==null?void 0:w.activeElement)!==H)return;let{selectionStart:$,selectionEnd:q}=H;Math.abs((q??0)-($??0))===0&&$===0&&H.setSelectionRange(H.value.length,H.value.length)}))},[k,a.comboboxState,w,a.isTyping]),pF(([R],[W])=>{if(R===0&&W===1){if(a.isTyping)return;let Y=x.current;if(!Y)return;let Z=Y.value,{selectionStart:H,selectionEnd:$,selectionDirection:q}=Y;Y.value="",Y.value=Z,q!==null?Y.setSelectionRange(H,$,q):Y.setSelectionRange(H,$)}},[a.comboboxState]);let j=C.useRef(!1),_=yt(()=>{j.current=!0}),D=yt(()=>{S.nextFrame(()=>{j.current=!1})}),M=yt(R=>{switch(l.setIsTyping(!0),R.key){case os.Enter:if(a.comboboxState!==0||j.current)return;if(R.preventDefault(),R.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case os.ArrowDown:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Next),1:()=>l.openCombobox()});case os.ArrowUp:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ir.Last)}});case os.Home:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.PageUp:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.End:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.PageDown:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.Escape:return a.comboboxState!==0?void 0:(R.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&R.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case os.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),T=yt(R=>{h==null||h(R),a.mode===0&&R.target.value===""&&N(),l.openCombobox()}),O=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);if(!((Y=a.optionsElement)!=null&&Y.contains(H))&&!((Z=a.buttonElement)!=null&&Z.contains(H))&&a.comboboxState===0)return R.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),A=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);(Y=a.buttonElement)!=null&&Y.contains(H)||(Z=a.optionsElement)!=null&&Z.contains(H)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=n1(),F=cTe(),{isFocused:V,focusProps:U}=JW({autoFocus:g}),{isHovered:z,hoverProps:I}=QW({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:z,focus:V,autofocus:g}),[a,z,V,g,m]),L=oM({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(R=>!R.dataRef.current.disabled&&a.compare(R.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:_,onCompositionEnd:D,onKeyDown:M,onChange:T,onFocus:A,onBlur:O},U,I);return fi()({ourProps:L,theirProps:y,slot:B,defaultTag:uIe,name:"Combobox.Input"})}let fIe="button";function hIe(e,t){var n;let r=Th("Combobox.Button"),s=db("Combobox.Button"),o=Qa(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:c=!1,...d}=e,f=gq(r.inputElement),h=yt(k=>{switch(k.key){case os.Space:case os.Enter:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case os.ArrowDown:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.First)),f();return;case os.ArrowUp:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.Last)),f();return;case os.Escape:if(r.comboboxState!==0)return;k.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&k.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=yt(k=>{k.preventDefault(),!iTe(k.currentTarget)&&(k.button===dM.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=n1([a]),{isFocusVisible:g,focusProps:b}=JW({autoFocus:c}),{isHovered:y,hoverProps:x}=QW({isDisabled:l}),{pressed:v,pressProps:w}=UMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:y,focus:g}),[r,y,g,v,l]),N=oM({ref:o,id:a,type:YTe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:c,onMouseDown:p,onKeyDown:h},b,x,w);return fi()({ourProps:N,theirProps:d,slot:S,defaultTag:fIe,name:"Combobox.Button"})}let pIe="div",mIe=Wk.RenderStrategy|Wk.Static;function gIe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:c=!1,modal:d=!0,transition:f=!1,...h}=e,p=Th("Combobox.Options"),m=db("Combobox.Options"),g=DRe(l);g&&(c=!0);let[b,y]=RRe(g),[x,v]=C.useState(null),w=TRe(),S=Qa(t,g?b:null,m.setOptionsElement,v),N=r1(p.optionsElement),k=FRe(),[j,_]=sRe(f,x,k!==null?(k&Xm.Open)===Xm.Open:p.comboboxState===0);OTe(j,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;JTe(D,N);let M=p.__demoMode?!1:d&&p.comboboxState===0;PTe(M,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Bn(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),Bn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),lRe(p.comboboxState===0,{container:p.optionsElement,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let T=n1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),A=yt(()=>{m.setActivationTrigger(0)}),P=yt(L=>{L.preventDefault(),m.setActivationTrigger(0)}),F=oM(g?w():{},{"aria-labelledby":T,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":aF(p.inputElement,!0).width,"--button-width":aF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:A,onMouseDown:P,...rRe(_)}),V=j&&p.comboboxState===1,U=Zk(V,(r=p.virtual)==null?void 0:r.options),z=Zk(V,p.value),I=yt(L=>p.compare(z,L));if(p.virtual){if(U===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(Qm.Provider,{value:U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},C.createElement(iIe,{slot:O},h.children))})}let B=fi();return C.createElement(eIe,{enabled:c?e.static||j:!1},C.createElement(Qm.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(ORe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:pIe,features:mIe,visible:j,name:"Combobox.Options"})))}let bIe="div";function yIe(e,t){var n,r,s,o;let i=Th("Combobox.Option"),a=db("Combobox.Option"),l=C.useId(),{id:c=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=gq(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===c,b=i.isSelected(d),y=C.useRef(null),x=id({disabled:f,value:d,domRef:y,order:h}),v=C.useContext(Sq),w=Qa(t,y,v?v.measureElement:null),S=yt(()=>{a.setIsTyping(!1),a.onChange(d)});Bn(()=>a.registerOption(c,x),[x,c]);let N=C.useRef(!(i.virtual||i.__demoMode));Bn(()=>{if(!i.virtual&&!i.__demoMode)return qi().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Bn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return qi().requestAnimationFrame(()=>{var P,F;(F=(P=y.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[y,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let k=yt(P=>{P.preventDefault(),P.button===dM.Left&&(f||(S(),mq()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),j=yt(()=>{if(f)return a.goToOption(ir.Nothing);let P=i.calculateIndex(d);a.goToOption(ir.Specific,P)}),_=eRe(),D=yt(P=>_.update(P)),M=yt(P=>{if(!_.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ir.Specific,F,0)}),T=yt(P=>{_.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ir.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),A={id:c,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:k,onFocus:j,onPointerEnter:D,onMouseEnter:D,onPointerMove:M,onMouseMove:M,onPointerLeave:T,onMouseLeave:T};return fi()({ourProps:A,theirProps:p,slot:O,defaultTag:bIe,name:"Combobox.Option"})}let xIe=hi(cIe),Cq=hi(hIe),Nq=hi(dIe),vIe=bTe,kq=hi(gIe),Eq=hi(yIe),wIe=Object.assign(xIe,{Input:Nq,Button:Cq,Label:vIe,Options:kq,Option:Eq});function SIe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const CIe=C.memo(({option:e,currentStyle:t})=>u.jsxs(Eq,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[u.jsx(_r,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function NIe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:c}){const[d,f]=C.useState(""),h=te(x=>x.themeStyle),p=C.useMemo(()=>{const x=s||e;return d===""?x:x==null?void 0:x.filter(v=>v!=null&&v.value?String(v.value).toLowerCase().includes(d==null?void 0:d.toLowerCase()):!1)},[e,s,d]);function m(x){return x!=null&&x.length?x==null?void 0:x.map(v=>v.value).join(", "):""}function g(x){Array.isArray(x)||(x=[x]),t(x)}function b(){return p&&p.length>0?null:u.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function y(){return!r||!(p!=null&&p.length)?null:u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{children:"All"}),u.jsx(gn,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return u.jsx(wIe,{multiple:r,value:n,onChange:g,onClose:()=>f(""),children:({open:x})=>u.jsxs("div",{children:[u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[c&&u.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),u.jsx(Nq,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:h==null?void 0:h.controlInputRadius},displayValue:m,onChange:v=>f(v.target.value)}),u.jsx(Cq,{className:"group absolute inset-y-0 right-0 px-2.5",children:u.jsx(js,{className:"size-4 text-muted-foreground hover:text-foreground"})})]}),u.jsxs(kq,{anchor:"bottom",transition:!0,style:{borderRadius:h==null?void 0:h.controlInputRadius},className:Su("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[x&&u.jsx(SIe,{elementId:"headlessui-portal-root"}),b(),y(),p==null?void 0:p.map(v=>u.jsx(CIe,{option:v,currentStyle:h},v.id))]})]})})}function kIe({filter:e}){const t=te(f=>f.themeStyle),{filteredRecords:n,isSingleSelect:r,allSelected:s,handleChange:o,handleSelectAll:i,isLoading:a,isFetching:l,isError:c,selectedRecords:d}=nM(e);return a||l?u.jsx(Ia,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):c?u.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):u.jsx(NIe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>u.jsx(EIe,{filter:e}),inputClassName:"h-8",options:n,selectedOptions:d,onChange:o,multiple:!r,selectAllChecked:s,onSelectAllCheckedChange:i})}function EIe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n}=Qt();function r(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}return u.jsx(ie,{onClick:r,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:kv(t)})}function jIe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=nM(e);function s(i){n([{value:i,id:i}])}return u.jsx(ni,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Wn,{value:i.value,id:"r1"}),u.jsx(ae,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function hM({filter:e}){return Yu(e.dataType)?u.jsx(xMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?u.jsx(jIe,{filter:e}):u.jsx(kIe,{filter:e})}function _Ie({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Ba(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:c,isFetching:d}=Ba(a);return(a==null?void 0:a.type)!=="text"?u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):u.jsxs(Rs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?u.jsx("div",{className:"overflow-y-auto break-words p-1",children:u.jsx(Zf,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),u.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:u.jsx(ob,{disabled:c||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?u.jsx(cte,{className:"size-4 text-muted-foreground/70"}):u.jsx(ute,{className:"size-4 text-muted-foreground/70"})})})]})}function q0(e){return{clickFilter:Ca,drillToDetail:Dg,drillThrough:ej,drillToURL:_g,drillDown:hte,drillUp:pte,dynamicDrill:ec,inlineDrill:Mv}[e]||Ca}function ad(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function DIe(e,t,n,r,s){const o=q0(e.mode),i=e.label||ad(e.mode),a=MIe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function MIe(e,t,n=0,r,s){var o,i,a,l,c,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=OE(f,r,s),m=PE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(c=f.steps[n-2])==null?void 0:c.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function TIe(e,t,n,r,s){return e.map(o=>DIe(o,t,n,r,s))}function RIe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:c,breadcrumbs:d}=Kt(w=>{var S,N,k;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((k=w.interactionStates[a])==null?void 0:k.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>TIe(r,i,c,l,d),[r,i,c,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let y=n.x,x=n.y+8;y+p>g&&(y=Math.max(8,g-p-8)),x+m>b&&(x=Math.max(8,n.y-m-8));const v=u.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[u.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),u.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${y}px`,top:`${x}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&u.jsxs("div",{className:"border-b px-4 py-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),u.jsx("p",{className:"text-sm font-medium",children:h})]}),u.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var j;const N=w.icon,k=w.interaction.mode==="dynamicDrill"&&(S===0||((j=f[S-1])==null?void 0:j.interaction.mode)!=="dynamicDrill");return u.jsxs(E.Fragment,{children:[k&&u.jsx("div",{className:"border-t px-4 py-2",children:u.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),u.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[u.jsx("div",{className:"mt-0.5 flex-shrink-0",children:u.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&u.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function IIe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=_i(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=Rp(h=>h.registerClearBlurCallback),a=Rp(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((y,x)=>h.getDatasetMeta(x).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((y,x)=>{const v=b[x];if(p.length===0){y.backgroundColor=[...v];return}y.backgroundColor=v.map((w,S)=>p.some(k=>k.datasetIndex===x&&k.dataIndex===S)?w:c(w,.2))});try{h.update()}catch(y){console.warn("Failed to update chart during blur toggle:",y)}}function c(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],y={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(y)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[y]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function AIe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var c,d,f,h,p,m,g,b,y,x;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(c=o[0].element)==null?void 0:c.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=Qn(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,k=j=>w.find(_=>_.label===j)||S.find(_=>_.label===j)||N.find(_=>_.label===j);if(t.type==="map"){const j=v[0],_=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=k(j);return!D||_==null?void 0:{conditions:[{field:D,operator:"=",value:_}]}}if(["pie","funnel","doughnut"].includes(t.type)){const j=v[0],_=v==null?void 0:v[1+i],D=k(j),M=k(_),T=(g=n==null?void 0:n[a])==null?void 0:g[j];if(!D||T==null){console.log("no dim field or value",j,T);return}return{conditions:[{field:D,operator:"=",value:T}],metrics:M?[{field:M,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const j=v[0],_=k(j),D=(b=n==null?void 0:n[a])==null?void 0:b[j];if(!_||D==null){console.log("no dim field or value for stacked bar",j,D);return}const M=N[i]||N[0];if(!M){console.log("no metric field found");return}const T=S[0],A=Object.keys(n[0]).filter(U=>U!==j)[i],F=(A?(y=n==null?void 0:n[a])==null?void 0:y[A]:(x=n==null?void 0:n[a])==null?void 0:x[M.label])??l,V=[{field:_,operator:"=",value:D}];return T&&A&&V.push({field:T,operator:"=",value:A}),{conditions:V,metrics:[{field:M,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function PIe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function OIe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function jq({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?u.jsx("div",{className:"px-6 pb-4",children:u.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(c=>{var d,f;if(PIe(c))return{fieldName:((d=c.field)==null?void 0:d.label)||((f=c.field)==null?void 0:f.name)||"Unknown",operator:c.operator,value:$Ie(c)};if(OIe(c)){const h=t==null?void 0:t.find(p=>p.id===c.filterId);return{fieldName:(h==null?void 0:h.title)||c.name,operator:c.operation,value:FIe(c)}}else return{fieldName:"Unknown",operator:"=",value:String(c)}}).reduce((c,d)=>(c[d.fieldName]||(c[d.fieldName]=[]),c[d.fieldName].push(d),c),{});return u.jsxs("div",{className:r||"px-6 pb-4 border-b",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&i&&u.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,u.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:o})]}),s&&!i&&u.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:o}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([c,d])=>u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("span",{className:"text-sm font-medium",children:[c,":"]}),d.map((f,h)=>u.jsx(jt,{variant:"secondary",className:"border border-primary/20 bg-primary/10 text-primary",children:f.value},`${c}-${h}`))]},c))})]}),n&&u.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&u.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&u.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&u.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function FIe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function $Ie(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function LIe({cardId:e,className:t}){const n=Kt(d=>d.interactionStates[e]),r=Kt(d=>d.popInteractionStep),s=Kt(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),c=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return u.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&u.jsx(jq,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:u.jsx(gte,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(to,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(nte,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return u.jsx(si,{children:u.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[u.jsx(qr,{children:u.jsx(Yr,{asChild:!0,children:u.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:u.jsx(D$,{className:"h-3.5 w-3.5"})})})}),u.jsx(La,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),u.jsx("div",{className:"flex items-center",children:o.map((d,f)=>u.jsxs("div",{className:"flex items-center",children:[f>0&&u.jsx(La,{className:"mx-1 h-3 w-3 text-muted-foreground"}),u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(ie,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),u.jsx(KD,{className:"ml-4",side:"bottom",children:c(d)})]})]},f))})]})})}function zIe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function pM({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=zIe(s),i=ez(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:c=>{var d;return((d=a.overrides)==null?void 0:d[c])??!0}}},[t,n]);return u.jsx(Z6.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ne,oe,de,le,ke,ye,Pe,Ve,lt;const{customCards:n,placeholders:r,tokenProps:s}=Ye(),{shouldShowElement:o}=nc(),i=Kt(ue=>ue.interactionStates[e.id]),a=((ne=i==null?void 0:i.breadcrumbs)==null?void 0:ne.length)>0,l=te(ue=>ue.themeStyle),c=te(ue=>ue.selectedSheetId),d=te(ue=>ue.isDashboardEditing);te(ue=>ue.selectedLensId);const f=te(ue=>ue.dashboard.filters),h=f==null?void 0:f.find(ue=>ue.id===t.filterId&&!ue.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Qt(),{updateFrame:y}=Qt(),{handleChartClick:x}=IIe(e),v=o("showHeader")&&(((oe=e.customCardPreferences)==null?void 0:oe.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:k,isPending:j,data:_,handleDatapointClick:D,pagination:M}=Wg(e),[T,O]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:A,hierarchyId:P}=Kt(ue=>{var Ne,Je;return{breadcrumbs:((Ne=ue.interactionStates[e.id])==null?void 0:Ne.breadcrumbs)??[],hierarchyId:(Je=ue.interactionStates[e.id])==null?void 0:Je.hierarchyId}}),F=(ue,Ne,Je)=>{var Oe;const We=A.length>0?[{mode:"drillUp",trigger:(Oe=ue[0])==null?void 0:Oe.trigger,label:"Drill Up",hierarchyId:P}]:[],re=[];for(const Me of ue)if(Me.mode==="dynamicDrill"&&Me.availableFields){const nt=Me.availableFields.filter(Dt=>!A.some(ct=>{var Ot;return((Ot=ct.toField)==null?void 0:Ot.id)===Dt.id}));for(const Dt of nt)re.push({mode:"dynamicDrill",trigger:Me.trigger,drillField:Dt,label:Dt.label,availableFields:Me.availableFields})}const fe=ue.filter(Me=>Me.mode!=="dynamicDrill"),De=[...We,...fe,...re];O({open:!0,position:Je||{x:0,y:0},interactions:De,context:Ne})},{handlePointerInteraction:V,applySelectedInteraction:U}=UJ(e,F),z=b3(e),I=C.useMemo(()=>{var ue;return e.type!=="pivotTable"||!((ue=_==null?void 0:_.records)!=null&&ue.length)?null:{records:_.records,columnSubtotalMeta:_.columnSubtotalMeta,subtotalColumns:_.subtotalColumns||[],pivotSchema:_.pivotSchema||[],groupByColumns:_.groupByColumns}},[e.type,_==null?void 0:_.records,_==null?void 0:_.columnSubtotalMeta,_==null?void 0:_.subtotalColumns,_==null?void 0:_.pivotSchema,_==null?void 0:_.groupByColumns]),B=Ch(e,I),L=(ue,Ne)=>{const Je={...e,paginationConfig:{page:ue+1,pageSize:Ne}},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)};function R(ue,Ne){ue.stopPropagation();const Je=AIe({resolvedCardConfig:z,card:e,records:(_==null?void 0:_.records)||[],chart:Ne,clickEvent:ue.nativeEvent});if(!Je)return;const We=_i(e.interactionConfig),re=FE(We,Je),fe=re.length===1&&re[0].mode==="clickFilter",De=re.some(nt=>nt.mode==="dynamicDrill"),Oe=re.length>1||De;ue.button===0&&fe&&!Oe&&x(ue.nativeEvent,Ne);const Me={shift:ue.shiftKey,ctrl:ue.ctrlKey,meta:ue.metaKey};ue.button===0?V({context:Je,gesture:"leftClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}}):ue.button===2&&V({context:Je,gesture:"rightClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}})}function W(){var ue,Ne,Je;if(n&&n.length>0){const We=n.find(re=>re.cardId===e.id);if(We&&We.replaceDefault){const re=We.content;if(re)return u.jsx(re,{card:e})}}if(e.type==="kpi"){if(((ue=t==null?void 0:t.cards)==null?void 0:ue.length)===1)return u.jsx(Zm,{card:e,data:w?[]:(_==null?void 0:_.records)||[],isPending:j,isError:w});if(((Ne=t==null?void 0:t.cards)==null?void 0:Ne.length)>1)return u.jsx(_Ie,{frame:t})}return e.type==="text"&&((Je=t==null?void 0:t.cards)==null?void 0:Je.length)===1?u.jsx(Rs,{className:"my-4 overflow-y-auto break-words px-4",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})}):ee}function Y(){if(w)return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(Rv,{className:"size-8 text-destructive"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return u.jsx("div",{className:"flex h-full w-full items-center justify-center",children:u.jsx(Ou,{size:"md",color:"muted","aria-label":"Loading data"})});if(_!=null&&_.records&&(_==null?void 0:_.records.length)===0)return r!=null&&r.NoRecords?u.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(aj,{className:"size-8 text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(_==null?void 0:_.records)||[],paginationMetadata:M,onPaginationChange:L,isLoading:S||N})});if(e.type==="pivotTable"&&B)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:B.data,options:B.options,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},onAggregationLabelChange:ue=>{const Ne=zW(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)}})});if(e.type==="aggregateTable")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(_==null?void 0:_.records)||[],groupByColumns:_==null?void 0:_.groupByColumns,pivotSchema:_==null?void 0:_.pivotSchema,paginationMetadata:M,onPaginationChange:L,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},isLoading:S||N})});if(e.type==="text")return u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})});if(e.type==="custom")return u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})});if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.content){const Ne=ue.content;return u.jsx(Ne,{card:e})}}if(k)return u.jsx(Jg,{cfg:k,onChartClick:R,onDatapointClick:D})}function Z(){if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.footer){const Ne=ue.footer;if(Ne)return u.jsx(Ne,{card:e})}}return null}function H(){var Je;const ue=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}),Ne=l==null?void 0:l.controlInputRadius;return u.jsx(lo,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:We=>{const re={...t,activeCardId:We};y(c,re)},children:u.jsx(Os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(Je=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}))==null?void 0:Je.map((We,re)=>u.jsx(mn,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":re!==ue.length-1}),style:{borderTopLeftRadius:re===0?Ne:0,borderTopRightRadius:re===ue.length-1?Ne:0,borderBottomLeftRadius:re===0?Ne:0,borderBottomRightRadius:re===ue.length-1?Ne:0},value:We.id,children:We.tabTitle||We.title},We.id))})})}function $(){var Ne,Je,We,re;let ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle===`${e.tabTitle}__Header`);return ue||(ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle==="All__Header")),ue?u.jsx("div",{className:"flex items-end gap-2",children:u.jsx(fMe,{renderFilterInfo:()=>{var fe,De,Oe,Me;return o("showFilterInfo")&&((De=(fe=e.preferences)==null?void 0:fe.displayOptions)==null?void 0:De.showFilterInfo)!==!1?u.jsx(Lk,{cardId:e.id,cardFilters:(Oe=e.config)==null?void 0:Oe.filters,cardFilterCount:H0(((Me=e.config)==null?void 0:Me.filters)||null)}):null},card:ue})}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&u.jsx(zi,{className:K("text-base",{}),children:u.jsx(Do,{value:e.title,onSave:fe=>p(c,e.id,fe),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&u.jsx(LW,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&u.jsxs(qr,{children:[u.jsx(Yr,{className:"pr-1",children:u.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),u.jsx(fs,{side:"right",align:"center",children:u.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((Je=(Ne=e.preferences)==null?void 0:Ne.displayOptions)==null?void 0:Je.showFilterInfo)!==!1&&u.jsx(Lk,{cardId:e.id,cardFilters:(We=e.config)==null?void 0:We.filters,cardFilterCount:H0(((re=e.config)==null?void 0:re.filters)||null)})]}),u.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&u.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:u.jsx(Do,{value:(e==null?void 0:e.description)||"",onSave:fe=>m(c,e.id,fe),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&u.jsx(LIe,{cardId:e.id})]})]})}if(!e.id)return null;const q=((le=(de=e.preferences)==null?void 0:de.displayOptions)==null?void 0:le.showChrome)??!0,G=((ye=(ke=e.preferences)==null?void 0:ke.displayOptions)==null?void 0:ye.allowScroll)??!0,ee=q?u.jsxs(u.Fragment,{children:[v?u.jsx(Li,{children:u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:$()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx("div",{children:h&&o("showFilters")&&u.jsxs("div",{style:{borderRadius:(Ve=(Pe=l==null?void 0:l.chart)==null?void 0:Pe.options)==null?void 0:Ve.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!Yu(h.dataType)&&u.jsx(ae,{className:"my-1 shrink-0 px-3",children:u.jsx(Do,{value:h.title||h.column,onSave:ue=>b({...h,title:ue}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),u.jsx(hM,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&H()]})]})}):u.jsx("div",{className:"h-8"}),u.jsx($a,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:Y()}),o("showFooter")&&u.jsx(r$,{children:Z()})]}):Y(),Q=()=>q&&G?"flex h-full flex-col":q&&!G?"flex h-full flex-col overflow-hidden":!q&&!G?"h-full":"h-full overflow-auto";return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:K(Q(),{"animate-pulse":S||N}),children:W()}),T.context&&u.jsx(RIe,{open:T.open,onOpenChange:ue=>{O(Ne=>({...Ne,open:ue}))},position:T.position,interactions:T.interactions,selectedConditions:T.context.conditions,drillHierarchies:(lt=e.interactionConfig)==null?void 0:lt.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ue=>{T.context&&U(ue,T.context),O({open:!1,position:null,interactions:[],context:null})}})]})}function _q({card:e,frame:t}){return e.displayPreferences?u.jsx(pM,{displayPreferences:e.displayPreferences,children:u.jsx(CF,{card:e,frame:t})}):u.jsx(CF,{card:e,frame:t})}function BIe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Wg(e),c=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Ch(e,c);if(s||o)return u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return u.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?u.jsx(Zm,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})}):i?u.jsx(Jg,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return u.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&u.jsxs("div",{className:"border-b px-4 py-2",children:[u.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&u.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),u.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function Dq({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=dj(e,{enabled:!!e}),a=Kt(f=>f.setInteractionState),l=Kt(f=>f.resetInteractionState),c=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=c==null?void 0:c.cards)!=null&&f.length?c.activeCardId&&c.cards.find(h=>h.id===c.activeCardId)||c.cards[0]:null},[c]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...Wo(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...Wo(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!c||!d?u.jsx("div",{className:"flex items-center justify-center p-12",children:u.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):u.jsx("div",{className:"h-full w-full",children:u.jsx(BIe,{card:d,frame:c,showTitle:!1})})}function VIe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?u.jsxs(jt,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[u.jsx(Ca,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return u.jsx(si,{children:u.jsxs(qr,{delayDuration:200,children:[u.jsx(Yr,{asChild:!0,children:u.jsxs(jt,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[u.jsx(Ca,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),u.jsx(fs,{side:"bottom",align:"start",className:"max-w-md",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),u.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>u.jsxs("div",{className:"text-xs",children:[u.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>u.jsxs("span",{children:[HIe(i),a<o.length-1?", ":""]},a))]},s))}),t&&u.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:UIe(t)})]})})]})})}function HIe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function UIe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function Mq(e,t={}){const{enabled:n=!0}=t,{data:r}=dj(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,c;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((c=i==null?void 0:i.cards)!=null&&c.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function WIe({cardId:e,children:t}){const n=Kt(o=>o.replacedCards[e]),r=Kt(o=>o.restoreCard),s=Mq((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?u.jsxs("div",{className:"flex h-full w-full flex-col",children:[u.jsxs("div",{className:"border-b bg-muted/30",children:[u.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-muted-foreground",children:"-"}),u.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),u.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[u.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[u.jsx(o$,{className:"h-4 w-4"}),"Back"]}),u.jsx(VIe,{filters:n.filters,contextMode:n.contextMode})]})]}),u.jsx("div",{className:"min-h-0 flex-1",children:u.jsx(Dq,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):u.jsx(u.Fragment,{children:t})}function qIe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=te(N=>N.themeStyle),l=te(N=>N.isVisualEditing),c=te(N=>N.selectedFrameId),d=te(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Qt(),{clearSelectedVisual:h}=Eg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:y}=Gr();C.useEffect(()=>{if(c===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[c,e.id,d,l,s]);const x=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),x&&y(x),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&m(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&g(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable)}return u.jsx(uc,{FallbackComponent:OD,children:u.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":x==null?void 0:x.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":c===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=x==null?void 0:x.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&u.jsx(vW,{frame:e,isHovered:o}),x&&u.jsx(WIe,{cardId:x.id,children:u.jsx(_q,{card:x,frame:e},x.id)})]})})}function YIe({label:e,onCheckedChange:t,checked:n}){return u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{onCheckedChange:t,id:"terms",checked:n}),u.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function mM(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var GIe=["color"],ZIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,GIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KIe=["color"],Tq=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,KIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),XIe=["color"],QIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,XIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function eh({text:e,className:t}){const[n,r]=C.useState(!1);return u.jsx(ie,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?u.jsx(Tq,{className:"size-3.5"}):u.jsx(JE,{className:"size-3.5"})})}function JIe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=te(y=>y.dashboard.sheets)||[],o=C.useMemo(()=>{const y=[];return s==null||s.forEach(x=>{var v;(v=x.frames)==null||v.forEach(w=>{var S;(S=w.cards)==null||S.forEach(N=>{y.push({...N,sheetId:x.id,sheetTitle:x.title||x.id})})})}),y},[s]),i=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",a=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",l=y=>{const x={};switch(y){case"all-sheets":x.applyToSheetIds=void 0,x.excludeSheetIds=void 0;break;case"specific-sheets":x.applyToSheetIds=[],x.excludeSheetIds=void 0;break;case"all-except-specific":x.applyToSheetIds=void 0,x.excludeSheetIds=[];break}t(x)},c=y=>{const x={};switch(y){case"all-cards":x.applyToCardIds=void 0,x.excludeCardIds=void 0;break;case"specific-cards":x.applyToCardIds=[],x.excludeCardIds=void 0;break;case"all-except-specific":x.applyToCardIds=void 0,x.excludeCardIds=[];break}t(x)},d=(y,x)=>{if(x==="specific-sheets"){const v=e.applyToSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToSheetIds:w})}else if(x==="all-except-specific"){const v=e.excludeSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeSheetIds:w})}},f=(y,x)=>{if(x==="specific-cards"){const v=e.applyToCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToCardIds:w})}else if(x==="all-except-specific"){const v=e.excludeCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeCardIds:w})}},h=()=>{const y=i();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(x=>{var v;return!((v=e.excludeSheetIds)!=null&&v.includes(x.id))}).map(x=>x.id))||[]:(s==null?void 0:s.map(x=>x.id))||[]},p=C.useMemo(()=>{const y=h();return o.filter(x=>y.includes(x.sheetId))},[o,e.applyToSheetIds,e.excludeSheetIds]),m=C.useMemo(()=>{if(!n.trim())return p;const y=n.toLowerCase();return p.filter(x=>{var v;return(v=x==null?void 0:x.title)==null?void 0:v.toLowerCase().includes(y)})},[n,p]),g=i(),b=a();return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Sheet Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),u.jsxs(ni,{value:g,onValueChange:y=>l(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),g==="specific-sheets"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.applyToSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"specific-sheets")}),u.jsx(ae,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),g==="all-except-specific"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.excludeSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-exclude-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"all-except-specific")}),u.jsx(ae,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})})]})]}),u.jsxs("div",{className:"space-y-3 border-t pt-4",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Card Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),u.jsxs(ni,{value:b,onValueChange:y=>c(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",p.length," cards)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),b==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.applyToCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),b==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.excludeCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),u.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function eAe({filter:e}){const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[c,d]=C.useState(e.column),f=te(y=>y.selectedSheetId),{updateFilter:h}=Qt();function p(){const y=a.trim(),x=c.trim(),v={sql:t,...o},w=x||e.column;x&&x!==e.column&&(v.column=w),v.title=y||w;const S={...e,...v};h(S),i({}),s(!1)}C.useEffect(()=>{r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column))},[r,e.sql,e.title,e.column]);function m(y){const x={...e,type:y};h(x)}function g(y){const x={...e,uiType:y};h(x)}function b(y){if(!f)return;const x={...e,sheetId:y?f:void 0};h(x)}return u.jsxs(Ds,{open:r,onOpenChange:s,children:[u.jsx(Ms,{children:u.jsx(ou,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),u.jsx(Ts,{onMouseDown:y=>y.stopPropagation(),onDoubleClick:y=>y.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px] overflow-hidden",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),u.jsx(jt,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),u.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),u.jsxs(lo,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[u.jsxs(Os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[u.jsx(mn,{value:"scope",children:"Scope"}),u.jsx(mn,{value:"advanced",children:"Configuration"})]}),u.jsx(lr,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:u.jsx(JIe,{filter:{...e,...o},onUpdate:y=>{i(x=>({...x,...y}))}})}),u.jsxs(lr,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Custom Title (optional)"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),u.jsxs("div",{className:"space-y-1 border-t pt-2",children:[u.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),u.jsx(eh,{text:e.id})]})]})]})})]})})]}),u.jsx(pr,{value:a,onChange:y=>l(y.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Column Name"}),u.jsx(pr,{value:c,onChange:y=>d(y.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Selection Type"}),u.jsxs(ni,{onValueChange:m,value:e.type||"multiple",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"multiple",id:"r1"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r1",children:"Multiple"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"single",id:"r2"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r2",children:"Single"})]})]})]}),e.type==="single"&&u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"UI Component"}),u.jsxs(ni,{onValueChange:g,value:e.uiType||"dropdown",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"dropdown",id:"dropdown"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"dropdown",children:"Dropdown"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"radio",id:"radio"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"radio",children:"Radio"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"SQL"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),u.jsx(ch,{onKeyDown:y=>{y.stopPropagation()},value:t,onChange:y=>n(y.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${Kd}`,placeholder:"SELECT column FROM table..."})]}),u.jsx("div",{className:"border-t pt-2",children:u.jsx(YIe,{label:"Local to sheet",onCheckedChange:b,checked:!!e.sheetId})})]})]}),u.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:u.jsxs(ie,{onClick:p,size:"sm",variant:"outline",children:[u.jsx(_r,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}const Rq=C.createContext(void 0);function fb(){const e=C.useContext(Rq);return e||{preferences:{},isLocalDev:!1,isConsoleMode:!1}}function Iq({filter:e}){var c;const t=te(d=>d.isDashboardEditing),{preferences:n}=fb(),r=((c=n==null?void 0:n.cardDisplay)==null?void 0:c.mode)==="print",s=te(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Qt();return u.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[u.jsxs("div",{className:"flex grow items-center gap-2",children:[u.jsx(ae,{className:"my-1 inline-block text-sm",children:u.jsx(Do,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&u.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:u.jsx(lte,{className:"size-3.5"})}),t&&u.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?u.jsx(oh,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):u.jsx(Dv,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&u.jsx(eAe,{filter:e})]}),u.jsx("div",{className:"flex items-center gap-2",children:t&&u.jsx(Xt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function Aq(){var g;const e=te(b=>b.isDashboardEditing),t=te(b=>b.selectedSheetId),n=te(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=Ae(b=>b.card),i=Ae(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:c}=Qt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=Gr();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const y=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],x=y==null?void 0:y.type;if(y)return{connectionId:y.connectionId,connectionType:y.connectionType,type:x,selectedEntities:[y]}}function m(b){const y=(b==null?void 0:b.sheetId)||t,x=r==null?void 0:r.find(k=>k.id===y);if(!x){console.warn("Cannot add frame: No sheet found");return}if(!(!x.frames||x.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:wr(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:wr(),cards:[S],activeCardId:S.id};return y&&(a(y,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),c(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function tAe({sheetId:e}){const{handleAddNewFrame:t}=Aq(),n=te(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return u.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:u.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[u.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:u.jsx(gr,{className:"h-6 w-6 text-primary"})}),u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Y0(e){const t=(e||"").toLowerCase(),n=Jl(t);return n==="string"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-blue-100 text-xs text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:u.jsx(B$,{className:"h-3 w-3"})}):n==="number"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-green-100 text-xs text-green-700 dark:bg-green-950 dark:text-green-300",children:u.jsx(_$,{className:"h-3 w-3"})}):n==="date"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-purple-100 text-xs text-purple-700 dark:bg-purple-950 dark:text-purple-300",children:u.jsx(to,{className:"h-3 w-3"})}):n==="boolean"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(L$,{className:"h-3 w-3"})}):n==="json"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(w$,{className:"h-3 w-3"})}):n==="geo"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(dte,{className:"h-3 w-3"})}):n==="calculated"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(l$,{className:"h-3 w-3"})}):null}function nAe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return u.jsx(si,{children:u.jsxs("div",{className:"space-y-4",children:[n.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),u.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),u.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&u.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function rAe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return u.jsx("div",{className:"space-y-2",children:u.jsxs(pt,{value:e,onValueChange:t,children:[u.jsx(dt,{className:"w-full",children:u.jsx(bt,{placeholder:"Choose action...",children:n&&u.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=q0(n.value);return u.jsx(r,{className:"h-4 w-4"})})(),u.jsx("span",{children:n.label})]})})}),u.jsx(ft,{children:NF.map(r=>{const s=q0(r.value);return u.jsx(be,{value:r.value,children:u.jsxs("div",{className:"flex items-start gap-2 py-1",children:[u.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:r.label}),u.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function sAe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=E3(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),c=o();return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Filter scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),u.jsxs(ni,{value:c,onValueChange:d=>i(d),className:"space-y-2",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),c==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to filter"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),c==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to exclude"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var gM="Collapsible",[oAe,Pq]=yr(gM),[iAe,bM]=oAe(gM),Oq=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,c]=Mr({prop:r,defaultProp:s,onChange:i});return u.jsx(iAe,{scope:n,disabled:o,contentId:Gn(),open:l,onOpenToggle:E.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Re.div,{"data-state":wM(l),"data-disabled":o?"":void 0,...a,ref:t})})});Oq.displayName=gM;var Fq="CollapsibleTrigger",yM=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=bM(Fq,n);return u.jsx(Re.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":wM(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:we(e.onClick,s.onOpenToggle)})});yM.displayName=Fq;var xM="CollapsibleContent",vM=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=bM(xM,e.__scopeCollapsible);return u.jsx(Zn,{present:n||s.open,children:({present:o})=>u.jsx(aAe,{...r,ref:t,present:o})})});vM.displayName=xM;var aAe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=bM(xM,n),[a,l]=E.useState(r),c=E.useRef(null),d=at(t,c),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),Dr(()=>{const x=c.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(Re.div,{"data-state":wM(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function wM(e){return e?"open":"closed"}var $q=Oq,lAe=yM,cAe=vM;const zu=$q,Bu=yM,Vu=vM;function uAe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const s1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rh(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function SM(e){return"nodeType"in e}function hs(e){var t,n;return e?Rh(e)?e:SM(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function CM(e){const{Document:t}=hs(e);return e instanceof t}function hb(e){return Rh(e)?!1:e instanceof hs(e).HTMLElement}function Lq(e){return e instanceof hs(e).SVGElement}function Ih(e){return e?Rh(e)?e.document:SM(e)?CM(e)?e:hb(e)||Lq(e)?e.ownerDocument:document:document:document}const ii=s1?C.useLayoutEffect:C.useEffect;function o1(e){const t=C.useRef(e);return ii(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function dAe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Jm(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return ii(()=>{n.current!==e&&(n.current=e)},t),n}function pb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function G0(e){const t=o1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Z0(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let VC={};function mb(e,t){return C.useMemo(()=>{if(t)return t;const n=VC[e]==null?0:VC[e]+1;return VC[e]=n,e+"-"+n},[e,t])}function zq(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,c]of a){const d=o[l];d!=null&&(o[l]=d+e*c)}return o},{...t})}}const uf=zq(1),eg=zq(-1);function fAe(e){return"clientX"in e&&"clientY"in e}function i1(e){if(!e)return!1;const{KeyboardEvent:t}=hs(e.target);return t&&e instanceof t}function hAe(e){if(!e)return!1;const{TouchEvent:t}=hs(e.target);return t&&e instanceof t}function K0(e){if(hAe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return fAe(e)?{x:e.clientX,y:e.clientY}:null}const Yi=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Yi.Translate.toString(e),Yi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),kF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pAe(e){return e.matches(kF)?e:e.querySelector(kF)}const mAe={display:"none"};function gAe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:mAe},n)}function bAe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function yAe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Bq=C.createContext(null);function xAe(e){const t=C.useContext(Bq);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function vAe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const wAe={draggable:`
911
911
  To pick up a draggable item, press the space bar.
912
912
  While dragging, use the arrow keys to move the item.
913
913
  Press space again to drop the item in its new position, or press escape to cancel.
914
- `},SAe={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function CAe(e){let{announcements:t=SAe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:s=wAe}=e;const{announce:o,announcement:i}=yAe(),a=mb("DndLiveRegion"),[l,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),xAe(C.useMemo(()=>({onDragStart(f){let{active:h}=f;o(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:p}=f;t.onDragMove&&o(t.onDragMove({active:h,over:p}))},onDragOver(f){let{active:h,over:p}=f;o(t.onDragOver({active:h,over:p}))},onDragEnd(f){let{active:h,over:p}=f;o(t.onDragEnd({active:h,over:p}))},onDragCancel(f){let{active:h,over:p}=f;o(t.onDragCancel({active:h,over:p}))}}),[o,t])),!l)return null;const d=C.createElement(C.Fragment,null,C.createElement(gAe,{id:r,value:s.draggable}),C.createElement(bAe,{id:a,announcement:i}));return n?_n.createPortal(d,n):d}var mr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(mr||(mr={}));function X0(){}function tg(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function NM(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ai=Object.freeze({x:0,y:0});function Vq(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function NAe(e,t){const n=K0(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Hq(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function kAe(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function EF(e){let{left:t,top:n,height:r,width:s}=e;return[{x:t,y:n},{x:t+s,y:n},{x:t,y:n+r},{x:t+s,y:n+r}]}function Uq(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function jF(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const kM=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=jF(t,t.left,t.top),o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=Vq(jF(l),s);o.push({id:a,data:{droppableContainer:i,value:c}})}}return o.sort(Hq)},EAe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=EF(t),o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=EF(l),d=s.reduce((h,p,m)=>h+Vq(c[m],p),0),f=Number((d/4).toFixed(4));o.push({id:a,data:{droppableContainer:i,value:f}})}}return o.sort(Hq)};function jAe(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),i=s-r,a=o-n;if(r<s&&n<o){const l=t.width*t.height,c=e.width*e.height,d=i*a,f=d/(l+c-d);return Number(f.toFixed(4))}return 0}const _Ae=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=[];for(const o of r){const{id:i}=o,a=n.get(i);if(a){const l=jAe(a,t);l>0&&s.push({id:i,data:{droppableContainer:o,value:l}})}}return s.sort(kAe)};function DAe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Wq(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ai}function MAe(e){return function(n){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s.reduce((i,a)=>({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const TAe=MAe(1);function qq(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function RAe(e,t,n){const r=qq(t);if(!r)return e;const{scaleX:s,scaleY:o,x:i,y:a}=r,l=e.left-i-(1-s)*parseFloat(n),c=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,f=o?e.height/o:e.height;return{width:d,height:f,top:c,right:l+d,bottom:c+f,left:l}}const IAe={ignoreTransform:!1};function Ah(e,t){t===void 0&&(t=IAe);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:d}=hs(e).getComputedStyle(e);c&&(n=RAe(n,c,d))}const{top:r,left:s,width:o,height:i,bottom:a,right:l}=n;return{top:r,left:s,width:o,height:i,bottom:a,right:l}}function _F(e){return Ah(e,{ignoreTransform:!0})}function AAe(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function PAe(e,t){return t===void 0&&(t=hs(e).getComputedStyle(e)),t.position==="fixed"}function OAe(e,t){t===void 0&&(t=hs(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const o=t[s];return typeof o=="string"?n.test(o):!1})}function a1(e,t){const n=[];function r(s){if(t!=null&&n.length>=t||!s)return n;if(CM(s)&&s.scrollingElement!=null&&!n.includes(s.scrollingElement))return n.push(s.scrollingElement),n;if(!hb(s)||Lq(s)||n.includes(s))return n;const o=hs(e).getComputedStyle(s);return s!==e&&OAe(s,o)&&n.push(s),PAe(s,o)?n:r(s.parentNode)}return e?r(e):n}function Yq(e){const[t]=a1(e,1);return t??null}function HC(e){return!s1||!e?null:Rh(e)?e:SM(e)?CM(e)||e===Ih(e).scrollingElement?window:hb(e)?e:null:null}function Gq(e){return Rh(e)?e.scrollX:e.scrollLeft}function Zq(e){return Rh(e)?e.scrollY:e.scrollTop}function Kk(e){return{x:Gq(e),y:Zq(e)}}var vr;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(vr||(vr={}));function Kq(e){return!s1||!e?!1:e===document.scrollingElement}function Xq(e){const t={x:0,y:0},n=Kq(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},s=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:s,isLeft:o,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const FAe={x:.2,y:.2};function $Ae(e,t,n,r,s){let{top:o,left:i,right:a,bottom:l}=n;r===void 0&&(r=10),s===void 0&&(s=FAe);const{isTop:c,isBottom:d,isLeft:f,isRight:h}=Xq(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*s.y,width:t.width*s.x};return!c&&o<=t.top+g.height?(p.y=vr.Backward,m.y=r*Math.abs((t.top+g.height-o)/g.height)):!d&&l>=t.bottom-g.height&&(p.y=vr.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=vr.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!f&&i<=t.left+g.width&&(p.x=vr.Backward,m.x=r*Math.abs((t.left+g.width-i)/g.width)),{direction:p,speed:m}}function LAe(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:t,left:n,right:r,bottom:s}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:s,width:e.clientWidth,height:e.clientHeight}}function Qq(e){return e.reduce((t,n)=>uf(t,Kk(n)),ai)}function zAe(e){return e.reduce((t,n)=>t+Gq(n),0)}function BAe(e){return e.reduce((t,n)=>t+Zq(n),0)}function Jq(e,t){if(t===void 0&&(t=Ah),!e)return;const{top:n,left:r,bottom:s,right:o}=t(e);Yq(e)&&(s<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const VAe=[["x",["left","right"],zAe],["y",["top","bottom"],BAe]];class EM{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=a1(n),s=Qq(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,i,a]of VAe)for(const l of i)Object.defineProperty(this,l,{get:()=>{const c=a(r),d=s[o]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class sm{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var s;(s=this.target)==null||s.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function HAe(e){const{EventTarget:t}=hs(e);return e instanceof t?e:Ih(e)}function UC(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var yo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(yo||(yo={}));function DF(e){e.preventDefault()}function UAe(e){e.stopPropagation()}var Lt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Lt||(Lt={}));const eY={start:[Lt.Space,Lt.Enter],cancel:[Lt.Esc],end:[Lt.Space,Lt.Enter,Lt.Tab]},WAe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Lt.Right:return{...n,x:n.x+25};case Lt.Left:return{...n,x:n.x-25};case Lt.Down:return{...n,y:n.y+25};case Lt.Up:return{...n,y:n.y-25}}};class gb{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new sm(Ih(n)),this.windowListeners=new sm(hs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Jq(r),n(ai)}handleKeyDown(t){if(i1(t)){const{active:n,context:r,options:s}=this.props,{keyboardCodes:o=eY,coordinateGetter:i=WAe,scrollBehavior:a="smooth"}=s,{code:l}=t;if(o.end.includes(l)){this.handleEnd(t);return}if(o.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,d=c?{x:c.left,y:c.top}:ai;this.referenceCoordinates||(this.referenceCoordinates=d);const f=i(t,{active:n,context:r.current,currentCoordinates:d});if(f){const h=eg(f,d),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:x,isLeft:v,isBottom:w,maxScroll:S,minScroll:N}=Xq(g),k=LAe(g),j={x:Math.min(b===Lt.Right?k.right-k.width/2:k.right,Math.max(b===Lt.Right?k.left:k.left+k.width/2,f.x)),y:Math.min(b===Lt.Down?k.bottom-k.height/2:k.bottom,Math.max(b===Lt.Down?k.top:k.top+k.height/2,f.y))},_=b===Lt.Right&&!x||b===Lt.Left&&!v,D=b===Lt.Down&&!w||b===Lt.Up&&!y;if(_&&j.x!==f.x){const M=g.scrollLeft+h.x,T=b===Lt.Right&&M<=S.x||b===Lt.Left&&M>=N.x;if(T&&!h.y){g.scrollTo({left:M,behavior:a});return}T?p.x=g.scrollLeft-M:p.x=b===Lt.Right?g.scrollLeft-S.x:g.scrollLeft-N.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(D&&j.y!==f.y){const M=g.scrollTop+h.y,T=b===Lt.Down&&M<=S.y||b===Lt.Up&&M>=N.y;if(T&&!h.x){g.scrollTo({top:M,behavior:a});return}T?p.y=g.scrollTop-M:p.y=b===Lt.Down?g.scrollTop-S.y:g.scrollTop-N.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,uf(eg(f,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}gb.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=eY,onActivation:s}=t,{active:o}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=o.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),s==null||s({event:e.nativeEvent}),!0)}return!1}}];function MF(e){return!!(e&&"distance"in e)}function TF(e){return!!(e&&"delay"in e)}class jM{constructor(t,n,r){var s;r===void 0&&(r=HAe(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:o}=t,{target:i}=o;this.props=t,this.events=n,this.document=Ih(i),this.documentListeners=new sm(this.document),this.listeners=new sm(r),this.windowListeners=new sm(hs(i)),this.initialCoordinates=(s=K0(o))!=null?s:ai,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.DragStart,DF),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),this.windowListeners.add(yo.ContextMenu,DF),this.documentListeners.add(yo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(TF(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(MF(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:s}=this.props;s(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(yo.Click,UAe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:s,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!s)return;const l=(n=K0(t))!=null?n:ai,c=eg(s,l);if(!r&&a){if(MF(a)){if(a.tolerance!=null&&UC(c,a.tolerance))return this.handleCancel();if(UC(c,a.distance))return this.handleStart()}if(TF(a)&&UC(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),i(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Lt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const qAe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bb extends jM{constructor(t){const{event:n}=t,r=Ih(n.target);super(t,qAe,r)}}bb.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const YAe={move:{name:"mousemove"},end:{name:"mouseup"}};var Xk;(function(e){e[e.RightClick=2]="RightClick"})(Xk||(Xk={}));class GAe extends jM{constructor(t){super(t,YAe,Ih(t.event.target))}}GAe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xk.RightClick?!1:(r==null||r({event:n}),!0)}}];const WC={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ZAe extends jM{constructor(t){super(t,WC)}static setup(){return window.addEventListener(WC.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(WC.move.name,t)};function t(){}}}ZAe.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:s}=n;return s.length>1?!1:(r==null||r({event:n}),!0)}}];var om;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(om||(om={}));var Q0;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Q0||(Q0={}));function KAe(e){let{acceleration:t,activator:n=om.Pointer,canScroll:r,draggingRect:s,enabled:o,interval:i=5,order:a=Q0.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:f,threshold:h}=e;const p=QAe({delta:f,disabled:!o}),[m,g]=dAe(),b=C.useRef({x:0,y:0}),y=C.useRef({x:0,y:0}),x=C.useMemo(()=>{switch(n){case om.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case om.DraggableRect:return s}},[n,s,l]),v=C.useRef(null),w=C.useCallback(()=>{const N=v.current;if(!N)return;const k=b.current.x*y.current.x,j=b.current.y*y.current.y;N.scrollBy(k,j)},[]),S=C.useMemo(()=>a===Q0.TreeOrder?[...c].reverse():c,[a,c]);C.useEffect(()=>{if(!o||!c.length||!x){g();return}for(const N of S){if((r==null?void 0:r(N))===!1)continue;const k=c.indexOf(N),j=d[k];if(!j)continue;const{direction:_,speed:D}=$Ae(N,j,x,t,h);for(const M of["x","y"])p[M][_[M]]||(D[M]=0,_[M]=0);if(D.x>0||D.y>0){g(),v.current=N,m(w,i),b.current=D,y.current=_;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,w,r,g,o,i,JSON.stringify(x),JSON.stringify(p),m,c,S,d,JSON.stringify(h)])}const XAe={x:{[vr.Backward]:!1,[vr.Forward]:!1},y:{[vr.Backward]:!1,[vr.Forward]:!1}};function QAe(e){let{delta:t,disabled:n}=e;const r=Z0(t);return pb(s=>{if(n||!r||!s)return XAe;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[vr.Backward]:s.x[vr.Backward]||o.x===-1,[vr.Forward]:s.x[vr.Forward]||o.x===1},y:{[vr.Backward]:s.y[vr.Backward]||o.y===-1,[vr.Forward]:s.y[vr.Forward]||o.y===1}}},[n,t,r])}function JAe(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return pb(s=>{var o;return t==null?null:(o=r??s)!=null?o:null},[r,t])}function ePe(e,t){return C.useMemo(()=>e.reduce((n,r)=>{const{sensor:s}=r,o=s.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...o]},[]),[e,t])}var ng;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ng||(ng={}));var Qk;(function(e){e.Optimized="optimized"})(Qk||(Qk={}));const RF=new Map;function tPe(e,t){let{dragging:n,dependencies:r,config:s}=t;const[o,i]=C.useState(null),{frequency:a,measure:l,strategy:c}=s,d=C.useRef(e),f=b(),h=Jm(f),p=C.useCallback(function(y){y===void 0&&(y=[]),!h.current&&i(x=>x===null?y:x.concat(y.filter(v=>!x.includes(v))))},[h]),m=C.useRef(null),g=pb(y=>{if(f&&!n)return RF;if(!y||y===RF||d.current!==e||o!=null){const x=new Map;for(let v of e){if(!v)continue;if(o&&o.length>0&&!o.includes(v.id)&&v.rect.current){x.set(v.id,v.rect.current);continue}const w=v.node.current,S=w?new EM(l(w),w):null;v.rect.current=S,S&&x.set(v.id,S)}return x}return y},[e,o,n,f,l]);return C.useEffect(()=>{d.current=e},[e]),C.useEffect(()=>{f||p()},[n,f]),C.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),C.useEffect(()=>{f||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,f,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:o!=null};function b(){switch(c){case ng.Always:return!1;case ng.BeforeDragging:return n;default:return!n}}}function _M(e,t){return pb(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function nPe(e,t){return _M(e,t)}function rPe(e){let{callback:t,disabled:n}=e;const r=o1(t),s=C.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return C.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function l1(e){let{callback:t,disabled:n}=e;const r=o1(t),s=C.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return C.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function sPe(e){return new EM(Ah(e),e)}function IF(e,t,n){t===void 0&&(t=sPe);const[r,s]=C.useState(null);function o(){s(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const d=t(e);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const i=rPe({callback(l){if(e)for(const c of l){const{type:d,target:f}=c;if(d==="childList"&&f instanceof HTMLElement&&f.contains(e)){o();break}}}}),a=l1({callback:o});return ii(()=>{o(),e?(a==null||a.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[e]),r}function oPe(e){const t=_M(e);return Wq(e,t)}const AF=[];function iPe(e){const t=C.useRef(e),n=pb(r=>e?r&&r!==AF&&e&&t.current&&e.parentNode===t.current.parentNode?r:a1(e):AF,[e]);return C.useEffect(()=>{t.current=e},[e]),n}function aPe(e){const[t,n]=C.useState(null),r=C.useRef(e),s=C.useCallback(o=>{const i=HC(o.target);i&&n(a=>a?(a.set(i,Kk(i)),new Map(a)):null)},[]);return C.useEffect(()=>{const o=r.current;if(e!==o){i(o);const a=e.map(l=>{const c=HC(l);return c?(c.addEventListener("scroll",s,{passive:!0}),[c,Kk(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(o)};function i(a){a.forEach(l=>{const c=HC(l);c==null||c.removeEventListener("scroll",s)})}},[s,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,i)=>uf(o,i),ai):Qq(e):ai,[e,t])}function PF(e,t){t===void 0&&(t=[]);const n=C.useRef(null);return C.useEffect(()=>{n.current=null},t),C.useEffect(()=>{const r=e!==ai;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?eg(e,n.current):ai}function lPe(e){C.useEffect(()=>{if(!s1)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function cPe(e,t){return C.useMemo(()=>e.reduce((n,r)=>{let{eventName:s,handler:o}=r;return n[s]=i=>{o(i,t)},n},{}),[e,t])}function tY(e){return C.useMemo(()=>e?AAe(e):null,[e])}const OF=[];function uPe(e,t){t===void 0&&(t=Ah);const[n]=e,r=tY(n?hs(n):null),[s,o]=C.useState(OF);function i(){o(()=>e.length?e.map(l=>Kq(l)?r:new EM(t(l),l)):OF)}const a=l1({callback:i});return ii(()=>{a==null||a.disconnect(),i(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),s}function nY(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return hb(t)?t:e}function dPe(e){let{measure:t}=e;const[n,r]=C.useState(null),s=C.useCallback(c=>{for(const{target:d}of c)if(hb(d)){r(f=>{const h=t(d);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),o=l1({callback:s}),i=C.useCallback(c=>{const d=nY(c);o==null||o.disconnect(),d&&(o==null||o.observe(d)),r(d?t(d):null)},[t,o]),[a,l]=G0(i);return C.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const fPe=[{sensor:bb,options:{}},{sensor:gb,options:{}}],hPe={current:{}},Nx={draggable:{measure:_F},droppable:{measure:_F,strategy:ng.WhileDragging,frequency:Qk.Optimized},dragOverlay:{measure:Ah}};class im extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const pPe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new im,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:X0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Nx,measureDroppableContainers:X0,windowRect:null,measuringScheduled:!1},rY={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:X0,draggableNodes:new Map,over:null,measureDroppableContainers:X0},yb=C.createContext(rY),sY=C.createContext(pPe);function mPe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new im}}}function gPe(e,t){switch(t.type){case mr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case mr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case mr.DragEnd:case mr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case mr.RegisterDroppable:{const{element:n}=t,{id:r}=n,s=new im(e.droppable.containers);return s.set(r,n),{...e,droppable:{...e.droppable,containers:s}}}case mr.SetDroppableDisabled:{const{id:n,key:r,disabled:s}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new im(e.droppable.containers);return i.set(n,{...o,disabled:s}),{...e,droppable:{...e.droppable,containers:i}}}case mr.UnregisterDroppable:{const{id:n,key:r}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const o=new im(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function bPe(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:s}=C.useContext(yb),o=Z0(r),i=Z0(n==null?void 0:n.id);return C.useEffect(()=>{if(!t&&!r&&o&&i!=null){if(!i1(o)||document.activeElement===o.target)return;const a=s.get(i);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const f=pAe(d);if(f){f.focus();break}}})}},[r,t,s,i,o]),null}function oY(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((s,o)=>o({transform:s,...r}),n):n}function yPe(e){return C.useMemo(()=>({draggable:{...Nx.draggable,...e==null?void 0:e.draggable},droppable:{...Nx.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Nx.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function xPe(e){let{activeNode:t,measure:n,initialRect:r,config:s=!0}=e;const o=C.useRef(!1),{x:i,y:a}=typeof s=="boolean"?{x:s,y:s}:s;ii(()=>{if(!i&&!a||!t){o.current=!1;return}if(o.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const d=n(c),f=Wq(d,r);if(i||(f.x=0),a||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const h=Yq(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,i,a,r,n])}const c1=C.createContext({...ai,scaleX:1,scaleY:1});var fl;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(fl||(fl={}));const DM=C.memo(function(t){var n,r,s,o;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:d=fPe,collisionDetection:f=_Ae,measuring:h,modifiers:p,...m}=t;const g=C.useReducer(gPe,void 0,mPe),[b,y]=g,[x,v]=vAe(),[w,S]=C.useState(fl.Uninitialized),N=w===fl.Initialized,{draggable:{active:k,nodes:j,translate:_},droppable:{containers:D}}=b,M=k!=null?j.get(k):null,T=C.useRef({initial:null,translated:null}),O=C.useMemo(()=>{var He;return k!=null?{id:k,data:(He=M==null?void 0:M.data)!=null?He:hPe,rect:T}:null},[k,M]),A=C.useRef(null),[P,F]=C.useState(null),[V,U]=C.useState(null),z=Jm(m,Object.values(m)),I=mb("DndDescribedBy",i),B=C.useMemo(()=>D.getEnabled(),[D]),L=yPe(h),{droppableRects:R,measureDroppableContainers:W,measuringScheduled:Y}=tPe(B,{dragging:N,dependencies:[_.x,_.y],config:L.droppable}),Z=JAe(j,k),H=C.useMemo(()=>V?K0(V):null,[V]),$=_e(),q=nPe(Z,L.draggable.measure);xPe({activeNode:k!=null?j.get(k):null,config:$.layoutShiftCompensation,initialRect:q,measure:L.draggable.measure});const G=IF(Z,L.draggable.measure,q),ee=IF(Z?Z.parentElement:null),Q=C.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:R,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=D.getNodeFor((n=Q.current.over)==null?void 0:n.id),oe=dPe({measure:L.dragOverlay.measure}),de=(r=oe.nodeRef.current)!=null?r:Z,le=N?(s=oe.rect)!=null?s:G:null,ke=!!(oe.nodeRef.current&&oe.rect),ye=oPe(ke?null:G),Pe=tY(de?hs(de):null),Ve=iPe(N?ne??Z:null),lt=uPe(Ve),ue=oY(p,{transform:{x:_.x-ye.x,y:_.y-ye.y,scaleX:1,scaleY:1},activatorEvent:V,active:O,activeNodeRect:G,containerNodeRect:ee,draggingNodeRect:le,over:Q.current.over,overlayNodeRect:oe.rect,scrollableAncestors:Ve,scrollableAncestorRects:lt,windowRect:Pe}),Ne=H?uf(H,_):null,Je=aPe(Ve),We=PF(Je),re=PF(Je,[G]),fe=uf(ue,We),De=le?TAe(le,ue):null,Oe=O&&De?f({active:O,collisionRect:De,droppableRects:R,droppableContainers:B,pointerCoordinates:Ne}):null,Me=Uq(Oe,"id"),[nt,Dt]=C.useState(null),ct=ke?ue:uf(ue,re),Ot=DAe(ct,(o=nt==null?void 0:nt.rect)!=null?o:null,G),ve=C.useRef(null),_t=C.useCallback((He,et)=>{let{sensor:qe,options:$e}=et;if(A.current==null)return;const Ze=j.get(A.current);if(!Ze)return;const rt=He.nativeEvent,qt=new qe({active:A.current,activeNode:Ze,event:rt,options:$e,context:Q,onAbort(Yt){if(!j.get(Yt))return;const{onDragAbort:Rn}=z.current,er={id:Yt};Rn==null||Rn(er),x({type:"onDragAbort",event:er})},onPending(Yt,xr,Rn,er){if(!j.get(Yt))return;const{onDragPending:co}=z.current,pi={id:Yt,constraint:xr,initialCoordinates:Rn,offset:er};co==null||co(pi),x({type:"onDragPending",event:pi})},onStart(Yt){const xr=A.current;if(xr==null)return;const Rn=j.get(xr);if(!Rn)return;const{onDragStart:er}=z.current,pc={activatorEvent:rt,active:{id:xr,data:Rn.data,rect:T}};_n.unstable_batchedUpdates(()=>{er==null||er(pc),S(fl.Initializing),y({type:mr.DragStart,initialCoordinates:Yt,active:xr}),x({type:"onDragStart",event:pc}),F(ve.current),U(rt)})},onMove(Yt){y({type:mr.DragMove,coordinates:Yt})},onEnd:Ft(mr.DragEnd),onCancel:Ft(mr.DragCancel)});ve.current=qt;function Ft(Yt){return async function(){const{active:Rn,collisions:er,over:pc,scrollAdjustedTranslate:co}=Q.current;let pi=null;if(Rn&&co){const{cancelDrop:mc}=z.current;pi={activatorEvent:rt,active:Rn,collisions:er,delta:co,over:pc},Yt===mr.DragEnd&&typeof mc=="function"&&await Promise.resolve(mc(pi))&&(Yt=mr.DragCancel)}A.current=null,_n.unstable_batchedUpdates(()=>{y({type:Yt}),S(fl.Uninitialized),Dt(null),F(null),U(null),ve.current=null;const mc=Yt===mr.DragEnd?"onDragEnd":"onDragCancel";if(pi){const Fh=z.current[mc];Fh==null||Fh(pi),x({type:mc,event:pi})}})}}},[j]),vn=C.useCallback((He,et)=>(qe,$e)=>{const Ze=qe.nativeEvent,rt=j.get($e);if(A.current!==null||!rt||Ze.dndKit||Ze.defaultPrevented)return;const qt={active:rt};He(qe,et.options,qt)===!0&&(Ze.dndKit={capturedBy:et.sensor},A.current=$e,_t(qe,et))},[j,_t]),he=ePe(d,vn);lPe(d),ii(()=>{G&&w===fl.Initializing&&S(fl.Initialized)},[G,w]),C.useEffect(()=>{const{onDragMove:He}=z.current,{active:et,activatorEvent:qe,collisions:$e,over:Ze}=Q.current;if(!et||!qe)return;const rt={active:et,activatorEvent:qe,collisions:$e,delta:{x:fe.x,y:fe.y},over:Ze};_n.unstable_batchedUpdates(()=>{He==null||He(rt),x({type:"onDragMove",event:rt})})},[fe.x,fe.y]),C.useEffect(()=>{const{active:He,activatorEvent:et,collisions:qe,droppableContainers:$e,scrollAdjustedTranslate:Ze}=Q.current;if(!He||A.current==null||!et||!Ze)return;const{onDragOver:rt}=z.current,qt=$e.get(Me),Ft=qt&&qt.rect.current?{id:qt.id,rect:qt.rect.current,data:qt.data,disabled:qt.disabled}:null,Yt={active:He,activatorEvent:et,collisions:qe,delta:{x:Ze.x,y:Ze.y},over:Ft};_n.unstable_batchedUpdates(()=>{Dt(Ft),rt==null||rt(Yt),x({type:"onDragOver",event:Yt})})},[Me]),ii(()=>{Q.current={activatorEvent:V,active:O,activeNode:Z,collisionRect:De,collisions:Oe,droppableRects:R,draggableNodes:j,draggingNode:de,draggingNodeRect:le,droppableContainers:D,over:nt,scrollableAncestors:Ve,scrollAdjustedTranslate:fe},T.current={initial:le,translated:De}},[O,Z,Oe,De,j,de,le,R,D,nt,Ve,fe]),KAe({...$,delta:_,draggingRect:De,pointerCoordinates:Ne,scrollableAncestors:Ve,scrollableAncestorRects:lt});const xe=C.useMemo(()=>({active:O,activeNode:Z,activeNodeRect:G,activatorEvent:V,collisions:Oe,containerNodeRect:ee,dragOverlay:oe,draggableNodes:j,droppableContainers:D,droppableRects:R,over:nt,measureDroppableContainers:W,scrollableAncestors:Ve,scrollableAncestorRects:lt,measuringConfiguration:L,measuringScheduled:Y,windowRect:Pe}),[O,Z,G,V,Oe,ee,oe,j,D,R,nt,W,Ve,lt,L,Y,Pe]),Ie=C.useMemo(()=>({activatorEvent:V,activators:he,active:O,activeNodeRect:G,ariaDescribedById:{draggable:I},dispatch:y,draggableNodes:j,over:nt,measureDroppableContainers:W}),[V,he,O,G,y,I,j,nt,W]);return C.createElement(Bq.Provider,{value:v},C.createElement(yb.Provider,{value:Ie},C.createElement(sY.Provider,{value:xe},C.createElement(c1.Provider,{value:Ot},c)),C.createElement(bPe,{disabled:(a==null?void 0:a.restoreFocus)===!1})),C.createElement(CAe,{...a,hiddenTextDescribedById:I}));function _e(){const He=(P==null?void 0:P.autoScrollEnabled)===!1,et=typeof l=="object"?l.enabled===!1:l===!1,qe=N&&!He&&!et;return typeof l=="object"?{...l,enabled:qe}:{enabled:qe}}}),vPe=C.createContext(null),FF="button",wPe="Draggable";function SPe(e){let{id:t,data:n,disabled:r=!1,attributes:s}=e;const o=mb(wPe),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:f,over:h}=C.useContext(yb),{role:p=FF,roleDescription:m="draggable",tabIndex:g=0}=s??{},b=(l==null?void 0:l.id)===t,y=C.useContext(b?c1:vPe),[x,v]=G0(),[w,S]=G0(),N=cPe(i,t),k=Jm(n);ii(()=>(f.set(t,{id:t,key:o,node:x,activatorNode:w,data:k}),()=>{const _=f.get(t);_&&_.key===o&&f.delete(t)}),[f,t]);const j=C.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===FF?!0:void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[r,p,g,b,m,d.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:j,isDragging:b,listeners:r?void 0:N,node:x,over:h,setNodeRef:v,setActivatorNodeRef:S,transform:y}}function iY(){return C.useContext(sY)}const CPe="Droppable",NPe={timeout:25};function aY(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:s}=e;const o=mb(CPe),{active:i,dispatch:a,over:l,measureDroppableContainers:c}=C.useContext(yb),d=C.useRef({disabled:n}),f=C.useRef(!1),h=C.useRef(null),p=C.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...NPe,...s},y=Jm(g??r),x=C.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),v=l1({callback:x,disabled:m||!i}),w=C.useCallback((j,_)=>{v&&(_&&(v.unobserve(_),f.current=!1),j&&v.observe(j))},[v]),[S,N]=G0(w),k=Jm(t);return C.useEffect(()=>{!v||!S.current||(v.disconnect(),f.current=!1,v.observe(S.current))},[S,v]),C.useEffect(()=>(a({type:mr.RegisterDroppable,element:{id:r,key:o,disabled:n,node:S,rect:h,data:k}}),()=>a({type:mr.UnregisterDroppable,key:o,id:r})),[r]),C.useEffect(()=>{n!==d.current.disabled&&(a({type:mr.SetDroppableDisabled,id:r,key:o,disabled:n}),d.current.disabled=n)},[r,o,n,a]),{active:i,rect:h,isOver:(l==null?void 0:l.id)===r,node:S,over:l,setNodeRef:N}}function kPe(e){let{animation:t,children:n}=e;const[r,s]=C.useState(null),[o,i]=C.useState(null),a=Z0(n);return!n&&!r&&a&&s(a),ii(()=>{if(!o)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){s(null);return}Promise.resolve(t(c,o)).then(()=>{s(null)})},[t,r,o]),C.createElement(C.Fragment,null,n,r?C.cloneElement(r,{ref:i}):null)}const EPe={x:0,y:0,scaleX:1,scaleY:1};function jPe(e){let{children:t}=e;return C.createElement(yb.Provider,{value:rY},C.createElement(c1.Provider,{value:EPe},t))}const _Pe={position:"fixed",touchAction:"none"},DPe=e=>i1(e)?"transform 250ms ease":void 0,MPe=C.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:s,children:o,className:i,rect:a,style:l,transform:c,transition:d=DPe}=e;if(!a)return null;const f=s?c:{...c,scaleX:1,scaleY:1},h={..._Pe,width:a.width,height:a.height,top:a.top,left:a.left,transform:Yi.Transform.toString(f),transformOrigin:s&&r?NAe(r,a):void 0,transition:typeof d=="function"?d(r):d,...l};return C.createElement(n,{className:i,style:h,ref:t},o)}),TPe=e=>t=>{let{active:n,dragOverlay:r}=t;const s={},{styles:o,className:i}=e;if(o!=null&&o.active)for(const[a,l]of Object.entries(o.active))l!==void 0&&(s[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(o!=null&&o.dragOverlay)for(const[a,l]of Object.entries(o.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return i!=null&&i.active&&n.node.classList.add(i.active),i!=null&&i.dragOverlay&&r.node.classList.add(i.dragOverlay),function(){for(const[l,c]of Object.entries(s))n.node.style.setProperty(l,c);i!=null&&i.active&&n.node.classList.remove(i.active)}},RPe=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Yi.Transform.toString(t)},{transform:Yi.Transform.toString(n)}]},IPe={duration:250,easing:"ease",keyframes:RPe,sideEffects:TPe({styles:{active:{opacity:"0"}}})};function APe(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:s}=e;return o1((o,i)=>{if(t===null)return;const a=n.get(o);if(!a)return;const l=a.node.current;if(!l)return;const c=nY(i);if(!c)return;const{transform:d}=hs(i).getComputedStyle(i),f=qq(d);if(!f)return;const h=typeof t=="function"?t:PPe(t);return Jq(l,s.draggable.measure),h({active:{id:o,data:a.data,node:l,rect:s.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:i,rect:s.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:s,transform:f})})}function PPe(e){const{duration:t,easing:n,sideEffects:r,keyframes:s}={...IPe,...e};return o=>{let{active:i,dragOverlay:a,transform:l,...c}=o;if(!t)return;const d={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},f={scaleX:l.scaleX!==1?i.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?i.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-d.x,y:l.y-d.y,...f},p=s({...c,active:i,dragOverlay:a,transform:{initial:l,final:h}}),[m]=p,g=p[p.length-1];if(JSON.stringify(m)===JSON.stringify(g))return;const b=r==null?void 0:r({active:i,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(x=>{y.onfinish=()=>{b==null||b(),x()}})}}let $F=0;function OPe(e){return C.useMemo(()=>{if(e!=null)return $F++,$F},[e])}const lY=C.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:s,transition:o,modifiers:i,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:d,active:f,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:x,scrollableAncestors:v,scrollableAncestorRects:w,windowRect:S}=iY(),N=C.useContext(c1),k=OPe(f==null?void 0:f.id),j=oY(i,{activatorEvent:d,active:f,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:v,scrollableAncestorRects:w,transform:N,windowRect:S}),_=_M(h),D=APe({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:x}),M=_?b.setRef:void 0;return C.createElement(jPe,null,C.createElement(kPe,{animation:D},f&&k?C.createElement(MPe,{key:k,id:f.id,ref:M,as:a,activatorEvent:d,adjustScale:t,className:l,transition:o,rect:_,style:{zIndex:c,...s},transform:j},n):null))});function xb(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function FPe(e,t){return e.reduce((n,r,s)=>{const o=t.get(r);return o&&(n[s]=o),n},Array(e.length))}function By(e){return e!==null&&e>=0}function $Pe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function LPe(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Vy={scaleX:1,scaleY:1},zPe=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:s,overIndex:o,index:i}=e;const a=(t=n[s])!=null?t:r;if(!a)return null;const l=BPe(n,i,s);if(i===s){const c=n[o];return c?{x:s<o?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Vy}:null}return i>s&&i<=o?{x:-a.width-l,y:0,...Vy}:i<s&&i>=o?{x:a.width+l,y:0,...Vy}:{x:0,y:0,...Vy}};function BPe(e,t,n){const r=e[t],s=e[t-1],o=e[t+1];return!r||!s&&!o?0:n<t?s?r.left-(s.left+s.width):o.left-(r.left+r.width):o?o.left-(r.left+r.width):r.left-(s.left+s.width)}const cY=e=>{let{rects:t,activeIndex:n,overIndex:r,index:s}=e;const o=xb(t,r,n),i=t[s],a=o[s];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},Hy={scaleX:1,scaleY:1},uY=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:s,rects:o,overIndex:i}=e;const a=(t=o[n])!=null?t:r;if(!a)return null;if(s===n){const c=o[i];return c?{x:0,y:n<i?c.top+c.height-(a.top+a.height):c.top-a.top,...Hy}:null}const l=VPe(o,s,n);return s>n&&s<=i?{x:0,y:-a.height-l,...Hy}:s<n&&s>=i?{x:0,y:a.height+l,...Hy}:{x:0,y:0,...Hy}};function VPe(e,t,n){const r=e[t],s=e[t-1],o=e[t+1];return r?n<t?s?r.top-(s.top+s.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const dY="Sortable",fY=C.createContext({activeIndex:-1,containerId:dY,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:cY,disabled:{draggable:!1,droppable:!1}});function MM(e){let{children:t,id:n,items:r,strategy:s=cY,disabled:o=!1}=e;const{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:d}=iY(),f=mb(dY,n),h=a.rect!==null,p=C.useMemo(()=>r.map(N=>typeof N=="object"&&"id"in N?N.id:N),[r]),m=i!=null,g=i?p.indexOf(i.id):-1,b=c?p.indexOf(c.id):-1,y=C.useRef(p),x=!$Pe(p,y.current),v=b!==-1&&g===-1||x,w=LPe(o);ii(()=>{x&&m&&d(p)},[x,p,m,d]),C.useEffect(()=>{y.current=p},[p]);const S=C.useMemo(()=>({activeIndex:g,containerId:f,disabled:w,disableTransforms:v,items:p,overIndex:b,useDragOverlay:h,sortedRects:FPe(p,l),strategy:s}),[g,f,w.draggable,w.droppable,v,p,b,l,h,s]);return C.createElement(fY.Provider,{value:S},t)}const HPe=e=>{let{id:t,items:n,activeIndex:r,overIndex:s}=e;return xb(n,r,s).indexOf(t)},UPe=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:s,items:o,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==o&&s===i?!1:n?!0:i!==s&&t===l},WPe={duration:200,easing:"ease"},hY="transform",qPe=Yi.Transition.toString({property:hY,duration:0,easing:"linear"}),YPe={roleDescription:"sortable"};function GPe(e){let{disabled:t,index:n,node:r,rect:s}=e;const[o,i]=C.useState(null),a=C.useRef(n);return ii(()=>{if(!t&&n!==a.current&&r.current){const l=s.current;if(l){const c=Ah(r.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&i(d)}}n!==a.current&&(a.current=n)},[t,n,r,s]),C.useEffect(()=>{o&&i(null)},[o]),o}function TM(e){let{animateLayoutChanges:t=UPe,attributes:n,disabled:r,data:s,getNewIndex:o=HPe,id:i,strategy:a,resizeObserverConfig:l,transition:c=WPe}=e;const{items:d,containerId:f,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:x}=C.useContext(fY),v=ZPe(r,p),w=d.indexOf(i),S=C.useMemo(()=>({sortable:{containerId:f,index:w,items:d},...s}),[f,s,w,d]),N=C.useMemo(()=>d.slice(d.indexOf(i)),[d,i]),{rect:k,node:j,isOver:_,setNodeRef:D}=aY({id:i,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...l}}),{active:M,activatorEvent:T,activeNodeRect:O,attributes:A,setNodeRef:P,listeners:F,isDragging:V,over:U,setActivatorNodeRef:z,transform:I}=SPe({id:i,data:S,attributes:{...YPe,...n},disabled:v.draggable}),B=uAe(D,P),L=!!M,R=L&&!m&&By(h)&&By(b),W=!y&&V,Y=W&&R?I:null,H=R?Y??(a??x)({rects:g,activeNodeRect:O,activeIndex:h,overIndex:b,index:w}):null,$=By(h)&&By(b)?o({id:i,items:d,activeIndex:h,overIndex:b}):w,q=M==null?void 0:M.id,G=C.useRef({activeId:q,items:d,newIndex:$,containerId:f}),ee=d!==G.current.items,Q=t({active:M,containerId:f,isDragging:V,isSorting:L,id:i,index:w,items:d,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:c,wasDragging:G.current.activeId!=null}),ne=GPe({disabled:!Q,index:w,node:j,rect:k});return C.useEffect(()=>{L&&G.current.newIndex!==$&&(G.current.newIndex=$),f!==G.current.containerId&&(G.current.containerId=f),d!==G.current.items&&(G.current.items=d)},[L,$,f,d]),C.useEffect(()=>{if(q===G.current.activeId)return;if(q!=null&&G.current.activeId==null){G.current.activeId=q;return}const de=setTimeout(()=>{G.current.activeId=q},50);return()=>clearTimeout(de)},[q]),{active:M,activeIndex:h,attributes:A,data:S,rect:k,index:w,newIndex:$,items:d,isOver:_,isSorting:L,isDragging:V,listeners:F,node:j,overIndex:b,over:U,setNodeRef:B,setActivatorNodeRef:z,setDroppableNodeRef:D,setDraggableNodeRef:P,transform:ne??H,transition:oe()};function oe(){if(ne||ee&&G.current.newIndex===w)return qPe;if(!(W&&!i1(T)||!c)&&(L||Q))return Yi.Transition.toString({...c,property:hY})}}function ZPe(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function J0(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const KPe=[Lt.Down,Lt.Right,Lt.Up,Lt.Left],RM=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:s,droppableContainers:o,over:i,scrollableAncestors:a}}=t;if(KPe.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=s.get(f.id);if(h)switch(e.code){case Lt.Down:r.top<h.top&&l.push(f);break;case Lt.Up:r.top>h.top&&l.push(f);break;case Lt.Left:r.left>h.left&&l.push(f);break;case Lt.Right:r.left<h.left&&l.push(f);break}});const c=EAe({collisionRect:r,droppableRects:s,droppableContainers:l});let d=Uq(c,"id");if(d===(i==null?void 0:i.id)&&c.length>1&&(d=c[1].id),d!=null){const f=o.get(n.id),h=o.get(d),p=h?s.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&f&&h){const b=a1(m).some((N,k)=>a[k]!==N),y=pY(f,h),x=XPe(f,h),v=b||!y?{x:0,y:0}:{x:x?r.width-p.width:0,y:x?r.height-p.height:0},w={x:p.left,y:p.top};return v.x&&v.y?w:eg(w,v)}}}};function pY(e,t){return!J0(e)||!J0(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function XPe(e,t){return!J0(e)||!J0(t)||!pY(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function QPe(e,t,n){const[r,s]=C.useState(null),[o,i]=C.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:o||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),i(""),s(m.id)},l=m=>{t(e.filter(g=>g.id!==m))},c=(m,g)=>{t(e.map(b=>b.id===m?{...b,...g}:b))};return{editingHierarchy:r,setEditingHierarchy:s,newHierarchyName:o,setNewHierarchyName:i,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(v=>v.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},x=e.find(v=>v.id===m);x&&c(m,{steps:[...x.steps,y]})},removeStepFromHierarchy:(m,g)=>{const b=e.find(y=>y.id===m);if(b){const y=[...b.steps];y.splice(g,1),c(m,{steps:y})}},updateStep:(m,g,b)=>{const y=e.find(x=>x.id===m);if(y){const x=y.steps.map((v,w)=>w===g?{...v,...b}:v);c(m,{steps:x})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function JPe({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:s,onOpenChange:o,trigger:i}){return u.jsxs(Ds,{open:s,onOpenChange:o,children:[u.jsx(Ms,{asChild:!0,children:i}),u.jsx(Ts,{className:"z-50 w-80",align:"start",children:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),u.jsxs(pt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[u.jsx(dt,{className:"h-8",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[u.jsx(be,{value:"bar",children:"Bar Chart"}),u.jsx(be,{value:"pie",children:"Pie Chart"}),u.jsx(be,{value:"line",children:"Line Chart"}),u.jsx(be,{value:"donut",children:"Donut Chart"}),u.jsx(be,{value:"table",children:"Table"}),u.jsx(be,{value:"metric",children:"Metric"})]})]})]}),u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),u.jsx(bn,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),u.jsx(bn,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),u.jsx("div",{className:"flex items-center gap-4",children:u.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[u.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),u.jsx("div",{className:"flex justify-end",children:u.jsx(ie,{size:"sm",variant:"outline",onClick:()=>o(!1),children:"Done"})})]})})]})}function eOe({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:s,onRemoveStep:o}){const[i,a]=C.useState(!1),{attributes:l,listeners:c,setNodeRef:d,transform:f,transition:h,isDragging:p}=TM({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:Yi.Transform.toString(f),transition:h,opacity:p?.8:1,zIndex:p?1e3:1};return u.jsx("div",{ref:d,style:m,className:`relative ${i?"z-[9998]":""}`,...l,children:u.jsx(JPe,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:s,open:i,onOpenChange:a,trigger:u.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg border bg-muted px-3 py-2 transition-colors hover:bg-muted/50 ${p?"shadow-lg ring-2 ring-primary":""}`,...c,onClick:g=>{g.stopPropagation(),a(b=>!b)},children:[u.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[u.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&u.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&u.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),u.jsx("button",{className:"pointer-events-auto ml-1 text-xs text-muted-foreground hover:text-red-800 dark:hover:text-red-400",onClick:g=>{g.stopPropagation(),o(r,n)},children:u.jsx(Xt,{className:"h-3 w-3"})})]})})})}function tOe(e){return{sensors:NM(tg(bb,{activationConstraint:{distance:5}}),tg(gb,{coordinateGetter:RM})),handleStepDragEnd:(r,s)=>{const{active:o,over:i}=r;if(!i||o.id===i.id)return;const a=o.id.replace(`${s.id}-`,""),l=i.id.replace(`${s.id}-`,""),c=s.steps.findIndex(f=>f.field.id===a),d=s.steps.findIndex(f=>f.field.id===l);if(c!==-1&&d!==-1&&c!==d){const f=xb(s.steps,c,d);e(s.id,{steps:f})}}}}function nOe({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:s}=tOe(r),[o,i]=C.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),d=h=>{const p=h.active.id,m=Number.parseInt(p.split("-").pop()||"0"),g=a[m],b=g==null?void 0:g.field;i(b||null)},f=h=>{i(null);const{active:p,over:m}=h;if(!m||p.id===m.id)return;const g=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(m.id.split("-").pop()||"0");if(g!==b&&g<a.length&&b<a.length){const y=[...e.steps],[x]=y.splice(g,1);y.splice(b,0,x),r(e.id,{steps:y})}};return a.length===0?u.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:u.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):u.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:u.jsxs(DM,{sensors:s,collisionDetection:kM,onDragStart:d,onDragEnd:f,children:[u.jsx(MM,{items:c,strategy:zPe,children:u.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const m=[];p>0&&m.push(u.jsx(La,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const g=p===0,b=p===a.length-1;return m.push(u.jsx(eOe,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:g,isLastField:b},`field-${h.field.id}-${p}`)),m})})}),typeof window<"u"&&_n.createPortal(u.jsx(lY,{className:"semaphor-scope",style:{zIndex:9999},children:o?u.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:u.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:o.label})}):null}),document.body)]})})}var LF=1,rOe=.9,sOe=.8,oOe=.17,qC=.1,YC=.999,iOe=.9999,aOe=.99,lOe=/[\\\/_+.#"@\[\(\{&]/,cOe=/[\\\/_+.#"@\[\(\{&]/g,uOe=/[\s-]/,mY=/[\s-]/g;function Jk(e,t,n,r,s,o,i){if(o===t.length)return s===e.length?LF:aOe;var a=`${s},${o}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(o),c=n.indexOf(l,s),d=0,f,h,p,m;c>=0;)f=Jk(e,t,n,r,c+1,o+1,i),f>d&&(c===s?f*=LF:lOe.test(e.charAt(c-1))?(f*=sOe,p=e.slice(s,c-1).match(cOe),p&&s>0&&(f*=Math.pow(YC,p.length))):uOe.test(e.charAt(c-1))?(f*=rOe,m=e.slice(s,c-1).match(mY),m&&s>0&&(f*=Math.pow(YC,m.length))):(f*=oOe,s>0&&(f*=Math.pow(YC,c-s))),e.charAt(c)!==t.charAt(o)&&(f*=iOe)),(f<qC&&n.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(c-1)!==r.charAt(o))&&(h=Jk(e,t,n,r,c+1,o+2,i),h*qC>f&&(f=h*qC)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function zF(e){return e.toLowerCase().replace(mY," ")}function dOe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Jk(e,t,zF(e),zF(t),0,0,{})}var sp='[cmdk-group=""]',GC='[cmdk-group-items=""]',fOe='[cmdk-group-heading=""]',gY='[cmdk-item=""]',BF=`${gY}:not([aria-disabled="true"])`,eE="cmdk-item-select",Td="data-value",hOe=(e,t,n)=>dOe(e,t,n),bY=E.createContext(void 0),vb=()=>E.useContext(bY),yY=E.createContext(void 0),IM=()=>E.useContext(yY),xY=E.createContext(void 0),vY=E.forwardRef((e,t)=>{let n=Rd(()=>{var L,R;return{search:"",value:(R=(L=e.value)!=null?L:e.defaultValue)!=null?R:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Rd(()=>new Set),s=Rd(()=>new Map),o=Rd(()=>new Map),i=Rd(()=>new Set),a=wY(e),{label:l,children:c,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,x=Gn(),v=Gn(),w=Gn(),S=E.useRef(null),N=NOe();Hu(()=>{if(d!==void 0){let L=d.trim();n.current.value=L,k.emit()}},[d]),Hu(()=>{N(6,O)},[]);let k=E.useMemo(()=>({subscribe:L=>(i.current.add(L),()=>i.current.delete(L)),snapshot:()=>n.current,setState:(L,R,W)=>{var Y,Z,H,$;if(!Object.is(n.current[L],R)){if(n.current[L]=R,L==="search")T(),D(),N(1,M);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(w);q?q.focus():(Y=document.getElementById(x))==null||Y.focus()}if(N(7,()=>{var q;n.current.selectedItemId=(q=A())==null?void 0:q.id,k.emit()}),W||N(5,O),((Z=a.current)==null?void 0:Z.value)!==void 0){let q=R??"";($=(H=a.current).onValueChange)==null||$.call(H,q);return}}k.emit()}},emit:()=>{i.current.forEach(L=>L())}}),[]),j=E.useMemo(()=>({value:(L,R,W)=>{var Y;R!==((Y=o.current.get(L))==null?void 0:Y.value)&&(o.current.set(L,{value:R,keywords:W}),n.current.filtered.items.set(L,_(R,W)),N(2,()=>{D(),k.emit()}))},item:(L,R)=>(r.current.add(L),R&&(s.current.has(R)?s.current.get(R).add(L):s.current.set(R,new Set([L]))),N(3,()=>{T(),D(),n.current.value||M(),k.emit()}),()=>{o.current.delete(L),r.current.delete(L),n.current.filtered.items.delete(L);let W=A();N(4,()=>{T(),(W==null?void 0:W.getAttribute("id"))===L&&M(),k.emit()})}),group:L=>(s.current.has(L)||s.current.set(L,new Set),()=>{o.current.delete(L),s.current.delete(L)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:x,inputId:w,labelId:v,listInnerRef:S}),[]);function _(L,R){var W,Y;let Z=(Y=(W=a.current)==null?void 0:W.filter)!=null?Y:hOe;return L?Z(L,n.current.search,R):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let L=n.current.filtered.items,R=[];n.current.filtered.groups.forEach(Y=>{let Z=s.current.get(Y),H=0;Z.forEach($=>{let q=L.get($);H=Math.max(q,H)}),R.push([Y,H])});let W=S.current;P().sort((Y,Z)=>{var H,$;let q=Y.getAttribute("id"),G=Z.getAttribute("id");return((H=L.get(G))!=null?H:0)-(($=L.get(q))!=null?$:0)}).forEach(Y=>{let Z=Y.closest(GC);Z?Z.appendChild(Y.parentElement===Z?Y:Y.closest(`${GC} > *`)):W.appendChild(Y.parentElement===W?Y:Y.closest(`${GC} > *`))}),R.sort((Y,Z)=>Z[1]-Y[1]).forEach(Y=>{var Z;let H=(Z=S.current)==null?void 0:Z.querySelector(`${sp}[${Td}="${encodeURIComponent(Y[0])}"]`);H==null||H.parentElement.appendChild(H)})}function M(){let L=P().find(W=>W.getAttribute("aria-disabled")!=="true"),R=L==null?void 0:L.getAttribute(Td);k.setState("value",R||void 0)}function T(){var L,R,W,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Z=0;for(let H of r.current){let $=(R=(L=o.current.get(H))==null?void 0:L.value)!=null?R:"",q=(Y=(W=o.current.get(H))==null?void 0:W.keywords)!=null?Y:[],G=_($,q);n.current.filtered.items.set(H,G),G>0&&Z++}for(let[H,$]of s.current)for(let q of $)if(n.current.filtered.items.get(q)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=Z}function O(){var L,R,W;let Y=A();Y&&(((L=Y.parentElement)==null?void 0:L.firstChild)===Y&&((W=(R=Y.closest(sp))==null?void 0:R.querySelector(fOe))==null||W.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function A(){var L;return(L=S.current)==null?void 0:L.querySelector(`${gY}[aria-selected="true"]`)}function P(){var L;return Array.from(((L=S.current)==null?void 0:L.querySelectorAll(BF))||[])}function F(L){let R=P()[L];R&&k.setState("value",R.getAttribute(Td))}function V(L){var R;let W=A(),Y=P(),Z=Y.findIndex($=>$===W),H=Y[Z+L];(R=a.current)!=null&&R.loop&&(H=Z+L<0?Y[Y.length-1]:Z+L===Y.length?Y[0]:Y[Z+L]),H&&k.setState("value",H.getAttribute(Td))}function U(L){let R=A(),W=R==null?void 0:R.closest(sp),Y;for(;W&&!Y;)W=L>0?SOe(W,sp):COe(W,sp),Y=W==null?void 0:W.querySelector(BF);Y?k.setState("value",Y.getAttribute(Td)):V(L)}let z=()=>F(P().length-1),I=L=>{L.preventDefault(),L.metaKey?z():L.altKey?U(1):V(1)},B=L=>{L.preventDefault(),L.metaKey?F(0):L.altKey?U(-1):V(-1)};return E.createElement(Re.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:L=>{var R;(R=y.onKeyDown)==null||R.call(y,L);let W=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||W))switch(L.key){case"n":case"j":{b&&L.ctrlKey&&I(L);break}case"ArrowDown":{I(L);break}case"p":case"k":{b&&L.ctrlKey&&B(L);break}case"ArrowUp":{B(L);break}case"Home":{L.preventDefault(),F(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let Y=A();if(Y){let Z=new Event(eE);Y.dispatchEvent(Z)}}}}},E.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:EOe},l),u1(e,L=>E.createElement(yY.Provider,{value:k},E.createElement(bY.Provider,{value:j},L))))}),pOe=E.forwardRef((e,t)=>{var n,r;let s=Gn(),o=E.useRef(null),i=E.useContext(xY),a=vb(),l=wY(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Hu(()=>{if(!c)return a.item(s,i==null?void 0:i.id)},[c]);let d=SY(s,o,[e.value,e.children,o],e.keywords),f=IM(),h=Yl(N=>N.value&&N.value===d.current),p=Yl(N=>c||a.filter()===!1?!0:N.search?N.filtered.items.get(s)>0:!0);E.useEffect(()=>{let N=o.current;if(!(!N||e.disabled))return N.addEventListener(eE,m),()=>N.removeEventListener(eE,m)},[p,e.onSelect,e.disabled]);function m(){var N,k;g(),(k=(N=l.current).onSelect)==null||k.call(N,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:x,forceMount:v,keywords:w,...S}=e;return E.createElement(Re.div,{ref:us(o,t),...S,id:s,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:g,onClick:b?void 0:m},e.children)}),mOe=E.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...o}=e,i=Gn(),a=E.useRef(null),l=E.useRef(null),c=Gn(),d=vb(),f=Yl(p=>s||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Hu(()=>d.group(i),[]),SY(i,a,[e.value,e.heading,l]);let h=E.useMemo(()=>({id:i,forceMount:s}),[s]);return E.createElement(Re.div,{ref:us(a,t),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&E.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),u1(e,p=>E.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},E.createElement(xY.Provider,{value:h},p))))}),gOe=E.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=E.useRef(null),o=Yl(i=>!i.search);return!n&&!o?null:E.createElement(Re.div,{ref:us(s,t),...r,"cmdk-separator":"",role:"separator"})}),bOe=E.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,o=IM(),i=Yl(c=>c.search),a=Yl(c=>c.selectedItemId),l=vb();return E.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),E.createElement(Re.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?e.value:i,onChange:c=>{s||o.setState("search",c.target.value),n==null||n(c.target.value)}})}),yOe=E.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,o=E.useRef(null),i=E.useRef(null),a=Yl(c=>c.selectedItemId),l=vb();return E.useEffect(()=>{if(i.current&&o.current){let c=i.current,d=o.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(f),h.unobserve(c)}}},[]),E.createElement(Re.div,{ref:us(o,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},u1(e,c=>E.createElement("div",{ref:us(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xOe=E.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:o,container:i,...a}=e;return E.createElement(kL,{open:n,onOpenChange:r},E.createElement(EL,{container:i},E.createElement(gj,{"cmdk-overlay":"",className:s}),E.createElement(bj,{"aria-label":e.label,"cmdk-dialog":"",className:o},E.createElement(vY,{ref:t,...a}))))}),vOe=E.forwardRef((e,t)=>Yl(n=>n.filtered.count===0)?E.createElement(Re.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wOe=E.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...o}=e;return E.createElement(Re.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},u1(e,i=>E.createElement("div",{"aria-hidden":!0},i)))}),Kr=Object.assign(vY,{List:yOe,Item:pOe,Input:bOe,Group:mOe,Separator:gOe,Dialog:xOe,Empty:vOe,Loading:wOe});function SOe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function COe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function wY(e){let t=E.useRef(e);return Hu(()=>{t.current=e}),t}var Hu=typeof window>"u"?E.useEffect:E.useLayoutEffect;function Rd(e){let t=E.useRef();return t.current===void 0&&(t.current=e()),t}function Yl(e){let t=IM(),n=()=>e(t.snapshot());return E.useSyncExternalStore(t.subscribe,n,n)}function SY(e,t,n,r=[]){let s=E.useRef(),o=vb();return Hu(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():s.current}})(),l=r.map(c=>c.trim());o.value(e,a,l),(i=t.current)==null||i.setAttribute(Td,a),s.current=a}),s}var NOe=()=>{let[e,t]=E.useState(),n=Rd(()=>new Map);return Hu(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function kOe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function u1({asChild:e,children:t},n){return e&&E.isValidElement(t)?E.cloneElement(kOe(t),{ref:t.ref},n(t.props.children)):n(t)}var EOe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const d1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr,{ref:n,className:K("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));d1.displayName=Kr.displayName;const AM=E.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ec,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kr.Input,{ref:n,className:K("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));AM.displayName=Kr.Input.displayName;const f1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.List,{ref:n,className:K("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));f1.displayName=Kr.List.displayName;const h1=E.forwardRef((e,t)=>u.jsx(Kr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));h1.displayName=Kr.Empty.displayName;const p1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Group,{ref:n,className:K("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));p1.displayName=Kr.Group.displayName;const jOe=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Separator,{ref:n,className:K("-mx-1 h-px bg-border",e),...t}));jOe.displayName=Kr.Separator.displayName;const m1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Item,{ref:n,className:K("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));m1.displayName=Kr.Item.displayName;function _Oe({hierarchy:e,sampleFieldReferences:t,onUpdateHierarchy:n,onDeleteHierarchy:r,onUpdateStep:s,onRemoveStep:o,onAddStep:i}){const[a,l]=C.useState(!1),{attributes:c,listeners:d,setNodeRef:f,transform:h,transition:p}=TM({id:e.id,disabled:!1}),m={transform:Yi.Transform.toString(h),transition:p},g=e.steps.filter(b=>b.field).map(b=>b.field.id);return u.jsxs("div",{ref:f,style:m,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[u.jsxs("div",{className:"mb-3 flex cursor-move items-center justify-between",...c,...d,children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("div",{onPointerDown:b=>b.stopPropagation(),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),children:u.jsx(Do,{value:e.label||"",onSave:b=>{n(e.id,{label:b})},placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"})})}),u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(ie,{size:"sm",variant:"ghost",onClick:b=>{b.stopPropagation(),r(e.id)},onPointerDown:b=>b.stopPropagation(),children:u.jsx(ah,{className:"h-3 w-3"})})})]}),u.jsx(nOe,{hierarchy:e,onUpdateStep:s,onRemoveStep:o,onUpdateHierarchy:n}),u.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:a?u.jsxs(d1,{className:"rounded-lg border",children:[u.jsx(AM,{placeholder:"Search fields..."}),u.jsxs(f1,{children:[u.jsx(h1,{children:"No field found."}),u.jsx(p1,{children:t.filter(b=>!g.includes(b.id)).map(b=>u.jsx(m1,{value:b.label,onSelect:()=>{i(e.id,b.id),l(!1)},children:b.label},b.id))})]})]}):u.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:b=>{b.preventDefault(),b.stopPropagation(),l(!0)},children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add Step"]})})]})}function DOe({open:e,onOpenChange:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:s}){const[o,i]=C.useState(n);C.useEffect(()=>{e&&i(n)},[e,n]);const a=C.useMemo(()=>s.filter(x=>Jl(x.dataType)==="string"),[s]),l=NM(tg(bb),tg(gb,{coordinateGetter:RM})),{createNewHierarchy:c,deleteHierarchy:d,updateHierarchy:f,addStepToHierarchy:h,removeStepFromHierarchy:p,updateStep:m,setDefaultHierarchy:g}=QPe(o,i,a),b=x=>{const{active:v,over:w}=x;if(v.id!==(w==null?void 0:w.id)){const S=o.findIndex(k=>k.id===v.id),N=o.findIndex(k=>k.id===(w==null?void 0:w.id));i(xb(o,S,N))}},y=x=>{x||r(o),t(x)};return u.jsx(ao,{modal:!0,open:e,onOpenChange:y,children:u.jsx(Is,{className:"flex max-h-[85vh] max-w-3xl flex-col overflow-hidden p-0",onInteractOutside:x=>x.preventDefault(),onEscapeKeyDown:x=>x.preventDefault(),children:u.jsx(hh,{trapped:!1,children:u.jsxs("div",{className:"flex max-h-[85vh] max-w-3xl flex-col overflow-hidden",children:[u.jsxs(As,{className:"border-b px-6 pb-4 pt-6",children:[u.jsx(Ps,{children:"Manage Drill Hierarchies"}),u.jsx(Ao,{children:"Create multiple drill paths for different analysis scenarios. Define step-by-step navigation through your dimensions."})]}),u.jsx(Rs,{className:"flex-1 px-6",children:u.jsxs("div",{className:"space-y-4 py-4",children:[o.length>0&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(ie,{type:"button",size:"sm",onClick:x=>{x.preventDefault(),x.stopPropagation(),c()},children:[u.jsx(gr,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})}),o.length>0?u.jsx(DM,{sensors:l,collisionDetection:kM,onDragEnd:b,children:u.jsx(MM,{items:o.map(x=>x.id),strategy:uY,children:u.jsx("div",{className:"space-y-4",children:o.map(x=>u.jsx(_Oe,{hierarchy:x,sampleFieldReferences:a,onUpdateHierarchy:f,onDeleteHierarchy:d,onSetDefaultHierarchy:g,onUpdateStep:m,onRemoveStep:p,onAddStep:h},x.id))})})}):u.jsxs("div",{className:"rounded-lg border border-dashed p-8 text-center",children:[u.jsx("p",{className:"mb-2 text-sm text-muted-foreground",children:"No hierarchies configured yet"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Create your first hierarchy to enable drill-down interactions"}),u.jsxs(ie,{type:"button",size:"sm",variant:"outline",onClick:x=>{x.preventDefault(),x.stopPropagation(),c()},children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Create First Hierarchy"]})]})]})}),u.jsx("div",{className:"flex justify-end gap-2 border-t px-6 py-4",children:u.jsx(ie,{variant:"outline",onClick:()=>y(!1),children:"Done"})})]})})})})}function CY(e){switch(e){case"day":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"custom",label:"Custom Format..."}];case"week":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"Week of MMM DD, YYYY",label:"Week of Jan 15, 2024"},{value:"Week of MMMM DD, YYYY",label:"Week of January 15, 2024"},{value:"YYYY-WW",label:"2024-W03 (YYYY-WW)"},{value:"custom",label:"Custom Format..."}];case"month":return[{value:"MMM YYYY",label:"Jan 2024 (MMM YYYY)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MM/YYYY",label:"01/2024 (MM/YYYY)"},{value:"YYYY MMM",label:"2024 Jan (YYYY MMM)"},{value:"custom",label:"Custom Format..."}];case"quarter":return[{value:"Q1 YYYY",label:"Q1 2024 (Q1 YYYY)"},{value:"YYYY Q1",label:"2024 Q1 (YYYY Q1)"},{value:"1st Quarter YYYY",label:"1st Quarter 2024"},{value:"YYYY-Q1",label:"2024-Q1 (YYYY-Q1)"},{value:"Quarter 1, YYYY",label:"Quarter 1, 2024"},{value:"custom",label:"Custom Format..."}];case"year":return[{value:"YYYY",label:"2024 (YYYY)"},{value:"YY",label:"24 (YY)"},{value:"custom",label:"Custom Format..."}];default:return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"custom",label:"Custom Format..."}]}}function MOe({interaction:e,onUpdate:t,card:n,availableFields:r,onUpdateHierarchies:s,onManageHierarchies:o}){var M;const[i,a]=C.useState(!1),[l,c]=C.useState(!1),[d,f]=C.useState(null),[h,p]=C.useState(!1),[m,g]=C.useState({}),b=C.useMemo(()=>{var T;return((T=n.interactionConfig)==null?void 0:T.drillHierarchies)||[]},[(M=n.interactionConfig)==null?void 0:M.drillHierarchies]),y=C.useMemo(()=>{var P,F;const T=[],O=e.trigger;if(!O)return T;let A;if(O.type==="attribute"){const V=r.find(z=>z.id===O.field.id);V&&(V.dataType==="date"||V.dataType==="timestamp")&&(A=V)}else if(O.type==="metric"){const V=(F=(P=n.config)==null?void 0:P.groupByColumns)==null?void 0:F.find(U=>U.dataType==="date"||U.dataType==="timestamp");V&&(A=V)}if(A&&$J(A,b)){const V=FJ(A);T.push(V)}return T},[r,b,e.trigger,n.config]),x=C.useMemo(()=>[...b,...y],[b,y]),v=x.find(T=>T.id===e.hierarchyId);E.useEffect(()=>{i&&v&&v.type==="date"?f(v.id):i||f(null)},[i,v]);const w=T=>{if(y.some(A=>A.id===T)&&s){const A=y.find(P=>P.id===T);A&&s([...b,A])}t({...e,hierarchyId:T}),a(!1)},S=()=>{a(!1),c(!0),o&&o()},N=T=>{s&&s(T)},k=T=>T.steps.map(A=>A.field.label||A.field.name).join(" → "),j=T=>T&&T.charAt(0).toUpperCase()+T.slice(1),_=(T,O,A)=>{const P=[...T.steps];P[O]={...P[O],field:{...P[O].field,dateFormat:A,customFormat:A==="custom"?m[O]||"":void 0}};const F={...T,steps:P};if(s){const V=b.findIndex(U=>U.id===T.id);if(V>=0){const U=[...b];U[V]=F,s(U)}else s([...b,F])}},D=(T,O,A)=>{g(V=>({...V,[O]:A}));const P=[...T.steps];P[O]={...P[O],field:{...P[O].field,dateFormat:"custom",customFormat:A}};const F={...T,steps:P};if(s){const V=b.findIndex(U=>U.id===T.id);if(V>=0){const U=[...b];U[V]=F,s(U)}else s([...b,F])}};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Choose hierarchy"}),u.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"Select which hierarchy to drill through when this interaction triggers"}),x.length>0?u.jsxs(u.Fragment,{children:[u.jsxs(Ds,{open:i,onOpenChange:a,children:[u.jsx(Ms,{asChild:!0,children:u.jsxs(ie,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[u.jsx("div",{className:"flex flex-1 flex-col items-start text-left",children:v?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"font-medium",children:v.label||"Unnamed Hierarchy"})}),u.jsx("span",{className:"text-xs text-muted-foreground",children:k(v)})]}):u.jsx("span",{className:"text-muted-foreground",children:"Select hierarchy..."})}),u.jsxs("div",{className:"flex items-center gap-2",children:[v&&v.type==="date"&&u.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:T=>{T.stopPropagation(),p(!h)},children:u.jsx(ih,{className:"h-3 w-3"})}),u.jsx(La,{className:"h-4 w-4 shrink-0 opacity-50"})]})]})}),u.jsxs(Ts,{className:"w-[500px] p-0",align:"start",children:[u.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[u.jsx("span",{className:"text-sm font-medium",children:"Select Hierarchy"}),u.jsxs(ie,{variant:"ghost",size:"sm",onClick:S,children:[u.jsx(gr,{className:"mr-1.5 h-3.5 w-3.5"}),"Create new"]})]}),u.jsxs("div",{className:"p-2",children:[y.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"px-3 py-2",children:u.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"AUTO-GENERATED"})}),y.map(T=>u.jsx("div",{className:`cursor-pointer rounded-md p-3 hover:bg-muted ${e.hierarchyId===T.id?"bg-muted":""}`,onClick:()=>w(T.id),children:u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"text-sm font-medium",children:T.label||"Unnamed Hierarchy"})}),u.jsx("div",{className:"text-xs text-muted-foreground",children:k(T)})]})},T.id))]}),b.length>0&&u.jsxs(u.Fragment,{children:[y.length>0&&u.jsx("div",{className:"my-2 border-t"}),b.map(T=>u.jsx("div",{className:`cursor-pointer rounded-md p-3 hover:bg-muted ${e.hierarchyId===T.id?"bg-muted":""}`,onClick:()=>w(T.id),children:u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"text-sm font-medium",children:T.label||"Unnamed Hierarchy"})}),u.jsx("div",{className:"text-xs text-muted-foreground",children:k(T)})]})},T.id))]})]})]})]}),v&&v.type==="date"&&h&&u.jsxs("div",{className:"mt-3 space-y-3 rounded-md border border-border p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Customize Date Formats"}),u.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>p(!1),children:"Close"})]}),v.steps.map((T,O)=>{var V;const A=T.field.granularity;if(!A)return null;const P=CY(A),F=T.field.dateFormat||((V=P[0])==null?void 0:V.value);return u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-xs font-medium text-muted-foreground",children:T.field.label||j(A)}),u.jsxs(pt,{value:F,onValueChange:U=>{_(v,O,U)},children:[u.jsx(dt,{className:"h-8 text-xs",children:u.jsx(bt,{})}),u.jsx(ft,{children:P.map(U=>u.jsx(be,{value:U.value,className:"text-xs",children:U.label},U.value))})]}),F==="custom"&&u.jsxs("div",{className:"mt-2 space-y-1",children:[u.jsx(bn,{placeholder:"Enter custom format (e.g., YYYY-MM-DD)",value:T.field.customFormat||m[O]||"",onChange:U=>{D(v,O,U.target.value)},className:"h-8 text-xs"}),u.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Common tokens: YYYY (year), MM (month), DD (day), HH (hour), mm (minute)"})]})]},O)})]})]}):u.jsxs("div",{className:"rounded-md border border-dashed p-6 text-center",children:[u.jsx("p",{className:"mb-2 text-sm text-muted-foreground",children:"No hierarchies configured"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Create a hierarchy to define your drill path"}),u.jsxs(ie,{variant:"outline",size:"sm",onClick:S,children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Create hierarchy"]})]})]}),u.jsx(DOe,{open:l,onOpenChange:c,drillHierarchies:b,onUpdateHierarchies:N,availableFields:r})]})}function TOe({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:s=""}){const[o,i]=C.useState(""),a=e.filter(d=>d.label.toLowerCase().includes(o.toLowerCase())||d.qualifiedEntityName&&d.qualifiedEntityName.toLowerCase().includes(o.toLowerCase())),l=()=>{const d=[...new Set([...t,...a.map(f=>f.id)])];n(d)},c=()=>{const d=a.map(f=>f.id);n(t.filter(f=>!d.includes(f)))};return u.jsxs("div",{className:`space-y-2 ${s}`,children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx(bn,{placeholder:r,value:o,onChange:d=>i(d.target.value),className:"flex-1"}),u.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),u.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[u.jsx(ie,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),u.jsx(ie,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),u.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),u.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(d=>u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded p-2 text-xs hover:bg-muted/50",children:[u.jsx(gn,{checked:t.includes(d.id),onCheckedChange:f=>{n(f?[...t,d.id]:t.filter(h=>h!==d.id))}}),u.jsx("span",{className:"font-medium",children:d.label})]},d.id))}),o&&a.length===0&&u.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',o,'"']})]})}const ROe=e=>["string","boolean"].includes(Jl(e.dataType));function IOe({interaction:e,availableFields:t,onUpdate:n}){var i;const r=t.filter(ROe),s=((i=e.availableFields)==null?void 0:i.map(a=>a.id))||[],o=a=>{const l=r.filter(c=>a.includes(c.id));n({...e,availableFields:l})};return u.jsx("div",{className:"space-y-4",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{children:"Available dimensions"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically"}),u.jsx(TOe,{fields:r,selectedFieldIds:s,onSelectionChange:o,searchPlaceholder:"Search fields..."}),s.length===0&&u.jsx("p",{className:"text-xs text-amber-600",children:"⚠️ Please select at least one field"})]})})}function AOe({value:e,onChange:t}){const[n,r]=C.useState(!1),[s,o]=C.useState(""),[i,a]=C.useState("all"),{currentUser:l}=Io(),{data:c,isLoading:d}=uj(Wt.DASHBOARD,s),f=(c==null?void 0:c.dashboards)||[],h=f.filter(g=>i==="me"?g.ownership.createdBy.userId===(l==null?void 0:l.id):!0),p=f.find(g=>g.id===e),m=g=>{t(g.id,g.title),r(!1),o("")};return u.jsxs(Ds,{open:n,onOpenChange:r,children:[u.jsx(Ms,{asChild:!0,children:u.jsx(ie,{variant:"outline",className:K("w-full justify-start text-left font-normal",!e&&"text-muted-foreground"),children:p?u.jsx("span",{className:"truncate",children:p.title}):"Choose dashboard..."})}),u.jsx(Ts,{className:"w-[500px] p-0",align:"start",children:u.jsxs(lo,{value:i,onValueChange:g=>a(g),children:[u.jsx("div",{className:"p-3 border-b",children:u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{placeholder:"Search all dashboards...",value:s,onChange:g=>o(g.target.value),className:"pl-9"})]})}),u.jsxs(Os,{className:"w-full justify-start rounded-none border-b bg-transparent p-0",children:[u.jsx(mn,{value:"me",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"created by me"}),u.jsx(mn,{value:"all",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"all"})]}),u.jsx(lr,{value:i,className:"mt-0",children:u.jsx(Rs,{className:"h-[300px]",children:d?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"Loading dashboards..."}):h.length===0?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:s?`No dashboards found matching "${s}"`:i==="me"?"No dashboards created by you":"No dashboards available"}):u.jsx("div",{className:"p-2",children:h.map(g=>u.jsxs("button",{onClick:()=>m(g),className:K("w-full flex items-start gap-3 p-3 rounded-md hover:bg-muted/50 transition-colors text-left",e===g.id&&"bg-muted"),children:[u.jsx(M$,{className:"h-5 w-5 mt-0.5 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium text-sm truncate",children:g.title}),u.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:POe(g.createdAt)})]})]},g.id))})})})]})})]})}function POe(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()){const i=t.getHours(),a=t.getMinutes(),l=i>=12?"PM":"AM",c=i%12||12,d=a.toString().padStart(2,"0");return`TODAY AT ${c}:${d} ${l}`}const s=t.toLocaleString("en-US",{month:"short"}).toUpperCase(),o=t.getDate();return`${s} ${o}`}function OOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Target dashboard"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select which dashboard to navigate to when this interaction triggers"}),u.jsx(AOe,{value:e.targetDashboardId,onChange:(n,r)=>{const s={...e,targetDashboardId:n};!e.label&&r&&(s.label=r),t(s)}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Propagate Filters"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose what filters to pass to the target dashboard"}),u.jsxs(pt,{value:e.contextMode||"full",onValueChange:n=>t({...e,contextMode:n}),children:[u.jsx(dt,{children:u.jsxs(bt,{placeholder:"Choose context mode...",children:[e.contextMode==="interactionFilters"&&"Interaction Filters",(e.contextMode==="full"||!e.contextMode)&&"All Filters",e.contextMode==="none"&&"None"]})}),u.jsxs(ft,{children:[u.jsx(be,{value:"interactionFilters",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Interaction Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass only the clicked element as a filter"})]})}),u.jsx(be,{value:"full",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"All Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass current dashboard filters + clicked element"})]})}),u.jsx(be,{value:"none",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"None"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Navigate without passing any filters"})]})})]})]})]}),!e.targetDashboardId&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please select a target dashboard to complete this configuration"})}),e.targetDashboardId&&u.jsx("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:u.jsx("p",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Dashboard drill-through configured successfully"})}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function FOe({value:e,onChange:t}){const[n,r]=C.useState(!1),[s,o]=C.useState(""),[i,a]=C.useState("all"),{currentUser:l}=Io(),{data:c,isLoading:d}=uj(Wt.VISUAL,s),f=(c==null?void 0:c.visuals)||[],h=f.filter(g=>i==="me"?g.ownership.createdBy.userId===(l==null?void 0:l.id):!0),p=f.find(g=>g.id===e),m=g=>{t(g.id,g.title),r(!1),o("")};return u.jsxs(Ds,{open:n,onOpenChange:r,children:[u.jsx(Ms,{asChild:!0,children:u.jsx(ie,{variant:"outline",className:K("w-full justify-start text-left font-normal",!e&&"text-muted-foreground"),children:p?u.jsx("span",{className:"truncate",children:p.title}):"Choose insight..."})}),u.jsx(Ts,{className:"w-[500px] p-0",align:"start",children:u.jsxs(lo,{value:i,onValueChange:g=>a(g),children:[u.jsx("div",{className:"p-3 border-b",children:u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{placeholder:"Search all insights...",value:s,onChange:g=>o(g.target.value),className:"pl-9"})]})}),u.jsxs(Os,{className:"w-full justify-start rounded-none border-b bg-transparent p-0",children:[u.jsx(mn,{value:"me",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"created by me"}),u.jsx(mn,{value:"all",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"all"})]}),u.jsx(lr,{value:i,className:"mt-0",children:u.jsx(Rs,{className:"h-[300px]",children:d?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"Loading insights..."}):h.length===0?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:s?`No insights found matching "${s}"`:i==="me"?"No insights created by you":"No insights available"}):u.jsx("div",{className:"p-2",children:h.map(g=>u.jsxs("button",{onClick:()=>m(g),className:K("w-full flex items-start gap-3 p-3 rounded-md hover:bg-muted/50 transition-colors text-left",e===g.id&&"bg-muted"),children:[u.jsx(jg,{className:"h-5 w-5 mt-0.5 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium text-sm truncate",children:g.title}),u.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:$Oe(g.createdAt)})]})]},g.id))})})})]})})]})}function $Oe(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()){const i=t.getHours(),a=t.getMinutes(),l=i>=12?"PM":"AM",c=i%12||12,d=a.toString().padStart(2,"0");return`TODAY AT ${c}:${d} ${l}`}const s=t.toLocaleString("en-US",{month:"short"}).toUpperCase(),o=t.getDate();return`${s} ${o}`}function LOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Target insight"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select the saved insight to navigate to"}),u.jsx(FOe,{value:e.targetInsightId,onChange:(n,r)=>{const s={...e,targetInsightId:n};!e.label&&r&&(s.label=r),t(s)}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Propagate Filters"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose what filters to pass to the insight"}),u.jsxs(pt,{value:e.contextMode||"full",onValueChange:n=>t({...e,contextMode:n}),children:[u.jsx(dt,{children:u.jsxs(bt,{placeholder:"Choose context mode...",children:[e.contextMode==="interactionFilters"&&"Interaction Filters",(e.contextMode==="full"||!e.contextMode)&&"All Filters",e.contextMode==="none"&&"None"]})}),u.jsxs(ft,{children:[u.jsx(be,{value:"interactionFilters",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Interaction Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass only the clicked element as a filter"})]})}),u.jsx(be,{value:"full",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"All Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass all current filters and selections"})]})}),u.jsx(be,{value:"none",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"None"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Open insight without any filters"})]})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Display mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose how the insight should be displayed"}),u.jsxs(pt,{value:e.displayMode||"modal",onValueChange:n=>t({...e,displayMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose display mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"modal",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Open in modal"})})}),u.jsx(be,{value:"replace-card",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Replace the card"})})})]})]})]}),!e.targetInsightId&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please enter a target insight ID to complete this configuration"})}),e.targetInsightId&&u.jsx("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:u.jsx("p",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Insight drill-through configured successfully"})}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var PM="Switch",[zOe,yGe]=yr(PM),[BOe,VOe]=zOe(PM),NY=E.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:o,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=E.useState(null),m=at(t,v=>p(v)),g=E.useRef(!1),b=h?d||!!h.closest("form"):!0,[y=!1,x]=Mr({prop:s,defaultProp:o,onChange:c});return u.jsxs(BOe,{scope:n,checked:y,disabled:a,children:[u.jsx(Re.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":jY(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:we(e.onClick,v=>{x(w=>!w),b&&(g.current=v.isPropagationStopped(),g.current||v.stopPropagation())})}),b&&u.jsx(HOe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});NY.displayName=PM;var kY="SwitchThumb",EY=E.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,s=VOe(kY,n);return u.jsx(Re.span,{"data-state":jY(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:t})});EY.displayName=kY;var HOe=e=>{const{control:t,checked:n,bubbles:r=!0,...s}=e,o=E.useRef(null),i=nw(n),a=rw(t);return E.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function jY(e){return e?"checked":"unchecked"}var g1=NY,_Y=EY;const th=E.forwardRef(({className:e,...t},n)=>u.jsx(g1,{className:K("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(_Y,{className:K("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));th.displayName=g1.displayName;function UOe({interaction:e,availableFields:t=[],onUpdate:n}){const[r,s]=C.useState(null),o=l=>{const c=e.urlTemplate||"",d=`{{${l}}}`;if(r!==null){const f=c.slice(0,r),h=c.slice(r);n({...e,urlTemplate:f+d+h})}else n({...e,urlTemplate:c+d})},a=((e.urlTemplate||"").match(/\{\{([^}]+)\}\}/g)||[]).map(d=>d.replace(/[{}]/g,""));return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"URL template"}),u.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:["Enter the URL with ","{{field_name}}"," for parameters"]}),u.jsx(bn,{placeholder:"https://example.com/product/{{product_id}}",value:e.urlTemplate||"",onChange:l=>{n({...e,urlTemplate:l.target.value}),s(l.target.selectionStart)},onSelect:l=>{const c=l.target;s(c.selectionStart)}}),u.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 p-3 flex gap-2",children:[u.jsx(Bi,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:[u.jsx("div",{className:"font-medium mb-1",children:"Template syntax:"}),u.jsxs("div",{children:["Use ","{{field_name}}"," to insert field values"]}),u.jsxs("div",{className:"mt-1 text-blue-600 dark:text-blue-300",children:["Example: https://example.com?id=","{{product_id}}","&region=","{{region}}"]})]})]})]}),t.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Insert parameter"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select a field to insert into the URL template"}),u.jsx("div",{className:"flex gap-2",children:u.jsxs(pt,{onValueChange:o,children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose field..."})}),u.jsx(ft,{children:t.map(l=>u.jsx(be,{value:l.id,children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:l.role==="metric"?"123":"ABC"}),u.jsx("span",{children:l.label})]})},l.id))})]})}),a.length>0&&u.jsxs("div",{className:"mt-2",children:[u.jsx("div",{className:"text-xs font-medium mb-1",children:"Parameters in use:"}),u.jsx("div",{className:"flex flex-wrap gap-1",children:a.map((l,c)=>u.jsx("span",{className:"inline-flex items-center rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary",children:`{{${l}}}`},c))})]})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsxs(ae,{className:"text-sm font-medium flex items-center gap-2",children:["Open in new tab",u.jsx(ej,{className:"h-3 w-3"})]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Open the URL in a new browser tab"})]}),u.jsx(th,{checked:e.openInNewTab??!0,onCheckedChange:l=>n({...e,openInNewTab:l})})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"URL encode parameters"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically encode special characters in parameter values"})]}),u.jsx(th,{checked:e.encodeParameters??!0,onCheckedChange:l=>n({...e,encodeParameters:l})})]}),!e.urlTemplate&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please enter a URL template to complete this configuration"})}),e.urlTemplate&&u.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:[u.jsx("div",{className:"flex items-start gap-2",children:u.jsx("span",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ URL drill-through configured successfully"})}),a.length>0&&u.jsxs("div",{className:"mt-2 text-xs text-green-700 dark:text-green-300",children:["Using ",a.length," parameter",a.length!==1?"s":"",":"," ",a.join(", ")]})]}),e.urlTemplate&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Preview"}),u.jsx("div",{className:"rounded-md bg-muted p-3",children:u.jsx("div",{className:"text-xs font-mono break-all",children:e.urlTemplate})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:l=>n({...e,label:l.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function WOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Fetch mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose when to load the detailed data"}),u.jsxs(pt,{value:e.fetchMode||"lazy",onValueChange:n=>t({...e,fetchMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose fetch mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"lazy",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Lazy loading"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Fetch data only when user clicks"})]})}),u.jsx(be,{value:"preloaded",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Preloaded"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Fetch all data when dashboard loads"})]})})]})]}),u.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 p-3 flex gap-2",children:[u.jsx(Bi,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsx("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:e.fetchMode==="lazy"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium",children:"Lazy loading"}),u.jsx("div",{className:"mt-1",children:"Data is fetched on-demand when the user clicks. Best for large datasets or when detailed data isn't always needed."})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium",children:"Preloaded"}),u.jsx("div",{className:"mt-1",children:"Data is fetched when the dashboard loads. Best for small datasets or when instant drill-down is required."})]})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Record limit"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Maximum number of detailed records to show (0 for unlimited)"}),u.jsx(bn,{type:"number",min:"0",placeholder:"100",value:e.inlineLimit??100,onChange:n=>{const r=parseInt(n.target.value)||0;t({...e,inlineLimit:r})}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Display mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"How to display the detailed records"}),u.jsxs(pt,{value:e.displayMode||"table",onValueChange:n=>t({...e,displayMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose display mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"table",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Table view"})})}),u.jsx(be,{value:"list",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"List view"})})}),u.jsx(be,{value:"cards",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Card view"})})})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Show in modal"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display detailed records in a modal overlay"})]}),u.jsx(th,{checked:e.showInModal??!1,onCheckedChange:n=>t({...e,showInModal:n})})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Allow export"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable users to export the detailed records"})]}),u.jsx(th,{checked:e.allowExport??!0,onCheckedChange:n=>t({...e,allowExport:n})})]}),u.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:[u.jsx("div",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Inline drill configured successfully"}),u.jsxs("div",{className:"mt-2 space-y-1 text-xs text-green-700 dark:text-green-300",children:[u.jsxs("div",{children:["Mode: ",e.fetchMode==="lazy"?"Lazy loading":"Preloaded"]}),u.jsxs("div",{children:["Limit: ",e.inlineLimit===0?"Unlimited":`${e.inlineLimit} records`]}),u.jsxs("div",{children:["Display: ",e.displayMode==="table"?"Table view":e.displayMode==="list"?"List view":"Card view"]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function qOe({interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i,onRemove:a}){const l=e.trigger!==void 0,c=e.mode!==void 0,d=l&&c,[f,h]=C.useState(!d),p=()=>{var y;if(!l)return"Configure interaction";const g=`When ${((y=e.trigger)==null?void 0:y.field.label)||"..."}`;if(!c)return`${g} → Choose action`;const b=e.label||ad(e.mode);return`${g} → ${b}`},m=c?q0(e.mode):null;return u.jsxs(ei,{className:"relative p-0",children:[u.jsx(ie,{variant:"ghost",size:"sm",className:"absolute right-2 top-2 z-10 h-8 w-8 p-0",onClick:a,"aria-label":"Remove interaction",children:u.jsx(Xt,{className:"h-3 w-3"})}),u.jsxs(zu,{open:f,onOpenChange:h,children:[u.jsx(Bu,{asChild:!0,children:u.jsxs(ie,{variant:"ghost",className:"h-auto w-full justify-between p-4 pr-12 hover:bg-muted/50",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[m&&u.jsx(m,{className:"h-4 w-4 flex-shrink-0"}),u.jsx("span",{className:"text-left text-sm font-medium",children:p()})]}),f?u.jsx(rj,{className:"h-3 w-3 flex-shrink-0"}):u.jsx(Tv,{className:"h-3 w-3 flex-shrink-0"})]})}),u.jsx(Vu,{children:u.jsxs("div",{className:"space-y-6 border-t p-6",children:[u.jsx("div",{className:"space-y-3",children:l?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"text-base font-medium",children:["When I click on"," ",u.jsx("span",{className:"text-muted-foreground",children:"(value of)"})]}),e.trigger&&u.jsxs("div",{className:"inline-flex cursor-pointer items-center gap-2 rounded-md border bg-background px-3 py-2 hover:bg-muted/50",onClick:()=>{i({...e,trigger:void 0})},children:[Y0(e.trigger.field.dataType),u.jsx("span",{className:"text-sm font-medium",children:e.trigger.field.label})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-sm font-medium",children:"When I click on"}),u.jsx(nAe,{value:e.trigger,onChange:g=>{i({...e,trigger:g})},metrics:t,attributes:n})]})}),l&&u.jsx(u.Fragment,{children:u.jsxs("div",{className:"space-y-3",children:[u.jsx("div",{className:"text-sm font-medium",children:"I want to"}),u.jsx(rAe,{value:e.mode,onChange:g=>{if(!e.trigger){console.error("Trigger must be defined before selecting action");return}const b={mode:g,trigger:e.trigger};switch(g){case"clickFilter":i({...b,mode:"clickFilter",filterFields:[]});break;case"drillDown":i({...b,mode:"drillDown",filterFields:[]});break;case"dynamicDrill":i({...b,mode:"dynamicDrill",availableFields:[]});break;case"drillThrough":i({...b,mode:"drillThrough",filterFields:[],targetDashboardId:""});break;case"drillToDetail":i({...b,mode:"drillToDetail",filterFields:[]});break;case"drillToURL":i({...b,mode:"drillToURL",filterFields:[],urlTemplate:""});break;case"inlineDrill":i({...b,mode:"inlineDrill",filterFields:[]});break}}})]})}),l&&c&&u.jsxs(u.Fragment,{children:[u.jsx(ri,{}),u.jsx(YOe,{interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i})]})]})})]})]})}function YOe({interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i}){switch(e.mode){case"clickFilter":return u.jsx(sAe,{interaction:e,onUpdate:a=>i(a)});case"drillDown":return u.jsx(MOe,{interaction:e,onUpdate:a=>i(a),card:s,availableFields:r,onUpdateHierarchies:o});case"dynamicDrill":return u.jsx(IOe,{interaction:e,onUpdate:a=>i(a),availableFields:r});case"drillThrough":return u.jsx(OOe,{interaction:e,onUpdate:a=>i(a)});case"drillToDetail":return u.jsx(LOe,{interaction:e,onUpdate:a=>i(a)});case"drillToURL":return u.jsx(UOe,{interaction:e,availableFields:[...t,...n],onUpdate:a=>i(a)});case"inlineDrill":return u.jsx(WOe,{interaction:e,onUpdate:a=>i(a)});default:return u.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown interaction type"})}}function GOe({interactions:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onChange:i}){const[a,l]=C.useState(null),c=()=>{const h={};i([...e,h]),l(e.length)},d=(h,p)=>{const m=[...e];m[h]=p,i(m)},f=h=>{const p=e.filter((m,g)=>g!==h);i(p),a===h&&l(null)};return u.jsxs("div",{className:"space-y-4",children:[e.length>0?u.jsx("div",{className:"space-y-3",children:e.map((h,p)=>u.jsx(qOe,{interaction:h,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:m=>d(p,m),onRemove:()=>f(p)},p))}):u.jsx("div",{className:"border rounded-lg p-8 text-center bg-muted/30",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"No interactions configured"}),u.jsx("div",{className:"text-xs text-muted-foreground",children:'Click "Add Interaction" to create your first interaction'}),u.jsx("div",{className:"pt-2",children:u.jsxs(ie,{onClick:c,size:"sm",variant:"outline",children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add First Interaction"]})})]})}),e.length>0&&u.jsx("div",{className:"flex justify-start pt-2",children:u.jsxs(ie,{onClick:c,size:"sm",variant:"outline",children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add Interaction"]})})]})}function ZOe(){var F,V,U;const{open:e,frameId:t,cardId:n,closePopover:r,anchorPosition:s}=Xj(),o=hse(),i=pse(),{updateCurrentDashboardCard:a}=Qt(),{setCard:l}=Gr(),c=te(z=>z.dashboard),d=((F=c==null?void 0:c.sheets)==null?void 0:F.flatMap(z=>z.frames||[]).find(z=>(z==null?void 0:z.id)===t))||null,f=d&&n?d.cards.find(z=>z.id===n):null;C.useEffect(()=>{e&&f&&l(f)},[e,f,l]);const{columns:h}=$L(),{metricFields:p,groupByFields:m,pivotByFields:g}=j3();[...m,...g];const b=h,y=p,x=[...m,...g],v=((V=o.interactionConfig)==null?void 0:V.drillHierarchies)||[],w=((U=o.interactionConfig)==null?void 0:U.allowedDrillTargets)||[],[S,N]=C.useState(v),[k,j]=C.useState(w||[]),[_,D]=C.useState(null),[M,T]=C.useState(()=>_i(o.interactionConfig));C.useRef(null),C.useEffect(()=>{var z,I;e&&(N(((z=o.interactionConfig)==null?void 0:z.drillHierarchies)||[]),j(((I=o.interactionConfig)==null?void 0:I.allowedDrillTargets)||[]),D(null),T(_i(o.interactionConfig)))},[e,o.interactionConfig]);const O=()=>{i.updateDrillHierarchies(S),i.updateAllowedDrillTargets(k);const z={...o,interactionConfig:{...o.interactionConfig,drillHierarchies:S,allowedDrillTargets:k,interactions:M}};a(z),l(z),r()},A=()=>{D(null),r()};if(!e||!t||!n||!f||!s)return null;const P={position:"fixed",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`};return u.jsxs(Ds,{modal:!0,open:e,onOpenChange:z=>!z&&r(),children:[u.jsx(Ms,{asChild:!0,children:u.jsx("div",{style:P,className:"pointer-events-none invisible","aria-hidden":"true"})}),u.jsxs(Ts,{onEscapeKeyDown:z=>z.preventDefault(),className:"mt-5 flex max-h-[70vh] w-[600px] max-w-4xl flex-col overflow-hidden p-0",align:"start",side:"right",sideOffset:20,children:[u.jsx(lke,{className:"fill-border",width:12,height:8}),u.jsxs("div",{className:"flex flex-col border-b px-6 py-4",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h2",{className:"text-lg font-semibold",children:"Configure Interactions"}),M.length>0&&u.jsx(jt,{variant:"default",className:"h-5 min-w-5 rounded-full px-1.5 text-xs",children:M.length})]}),u.jsxs("p",{className:"text-sm text-muted-foreground",children:["Set up drill behaviors for"," ",(f==null?void 0:f.title)||(o==null?void 0:o.title)||"this chart"]})]}),u.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:u.jsx("div",{className:"space-y-6 p-6",children:u.jsx("div",{children:u.jsx("div",{className:"grid grid-cols-1 gap-4",children:u.jsx(GOe,{interactions:M,metrics:y,attributes:x,availableFields:b,card:{...o,interactionConfig:{...o.interactionConfig,drillHierarchies:S}},onUpdateHierarchies:N,onChange:T})})})})}),u.jsxs("div",{className:"flex justify-end gap-2 border-t px-6 py-4",children:[u.jsx(ie,{variant:"outline",onClick:A,children:"Cancel"}),u.jsx(ie,{onClick:O,children:"Save Changes"})]})]})]})}const KOe=hI.WidthProvider(hI.Responsive);function XOe(){const{open:e}=Xj();return e?u.jsx(ZOe,{}):null}function QOe({sheet:e}){var y,x;const t=te(v=>v.isDashboardEditing),n=te(v=>v.currentBreakpoint),r=te(v=>v.themeStyle),s=te(v=>v.selectedSheetId),o=e.layouts,i=te(v=>v.dashboard.filters),a=e.frames,{setSheetLayouts:l,setCurrentBreakpoint:c}=te(v=>v.actions);C.useEffect(()=>{document.documentElement.style.setProperty("--placeholder-border-radius",`${r==null?void 0:r.cardBorderRadius}px`)},[r==null?void 0:r.cardBorderRadius]);function d(v){c(v)}function f(v,w){s===e.id&&l(s,w)}if(!s)return null;const h=(v,w)=>u.jsx(DY,{className:"after:content-none",ref:w,handleAxis:v}),p=v=>v&&(v==null?void 0:v.h)===1&&(v==null?void 0:v.w)===1?{...v,h:8,minH:7,w:7}:null;function m(){var w;const v=(w=Pg(i,s))==null?void 0:w.filter(S=>!S.hide);return v==null?void 0:v.map(S=>{var j;const N=(j=o==null?void 0:o[n])==null?void 0:j.find(_=>_.i===S.id);if(S.location==="frame")return null;const k=p(N);return u.jsxs("div",{style:{borderRadius:r==null?void 0:r.cardBorderRadius},className:K("z-50 flex flex-col rounded-md border bg-background px-3 py-2"),...k?{"data-grid":k}:{},children:[u.jsx(Iq,{filter:S}),u.jsx(hM,{filter:S})]},S.id)})}function g(){return a==null?void 0:a.map(v=>u.jsx("div",{role:"dashboard-frame-container",className:K("group isolate overflow-hidden",r==null?void 0:r.dashboardCardContainer),children:u.jsx(uc,{FallbackComponent:({error:w,resetErrorBoundary:S})=>u.jsx(DNe,{error:w,resetErrorBoundary:S,frame:v}),children:u.jsx(qIe,{frame:v})})},v.id))}const b=((y=r==null?void 0:r.gridLayout)==null?void 0:y.margin)||[10,10];return!a||a.length===0?u.jsx(tAe,{sheetId:e.id}):u.jsxs(lle,{children:[u.jsxs(KOe,{margin:b,isDraggable:t,resizeHandles:t?["sw","nw","ne","se","e","w"]:[],className:K((x=r==null?void 0:r.gridLayout)==null?void 0:x.className),layouts:o,cols:{lg:48,md:36,sm:24,xs:12,xxs:6},rowHeight:1,onBreakpointChange:d,onLayoutChange:f,resizeHandle:h,children:[m(),g()]}),u.jsx(XOe,{})]})}const DY=C.forwardRef(({className:e,handleAxis:t,...n},r)=>{const s=te(i=>i.themeStyle),o=(s==null?void 0:s.cardBorderRadius)||0;return u.jsx("div",{ref:r,className:K(`react-resizable-handle z-10 react-resizable-handle-${t} absolute border-foreground/40`,{"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-r-0":t==="nw"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-l-0":t==="ne"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-r-0 group-hover:border-t-0":t==="sw"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-l-0 group-hover:border-t-0":t==="se"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-l-0 group-hover:border-t-0":t==="e","border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-r-0 group-hover:border-t-0":t==="w"},e),...n})});DY.displayName="ResizeHandle";const{createElement:nh,createContext:JOe,forwardRef:MY,useCallback:bs,useContext:TY,useEffect:vu,useImperativeHandle:RY,useLayoutEffect:eFe,useMemo:tFe,useRef:Cs,useState:df}=E,VF=E[`useId${Math.random()}`.slice(0,5)],nFe=eFe,b1=JOe(null);b1.displayName="PanelGroupContext";const wu=nFe,rFe=typeof VF=="function"?VF:()=>null;let sFe=0;function OM(e=null){const t=rFe(),n=Cs(e||t||null);return n.current===null&&(n.current=""+sFe++),e??n.current}function IY({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:o,id:i,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:h,style:p,tagName:m="div",...g}){const b=TY(b1);if(b===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:x,getPanelSize:v,getPanelStyle:w,groupId:S,isPanelCollapsed:N,reevaluatePanelConstraints:k,registerPanel:j,resizePanel:_,unregisterPanel:D}=b,M=OM(i),T=Cs({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:a,minSize:l},id:M,idIsFromProps:i!==void 0,order:h});Cs({didLogMissingDefaultSizeWarning:!1}),wu(()=>{const{callbacks:A,constraints:P}=T.current,F={...P};T.current.id=M,T.current.idIsFromProps=i!==void 0,T.current.order=h,A.onCollapse=c,A.onExpand=d,A.onResize=f,P.collapsedSize=n,P.collapsible=r,P.defaultSize=s,P.maxSize=a,P.minSize=l,(F.collapsedSize!==P.collapsedSize||F.collapsible!==P.collapsible||F.maxSize!==P.maxSize||F.minSize!==P.minSize)&&k(T.current,F)}),wu(()=>{const A=T.current;return j(A),()=>{D(A)}},[h,M,j,D]),RY(o,()=>({collapse:()=>{y(T.current)},expand:A=>{x(T.current,A)},getId(){return M},getSize(){return v(T.current)},isCollapsed(){return N(T.current)},isExpanded(){return!N(T.current)},resize:A=>{_(T.current,A)}}),[y,x,v,N,M,_]);const O=w(T.current,s);return nh(m,{...g,children:e,className:t,id:i,style:{...O,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":S,"data-panel-id":M,"data-panel-size":parseFloat(""+O.flexGrow).toFixed(1)})}const AY=MY((e,t)=>nh(IY,{...e,forwardedRef:t}));IY.displayName="Panel";AY.displayName="forwardRef(Panel)";let tE=null,qc=null;function oFe(e,t){if(t){const n=(t&LY)!==0,r=(t&zY)!==0,s=(t&BY)!==0,o=(t&VY)!==0;if(n)return s?"se-resize":o?"ne-resize":"e-resize";if(r)return s?"sw-resize":o?"nw-resize":"w-resize";if(s)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function iFe(){qc!==null&&(document.head.removeChild(qc),tE=null,qc=null)}function ZC(e,t){const n=oFe(e,t);tE!==n&&(tE=n,qc===null&&(qc=document.createElement("style"),document.head.appendChild(qc)),qc.innerHTML=`*{cursor: ${n}!important;}`)}function PY(e){return e.type==="keydown"}function OY(e){return e.type.startsWith("pointer")}function FY(e){return e.type.startsWith("mouse")}function y1(e){if(OY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(FY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function aFe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function lFe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function cFe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:WF(e),b:WF(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Et(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:UF(HF(n.a)),b:UF(HF(n.b))};if(s.a===s.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let a=o.length;for(;a--;){const l=o[a];if(l===i.a)return 1;if(l===i.b)return-1}}return Math.sign(s.a-s.b)}const uFe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dFe(e){var t;const n=getComputedStyle((t=$Y(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function fFe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||dFe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uFe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function HF(e){let t=e.length;for(;t--;){const n=e[t];if(Et(n,"Missing node"),fFe(n))return n}return null}function UF(e){return e&&Number(getComputedStyle(e).zIndex)||0}function WF(e){const t=[];for(;e;)t.push(e),e=$Y(e);return t}function $Y(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const LY=1,zY=2,BY=4,VY=8,hFe=aFe()==="coarse";let Qo=[],ff=!1,hl=new Map,x1=new Map;const rg=new Set;function pFe(e,t,n,r,s){var o;const{ownerDocument:i}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},l=(o=hl.get(i))!==null&&o!==void 0?o:0;return hl.set(i,l+1),rg.add(a),ev(),function(){var d;x1.delete(e),rg.delete(a);const f=(d=hl.get(i))!==null&&d!==void 0?d:1;if(hl.set(i,f-1),ev(),f===1&&hl.delete(i),Qo.includes(a)){const h=Qo.indexOf(a);h>=0&&Qo.splice(h,1),$M(),s("up",!0,null)}}}function qF(e){const{target:t}=e,{x:n,y:r}=y1(e);ff=!0,FM({target:t,x:n,y:r}),ev(),Qo.length>0&&(tv("down",e),e.preventDefault(),e.stopPropagation())}function op(e){const{x:t,y:n}=y1(e);if(ff&&e.buttons===0&&(ff=!1,tv("up",e)),!ff){const{target:r}=e;FM({target:r,x:t,y:n})}tv("move",e),$M(),Qo.length>0&&e.preventDefault()}function Ed(e){const{target:t}=e,{x:n,y:r}=y1(e);x1.clear(),ff=!1,Qo.length>0&&e.preventDefault(),tv("up",e),FM({target:t,x:n,y:r}),$M(),ev()}function FM({target:e,x:t,y:n}){Qo.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),rg.forEach(s=>{const{element:o,hitAreaMargins:i}=s,a=o.getBoundingClientRect(),{bottom:l,left:c,right:d,top:f}=a,h=hFe?i.coarse:i.fine;if(t>=c-h&&t<=d+h&&n>=f-h&&n<=l+h){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&cFe(r,o)>0){let m=r,g=!1;for(;m&&!m.contains(o);){if(lFe(m.getBoundingClientRect(),a)){g=!0;break}m=m.parentElement}if(g)return}Qo.push(s)}})}function KC(e,t){x1.set(e,t)}function $M(){let e=!1,t=!1;Qo.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;x1.forEach(r=>{n|=r}),e&&t?ZC("intersection",n):e?ZC("horizontal",n):t?ZC("vertical",n):iFe()}function ev(){hl.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Ed),n.removeEventListener("pointerdown",qF),n.removeEventListener("pointerleave",op),n.removeEventListener("pointermove",op)}),window.removeEventListener("pointerup",Ed),window.removeEventListener("pointercancel",Ed),rg.size>0&&(ff?(Qo.length>0&&hl.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Ed),n.addEventListener("pointerleave",op),n.addEventListener("pointermove",op))}),window.addEventListener("pointerup",Ed),window.addEventListener("pointercancel",Ed)):hl.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",qF,{capture:!0}),n.addEventListener("pointermove",op))}))}function tv(e,t){rg.forEach(n=>{const{setResizeHandlerState:r}=n,s=Qo.includes(n);r(e,s,t)})}function mFe(){const[e,t]=df(0);return bs(()=>t(n=>n+1),[])}function Et(e,t){if(!e)throw console.error(t),Error(t)}const LM=10;function Uu(e,t,n=LM){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function wa(e,t,n=LM){return Uu(e,t,n)===0}function Ws(e,t,n){return Uu(e,t,n)===0}function gFe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=t[r];if(!Ws(s,o,n))return!1}return!0}function qd({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Et(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:o,maxSize:i=100,minSize:a=0}=r;if(Uu(n,a)<0)if(o){const l=(s+a)/2;Uu(n,l)<0?n=s:n=a}else n=a;return n=Math.min(i,n),n=parseFloat(n.toFixed(LM)),n}function kp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:o}){if(Ws(e,0))return t;const i=[...t],[a,l]=r;Et(a!=null,"Invalid first pivot index"),Et(l!=null,"Invalid second pivot index");let c=0;if(o==="keyboard"){{const f=e<0?l:a,h=n[f];Et(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:g=0}=h;if(m){const b=t[f];if(Et(b!=null,`Previous layout not found for panel index ${f}`),Ws(b,p)){const y=g-b;Uu(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:l,h=n[f];Et(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:g=0}=h;if(m){const b=t[f];if(Et(b!=null,`Previous layout not found for panel index ${f}`),Ws(b,g)){const y=b-p;Uu(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let h=e<0?l:a,p=0;for(;;){const g=t[h];Et(g!=null,`Previous layout not found for panel index ${h}`);const y=qd({panelConstraints:n,panelIndex:h,size:100})-g;if(p+=y,h+=f,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?a:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(c),m=t[h];Et(m!=null,`Previous layout not found for panel index ${h}`);const g=m-p,b=qd({panelConstraints:n,panelIndex:h,size:g});if(!Ws(m,b)&&(c+=m-b,i[h]=b,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(gFe(s,i))return s;{const f=e<0?l:a,h=t[f];Et(h!=null,`Previous layout not found for panel index ${f}`);const p=h+c,m=qd({panelConstraints:n,panelIndex:f,size:p});if(i[f]=m,!Ws(m,p)){let g=p-m,y=e<0?l:a;for(;y>=0&&y<n.length;){const x=i[y];Et(x!=null,`Previous layout not found for panel index ${y}`);const v=x+g,w=qd({panelConstraints:n,panelIndex:y,size:v});if(Ws(x,w)||(g-=w-x,i[y]=w),Ws(g,0))break;e>0?y--:y++}}}const d=i.reduce((f,h)=>h+f,0);return Ws(d,100)?i:s}function bFe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,o=0,i=0;const a=n[0];Et(a!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:m=100,minSize:g=0}=p;h===a?(r=g,s=m):(o+=g,i+=m)});const l=Math.min(s,100-o),c=Math.max(r,100-i),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function sg(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function HY(e,t,n=document){const s=sg(e,n).findIndex(o=>o.getAttribute("data-panel-resize-handle-id")===t);return s??null}function UY(e,t,n){const r=HY(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function WY(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function v1(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function yFe(e,t,n,r=document){var s,o,i,a;const l=v1(t,r),c=sg(e,r),d=l?c.indexOf(l):-1,f=(s=(o=n[d])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,h=(i=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&i!==void 0?i:null;return[f,h]}function xFe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:o,setLayout:i}){Cs({didWarnAboutMissingResizeHandle:!1}),wu(()=>{if(!o)return;const a=sg(n,o);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:d,valueNow:f}=bFe({layout:r,panelsArray:s,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const p=s[l];Et(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,s,o]),vu(()=>{if(!o)return;const a=t.current;Et(a,"Eager values not found");const{panelDataArray:l}=a,c=WY(n,o);Et(c!=null,`No group found for id "${n}"`);const d=sg(n,o);Et(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");Et(p,"Resize handle element has no handle id attribute");const[m,g]=yFe(n,p,l,o);if(m==null||g==null)return()=>{};const b=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const x=l.findIndex(v=>v.id===m);if(x>=0){const v=l[x];Et(v,`No panel data found for index ${x}`);const w=r[x],{collapsedSize:S=0,collapsible:N,minSize:k=0}=v.constraints;if(w!=null&&N){const j=kp({delta:Ws(w,S)?k-S:S-w,initialLayout:r,panelConstraints:l.map(_=>_.constraints),pivotIndices:UY(n,p,o),prevLayout:r,trigger:"keyboard"});r!==j&&i(j)}}break}}};return h.addEventListener("keydown",b),()=>{h.removeEventListener("keydown",b)}});return()=>{f.forEach(h=>h())}},[o,e,t,n,r,s,i])}function YF(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function qY(e,t){const n=e==="horizontal",{x:r,y:s}=y1(t);return n?r:s}function vFe(e,t,n,r,s){const o=n==="horizontal",i=v1(t,s);Et(i,`No resize handle element found for id "${t}"`);const a=i.getAttribute("data-panel-group-id");Et(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=qY(n,e),d=WY(a,s);Et(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),h=o?f.width:f.height;return(c-l)/h*100}function wFe(e,t,n,r,s,o){if(PY(e)){const i=n==="horizontal";let a=0;e.shiftKey?a=100:s!=null?a=s:a=10;let l=0;switch(e.key){case"ArrowDown":l=i?0:a;break;case"ArrowLeft":l=i?-a:0;break;case"ArrowRight":l=i?a:0;break;case"ArrowUp":l=i?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:vFe(e,t,n,r,o)}function SFe({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,s=100;for(let o=0;o<e.length;o++){const i=n[o];Et(i,`Panel constraints not found for index ${o}`);const{defaultSize:a}=i;a!=null&&(r++,t[o]=a,s-=a)}for(let o=0;o<e.length;o++){const i=n[o];Et(i,`Panel constraints not found for index ${o}`);const{defaultSize:a}=i;if(a!=null)continue;const l=e.length-r,c=s/l;r++,t[o]=c,s-=c}return t}function jd(e,t,n){t.forEach((r,s)=>{const o=e[s];Et(o,`Panel data not found for index ${s}`);const{callbacks:i,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:h,onExpand:p,onResize:m}=i;m&&m(r,f),d&&(h||p)&&(p&&(f==null||wa(f,c))&&!wa(r,c)&&p(),h&&(f==null||!wa(f,c))&&wa(r,c)&&h())}})}function Uy(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function CFe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:o=3}){const i=n[s];let a;return i==null?a=e!=null?e.toPrecision(o):"1":r.length===1?a="1":a=i.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function NFe(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function GF(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function YY(e){return`react-resizable-panels:${e}`}function GY(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:o}=t;return s?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function ZY(e,t){try{const n=YY(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function kFe(e,t,n){var r,s;const o=(r=ZY(e,n))!==null&&r!==void 0?r:{},i=GY(t);return(s=o[i])!==null&&s!==void 0?s:null}function EFe(e,t,n,r,s){var o;const i=YY(e),a=GY(t),l=(o=ZY(e,s))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function ZF({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Ws(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=100/r*i;n[o]=a}let s=0;for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=qd({panelConstraints:t,panelIndex:o,size:i});i!=a&&(s+=i-a,n[o]=a)}if(!Ws(s,0))for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=i+s,l=qd({panelConstraints:t,panelIndex:o,size:a});if(i!==l&&(s-=l-i,n[o]=l,Ws(s,0)))break}return n}const jFe=100,Ep={getItem:e=>(GF(Ep),Ep.getItem(e)),setItem:(e,t)=>{GF(Ep),Ep.setItem(e,t)}},KF={};function KY({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:o=null,onLayout:i=null,keyboardResizeBy:a=null,storage:l=Ep,style:c,tagName:d="div",...f}){const h=OM(o),p=Cs(null),[m,g]=df(null),[b,y]=df([]),x=mFe(),v=Cs({}),w=Cs(new Map),S=Cs(0),N=Cs({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:a,onLayout:i,storage:l}),k=Cs({layout:b,panelDataArray:[],panelDataArrayChanged:!1});Cs({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),RY(s,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:R}=k.current;return R},setLayout:R=>{const{onLayout:W}=N.current,{layout:Y,panelDataArray:Z}=k.current,H=ZF({layout:R,panelConstraints:Z.map($=>$.constraints)});YF(Y,H)||(y(H),k.current.layout=H,W&&W(H),jd(Z,H,v.current))}}),[]),wu(()=>{N.current.autoSaveId=e,N.current.direction=r,N.current.dragState=m,N.current.id=h,N.current.onLayout=i,N.current.storage=l}),xFe({committedValuesRef:N,eagerValuesRef:k,groupId:h,layout:b,panelDataArray:k.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),vu(()=>{const{panelDataArray:R}=k.current;if(e){if(b.length===0||b.length!==R.length)return;let W=KF[e];W==null&&(W=NFe(EFe,jFe),KF[e]=W);const Y=[...R],Z=new Map(w.current);W(e,Y,Z,b,l)}},[e,b,l]),vu(()=>{});const j=bs(R=>{const{onLayout:W}=N.current,{layout:Y,panelDataArray:Z}=k.current;if(R.constraints.collapsible){const H=Z.map(ee=>ee.constraints),{collapsedSize:$=0,panelSize:q,pivotIndices:G}=Cc(Z,R,Y);if(Et(q!=null,`Panel size not found for panel "${R.id}"`),!wa(q,$)){w.current.set(R.id,q);const Q=Id(Z,R)===Z.length-1?q-$:$-q,ne=kp({delta:Q,initialLayout:Y,panelConstraints:H,pivotIndices:G,prevLayout:Y,trigger:"imperative-api"});Uy(Y,ne)||(y(ne),k.current.layout=ne,W&&W(ne),jd(Z,ne,v.current))}}},[]),_=bs((R,W)=>{const{onLayout:Y}=N.current,{layout:Z,panelDataArray:H}=k.current;if(R.constraints.collapsible){const $=H.map(oe=>oe.constraints),{collapsedSize:q=0,panelSize:G=0,minSize:ee=0,pivotIndices:Q}=Cc(H,R,Z),ne=W??ee;if(wa(G,q)){const oe=w.current.get(R.id),de=oe!=null&&oe>=ne?oe:ne,ke=Id(H,R)===H.length-1?G-de:de-G,ye=kp({delta:ke,initialLayout:Z,panelConstraints:$,pivotIndices:Q,prevLayout:Z,trigger:"imperative-api"});Uy(Z,ye)||(y(ye),k.current.layout=ye,Y&&Y(ye),jd(H,ye,v.current))}}},[]),D=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{panelSize:Z}=Cc(Y,R,W);return Et(Z!=null,`Panel size not found for panel "${R.id}"`),Z},[]),M=bs((R,W)=>{const{panelDataArray:Y}=k.current,Z=Id(Y,R);return CFe({defaultSize:W,dragState:m,layout:b,panelData:Y,panelIndex:Z})},[m,b]),T=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{collapsedSize:Z=0,collapsible:H,panelSize:$}=Cc(Y,R,W);return Et($!=null,`Panel size not found for panel "${R.id}"`),H===!0&&wa($,Z)},[]),O=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{collapsedSize:Z=0,collapsible:H,panelSize:$}=Cc(Y,R,W);return Et($!=null,`Panel size not found for panel "${R.id}"`),!H||Uu($,Z)>0},[]),A=bs(R=>{const{panelDataArray:W}=k.current;W.push(R),W.sort((Y,Z)=>{const H=Y.order,$=Z.order;return H==null&&$==null?0:H==null?-1:$==null?1:H-$}),k.current.panelDataArrayChanged=!0,x()},[x]);wu(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:R,onLayout:W,storage:Y}=N.current,{layout:Z,panelDataArray:H}=k.current;let $=null;if(R){const G=kFe(R,H,Y);G&&(w.current=new Map(Object.entries(G.expandToSizes)),$=G.layout)}$==null&&($=SFe({panelDataArray:H}));const q=ZF({layout:$,panelConstraints:H.map(G=>G.constraints)});YF(Z,q)||(y(q),k.current.layout=q,W&&W(q),jd(H,q,v.current))}}),wu(()=>{const R=k.current;return()=>{R.layout=[]}},[]);const P=bs(R=>{let W=!1;const Y=p.current;return Y&&window.getComputedStyle(Y,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(H){H.preventDefault();const $=p.current;if(!$)return()=>null;const{direction:q,dragState:G,id:ee,keyboardResizeBy:Q,onLayout:ne}=N.current,{layout:oe,panelDataArray:de}=k.current,{initialLayout:le}=G??{},ke=UY(ee,R,$);let ye=wFe(H,R,q,G,Q,$);const Pe=q==="horizontal";Pe&&W&&(ye=-ye);const Ve=de.map(Ne=>Ne.constraints),lt=kp({delta:ye,initialLayout:le??oe,panelConstraints:Ve,pivotIndices:ke,prevLayout:oe,trigger:PY(H)?"keyboard":"mouse-or-touch"}),ue=!Uy(oe,lt);(OY(H)||FY(H))&&S.current!=ye&&(S.current=ye,!ue&&ye!==0?Pe?KC(R,ye<0?LY:zY):KC(R,ye<0?BY:VY):KC(R,0)),ue&&(y(lt),k.current.layout=lt,ne&&ne(lt),jd(de,lt,v.current))}},[]),F=bs((R,W)=>{const{onLayout:Y}=N.current,{layout:Z,panelDataArray:H}=k.current,$=H.map(oe=>oe.constraints),{panelSize:q,pivotIndices:G}=Cc(H,R,Z);Et(q!=null,`Panel size not found for panel "${R.id}"`);const Q=Id(H,R)===H.length-1?q-W:W-q,ne=kp({delta:Q,initialLayout:Z,panelConstraints:$,pivotIndices:G,prevLayout:Z,trigger:"imperative-api"});Uy(Z,ne)||(y(ne),k.current.layout=ne,Y&&Y(ne),jd(H,ne,v.current))},[]),V=bs((R,W)=>{const{layout:Y,panelDataArray:Z}=k.current,{collapsedSize:H=0,collapsible:$}=W,{collapsedSize:q=0,collapsible:G,maxSize:ee=100,minSize:Q=0}=R.constraints,{panelSize:ne}=Cc(Z,R,Y);ne!=null&&($&&G&&wa(ne,H)?wa(H,q)||F(R,q):ne<Q?F(R,Q):ne>ee&&F(R,ee))},[F]),U=bs((R,W)=>{const{direction:Y}=N.current,{layout:Z}=k.current;if(!p.current)return;const H=v1(R,p.current);Et(H,`Drag handle element not found for id "${R}"`);const $=qY(Y,W);g({dragHandleId:R,dragHandleRect:H.getBoundingClientRect(),initialCursorPosition:$,initialLayout:Z})},[]),z=bs(()=>{g(null)},[]),I=bs(R=>{const{panelDataArray:W}=k.current,Y=Id(W,R);Y>=0&&(W.splice(Y,1),delete v.current[R.id],k.current.panelDataArrayChanged=!0,x())},[x]),B=tFe(()=>({collapsePanel:j,direction:r,dragState:m,expandPanel:_,getPanelSize:D,getPanelStyle:M,groupId:h,isPanelCollapsed:T,isPanelExpanded:O,reevaluatePanelConstraints:V,registerPanel:A,registerResizeHandle:P,resizePanel:F,startDragging:U,stopDragging:z,unregisterPanel:I,panelGroupElement:p.current}),[j,m,r,_,D,M,h,T,O,V,A,P,F,U,z,I]),L={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return nh(b1.Provider,{value:B},nh(d,{...f,children:t,className:n,id:o,ref:p,style:{...L,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const XY=MY((e,t)=>nh(KY,{...e,forwardedRef:t}));KY.displayName="PanelGroup";XY.displayName="forwardRef(PanelGroup)";function Id(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Cc(e,t,n){const r=Id(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function _Fe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){vu(()=>{if(e||n==null||r==null)return;const s=v1(t,r);if(s==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const a=s.getAttribute("data-panel-group-id");Et(a,`No group element found for id "${a}"`);const l=sg(a,r),c=HY(a,t,r);Et(c!==null,`No resize element found for id "${t}"`);const d=i.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[r,e,t,n])}function zM({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:o,onDragging:i,onFocus:a,style:l={},tabIndex:c=0,tagName:d="div",...f}){var h,p;const m=Cs(null),g=Cs({onDragging:i});vu(()=>{g.current.onDragging=i});const b=TY(b1);if(b===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:x,registerResizeHandle:v,startDragging:w,stopDragging:S,panelGroupElement:N}=b,k=OM(s),[j,_]=df("inactive"),[D,M]=df(!1),[T,O]=df(null),A=Cs({state:j});wu(()=>{A.current.state=j}),vu(()=>{if(n)O(null);else{const U=v(k);O(()=>U)}},[n,k,v]);const P=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,F=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return vu(()=>{if(n||T==null)return;const U=m.current;return Et(U,"Element ref not attached"),pFe(k,U,y,{coarse:P,fine:F},(I,B,L)=>{if(B)switch(I){case"down":{_("drag"),Et(L,'Expected event to be defined for "down" action'),w(k,L);const{onDragging:R}=g.current;R&&R(!0);break}case"move":{const{state:R}=A.current;R!=="drag"&&_("hover"),Et(L,'Expected event to be defined for "move" action'),T(L);break}case"up":{_("hover"),S();const{onDragging:R}=g.current;R&&R(!1);break}}else _("inactive")})},[P,y,n,F,v,k,T,w,S]),_Fe({disabled:n,handleId:k,resizeHandler:T,panelGroupElement:N}),nh(d,{...f,children:e,className:t,id:s,onBlur:()=>{M(!1),o==null||o()},onFocus:()=>{M(!0),a==null||a()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":y,"data-panel-group-id":x,"data-resize-handle":"","data-resize-handle-active":j==="drag"?"pointer":D?"keyboard":void 0,"data-resize-handle-state":j,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":k})}zM.displayName="PanelResizeHandle";const QY=({className:e,...t})=>u.jsx(XY,{className:K("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),nE=AY,DFe=({withHandle:e,className:t,...n})=>u.jsx(zM,{className:K("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:u.jsx(j$,{className:"h-2.5 w-2.5"})})}),MFe=({withHandle:e,className:t,onTabClick:n,open:r,...s})=>u.jsx(zM,{className:K("relative flex w-px items-start justify-end bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",{"justify-start":r},t),...s,children:e&&!1});function TFe({open:e,setOpen:t}){const n=te(o=>o.selectedSheetId),{deleteSheet:r}=Qt();function s(){n&&(r(n),t(!1))}return u.jsx(ZD,{open:e,onOpenChange:t,children:u.jsxs(Hw,{children:[u.jsxs(Uw,{children:[u.jsx(qw,{children:"Delete Sheet"}),u.jsx(Yw,{children:"Are you sure you want to delete this sheet along with all its cards? This action cannot be undone."})]}),u.jsxs(Ww,{children:[u.jsx(Zw,{children:"Cancel"}),u.jsx(Gw,{className:"bg-destructive hover:bg-destructive/90",onClick:s,children:"Delete"})]})]})})}function RFe({children:e}){return u.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function IFe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const AFe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PFe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,OFe={};function XF(e,t){return(OFe.jsx?PFe:AFe).test(e)}const FFe=/[ \t\n\f\r]/g;function $Fe(e){return typeof e=="object"?e.type==="text"?QF(e.value):!1:QF(e)}function QF(e){return e.replace(FFe,"")===""}class wb{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}wb.prototype.normal={};wb.prototype.property={};wb.prototype.space=void 0;function JY(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new wb(n,r,t)}function rE(e){return e.toLowerCase()}class Fs{constructor(t,n){this.attribute=n,this.property=t}}Fs.prototype.attribute="";Fs.prototype.booleanish=!1;Fs.prototype.boolean=!1;Fs.prototype.commaOrSpaceSeparated=!1;Fs.prototype.commaSeparated=!1;Fs.prototype.defined=!1;Fs.prototype.mustUseProperty=!1;Fs.prototype.number=!1;Fs.prototype.overloadedBoolean=!1;Fs.prototype.property="";Fs.prototype.spaceSeparated=!1;Fs.prototype.space=void 0;let LFe=0;const gt=ld(),rr=ld(),eG=ld(),Ce=ld(),wn=ld(),hf=ld(),Vs=ld();function ld(){return 2**++LFe}const sE=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:rr,commaOrSpaceSeparated:Vs,commaSeparated:hf,number:Ce,overloadedBoolean:eG,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),XC=Object.keys(sE);class BM extends Fs{constructor(t,n,r,s){let o=-1;if(super(t,n),JF(this,"space",s),typeof r=="number")for(;++o<XC.length;){const i=XC[o];JF(this,XC[o],(r&sE[i])===sE[i])}}}BM.prototype.defined=!0;function JF(e,t,n){n&&(e[t]=n)}function Ph(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new BM(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[rE(r)]=r,n[rE(o.attribute)]=r}return new wb(t,n,e.space)}const tG=Ph({properties:{ariaActiveDescendant:null,ariaAtomic:rr,ariaAutoComplete:null,ariaBusy:rr,ariaChecked:rr,ariaColCount:Ce,ariaColIndex:Ce,ariaColSpan:Ce,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:rr,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:rr,ariaFlowTo:wn,ariaGrabbed:rr,ariaHasPopup:null,ariaHidden:rr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:Ce,ariaLive:null,ariaModal:rr,ariaMultiLine:rr,ariaMultiSelectable:rr,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:Ce,ariaPressed:rr,ariaReadOnly:rr,ariaRelevant:null,ariaRequired:rr,ariaRoleDescription:wn,ariaRowCount:Ce,ariaRowIndex:Ce,ariaRowSpan:Ce,ariaSelected:rr,ariaSetSize:Ce,ariaSort:null,ariaValueMax:Ce,ariaValueMin:Ce,ariaValueNow:Ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function nG(e,t){return t in e?e[t]:t}function rG(e,t){return nG(e,t.toLowerCase())}const zFe=Ph({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hf,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:wn,autoFocus:gt,autoPlay:gt,blocking:wn,capture:null,charSet:null,checked:gt,cite:null,className:wn,cols:Ce,colSpan:null,content:null,contentEditable:rr,controls:gt,controlsList:wn,coords:Ce|hf,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:eG,draggable:rr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:wn,height:Ce,hidden:gt,high:Ce,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:wn,itemRef:wn,itemScope:gt,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Ce,manifest:null,max:null,maxLength:Ce,media:null,method:null,min:null,minLength:Ce,multiple:gt,muted:gt,name:null,nonce:null,noModule:gt,noValidate:gt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:gt,optimum:Ce,pattern:null,ping:wn,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:wn,required:gt,reversed:gt,rows:Ce,rowSpan:Ce,sandbox:wn,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shape:null,size:Ce,sizes:null,slot:null,span:Ce,spellCheck:rr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ce,step:null,style:null,tabIndex:Ce,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:rr,width:Ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:Ce,borderColor:null,bottomMargin:Ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gt,declare:gt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ce,leftMargin:Ce,link:null,longDesc:null,lowSrc:null,marginHeight:Ce,marginWidth:Ce,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ce,rules:null,scheme:null,scrolling:rr,standby:null,summary:null,text:null,topMargin:Ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:gt,disableRemotePlayback:gt,prefix:null,property:null,results:Ce,security:null,unselectable:null},space:"html",transform:rG}),BFe=Ph({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Vs,accentHeight:Ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ce,amplitude:Ce,arabicForm:null,ascent:Ce,attributeName:null,attributeType:null,azimuth:Ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ce,by:null,calcMode:null,capHeight:Ce,className:wn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ce,diffuseConstant:Ce,direction:null,display:null,dur:null,divisor:Ce,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ce,enableBackground:null,end:null,event:null,exponent:Ce,externalResourcesRequired:null,fill:null,fillOpacity:Ce,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hf,g2:hf,glyphName:hf,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ce,horizOriginX:Ce,horizOriginY:Ce,id:null,ideographic:Ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ce,k:Ce,k1:Ce,k2:Ce,k3:Ce,k4:Ce,kernelMatrix:Vs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ce,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ce,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ce,overlineThickness:Ce,paintOrder:null,panose1:null,path:null,pathLength:Ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ce,pointsAtY:Ce,pointsAtZ:Ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vs,rev:Vs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vs,requiredFeatures:Vs,requiredFonts:Vs,requiredFormats:Vs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ce,specularExponent:Ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ce,strikethroughThickness:Ce,string:null,stroke:null,strokeDashArray:Vs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ce,strokeOpacity:Ce,strokeWidth:null,style:null,surfaceScale:Ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Vs,tabIndex:Ce,tableValues:null,target:null,targetX:Ce,targetY:Ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Vs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ce,underlineThickness:Ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ce,values:null,vAlphabetic:Ce,vMathematical:Ce,vectorEffect:null,vHanging:Ce,vIdeographic:Ce,version:null,vertAdvY:Ce,vertOriginX:Ce,vertOriginY:Ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:nG}),sG=Ph({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),oG=Ph({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rG}),iG=Ph({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),VFe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},HFe=/[A-Z]/g,e5=/-[a-z]/g,UFe=/^data[-\w.:]+$/i;function WFe(e,t){const n=rE(t);let r=t,s=Fs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&UFe.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(e5,YFe);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!e5.test(o)){let i=o.replace(HFe,qFe);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=BM}return new s(r,t)}function qFe(e){return"-"+e.toLowerCase()}function YFe(e){return e.charAt(1).toUpperCase()}const GFe=JY([tG,zFe,sG,oG,iG],"html"),VM=JY([tG,BFe,sG,oG,iG],"svg");function ZFe(e){return e.join(" ").trim()}var HM={},t5=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,KFe=/\n/g,XFe=/^\s*/,QFe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,JFe=/^:\s*/,e5e=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,t5e=/^[;\s]*/,n5e=/^\s+|\s+$/g,r5e=`
914
+ `},SAe={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function CAe(e){let{announcements:t=SAe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:s=wAe}=e;const{announce:o,announcement:i}=yAe(),a=mb("DndLiveRegion"),[l,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),xAe(C.useMemo(()=>({onDragStart(f){let{active:h}=f;o(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:p}=f;t.onDragMove&&o(t.onDragMove({active:h,over:p}))},onDragOver(f){let{active:h,over:p}=f;o(t.onDragOver({active:h,over:p}))},onDragEnd(f){let{active:h,over:p}=f;o(t.onDragEnd({active:h,over:p}))},onDragCancel(f){let{active:h,over:p}=f;o(t.onDragCancel({active:h,over:p}))}}),[o,t])),!l)return null;const d=C.createElement(C.Fragment,null,C.createElement(gAe,{id:r,value:s.draggable}),C.createElement(bAe,{id:a,announcement:i}));return n?_n.createPortal(d,n):d}var mr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(mr||(mr={}));function X0(){}function tg(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function NM(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ai=Object.freeze({x:0,y:0});function Vq(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function NAe(e,t){const n=K0(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Hq(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function kAe(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function EF(e){let{left:t,top:n,height:r,width:s}=e;return[{x:t,y:n},{x:t+s,y:n},{x:t,y:n+r},{x:t+s,y:n+r}]}function Uq(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function jF(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const kM=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=jF(t,t.left,t.top),o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=Vq(jF(l),s);o.push({id:a,data:{droppableContainer:i,value:c}})}}return o.sort(Hq)},EAe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=EF(t),o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=EF(l),d=s.reduce((h,p,m)=>h+Vq(c[m],p),0),f=Number((d/4).toFixed(4));o.push({id:a,data:{droppableContainer:i,value:f}})}}return o.sort(Hq)};function jAe(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),i=s-r,a=o-n;if(r<s&&n<o){const l=t.width*t.height,c=e.width*e.height,d=i*a,f=d/(l+c-d);return Number(f.toFixed(4))}return 0}const _Ae=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=[];for(const o of r){const{id:i}=o,a=n.get(i);if(a){const l=jAe(a,t);l>0&&s.push({id:i,data:{droppableContainer:o,value:l}})}}return s.sort(kAe)};function DAe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Wq(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ai}function MAe(e){return function(n){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s.reduce((i,a)=>({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const TAe=MAe(1);function qq(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function RAe(e,t,n){const r=qq(t);if(!r)return e;const{scaleX:s,scaleY:o,x:i,y:a}=r,l=e.left-i-(1-s)*parseFloat(n),c=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,f=o?e.height/o:e.height;return{width:d,height:f,top:c,right:l+d,bottom:c+f,left:l}}const IAe={ignoreTransform:!1};function Ah(e,t){t===void 0&&(t=IAe);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:d}=hs(e).getComputedStyle(e);c&&(n=RAe(n,c,d))}const{top:r,left:s,width:o,height:i,bottom:a,right:l}=n;return{top:r,left:s,width:o,height:i,bottom:a,right:l}}function _F(e){return Ah(e,{ignoreTransform:!0})}function AAe(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function PAe(e,t){return t===void 0&&(t=hs(e).getComputedStyle(e)),t.position==="fixed"}function OAe(e,t){t===void 0&&(t=hs(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const o=t[s];return typeof o=="string"?n.test(o):!1})}function a1(e,t){const n=[];function r(s){if(t!=null&&n.length>=t||!s)return n;if(CM(s)&&s.scrollingElement!=null&&!n.includes(s.scrollingElement))return n.push(s.scrollingElement),n;if(!hb(s)||Lq(s)||n.includes(s))return n;const o=hs(e).getComputedStyle(s);return s!==e&&OAe(s,o)&&n.push(s),PAe(s,o)?n:r(s.parentNode)}return e?r(e):n}function Yq(e){const[t]=a1(e,1);return t??null}function HC(e){return!s1||!e?null:Rh(e)?e:SM(e)?CM(e)||e===Ih(e).scrollingElement?window:hb(e)?e:null:null}function Gq(e){return Rh(e)?e.scrollX:e.scrollLeft}function Zq(e){return Rh(e)?e.scrollY:e.scrollTop}function Kk(e){return{x:Gq(e),y:Zq(e)}}var vr;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(vr||(vr={}));function Kq(e){return!s1||!e?!1:e===document.scrollingElement}function Xq(e){const t={x:0,y:0},n=Kq(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},s=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:s,isLeft:o,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const FAe={x:.2,y:.2};function $Ae(e,t,n,r,s){let{top:o,left:i,right:a,bottom:l}=n;r===void 0&&(r=10),s===void 0&&(s=FAe);const{isTop:c,isBottom:d,isLeft:f,isRight:h}=Xq(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*s.y,width:t.width*s.x};return!c&&o<=t.top+g.height?(p.y=vr.Backward,m.y=r*Math.abs((t.top+g.height-o)/g.height)):!d&&l>=t.bottom-g.height&&(p.y=vr.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=vr.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!f&&i<=t.left+g.width&&(p.x=vr.Backward,m.x=r*Math.abs((t.left+g.width-i)/g.width)),{direction:p,speed:m}}function LAe(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:t,left:n,right:r,bottom:s}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:s,width:e.clientWidth,height:e.clientHeight}}function Qq(e){return e.reduce((t,n)=>uf(t,Kk(n)),ai)}function zAe(e){return e.reduce((t,n)=>t+Gq(n),0)}function BAe(e){return e.reduce((t,n)=>t+Zq(n),0)}function Jq(e,t){if(t===void 0&&(t=Ah),!e)return;const{top:n,left:r,bottom:s,right:o}=t(e);Yq(e)&&(s<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const VAe=[["x",["left","right"],zAe],["y",["top","bottom"],BAe]];class EM{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=a1(n),s=Qq(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,i,a]of VAe)for(const l of i)Object.defineProperty(this,l,{get:()=>{const c=a(r),d=s[o]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class sm{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var s;(s=this.target)==null||s.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function HAe(e){const{EventTarget:t}=hs(e);return e instanceof t?e:Ih(e)}function UC(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var yo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(yo||(yo={}));function DF(e){e.preventDefault()}function UAe(e){e.stopPropagation()}var Lt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Lt||(Lt={}));const eY={start:[Lt.Space,Lt.Enter],cancel:[Lt.Esc],end:[Lt.Space,Lt.Enter,Lt.Tab]},WAe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Lt.Right:return{...n,x:n.x+25};case Lt.Left:return{...n,x:n.x-25};case Lt.Down:return{...n,y:n.y+25};case Lt.Up:return{...n,y:n.y-25}}};class gb{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new sm(Ih(n)),this.windowListeners=new sm(hs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Jq(r),n(ai)}handleKeyDown(t){if(i1(t)){const{active:n,context:r,options:s}=this.props,{keyboardCodes:o=eY,coordinateGetter:i=WAe,scrollBehavior:a="smooth"}=s,{code:l}=t;if(o.end.includes(l)){this.handleEnd(t);return}if(o.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,d=c?{x:c.left,y:c.top}:ai;this.referenceCoordinates||(this.referenceCoordinates=d);const f=i(t,{active:n,context:r.current,currentCoordinates:d});if(f){const h=eg(f,d),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:x,isLeft:v,isBottom:w,maxScroll:S,minScroll:N}=Xq(g),k=LAe(g),j={x:Math.min(b===Lt.Right?k.right-k.width/2:k.right,Math.max(b===Lt.Right?k.left:k.left+k.width/2,f.x)),y:Math.min(b===Lt.Down?k.bottom-k.height/2:k.bottom,Math.max(b===Lt.Down?k.top:k.top+k.height/2,f.y))},_=b===Lt.Right&&!x||b===Lt.Left&&!v,D=b===Lt.Down&&!w||b===Lt.Up&&!y;if(_&&j.x!==f.x){const M=g.scrollLeft+h.x,T=b===Lt.Right&&M<=S.x||b===Lt.Left&&M>=N.x;if(T&&!h.y){g.scrollTo({left:M,behavior:a});return}T?p.x=g.scrollLeft-M:p.x=b===Lt.Right?g.scrollLeft-S.x:g.scrollLeft-N.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(D&&j.y!==f.y){const M=g.scrollTop+h.y,T=b===Lt.Down&&M<=S.y||b===Lt.Up&&M>=N.y;if(T&&!h.x){g.scrollTo({top:M,behavior:a});return}T?p.y=g.scrollTop-M:p.y=b===Lt.Down?g.scrollTop-S.y:g.scrollTop-N.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,uf(eg(f,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}gb.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=eY,onActivation:s}=t,{active:o}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=o.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),s==null||s({event:e.nativeEvent}),!0)}return!1}}];function MF(e){return!!(e&&"distance"in e)}function TF(e){return!!(e&&"delay"in e)}class jM{constructor(t,n,r){var s;r===void 0&&(r=HAe(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:o}=t,{target:i}=o;this.props=t,this.events=n,this.document=Ih(i),this.documentListeners=new sm(this.document),this.listeners=new sm(r),this.windowListeners=new sm(hs(i)),this.initialCoordinates=(s=K0(o))!=null?s:ai,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.DragStart,DF),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),this.windowListeners.add(yo.ContextMenu,DF),this.documentListeners.add(yo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(TF(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(MF(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:s}=this.props;s(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(yo.Click,UAe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:s,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!s)return;const l=(n=K0(t))!=null?n:ai,c=eg(s,l);if(!r&&a){if(MF(a)){if(a.tolerance!=null&&UC(c,a.tolerance))return this.handleCancel();if(UC(c,a.distance))return this.handleStart()}if(TF(a)&&UC(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),i(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Lt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const qAe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bb extends jM{constructor(t){const{event:n}=t,r=Ih(n.target);super(t,qAe,r)}}bb.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const YAe={move:{name:"mousemove"},end:{name:"mouseup"}};var Xk;(function(e){e[e.RightClick=2]="RightClick"})(Xk||(Xk={}));class GAe extends jM{constructor(t){super(t,YAe,Ih(t.event.target))}}GAe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xk.RightClick?!1:(r==null||r({event:n}),!0)}}];const WC={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ZAe extends jM{constructor(t){super(t,WC)}static setup(){return window.addEventListener(WC.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(WC.move.name,t)};function t(){}}}ZAe.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:s}=n;return s.length>1?!1:(r==null||r({event:n}),!0)}}];var om;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(om||(om={}));var Q0;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Q0||(Q0={}));function KAe(e){let{acceleration:t,activator:n=om.Pointer,canScroll:r,draggingRect:s,enabled:o,interval:i=5,order:a=Q0.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:f,threshold:h}=e;const p=QAe({delta:f,disabled:!o}),[m,g]=dAe(),b=C.useRef({x:0,y:0}),y=C.useRef({x:0,y:0}),x=C.useMemo(()=>{switch(n){case om.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case om.DraggableRect:return s}},[n,s,l]),v=C.useRef(null),w=C.useCallback(()=>{const N=v.current;if(!N)return;const k=b.current.x*y.current.x,j=b.current.y*y.current.y;N.scrollBy(k,j)},[]),S=C.useMemo(()=>a===Q0.TreeOrder?[...c].reverse():c,[a,c]);C.useEffect(()=>{if(!o||!c.length||!x){g();return}for(const N of S){if((r==null?void 0:r(N))===!1)continue;const k=c.indexOf(N),j=d[k];if(!j)continue;const{direction:_,speed:D}=$Ae(N,j,x,t,h);for(const M of["x","y"])p[M][_[M]]||(D[M]=0,_[M]=0);if(D.x>0||D.y>0){g(),v.current=N,m(w,i),b.current=D,y.current=_;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,w,r,g,o,i,JSON.stringify(x),JSON.stringify(p),m,c,S,d,JSON.stringify(h)])}const XAe={x:{[vr.Backward]:!1,[vr.Forward]:!1},y:{[vr.Backward]:!1,[vr.Forward]:!1}};function QAe(e){let{delta:t,disabled:n}=e;const r=Z0(t);return pb(s=>{if(n||!r||!s)return XAe;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[vr.Backward]:s.x[vr.Backward]||o.x===-1,[vr.Forward]:s.x[vr.Forward]||o.x===1},y:{[vr.Backward]:s.y[vr.Backward]||o.y===-1,[vr.Forward]:s.y[vr.Forward]||o.y===1}}},[n,t,r])}function JAe(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return pb(s=>{var o;return t==null?null:(o=r??s)!=null?o:null},[r,t])}function ePe(e,t){return C.useMemo(()=>e.reduce((n,r)=>{const{sensor:s}=r,o=s.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...o]},[]),[e,t])}var ng;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ng||(ng={}));var Qk;(function(e){e.Optimized="optimized"})(Qk||(Qk={}));const RF=new Map;function tPe(e,t){let{dragging:n,dependencies:r,config:s}=t;const[o,i]=C.useState(null),{frequency:a,measure:l,strategy:c}=s,d=C.useRef(e),f=b(),h=Jm(f),p=C.useCallback(function(y){y===void 0&&(y=[]),!h.current&&i(x=>x===null?y:x.concat(y.filter(v=>!x.includes(v))))},[h]),m=C.useRef(null),g=pb(y=>{if(f&&!n)return RF;if(!y||y===RF||d.current!==e||o!=null){const x=new Map;for(let v of e){if(!v)continue;if(o&&o.length>0&&!o.includes(v.id)&&v.rect.current){x.set(v.id,v.rect.current);continue}const w=v.node.current,S=w?new EM(l(w),w):null;v.rect.current=S,S&&x.set(v.id,S)}return x}return y},[e,o,n,f,l]);return C.useEffect(()=>{d.current=e},[e]),C.useEffect(()=>{f||p()},[n,f]),C.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),C.useEffect(()=>{f||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,f,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:o!=null};function b(){switch(c){case ng.Always:return!1;case ng.BeforeDragging:return n;default:return!n}}}function _M(e,t){return pb(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function nPe(e,t){return _M(e,t)}function rPe(e){let{callback:t,disabled:n}=e;const r=o1(t),s=C.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return C.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function l1(e){let{callback:t,disabled:n}=e;const r=o1(t),s=C.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return C.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function sPe(e){return new EM(Ah(e),e)}function IF(e,t,n){t===void 0&&(t=sPe);const[r,s]=C.useState(null);function o(){s(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const d=t(e);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const i=rPe({callback(l){if(e)for(const c of l){const{type:d,target:f}=c;if(d==="childList"&&f instanceof HTMLElement&&f.contains(e)){o();break}}}}),a=l1({callback:o});return ii(()=>{o(),e?(a==null||a.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[e]),r}function oPe(e){const t=_M(e);return Wq(e,t)}const AF=[];function iPe(e){const t=C.useRef(e),n=pb(r=>e?r&&r!==AF&&e&&t.current&&e.parentNode===t.current.parentNode?r:a1(e):AF,[e]);return C.useEffect(()=>{t.current=e},[e]),n}function aPe(e){const[t,n]=C.useState(null),r=C.useRef(e),s=C.useCallback(o=>{const i=HC(o.target);i&&n(a=>a?(a.set(i,Kk(i)),new Map(a)):null)},[]);return C.useEffect(()=>{const o=r.current;if(e!==o){i(o);const a=e.map(l=>{const c=HC(l);return c?(c.addEventListener("scroll",s,{passive:!0}),[c,Kk(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(o)};function i(a){a.forEach(l=>{const c=HC(l);c==null||c.removeEventListener("scroll",s)})}},[s,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,i)=>uf(o,i),ai):Qq(e):ai,[e,t])}function PF(e,t){t===void 0&&(t=[]);const n=C.useRef(null);return C.useEffect(()=>{n.current=null},t),C.useEffect(()=>{const r=e!==ai;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?eg(e,n.current):ai}function lPe(e){C.useEffect(()=>{if(!s1)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function cPe(e,t){return C.useMemo(()=>e.reduce((n,r)=>{let{eventName:s,handler:o}=r;return n[s]=i=>{o(i,t)},n},{}),[e,t])}function tY(e){return C.useMemo(()=>e?AAe(e):null,[e])}const OF=[];function uPe(e,t){t===void 0&&(t=Ah);const[n]=e,r=tY(n?hs(n):null),[s,o]=C.useState(OF);function i(){o(()=>e.length?e.map(l=>Kq(l)?r:new EM(t(l),l)):OF)}const a=l1({callback:i});return ii(()=>{a==null||a.disconnect(),i(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),s}function nY(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return hb(t)?t:e}function dPe(e){let{measure:t}=e;const[n,r]=C.useState(null),s=C.useCallback(c=>{for(const{target:d}of c)if(hb(d)){r(f=>{const h=t(d);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),o=l1({callback:s}),i=C.useCallback(c=>{const d=nY(c);o==null||o.disconnect(),d&&(o==null||o.observe(d)),r(d?t(d):null)},[t,o]),[a,l]=G0(i);return C.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const fPe=[{sensor:bb,options:{}},{sensor:gb,options:{}}],hPe={current:{}},Nx={draggable:{measure:_F},droppable:{measure:_F,strategy:ng.WhileDragging,frequency:Qk.Optimized},dragOverlay:{measure:Ah}};class im extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const pPe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new im,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:X0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Nx,measureDroppableContainers:X0,windowRect:null,measuringScheduled:!1},rY={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:X0,draggableNodes:new Map,over:null,measureDroppableContainers:X0},yb=C.createContext(rY),sY=C.createContext(pPe);function mPe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new im}}}function gPe(e,t){switch(t.type){case mr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case mr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case mr.DragEnd:case mr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case mr.RegisterDroppable:{const{element:n}=t,{id:r}=n,s=new im(e.droppable.containers);return s.set(r,n),{...e,droppable:{...e.droppable,containers:s}}}case mr.SetDroppableDisabled:{const{id:n,key:r,disabled:s}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new im(e.droppable.containers);return i.set(n,{...o,disabled:s}),{...e,droppable:{...e.droppable,containers:i}}}case mr.UnregisterDroppable:{const{id:n,key:r}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const o=new im(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function bPe(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:s}=C.useContext(yb),o=Z0(r),i=Z0(n==null?void 0:n.id);return C.useEffect(()=>{if(!t&&!r&&o&&i!=null){if(!i1(o)||document.activeElement===o.target)return;const a=s.get(i);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const f=pAe(d);if(f){f.focus();break}}})}},[r,t,s,i,o]),null}function oY(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((s,o)=>o({transform:s,...r}),n):n}function yPe(e){return C.useMemo(()=>({draggable:{...Nx.draggable,...e==null?void 0:e.draggable},droppable:{...Nx.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Nx.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function xPe(e){let{activeNode:t,measure:n,initialRect:r,config:s=!0}=e;const o=C.useRef(!1),{x:i,y:a}=typeof s=="boolean"?{x:s,y:s}:s;ii(()=>{if(!i&&!a||!t){o.current=!1;return}if(o.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const d=n(c),f=Wq(d,r);if(i||(f.x=0),a||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const h=Yq(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,i,a,r,n])}const c1=C.createContext({...ai,scaleX:1,scaleY:1});var fl;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(fl||(fl={}));const DM=C.memo(function(t){var n,r,s,o;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:d=fPe,collisionDetection:f=_Ae,measuring:h,modifiers:p,...m}=t;const g=C.useReducer(gPe,void 0,mPe),[b,y]=g,[x,v]=vAe(),[w,S]=C.useState(fl.Uninitialized),N=w===fl.Initialized,{draggable:{active:k,nodes:j,translate:_},droppable:{containers:D}}=b,M=k!=null?j.get(k):null,T=C.useRef({initial:null,translated:null}),O=C.useMemo(()=>{var He;return k!=null?{id:k,data:(He=M==null?void 0:M.data)!=null?He:hPe,rect:T}:null},[k,M]),A=C.useRef(null),[P,F]=C.useState(null),[V,U]=C.useState(null),z=Jm(m,Object.values(m)),I=mb("DndDescribedBy",i),B=C.useMemo(()=>D.getEnabled(),[D]),L=yPe(h),{droppableRects:R,measureDroppableContainers:W,measuringScheduled:Y}=tPe(B,{dragging:N,dependencies:[_.x,_.y],config:L.droppable}),Z=JAe(j,k),H=C.useMemo(()=>V?K0(V):null,[V]),$=_e(),q=nPe(Z,L.draggable.measure);xPe({activeNode:k!=null?j.get(k):null,config:$.layoutShiftCompensation,initialRect:q,measure:L.draggable.measure});const G=IF(Z,L.draggable.measure,q),ee=IF(Z?Z.parentElement:null),Q=C.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:R,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=D.getNodeFor((n=Q.current.over)==null?void 0:n.id),oe=dPe({measure:L.dragOverlay.measure}),de=(r=oe.nodeRef.current)!=null?r:Z,le=N?(s=oe.rect)!=null?s:G:null,ke=!!(oe.nodeRef.current&&oe.rect),ye=oPe(ke?null:G),Pe=tY(de?hs(de):null),Ve=iPe(N?ne??Z:null),lt=uPe(Ve),ue=oY(p,{transform:{x:_.x-ye.x,y:_.y-ye.y,scaleX:1,scaleY:1},activatorEvent:V,active:O,activeNodeRect:G,containerNodeRect:ee,draggingNodeRect:le,over:Q.current.over,overlayNodeRect:oe.rect,scrollableAncestors:Ve,scrollableAncestorRects:lt,windowRect:Pe}),Ne=H?uf(H,_):null,Je=aPe(Ve),We=PF(Je),re=PF(Je,[G]),fe=uf(ue,We),De=le?TAe(le,ue):null,Oe=O&&De?f({active:O,collisionRect:De,droppableRects:R,droppableContainers:B,pointerCoordinates:Ne}):null,Me=Uq(Oe,"id"),[nt,Dt]=C.useState(null),ct=ke?ue:uf(ue,re),Ot=DAe(ct,(o=nt==null?void 0:nt.rect)!=null?o:null,G),ve=C.useRef(null),_t=C.useCallback((He,et)=>{let{sensor:qe,options:$e}=et;if(A.current==null)return;const Ze=j.get(A.current);if(!Ze)return;const rt=He.nativeEvent,qt=new qe({active:A.current,activeNode:Ze,event:rt,options:$e,context:Q,onAbort(Yt){if(!j.get(Yt))return;const{onDragAbort:Rn}=z.current,er={id:Yt};Rn==null||Rn(er),x({type:"onDragAbort",event:er})},onPending(Yt,xr,Rn,er){if(!j.get(Yt))return;const{onDragPending:co}=z.current,pi={id:Yt,constraint:xr,initialCoordinates:Rn,offset:er};co==null||co(pi),x({type:"onDragPending",event:pi})},onStart(Yt){const xr=A.current;if(xr==null)return;const Rn=j.get(xr);if(!Rn)return;const{onDragStart:er}=z.current,pc={activatorEvent:rt,active:{id:xr,data:Rn.data,rect:T}};_n.unstable_batchedUpdates(()=>{er==null||er(pc),S(fl.Initializing),y({type:mr.DragStart,initialCoordinates:Yt,active:xr}),x({type:"onDragStart",event:pc}),F(ve.current),U(rt)})},onMove(Yt){y({type:mr.DragMove,coordinates:Yt})},onEnd:Ft(mr.DragEnd),onCancel:Ft(mr.DragCancel)});ve.current=qt;function Ft(Yt){return async function(){const{active:Rn,collisions:er,over:pc,scrollAdjustedTranslate:co}=Q.current;let pi=null;if(Rn&&co){const{cancelDrop:mc}=z.current;pi={activatorEvent:rt,active:Rn,collisions:er,delta:co,over:pc},Yt===mr.DragEnd&&typeof mc=="function"&&await Promise.resolve(mc(pi))&&(Yt=mr.DragCancel)}A.current=null,_n.unstable_batchedUpdates(()=>{y({type:Yt}),S(fl.Uninitialized),Dt(null),F(null),U(null),ve.current=null;const mc=Yt===mr.DragEnd?"onDragEnd":"onDragCancel";if(pi){const Fh=z.current[mc];Fh==null||Fh(pi),x({type:mc,event:pi})}})}}},[j]),vn=C.useCallback((He,et)=>(qe,$e)=>{const Ze=qe.nativeEvent,rt=j.get($e);if(A.current!==null||!rt||Ze.dndKit||Ze.defaultPrevented)return;const qt={active:rt};He(qe,et.options,qt)===!0&&(Ze.dndKit={capturedBy:et.sensor},A.current=$e,_t(qe,et))},[j,_t]),he=ePe(d,vn);lPe(d),ii(()=>{G&&w===fl.Initializing&&S(fl.Initialized)},[G,w]),C.useEffect(()=>{const{onDragMove:He}=z.current,{active:et,activatorEvent:qe,collisions:$e,over:Ze}=Q.current;if(!et||!qe)return;const rt={active:et,activatorEvent:qe,collisions:$e,delta:{x:fe.x,y:fe.y},over:Ze};_n.unstable_batchedUpdates(()=>{He==null||He(rt),x({type:"onDragMove",event:rt})})},[fe.x,fe.y]),C.useEffect(()=>{const{active:He,activatorEvent:et,collisions:qe,droppableContainers:$e,scrollAdjustedTranslate:Ze}=Q.current;if(!He||A.current==null||!et||!Ze)return;const{onDragOver:rt}=z.current,qt=$e.get(Me),Ft=qt&&qt.rect.current?{id:qt.id,rect:qt.rect.current,data:qt.data,disabled:qt.disabled}:null,Yt={active:He,activatorEvent:et,collisions:qe,delta:{x:Ze.x,y:Ze.y},over:Ft};_n.unstable_batchedUpdates(()=>{Dt(Ft),rt==null||rt(Yt),x({type:"onDragOver",event:Yt})})},[Me]),ii(()=>{Q.current={activatorEvent:V,active:O,activeNode:Z,collisionRect:De,collisions:Oe,droppableRects:R,draggableNodes:j,draggingNode:de,draggingNodeRect:le,droppableContainers:D,over:nt,scrollableAncestors:Ve,scrollAdjustedTranslate:fe},T.current={initial:le,translated:De}},[O,Z,Oe,De,j,de,le,R,D,nt,Ve,fe]),KAe({...$,delta:_,draggingRect:De,pointerCoordinates:Ne,scrollableAncestors:Ve,scrollableAncestorRects:lt});const xe=C.useMemo(()=>({active:O,activeNode:Z,activeNodeRect:G,activatorEvent:V,collisions:Oe,containerNodeRect:ee,dragOverlay:oe,draggableNodes:j,droppableContainers:D,droppableRects:R,over:nt,measureDroppableContainers:W,scrollableAncestors:Ve,scrollableAncestorRects:lt,measuringConfiguration:L,measuringScheduled:Y,windowRect:Pe}),[O,Z,G,V,Oe,ee,oe,j,D,R,nt,W,Ve,lt,L,Y,Pe]),Ie=C.useMemo(()=>({activatorEvent:V,activators:he,active:O,activeNodeRect:G,ariaDescribedById:{draggable:I},dispatch:y,draggableNodes:j,over:nt,measureDroppableContainers:W}),[V,he,O,G,y,I,j,nt,W]);return C.createElement(Bq.Provider,{value:v},C.createElement(yb.Provider,{value:Ie},C.createElement(sY.Provider,{value:xe},C.createElement(c1.Provider,{value:Ot},c)),C.createElement(bPe,{disabled:(a==null?void 0:a.restoreFocus)===!1})),C.createElement(CAe,{...a,hiddenTextDescribedById:I}));function _e(){const He=(P==null?void 0:P.autoScrollEnabled)===!1,et=typeof l=="object"?l.enabled===!1:l===!1,qe=N&&!He&&!et;return typeof l=="object"?{...l,enabled:qe}:{enabled:qe}}}),vPe=C.createContext(null),FF="button",wPe="Draggable";function SPe(e){let{id:t,data:n,disabled:r=!1,attributes:s}=e;const o=mb(wPe),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:f,over:h}=C.useContext(yb),{role:p=FF,roleDescription:m="draggable",tabIndex:g=0}=s??{},b=(l==null?void 0:l.id)===t,y=C.useContext(b?c1:vPe),[x,v]=G0(),[w,S]=G0(),N=cPe(i,t),k=Jm(n);ii(()=>(f.set(t,{id:t,key:o,node:x,activatorNode:w,data:k}),()=>{const _=f.get(t);_&&_.key===o&&f.delete(t)}),[f,t]);const j=C.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===FF?!0:void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[r,p,g,b,m,d.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:j,isDragging:b,listeners:r?void 0:N,node:x,over:h,setNodeRef:v,setActivatorNodeRef:S,transform:y}}function iY(){return C.useContext(sY)}const CPe="Droppable",NPe={timeout:25};function aY(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:s}=e;const o=mb(CPe),{active:i,dispatch:a,over:l,measureDroppableContainers:c}=C.useContext(yb),d=C.useRef({disabled:n}),f=C.useRef(!1),h=C.useRef(null),p=C.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...NPe,...s},y=Jm(g??r),x=C.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),v=l1({callback:x,disabled:m||!i}),w=C.useCallback((j,_)=>{v&&(_&&(v.unobserve(_),f.current=!1),j&&v.observe(j))},[v]),[S,N]=G0(w),k=Jm(t);return C.useEffect(()=>{!v||!S.current||(v.disconnect(),f.current=!1,v.observe(S.current))},[S,v]),C.useEffect(()=>(a({type:mr.RegisterDroppable,element:{id:r,key:o,disabled:n,node:S,rect:h,data:k}}),()=>a({type:mr.UnregisterDroppable,key:o,id:r})),[r]),C.useEffect(()=>{n!==d.current.disabled&&(a({type:mr.SetDroppableDisabled,id:r,key:o,disabled:n}),d.current.disabled=n)},[r,o,n,a]),{active:i,rect:h,isOver:(l==null?void 0:l.id)===r,node:S,over:l,setNodeRef:N}}function kPe(e){let{animation:t,children:n}=e;const[r,s]=C.useState(null),[o,i]=C.useState(null),a=Z0(n);return!n&&!r&&a&&s(a),ii(()=>{if(!o)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){s(null);return}Promise.resolve(t(c,o)).then(()=>{s(null)})},[t,r,o]),C.createElement(C.Fragment,null,n,r?C.cloneElement(r,{ref:i}):null)}const EPe={x:0,y:0,scaleX:1,scaleY:1};function jPe(e){let{children:t}=e;return C.createElement(yb.Provider,{value:rY},C.createElement(c1.Provider,{value:EPe},t))}const _Pe={position:"fixed",touchAction:"none"},DPe=e=>i1(e)?"transform 250ms ease":void 0,MPe=C.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:s,children:o,className:i,rect:a,style:l,transform:c,transition:d=DPe}=e;if(!a)return null;const f=s?c:{...c,scaleX:1,scaleY:1},h={..._Pe,width:a.width,height:a.height,top:a.top,left:a.left,transform:Yi.Transform.toString(f),transformOrigin:s&&r?NAe(r,a):void 0,transition:typeof d=="function"?d(r):d,...l};return C.createElement(n,{className:i,style:h,ref:t},o)}),TPe=e=>t=>{let{active:n,dragOverlay:r}=t;const s={},{styles:o,className:i}=e;if(o!=null&&o.active)for(const[a,l]of Object.entries(o.active))l!==void 0&&(s[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(o!=null&&o.dragOverlay)for(const[a,l]of Object.entries(o.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return i!=null&&i.active&&n.node.classList.add(i.active),i!=null&&i.dragOverlay&&r.node.classList.add(i.dragOverlay),function(){for(const[l,c]of Object.entries(s))n.node.style.setProperty(l,c);i!=null&&i.active&&n.node.classList.remove(i.active)}},RPe=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Yi.Transform.toString(t)},{transform:Yi.Transform.toString(n)}]},IPe={duration:250,easing:"ease",keyframes:RPe,sideEffects:TPe({styles:{active:{opacity:"0"}}})};function APe(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:s}=e;return o1((o,i)=>{if(t===null)return;const a=n.get(o);if(!a)return;const l=a.node.current;if(!l)return;const c=nY(i);if(!c)return;const{transform:d}=hs(i).getComputedStyle(i),f=qq(d);if(!f)return;const h=typeof t=="function"?t:PPe(t);return Jq(l,s.draggable.measure),h({active:{id:o,data:a.data,node:l,rect:s.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:i,rect:s.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:s,transform:f})})}function PPe(e){const{duration:t,easing:n,sideEffects:r,keyframes:s}={...IPe,...e};return o=>{let{active:i,dragOverlay:a,transform:l,...c}=o;if(!t)return;const d={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},f={scaleX:l.scaleX!==1?i.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?i.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-d.x,y:l.y-d.y,...f},p=s({...c,active:i,dragOverlay:a,transform:{initial:l,final:h}}),[m]=p,g=p[p.length-1];if(JSON.stringify(m)===JSON.stringify(g))return;const b=r==null?void 0:r({active:i,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(x=>{y.onfinish=()=>{b==null||b(),x()}})}}let $F=0;function OPe(e){return C.useMemo(()=>{if(e!=null)return $F++,$F},[e])}const lY=C.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:s,transition:o,modifiers:i,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:d,active:f,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:x,scrollableAncestors:v,scrollableAncestorRects:w,windowRect:S}=iY(),N=C.useContext(c1),k=OPe(f==null?void 0:f.id),j=oY(i,{activatorEvent:d,active:f,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:v,scrollableAncestorRects:w,transform:N,windowRect:S}),_=_M(h),D=APe({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:x}),M=_?b.setRef:void 0;return C.createElement(jPe,null,C.createElement(kPe,{animation:D},f&&k?C.createElement(MPe,{key:k,id:f.id,ref:M,as:a,activatorEvent:d,adjustScale:t,className:l,transition:o,rect:_,style:{zIndex:c,...s},transform:j},n):null))});function xb(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function FPe(e,t){return e.reduce((n,r,s)=>{const o=t.get(r);return o&&(n[s]=o),n},Array(e.length))}function By(e){return e!==null&&e>=0}function $Pe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function LPe(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Vy={scaleX:1,scaleY:1},zPe=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:s,overIndex:o,index:i}=e;const a=(t=n[s])!=null?t:r;if(!a)return null;const l=BPe(n,i,s);if(i===s){const c=n[o];return c?{x:s<o?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Vy}:null}return i>s&&i<=o?{x:-a.width-l,y:0,...Vy}:i<s&&i>=o?{x:a.width+l,y:0,...Vy}:{x:0,y:0,...Vy}};function BPe(e,t,n){const r=e[t],s=e[t-1],o=e[t+1];return!r||!s&&!o?0:n<t?s?r.left-(s.left+s.width):o.left-(r.left+r.width):o?o.left-(r.left+r.width):r.left-(s.left+s.width)}const cY=e=>{let{rects:t,activeIndex:n,overIndex:r,index:s}=e;const o=xb(t,r,n),i=t[s],a=o[s];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},Hy={scaleX:1,scaleY:1},uY=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:s,rects:o,overIndex:i}=e;const a=(t=o[n])!=null?t:r;if(!a)return null;if(s===n){const c=o[i];return c?{x:0,y:n<i?c.top+c.height-(a.top+a.height):c.top-a.top,...Hy}:null}const l=VPe(o,s,n);return s>n&&s<=i?{x:0,y:-a.height-l,...Hy}:s<n&&s>=i?{x:0,y:a.height+l,...Hy}:{x:0,y:0,...Hy}};function VPe(e,t,n){const r=e[t],s=e[t-1],o=e[t+1];return r?n<t?s?r.top-(s.top+s.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const dY="Sortable",fY=C.createContext({activeIndex:-1,containerId:dY,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:cY,disabled:{draggable:!1,droppable:!1}});function MM(e){let{children:t,id:n,items:r,strategy:s=cY,disabled:o=!1}=e;const{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:d}=iY(),f=mb(dY,n),h=a.rect!==null,p=C.useMemo(()=>r.map(N=>typeof N=="object"&&"id"in N?N.id:N),[r]),m=i!=null,g=i?p.indexOf(i.id):-1,b=c?p.indexOf(c.id):-1,y=C.useRef(p),x=!$Pe(p,y.current),v=b!==-1&&g===-1||x,w=LPe(o);ii(()=>{x&&m&&d(p)},[x,p,m,d]),C.useEffect(()=>{y.current=p},[p]);const S=C.useMemo(()=>({activeIndex:g,containerId:f,disabled:w,disableTransforms:v,items:p,overIndex:b,useDragOverlay:h,sortedRects:FPe(p,l),strategy:s}),[g,f,w.draggable,w.droppable,v,p,b,l,h,s]);return C.createElement(fY.Provider,{value:S},t)}const HPe=e=>{let{id:t,items:n,activeIndex:r,overIndex:s}=e;return xb(n,r,s).indexOf(t)},UPe=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:s,items:o,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==o&&s===i?!1:n?!0:i!==s&&t===l},WPe={duration:200,easing:"ease"},hY="transform",qPe=Yi.Transition.toString({property:hY,duration:0,easing:"linear"}),YPe={roleDescription:"sortable"};function GPe(e){let{disabled:t,index:n,node:r,rect:s}=e;const[o,i]=C.useState(null),a=C.useRef(n);return ii(()=>{if(!t&&n!==a.current&&r.current){const l=s.current;if(l){const c=Ah(r.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&i(d)}}n!==a.current&&(a.current=n)},[t,n,r,s]),C.useEffect(()=>{o&&i(null)},[o]),o}function TM(e){let{animateLayoutChanges:t=UPe,attributes:n,disabled:r,data:s,getNewIndex:o=HPe,id:i,strategy:a,resizeObserverConfig:l,transition:c=WPe}=e;const{items:d,containerId:f,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:x}=C.useContext(fY),v=ZPe(r,p),w=d.indexOf(i),S=C.useMemo(()=>({sortable:{containerId:f,index:w,items:d},...s}),[f,s,w,d]),N=C.useMemo(()=>d.slice(d.indexOf(i)),[d,i]),{rect:k,node:j,isOver:_,setNodeRef:D}=aY({id:i,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...l}}),{active:M,activatorEvent:T,activeNodeRect:O,attributes:A,setNodeRef:P,listeners:F,isDragging:V,over:U,setActivatorNodeRef:z,transform:I}=SPe({id:i,data:S,attributes:{...YPe,...n},disabled:v.draggable}),B=uAe(D,P),L=!!M,R=L&&!m&&By(h)&&By(b),W=!y&&V,Y=W&&R?I:null,H=R?Y??(a??x)({rects:g,activeNodeRect:O,activeIndex:h,overIndex:b,index:w}):null,$=By(h)&&By(b)?o({id:i,items:d,activeIndex:h,overIndex:b}):w,q=M==null?void 0:M.id,G=C.useRef({activeId:q,items:d,newIndex:$,containerId:f}),ee=d!==G.current.items,Q=t({active:M,containerId:f,isDragging:V,isSorting:L,id:i,index:w,items:d,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:c,wasDragging:G.current.activeId!=null}),ne=GPe({disabled:!Q,index:w,node:j,rect:k});return C.useEffect(()=>{L&&G.current.newIndex!==$&&(G.current.newIndex=$),f!==G.current.containerId&&(G.current.containerId=f),d!==G.current.items&&(G.current.items=d)},[L,$,f,d]),C.useEffect(()=>{if(q===G.current.activeId)return;if(q!=null&&G.current.activeId==null){G.current.activeId=q;return}const de=setTimeout(()=>{G.current.activeId=q},50);return()=>clearTimeout(de)},[q]),{active:M,activeIndex:h,attributes:A,data:S,rect:k,index:w,newIndex:$,items:d,isOver:_,isSorting:L,isDragging:V,listeners:F,node:j,overIndex:b,over:U,setNodeRef:B,setActivatorNodeRef:z,setDroppableNodeRef:D,setDraggableNodeRef:P,transform:ne??H,transition:oe()};function oe(){if(ne||ee&&G.current.newIndex===w)return qPe;if(!(W&&!i1(T)||!c)&&(L||Q))return Yi.Transition.toString({...c,property:hY})}}function ZPe(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function J0(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const KPe=[Lt.Down,Lt.Right,Lt.Up,Lt.Left],RM=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:s,droppableContainers:o,over:i,scrollableAncestors:a}}=t;if(KPe.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=s.get(f.id);if(h)switch(e.code){case Lt.Down:r.top<h.top&&l.push(f);break;case Lt.Up:r.top>h.top&&l.push(f);break;case Lt.Left:r.left>h.left&&l.push(f);break;case Lt.Right:r.left<h.left&&l.push(f);break}});const c=EAe({collisionRect:r,droppableRects:s,droppableContainers:l});let d=Uq(c,"id");if(d===(i==null?void 0:i.id)&&c.length>1&&(d=c[1].id),d!=null){const f=o.get(n.id),h=o.get(d),p=h?s.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&f&&h){const b=a1(m).some((N,k)=>a[k]!==N),y=pY(f,h),x=XPe(f,h),v=b||!y?{x:0,y:0}:{x:x?r.width-p.width:0,y:x?r.height-p.height:0},w={x:p.left,y:p.top};return v.x&&v.y?w:eg(w,v)}}}};function pY(e,t){return!J0(e)||!J0(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function XPe(e,t){return!J0(e)||!J0(t)||!pY(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function QPe(e,t,n){const[r,s]=C.useState(null),[o,i]=C.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:o||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),i(""),s(m.id)},l=m=>{t(e.filter(g=>g.id!==m))},c=(m,g)=>{t(e.map(b=>b.id===m?{...b,...g}:b))};return{editingHierarchy:r,setEditingHierarchy:s,newHierarchyName:o,setNewHierarchyName:i,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(v=>v.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},x=e.find(v=>v.id===m);x&&c(m,{steps:[...x.steps,y]})},removeStepFromHierarchy:(m,g)=>{const b=e.find(y=>y.id===m);if(b){const y=[...b.steps];y.splice(g,1),c(m,{steps:y})}},updateStep:(m,g,b)=>{const y=e.find(x=>x.id===m);if(y){const x=y.steps.map((v,w)=>w===g?{...v,...b}:v);c(m,{steps:x})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function JPe({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:s,onOpenChange:o,trigger:i}){return u.jsxs(Ds,{open:s,onOpenChange:o,children:[u.jsx(Ms,{asChild:!0,children:i}),u.jsx(Ts,{className:"z-50 w-80",align:"start",children:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),u.jsxs(pt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[u.jsx(dt,{className:"h-8",children:u.jsx(bt,{})}),u.jsxs(ft,{children:[u.jsx(be,{value:"bar",children:"Bar Chart"}),u.jsx(be,{value:"pie",children:"Pie Chart"}),u.jsx(be,{value:"line",children:"Line Chart"}),u.jsx(be,{value:"donut",children:"Donut Chart"}),u.jsx(be,{value:"table",children:"Table"}),u.jsx(be,{value:"metric",children:"Metric"})]})]})]}),u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),u.jsx(bn,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),u.jsxs("div",{children:[u.jsx(ae,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),u.jsx(bn,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),u.jsx("div",{className:"flex items-center gap-4",children:u.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[u.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),u.jsx("div",{className:"flex justify-end",children:u.jsx(ie,{size:"sm",variant:"outline",onClick:()=>o(!1),children:"Done"})})]})})]})}function eOe({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:s,onRemoveStep:o}){const[i,a]=C.useState(!1),{attributes:l,listeners:c,setNodeRef:d,transform:f,transition:h,isDragging:p}=TM({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:Yi.Transform.toString(f),transition:h,opacity:p?.8:1,zIndex:p?1e3:1};return u.jsx("div",{ref:d,style:m,className:`relative ${i?"z-[9998]":""}`,...l,children:u.jsx(JPe,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:s,open:i,onOpenChange:a,trigger:u.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg border bg-muted px-3 py-2 transition-colors hover:bg-muted/50 ${p?"shadow-lg ring-2 ring-primary":""}`,...c,onClick:g=>{g.stopPropagation(),a(b=>!b)},children:[u.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[u.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&u.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&u.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),u.jsx("button",{className:"pointer-events-auto ml-1 text-xs text-muted-foreground hover:text-red-800 dark:hover:text-red-400",onClick:g=>{g.stopPropagation(),o(r,n)},children:u.jsx(Xt,{className:"h-3 w-3"})})]})})})}function tOe(e){return{sensors:NM(tg(bb,{activationConstraint:{distance:5}}),tg(gb,{coordinateGetter:RM})),handleStepDragEnd:(r,s)=>{const{active:o,over:i}=r;if(!i||o.id===i.id)return;const a=o.id.replace(`${s.id}-`,""),l=i.id.replace(`${s.id}-`,""),c=s.steps.findIndex(f=>f.field.id===a),d=s.steps.findIndex(f=>f.field.id===l);if(c!==-1&&d!==-1&&c!==d){const f=xb(s.steps,c,d);e(s.id,{steps:f})}}}}function nOe({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:s}=tOe(r),[o,i]=C.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),d=h=>{const p=h.active.id,m=Number.parseInt(p.split("-").pop()||"0"),g=a[m],b=g==null?void 0:g.field;i(b||null)},f=h=>{i(null);const{active:p,over:m}=h;if(!m||p.id===m.id)return;const g=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(m.id.split("-").pop()||"0");if(g!==b&&g<a.length&&b<a.length){const y=[...e.steps],[x]=y.splice(g,1);y.splice(b,0,x),r(e.id,{steps:y})}};return a.length===0?u.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:u.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):u.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:u.jsxs(DM,{sensors:s,collisionDetection:kM,onDragStart:d,onDragEnd:f,children:[u.jsx(MM,{items:c,strategy:zPe,children:u.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const m=[];p>0&&m.push(u.jsx(La,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const g=p===0,b=p===a.length-1;return m.push(u.jsx(eOe,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:g,isLastField:b},`field-${h.field.id}-${p}`)),m})})}),typeof window<"u"&&_n.createPortal(u.jsx(lY,{className:"semaphor-scope",style:{zIndex:9999},children:o?u.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:u.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:o.label})}):null}),document.body)]})})}var LF=1,rOe=.9,sOe=.8,oOe=.17,qC=.1,YC=.999,iOe=.9999,aOe=.99,lOe=/[\\\/_+.#"@\[\(\{&]/,cOe=/[\\\/_+.#"@\[\(\{&]/g,uOe=/[\s-]/,mY=/[\s-]/g;function Jk(e,t,n,r,s,o,i){if(o===t.length)return s===e.length?LF:aOe;var a=`${s},${o}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(o),c=n.indexOf(l,s),d=0,f,h,p,m;c>=0;)f=Jk(e,t,n,r,c+1,o+1,i),f>d&&(c===s?f*=LF:lOe.test(e.charAt(c-1))?(f*=sOe,p=e.slice(s,c-1).match(cOe),p&&s>0&&(f*=Math.pow(YC,p.length))):uOe.test(e.charAt(c-1))?(f*=rOe,m=e.slice(s,c-1).match(mY),m&&s>0&&(f*=Math.pow(YC,m.length))):(f*=oOe,s>0&&(f*=Math.pow(YC,c-s))),e.charAt(c)!==t.charAt(o)&&(f*=iOe)),(f<qC&&n.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(c-1)!==r.charAt(o))&&(h=Jk(e,t,n,r,c+1,o+2,i),h*qC>f&&(f=h*qC)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function zF(e){return e.toLowerCase().replace(mY," ")}function dOe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Jk(e,t,zF(e),zF(t),0,0,{})}var sp='[cmdk-group=""]',GC='[cmdk-group-items=""]',fOe='[cmdk-group-heading=""]',gY='[cmdk-item=""]',BF=`${gY}:not([aria-disabled="true"])`,eE="cmdk-item-select",Td="data-value",hOe=(e,t,n)=>dOe(e,t,n),bY=E.createContext(void 0),vb=()=>E.useContext(bY),yY=E.createContext(void 0),IM=()=>E.useContext(yY),xY=E.createContext(void 0),vY=E.forwardRef((e,t)=>{let n=Rd(()=>{var L,R;return{search:"",value:(R=(L=e.value)!=null?L:e.defaultValue)!=null?R:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Rd(()=>new Set),s=Rd(()=>new Map),o=Rd(()=>new Map),i=Rd(()=>new Set),a=wY(e),{label:l,children:c,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,x=Gn(),v=Gn(),w=Gn(),S=E.useRef(null),N=NOe();Hu(()=>{if(d!==void 0){let L=d.trim();n.current.value=L,k.emit()}},[d]),Hu(()=>{N(6,O)},[]);let k=E.useMemo(()=>({subscribe:L=>(i.current.add(L),()=>i.current.delete(L)),snapshot:()=>n.current,setState:(L,R,W)=>{var Y,Z,H,$;if(!Object.is(n.current[L],R)){if(n.current[L]=R,L==="search")T(),D(),N(1,M);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(w);q?q.focus():(Y=document.getElementById(x))==null||Y.focus()}if(N(7,()=>{var q;n.current.selectedItemId=(q=A())==null?void 0:q.id,k.emit()}),W||N(5,O),((Z=a.current)==null?void 0:Z.value)!==void 0){let q=R??"";($=(H=a.current).onValueChange)==null||$.call(H,q);return}}k.emit()}},emit:()=>{i.current.forEach(L=>L())}}),[]),j=E.useMemo(()=>({value:(L,R,W)=>{var Y;R!==((Y=o.current.get(L))==null?void 0:Y.value)&&(o.current.set(L,{value:R,keywords:W}),n.current.filtered.items.set(L,_(R,W)),N(2,()=>{D(),k.emit()}))},item:(L,R)=>(r.current.add(L),R&&(s.current.has(R)?s.current.get(R).add(L):s.current.set(R,new Set([L]))),N(3,()=>{T(),D(),n.current.value||M(),k.emit()}),()=>{o.current.delete(L),r.current.delete(L),n.current.filtered.items.delete(L);let W=A();N(4,()=>{T(),(W==null?void 0:W.getAttribute("id"))===L&&M(),k.emit()})}),group:L=>(s.current.has(L)||s.current.set(L,new Set),()=>{o.current.delete(L),s.current.delete(L)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:x,inputId:w,labelId:v,listInnerRef:S}),[]);function _(L,R){var W,Y;let Z=(Y=(W=a.current)==null?void 0:W.filter)!=null?Y:hOe;return L?Z(L,n.current.search,R):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let L=n.current.filtered.items,R=[];n.current.filtered.groups.forEach(Y=>{let Z=s.current.get(Y),H=0;Z.forEach($=>{let q=L.get($);H=Math.max(q,H)}),R.push([Y,H])});let W=S.current;P().sort((Y,Z)=>{var H,$;let q=Y.getAttribute("id"),G=Z.getAttribute("id");return((H=L.get(G))!=null?H:0)-(($=L.get(q))!=null?$:0)}).forEach(Y=>{let Z=Y.closest(GC);Z?Z.appendChild(Y.parentElement===Z?Y:Y.closest(`${GC} > *`)):W.appendChild(Y.parentElement===W?Y:Y.closest(`${GC} > *`))}),R.sort((Y,Z)=>Z[1]-Y[1]).forEach(Y=>{var Z;let H=(Z=S.current)==null?void 0:Z.querySelector(`${sp}[${Td}="${encodeURIComponent(Y[0])}"]`);H==null||H.parentElement.appendChild(H)})}function M(){let L=P().find(W=>W.getAttribute("aria-disabled")!=="true"),R=L==null?void 0:L.getAttribute(Td);k.setState("value",R||void 0)}function T(){var L,R,W,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Z=0;for(let H of r.current){let $=(R=(L=o.current.get(H))==null?void 0:L.value)!=null?R:"",q=(Y=(W=o.current.get(H))==null?void 0:W.keywords)!=null?Y:[],G=_($,q);n.current.filtered.items.set(H,G),G>0&&Z++}for(let[H,$]of s.current)for(let q of $)if(n.current.filtered.items.get(q)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=Z}function O(){var L,R,W;let Y=A();Y&&(((L=Y.parentElement)==null?void 0:L.firstChild)===Y&&((W=(R=Y.closest(sp))==null?void 0:R.querySelector(fOe))==null||W.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function A(){var L;return(L=S.current)==null?void 0:L.querySelector(`${gY}[aria-selected="true"]`)}function P(){var L;return Array.from(((L=S.current)==null?void 0:L.querySelectorAll(BF))||[])}function F(L){let R=P()[L];R&&k.setState("value",R.getAttribute(Td))}function V(L){var R;let W=A(),Y=P(),Z=Y.findIndex($=>$===W),H=Y[Z+L];(R=a.current)!=null&&R.loop&&(H=Z+L<0?Y[Y.length-1]:Z+L===Y.length?Y[0]:Y[Z+L]),H&&k.setState("value",H.getAttribute(Td))}function U(L){let R=A(),W=R==null?void 0:R.closest(sp),Y;for(;W&&!Y;)W=L>0?SOe(W,sp):COe(W,sp),Y=W==null?void 0:W.querySelector(BF);Y?k.setState("value",Y.getAttribute(Td)):V(L)}let z=()=>F(P().length-1),I=L=>{L.preventDefault(),L.metaKey?z():L.altKey?U(1):V(1)},B=L=>{L.preventDefault(),L.metaKey?F(0):L.altKey?U(-1):V(-1)};return E.createElement(Re.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:L=>{var R;(R=y.onKeyDown)==null||R.call(y,L);let W=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||W))switch(L.key){case"n":case"j":{b&&L.ctrlKey&&I(L);break}case"ArrowDown":{I(L);break}case"p":case"k":{b&&L.ctrlKey&&B(L);break}case"ArrowUp":{B(L);break}case"Home":{L.preventDefault(),F(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let Y=A();if(Y){let Z=new Event(eE);Y.dispatchEvent(Z)}}}}},E.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:EOe},l),u1(e,L=>E.createElement(yY.Provider,{value:k},E.createElement(bY.Provider,{value:j},L))))}),pOe=E.forwardRef((e,t)=>{var n,r;let s=Gn(),o=E.useRef(null),i=E.useContext(xY),a=vb(),l=wY(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Hu(()=>{if(!c)return a.item(s,i==null?void 0:i.id)},[c]);let d=SY(s,o,[e.value,e.children,o],e.keywords),f=IM(),h=Yl(N=>N.value&&N.value===d.current),p=Yl(N=>c||a.filter()===!1?!0:N.search?N.filtered.items.get(s)>0:!0);E.useEffect(()=>{let N=o.current;if(!(!N||e.disabled))return N.addEventListener(eE,m),()=>N.removeEventListener(eE,m)},[p,e.onSelect,e.disabled]);function m(){var N,k;g(),(k=(N=l.current).onSelect)==null||k.call(N,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:x,forceMount:v,keywords:w,...S}=e;return E.createElement(Re.div,{ref:us(o,t),...S,id:s,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:g,onClick:b?void 0:m},e.children)}),mOe=E.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...o}=e,i=Gn(),a=E.useRef(null),l=E.useRef(null),c=Gn(),d=vb(),f=Yl(p=>s||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Hu(()=>d.group(i),[]),SY(i,a,[e.value,e.heading,l]);let h=E.useMemo(()=>({id:i,forceMount:s}),[s]);return E.createElement(Re.div,{ref:us(a,t),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&E.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),u1(e,p=>E.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},E.createElement(xY.Provider,{value:h},p))))}),gOe=E.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=E.useRef(null),o=Yl(i=>!i.search);return!n&&!o?null:E.createElement(Re.div,{ref:us(s,t),...r,"cmdk-separator":"",role:"separator"})}),bOe=E.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,o=IM(),i=Yl(c=>c.search),a=Yl(c=>c.selectedItemId),l=vb();return E.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),E.createElement(Re.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?e.value:i,onChange:c=>{s||o.setState("search",c.target.value),n==null||n(c.target.value)}})}),yOe=E.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,o=E.useRef(null),i=E.useRef(null),a=Yl(c=>c.selectedItemId),l=vb();return E.useEffect(()=>{if(i.current&&o.current){let c=i.current,d=o.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(f),h.unobserve(c)}}},[]),E.createElement(Re.div,{ref:us(o,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},u1(e,c=>E.createElement("div",{ref:us(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xOe=E.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:o,container:i,...a}=e;return E.createElement(kL,{open:n,onOpenChange:r},E.createElement(EL,{container:i},E.createElement(gj,{"cmdk-overlay":"",className:s}),E.createElement(bj,{"aria-label":e.label,"cmdk-dialog":"",className:o},E.createElement(vY,{ref:t,...a}))))}),vOe=E.forwardRef((e,t)=>Yl(n=>n.filtered.count===0)?E.createElement(Re.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wOe=E.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...o}=e;return E.createElement(Re.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},u1(e,i=>E.createElement("div",{"aria-hidden":!0},i)))}),Kr=Object.assign(vY,{List:yOe,Item:pOe,Input:bOe,Group:mOe,Separator:gOe,Dialog:xOe,Empty:vOe,Loading:wOe});function SOe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function COe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function wY(e){let t=E.useRef(e);return Hu(()=>{t.current=e}),t}var Hu=typeof window>"u"?E.useEffect:E.useLayoutEffect;function Rd(e){let t=E.useRef();return t.current===void 0&&(t.current=e()),t}function Yl(e){let t=IM(),n=()=>e(t.snapshot());return E.useSyncExternalStore(t.subscribe,n,n)}function SY(e,t,n,r=[]){let s=E.useRef(),o=vb();return Hu(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():s.current}})(),l=r.map(c=>c.trim());o.value(e,a,l),(i=t.current)==null||i.setAttribute(Td,a),s.current=a}),s}var NOe=()=>{let[e,t]=E.useState(),n=Rd(()=>new Map);return Hu(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function kOe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function u1({asChild:e,children:t},n){return e&&E.isValidElement(t)?E.cloneElement(kOe(t),{ref:t.ref},n(t.props.children)):n(t)}var EOe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const d1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr,{ref:n,className:K("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));d1.displayName=Kr.displayName;const AM=E.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ec,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kr.Input,{ref:n,className:K("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));AM.displayName=Kr.Input.displayName;const f1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.List,{ref:n,className:K("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));f1.displayName=Kr.List.displayName;const h1=E.forwardRef((e,t)=>u.jsx(Kr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));h1.displayName=Kr.Empty.displayName;const p1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Group,{ref:n,className:K("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));p1.displayName=Kr.Group.displayName;const jOe=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Separator,{ref:n,className:K("-mx-1 h-px bg-border",e),...t}));jOe.displayName=Kr.Separator.displayName;const m1=E.forwardRef(({className:e,...t},n)=>u.jsx(Kr.Item,{ref:n,className:K("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));m1.displayName=Kr.Item.displayName;function _Oe({hierarchy:e,sampleFieldReferences:t,onUpdateHierarchy:n,onDeleteHierarchy:r,onUpdateStep:s,onRemoveStep:o,onAddStep:i}){const[a,l]=C.useState(!1),{attributes:c,listeners:d,setNodeRef:f,transform:h,transition:p}=TM({id:e.id,disabled:!1}),m={transform:Yi.Transform.toString(h),transition:p},g=e.steps.filter(b=>b.field).map(b=>b.field.id);return u.jsxs("div",{ref:f,style:m,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[u.jsxs("div",{className:"mb-3 flex cursor-move items-center justify-between",...c,...d,children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("div",{onPointerDown:b=>b.stopPropagation(),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),children:u.jsx(Do,{value:e.label||"",onSave:b=>{n(e.id,{label:b})},placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"})})}),u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(ie,{size:"sm",variant:"ghost",onClick:b=>{b.stopPropagation(),r(e.id)},onPointerDown:b=>b.stopPropagation(),children:u.jsx(ah,{className:"h-3 w-3"})})})]}),u.jsx(nOe,{hierarchy:e,onUpdateStep:s,onRemoveStep:o,onUpdateHierarchy:n}),u.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:a?u.jsxs(d1,{className:"rounded-lg border",children:[u.jsx(AM,{placeholder:"Search fields..."}),u.jsxs(f1,{children:[u.jsx(h1,{children:"No field found."}),u.jsx(p1,{children:t.filter(b=>!g.includes(b.id)).map(b=>u.jsx(m1,{value:b.label,onSelect:()=>{i(e.id,b.id),l(!1)},children:b.label},b.id))})]})]}):u.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:b=>{b.preventDefault(),b.stopPropagation(),l(!0)},children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add Step"]})})]})}function DOe({open:e,onOpenChange:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:s}){const[o,i]=C.useState(n);C.useEffect(()=>{e&&i(n)},[e,n]);const a=C.useMemo(()=>s.filter(x=>Jl(x.dataType)==="string"),[s]),l=NM(tg(bb),tg(gb,{coordinateGetter:RM})),{createNewHierarchy:c,deleteHierarchy:d,updateHierarchy:f,addStepToHierarchy:h,removeStepFromHierarchy:p,updateStep:m,setDefaultHierarchy:g}=QPe(o,i,a),b=x=>{const{active:v,over:w}=x;if(v.id!==(w==null?void 0:w.id)){const S=o.findIndex(k=>k.id===v.id),N=o.findIndex(k=>k.id===(w==null?void 0:w.id));i(xb(o,S,N))}},y=x=>{x||r(o),t(x)};return u.jsx(ao,{modal:!0,open:e,onOpenChange:y,children:u.jsx(Is,{className:"flex max-h-[85vh] max-w-3xl flex-col overflow-hidden p-0",onInteractOutside:x=>x.preventDefault(),onEscapeKeyDown:x=>x.preventDefault(),children:u.jsx(hh,{trapped:!1,children:u.jsxs("div",{className:"flex max-h-[85vh] max-w-3xl flex-col overflow-hidden",children:[u.jsxs(As,{className:"border-b px-6 pb-4 pt-6",children:[u.jsx(Ps,{children:"Manage Drill Hierarchies"}),u.jsx(Ao,{children:"Create multiple drill paths for different analysis scenarios. Define step-by-step navigation through your dimensions."})]}),u.jsx(Rs,{className:"flex-1 px-6",children:u.jsxs("div",{className:"space-y-4 py-4",children:[o.length>0&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(ie,{type:"button",size:"sm",onClick:x=>{x.preventDefault(),x.stopPropagation(),c()},children:[u.jsx(gr,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})}),o.length>0?u.jsx(DM,{sensors:l,collisionDetection:kM,onDragEnd:b,children:u.jsx(MM,{items:o.map(x=>x.id),strategy:uY,children:u.jsx("div",{className:"space-y-4",children:o.map(x=>u.jsx(_Oe,{hierarchy:x,sampleFieldReferences:a,onUpdateHierarchy:f,onDeleteHierarchy:d,onSetDefaultHierarchy:g,onUpdateStep:m,onRemoveStep:p,onAddStep:h},x.id))})})}):u.jsxs("div",{className:"rounded-lg border border-dashed p-8 text-center",children:[u.jsx("p",{className:"mb-2 text-sm text-muted-foreground",children:"No hierarchies configured yet"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Create your first hierarchy to enable drill-down interactions"}),u.jsxs(ie,{type:"button",size:"sm",variant:"outline",onClick:x=>{x.preventDefault(),x.stopPropagation(),c()},children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Create First Hierarchy"]})]})]})}),u.jsx("div",{className:"flex justify-end gap-2 border-t px-6 py-4",children:u.jsx(ie,{variant:"outline",onClick:()=>y(!1),children:"Done"})})]})})})})}function CY(e){switch(e){case"day":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"custom",label:"Custom Format..."}];case"week":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"Week of MMM DD, YYYY",label:"Week of Jan 15, 2024"},{value:"Week of MMMM DD, YYYY",label:"Week of January 15, 2024"},{value:"YYYY-WW",label:"2024-W03 (YYYY-WW)"},{value:"custom",label:"Custom Format..."}];case"month":return[{value:"MMM YYYY",label:"Jan 2024 (MMM YYYY)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MM/YYYY",label:"01/2024 (MM/YYYY)"},{value:"YYYY MMM",label:"2024 Jan (YYYY MMM)"},{value:"custom",label:"Custom Format..."}];case"quarter":return[{value:"Q1 YYYY",label:"Q1 2024 (Q1 YYYY)"},{value:"YYYY Q1",label:"2024 Q1 (YYYY Q1)"},{value:"1st Quarter YYYY",label:"1st Quarter 2024"},{value:"YYYY-Q1",label:"2024-Q1 (YYYY-Q1)"},{value:"Quarter 1, YYYY",label:"Quarter 1, 2024"},{value:"custom",label:"Custom Format..."}];case"year":return[{value:"YYYY",label:"2024 (YYYY)"},{value:"YY",label:"24 (YY)"},{value:"custom",label:"Custom Format..."}];default:return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"custom",label:"Custom Format..."}]}}function MOe({interaction:e,onUpdate:t,card:n,availableFields:r,onUpdateHierarchies:s,onManageHierarchies:o}){var M;const[i,a]=C.useState(!1),[l,c]=C.useState(!1),[d,f]=C.useState(null),[h,p]=C.useState(!1),[m,g]=C.useState({}),b=C.useMemo(()=>{var T;return((T=n.interactionConfig)==null?void 0:T.drillHierarchies)||[]},[(M=n.interactionConfig)==null?void 0:M.drillHierarchies]),y=C.useMemo(()=>{var P,F;const T=[],O=e.trigger;if(!O)return T;let A;if(O.type==="attribute"){const V=r.find(z=>z.id===O.field.id);V&&(V.dataType==="date"||V.dataType==="timestamp")&&(A=V)}else if(O.type==="metric"){const V=(F=(P=n.config)==null?void 0:P.groupByColumns)==null?void 0:F.find(U=>U.dataType==="date"||U.dataType==="timestamp");V&&(A=V)}if(A&&$J(A,b)){const V=FJ(A);T.push(V)}return T},[r,b,e.trigger,n.config]),x=C.useMemo(()=>[...b,...y],[b,y]),v=x.find(T=>T.id===e.hierarchyId);E.useEffect(()=>{i&&v&&v.type==="date"?f(v.id):i||f(null)},[i,v]);const w=T=>{if(y.some(A=>A.id===T)&&s){const A=y.find(P=>P.id===T);A&&s([...b,A])}t({...e,hierarchyId:T}),a(!1)},S=()=>{a(!1),c(!0),o&&o()},N=T=>{s&&s(T)},k=T=>T.steps.map(A=>A.field.label||A.field.name).join(" → "),j=T=>T&&T.charAt(0).toUpperCase()+T.slice(1),_=(T,O,A)=>{const P=[...T.steps];P[O]={...P[O],field:{...P[O].field,dateFormat:A,customFormat:A==="custom"?m[O]||"":void 0}};const F={...T,steps:P};if(s){const V=b.findIndex(U=>U.id===T.id);if(V>=0){const U=[...b];U[V]=F,s(U)}else s([...b,F])}},D=(T,O,A)=>{g(V=>({...V,[O]:A}));const P=[...T.steps];P[O]={...P[O],field:{...P[O].field,dateFormat:"custom",customFormat:A}};const F={...T,steps:P};if(s){const V=b.findIndex(U=>U.id===T.id);if(V>=0){const U=[...b];U[V]=F,s(U)}else s([...b,F])}};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Choose hierarchy"}),u.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"Select which hierarchy to drill through when this interaction triggers"}),x.length>0?u.jsxs(u.Fragment,{children:[u.jsxs(Ds,{open:i,onOpenChange:a,children:[u.jsx(Ms,{asChild:!0,children:u.jsxs(ie,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[u.jsx("div",{className:"flex flex-1 flex-col items-start text-left",children:v?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"font-medium",children:v.label||"Unnamed Hierarchy"})}),u.jsx("span",{className:"text-xs text-muted-foreground",children:k(v)})]}):u.jsx("span",{className:"text-muted-foreground",children:"Select hierarchy..."})}),u.jsxs("div",{className:"flex items-center gap-2",children:[v&&v.type==="date"&&u.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:T=>{T.stopPropagation(),p(!h)},children:u.jsx(ih,{className:"h-3 w-3"})}),u.jsx(La,{className:"h-4 w-4 shrink-0 opacity-50"})]})]})}),u.jsxs(Ts,{className:"w-[500px] p-0",align:"start",children:[u.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[u.jsx("span",{className:"text-sm font-medium",children:"Select Hierarchy"}),u.jsxs(ie,{variant:"ghost",size:"sm",onClick:S,children:[u.jsx(gr,{className:"mr-1.5 h-3.5 w-3.5"}),"Create new"]})]}),u.jsxs("div",{className:"p-2",children:[y.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"px-3 py-2",children:u.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"AUTO-GENERATED"})}),y.map(T=>u.jsx("div",{className:`cursor-pointer rounded-md p-3 hover:bg-muted ${e.hierarchyId===T.id?"bg-muted":""}`,onClick:()=>w(T.id),children:u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"text-sm font-medium",children:T.label||"Unnamed Hierarchy"})}),u.jsx("div",{className:"text-xs text-muted-foreground",children:k(T)})]})},T.id))]}),b.length>0&&u.jsxs(u.Fragment,{children:[y.length>0&&u.jsx("div",{className:"my-2 border-t"}),b.map(T=>u.jsx("div",{className:`cursor-pointer rounded-md p-3 hover:bg-muted ${e.hierarchyId===T.id?"bg-muted":""}`,onClick:()=>w(T.id),children:u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"text-sm font-medium",children:T.label||"Unnamed Hierarchy"})}),u.jsx("div",{className:"text-xs text-muted-foreground",children:k(T)})]})},T.id))]})]})]})]}),v&&v.type==="date"&&h&&u.jsxs("div",{className:"mt-3 space-y-3 rounded-md border border-border p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Customize Date Formats"}),u.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>p(!1),children:"Close"})]}),v.steps.map((T,O)=>{var V;const A=T.field.granularity;if(!A)return null;const P=CY(A),F=T.field.dateFormat||((V=P[0])==null?void 0:V.value);return u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-xs font-medium text-muted-foreground",children:T.field.label||j(A)}),u.jsxs(pt,{value:F,onValueChange:U=>{_(v,O,U)},children:[u.jsx(dt,{className:"h-8 text-xs",children:u.jsx(bt,{})}),u.jsx(ft,{children:P.map(U=>u.jsx(be,{value:U.value,className:"text-xs",children:U.label},U.value))})]}),F==="custom"&&u.jsxs("div",{className:"mt-2 space-y-1",children:[u.jsx(bn,{placeholder:"Enter custom format (e.g., YYYY-MM-DD)",value:T.field.customFormat||m[O]||"",onChange:U=>{D(v,O,U.target.value)},className:"h-8 text-xs"}),u.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Common tokens: YYYY (year), MM (month), DD (day), HH (hour), mm (minute)"})]})]},O)})]})]}):u.jsxs("div",{className:"rounded-md border border-dashed p-6 text-center",children:[u.jsx("p",{className:"mb-2 text-sm text-muted-foreground",children:"No hierarchies configured"}),u.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Create a hierarchy to define your drill path"}),u.jsxs(ie,{variant:"outline",size:"sm",onClick:S,children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Create hierarchy"]})]})]}),u.jsx(DOe,{open:l,onOpenChange:c,drillHierarchies:b,onUpdateHierarchies:N,availableFields:r})]})}function TOe({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:s=""}){const[o,i]=C.useState(""),a=e.filter(d=>d.label.toLowerCase().includes(o.toLowerCase())||d.qualifiedEntityName&&d.qualifiedEntityName.toLowerCase().includes(o.toLowerCase())),l=()=>{const d=[...new Set([...t,...a.map(f=>f.id)])];n(d)},c=()=>{const d=a.map(f=>f.id);n(t.filter(f=>!d.includes(f)))};return u.jsxs("div",{className:`space-y-2 ${s}`,children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx(bn,{placeholder:r,value:o,onChange:d=>i(d.target.value),className:"flex-1"}),u.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),u.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[u.jsx(ie,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),u.jsx(ie,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),u.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),u.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(d=>u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded p-2 text-xs hover:bg-muted/50",children:[u.jsx(gn,{checked:t.includes(d.id),onCheckedChange:f=>{n(f?[...t,d.id]:t.filter(h=>h!==d.id))}}),u.jsx("span",{className:"font-medium",children:d.label})]},d.id))}),o&&a.length===0&&u.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',o,'"']})]})}const ROe=e=>["string","boolean"].includes(Jl(e.dataType));function IOe({interaction:e,availableFields:t,onUpdate:n}){var i;const r=t.filter(ROe),s=((i=e.availableFields)==null?void 0:i.map(a=>a.id))||[],o=a=>{const l=r.filter(c=>a.includes(c.id));n({...e,availableFields:l})};return u.jsx("div",{className:"space-y-4",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{children:"Available dimensions"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically"}),u.jsx(TOe,{fields:r,selectedFieldIds:s,onSelectionChange:o,searchPlaceholder:"Search fields..."}),s.length===0&&u.jsx("p",{className:"text-xs text-amber-600",children:"⚠️ Please select at least one field"})]})})}function AOe({value:e,onChange:t}){const[n,r]=C.useState(!1),[s,o]=C.useState(""),[i,a]=C.useState("all"),{currentUser:l}=Io(),{data:c,isLoading:d}=uj(Wt.DASHBOARD,s),f=(c==null?void 0:c.dashboards)||[],h=f.filter(g=>i==="me"?g.ownership.createdBy.userId===(l==null?void 0:l.id):!0),p=f.find(g=>g.id===e),m=g=>{t(g.id,g.title),r(!1),o("")};return u.jsxs(Ds,{open:n,onOpenChange:r,children:[u.jsx(Ms,{asChild:!0,children:u.jsx(ie,{variant:"outline",className:K("w-full justify-start text-left font-normal",!e&&"text-muted-foreground"),children:p?u.jsx("span",{className:"truncate",children:p.title}):"Choose dashboard..."})}),u.jsx(Ts,{className:"w-[500px] p-0",align:"start",children:u.jsxs(lo,{value:i,onValueChange:g=>a(g),children:[u.jsx("div",{className:"p-3 border-b",children:u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{placeholder:"Search all dashboards...",value:s,onChange:g=>o(g.target.value),className:"pl-9"})]})}),u.jsxs(Os,{className:"w-full justify-start rounded-none border-b bg-transparent p-0",children:[u.jsx(mn,{value:"me",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"created by me"}),u.jsx(mn,{value:"all",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"all"})]}),u.jsx(lr,{value:i,className:"mt-0",children:u.jsx(Rs,{className:"h-[300px]",children:d?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"Loading dashboards..."}):h.length===0?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:s?`No dashboards found matching "${s}"`:i==="me"?"No dashboards created by you":"No dashboards available"}):u.jsx("div",{className:"p-2",children:h.map(g=>u.jsxs("button",{onClick:()=>m(g),className:K("w-full flex items-start gap-3 p-3 rounded-md hover:bg-muted/50 transition-colors text-left",e===g.id&&"bg-muted"),children:[u.jsx(M$,{className:"h-5 w-5 mt-0.5 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium text-sm truncate",children:g.title}),u.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:POe(g.createdAt)})]})]},g.id))})})})]})})]})}function POe(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()){const i=t.getHours(),a=t.getMinutes(),l=i>=12?"PM":"AM",c=i%12||12,d=a.toString().padStart(2,"0");return`TODAY AT ${c}:${d} ${l}`}const s=t.toLocaleString("en-US",{month:"short"}).toUpperCase(),o=t.getDate();return`${s} ${o}`}function OOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Target dashboard"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select which dashboard to navigate to when this interaction triggers"}),u.jsx(AOe,{value:e.targetDashboardId,onChange:(n,r)=>{const s={...e,targetDashboardId:n};!e.label&&r&&(s.label=r),t(s)}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Propagate Filters"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose what filters to pass to the target dashboard"}),u.jsxs(pt,{value:e.contextMode||"full",onValueChange:n=>t({...e,contextMode:n}),children:[u.jsx(dt,{children:u.jsxs(bt,{placeholder:"Choose context mode...",children:[e.contextMode==="interactionFilters"&&"Interaction Filters",(e.contextMode==="full"||!e.contextMode)&&"All Filters",e.contextMode==="none"&&"None"]})}),u.jsxs(ft,{children:[u.jsx(be,{value:"interactionFilters",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Interaction Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass only the clicked element as a filter"})]})}),u.jsx(be,{value:"full",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"All Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass current dashboard filters + clicked element"})]})}),u.jsx(be,{value:"none",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"None"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Navigate without passing any filters"})]})})]})]})]}),!e.targetDashboardId&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please select a target dashboard to complete this configuration"})}),e.targetDashboardId&&u.jsx("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:u.jsx("p",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Dashboard drill-through configured successfully"})}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function FOe({value:e,onChange:t}){const[n,r]=C.useState(!1),[s,o]=C.useState(""),[i,a]=C.useState("all"),{currentUser:l}=Io(),{data:c,isLoading:d}=uj(Wt.VISUAL,s),f=(c==null?void 0:c.visuals)||[],h=f.filter(g=>i==="me"?g.ownership.createdBy.userId===(l==null?void 0:l.id):!0),p=f.find(g=>g.id===e),m=g=>{t(g.id,g.title),r(!1),o("")};return u.jsxs(Ds,{open:n,onOpenChange:r,children:[u.jsx(Ms,{asChild:!0,children:u.jsx(ie,{variant:"outline",className:K("w-full justify-start text-left font-normal",!e&&"text-muted-foreground"),children:p?u.jsx("span",{className:"truncate",children:p.title}):"Choose insight..."})}),u.jsx(Ts,{className:"w-[500px] p-0",align:"start",children:u.jsxs(lo,{value:i,onValueChange:g=>a(g),children:[u.jsx("div",{className:"p-3 border-b",children:u.jsxs("div",{className:"relative",children:[u.jsx(ec,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),u.jsx(bn,{placeholder:"Search all insights...",value:s,onChange:g=>o(g.target.value),className:"pl-9"})]})}),u.jsxs(Os,{className:"w-full justify-start rounded-none border-b bg-transparent p-0",children:[u.jsx(mn,{value:"me",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"created by me"}),u.jsx(mn,{value:"all",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"all"})]}),u.jsx(lr,{value:i,className:"mt-0",children:u.jsx(Rs,{className:"h-[300px]",children:d?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"Loading insights..."}):h.length===0?u.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:s?`No insights found matching "${s}"`:i==="me"?"No insights created by you":"No insights available"}):u.jsx("div",{className:"p-2",children:h.map(g=>u.jsxs("button",{onClick:()=>m(g),className:K("w-full flex items-start gap-3 p-3 rounded-md hover:bg-muted/50 transition-colors text-left",e===g.id&&"bg-muted"),children:[u.jsx(jg,{className:"h-5 w-5 mt-0.5 text-muted-foreground flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium text-sm truncate",children:g.title}),u.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:$Oe(g.createdAt)})]})]},g.id))})})})]})})]})}function $Oe(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()){const i=t.getHours(),a=t.getMinutes(),l=i>=12?"PM":"AM",c=i%12||12,d=a.toString().padStart(2,"0");return`TODAY AT ${c}:${d} ${l}`}const s=t.toLocaleString("en-US",{month:"short"}).toUpperCase(),o=t.getDate();return`${s} ${o}`}function LOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Target insight"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select the saved insight to navigate to"}),u.jsx(FOe,{value:e.targetInsightId,onChange:(n,r)=>{const s={...e,targetInsightId:n};!e.label&&r&&(s.label=r),t(s)}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Propagate Filters"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose what filters to pass to the insight"}),u.jsxs(pt,{value:e.contextMode||"full",onValueChange:n=>t({...e,contextMode:n}),children:[u.jsx(dt,{children:u.jsxs(bt,{placeholder:"Choose context mode...",children:[e.contextMode==="interactionFilters"&&"Interaction Filters",(e.contextMode==="full"||!e.contextMode)&&"All Filters",e.contextMode==="none"&&"None"]})}),u.jsxs(ft,{children:[u.jsx(be,{value:"interactionFilters",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Interaction Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass only the clicked element as a filter"})]})}),u.jsx(be,{value:"full",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"All Filters"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass all current filters and selections"})]})}),u.jsx(be,{value:"none",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"None"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Open insight without any filters"})]})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Display mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose how the insight should be displayed"}),u.jsxs(pt,{value:e.displayMode||"modal",onValueChange:n=>t({...e,displayMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose display mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"modal",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Open in modal"})})}),u.jsx(be,{value:"replace-card",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Replace the card"})})})]})]})]}),!e.targetInsightId&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please enter a target insight ID to complete this configuration"})}),e.targetInsightId&&u.jsx("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:u.jsx("p",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Insight drill-through configured successfully"})}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var PM="Switch",[zOe,yGe]=yr(PM),[BOe,VOe]=zOe(PM),NY=E.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:o,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=E.useState(null),m=at(t,v=>p(v)),g=E.useRef(!1),b=h?d||!!h.closest("form"):!0,[y=!1,x]=Mr({prop:s,defaultProp:o,onChange:c});return u.jsxs(BOe,{scope:n,checked:y,disabled:a,children:[u.jsx(Re.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":jY(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:we(e.onClick,v=>{x(w=>!w),b&&(g.current=v.isPropagationStopped(),g.current||v.stopPropagation())})}),b&&u.jsx(HOe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});NY.displayName=PM;var kY="SwitchThumb",EY=E.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,s=VOe(kY,n);return u.jsx(Re.span,{"data-state":jY(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:t})});EY.displayName=kY;var HOe=e=>{const{control:t,checked:n,bubbles:r=!0,...s}=e,o=E.useRef(null),i=nw(n),a=rw(t);return E.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function jY(e){return e?"checked":"unchecked"}var g1=NY,_Y=EY;const th=E.forwardRef(({className:e,...t},n)=>u.jsx(g1,{className:K("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(_Y,{className:K("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));th.displayName=g1.displayName;function UOe({interaction:e,availableFields:t=[],onUpdate:n}){const[r,s]=C.useState(null),o=l=>{const c=e.urlTemplate||"",d=`{{${l}}}`;if(r!==null){const f=c.slice(0,r),h=c.slice(r);n({...e,urlTemplate:f+d+h})}else n({...e,urlTemplate:c+d})},a=((e.urlTemplate||"").match(/\{\{([^}]+)\}\}/g)||[]).map(d=>d.replace(/[{}]/g,""));return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"URL template"}),u.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:["Enter the URL with ","{{field_name}}"," for parameters"]}),u.jsx(bn,{placeholder:"https://example.com/product/{{product_id}}",value:e.urlTemplate||"",onChange:l=>{n({...e,urlTemplate:l.target.value}),s(l.target.selectionStart)},onSelect:l=>{const c=l.target;s(c.selectionStart)}}),u.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 p-3 flex gap-2",children:[u.jsx(Bi,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:[u.jsx("div",{className:"font-medium mb-1",children:"Template syntax:"}),u.jsxs("div",{children:["Use ","{{field_name}}"," to insert field values"]}),u.jsxs("div",{className:"mt-1 text-blue-600 dark:text-blue-300",children:["Example: https://example.com?id=","{{product_id}}","&region=","{{region}}"]})]})]})]}),t.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Insert parameter"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select a field to insert into the URL template"}),u.jsx("div",{className:"flex gap-2",children:u.jsxs(pt,{onValueChange:o,children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose field..."})}),u.jsx(ft,{children:t.map(l=>u.jsx(be,{value:l.id,children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:l.role==="metric"?"123":"ABC"}),u.jsx("span",{children:l.label})]})},l.id))})]})}),a.length>0&&u.jsxs("div",{className:"mt-2",children:[u.jsx("div",{className:"text-xs font-medium mb-1",children:"Parameters in use:"}),u.jsx("div",{className:"flex flex-wrap gap-1",children:a.map((l,c)=>u.jsx("span",{className:"inline-flex items-center rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary",children:`{{${l}}}`},c))})]})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsxs(ae,{className:"text-sm font-medium flex items-center gap-2",children:["Open in new tab",u.jsx(ej,{className:"h-3 w-3"})]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Open the URL in a new browser tab"})]}),u.jsx(th,{checked:e.openInNewTab??!0,onCheckedChange:l=>n({...e,openInNewTab:l})})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"URL encode parameters"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically encode special characters in parameter values"})]}),u.jsx(th,{checked:e.encodeParameters??!0,onCheckedChange:l=>n({...e,encodeParameters:l})})]}),!e.urlTemplate&&u.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3",children:u.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:"⚠ Please enter a URL template to complete this configuration"})}),e.urlTemplate&&u.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:[u.jsx("div",{className:"flex items-start gap-2",children:u.jsx("span",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ URL drill-through configured successfully"})}),a.length>0&&u.jsxs("div",{className:"mt-2 text-xs text-green-700 dark:text-green-300",children:["Using ",a.length," parameter",a.length!==1?"s":"",":"," ",a.join(", ")]})]}),e.urlTemplate&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Preview"}),u.jsx("div",{className:"rounded-md bg-muted p-3",children:u.jsx("div",{className:"text-xs font-mono break-all",children:e.urlTemplate})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:l=>n({...e,label:l.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function WOe({interaction:e,onUpdate:t}){return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Fetch mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Choose when to load the detailed data"}),u.jsxs(pt,{value:e.fetchMode||"lazy",onValueChange:n=>t({...e,fetchMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose fetch mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"lazy",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Lazy loading"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Fetch data only when user clicks"})]})}),u.jsx(be,{value:"preloaded",children:u.jsxs("div",{className:"flex flex-col items-start gap-1 py-1",children:[u.jsx("span",{className:"font-medium",children:"Preloaded"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Fetch all data when dashboard loads"})]})})]})]}),u.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 p-3 flex gap-2",children:[u.jsx(Bi,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsx("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:e.fetchMode==="lazy"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium",children:"Lazy loading"}),u.jsx("div",{className:"mt-1",children:"Data is fetched on-demand when the user clicks. Best for large datasets or when detailed data isn't always needed."})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium",children:"Preloaded"}),u.jsx("div",{className:"mt-1",children:"Data is fetched when the dashboard loads. Best for small datasets or when instant drill-down is required."})]})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Record limit"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Maximum number of detailed records to show (0 for unlimited)"}),u.jsx(bn,{type:"number",min:"0",placeholder:"100",value:e.inlineLimit??100,onChange:n=>{const r=parseInt(n.target.value)||0;t({...e,inlineLimit:r})}})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Display mode"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"How to display the detailed records"}),u.jsxs(pt,{value:e.displayMode||"table",onValueChange:n=>t({...e,displayMode:n}),children:[u.jsx(dt,{children:u.jsx(bt,{placeholder:"Choose display mode..."})}),u.jsxs(ft,{children:[u.jsx(be,{value:"table",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Table view"})})}),u.jsx(be,{value:"list",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"List view"})})}),u.jsx(be,{value:"cards",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{children:"Card view"})})})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Show in modal"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display detailed records in a modal overlay"})]}),u.jsx(th,{checked:e.showInModal??!1,onCheckedChange:n=>t({...e,showInModal:n})})]}),u.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3 bg-background",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Allow export"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable users to export the detailed records"})]}),u.jsx(th,{checked:e.allowExport??!0,onCheckedChange:n=>t({...e,allowExport:n})})]}),u.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 p-3",children:[u.jsx("div",{className:"text-xs text-green-800 dark:text-green-200",children:"✓ Inline drill configured successfully"}),u.jsxs("div",{className:"mt-2 space-y-1 text-xs text-green-700 dark:text-green-300",children:[u.jsxs("div",{children:["Mode: ",e.fetchMode==="lazy"?"Lazy loading":"Preloaded"]}),u.jsxs("div",{children:["Limit: ",e.inlineLimit===0?"Unlimited":`${e.inlineLimit} records`]}),u.jsxs("div",{children:["Display: ",e.displayMode==="table"?"Table view":e.displayMode==="list"?"List view":"Card view"]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:n=>t({...e,label:n.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}function qOe({interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i,onRemove:a}){const l=e.trigger!==void 0,c=e.mode!==void 0,d=l&&c,[f,h]=C.useState(!d),p=()=>{var y;if(!l)return"Configure interaction";const g=`When ${((y=e.trigger)==null?void 0:y.field.label)||"..."}`;if(!c)return`${g} → Choose action`;const b=e.label||ad(e.mode);return`${g} → ${b}`},m=c?q0(e.mode):null;return u.jsxs(ei,{className:"relative p-0",children:[u.jsx(ie,{variant:"ghost",size:"sm",className:"absolute right-2 top-2 z-10 h-8 w-8 p-0",onClick:a,"aria-label":"Remove interaction",children:u.jsx(Xt,{className:"h-3 w-3"})}),u.jsxs(zu,{open:f,onOpenChange:h,children:[u.jsx(Bu,{asChild:!0,children:u.jsxs(ie,{variant:"ghost",className:"h-auto w-full justify-between p-4 pr-12 hover:bg-muted/50",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[m&&u.jsx(m,{className:"h-4 w-4 flex-shrink-0"}),u.jsx("span",{className:"text-left text-sm font-medium",children:p()})]}),f?u.jsx(rj,{className:"h-3 w-3 flex-shrink-0"}):u.jsx(Tv,{className:"h-3 w-3 flex-shrink-0"})]})}),u.jsx(Vu,{children:u.jsxs("div",{className:"space-y-6 border-t p-6",children:[u.jsx("div",{className:"space-y-3",children:l?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"text-sm font-medium",children:["When I click on"," ",u.jsx("span",{className:"text-muted-foreground",children:"(value of)"})]}),e.trigger&&u.jsxs("div",{className:"inline-flex cursor-pointer items-center gap-2 rounded-md border bg-background px-3 py-2 hover:bg-muted/50",onClick:()=>{i({...e,trigger:void 0})},children:[Y0(e.trigger.field.dataType),u.jsx("span",{className:"text-sm font-medium",children:e.trigger.field.label})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-sm font-medium",children:"When I click on"}),u.jsx(nAe,{value:e.trigger,onChange:g=>{i({...e,trigger:g})},metrics:t,attributes:n})]})}),l&&u.jsx(u.Fragment,{children:u.jsxs("div",{className:"space-y-3",children:[u.jsx("div",{className:"text-sm font-medium",children:"I want to"}),u.jsx(rAe,{value:e.mode,onChange:g=>{if(!e.trigger){console.error("Trigger must be defined before selecting action");return}const b={mode:g,trigger:e.trigger};switch(g){case"clickFilter":i({...b,mode:"clickFilter",filterFields:[]});break;case"drillDown":i({...b,mode:"drillDown",filterFields:[]});break;case"dynamicDrill":i({...b,mode:"dynamicDrill",availableFields:[]});break;case"drillThrough":i({...b,mode:"drillThrough",filterFields:[],targetDashboardId:""});break;case"drillToDetail":i({...b,mode:"drillToDetail",filterFields:[]});break;case"drillToURL":i({...b,mode:"drillToURL",filterFields:[],urlTemplate:""});break;case"inlineDrill":i({...b,mode:"inlineDrill",filterFields:[]});break}}})]})}),l&&c&&u.jsxs(u.Fragment,{children:[u.jsx(ri,{}),u.jsx(YOe,{interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i})]})]})})]})]})}function YOe({interaction:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:i}){switch(e.mode){case"clickFilter":return u.jsx(sAe,{interaction:e,onUpdate:a=>i(a)});case"drillDown":return u.jsx(MOe,{interaction:e,onUpdate:a=>i(a),card:s,availableFields:r,onUpdateHierarchies:o});case"dynamicDrill":return u.jsx(IOe,{interaction:e,onUpdate:a=>i(a),availableFields:r});case"drillThrough":return u.jsx(OOe,{interaction:e,onUpdate:a=>i(a)});case"drillToDetail":return u.jsx(LOe,{interaction:e,onUpdate:a=>i(a)});case"drillToURL":return u.jsx(UOe,{interaction:e,availableFields:[...t,...n],onUpdate:a=>i(a)});case"inlineDrill":return u.jsx(WOe,{interaction:e,onUpdate:a=>i(a)});default:return u.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown interaction type"})}}function GOe({interactions:e,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onChange:i}){const[a,l]=C.useState(null),c=()=>{const h={};i([...e,h]),l(e.length)},d=(h,p)=>{const m=[...e];m[h]=p,i(m)},f=h=>{const p=e.filter((m,g)=>g!==h);i(p),a===h&&l(null)};return u.jsxs("div",{className:"space-y-4",children:[e.length>0?u.jsx("div",{className:"space-y-3",children:e.map((h,p)=>u.jsx(qOe,{interaction:h,metrics:t,attributes:n,availableFields:r,card:s,onUpdateHierarchies:o,onUpdate:m=>d(p,m),onRemove:()=>f(p)},p))}):u.jsx("div",{className:"border rounded-lg p-8 text-center bg-muted/30",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"No interactions configured"}),u.jsx("div",{className:"text-xs text-muted-foreground",children:'Click "Add Interaction" to create your first interaction'}),u.jsx("div",{className:"pt-2",children:u.jsxs(ie,{onClick:c,size:"sm",variant:"outline",children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add First Interaction"]})})]})}),e.length>0&&u.jsx("div",{className:"flex justify-start pt-2",children:u.jsxs(ie,{onClick:c,size:"sm",variant:"outline",children:[u.jsx(gr,{className:"mr-2 h-4 w-4"}),"Add Interaction"]})})]})}function ZOe(){var F,V,U;const{open:e,frameId:t,cardId:n,closePopover:r,anchorPosition:s}=Xj(),o=hse(),i=pse(),{updateCurrentDashboardCard:a}=Qt(),{setCard:l}=Gr(),c=te(z=>z.dashboard),d=((F=c==null?void 0:c.sheets)==null?void 0:F.flatMap(z=>z.frames||[]).find(z=>(z==null?void 0:z.id)===t))||null,f=d&&n?d.cards.find(z=>z.id===n):null;C.useEffect(()=>{e&&f&&l(f)},[e,f,l]);const{columns:h}=$L(),{metricFields:p,groupByFields:m,pivotByFields:g}=j3();[...m,...g];const b=h,y=p,x=[...m,...g],v=((V=o.interactionConfig)==null?void 0:V.drillHierarchies)||[],w=((U=o.interactionConfig)==null?void 0:U.allowedDrillTargets)||[],[S,N]=C.useState(v),[k,j]=C.useState(w||[]),[_,D]=C.useState(null),[M,T]=C.useState(()=>_i(o.interactionConfig));C.useRef(null),C.useEffect(()=>{var z,I;e&&(N(((z=o.interactionConfig)==null?void 0:z.drillHierarchies)||[]),j(((I=o.interactionConfig)==null?void 0:I.allowedDrillTargets)||[]),D(null),T(_i(o.interactionConfig)))},[e,o.interactionConfig]);const O=()=>{i.updateDrillHierarchies(S),i.updateAllowedDrillTargets(k);const z={...o,interactionConfig:{...o.interactionConfig,drillHierarchies:S,allowedDrillTargets:k,interactions:M}};a(z),l(z),r()},A=()=>{D(null),r()};if(!e||!t||!n||!f||!s)return null;const P={position:"fixed",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`};return u.jsxs(Ds,{modal:!0,open:e,onOpenChange:z=>!z&&r(),children:[u.jsx(Ms,{asChild:!0,children:u.jsx("div",{style:P,className:"pointer-events-none invisible","aria-hidden":"true"})}),u.jsxs(Ts,{onEscapeKeyDown:z=>z.preventDefault(),className:"mt-5 flex max-h-[70vh] w-[600px] max-w-4xl flex-col overflow-hidden p-0",align:"start",side:"right",sideOffset:20,children:[u.jsx(lke,{className:"fill-border",width:12,height:8}),u.jsxs("div",{className:"flex flex-col border-b px-6 py-4",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h2",{className:"text-lg font-semibold",children:"Configure Interactions"}),M.length>0&&u.jsx(jt,{variant:"default",className:"h-5 min-w-5 rounded-full px-1.5 text-xs",children:M.length})]}),u.jsxs("p",{className:"text-sm text-muted-foreground",children:["Set up drill behaviors for"," ",(f==null?void 0:f.title)||(o==null?void 0:o.title)||"this chart"]})]}),u.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:u.jsx("div",{className:"space-y-6 p-6",children:u.jsx("div",{children:u.jsx("div",{className:"grid grid-cols-1 gap-4",children:u.jsx(GOe,{interactions:M,metrics:y,attributes:x,availableFields:b,card:{...o,interactionConfig:{...o.interactionConfig,drillHierarchies:S}},onUpdateHierarchies:N,onChange:T})})})})}),u.jsxs("div",{className:"flex justify-end gap-2 border-t px-6 py-4",children:[u.jsx(ie,{variant:"outline",onClick:A,children:"Cancel"}),u.jsx(ie,{onClick:O,children:"Save Changes"})]})]})]})}const KOe=hI.WidthProvider(hI.Responsive);function XOe(){const{open:e}=Xj();return e?u.jsx(ZOe,{}):null}function QOe({sheet:e}){var y,x;const t=te(v=>v.isDashboardEditing),n=te(v=>v.currentBreakpoint),r=te(v=>v.themeStyle),s=te(v=>v.selectedSheetId),o=e.layouts,i=te(v=>v.dashboard.filters),a=e.frames,{setSheetLayouts:l,setCurrentBreakpoint:c}=te(v=>v.actions);C.useEffect(()=>{document.documentElement.style.setProperty("--placeholder-border-radius",`${r==null?void 0:r.cardBorderRadius}px`)},[r==null?void 0:r.cardBorderRadius]);function d(v){c(v)}function f(v,w){s===e.id&&l(s,w)}if(!s)return null;const h=(v,w)=>u.jsx(DY,{className:"after:content-none",ref:w,handleAxis:v}),p=v=>v&&(v==null?void 0:v.h)===1&&(v==null?void 0:v.w)===1?{...v,h:8,minH:7,w:7}:null;function m(){var w;const v=(w=Pg(i,s))==null?void 0:w.filter(S=>!S.hide);return v==null?void 0:v.map(S=>{var j;const N=(j=o==null?void 0:o[n])==null?void 0:j.find(_=>_.i===S.id);if(S.location==="frame")return null;const k=p(N);return u.jsxs("div",{style:{borderRadius:r==null?void 0:r.cardBorderRadius},className:K("z-50 flex flex-col rounded-md border bg-background px-3 py-2"),...k?{"data-grid":k}:{},children:[u.jsx(Iq,{filter:S}),u.jsx(hM,{filter:S})]},S.id)})}function g(){return a==null?void 0:a.map(v=>u.jsx("div",{role:"dashboard-frame-container",className:K("group isolate overflow-hidden",r==null?void 0:r.dashboardCardContainer),children:u.jsx(uc,{FallbackComponent:({error:w,resetErrorBoundary:S})=>u.jsx(DNe,{error:w,resetErrorBoundary:S,frame:v}),children:u.jsx(qIe,{frame:v})})},v.id))}const b=((y=r==null?void 0:r.gridLayout)==null?void 0:y.margin)||[10,10];return!a||a.length===0?u.jsx(tAe,{sheetId:e.id}):u.jsxs(lle,{children:[u.jsxs(KOe,{margin:b,isDraggable:t,resizeHandles:t?["sw","nw","ne","se","e","w"]:[],className:K((x=r==null?void 0:r.gridLayout)==null?void 0:x.className),layouts:o,cols:{lg:48,md:36,sm:24,xs:12,xxs:6},rowHeight:1,onBreakpointChange:d,onLayoutChange:f,resizeHandle:h,children:[m(),g()]}),u.jsx(XOe,{})]})}const DY=C.forwardRef(({className:e,handleAxis:t,...n},r)=>{const s=te(i=>i.themeStyle),o=(s==null?void 0:s.cardBorderRadius)||0;return u.jsx("div",{ref:r,className:K(`react-resizable-handle z-10 react-resizable-handle-${t} absolute border-foreground/40`,{"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-r-0":t==="nw"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-l-0":t==="ne"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-r-0 group-hover:border-t-0":t==="sw"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-l-0 group-hover:border-t-0":t==="se"&&o<11,"border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-l-0 group-hover:border-t-0":t==="e","border-foreground/40 group-hover:border-2 group-hover:border-b-0 group-hover:border-r-0 group-hover:border-t-0":t==="w"},e),...n})});DY.displayName="ResizeHandle";const{createElement:nh,createContext:JOe,forwardRef:MY,useCallback:bs,useContext:TY,useEffect:vu,useImperativeHandle:RY,useLayoutEffect:eFe,useMemo:tFe,useRef:Cs,useState:df}=E,VF=E[`useId${Math.random()}`.slice(0,5)],nFe=eFe,b1=JOe(null);b1.displayName="PanelGroupContext";const wu=nFe,rFe=typeof VF=="function"?VF:()=>null;let sFe=0;function OM(e=null){const t=rFe(),n=Cs(e||t||null);return n.current===null&&(n.current=""+sFe++),e??n.current}function IY({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:o,id:i,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:h,style:p,tagName:m="div",...g}){const b=TY(b1);if(b===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:x,getPanelSize:v,getPanelStyle:w,groupId:S,isPanelCollapsed:N,reevaluatePanelConstraints:k,registerPanel:j,resizePanel:_,unregisterPanel:D}=b,M=OM(i),T=Cs({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:a,minSize:l},id:M,idIsFromProps:i!==void 0,order:h});Cs({didLogMissingDefaultSizeWarning:!1}),wu(()=>{const{callbacks:A,constraints:P}=T.current,F={...P};T.current.id=M,T.current.idIsFromProps=i!==void 0,T.current.order=h,A.onCollapse=c,A.onExpand=d,A.onResize=f,P.collapsedSize=n,P.collapsible=r,P.defaultSize=s,P.maxSize=a,P.minSize=l,(F.collapsedSize!==P.collapsedSize||F.collapsible!==P.collapsible||F.maxSize!==P.maxSize||F.minSize!==P.minSize)&&k(T.current,F)}),wu(()=>{const A=T.current;return j(A),()=>{D(A)}},[h,M,j,D]),RY(o,()=>({collapse:()=>{y(T.current)},expand:A=>{x(T.current,A)},getId(){return M},getSize(){return v(T.current)},isCollapsed(){return N(T.current)},isExpanded(){return!N(T.current)},resize:A=>{_(T.current,A)}}),[y,x,v,N,M,_]);const O=w(T.current,s);return nh(m,{...g,children:e,className:t,id:i,style:{...O,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":S,"data-panel-id":M,"data-panel-size":parseFloat(""+O.flexGrow).toFixed(1)})}const AY=MY((e,t)=>nh(IY,{...e,forwardedRef:t}));IY.displayName="Panel";AY.displayName="forwardRef(Panel)";let tE=null,qc=null;function oFe(e,t){if(t){const n=(t&LY)!==0,r=(t&zY)!==0,s=(t&BY)!==0,o=(t&VY)!==0;if(n)return s?"se-resize":o?"ne-resize":"e-resize";if(r)return s?"sw-resize":o?"nw-resize":"w-resize";if(s)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function iFe(){qc!==null&&(document.head.removeChild(qc),tE=null,qc=null)}function ZC(e,t){const n=oFe(e,t);tE!==n&&(tE=n,qc===null&&(qc=document.createElement("style"),document.head.appendChild(qc)),qc.innerHTML=`*{cursor: ${n}!important;}`)}function PY(e){return e.type==="keydown"}function OY(e){return e.type.startsWith("pointer")}function FY(e){return e.type.startsWith("mouse")}function y1(e){if(OY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(FY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function aFe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function lFe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function cFe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:WF(e),b:WF(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Et(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:UF(HF(n.a)),b:UF(HF(n.b))};if(s.a===s.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let a=o.length;for(;a--;){const l=o[a];if(l===i.a)return 1;if(l===i.b)return-1}}return Math.sign(s.a-s.b)}const uFe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dFe(e){var t;const n=getComputedStyle((t=$Y(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function fFe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||dFe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uFe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function HF(e){let t=e.length;for(;t--;){const n=e[t];if(Et(n,"Missing node"),fFe(n))return n}return null}function UF(e){return e&&Number(getComputedStyle(e).zIndex)||0}function WF(e){const t=[];for(;e;)t.push(e),e=$Y(e);return t}function $Y(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const LY=1,zY=2,BY=4,VY=8,hFe=aFe()==="coarse";let Qo=[],ff=!1,hl=new Map,x1=new Map;const rg=new Set;function pFe(e,t,n,r,s){var o;const{ownerDocument:i}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},l=(o=hl.get(i))!==null&&o!==void 0?o:0;return hl.set(i,l+1),rg.add(a),ev(),function(){var d;x1.delete(e),rg.delete(a);const f=(d=hl.get(i))!==null&&d!==void 0?d:1;if(hl.set(i,f-1),ev(),f===1&&hl.delete(i),Qo.includes(a)){const h=Qo.indexOf(a);h>=0&&Qo.splice(h,1),$M(),s("up",!0,null)}}}function qF(e){const{target:t}=e,{x:n,y:r}=y1(e);ff=!0,FM({target:t,x:n,y:r}),ev(),Qo.length>0&&(tv("down",e),e.preventDefault(),e.stopPropagation())}function op(e){const{x:t,y:n}=y1(e);if(ff&&e.buttons===0&&(ff=!1,tv("up",e)),!ff){const{target:r}=e;FM({target:r,x:t,y:n})}tv("move",e),$M(),Qo.length>0&&e.preventDefault()}function Ed(e){const{target:t}=e,{x:n,y:r}=y1(e);x1.clear(),ff=!1,Qo.length>0&&e.preventDefault(),tv("up",e),FM({target:t,x:n,y:r}),$M(),ev()}function FM({target:e,x:t,y:n}){Qo.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),rg.forEach(s=>{const{element:o,hitAreaMargins:i}=s,a=o.getBoundingClientRect(),{bottom:l,left:c,right:d,top:f}=a,h=hFe?i.coarse:i.fine;if(t>=c-h&&t<=d+h&&n>=f-h&&n<=l+h){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&cFe(r,o)>0){let m=r,g=!1;for(;m&&!m.contains(o);){if(lFe(m.getBoundingClientRect(),a)){g=!0;break}m=m.parentElement}if(g)return}Qo.push(s)}})}function KC(e,t){x1.set(e,t)}function $M(){let e=!1,t=!1;Qo.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;x1.forEach(r=>{n|=r}),e&&t?ZC("intersection",n):e?ZC("horizontal",n):t?ZC("vertical",n):iFe()}function ev(){hl.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Ed),n.removeEventListener("pointerdown",qF),n.removeEventListener("pointerleave",op),n.removeEventListener("pointermove",op)}),window.removeEventListener("pointerup",Ed),window.removeEventListener("pointercancel",Ed),rg.size>0&&(ff?(Qo.length>0&&hl.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Ed),n.addEventListener("pointerleave",op),n.addEventListener("pointermove",op))}),window.addEventListener("pointerup",Ed),window.addEventListener("pointercancel",Ed)):hl.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",qF,{capture:!0}),n.addEventListener("pointermove",op))}))}function tv(e,t){rg.forEach(n=>{const{setResizeHandlerState:r}=n,s=Qo.includes(n);r(e,s,t)})}function mFe(){const[e,t]=df(0);return bs(()=>t(n=>n+1),[])}function Et(e,t){if(!e)throw console.error(t),Error(t)}const LM=10;function Uu(e,t,n=LM){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function wa(e,t,n=LM){return Uu(e,t,n)===0}function Ws(e,t,n){return Uu(e,t,n)===0}function gFe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=t[r];if(!Ws(s,o,n))return!1}return!0}function qd({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Et(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:o,maxSize:i=100,minSize:a=0}=r;if(Uu(n,a)<0)if(o){const l=(s+a)/2;Uu(n,l)<0?n=s:n=a}else n=a;return n=Math.min(i,n),n=parseFloat(n.toFixed(LM)),n}function kp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:o}){if(Ws(e,0))return t;const i=[...t],[a,l]=r;Et(a!=null,"Invalid first pivot index"),Et(l!=null,"Invalid second pivot index");let c=0;if(o==="keyboard"){{const f=e<0?l:a,h=n[f];Et(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:g=0}=h;if(m){const b=t[f];if(Et(b!=null,`Previous layout not found for panel index ${f}`),Ws(b,p)){const y=g-b;Uu(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:l,h=n[f];Et(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:g=0}=h;if(m){const b=t[f];if(Et(b!=null,`Previous layout not found for panel index ${f}`),Ws(b,g)){const y=b-p;Uu(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let h=e<0?l:a,p=0;for(;;){const g=t[h];Et(g!=null,`Previous layout not found for panel index ${h}`);const y=qd({panelConstraints:n,panelIndex:h,size:100})-g;if(p+=y,h+=f,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?a:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(c),m=t[h];Et(m!=null,`Previous layout not found for panel index ${h}`);const g=m-p,b=qd({panelConstraints:n,panelIndex:h,size:g});if(!Ws(m,b)&&(c+=m-b,i[h]=b,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(gFe(s,i))return s;{const f=e<0?l:a,h=t[f];Et(h!=null,`Previous layout not found for panel index ${f}`);const p=h+c,m=qd({panelConstraints:n,panelIndex:f,size:p});if(i[f]=m,!Ws(m,p)){let g=p-m,y=e<0?l:a;for(;y>=0&&y<n.length;){const x=i[y];Et(x!=null,`Previous layout not found for panel index ${y}`);const v=x+g,w=qd({panelConstraints:n,panelIndex:y,size:v});if(Ws(x,w)||(g-=w-x,i[y]=w),Ws(g,0))break;e>0?y--:y++}}}const d=i.reduce((f,h)=>h+f,0);return Ws(d,100)?i:s}function bFe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,o=0,i=0;const a=n[0];Et(a!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:m=100,minSize:g=0}=p;h===a?(r=g,s=m):(o+=g,i+=m)});const l=Math.min(s,100-o),c=Math.max(r,100-i),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function sg(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function HY(e,t,n=document){const s=sg(e,n).findIndex(o=>o.getAttribute("data-panel-resize-handle-id")===t);return s??null}function UY(e,t,n){const r=HY(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function WY(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function v1(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function yFe(e,t,n,r=document){var s,o,i,a;const l=v1(t,r),c=sg(e,r),d=l?c.indexOf(l):-1,f=(s=(o=n[d])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,h=(i=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&i!==void 0?i:null;return[f,h]}function xFe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:o,setLayout:i}){Cs({didWarnAboutMissingResizeHandle:!1}),wu(()=>{if(!o)return;const a=sg(n,o);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:d,valueNow:f}=bFe({layout:r,panelsArray:s,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const p=s[l];Et(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,s,o]),vu(()=>{if(!o)return;const a=t.current;Et(a,"Eager values not found");const{panelDataArray:l}=a,c=WY(n,o);Et(c!=null,`No group found for id "${n}"`);const d=sg(n,o);Et(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");Et(p,"Resize handle element has no handle id attribute");const[m,g]=yFe(n,p,l,o);if(m==null||g==null)return()=>{};const b=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const x=l.findIndex(v=>v.id===m);if(x>=0){const v=l[x];Et(v,`No panel data found for index ${x}`);const w=r[x],{collapsedSize:S=0,collapsible:N,minSize:k=0}=v.constraints;if(w!=null&&N){const j=kp({delta:Ws(w,S)?k-S:S-w,initialLayout:r,panelConstraints:l.map(_=>_.constraints),pivotIndices:UY(n,p,o),prevLayout:r,trigger:"keyboard"});r!==j&&i(j)}}break}}};return h.addEventListener("keydown",b),()=>{h.removeEventListener("keydown",b)}});return()=>{f.forEach(h=>h())}},[o,e,t,n,r,s,i])}function YF(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function qY(e,t){const n=e==="horizontal",{x:r,y:s}=y1(t);return n?r:s}function vFe(e,t,n,r,s){const o=n==="horizontal",i=v1(t,s);Et(i,`No resize handle element found for id "${t}"`);const a=i.getAttribute("data-panel-group-id");Et(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=qY(n,e),d=WY(a,s);Et(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),h=o?f.width:f.height;return(c-l)/h*100}function wFe(e,t,n,r,s,o){if(PY(e)){const i=n==="horizontal";let a=0;e.shiftKey?a=100:s!=null?a=s:a=10;let l=0;switch(e.key){case"ArrowDown":l=i?0:a;break;case"ArrowLeft":l=i?-a:0;break;case"ArrowRight":l=i?a:0;break;case"ArrowUp":l=i?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:vFe(e,t,n,r,o)}function SFe({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,s=100;for(let o=0;o<e.length;o++){const i=n[o];Et(i,`Panel constraints not found for index ${o}`);const{defaultSize:a}=i;a!=null&&(r++,t[o]=a,s-=a)}for(let o=0;o<e.length;o++){const i=n[o];Et(i,`Panel constraints not found for index ${o}`);const{defaultSize:a}=i;if(a!=null)continue;const l=e.length-r,c=s/l;r++,t[o]=c,s-=c}return t}function jd(e,t,n){t.forEach((r,s)=>{const o=e[s];Et(o,`Panel data not found for index ${s}`);const{callbacks:i,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:h,onExpand:p,onResize:m}=i;m&&m(r,f),d&&(h||p)&&(p&&(f==null||wa(f,c))&&!wa(r,c)&&p(),h&&(f==null||!wa(f,c))&&wa(r,c)&&h())}})}function Uy(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function CFe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:o=3}){const i=n[s];let a;return i==null?a=e!=null?e.toPrecision(o):"1":r.length===1?a="1":a=i.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function NFe(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function GF(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function YY(e){return`react-resizable-panels:${e}`}function GY(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:o}=t;return s?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function ZY(e,t){try{const n=YY(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function kFe(e,t,n){var r,s;const o=(r=ZY(e,n))!==null&&r!==void 0?r:{},i=GY(t);return(s=o[i])!==null&&s!==void 0?s:null}function EFe(e,t,n,r,s){var o;const i=YY(e),a=GY(t),l=(o=ZY(e,s))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function ZF({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Ws(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=100/r*i;n[o]=a}let s=0;for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=qd({panelConstraints:t,panelIndex:o,size:i});i!=a&&(s+=i-a,n[o]=a)}if(!Ws(s,0))for(let o=0;o<t.length;o++){const i=n[o];Et(i!=null,`No layout data found for index ${o}`);const a=i+s,l=qd({panelConstraints:t,panelIndex:o,size:a});if(i!==l&&(s-=l-i,n[o]=l,Ws(s,0)))break}return n}const jFe=100,Ep={getItem:e=>(GF(Ep),Ep.getItem(e)),setItem:(e,t)=>{GF(Ep),Ep.setItem(e,t)}},KF={};function KY({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:o=null,onLayout:i=null,keyboardResizeBy:a=null,storage:l=Ep,style:c,tagName:d="div",...f}){const h=OM(o),p=Cs(null),[m,g]=df(null),[b,y]=df([]),x=mFe(),v=Cs({}),w=Cs(new Map),S=Cs(0),N=Cs({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:a,onLayout:i,storage:l}),k=Cs({layout:b,panelDataArray:[],panelDataArrayChanged:!1});Cs({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),RY(s,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:R}=k.current;return R},setLayout:R=>{const{onLayout:W}=N.current,{layout:Y,panelDataArray:Z}=k.current,H=ZF({layout:R,panelConstraints:Z.map($=>$.constraints)});YF(Y,H)||(y(H),k.current.layout=H,W&&W(H),jd(Z,H,v.current))}}),[]),wu(()=>{N.current.autoSaveId=e,N.current.direction=r,N.current.dragState=m,N.current.id=h,N.current.onLayout=i,N.current.storage=l}),xFe({committedValuesRef:N,eagerValuesRef:k,groupId:h,layout:b,panelDataArray:k.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),vu(()=>{const{panelDataArray:R}=k.current;if(e){if(b.length===0||b.length!==R.length)return;let W=KF[e];W==null&&(W=NFe(EFe,jFe),KF[e]=W);const Y=[...R],Z=new Map(w.current);W(e,Y,Z,b,l)}},[e,b,l]),vu(()=>{});const j=bs(R=>{const{onLayout:W}=N.current,{layout:Y,panelDataArray:Z}=k.current;if(R.constraints.collapsible){const H=Z.map(ee=>ee.constraints),{collapsedSize:$=0,panelSize:q,pivotIndices:G}=Cc(Z,R,Y);if(Et(q!=null,`Panel size not found for panel "${R.id}"`),!wa(q,$)){w.current.set(R.id,q);const Q=Id(Z,R)===Z.length-1?q-$:$-q,ne=kp({delta:Q,initialLayout:Y,panelConstraints:H,pivotIndices:G,prevLayout:Y,trigger:"imperative-api"});Uy(Y,ne)||(y(ne),k.current.layout=ne,W&&W(ne),jd(Z,ne,v.current))}}},[]),_=bs((R,W)=>{const{onLayout:Y}=N.current,{layout:Z,panelDataArray:H}=k.current;if(R.constraints.collapsible){const $=H.map(oe=>oe.constraints),{collapsedSize:q=0,panelSize:G=0,minSize:ee=0,pivotIndices:Q}=Cc(H,R,Z),ne=W??ee;if(wa(G,q)){const oe=w.current.get(R.id),de=oe!=null&&oe>=ne?oe:ne,ke=Id(H,R)===H.length-1?G-de:de-G,ye=kp({delta:ke,initialLayout:Z,panelConstraints:$,pivotIndices:Q,prevLayout:Z,trigger:"imperative-api"});Uy(Z,ye)||(y(ye),k.current.layout=ye,Y&&Y(ye),jd(H,ye,v.current))}}},[]),D=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{panelSize:Z}=Cc(Y,R,W);return Et(Z!=null,`Panel size not found for panel "${R.id}"`),Z},[]),M=bs((R,W)=>{const{panelDataArray:Y}=k.current,Z=Id(Y,R);return CFe({defaultSize:W,dragState:m,layout:b,panelData:Y,panelIndex:Z})},[m,b]),T=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{collapsedSize:Z=0,collapsible:H,panelSize:$}=Cc(Y,R,W);return Et($!=null,`Panel size not found for panel "${R.id}"`),H===!0&&wa($,Z)},[]),O=bs(R=>{const{layout:W,panelDataArray:Y}=k.current,{collapsedSize:Z=0,collapsible:H,panelSize:$}=Cc(Y,R,W);return Et($!=null,`Panel size not found for panel "${R.id}"`),!H||Uu($,Z)>0},[]),A=bs(R=>{const{panelDataArray:W}=k.current;W.push(R),W.sort((Y,Z)=>{const H=Y.order,$=Z.order;return H==null&&$==null?0:H==null?-1:$==null?1:H-$}),k.current.panelDataArrayChanged=!0,x()},[x]);wu(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:R,onLayout:W,storage:Y}=N.current,{layout:Z,panelDataArray:H}=k.current;let $=null;if(R){const G=kFe(R,H,Y);G&&(w.current=new Map(Object.entries(G.expandToSizes)),$=G.layout)}$==null&&($=SFe({panelDataArray:H}));const q=ZF({layout:$,panelConstraints:H.map(G=>G.constraints)});YF(Z,q)||(y(q),k.current.layout=q,W&&W(q),jd(H,q,v.current))}}),wu(()=>{const R=k.current;return()=>{R.layout=[]}},[]);const P=bs(R=>{let W=!1;const Y=p.current;return Y&&window.getComputedStyle(Y,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(H){H.preventDefault();const $=p.current;if(!$)return()=>null;const{direction:q,dragState:G,id:ee,keyboardResizeBy:Q,onLayout:ne}=N.current,{layout:oe,panelDataArray:de}=k.current,{initialLayout:le}=G??{},ke=UY(ee,R,$);let ye=wFe(H,R,q,G,Q,$);const Pe=q==="horizontal";Pe&&W&&(ye=-ye);const Ve=de.map(Ne=>Ne.constraints),lt=kp({delta:ye,initialLayout:le??oe,panelConstraints:Ve,pivotIndices:ke,prevLayout:oe,trigger:PY(H)?"keyboard":"mouse-or-touch"}),ue=!Uy(oe,lt);(OY(H)||FY(H))&&S.current!=ye&&(S.current=ye,!ue&&ye!==0?Pe?KC(R,ye<0?LY:zY):KC(R,ye<0?BY:VY):KC(R,0)),ue&&(y(lt),k.current.layout=lt,ne&&ne(lt),jd(de,lt,v.current))}},[]),F=bs((R,W)=>{const{onLayout:Y}=N.current,{layout:Z,panelDataArray:H}=k.current,$=H.map(oe=>oe.constraints),{panelSize:q,pivotIndices:G}=Cc(H,R,Z);Et(q!=null,`Panel size not found for panel "${R.id}"`);const Q=Id(H,R)===H.length-1?q-W:W-q,ne=kp({delta:Q,initialLayout:Z,panelConstraints:$,pivotIndices:G,prevLayout:Z,trigger:"imperative-api"});Uy(Z,ne)||(y(ne),k.current.layout=ne,Y&&Y(ne),jd(H,ne,v.current))},[]),V=bs((R,W)=>{const{layout:Y,panelDataArray:Z}=k.current,{collapsedSize:H=0,collapsible:$}=W,{collapsedSize:q=0,collapsible:G,maxSize:ee=100,minSize:Q=0}=R.constraints,{panelSize:ne}=Cc(Z,R,Y);ne!=null&&($&&G&&wa(ne,H)?wa(H,q)||F(R,q):ne<Q?F(R,Q):ne>ee&&F(R,ee))},[F]),U=bs((R,W)=>{const{direction:Y}=N.current,{layout:Z}=k.current;if(!p.current)return;const H=v1(R,p.current);Et(H,`Drag handle element not found for id "${R}"`);const $=qY(Y,W);g({dragHandleId:R,dragHandleRect:H.getBoundingClientRect(),initialCursorPosition:$,initialLayout:Z})},[]),z=bs(()=>{g(null)},[]),I=bs(R=>{const{panelDataArray:W}=k.current,Y=Id(W,R);Y>=0&&(W.splice(Y,1),delete v.current[R.id],k.current.panelDataArrayChanged=!0,x())},[x]),B=tFe(()=>({collapsePanel:j,direction:r,dragState:m,expandPanel:_,getPanelSize:D,getPanelStyle:M,groupId:h,isPanelCollapsed:T,isPanelExpanded:O,reevaluatePanelConstraints:V,registerPanel:A,registerResizeHandle:P,resizePanel:F,startDragging:U,stopDragging:z,unregisterPanel:I,panelGroupElement:p.current}),[j,m,r,_,D,M,h,T,O,V,A,P,F,U,z,I]),L={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return nh(b1.Provider,{value:B},nh(d,{...f,children:t,className:n,id:o,ref:p,style:{...L,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const XY=MY((e,t)=>nh(KY,{...e,forwardedRef:t}));KY.displayName="PanelGroup";XY.displayName="forwardRef(PanelGroup)";function Id(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Cc(e,t,n){const r=Id(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function _Fe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){vu(()=>{if(e||n==null||r==null)return;const s=v1(t,r);if(s==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const a=s.getAttribute("data-panel-group-id");Et(a,`No group element found for id "${a}"`);const l=sg(a,r),c=HY(a,t,r);Et(c!==null,`No resize element found for id "${t}"`);const d=i.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[r,e,t,n])}function zM({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:o,onDragging:i,onFocus:a,style:l={},tabIndex:c=0,tagName:d="div",...f}){var h,p;const m=Cs(null),g=Cs({onDragging:i});vu(()=>{g.current.onDragging=i});const b=TY(b1);if(b===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:x,registerResizeHandle:v,startDragging:w,stopDragging:S,panelGroupElement:N}=b,k=OM(s),[j,_]=df("inactive"),[D,M]=df(!1),[T,O]=df(null),A=Cs({state:j});wu(()=>{A.current.state=j}),vu(()=>{if(n)O(null);else{const U=v(k);O(()=>U)}},[n,k,v]);const P=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,F=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return vu(()=>{if(n||T==null)return;const U=m.current;return Et(U,"Element ref not attached"),pFe(k,U,y,{coarse:P,fine:F},(I,B,L)=>{if(B)switch(I){case"down":{_("drag"),Et(L,'Expected event to be defined for "down" action'),w(k,L);const{onDragging:R}=g.current;R&&R(!0);break}case"move":{const{state:R}=A.current;R!=="drag"&&_("hover"),Et(L,'Expected event to be defined for "move" action'),T(L);break}case"up":{_("hover"),S();const{onDragging:R}=g.current;R&&R(!1);break}}else _("inactive")})},[P,y,n,F,v,k,T,w,S]),_Fe({disabled:n,handleId:k,resizeHandler:T,panelGroupElement:N}),nh(d,{...f,children:e,className:t,id:s,onBlur:()=>{M(!1),o==null||o()},onFocus:()=>{M(!0),a==null||a()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":y,"data-panel-group-id":x,"data-resize-handle":"","data-resize-handle-active":j==="drag"?"pointer":D?"keyboard":void 0,"data-resize-handle-state":j,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":k})}zM.displayName="PanelResizeHandle";const QY=({className:e,...t})=>u.jsx(XY,{className:K("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),nE=AY,DFe=({withHandle:e,className:t,...n})=>u.jsx(zM,{className:K("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:u.jsx(j$,{className:"h-2.5 w-2.5"})})}),MFe=({withHandle:e,className:t,onTabClick:n,open:r,...s})=>u.jsx(zM,{className:K("relative flex w-px items-start justify-end bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",{"justify-start":r},t),...s,children:e&&!1});function TFe({open:e,setOpen:t}){const n=te(o=>o.selectedSheetId),{deleteSheet:r}=Qt();function s(){n&&(r(n),t(!1))}return u.jsx(ZD,{open:e,onOpenChange:t,children:u.jsxs(Hw,{children:[u.jsxs(Uw,{children:[u.jsx(qw,{children:"Delete Sheet"}),u.jsx(Yw,{children:"Are you sure you want to delete this sheet along with all its cards? This action cannot be undone."})]}),u.jsxs(Ww,{children:[u.jsx(Zw,{children:"Cancel"}),u.jsx(Gw,{className:"bg-destructive hover:bg-destructive/90",onClick:s,children:"Delete"})]})]})})}function RFe({children:e}){return u.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function IFe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const AFe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PFe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,OFe={};function XF(e,t){return(OFe.jsx?PFe:AFe).test(e)}const FFe=/[ \t\n\f\r]/g;function $Fe(e){return typeof e=="object"?e.type==="text"?QF(e.value):!1:QF(e)}function QF(e){return e.replace(FFe,"")===""}class wb{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}wb.prototype.normal={};wb.prototype.property={};wb.prototype.space=void 0;function JY(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new wb(n,r,t)}function rE(e){return e.toLowerCase()}class Fs{constructor(t,n){this.attribute=n,this.property=t}}Fs.prototype.attribute="";Fs.prototype.booleanish=!1;Fs.prototype.boolean=!1;Fs.prototype.commaOrSpaceSeparated=!1;Fs.prototype.commaSeparated=!1;Fs.prototype.defined=!1;Fs.prototype.mustUseProperty=!1;Fs.prototype.number=!1;Fs.prototype.overloadedBoolean=!1;Fs.prototype.property="";Fs.prototype.spaceSeparated=!1;Fs.prototype.space=void 0;let LFe=0;const gt=ld(),rr=ld(),eG=ld(),Ce=ld(),wn=ld(),hf=ld(),Vs=ld();function ld(){return 2**++LFe}const sE=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:rr,commaOrSpaceSeparated:Vs,commaSeparated:hf,number:Ce,overloadedBoolean:eG,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),XC=Object.keys(sE);class BM extends Fs{constructor(t,n,r,s){let o=-1;if(super(t,n),JF(this,"space",s),typeof r=="number")for(;++o<XC.length;){const i=XC[o];JF(this,XC[o],(r&sE[i])===sE[i])}}}BM.prototype.defined=!0;function JF(e,t,n){n&&(e[t]=n)}function Ph(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new BM(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[rE(r)]=r,n[rE(o.attribute)]=r}return new wb(t,n,e.space)}const tG=Ph({properties:{ariaActiveDescendant:null,ariaAtomic:rr,ariaAutoComplete:null,ariaBusy:rr,ariaChecked:rr,ariaColCount:Ce,ariaColIndex:Ce,ariaColSpan:Ce,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:rr,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:rr,ariaFlowTo:wn,ariaGrabbed:rr,ariaHasPopup:null,ariaHidden:rr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:Ce,ariaLive:null,ariaModal:rr,ariaMultiLine:rr,ariaMultiSelectable:rr,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:Ce,ariaPressed:rr,ariaReadOnly:rr,ariaRelevant:null,ariaRequired:rr,ariaRoleDescription:wn,ariaRowCount:Ce,ariaRowIndex:Ce,ariaRowSpan:Ce,ariaSelected:rr,ariaSetSize:Ce,ariaSort:null,ariaValueMax:Ce,ariaValueMin:Ce,ariaValueNow:Ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function nG(e,t){return t in e?e[t]:t}function rG(e,t){return nG(e,t.toLowerCase())}const zFe=Ph({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hf,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:wn,autoFocus:gt,autoPlay:gt,blocking:wn,capture:null,charSet:null,checked:gt,cite:null,className:wn,cols:Ce,colSpan:null,content:null,contentEditable:rr,controls:gt,controlsList:wn,coords:Ce|hf,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:eG,draggable:rr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:wn,height:Ce,hidden:gt,high:Ce,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:wn,itemRef:wn,itemScope:gt,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Ce,manifest:null,max:null,maxLength:Ce,media:null,method:null,min:null,minLength:Ce,multiple:gt,muted:gt,name:null,nonce:null,noModule:gt,noValidate:gt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:gt,optimum:Ce,pattern:null,ping:wn,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:wn,required:gt,reversed:gt,rows:Ce,rowSpan:Ce,sandbox:wn,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shape:null,size:Ce,sizes:null,slot:null,span:Ce,spellCheck:rr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ce,step:null,style:null,tabIndex:Ce,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:rr,width:Ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:Ce,borderColor:null,bottomMargin:Ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gt,declare:gt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ce,leftMargin:Ce,link:null,longDesc:null,lowSrc:null,marginHeight:Ce,marginWidth:Ce,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ce,rules:null,scheme:null,scrolling:rr,standby:null,summary:null,text:null,topMargin:Ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:gt,disableRemotePlayback:gt,prefix:null,property:null,results:Ce,security:null,unselectable:null},space:"html",transform:rG}),BFe=Ph({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Vs,accentHeight:Ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ce,amplitude:Ce,arabicForm:null,ascent:Ce,attributeName:null,attributeType:null,azimuth:Ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ce,by:null,calcMode:null,capHeight:Ce,className:wn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ce,diffuseConstant:Ce,direction:null,display:null,dur:null,divisor:Ce,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ce,enableBackground:null,end:null,event:null,exponent:Ce,externalResourcesRequired:null,fill:null,fillOpacity:Ce,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hf,g2:hf,glyphName:hf,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ce,horizOriginX:Ce,horizOriginY:Ce,id:null,ideographic:Ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ce,k:Ce,k1:Ce,k2:Ce,k3:Ce,k4:Ce,kernelMatrix:Vs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ce,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ce,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ce,overlineThickness:Ce,paintOrder:null,panose1:null,path:null,pathLength:Ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ce,pointsAtY:Ce,pointsAtZ:Ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vs,rev:Vs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vs,requiredFeatures:Vs,requiredFonts:Vs,requiredFormats:Vs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ce,specularExponent:Ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ce,strikethroughThickness:Ce,string:null,stroke:null,strokeDashArray:Vs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ce,strokeOpacity:Ce,strokeWidth:null,style:null,surfaceScale:Ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Vs,tabIndex:Ce,tableValues:null,target:null,targetX:Ce,targetY:Ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Vs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ce,underlineThickness:Ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ce,values:null,vAlphabetic:Ce,vMathematical:Ce,vectorEffect:null,vHanging:Ce,vIdeographic:Ce,version:null,vertAdvY:Ce,vertOriginX:Ce,vertOriginY:Ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:nG}),sG=Ph({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),oG=Ph({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rG}),iG=Ph({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),VFe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},HFe=/[A-Z]/g,e5=/-[a-z]/g,UFe=/^data[-\w.:]+$/i;function WFe(e,t){const n=rE(t);let r=t,s=Fs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&UFe.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(e5,YFe);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!e5.test(o)){let i=o.replace(HFe,qFe);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=BM}return new s(r,t)}function qFe(e){return"-"+e.toLowerCase()}function YFe(e){return e.charAt(1).toUpperCase()}const GFe=JY([tG,zFe,sG,oG,iG],"html"),VM=JY([tG,BFe,sG,oG,iG],"svg");function ZFe(e){return e.join(" ").trim()}var HM={},t5=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,KFe=/\n/g,XFe=/^\s*/,QFe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,JFe=/^:\s*/,e5e=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,t5e=/^[;\s]*/,n5e=/^\s+|\s+$/g,r5e=`
915
915
  `,n5="/",r5="*",$c="",s5e="comment",o5e="declaration",i5e=function(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(m){var g=m.match(KFe);g&&(n+=g.length);var b=m.lastIndexOf(r5e);r=~b?m.length-b:r+m.length}function o(){var m={line:n,column:r};return function(g){return g.position=new i(m),c(),g}}function i(m){this.start=m,this.end={line:n,column:r},this.source=t.source}i.prototype.content=e;function a(m){var g=new Error(t.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=t.source,g.line=n,g.column=r,g.source=e,!t.silent)throw g}function l(m){var g=m.exec(e);if(g){var b=g[0];return s(b),e=e.slice(b.length),g}}function c(){l(XFe)}function d(m){var g;for(m=m||[];g=f();)g!==!1&&m.push(g);return m}function f(){var m=o();if(!(n5!=e.charAt(0)||r5!=e.charAt(1))){for(var g=2;$c!=e.charAt(g)&&(r5!=e.charAt(g)||n5!=e.charAt(g+1));)++g;if(g+=2,$c===e.charAt(g-1))return a("End of comment missing");var b=e.slice(2,g-2);return r+=2,s(b),e=e.slice(g),r+=2,m({type:s5e,comment:b})}}function h(){var m=o(),g=l(QFe);if(g){if(f(),!l(JFe))return a("property missing ':'");var b=l(e5e),y=m({type:o5e,property:s5(g[0].replace(t5,$c)),value:b?s5(b[0].replace(t5,$c)):$c});return l(t5e),y}}function p(){var m=[];d(m);for(var g;g=h();)g!==!1&&(m.push(g),d(m));return m}return c(),p()};function s5(e){return e?e.replace(n5e,$c):$c}var a5e=Sa&&Sa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(HM,"__esModule",{value:!0});HM.default=c5e;var l5e=a5e(i5e);function c5e(e,t){var n=null;if(!e||typeof e!="string")return n;var r=(0,l5e.default)(e),s=typeof t=="function";return r.forEach(function(o){if(o.type==="declaration"){var i=o.property,a=o.value;s?t(i,a,o):a&&(n=n||{},n[i]=a)}}),n}var w1={};Object.defineProperty(w1,"__esModule",{value:!0});w1.camelCase=void 0;var u5e=/^--[a-zA-Z0-9_-]+$/,d5e=/-([a-z])/g,f5e=/^[^-]+$/,h5e=/^-(webkit|moz|ms|o|khtml)-/,p5e=/^-(ms)-/,m5e=function(e){return!e||f5e.test(e)||u5e.test(e)},g5e=function(e,t){return t.toUpperCase()},o5=function(e,t){return"".concat(t,"-")},b5e=function(e,t){return t===void 0&&(t={}),m5e(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(p5e,o5):e=e.replace(h5e,o5),e.replace(d5e,g5e))};w1.camelCase=b5e;var y5e=Sa&&Sa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},x5e=y5e(HM),v5e=w1;function oE(e,t){var n={};return!e||typeof e!="string"||(0,x5e.default)(e,function(r,s){r&&s&&(n[(0,v5e.camelCase)(r,t)]=s)}),n}oE.default=oE;var w5e=oE;const S5e=Ql(w5e),aG=lG("end"),UM=lG("start");function lG(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function C5e(e){const t=UM(e),n=aG(e);if(t&&n)return{start:t,end:n}}function am(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?i5(e.position):"start"in e||"end"in e?i5(e):"line"in e||"column"in e?iE(e):""}function iE(e){return a5(e&&e.line)+":"+a5(e&&e.column)}function i5(e){return iE(e&&e.start)+"-"+iE(e&&e.end)}function a5(e){return e&&typeof e=="number"?e:1}class Xr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(i=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=s,this.line=a?a.line:void 0,this.name=am(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}Xr.prototype.file="";Xr.prototype.name="";Xr.prototype.reason="";Xr.prototype.message="";Xr.prototype.stack="";Xr.prototype.column=void 0;Xr.prototype.line=void 0;Xr.prototype.ancestors=void 0;Xr.prototype.cause=void 0;Xr.prototype.fatal=void 0;Xr.prototype.place=void 0;Xr.prototype.ruleId=void 0;Xr.prototype.source=void 0;const WM={}.hasOwnProperty,N5e=new Map,k5e=/[A-Z]/g,E5e=new Set(["table","tbody","thead","tfoot","tr"]),j5e=new Set(["td","th"]),cG="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _5e(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=O5e(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=P5e(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?VM:GFe,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=uG(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function uG(e,t,n){if(t.type==="element")return D5e(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return M5e(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return R5e(e,t,n);if(t.type==="mdxjsEsm")return T5e(e,t);if(t.type==="root")return I5e(e,t,n);if(t.type==="text")return A5e(e,t)}function D5e(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=VM,e.schema=s),e.ancestors.push(t);const o=fG(e,t.tagName,!1),i=F5e(e,t);let a=YM(e,t);return E5e.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!$Fe(l):!0})),dG(e,i,o,t),qM(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function M5e(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}og(e,t.position)}function T5e(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);og(e,t.position)}function R5e(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=VM,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:fG(e,t.name,!0),i=$5e(e,t),a=YM(e,t);return dG(e,i,o,t),qM(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function I5e(e,t,n){const r={};return qM(r,YM(e,t)),e.create(t,e.Fragment,r,n)}function A5e(e,t){return t.value}function dG(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qM(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function P5e(e,t,n){return r;function r(s,o,i,a){const c=Array.isArray(i.children)?n:t;return a?c(o,i,a):c(o,i)}}function O5e(e,t){return n;function n(r,s,o,i){const a=Array.isArray(o.children),l=UM(r);return t(s,o,i,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function F5e(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&WM.call(t.properties,s)){const o=L5e(e,s,t.properties[s]);if(o){const[i,a]=o;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&j5e.has(t.tagName)?r=a:n[i]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function $5e(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const i=o.expression;i.type;const a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else og(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else og(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function YM(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:N5e;for(;++r<t.children.length;){const o=t.children[r];let i;if(e.passKeys){const l=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(l){const c=s.get(l)||0;i=l+"-"+c,s.set(l,c+1)}}const a=uG(e,o,i);a!==void 0&&n.push(a)}return n}function L5e(e,t,n){const r=WFe(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?IFe(n):ZFe(n)),r.property==="style"){let s=typeof n=="object"?n:z5e(e,String(n));return e.stylePropertyNameCase==="css"&&(s=B5e(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?VFe[r.property]||r.property:r.attribute,n]}}function z5e(e,t){try{return S5e(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Xr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=cG+"#cannot-parse-style-attribute",s}}function fG(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,i;for(;++o<s.length;){const a=XF(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=i}else r=XF(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return WM.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);og(e)}function og(e,t){const n=new Xr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=cG+"#cannot-handle-mdx-estrees-without-createevaluater",n}function B5e(e){const t={};let n;for(n in e)WM.call(e,n)&&(t[V5e(n)]=e[n]);return t}function V5e(e){let t=e.replace(k5e,H5e);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function H5e(e){return"-"+e.toLowerCase()}const QC={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},U5e={};function GM(e,t){const n=U5e,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return hG(e,r,s)}function hG(e,t,n){if(W5e(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return l5(e.children,t,n)}return Array.isArray(e)?l5(e,t,n):""}function l5(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=hG(e[s],t,n);return r.join("")}function W5e(e){return!!(e&&typeof e=="object")}const c5=document.createElement("i");function ZM(e){const t="&"+e+";";c5.innerHTML=t;const n=c5.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Qs(e,t,n,r){const s=e.length;let o=0,i;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)i=r.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function vo(e,t){return e.length>0?(Qs(e,e.length,0,t),e):t}const u5={}.hasOwnProperty;function pG(e){const t={};let n=-1;for(;++n<e.length;)q5e(t,e[n]);return t}function q5e(e,t){let n;for(n in t){const s=(u5.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){u5.call(s,i)||(s[i]=[]);const a=o[i];Y5e(s[i],Array.isArray(a)?a:a?[a]:[])}}}function Y5e(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Qs(e,0,0,r)}function mG(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Jo(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const as=fc(/[A-Za-z]/),Wr=fc(/[\dA-Za-z]/),G5e=fc(/[#-'*+\--9=?A-Z^-~]/);function nv(e){return e!==null&&(e<32||e===127)}const aE=fc(/\d/),Z5e=fc(/[\dA-Fa-f]/),K5e=fc(/[!-/:-@[-`{-~]/);function Ge(e){return e!==null&&e<-2}function yn(e){return e!==null&&(e<0||e===32)}function At(e){return e===-2||e===-1||e===32}const S1=fc(new RegExp("\\p{P}|\\p{S}","u")),Wu=fc(/\s/);function fc(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Oh(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let i="";if(o===37&&Wr(e.charCodeAt(n+1))&&Wr(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(i=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(i=String.fromCharCode(o,a),s=1):i="�"}else i=String.fromCharCode(o);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+s+1,i=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Ht(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return i;function i(l){return At(l)?(e.enter(n),a(l)):t(l)}function a(l){return At(l)&&o++<s?(e.consume(l),a):(e.exit(n),t(l))}}const X5e={tokenize:Q5e};function Q5e(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ht(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,i(a)}function i(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Ge(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),i)}}const J5e={tokenize:e4e},d5={tokenize:t4e};function e4e(e){const t=this,n=[];let r=0,s,o,i;return a;function a(v){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(v)}return c(v)}function l(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&x();const w=t.events.length;let S=w,N;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){N=t.events[S][1].end;break}y(r);let k=w;for(;k<t.events.length;)t.events[k][1].end={...N},k++;return Qs(t.events,S+1,0,t.events.slice(w)),t.events.length=k,c(v)}return a(v)}function c(v){if(r===n.length){if(!s)return h(v);if(s.currentConstruct&&s.currentConstruct.concrete)return m(v);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(d5,d,f)(v)}function d(v){return s&&x(),y(r),h(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,i=t.now().offset,m(v)}function h(v){return t.containerState={},e.attempt(d5,p,m)(v)}function p(v){return r++,n.push([t.currentConstruct,t.containerState]),h(v)}function m(v){if(v===null){s&&x(),y(0),e.consume(v);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),g(v)}function g(v){if(v===null){b(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return Ge(v)?(e.consume(v),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(v),g)}function b(v,w){const S=t.sliceStream(v);if(w&&S.push(null),v.previous=o,o&&(o.next=v),o=v,s.defineSkip(v.start),s.write(S),t.parser.lazy[v.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<i&&(!s.events[N][1].end||s.events[N][1].end.offset>i))return;const k=t.events.length;let j=k,_,D;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(_){D=t.events[j][1].end;break}_=!0}for(y(r),N=k;N<t.events.length;)t.events[N][1].end={...D},N++;Qs(t.events,j+1,0,t.events.slice(k)),t.events.length=N}}function y(v){let w=n.length;for(;w-- >v;){const S=n[w];t.containerState=S[1],S[0].exit.call(t,e)}n.length=v}function x(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function t4e(e,t,n){return Ht(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function rh(e){if(e===null||yn(e)||Wu(e))return 1;if(S1(e))return 2}function C1(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const lE={name:"attention",resolveAll:n4e,tokenize:r4e};function n4e(e,t){let n=-1,r,s,o,i,a,l,c,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};f5(f,-l),f5(h,l),i={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},o={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...i.start},end:{...a.end}},e[r][1].end={...i.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=vo(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=vo(c,[["enter",s,t],["enter",i,t],["exit",i,t],["enter",o,t]]),c=vo(c,C1(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=vo(c,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,c=vo(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Qs(e,r-1,n-r+3,c),n=r+c.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function r4e(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=rh(r);let o;return i;function i(l){return o=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===o)return e.consume(l),a;const c=e.exit("attentionSequence"),d=rh(l),f=!d||d===2&&s||n.includes(l),h=!s||s===2&&d||n.includes(r);return c._open=!!(o===42?f:f&&(s||!h)),c._close=!!(o===42?h:h&&(d||!f)),t(l)}}function f5(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const s4e={name:"autolink",tokenize:o4e};function o4e(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return as(p)?(e.consume(p),i):p===64?n(p):c(p)}function i(p){return p===43||p===45||p===46||Wr(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Wr(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||nv(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),d):G5e(p)?(e.consume(p),c):n(p)}function d(p){return Wr(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Wr(p))&&r++<63){const m=p===45?h:f;return e.consume(p),m}return n(p)}}const Sb={partial:!0,tokenize:i4e};function i4e(e,t,n){return r;function r(o){return At(o)?Ht(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Ge(o)?t(o):n(o)}}const gG={continuation:{tokenize:l4e},exit:c4e,name:"blockQuote",tokenize:a4e};function a4e(e,t,n){const r=this;return s;function s(i){if(i===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),o}return n(i)}function o(i){return At(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function l4e(e,t,n){const r=this;return s;function s(i){return At(i)?Ht(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):o(i)}function o(i){return e.attempt(gG,t,n)(i)}}function c4e(e){e.exit("blockQuote")}const bG={name:"characterEscape",tokenize:u4e};function u4e(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return K5e(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const yG={name:"characterReference",tokenize:d4e};function d4e(e,t,n){const r=this;let s=0,o,i;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),o=31,i=Wr,d(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=Z5e,d):(e.enter("characterReferenceValue"),o=7,i=aE,d(f))}function d(f){if(f===59&&s){const h=e.exit("characterReferenceValue");return i===Wr&&!ZM(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(f)&&s++<o?(e.consume(f),d):n(f)}}const h5={partial:!0,tokenize:h4e},p5={concrete:!0,name:"codeFenced",tokenize:f4e};function f4e(e,t,n){const r=this,s={partial:!0,tokenize:S};let o=0,i=0,a;return l;function l(N){return c(N)}function c(N){const k=r.events[r.events.length-1];return o=k&&k[1].type==="linePrefix"?k[2].sliceSerialize(k[1],!0).length:0,a=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(N)}function d(N){return N===a?(i++,e.consume(N),d):i<3?n(N):(e.exit("codeFencedFenceSequence"),At(N)?Ht(e,f,"whitespace")(N):f(N))}function f(N){return N===null||Ge(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(h5,g,w)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(N))}function h(N){return N===null||Ge(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):At(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,p,"whitespace")(N)):N===96&&N===a?n(N):(e.consume(N),h)}function p(N){return N===null||Ge(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(N))}function m(N){return N===null||Ge(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===a?n(N):(e.consume(N),m)}function g(N){return e.attempt(s,w,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y}function y(N){return o>0&&At(N)?Ht(e,x,"linePrefix",o+1)(N):x(N)}function x(N){return N===null||Ge(N)?e.check(h5,g,w)(N):(e.enter("codeFlowValue"),v(N))}function v(N){return N===null||Ge(N)?(e.exit("codeFlowValue"),x(N)):(e.consume(N),v)}function w(N){return e.exit("codeFenced"),t(N)}function S(N,k,j){let _=0;return D;function D(P){return N.enter("lineEnding"),N.consume(P),N.exit("lineEnding"),M}function M(P){return N.enter("codeFencedFence"),At(P)?Ht(N,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):T(P)}function T(P){return P===a?(N.enter("codeFencedFenceSequence"),O(P)):j(P)}function O(P){return P===a?(_++,N.consume(P),O):_>=i?(N.exit("codeFencedFenceSequence"),At(P)?Ht(N,A,"whitespace")(P):A(P)):j(P)}function A(P){return P===null||Ge(P)?(N.exit("codeFencedFence"),k(P)):j(P)}}}function h4e(e,t,n){const r=this;return s;function s(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}const JC={name:"codeIndented",tokenize:m4e},p4e={partial:!0,tokenize:g4e};function m4e(e,t,n){const r=this;return s;function s(c){return e.enter("codeIndented"),Ht(e,o,"linePrefix",5)(c)}function o(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(c):n(c)}function i(c){return c===null?l(c):Ge(c)?e.attempt(p4e,i,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Ge(c)?(e.exit("codeFlowValue"),i(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function g4e(e,t,n){const r=this;return s;function s(i){return r.parser.lazy[r.now().line]?n(i):Ge(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):Ht(e,o,"linePrefix",5)(i)}function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):Ge(i)?s(i):n(i)}}const b4e={name:"codeText",previous:x4e,resolve:y4e,tokenize:v4e};function y4e(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function x4e(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function v4e(e,t,n){let r=0,s,o;return i;function i(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(o=e.enter("codeTextSequence"),s=0,d(f)):Ge(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||Ge(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),c)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",c(f))}}class w4e{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&ip(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ip(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ip(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ip(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ip(this.left,n.reverse())}}}function ip(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function xG(e){const t={};let n=-1,r,s,o,i,a,l,c;const d=new w4e(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,o=0,o<l.length&&l[o][1].type==="lineEndingBlank"&&(o+=2),o<l.length&&l[o][1].type==="content"))for(;++o<l.length&&l[o][1].type!=="content";)l[o][1].type==="chunkText"&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,S4e(d,n)),n=t[n],c=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(i=d.get(o),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),i[1].type="lineEnding",s=o);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;s&&(r[1].end={...d.get(s)[1].start},a=d.slice(s,n),a.unshift(r),d.splice(s,n-s+1,a))}}return Qs(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function S4e(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,l=[],c={};let d,f,h=-1,p=n,m=0,g=0;const b=[g];for(;p;){for(;e.get(++s)[1]!==p;);o.push(s),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&i.defineSkip(p.start),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(g=h+1,b.push(g),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(i.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),h=b.length;h--;){const y=a.slice(b[h],b[h+1]),x=o.pop();l.push([x,x+y.length-1]),e.splice(x,2,y)}for(l.reverse(),h=-1;++h<l.length;)c[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return c}const C4e={resolve:k4e,tokenize:E4e},N4e={partial:!0,tokenize:j4e};function k4e(e){return xG(e),e}function E4e(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):Ge(a)?e.check(N4e,i,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function i(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function j4e(e,t,n){const r=this;return s;function s(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ht(e,o,"linePrefix")}function o(i){if(i===null||Ge(i))return n(i);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function vG(e,t,n,r,s,o,i,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),h):y===null||y===32||y===41||nv(y)?n(y):(e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),g(y))}function h(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Ge(y)?n(y):(e.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function g(y){return!d&&(y===null||y===41||yn(y))?(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(y)):d<c&&y===40?(e.consume(y),d++,g):y===41?(e.consume(y),d--,g):y===null||y===32||y===40||nv(y)?n(y):(e.consume(y),y===92?b:g)}function b(y){return y===40||y===41||y===92?(e.consume(y),g):g(y)}}function wG(e,t,n,r,s,o){const i=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(o),d}function d(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in i.parser.constructs?n(p):p===93?(e.exit(o),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):Ge(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Ge(p)||a++>999?(e.exit("chunkString"),d(p)):(e.consume(p),l||(l=!At(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function SG(e,t,n,r,s,o){let i;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),i=h===40?41:h,l):n(h)}function l(h){return h===i?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(o),c(h))}function c(h){return h===i?(e.exit(o),l(i)):h===null?n(h):Ge(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ht(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===i||h===null||Ge(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?f:d)}function f(h){return h===i||h===92?(e.consume(h),d):d(h)}}function lm(e,t){let n;return r;function r(s){return Ge(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):At(s)?Ht(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const _4e={name:"definition",tokenize:M4e},D4e={partial:!0,tokenize:T4e};function M4e(e,t,n){const r=this;let s;return o;function o(p){return e.enter("definition"),i(p)}function i(p){return wG.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=Jo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return yn(p)?lm(e,c)(p):c(p)}function c(p){return vG(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(D4e,f,f)(p)}function f(p){return At(p)?Ht(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Ge(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function T4e(e,t,n){return r;function r(a){return yn(a)?lm(e,s)(a):n(a)}function s(a){return SG(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return At(a)?Ht(e,i,"whitespace")(a):i(a)}function i(a){return a===null||Ge(a)?t(a):n(a)}}const R4e={name:"hardBreakEscape",tokenize:I4e};function I4e(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Ge(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const A4e={name:"headingAtx",resolve:P4e,tokenize:O4e};function P4e(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Qs(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function O4e(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&r++<6?(e.consume(d),i):d===null||yn(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||Ge(d)?(e.exit("atxHeading"),t(d)):At(d)?Ht(e,a,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function c(d){return d===null||d===35||yn(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),c)}}const F4e=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],m5=["pre","script","style","textarea"],$4e={concrete:!0,name:"htmlFlow",resolveTo:B4e,tokenize:V4e},L4e={partial:!0,tokenize:U4e},z4e={partial:!0,tokenize:H4e};function B4e(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function V4e(e,t,n){const r=this;let s,o,i,a,l;return c;function c(R){return d(R)}function d(R){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(R),f}function f(R){return R===33?(e.consume(R),h):R===47?(e.consume(R),o=!0,g):R===63?(e.consume(R),s=3,r.interrupt?t:I):as(R)?(e.consume(R),i=String.fromCharCode(R),b):n(R)}function h(R){return R===45?(e.consume(R),s=2,p):R===91?(e.consume(R),s=5,a=0,m):as(R)?(e.consume(R),s=4,r.interrupt?t:I):n(R)}function p(R){return R===45?(e.consume(R),r.interrupt?t:I):n(R)}function m(R){const W="CDATA[";return R===W.charCodeAt(a++)?(e.consume(R),a===W.length?r.interrupt?t:T:m):n(R)}function g(R){return as(R)?(e.consume(R),i=String.fromCharCode(R),b):n(R)}function b(R){if(R===null||R===47||R===62||yn(R)){const W=R===47,Y=i.toLowerCase();return!W&&!o&&m5.includes(Y)?(s=1,r.interrupt?t(R):T(R)):F4e.includes(i.toLowerCase())?(s=6,W?(e.consume(R),y):r.interrupt?t(R):T(R)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(R):o?x(R):v(R))}return R===45||Wr(R)?(e.consume(R),i+=String.fromCharCode(R),b):n(R)}function y(R){return R===62?(e.consume(R),r.interrupt?t:T):n(R)}function x(R){return At(R)?(e.consume(R),x):D(R)}function v(R){return R===47?(e.consume(R),D):R===58||R===95||as(R)?(e.consume(R),w):At(R)?(e.consume(R),v):D(R)}function w(R){return R===45||R===46||R===58||R===95||Wr(R)?(e.consume(R),w):S(R)}function S(R){return R===61?(e.consume(R),N):At(R)?(e.consume(R),S):v(R)}function N(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),l=R,k):At(R)?(e.consume(R),N):j(R)}function k(R){return R===l?(e.consume(R),l=null,_):R===null||Ge(R)?n(R):(e.consume(R),k)}function j(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||yn(R)?S(R):(e.consume(R),j)}function _(R){return R===47||R===62||At(R)?v(R):n(R)}function D(R){return R===62?(e.consume(R),M):n(R)}function M(R){return R===null||Ge(R)?T(R):At(R)?(e.consume(R),M):n(R)}function T(R){return R===45&&s===2?(e.consume(R),F):R===60&&s===1?(e.consume(R),V):R===62&&s===4?(e.consume(R),B):R===63&&s===3?(e.consume(R),I):R===93&&s===5?(e.consume(R),z):Ge(R)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(L4e,L,O)(R)):R===null||Ge(R)?(e.exit("htmlFlowData"),O(R)):(e.consume(R),T)}function O(R){return e.check(z4e,A,L)(R)}function A(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),P}function P(R){return R===null||Ge(R)?O(R):(e.enter("htmlFlowData"),T(R))}function F(R){return R===45?(e.consume(R),I):T(R)}function V(R){return R===47?(e.consume(R),i="",U):T(R)}function U(R){if(R===62){const W=i.toLowerCase();return m5.includes(W)?(e.consume(R),B):T(R)}return as(R)&&i.length<8?(e.consume(R),i+=String.fromCharCode(R),U):T(R)}function z(R){return R===93?(e.consume(R),I):T(R)}function I(R){return R===62?(e.consume(R),B):R===45&&s===2?(e.consume(R),I):T(R)}function B(R){return R===null||Ge(R)?(e.exit("htmlFlowData"),L(R)):(e.consume(R),B)}function L(R){return e.exit("htmlFlow"),t(R)}}function H4e(e,t,n){const r=this;return s;function s(i){return Ge(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):n(i)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}function U4e(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Sb,t,n)}}const W4e={name:"htmlText",tokenize:q4e};function q4e(e,t,n){const r=this;let s,o,i;return a;function a(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),l}function l(I){return I===33?(e.consume(I),c):I===47?(e.consume(I),S):I===63?(e.consume(I),v):as(I)?(e.consume(I),j):n(I)}function c(I){return I===45?(e.consume(I),d):I===91?(e.consume(I),o=0,m):as(I)?(e.consume(I),x):n(I)}function d(I){return I===45?(e.consume(I),p):n(I)}function f(I){return I===null?n(I):I===45?(e.consume(I),h):Ge(I)?(i=f,V(I)):(e.consume(I),f)}function h(I){return I===45?(e.consume(I),p):f(I)}function p(I){return I===62?F(I):I===45?h(I):f(I)}function m(I){const B="CDATA[";return I===B.charCodeAt(o++)?(e.consume(I),o===B.length?g:m):n(I)}function g(I){return I===null?n(I):I===93?(e.consume(I),b):Ge(I)?(i=g,V(I)):(e.consume(I),g)}function b(I){return I===93?(e.consume(I),y):g(I)}function y(I){return I===62?F(I):I===93?(e.consume(I),y):g(I)}function x(I){return I===null||I===62?F(I):Ge(I)?(i=x,V(I)):(e.consume(I),x)}function v(I){return I===null?n(I):I===63?(e.consume(I),w):Ge(I)?(i=v,V(I)):(e.consume(I),v)}function w(I){return I===62?F(I):v(I)}function S(I){return as(I)?(e.consume(I),N):n(I)}function N(I){return I===45||Wr(I)?(e.consume(I),N):k(I)}function k(I){return Ge(I)?(i=k,V(I)):At(I)?(e.consume(I),k):F(I)}function j(I){return I===45||Wr(I)?(e.consume(I),j):I===47||I===62||yn(I)?_(I):n(I)}function _(I){return I===47?(e.consume(I),F):I===58||I===95||as(I)?(e.consume(I),D):Ge(I)?(i=_,V(I)):At(I)?(e.consume(I),_):F(I)}function D(I){return I===45||I===46||I===58||I===95||Wr(I)?(e.consume(I),D):M(I)}function M(I){return I===61?(e.consume(I),T):Ge(I)?(i=M,V(I)):At(I)?(e.consume(I),M):_(I)}function T(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),s=I,O):Ge(I)?(i=T,V(I)):At(I)?(e.consume(I),T):(e.consume(I),A)}function O(I){return I===s?(e.consume(I),s=void 0,P):I===null?n(I):Ge(I)?(i=O,V(I)):(e.consume(I),O)}function A(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||yn(I)?_(I):(e.consume(I),A)}function P(I){return I===47||I===62||yn(I)?_(I):n(I)}function F(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function V(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),U}function U(I){return At(I)?Ht(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):z(I)}function z(I){return e.enter("htmlTextData"),i(I)}}const KM={name:"labelEnd",resolveAll:K4e,resolveTo:X4e,tokenize:Q4e},Y4e={tokenize:J4e},G4e={tokenize:e3e},Z4e={tokenize:t3e};function K4e(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&Qs(e,0,e.length,n),e}function X4e(e,t){let n=e.length,r=0,s,o,i,a;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(i=n);const l={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[o][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[i-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=vo(a,e.slice(o+1,o+r+3)),a=vo(a,[["enter",d,t]]),a=vo(a,C1(t.parser.constructs.insideSpan.null,e.slice(o+r+4,i-3),t)),a=vo(a,[["exit",d,t],e[i-2],e[i-1],["exit",c,t]]),a=vo(a,e.slice(i+1)),a=vo(a,[["exit",l,t]]),Qs(e,o,e.length,a),e}function Q4e(e,t,n){const r=this;let s=r.events.length,o,i;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return a;function a(h){return o?o._inactive?f(h):(i=r.parser.defined.includes(Jo(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(Y4e,d,i?d:f)(h):h===91?e.attempt(G4e,d,i?c:f)(h):i?d(h):f(h)}function c(h){return e.attempt(Z4e,d,f)(h)}function d(h){return t(h)}function f(h){return o._balanced=!0,n(h)}}function J4e(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return yn(f)?lm(e,o)(f):o(f)}function o(f){return f===41?d(f):vG(e,i,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function i(f){return yn(f)?lm(e,l)(f):d(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?SG(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function c(f){return yn(f)?lm(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function e3e(e,t,n){const r=this;return s;function s(a){return wG.call(r,e,o,i,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(Jo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function i(a){return n(a)}}function t3e(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const n3e={name:"labelStartImage",resolveAll:KM.resolveAll,tokenize:r3e};function r3e(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),i):n(a)}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const s3e={name:"labelStartLink",resolveAll:KM.resolveAll,tokenize:o3e};function o3e(e,t,n){const r=this;return s;function s(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),o}function o(i){return i===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(i):t(i)}}const e2={name:"lineEnding",tokenize:i3e};function i3e(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ht(e,t,"linePrefix")}}const kx={name:"thematicBreak",tokenize:a3e};function a3e(e,t,n){let r=0,s;return o;function o(c){return e.enter("thematicBreak"),i(c)}function i(c){return s=c,a(c)}function a(c){return c===s?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||Ge(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===s?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),At(c)?Ht(e,a,"whitespace")(c):a(c))}}const ys={continuation:{tokenize:d3e},exit:h3e,name:"list",tokenize:u3e},l3e={partial:!0,tokenize:p3e},c3e={partial:!0,tokenize:f3e};function u3e(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,i=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:aE(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(kx,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return aE(p)&&++i<10?(e.consume(p),l):(!r.interrupt||i<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Sb,r.interrupt?n:d,e.attempt(l3e,h,f))}function d(p){return r.containerState.initialBlankLine=!0,o++,h(p)}function f(p){return At(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function d3e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sb,s,o);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ht(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!At(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(c3e,t,i)(a))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ht(e,e.attempt(ys,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function f3e(e,t,n){const r=this;return Ht(e,s,"listItemIndent",r.containerState.size+1);function s(o){const i=r.events[r.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(o):n(o)}}function h3e(e){e.exit(this.containerState.type)}function p3e(e,t,n){const r=this;return Ht(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const i=r.events[r.events.length-1];return!At(o)&&i&&i[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const g5={name:"setextUnderline",resolveTo:m3e,tokenize:g3e};function m3e(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",i,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=i,e.push(["exit",i,t]),e}function g3e(e,t,n){const r=this;let s;return o;function o(c){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=c,i(c)):n(c)}function i(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===s?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),At(c)?Ht(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Ge(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const b3e={tokenize:y3e};function y3e(e){const t=this,n=e.attempt(Sb,r,e.attempt(this.parser.constructs.flowInitial,s,Ht(e,e.attempt(this.parser.constructs.flow,s,e.attempt(C4e,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const x3e={resolveAll:NG()},v3e=CG("string"),w3e=CG("text");function CG(e){return{resolveAll:NG(e==="text"?S3e:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,i,a);return i;function i(d){return c(d)?o(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return c(d)?(n.exit("data"),o(d)):(n.consume(d),l)}function c(d){if(d===null)return!0;const f=s[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function NG(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function S3e(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,i=-1,a=0,l;for(;o--;){const c=s[o];if(typeof c=="string"){for(i=c.length;c.charCodeAt(i-1)===32;)a++,i--;if(i)break;i=-1}else if(c===-2)l=!0,a++;else if(c!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?i:r.start._bufferIndex+i,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const C3e={42:ys,43:ys,45:ys,48:ys,49:ys,50:ys,51:ys,52:ys,53:ys,54:ys,55:ys,56:ys,57:ys,62:gG},N3e={91:_4e},k3e={[-2]:JC,[-1]:JC,32:JC},E3e={35:A4e,42:kx,45:[g5,kx],60:$4e,61:g5,95:kx,96:p5,126:p5},j3e={38:yG,92:bG},_3e={[-5]:e2,[-4]:e2,[-3]:e2,33:n3e,38:yG,42:lE,60:[s4e,W4e],91:s3e,92:[R4e,bG],93:KM,95:lE,96:b4e},D3e={null:[lE,x3e]},M3e={null:[42,95]},T3e={null:[]},R3e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:M3e,contentInitial:N3e,disable:T3e,document:C3e,flow:E3e,flowInitial:k3e,insideSpan:D3e,string:j3e,text:_3e},Symbol.toStringTag,{value:"Module"}));function I3e(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let i=[],a=[];const l={attempt:k(S),check:k(N),consume:x,enter:v,exit:w,interrupt:k(N,{interrupt:!0})},c={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(c,l);return t.resolveAll&&o.push(t),c;function f(M){return i=vo(i,M),b(),i[i.length-1]!==null?[]:(j(t,0),c.events=C1(o,c.events,c),c.events)}function h(M,T){return P3e(p(M),T)}function p(M){return A3e(i,M)}function m(){const{_bufferIndex:M,_index:T,line:O,column:A,offset:P}=r;return{_bufferIndex:M,_index:T,line:O,column:A,offset:P}}function g(M){s[M.line]=M.column,D()}function b(){let M;for(;r._index<i.length;){const T=i[r._index];if(typeof T=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<T.length;)y(T.charCodeAt(r._bufferIndex));else y(T)}}function y(M){d=d(M)}function x(M){Ge(M)?(r.line++,r.column=1,r.offset+=M===-3?2:1,D()):M!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=M}function v(M,T){const O=T||{};return O.type=M,O.start=m(),c.events.push(["enter",O,c]),a.push(O),O}function w(M){const T=a.pop();return T.end=m(),c.events.push(["exit",T,c]),T}function S(M,T){j(M,T.from)}function N(M,T){T.restore()}function k(M,T){return O;function O(A,P,F){let V,U,z,I;return Array.isArray(A)?L(A):"tokenize"in A?L([A]):B(A);function B(Z){return H;function H($){const q=$!==null&&Z[$],G=$!==null&&Z.null,ee=[...Array.isArray(q)?q:q?[q]:[],...Array.isArray(G)?G:G?[G]:[]];return L(ee)($)}}function L(Z){return V=Z,U=0,Z.length===0?F:R(Z[U])}function R(Z){return H;function H($){return I=_(),z=Z,Z.partial||(c.currentConstruct=Z),Z.name&&c.parser.constructs.disable.null.includes(Z.name)?Y():Z.tokenize.call(T?Object.assign(Object.create(c),T):c,l,W,Y)($)}}function W(Z){return M(z,I),P}function Y(Z){return I.restore(),++U<V.length?R(V[U]):F}}}function j(M,T){M.resolveAll&&!o.includes(M)&&o.push(M),M.resolve&&Qs(c.events,T,c.events.length-T,M.resolve(c.events.slice(T),c)),M.resolveTo&&(c.events=M.resolveTo(c.events,c))}function _(){const M=m(),T=c.previous,O=c.currentConstruct,A=c.events.length,P=Array.from(a);return{from:A,restore:F};function F(){r=M,c.previous=T,c.currentConstruct=O,c.events.length=A,a=P,D()}}function D(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function A3e(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let i;if(n===s)i=[e[n].slice(r,o)];else{if(i=e.slice(n,s),r>-1){const a=i[0];typeof a=="string"?i[0]=a.slice(r):i.shift()}o>0&&i.push(e[s].slice(0,o))}return i}function P3e(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let i;if(typeof o=="string")i=o;else switch(o){case-5:{i="\r";break}case-4:{i=`
916
916
  `;break}case-3:{i=`\r
917
917
  `;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&s)continue;i=" ";break}default:i=String.fromCharCode(o)}s=o===-2,r.push(i)}return r.join("")}function O3e(e){const r={constructs:pG([R3e,...(e||{}).extensions||[]]),content:s(X5e),defined:[],document:s(J5e),flow:s(b3e),lazy:{},string:s(v3e),text:s(w3e)};return r;function s(o){return i;function i(a){return I3e(r,o,a)}}}function F3e(e){for(;!xG(e););return e}const b5=/[\0\t\n\r]/g;function $3e(){let e=1,t="",n=!0,r;return s;function s(o,i,a){const l=[];let c,d,f,h,p;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(i||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(b5.lastIndex=f,c=b5.exec(o),h=c&&c.index!==void 0?c.index:o.length,p=o.charCodeAt(h),!c){t=o.slice(f);break}if(p===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(o.slice(f,h)),e+=h-f),p){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const L3e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function z3e(e){return e.replace(L3e,B3e)}function B3e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return mG(n.slice(o?2:1),o?16:10)}return ZM(n)||e}const kG={}.hasOwnProperty;function V3e(e,t,n){return typeof t!="string"&&(n=t,t=void 0),H3e(n)(F3e(O3e(n).document().write($3e()(e,t,!0))))}function H3e(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Pe),autolinkProtocol:_,autolinkEmail:_,atxHeading:o(de),blockQuote:o(G),characterEscape:_,characterReference:_,codeFenced:o(ee),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(ee,i),codeText:o(Q,i),codeTextData:_,data:_,codeFlowValue:_,definition:o(ne),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o(oe),hardBreakEscape:o(le),hardBreakTrailing:o(le),htmlFlow:o(ke,i),htmlFlowData:_,htmlText:o(ke,i),htmlTextData:_,image:o(ye),label:i,link:o(Pe),listItem:o(lt),listItemValue:h,listOrdered:o(Ve,f),listUnordered:o(Ve),paragraph:o(ue),reference:R,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(de),strong:o(Ne),thematicBreak:o(We)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:q,autolinkProtocol:$,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:Y,characterReferenceMarkerNumeric:Y,characterReferenceValue:Z,characterReference:H,codeFenced:l(b),codeFencedFence:g,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:D,codeIndented:l(y),codeText:l(P),codeTextData:D,data:D,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(T),hardBreakTrailing:l(T),htmlFlow:l(O),htmlFlowData:D,htmlText:l(A),htmlTextData:D,image:l(V),label:z,labelText:U,lineEnding:M,link:l(F),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:W,resourceDestinationString:I,resourceTitleString:B,resource:L,setextHeading:l(j),setextHeadingLineSequence:k,setextHeadingText:N,strong:l(),thematicBreak:l()}};EG(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(re){let fe={type:"root",children:[]};const De={stack:[fe],tokenStack:[],config:t,enter:a,exit:c,buffer:i,resume:d,data:n},Oe=[];let Me=-1;for(;++Me<re.length;)if(re[Me][1].type==="listOrdered"||re[Me][1].type==="listUnordered")if(re[Me][0]==="enter")Oe.push(Me);else{const nt=Oe.pop();Me=s(re,nt,Me)}for(Me=-1;++Me<re.length;){const nt=t[re[Me][0]];kG.call(nt,re[Me][1].type)&&nt[re[Me][1].type].call(Object.assign({sliceSerialize:re[Me][2].sliceSerialize},De),re[Me][1])}if(De.tokenStack.length>0){const nt=De.tokenStack[De.tokenStack.length-1];(nt[1]||y5).call(De,void 0,nt[0])}for(fe.position={start:al(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:al(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},Me=-1;++Me<t.transforms.length;)fe=t.transforms[Me](fe)||fe;return fe}function s(re,fe,De){let Oe=fe-1,Me=-1,nt=!1,Dt,ct,Ot,ve;for(;++Oe<=De;){const _t=re[Oe];switch(_t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{_t[0]==="enter"?Me++:Me--,ve=void 0;break}case"lineEndingBlank":{_t[0]==="enter"&&(Dt&&!ve&&!Me&&!Ot&&(Ot=Oe),ve=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ve=void 0}if(!Me&&_t[0]==="enter"&&_t[1].type==="listItemPrefix"||Me===-1&&_t[0]==="exit"&&(_t[1].type==="listUnordered"||_t[1].type==="listOrdered")){if(Dt){let vn=Oe;for(ct=void 0;vn--;){const he=re[vn];if(he[1].type==="lineEnding"||he[1].type==="lineEndingBlank"){if(he[0]==="exit")continue;ct&&(re[ct][1].type="lineEndingBlank",nt=!0),he[1].type="lineEnding",ct=vn}else if(!(he[1].type==="linePrefix"||he[1].type==="blockQuotePrefix"||he[1].type==="blockQuotePrefixWhitespace"||he[1].type==="blockQuoteMarker"||he[1].type==="listItemIndent"))break}Ot&&(!ct||Ot<ct)&&(Dt._spread=!0),Dt.end=Object.assign({},ct?re[ct][1].start:_t[1].end),re.splice(ct||Oe,0,["exit",Dt,_t[2]]),Oe++,De++}if(_t[1].type==="listItemPrefix"){const vn={type:"listItem",_spread:!1,start:Object.assign({},_t[1].start),end:void 0};Dt=vn,re.splice(Oe,0,["enter",vn,_t[2]]),Oe++,De++,Ot=void 0,ve=!0}}}return re[fe][1]._spread=nt,De}function o(re,fe){return De;function De(Oe){a.call(this,re(Oe),Oe),fe&&fe.call(this,Oe)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(re,fe,De){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([fe,De||void 0]),re.position={start:al(fe.start),end:void 0}}function l(re){return fe;function fe(De){re&&re.call(this,De),c.call(this,De)}}function c(re,fe){const De=this.stack.pop(),Oe=this.tokenStack.pop();if(Oe)Oe[0].type!==re.type&&(fe?fe.call(this,re,Oe[0]):(Oe[1]||y5).call(this,re,Oe[0]));else throw new Error("Cannot close `"+re.type+"` ("+am({start:re.start,end:re.end})+"): it’s not open");De.position.end=al(re.end)}function d(){return GM(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(re){if(this.data.expectingFirstListItemValue){const fe=this.stack[this.stack.length-2];fe.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function p(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.lang=re}function m(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.meta=re}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.value=re.replace(/(\r?\n|\r)$/g,"")}function x(re){const fe=this.resume(),De=this.stack[this.stack.length-1];De.label=fe,De.identifier=Jo(this.sliceSerialize(re)).toLowerCase()}function v(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.title=re}function w(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.url=re}function S(re){const fe=this.stack[this.stack.length-1];if(!fe.depth){const De=this.sliceSerialize(re).length;fe.depth=De}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function k(re){const fe=this.stack[this.stack.length-1];fe.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function _(re){const De=this.stack[this.stack.length-1].children;let Oe=De[De.length-1];(!Oe||Oe.type!=="text")&&(Oe=Je(),Oe.position={start:al(re.start),end:void 0},De.push(Oe)),this.stack.push(Oe)}function D(re){const fe=this.stack.pop();fe.value+=this.sliceSerialize(re),fe.position.end=al(re.end)}function M(re){const fe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=fe.children[fe.children.length-1];De.position.end=al(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(fe.type)&&(_.call(this,re),D.call(this,re))}function T(){this.data.atHardBreak=!0}function O(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.value=re}function A(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.value=re}function P(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.value=re}function F(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const fe=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=fe,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function V(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const fe=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=fe,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function U(re){const fe=this.sliceSerialize(re),De=this.stack[this.stack.length-2];De.label=z3e(fe),De.identifier=Jo(fe).toLowerCase()}function z(){const re=this.stack[this.stack.length-1],fe=this.resume(),De=this.stack[this.stack.length-1];if(this.data.inReference=!0,De.type==="link"){const Oe=re.children;De.children=Oe}else De.alt=fe}function I(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.url=re}function B(){const re=this.resume(),fe=this.stack[this.stack.length-1];fe.title=re}function L(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function W(re){const fe=this.resume(),De=this.stack[this.stack.length-1];De.label=fe,De.identifier=Jo(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function Y(re){this.data.characterReferenceType=re.type}function Z(re){const fe=this.sliceSerialize(re),De=this.data.characterReferenceType;let Oe;De?(Oe=mG(fe,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Oe=ZM(fe);const Me=this.stack[this.stack.length-1];Me.value+=Oe}function H(re){const fe=this.stack.pop();fe.position.end=al(re.end)}function $(re){D.call(this,re);const fe=this.stack[this.stack.length-1];fe.url=this.sliceSerialize(re)}function q(re){D.call(this,re);const fe=this.stack[this.stack.length-1];fe.url="mailto:"+this.sliceSerialize(re)}function G(){return{type:"blockquote",children:[]}}function ee(){return{type:"code",lang:null,meta:null,value:""}}function Q(){return{type:"inlineCode",value:""}}function ne(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function oe(){return{type:"emphasis",children:[]}}function de(){return{type:"heading",depth:0,children:[]}}function le(){return{type:"break"}}function ke(){return{type:"html",value:""}}function ye(){return{type:"image",title:null,url:"",alt:null}}function Pe(){return{type:"link",title:null,url:"",children:[]}}function Ve(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function lt(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function ue(){return{type:"paragraph",children:[]}}function Ne(){return{type:"strong",children:[]}}function Je(){return{type:"text",value:""}}function We(){return{type:"thematicBreak"}}}function al(e){return{line:e.line,column:e.column,offset:e.offset}}function EG(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?EG(e,r):U3e(e,r)}}function U3e(e,t){let n;for(n in t)if(kG.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function y5(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+am({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+am({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+am({start:t.start,end:t.end})+") is still open")}function W3e(e){const t=this;t.parser=n;function n(r){return V3e(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function q3e(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Y3e(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`