react-semaphor 0.1.482 → 0.1.483

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/chunks/{dashboard-briefing-launcher-CFj87qD9.js → dashboard-briefing-launcher-CCo-tyt1.js} +2 -2
  2. package/dist/chunks/{dashboard-briefing-launcher-CfhH2Qi3.cjs → dashboard-briefing-launcher-SjUYBRde.cjs} +1 -1
  3. package/dist/chunks/{dashboard-controls-DMLiiHg5.js → dashboard-controls-D0rRra6q.js} +3 -3
  4. package/dist/chunks/{dashboard-controls-rUeEbuQf.cjs → dashboard-controls-DfbxzqR2.cjs} +1 -1
  5. package/dist/chunks/{dashboard-json-ByWfNTdJ.js → dashboard-json-B2gej33z.js} +1 -1
  6. package/dist/chunks/{dashboard-json-CzWhgrtq.cjs → dashboard-json-CkBPnsxB.cjs} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-CbXkxxl5.cjs → edit-dashboard-visual-CiuJ6CVM.cjs} +1 -1
  8. package/dist/chunks/{edit-dashboard-visual-W4cEjYDe.js → edit-dashboard-visual-Dqde1zgg.js} +2 -2
  9. package/dist/chunks/{editor-action-buttons-DwaxVWvd.cjs → editor-action-buttons-5t5tU5r3.cjs} +1 -1
  10. package/dist/chunks/{editor-action-buttons-ClCeVNv7.js → editor-action-buttons-Cwu9P_LX.js} +1 -1
  11. package/dist/chunks/{index-BBXlxiaI.js → index-CIMKtcRh.js} +6 -4
  12. package/dist/chunks/{index-DEmUUHy3.cjs → index-I4TbmEn2.cjs} +2 -2
  13. package/dist/chunks/{report-preferences-dialog-uog1R8p6.cjs → report-preferences-dialog-CFr6WG6r.cjs} +1 -1
  14. package/dist/chunks/{report-preferences-dialog-CBd1Ornu.js → report-preferences-dialog-DHOl809j.js} +1 -1
  15. package/dist/dashboard/index.cjs +1 -1
  16. package/dist/dashboard/index.js +1 -1
  17. package/dist/data-app-builder/index.cjs +1 -1
  18. package/dist/data-app-builder/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +2 -2
  24. package/package.json +1 -1
@@ -1298,7 +1298,7 @@ Include in the briefing:
1298
1298
  `,...s.current()});return/^[\t ]/.test(u)&&(u=yv(u.charCodeAt(0))+u.slice(1)),u=u?i+" "+u:i,n.options.closeAtx&&(u+=" "+i),c(),a(),u}Pfe.peek=Ylt;function Pfe(e){return e.value||""}function Ylt(){return"<"}Ffe.peek=Zlt;function Ffe(e,t,n,r){const o=Az(n),s=o==='"'?"Quote":"Apostrophe",i=n.enter("image");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(a=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=c.move(" "+o),u+=c.move(n.safe(e.title,{before:u,after:o,...c.current()})),u+=c.move(o),a()),u+=c.move(")"),i(),u}function Zlt(){return"!"}Ofe.peek=Xlt;function Ofe(e,t,n,r){const o=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const a=n.createTracker(r);let c=a.move("![");const u=n.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return i(),n.stack=d,s(),o==="full"||!u||u!==f?c+=a.move(f+"]"):o==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function Xlt(){return"!"}Lfe.peek=Qlt;function Lfe(e,t,n){let r=e.value||"",o="`",s=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const i=n.unsafe[s],a=n.compilePattern(i);let c;if(i.atBreak)for(;c=a.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return o+r+o}function Qlt(){return"`"}function $fe(e,t){const n=Nz(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}zfe.peek=Jlt;function zfe(e,t,n,r){const o=Az(n),s=o==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let a,c;if($fe(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let f=i.move("<");return f+=i.move(n.containerPhrasing(e,{before:f,after:">",...i.current()})),f+=i.move(">"),a(),n.stack=d,f}a=n.enter("link"),c=n.enter("label");let u=i.move("[");return u+=i.move(n.containerPhrasing(e,{before:u,after:"](",...i.current()})),u+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=i.move("<"),u+=i.move(n.safe(e.url,{before:u,after:">",...i.current()})),u+=i.move(">")):(c=n.enter("destinationRaw"),u+=i.move(n.safe(e.url,{before:u,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=i.move(" "+o),u+=i.move(n.safe(e.title,{before:u,after:o,...i.current()})),u+=i.move(o),c()),u+=i.move(")"),a(),u}function Jlt(e,t,n){return $fe(e,n)?"<":"["}Bfe.peek=ect;function Bfe(e,t,n,r){const o=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const a=n.createTracker(r);let c=a.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return i(),n.stack=d,s(),o==="full"||!u||u!==f?c+=a.move(f+"]"):o==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function ect(){return"["}function Pz(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function tct(e){const t=Pz(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function nct(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Vfe(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function rct(e,t,n,r){const o=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?nct(n):Pz(n);const a=e.ordered?i==="."?")":".":tct(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Vfe(n)===i&&d){let f=-1;for(;++f<e.children.length;){const h=e.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=a),n.bulletCurrent=i;const u=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=s,o(),u}function oct(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function sct(e,t,n,r){const o=oct(n);let s=n.bulletCurrent||Pz(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let i=s.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(i-s.length)),a.shift(i);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),d);return c(),u;function d(f,h,p){return h?(p?"":" ".repeat(i))+f:(p?s:s+" ".repeat(i-s.length))+f}}function ict(e,t,n,r){const o=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,r);return s(),o(),i}const act=cT(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function lct(e,t,n,r){return(e.children.some(function(i){return act(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function cct(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Hfe.peek=uct;function Hfe(e,t,n,r){const o=cct(n),s=n.enter("strong"),i=n.createTracker(r),a=i.move(o+o);let c=i.move(n.containerPhrasing(e,{after:o,before:a,...i.current()}));const u=c.charCodeAt(0),d=uk(r.before.charCodeAt(r.before.length-1),u,o);d.inside&&(c=yv(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=uk(r.after.charCodeAt(0),f,o);h.inside&&(c=c.slice(0,-1)+yv(f));const p=i.move(o+o);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+c+p}function uct(e,t,n){return n.options.strong||"*"}function dct(e,t,n,r){return n.safe(e.value,r)}function fct(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function hct(e,t,n){const r=(Vfe(n)+(n.options.ruleSpaces?" ":"")).repeat(fct(n));return n.options.ruleSpaces?r.slice(0,-1):r}const qfe={blockquote:Flt,break:TW,code:Vlt,definition:qlt,emphasis:Afe,hardBreak:TW,heading:Glt,html:Pfe,image:Ffe,imageReference:Ofe,inlineCode:Lfe,link:zfe,linkReference:Bfe,list:rct,listItem:sct,paragraph:ict,root:lct,strong:Hfe,text:dct,thematicBreak:hct};function mct(){return{enter:{table:pct,tableData:EW,tableHeader:EW,tableRow:bct},exit:{codeText:xct,table:gct,tableData:t2,tableHeader:t2,tableRow:t2}}}function pct(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function gct(e){this.exit(e),this.data.inTable=void 0}function bct(e){this.enter({type:"tableRow",children:[]},e)}function t2(e){this.exit(e)}function EW(e){this.enter({type:"tableCell",children:[]},e)}function xct(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,yct));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function yct(e,t){return t==="|"?t:e}function vct(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
1299
1299
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:i,tableCell:c,tableRow:a}};function i(p,g,b,x){return u(d(p,b,x),p.align)}function a(p,g,b,x){const y=f(p,b,x),C=u([y]);return C.slice(0,C.indexOf(`
1300
1300
  `))}function c(p,g,b,x){const y=b.enter("tableCell"),C=b.enter("phrasing"),w=b.containerPhrasing(p,{...x,before:s,after:s});return C(),y(),w}function u(p,g){return Alt(p,{align:g,alignDelimiters:r,padding:n,stringLength:o})}function d(p,g,b){const x=p.children;let y=-1;const C=[],w=g.enter("table");for(;++y<x.length;)C[y]=f(x[y],g,b);return w(),C}function f(p,g,b){const x=p.children;let y=-1;const C=[],w=g.enter("tableRow");for(;++y<x.length;)C[y]=c(x[y],p,g,b);return w(),C}function h(p,g,b){let x=qfe.inlineCode(p,g,b);return b.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function wct(){return{exit:{taskListCheckValueChecked:DW,taskListCheckValueUnchecked:DW,paragraph:Sct}}}function Cct(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Nct}}}function DW(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Sct(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let s=-1,i;for(;++s<o.length;){const a=o[s];if(a.type==="paragraph"){i=a;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Nct(e,t,n,r){const o=e.children[0],s=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(i);let c=qfe.listItem(e,t,n,{...r,...a.current()});return s&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+i}}function jct(){return[rlt(),Nlt(),Ilt(),mct(),wct()]}function kct(e){return{extensions:[olt(),jlt(e),Tlt(),vct(e),Cct()]}}const _ct={tokenize:Rct,partial:!0},Ufe={tokenize:Act,partial:!0},Wfe={tokenize:Pct,partial:!0},Kfe={tokenize:Fct,partial:!0},Ict={tokenize:Oct,partial:!0},Gfe={name:"wwwAutolink",tokenize:Dct,previous:Zfe},Yfe={name:"protocolAutolink",tokenize:Mct,previous:Xfe},Uu={name:"emailAutolink",tokenize:Ect,previous:Qfe},wc={};function Tct(){return{text:wc}}let Bf=48;for(;Bf<123;)wc[Bf]=Uu,Bf++,Bf===58?Bf=65:Bf===91&&(Bf=97);wc[43]=Uu;wc[45]=Uu;wc[46]=Uu;wc[95]=Uu;wc[72]=[Uu,Yfe];wc[104]=[Uu,Yfe];wc[87]=[Uu,Gfe];wc[119]=[Uu,Gfe];function Ect(e,t,n){const r=this;let o,s;return i;function i(f){return!EF(f)||!Qfe.call(r,r.previous)||Fz(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return EF(f)?(e.consume(f),a):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(Ict,d,u)(f):f===45||f===95||_s(f)?(s=!0,e.consume(f),c):d(f)}function u(f){return e.consume(f),o=!0,c}function d(f){return s&&o&&Zs(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function Dct(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!Zfe.call(r,r.previous)||Fz(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_ct,e.attempt(Ufe,e.attempt(Wfe,s),n),n)(i))}function s(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function Mct(e,t,n){const r=this;let o="",s=!1;return i;function i(f){return(f===72||f===104)&&Xfe.call(r,r.previous)&&!Fz(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(Zs(f)&&o.length<5)return o+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const h=o.toLowerCase();if(h==="http"||h==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),s?u:(s=!0,c)):n(f)}function u(f){return f===null||ak(f)||Sr(f)||_m(f)||iT(f)?n(f):e.attempt(Ufe,e.attempt(Wfe,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Rct(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),s):n(i)}function s(i){return i===null?n(i):t(i)}}function Act(e,t,n){let r,o,s;return i;function i(u){return u===46||u===95?e.check(Kfe,c,a)(u):u===null||Sr(u)||_m(u)||u!==45&&iT(u)?c(u):(s=!0,e.consume(u),i)}function a(u){return u===95?r=!0:(o=r,r=void 0),e.consume(u),i}function c(u){return o||r||!s?n(u):t(u)}}function Pct(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?s(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(Kfe,t,s)(i):i===null||Sr(i)||_m(i)?t(i):(e.consume(i),o)}function s(i){return i===41&&r++,e.consume(i),o}}function Fct(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),o):a===60||a===null||Sr(a)||_m(a)?t(a):n(a)}function o(a){return a===null||a===40||a===91||Sr(a)||_m(a)?t(a):r(a)}function s(a){return Zs(a)?i(a):n(a)}function i(a){return a===59?(e.consume(a),r):Zs(a)?(e.consume(a),i):n(a)}}function Oct(e,t,n){return r;function r(s){return e.consume(s),o}function o(s){return _s(s)?n(s):t(s)}}function Zfe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Sr(e)}function Xfe(e){return!Zs(e)}function Qfe(e){return!(e===47||EF(e))}function EF(e){return e===43||e===45||e===46||e===95||_s(e)}function Fz(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Lct={tokenize:Wct,partial:!0};function $ct(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Hct,continuation:{tokenize:qct},exit:Uct}},text:{91:{name:"gfmFootnoteCall",tokenize:Vct},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:zct,resolveTo:Bct}}}}function zct(e,t,n){const r=this;let o=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const c=r.events[o][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return a;function a(c){if(!i||!i._balanced)return n(c);const u=nl(r.sliceSerialize({start:i.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Bct(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function Vct(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,i;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!i||f===null||f===91||Sr(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return o.includes(nl(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Sr(f)||(i=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function Hct(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0,a;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(i>999||g===93&&!a||g===null||g===91||Sr(g))return n(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=nl(r.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Sr(g)||(a=!0),i++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),i++,d):d(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),o.includes(s)||o.push(s),Un(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function qct(e,t,n){return e.check(nC,t,e.attempt(Lct,t,n))}function Uct(e){e.exit("gfmFootnoteDefinition")}function Wct(e,t,n){const r=this;return Un(e,o,"gfmFootnoteDefinitionIndent",5);function o(s){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(s):n(s)}}function Kct(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,a){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let u=c;for(;u--;)if(i[u][0]==="exit"&&i[u][1].type==="strikethroughSequenceTemporary"&&i[u][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[u][1].end.offset-i[u][1].start.offset){i[c][1].type="strikethroughSequence",i[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},i[u][1].start),end:Object.assign({},i[c][1].end)},f={type:"strikethroughText",start:Object.assign({},i[u][1].end),end:Object.assign({},i[c][1].start)},h=[["enter",d,a],["enter",i[u][1],a],["exit",i[u][1],a],["enter",f,a]],p=a.parser.constructs.insideSpan.null;p&&qi(h,h.length,0,aT(p,i.slice(u+1,c),a)),qi(h,h.length,0,[["exit",f,a],["enter",i[c][1],a],["exit",i[c][1],a],["exit",d,a]]),qi(i,u-1,c-u+3,h),c=u+h.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function s(i,a,c){const u=this.previous,d=this.events;let f=0;return h;function h(g){return u===126&&d[d.length-1][1].type!=="characterEscape"?c(g):(i.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const b=ub(u);if(g===126)return f>1?c(g):(i.consume(g),f++,p);if(f<2&&!n)return c(g);const x=i.exit("strikethroughSequenceTemporary"),y=ub(g);return x._open=!y||y===2&&!!b,x._close=!b||b===2&&!!y,a(g)}}}class Gct{constructor(){this.map=[]}add(t,n,r){Yct(this,t,n,r)}consume(t){if(this.map.sort(function(s,i){return s[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const s of o)t.push(s);o=r.pop()}this.map.length=0}}function Yct(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function Zct(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Xct(){return{flow:{null:{name:"table",tokenize:Qct,resolveAll:Jct}}}}function Qct(e,t,n){const r=this;let o=0,s=0,i;return a;function a(_){let E=r.events.length-1;for(;E>-1;){const P=r.events[E][1].type;if(P==="lineEnding"||P==="linePrefix")E--;else break}const D=E>-1?r.events[E][1].type:null,M=D==="tableHead"||D==="tableRow"?j:c;return M===j&&r.parser.lazy[r.now().line]?n(_):M(_)}function c(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(i=!0,s+=1),d(_)}function d(_){return _===null?n(_):Zt(_)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):On(_)?Un(e,d,"whitespace")(_):(s+=1,i&&(i=!1,o+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),i=!0,d):(e.enter("data"),f(_)))}function f(_){return _===null||_===124||Sr(_)?(e.exit("data"),d(_)):(e.consume(_),_===92?h:f)}function h(_){return _===92||_===124?(e.consume(_),f):f(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),i=!1,On(_)?Un(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?x(_):_===124?(i=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),b):S(_)}function b(_){return On(_)?Un(e,x,"whitespace")(_):x(_)}function x(_){return _===58?(s+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),y):_===45?(s+=1,y(_)):_===null||Zt(_)?N(_):S(_)}function y(_){return _===45?(e.enter("tableDelimiterFiller"),C(_)):S(_)}function C(_){return _===45?(e.consume(_),C):_===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(_))}function w(_){return On(_)?Un(e,N,"whitespace")(_):N(_)}function N(_){return _===124?g(_):_===null||Zt(_)?!i||o!==s?S(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):S(_)}function S(_){return n(_)}function j(_){return e.enter("tableRow"),I(_)}function I(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),I):_===null||Zt(_)?(e.exit("tableRow"),t(_)):On(_)?Un(e,I,"whitespace")(_):(e.enter("data"),k(_))}function k(_){return _===null||_===124||Sr(_)?(e.exit("data"),I(_)):(e.consume(_),_===92?T:k)}function T(_){return _===92||_===124?(e.consume(_),k):k(_)}}function Jct(e,t){let n=-1,r=!0,o=0,s=[0,0,0,0],i=[0,0,0,0],a=!1,c=0,u,d,f;const h=new Gct;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,c!==0&&(MW(h,t,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],i=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",d,t]])),o=g.type==="tableDelimiterRow"?2:d?3:1):o&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(s[1]!==0&&(i[0]=i[1],f=n1(h,t,s,o,void 0,f),s=[0,0,0,0]),i[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(i[0]=i[1],f=n1(h,t,s,o,void 0,f)),s=i,i=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,s[1]!==0?(i[0]=i[1],f=n1(h,t,s,o,n,f)):i[1]!==0&&(f=n1(h,t,i,o,n,f)),o=0):o&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&MW(h,t,c,u,d),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=Zct(t.events,n))}return e}function n1(e,t,n,r,o,s){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},$p(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const c=$p(t.events,n[1]);if(s={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=$p(t.events,n[2]),d=$p(t.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,b=n[3]-n[2]-1;e.add(g,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return o!==void 0&&(s.end=Object.assign({},$p(t.events,o)),e.add(o,0,[["exit",s,t]]),s=void 0),s}function MW(e,t,n,r,o){const s=[],i=$p(t.events,n);o&&(o.end=Object.assign({},i),s.push(["exit",o,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function $p(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const eut={name:"tasklistCheck",tokenize:nut};function tut(){return{text:{91:eut}}}function nut(e,t,n){const r=this;return o;function o(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Sr(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(c)}function a(c){return Zt(c)?t(c):On(c)?e.check({tokenize:rut},t,n)(c):n(c)}}function rut(e,t,n){return Un(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function out(e){return lfe([Tct(),$ct(),Kct(e),Xct(),tut()])}const sut={};function Oz(e){const t=this,n=e||sut,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(out(n)),s.push(jct()),i.push(kct(n))}const DF=ok,wh=sk;function iut(e){var r,o;const t=(r=e==null?void 0:e.email)==null?void 0:r.trim();if(!t)return null;const n=(o=e==null?void 0:e.name)==null?void 0:o.trim();return{type:"email",address:t,...n&&n!==t?{name:n}:{}}}function Jfe(e){const t=v.useMemo(()=>e?new Date(e).getTime():null,[e]),[n,r]=v.useState(()=>Date.now());return v.useEffect(()=>{if(t===null)return;r(Date.now());const o=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(o)},[t]),t===null?null:Math.max(0,Math.floor((n-t)/1e3))}function Lz(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function wo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function aut(e){if(!wo(e))return null;const t=typeof e.subject=="string"?e.subject:null,n=typeof e.body=="string"?e.body:null,r=Array.isArray(e.recipients)?e.recipients.flatMap(i=>!wo(i)||typeof i.label!="string"?[]:[{type:i.type==="email"||i.type==="user"||i.type==="tenant_user"||i.type==="group"?i.type:"email",label:i.label,...typeof i.detail=="string"?{detail:i.detail}:{},...typeof i.memberCount=="number"?{memberCount:i.memberCount}:{},...typeof i.hasMoreMembers=="boolean"?{hasMoreMembers:i.hasMoreMembers}:{},...Array.isArray(i.previewMembers)?{previewMembers:i.previewMembers.flatMap(c=>!wo(c)||typeof c.label!="string"?[]:[{type:c.type==="user"||c.type==="tenant_user"||c.type==="email"?c.type:"email",label:c.label,...typeof c.detail=="string"?{detail:c.detail}:{}}])}:{}}]):null,o=Array.isArray(e.channels)?e.channels.filter(i=>typeof i=="string"):null,s=Array.isArray(e.attachments)?e.attachments.filter(i=>typeof i=="string"):null;return!t||!n||!r||!o||!s?null:{subject:t,body:n,...typeof e.bodyHtml=="string"&&e.bodyHtml.trim()?{bodyHtml:e.bodyHtml}:{},recipients:r,channels:o,attachments:s,...typeof e.attachmentNotice=="string"?{attachmentNotice:e.attachmentNotice}:{}}}function lut(e){if(!wo(e))return null;const t=typeof e.channel=="string"?e.channel:null,n=typeof e.text=="string"?e.text:null,r=Array.isArray(e.blocks)?e.blocks.filter(wo):null;if(!t||!n||!r)return null;const o=wo(e.thread)?{text:typeof e.thread.text=="string"?e.thread.text:"",blocks:Array.isArray(e.thread.blocks)?e.thread.blocks.filter(wo):[],reply_broadcast:!1}:void 0;return{channel:t,text:n,blocks:r,unfurl_links:!1,unfurl_media:!1,...o?{thread:o}:{}}}function cut(e){if(!wo(e))return null;if(e.type==="email"){const t=typeof e.address=="string"?e.address:null;if(!t)return null;const n=typeof e.name=="string"?e.name:null;return{type:"email",label:n||t,...n?{detail:t}:{}}}if(e.type==="group"){const t=typeof e.name=="string"?e.name:null,n=typeof e.groupId=="string"?e.groupId:null;return{type:"group",label:t||"Group",...n&&!t?{detail:n}:{}}}if(e.type==="tenant_user"){const t=typeof e.name=="string"?e.name:null,n=typeof e.email=="string"?e.email:null,r=typeof e.tenantUserId=="string"?e.tenantUserId:null;return{type:"tenant_user",label:t||n||"Tenant user",...n&&t?{detail:n}:{},...r&&!t&&!n?{detail:r}:{}}}if(e.type==="user"){const t=typeof e.name=="string"?e.name:null,n=typeof e.email=="string"?e.email:null,r=typeof e.userId=="string"?e.userId:null;return{type:"user",label:t||n||"User",...n&&t?{detail:n}:{},...r&&!t&&!n?{detail:r}:{}}}return null}function ehe(e){if(!wo(e.result))return null;const t=wo(e.result.deliveryReadiness)?e.result.deliveryReadiness:null,n=t&&wo(t.intent)?t.intent:null,r=wo(e.result.deliveryPackage)?e.result.deliveryPackage:null,o=wo(e.result.deliveryResult)?e.result.deliveryResult:null,s=wo(e.result.package)?e.result.package:null,i=typeof(r==null?void 0:r.subject)=="string"&&r.subject||typeof(t==null?void 0:t.subject)=="string"&&t.subject||typeof(n==null?void 0:n.subject)=="string"&&n.subject||typeof e.result.title=="string"&&e.result.title||"Briefing email",a=typeof(r==null?void 0:r.bodyMarkdown)=="string"&&r.bodyMarkdown||typeof(n==null?void 0:n.body)=="string"&&n.body||typeof e.result.summary=="string"&&e.result.summary||"",c=typeof(r==null?void 0:r.bodyHtml)=="string"&&r.bodyHtml.trim()?r.bodyHtml:null;if(!a)return null;const u=Array.isArray(n==null?void 0:n.recipients)?n.recipients.flatMap(h=>{const p=cut(h);return p?[p]:[]}):[],d=Array.isArray(n==null?void 0:n.channels)?n.channels.filter(h=>typeof h=="string"):typeof(o==null?void 0:o.channel)=="string"?[o.channel]:[],f=Array.isArray(s==null?void 0:s.attachments)?s.attachments.flatMap(h=>wo(h)?typeof h.label=="string"?[h.label]:typeof h.title=="string"?[h.title]:typeof h.filename=="string"?[h.filename]:[]:[]):[];return{subject:i,body:a,...c?{bodyHtml:c}:{},recipients:u,channels:d,attachments:f}}function the({html:e,title:t="Briefing HTML artifact",className:n}){const r=v.useMemo(()=>LP.sanitize(e,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style"]}),[e]);return l.jsx("iframe",{title:t,srcDoc:r,sandbox:"",className:m.cn("h-[760px] w-full rounded-card border border-border bg-background ",n)})}const Er={info:{surface:"border-border bg-blue-50/60 text-foreground dark:border-border dark:bg-blue-950/30",icon:"text-blue-600 dark:text-blue-400"},success:{surface:"border-emerald-200 bg-emerald-50/70 text-foreground dark:border-emerald-900/50 dark:bg-emerald-950/30",icon:"text-emerald-700 dark:text-emerald-300",dot:"bg-emerald-500",label:"text-emerald-700 dark:text-emerald-400",iconBg:"bg-emerald-100 dark:bg-emerald-900/60"},danger:{surface:"border-destructive/30 bg-destructive/10 text-destructive",icon:"text-destructive",dot:"bg-destructive",iconBg:"bg-destructive/15"},warning:{surface:"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300",dot:"bg-amber-500"},neutral:{dot:"bg-border"}};function RW(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e;return{status:typeof n.status=="string"?n.status:"SKIPPED",channel:typeof n.channel=="string"?n.channel:t,sentCount:typeof n.sentCount=="number"?n.sentCount:0,failedCount:typeof n.failedCount=="number"?n.failedCount:0,attemptedCount:typeof n.attemptedCount=="number"?n.attemptedCount:0,attachmentCount:typeof n.attachmentCount=="number"?n.attachmentCount:0,message:typeof n.message=="string"?n.message:""}}function uut(e){return e.status==="SUCCESS"?"Complete":e.status==="FAILED"?"Failed":e.status==="RUNNING"?"Running":"Queued"}function $z(e){const t=e==null?void 0:e.result;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.deliveryResult;if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n,o=RW(r.email,"EMAIL"),s=RW(r.slack,"SLACK"),i=[o,s].filter(a=>a!==null);if(i.length>0){const a=i.some(f=>f.status==="FAILED"),c=i.filter(f=>f.status==="SENT").length,u=a&&c===0?"FAILED":a?"PARTIAL":c>0?"SENT":typeof r.status=="string"?r.status:"SKIPPED",d=i.map(f=>f.message).filter(Boolean).join(" ")||(typeof r.message=="string"?r.message:"");return{status:u,channel:typeof r.channel=="string"?r.channel:"BRIEFING",sentCount:i.reduce((f,h)=>f+h.sentCount,0),failedCount:i.reduce((f,h)=>f+h.failedCount,0),attemptedCount:i.reduce((f,h)=>f+h.attemptedCount,0),attachmentCount:i.reduce((f,h)=>f+h.attachmentCount,0),message:d,channels:{email:o??void 0,slack:s??void 0}}}return{status:typeof r.status=="string"?r.status:"SKIPPED",channel:typeof r.channel=="string"?r.channel:"EMAIL",sentCount:typeof r.sentCount=="number"?r.sentCount:0,failedCount:typeof r.failedCount=="number"?r.failedCount:0,attemptedCount:typeof r.attemptedCount=="number"?r.attemptedCount:0,attachmentCount:typeof r.attachmentCount=="number"?r.attachmentCount:0,message:typeof r.message=="string"?r.message:""}}function dut(e){var t,n,r,o;if(e.channel==="BRIEFING"||e.channels){const s=(n=(t=e.channels)==null?void 0:t.email)==null?void 0:n.status,i=(o=(r=e.channels)==null?void 0:r.slack)==null?void 0:o.status;if(s==="SENT"&&i==="SENT")return"Email and Slack sent";if(s==="SENT"&&i==="FAILED")return"Email sent, Slack failed";if(s==="FAILED"&&i==="SENT")return"Slack sent, email failed";if(s==="SENT")return"Email sent";if(i==="SENT")return"Slack sent";if(s==="FAILED"||i==="FAILED")return"Delivery failed";if(e.status==="SENT")return"Delivery sent"}return e.status==="SENT"?e.channel==="SLACK"?"Slack sent":e.sentCount===1?"Email sent":`${e.sentCount} emails sent`:e.status==="FAILED"?e.channel==="SLACK"?"Slack failed":e.failedCount===1?"Email failed":`${e.failedCount||e.attemptedCount||0} emails failed`:e.status==="NOT_CONFIGURED"?"Email not configured":e.message||"Email delivery skipped"}function fut(e){return e.status==="SENT"?Er.success.surface:e.status==="FAILED"||e.status==="PARTIAL"?Er.danger.surface:Er.warning.surface}function nhe(e){return e.status==="SUCCESS"?l.jsx(m.Check,{className:m.cn("h-3 w-3",Er.success.icon)}):e.status==="FAILED"?l.jsx(Me.X,{className:m.cn("h-3 w-3",Er.danger.icon)}):e.status==="RUNNING"?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin text-muted-foreground"}):l.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-muted-foreground/70"})}const hut=[{pattern:/^plan preview/i,label:"Plan preview"},{pattern:/^analysis preview/i,label:"Analysis preview"}];function mut(e){const t=e.runtime.split(/;\s*/).map(o=>o.trim()).filter(Boolean),n=e.toolCalls.split(/;\s*/).map(o=>o.trim()).filter(Boolean),r=[];for(const{pattern:o,label:s}of hut){const i=AW(t.find(c=>o.test(c))),a=AW(n.find(c=>o.test(c)));(i||a)&&r.push({label:s,duration:i,toolCalls:a})}return r}function AW(e){return e&&e.replace(/^(plan|analysis)\s+preview\s+(should return in|takes|uses(?: at most)?|usually (?:takes|uses(?: at most)?))\s+/i,"").replace(/[.;]\s*$/,"").trim()||null}const PW=3;function put({previewPlan:e,previewRun:t,scopeLabel:n}){return l.jsxs("div",{className:"space-y-5","aria-label":"Briefing plan",children:[l.jsxs("div",{children:[l.jsx("div",{className:oo,children:"What I understood from your brief"}),l.jsxs("div",{className:"mt-2 overflow-hidden rounded-card border border-border",children:[l.jsx(Wl,{field:"Datasets",value:l.jsx(Mut,{plan:e})}),l.jsx(Wl,{field:"Investigate",value:e.understood.investigation}),l.jsx(Wl,{field:"Threshold",value:e.understood.threshold}),l.jsx(Wl,{field:"Audience",value:e.understood.audience}),l.jsx(Wl,{field:"Format",value:e.understood.format,isLast:!0})]})]}),e.scope.grounding?l.jsx(gut,{plan:e}):null,l.jsxs("div",{children:[l.jsx("div",{className:m.cn(oo,"mb-2"),children:"What I'll do"}),l.jsx("ol",{className:"space-y-3",children:e.steps.map(r=>l.jsx(Rut,{order:r.order,title:r.title,detail:r.detail,tools:r.tools,optional:r.optional},r.order))})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"rounded-card border border-border px-3 py-2",children:[l.jsx("div",{className:oo,children:"Scope"}),l.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[12px] text-foreground/80",children:[l.jsx(Go,{className:"h-3 w-3 text-muted-foreground/70"}),l.jsx("span",{className:"truncate",children:(n==null?void 0:n.trim())||e.scope.sourceLabel})]})]}),l.jsxs("div",{className:"rounded-card border border-border px-3 py-2",children:[l.jsx("div",{className:oo,children:"Estimate"}),(()=>{var i;const o=mut(e.estimate).find(a=>a.label.toLowerCase().includes("analysis")),s=(o==null?void 0:o.duration)??((i=e.estimate.runtime)==null?void 0:i.trim())??null;return l.jsx("div",{className:"mt-1 text-[12px] tabular-nums text-foreground/80",children:s??"—"})})()]})]}),e.ambiguities.length>0?l.jsx("div",{className:"rounded-card border border-border bg-muted px-2.5 py-1.5 text-[11px] leading-[1.55] text-muted-foreground",children:l.jsxs("div",{className:"flex items-start gap-1.5",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("ul",{className:"space-y-0.5",children:e.ambiguities.map(r=>l.jsx("li",{children:r},r))})]})}):null,t&&!wh(t.status)?l.jsx(rhe,{run:t,labelPrefix:"Preview"}):null]})}function gut({plan:e}){const t=e.scope.grounding;if(!t)return null;const n=t.datasetLabel&&t.datasetName?`${t.datasetLabel} (${t.datasetName})`:t.datasetName??t.datasetLabel??"Not selected yet",r=t.dimensions.length?t.dimensions.join(", "):"Best available dimensions";return l.jsxs("div",{children:[l.jsx("div",{className:oo,children:"What I'll analyze"}),l.jsxs("div",{className:"mt-2 overflow-hidden rounded-card border border-border",children:[l.jsx(Wl,{field:"Metric",value:t.metric??"Not selected yet"}),l.jsx(Wl,{field:"Dataset",value:n}),l.jsx(Wl,{field:"Time field",value:t.dateField??"Not selected yet"}),l.jsx(Wl,{field:"Breakdown",value:r}),l.jsx(Wl,{field:"Confidence",value:`${t.confidence} · ${t.reason}`,isLast:!0})]})]})}function rhe({run:e,labelPrefix:t}){const n=e.progress??null,r=n?ahe(n.recentEvents??[],n.label).slice(-4).reverse():[],o=wh(e.status),s=n?dk(n.label):`${t?`${t} `:""}${uut(e)}`,i=lhe(e),a=n!=null&&n.updatedAt?new Date(n.updatedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"}):null;return l.jsxs("div",{className:"rounded-card border border-border px-3 py-2","aria-label":`${t?`${t} `:""}run progress`,children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[o?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin text-muted-foreground"}):nhe(e),l.jsx("span",{className:"font-medium",children:s})]}),n!=null&&n.detail&&e.status!=="FAILED"?l.jsx("p",{className:"mt-1 text-[11px] leading-[1.5] text-muted-foreground",children:n.detail}):null]}),a?l.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/70",children:a}):null]}),r.length>0?l.jsxs("div",{className:"mt-2 border-t border-border/60 pt-2",children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",children:"Recent activity"}),l.jsx("ol",{className:"space-y-1.5",children:r.map((c,u)=>l.jsxs("li",{className:"flex items-start gap-2 text-[11px] leading-[1.45] text-muted-foreground",children:[l.jsx(m.Check,{className:"mt-0.5 h-3 w-3 shrink-0 text-border"}),l.jsx("span",{children:ihe(c.label)})]},`${c.updatedAt}-${c.label}-${u}`))})]}):null,i.length>0?l.jsx("p",{className:"mt-2 text-[11px] leading-[1.55] text-muted-foreground",children:i.join(" ")}):null]})}function ohe({run:e,onRetryRun:t,retryDisabled:n,retryDisabledReason:r,onDeleteRun:o,deletePending:s}){const[i,a]=v.useState(!1),[c,u]=v.useState(!1),d=she(e.completedAt??e.startedAt??e.scheduledFor),h=(e.error?/cancel/i.test(e.error):!1)?"Run cancelled":"Run failed";return l.jsxs("div",{className:m.cn("rounded-card border px-3 py-2.5",Er.danger.surface),role:"alert","aria-label":h,children:[l.jsxs("div",{className:"flex items-start gap-2.5",children:[l.jsx("div",{className:m.cn("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full",Er.danger.iconBg),children:l.jsx(Me.X,{className:m.cn("h-3 w-3",Er.danger.icon)})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-2 text-[13px]",children:[l.jsx("span",{className:m.cn("font-medium",Er.danger.icon),children:h}),d?l.jsx("span",{className:"text-[11px] text-muted-foreground",children:d}):null]}),e.error?l.jsx("p",{className:"mt-1 text-[11px] leading-[1.55] text-foreground/80",children:e.error}):null]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t?l.jsxs("button",{type:"button",onClick:t,disabled:n,title:n?r:"Retry run",className:"inline-flex h-7 items-center gap-1.5 rounded-control border border-border bg-background px-2.5 text-[12px] font-medium text-foreground hover:bg-muted disabled:opacity-50",children:[l.jsx(ka,{className:"h-3 w-3"}),"Retry"]}):null,o?l.jsxs(Co,{open:c,onOpenChange:u,children:[l.jsx(So,{asChild:!0,children:l.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"More run actions",children:l.jsx(ei,{className:"h-3.5 w-3.5"})})}),l.jsx(mo,{align:"end",className:"z-[60] w-44",children:l.jsxs(mn,{onClick:p=>{p.preventDefault(),u(!1),a(!0)},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:[l.jsx(_a,{className:"h-3.5 w-3.5"}),"Delete run"]})})]}):null]})]}),o?l.jsx(mf,{open:i,onOpenChange:p=>{s||a(p)},children:l.jsxs(Eu,{children:[l.jsxs(Du,{children:[l.jsx(Ru,{children:"Delete this run record?"}),l.jsx(Au,{children:"The saved item stays. Only this run's record (status, error message, activity log) is removed and won't appear in history."})]}),l.jsxs(Mu,{children:[l.jsx(Fu,{disabled:s,children:"Cancel"}),l.jsxs(Pu,{disabled:s,onClick:p=>{p.preventDefault(),o()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[s?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin"}):l.jsx(_a,{className:"h-3 w-3"}),"Delete run"]})]})]})}):null]})}function but({run:e}){const t=$z(e);return!DF(e.status)||!t||t.status==="SKIPPED"?null:l.jsxs("div",{className:m.cn("rounded-card border px-3 py-2 text-[12px]",fut(t)),"aria-label":"Email delivery status",children:[l.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[l.jsx(zZ,{className:"h-3.5 w-3.5 shrink-0"}),l.jsx("span",{children:dut(t)})]}),t.message?l.jsx("p",{className:"mt-1 text-[11px] leading-[1.5] opacity-80",children:t.message}):null,l.jsxs("p",{className:"mt-1 text-[11px] leading-[1.5] opacity-70",children:[t.attachmentCount===1?"1 attachment":`${t.attachmentCount} attachments`,t.attemptedCount>0?` · ${t.attemptedCount} attempted`:""]})]})}function she(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function xut(e){const t=$z(e);return e.status==="FAILED"?(t==null?void 0:t.status)==="FAILED"?"Last email failed":"Last run failed":(t==null?void 0:t.channel)==="BRIEFING"||t!=null&&t.channels?t.status==="SENT"?"Last delivery sent":t.status==="FAILED"||t.status==="PARTIAL"?"Last delivery failed":"Last delivery completed":(t==null?void 0:t.status)==="SENT"?t.channel==="SLACK"?"Last Slack sent":t.sentCount===1?"Last email sent":"Last emails sent":(t==null?void 0:t.status)==="FAILED"?"Last email failed":"Last run completed"}function yut({run:e,onViewOutput:t,onDeleteRun:n,onRetryRun:r,retryDisabled:o,retryDisabledReason:s,deletePending:i}){const a=$z(e),c=she(e.completedAt??e.startedAt??e.scheduledFor);if(e.status==="FAILED"||(a==null?void 0:a.status)==="FAILED")return l.jsx(ohe,{run:e,onRetryRun:r,retryDisabled:o,retryDisabledReason:s,onDeleteRun:n,deletePending:i});const d=a&&a.status!=="SKIPPED"?[a.attachmentCount===1?"1 attachment":`${a.attachmentCount} attachments`,a.attemptedCount>0?`${a.attemptedCount} attempted`:null].filter(Boolean).join(" · "):e.error;return l.jsx("div",{className:m.cn("rounded-card border px-3 py-2",Er.success.surface),"aria-label":"Latest run",children:l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:m.cn("flex items-center gap-1.5 text-[12px] font-medium",Er.success.label),children:[nhe(e),l.jsx("span",{children:xut(e)}),c?l.jsx("span",{className:"font-normal text-muted-foreground",children:c}):null]}),d?l.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:d}):null]}),l.jsx("div",{className:"flex items-center gap-1",children:l.jsxs("button",{type:"button",className:ou,onClick:t,children:[l.jsx(Bd,{className:"h-3 w-3"}),"View output"]})})]})})}function dk(e){return e.replace(/\s+(started|completed)$/i,"")}function ihe(e){const t=/^(.*)\s+(started|completed)$/i.exec(e.trim());if(!t)return e;const n=t[1];return`${t[2].toLowerCase()==="completed"?"Completed":"Started"} ${n}`}function FW({run:e}){const t=e.progress??null,n=t?ahe(t.recentEvents??[],t.label).slice(-4).reverse():[],r=t!=null&&t.detail&&t.detail!==t.label?t.detail:null,o=lhe(e);return l.jsxs("div",{className:"border-b border-border bg-muted/60 px-4 py-3",children:[r?l.jsx("p",{className:"mb-3 text-[12px] leading-[1.5] text-foreground/80",children:r}):null,n.length>0?l.jsxs("div",{children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",children:"Recent activity"}),l.jsx("ol",{className:"space-y-1.5",children:n.map((s,i)=>l.jsxs("li",{className:"flex items-start gap-2 text-[11px] leading-[1.45] text-muted-foreground",children:[l.jsx(m.Check,{className:"mt-0.5 h-3 w-3 shrink-0 text-border"}),l.jsx("span",{children:ihe(s.label)})]},`${s.updatedAt}-${s.label}-${i}`))})]}):null,e.status==="FAILED"&&"error"in e&&e.error?l.jsx("p",{role:"alert",className:"mt-2 text-[11px] leading-[1.55] text-destructive",children:e.error}):null,o.length>0?l.jsx("p",{className:"mt-2 text-[11px] leading-[1.55] text-muted-foreground",children:o.join(" ")}):null]})}function ahe(e,t){const n=t?t.replace(/\s+(started|completed)$/i,"").trim().toLowerCase():null,r=n?e.filter(a=>a.label.replace(/\s+(started|completed)$/i,"").trim().toLowerCase()!==n):e.slice(),o=new Set;for(const a of r){const c=/^(.*)\s+completed$/i.exec(a.label.trim());c&&o.add(c[1].trim().toLowerCase())}const s=r.filter(a=>{const c=/^(.*)\s+started$/i.exec(a.label.trim());if(!c)return!0;const u=c[1].trim().toLowerCase();return!o.has(u)}),i=new Map;for(const a of s)i.set(a.label.trim().toLowerCase(),a);return Array.from(i.values())}function vut(){return l.jsx("div",{className:m.cn("border-b px-4 py-2 text-[12px] leading-[1.5]",Er.info.surface),role:"note",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(m.Info,{className:m.cn("mt-0.5 h-3 w-3 shrink-0",Er.info.icon)}),l.jsxs("p",{children:["This typically takes"," ",l.jsx("span",{className:"font-medium text-foreground",children:"1–3 minutes"}),". You can leave this open or come back later — we'll save the result."]})]})})}function wut({run:e,onExpand:t}){var o;const n=Jfe(e.startedAt),r=(o=e.progress)!=null&&o.label?dk(e.progress.label):"Run in progress";return l.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-[320px] overflow-hidden rounded-card border border-border bg-background shadow-md",children:[l.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-start gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-muted","aria-label":"Expand run",children:[l.jsx(m.LoaderCircle,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[13px] font-medium text-foreground",children:r}),l.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n!==null?l.jsx("span",{className:"font-mono tabular-nums",children:Lz(n)}):"Starting…"})]}),l.jsx(Ft.Maximize2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground/70"})]}),l.jsx("div",{className:"border-t border-border/60 bg-muted px-3 py-1.5",children:l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"We'll notify you when it's ready"})})]})}function Cut({title:e,durationSeconds:t,status:n,onView:r,onDismiss:o}){const s=n==="success";return l.jsx("div",{className:m.cn("border-b px-4 py-2.5",s?Er.success.surface:Er.danger.surface),role:"status",children:l.jsxs("div",{className:"flex items-start gap-2.5",children:[l.jsx("div",{className:m.cn("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full",s?Er.success.iconBg:Er.danger.iconBg),children:s?l.jsx(m.Check,{className:m.cn("h-3 w-3",Er.success.icon)}):l.jsx(Me.X,{className:"h-3 w-3 text-destructive"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-[13px] font-medium text-foreground",children:e}),t!==null&&s?l.jsxs("p",{className:"mt-0.5 text-[11px] text-foreground/70",children:["Generated in ",Lz(t)]}):null]}),s?l.jsxs("button",{type:"button",onClick:r,className:"inline-flex h-6 items-center gap-1 rounded-control bg-primary px-2 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:["View result",l.jsx(Qv,{className:"h-3 w-3"})]}):null,l.jsx("button",{type:"button",onClick:o,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Dismiss",children:l.jsx(Me.X,{className:"h-3 w-3"})})]})})}function Sut({run:e}){const t=Jfe(e==null?void 0:e.startedAt);return t===null?null:l.jsxs("span",{className:"inline-flex shrink-0 items-center whitespace-nowrap font-mono text-[11px] leading-none tabular-nums text-muted-foreground",children:["· ",Lz(t)]})}function Nut({pendingAction:e,previewRun:t,savedActiveRun:n,onShowDetails:r,onCancelPreviewRun:o,onCancelSavedRun:s,onMinimizeRun:i,detailsVisible:a}){var y,C,w,N;const c=t&&wh(t.status)?t:null,u=n;let d=null,f=null,h=!1;if(e==="plan"?(d="Reviewing your brief",f="Reading the brief and planning the analysis…"):e==="preview"?(d="Starting preview run",f="Starting the preview…"):e==="run"?(d="Starting run",f="Preparing the run…"):c?(d=(y=c.progress)!=null&&y.label?dk(c.progress.label):"Running preview",f=((C=c.progress)==null?void 0:C.detail)??null,h=!!c.progress):u&&(d=(w=u.progress)!=null&&w.label?dk(u.progress.label):"Running",f=((N=u.progress)==null?void 0:N.detail)??null,h=!!u.progress),!d)return null;const p=!a&&f,g=u??c,b=!!(u&&i)&&e!=="cancelRun",x=u?s:c?o:void 0;return l.jsx("div",{className:"border-b border-border bg-muted/60","aria-live":"polite","aria-label":"Run progress",children:l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-[12px]",children:[l.jsx(m.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),l.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:d}),l.jsx(Sut,{run:g}),p?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"shrink-0 text-border",children:"·"}),l.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:f})]}):null,l.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[h?l.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground","aria-expanded":a,"aria-label":a?"Hide details":"Show details",title:a?"Hide details":"Show details",children:l.jsx(Me.ChevronDown,{className:m.cn("h-3 w-3 transition-transform",a&&"rotate-180")})}):null,b&&i?l.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-control border border-border bg-background px-2 text-[11px] font-medium text-foreground hover:bg-muted","aria-label":"Run in background",title:"Run in background — we'll save the result",children:[l.jsx(Ft.Minimize2,{className:"h-3 w-3"}),"Run in background"]}):null,x?l.jsx("button",{type:"button",onClick:x,disabled:e==="cancelRun",className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50","aria-label":"Cancel run",title:"Cancel run",children:e==="cancelRun"?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin"}):l.jsx(Me.X,{className:"h-3 w-3"})}):null]})]})})}function lhe(e){if(!e.result||typeof e.result!="object"||Array.isArray(e.result))return[];const t=e.result.warnings;return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function jut(e){var t,n;return((n=(t=e.result)==null?void 0:t.limits)==null?void 0:n.previewKind)==="email_package"}function che({children:e,muted:t}){return l.jsx("span",{className:m.cn("inline-flex min-h-6 max-w-full items-center rounded-control border px-2 py-1 text-[12px] leading-[1.25]",t?"border-dashed border-border bg-muted text-muted-foreground":"border-border bg-muted text-foreground"),children:e})}function kut({recipient:e}){const[t,n]=v.useState(!1),r=e.previewMembers??[];return e.type==="group"&&r.length>0?l.jsxs("div",{className:"relative inline-flex",children:[l.jsxs("button",{type:"button",className:"inline-flex min-h-6 max-w-full items-center rounded-control border border-border bg-muted px-2 py-1 text-left text-[12px] leading-[1.25] text-foreground hover:border-border",onClick:()=>n(s=>!s),"aria-expanded":t,children:[l.jsx("span",{className:"min-w-0 truncate",children:e.label}),e.detail?l.jsx("span",{className:"ml-1.5 min-w-0 truncate text-muted-foreground",children:e.detail}):null,t?l.jsx(Me.ChevronDown,{className:"ml-1.5 h-3 w-3 shrink-0 text-muted-foreground"}):l.jsx(Ft.ChevronRight,{className:"ml-1.5 h-3 w-3 shrink-0 text-muted-foreground"})]}),t?l.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1 w-[280px] rounded-card border border-border bg-background p-2 shadow-md",children:[l.jsx("div",{className:oo,children:"Members"}),l.jsx("div",{className:"mt-1.5 space-y-1",children:r.map((s,i)=>l.jsxs("div",{className:"rounded-control bg-muted px-2 py-1.5 text-[12px] leading-4",children:[l.jsx("div",{className:"truncate text-foreground",children:s.label}),s.detail?l.jsx("div",{className:"truncate text-muted-foreground",children:s.detail}):null]},`${s.type}-${s.label}-${i}`))}),e.hasMoreMembers?l.jsxs("div",{className:"mt-1.5 text-[11px] text-muted-foreground",children:["Showing first ",r.length," of ",e.memberCount??"many"," members"]}):null]}):null]}):l.jsxs(che,{children:[l.jsx("span",{className:"min-w-0 truncate",children:e.label}),e.detail?l.jsx("span",{className:"ml-1.5 min-w-0 truncate text-muted-foreground",children:e.detail}):null]})}function uhe({markdown:e,className:t}){return l.jsx("div",{className:m.cn("text-[13px] leading-[1.6] text-foreground ",t),children:l.jsx(Rz,{remarkPlugins:[Oz],components:{h1:({children:n})=>l.jsx("h1",{className:"mb-4 text-[18px] font-semibold leading-6 text-foreground",children:n}),h2:({children:n})=>l.jsx("h2",{className:"mb-2 mt-5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground first:mt-0",children:n}),h3:({children:n})=>l.jsx("h3",{className:"mb-2 mt-4 text-[13px] font-semibold text-foreground",children:n}),p:({children:n})=>l.jsx("p",{className:"mb-3 max-w-[760px] text-[13px] leading-[1.65] text-foreground last:mb-0",children:n}),ul:({children:n})=>l.jsx("ul",{className:"mb-4 max-w-[760px] list-disc space-y-1.5 pl-5 text-[13px] leading-[1.6] marker:text-muted-foreground/70 last:mb-0",children:n}),ol:({children:n})=>l.jsx("ol",{className:"mb-4 max-w-[760px] list-decimal space-y-1.5 pl-5 text-[13px] leading-[1.6] marker:text-muted-foreground/70 last:mb-0",children:n}),li:({children:n})=>l.jsx("li",{className:"pl-0.5",children:n}),table:({children:n})=>l.jsx("div",{className:"my-4 overflow-x-auto rounded-card border border-border",children:l.jsx("table",{className:"w-full min-w-full border-collapse text-[12px]",children:n})}),th:({children:n})=>l.jsx("th",{className:"border-b border-border bg-muted px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:n}),td:({children:n})=>l.jsx("td",{className:"border-b border-border/60 px-3 py-2 align-top text-foreground last:border-b-0",children:n}),a:({children:n,href:r})=>l.jsx("a",{href:r,className:"font-medium text-primary underline decoration-primary/30 underline-offset-2 hover:text-primary",target:r!=null&&r.startsWith("#")?void 0:"_blank",rel:r!=null&&r.startsWith("#")?void 0:"noreferrer",children:n}),img:({alt:n,src:r})=>l.jsx("img",{alt:n??"",src:r??"",className:"my-4 max-h-[280px] w-auto max-w-full rounded-card border border-border object-contain"}),blockquote:({children:n})=>l.jsx("blockquote",{className:"my-4 max-w-[760px] border-l-2 border-border pl-3 text-foreground/70",children:n}),hr:()=>l.jsx("hr",{className:"my-5 border-border"}),code:({children:n})=>l.jsx("code",{className:"rounded-control bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:n}),pre:({children:n})=>l.jsx("pre",{className:"my-4 overflow-x-auto rounded-card border border-border bg-muted p-3 font-mono text-[11px] leading-[1.55] text-foreground/80",children:n})},children:e})})}function fk({preview:e,onExpand:t,reportMode:n=!1}){var a;const[r,o]=v.useState("rendered"),s=!!((a=e.bodyHtml)!=null&&a.trim()),i=oT(n);return l.jsxs("article",{className:"overflow-hidden rounded-card border border-border bg-background",children:[l.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border/60 px-4 py-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("h3",{className:"truncate text-[14px] font-semibold leading-5 text-foreground",children:e.subject||"Untitled"}),l.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"text-muted-foreground/70",children:"To"}),e.recipients.length>0?e.recipients.map((c,u)=>l.jsx(kut,{recipient:c},`${c.type}-${c.label}-${u}`)):l.jsx("span",{className:"italic text-muted-foreground/70",children:"No recipients"}),!n&&e.channels.length>0?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border",children:"·"}),l.jsxs("span",{children:["via ",e.channels.join(", ").toLowerCase()]})]}):null]})]}),s||t?l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s&&!n?l.jsx(m.Tabs,{value:r,onValueChange:c=>o(c==="html"?"html":"rendered"),children:l.jsxs(m.TabsList,{size:"xs",children:[l.jsx(m.TabsTrigger,{value:"rendered",children:"Rendered"}),l.jsx(m.TabsTrigger,{value:"html",children:"HTML"})]})}):null,t?l.jsx("button",{type:"button",onClick:t,"aria-label":"Expand preview to a larger view",className:"-mr-1 -mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground/70 hover:bg-muted hover:text-foreground/80",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}):null]}):null]}),r==="html"&&s?l.jsx(the,{html:e.bodyHtml??"",title:i.emailHtmlPreviewTitle,className:"h-[620px] rounded-none border-0"}):l.jsx(uhe,{markdown:e.body,className:"px-4 py-3.5"}),e.attachments.length>0||e.attachmentNotice?l.jsxs("footer",{className:"border-t border-border/60 px-4 py-2",children:[e.attachments.length>0?l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx("span",{children:"Attached:"}),e.attachments.map(c=>l.jsx(che,{children:c},c))]}):null,e.attachmentNotice?l.jsxs("div",{className:"mt-2 flex items-start gap-1.5 rounded-card border border-border bg-muted px-2.5 py-1.5 text-[11px] leading-[1.45] text-muted-foreground",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{children:e.attachmentNotice})]}):null]}):null]})}function bg(e){if(!wo(e))return null;const t=e.text;return typeof t=="string"?t:null}function _ut(e){return e.type==="header"||e.type==="section"?bg(e.text):e.type==="context"&&Array.isArray(e.elements)&&e.elements.map(n=>wo(n)?bg(n):null).filter(n=>!!n).join(" · ")||null}function Iut(e){return e.flatMap(t=>t.type!=="actions"||!Array.isArray(t.elements)?[]:t.elements.flatMap(n=>{if(!wo(n))return[];const r=bg(n.text);return r?[r]:[]}))}function Tut(e){const t={header:null,context:null,sections:[],actions:null};for(const n of e)n.type==="header"&&!t.header?t.header=n:n.type==="context"&&!t.context?t.context=n:n.type==="actions"&&!t.actions?t.actions=n:n.type==="section"&&t.sections.push(n);return t}function n2({size:e=6}){const t=e===5?"h-5 w-5":"h-6 w-6";return l.jsx("div",{className:m.cn("flex shrink-0 items-center justify-center rounded-[4px] bg-foreground",t),"aria-hidden":!0,children:l.jsxs("svg",{viewBox:"0 0 100 100",fill:"none",className:"h-[60%] w-[60%] text-background",children:[l.jsx("rect",{x:"20",y:"15",width:"60",height:"12",rx:"6",fill:"currentColor"}),l.jsx("rect",{x:"20",y:"35",width:"40",height:"12",rx:"6",fill:"currentColor"}),l.jsx("rect",{x:"40",y:"55",width:"40",height:"12",rx:"6",fill:"currentColor"}),l.jsx("rect",{x:"20",y:"75",width:"60",height:"12",rx:"6",fill:"currentColor"})]})})}function Eut({channel:e}){const n=/^[CDG][A-Z0-9]{6,}$/.test(e)?e:e.startsWith("#")?e.slice(1):e;return l.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[l.jsx(bb,{className:"h-3 w-3"}),l.jsx("span",{className:"truncate",children:n})]})}function Dut({preview:e,onExpand:t,trustLine:n,reactions:r}){const o=Tut(e.blocks),s=o.header?bg(o.header.text):null,i=o.context?_ut(o.context):null,a=o.sections.map(f=>bg(f.text)).filter(f=>!!f),c=o.actions?Iut([o.actions]):[],[u,d]=v.useState(!0);return l.jsxs("article",{className:"overflow-hidden rounded-card border border-border bg-background",children:[l.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-border/60 px-4 py-3",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l.jsx(_R,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"truncate text-[13px] font-semibold leading-5 text-foreground",children:"Slack message preview"}),l.jsx("div",{className:"mt-0.5",children:l.jsx(Eut,{channel:e.channel})})]})]}),t?l.jsx("button",{type:"button",onClick:t,"aria-label":"Expand preview to a larger view",className:"-mr-1 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground/70 hover:bg-muted hover:text-foreground/80",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}):null]}),l.jsxs("div",{className:"px-4 py-3.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(n2,{size:6}),l.jsx("span",{className:"text-[12.5px] font-semibold text-foreground",children:"Semaphor"}),l.jsx("span",{className:"rounded-[3px] bg-muted px-1 py-0 text-[9px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:"APP"}),l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"9:00 AM"})]}),s?l.jsx("div",{className:"mt-2 text-[13.5px] font-semibold leading-[1.35] text-foreground",children:s}):null,i?l.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:i}):null,(s||i)&&a.length>0?l.jsx("div",{className:"my-2.5 h-px bg-border/60"}):null,a.length>0?l.jsx("div",{className:"space-y-2 text-[12.5px] leading-[1.55] text-foreground/85",children:a.map((f,h)=>l.jsx("p",{className:"whitespace-pre-line",children:f},`section-${h}`))}):null,c.length>0?l.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:c.map((f,h)=>l.jsx("button",{type:"button",tabIndex:-1,className:m.cn("inline-flex h-7 items-center gap-1.5 rounded-control px-2.5 text-[11.5px] font-medium",h===0?"bg-foreground text-background":"border border-border bg-background text-foreground/80"),children:f},f))}):null,n?l.jsx("div",{className:"mt-2.5 text-[10.5px] italic text-muted-foreground/80",children:n}):null,r&&r.length>0?l.jsx("div",{className:"mt-2 flex items-center gap-1",children:r.map(f=>l.jsxs("span",{className:"inline-flex h-5 items-center gap-1 rounded-full border border-border bg-muted px-1.5 text-[10.5px]",children:[l.jsx("span",{children:f.emoji}),l.jsx("span",{className:"tabular-nums text-muted-foreground",children:f.count})]},f.emoji))}):null,e.thread?l.jsxs("button",{type:"button",onClick:()=>d(f=>!f),className:"mt-2.5 flex items-center gap-1.5 text-[11px] text-foreground/80 hover:underline",children:[l.jsx(n2,{size:5}),l.jsx("span",{className:"font-medium text-foreground",children:"1 reply"}),l.jsxs("span",{className:"text-muted-foreground",children:["· ",u?"hide thread":"view thread"]})]}):null]}),e.thread&&u?l.jsx("div",{className:"mx-4 mb-4 ml-7 border-l-2 border-border/60 pl-3",children:l.jsxs("div",{className:"rounded-card border border-border bg-background p-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(n2,{size:5}),l.jsx("span",{className:"text-[11.5px] font-semibold text-foreground",children:"Semaphor"}),l.jsx("span",{className:"rounded-[3px] bg-muted px-1 py-0 text-[9px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:"APP"}),l.jsx("span",{className:"text-[10.5px] text-muted-foreground",children:"9:00 AM"})]}),l.jsx("div",{className:m.cn(oo,"mb-1 mt-2"),children:"Detail"}),l.jsx("div",{className:"whitespace-pre-line text-[11.5px] leading-[1.55] text-foreground/80",children:e.thread.text})]})}):null]})}function Wl({field:e,value:t,isLast:n}){return l.jsxs("div",{className:m.cn("grid grid-cols-[110px_1fr] gap-3 px-3 py-2 text-[12px]",!n&&"border-b border-border/60 "),children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:e}),l.jsx("div",{className:"text-foreground",children:t})]})}function Mut({plan:e}){const t=e.scope.datasets;return t.length?l.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(n=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-border bg-muted px-1.5 py-0.5 text-[11px] leading-4 text-foreground/80",children:[l.jsx(Go,{className:"h-3 w-3 text-muted-foreground/70"}),n]},n))}):l.jsxs("div",{className:"flex items-start gap-1.5 text-muted-foreground",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{children:"No reachable datasets discovered during plan preview. Choose a dashboard, domain, metric, or more specific business question before running."})]})}function Rut({order:e,title:t,detail:n,optional:r}){const[o,s]=v.useState(!1);return l.jsxs("li",{className:"flex items-start gap-3",children:[l.jsx("span",{className:m.cn("mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",r?"border-border text-muted-foreground/70 0":"border-border/60 text-foreground "),children:e}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:m.cn("text-[12.5px] leading-[1.45]",r?"text-foreground/70 ":"text-foreground "),children:[t,r?l.jsx("span",{className:"ml-1.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground/70",children:"if needed"}):null]}),n?l.jsxs("div",{className:"mt-0.5 text-[11px] leading-[1.5] text-muted-foreground",children:[l.jsx("div",{className:m.cn("whitespace-pre-wrap break-words",!o&&`line-clamp-${PW}`),style:o?void 0:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:PW,overflow:"hidden"},children:n}),n.length>220?l.jsx("button",{type:"button",onClick:()=>s(i=>!i),className:"mt-0.5 text-[11px] text-foreground/60 hover:text-foreground",children:o?"Show less":"Show all fields"}):null]}):null]})]})}function OW({previewRun:e,onExpand:t,fullWidth:n,reportMode:r=!1}){var x,y,C,w,N,S;const o=e.result,s=oT(r),i=(x=o==null?void 0:o.artifactPreview)==null?void 0:x.markdown,a=(y=o==null?void 0:o.artifactPreview)==null?void 0:y.html,c=jut(e),u=c?aut((C=o==null?void 0:o.limits)==null?void 0:C.emailPreview):null,d=((w=o==null?void 0:o.limits)==null?void 0:w.previewKind)==="slack_message"?lut(o.limits.slackPreview):null,f=e.status==="FAILED",h=f&&!!((N=e.error)!=null&&N.toLowerCase().includes("cancel")),p=f?Er.danger:Er.success,g=f?Er.danger.icon:Er.success.label,b=h?"Cancelled":f?"Failed":"Complete";return l.jsxs("div",{className:m.cn("space-y-4",n&&"max-w-none"),"aria-label":s.previewResultLabel,children:[c?null:l.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-card border border-border/60 bg-muted/60 px-3 py-2",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[l.jsxs("span",{className:m.cn("inline-flex items-center gap-1",g),children:[l.jsx("span",{className:m.cn("h-1.5 w-1.5 rounded-full",p.dot)}),b]}),l.jsx("span",{className:"text-border",children:"·"}),l.jsx("span",{className:"text-muted-foreground",children:"Preview run"})]}),t?l.jsxs("button",{type:"button",onClick:t,className:m.cn(gv,"h-6 px-1.5 text-[11px]"),"aria-label":"Expand preview to a larger view",children:[l.jsx(Ft.Maximize2,{className:"h-3 w-3"}),"Expand"]}):null]}),r&&c?null:l.jsxs("div",{children:[l.jsx("div",{className:oo,children:c?"Email preview":d?"Slack preview":"The story"}),!c&&!d?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"mt-2 text-[15px] font-semibold leading-6 text-foreground",children:(o==null?void 0:o.title)??(f?s.previewStoppedLabel:s.previewLabel)}),f&&e.error?l.jsx("p",{role:"alert",className:m.cn("mt-2 rounded-card border px-3 py-2 text-[12px] leading-[1.5]",Er.danger.surface),children:e.error}):null,o!=null&&o.summary?l.jsx("p",{className:"mt-2 text-[13px] leading-[1.55] text-foreground/80",children:o.summary}):null]}):null]}),u?l.jsx(fk,{preview:u,onExpand:t,reportMode:r}):d?l.jsx(Dut,{preview:d,onExpand:t,trustLine:"Runs with your permissions on this dashboard's data"}):i?l.jsx("article",{className:m.cn("rounded-card border border-border px-4 py-3",c&&"bg-background "),children:l.jsx(uhe,{markdown:i})}):a?l.jsx(the,{html:a,title:s.htmlArtifactTitle,className:n?"h-[820px]":"h-[680px]"}):l.jsx("div",{className:"rounded-card border border-dashed border-border px-4 py-6 text-center text-[12px] text-muted-foreground",children:s.missingArtifactLabel}),(S=o==null?void 0:o.warnings)!=null&&S.length&&!c?l.jsx("div",{className:"rounded-card border border-border bg-muted px-3 py-2 text-[11px] leading-[1.55] text-muted-foreground",children:l.jsxs("div",{className:"flex items-start gap-1.5",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{children:o.warnings.join(" ")})]})}):null]})}function LW({run:e,onExpand:t,reportMode:n=!1,onDeleteRun:r,onRetryRun:o,retryDisabled:s,retryDisabledReason:i,deletePending:a}){const c=ehe(e),u=oT(n),d=e.status==="FAILED";return l.jsxs("div",{className:"space-y-4","aria-label":"Run result",children:[d?l.jsx(ohe,{run:e,onRetryRun:o,retryDisabled:s,retryDisabledReason:i,onDeleteRun:r,deletePending:a}):null,c?n?l.jsx(fk,{preview:c,onExpand:t,reportMode:!0}):l.jsxs("div",{children:[l.jsx("div",{className:oo,children:"Email"}),l.jsx("div",{className:"mt-2",children:l.jsx(fk,{preview:c,onExpand:t})})]}):null,!c&&wo(e.result)&&typeof e.result.summary=="string"?l.jsxs("div",{children:[l.jsx("div",{className:oo,children:u.titleNoun}),l.jsx("article",{className:"mt-2 rounded-card border border-border px-4 py-3 text-[13px] leading-[1.55] text-foreground",children:e.result.summary})]}):null,l.jsx(but,{run:e}),l.jsx(rhe,{run:e,labelPrefix:"Run"})]})}function Aut({previewRun:e,isStale:t,onViewOutput:n}){var o,s;const r=((o=e.result)==null?void 0:o.title)??((s=e.result)==null?void 0:s.summary)??"Generated briefing preview";return l.jsx("div",{className:m.cn("rounded-card border px-3 py-2",Er.success.surface),children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:m.cn("flex items-center gap-1.5 text-[11px] font-medium",Er.success.label),children:[l.jsx(m.Check,{className:"h-3 w-3 shrink-0"}),l.jsx("span",{children:"Preview output available"})]}),l.jsx("div",{className:"mt-1 truncate text-[12px] text-foreground/80",children:r}),t?l.jsx("div",{className:"mt-0.5 text-[10px] leading-[1.45] text-muted-foreground",children:"Generated before your latest edits."}):null]}),l.jsxs("button",{type:"button",className:ou,onClick:n,children:[l.jsx(Bd,{className:"h-3 w-3"}),"View output"]})]})})}function r1(e,t){return e.includes(t)?e:[...e,t]}function Put(e,t){const n=e.filter(r=>r!==t);return n.length>0?n:[t]}const Fut={createBriefing:jde,updateBriefing:rT,pauseBriefing:kde,resumeBriefing:_de,deleteBriefing:Ide,getBriefing:Nde,runBriefingNow:Tde,getBriefingRun:Ade,cancelBriefingRun:Pde,deleteBriefingRun:Fde,previewBriefingPlan:Ede,runBriefingPreview:Dde,getBriefingPreviewRun:Mde,cancelBriefingPreviewRun:Rde,polishBriefingText:Ode},$W=2e3,Out=10*6e4,Lut=20*6e4;function $ut(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`briefing-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ra(e){return e instanceof Error&&e.message?e.message:"Something went wrong. Please try again."}function zut(e){if(!(e instanceof eC))return[];const t=e.details;if(!t||typeof t!="object")return[];const n=t.issues;return Array.isArray(n)?n.filter(r=>!!r&&typeof r=="object"&&typeof r.field=="string"&&typeof r.message=="string"):[]}function But(e,t){return`${e.replace(/\/$/,"")}${t}`}async function r2(e,t,n,r){const o=await fetch(But(e,n),{cache:"no-store",...r,headers:{...(r==null?void 0:r.headers)??{},Authorization:`Bearer ${t}`}}),s=await o.json().catch(()=>({}));if(!o.ok){const i=s&&typeof s=="object"&&"error"in s?String(s.error):"Request failed";throw new Error(i)}return s}function Vut(e){return e==="PAUSED"||e==="DISABLED"?"bg-muted text-muted-foreground":"bg-primary/10 text-primary"}function dhe({apiServiceUrl:e,token:t,briefing:n,intent:r="analytical_briefing",initialAttachments:o,initialName:s,initialMessage:i,initialTimezone:a,availableDashboards:c,sourceContext:u,title:d="Briefing",hideHeader:f=!1,className:h,client:p,generateRequestId:g=$ut,onSaved:b,onDeleted:x,onRunStarted:y,onCancel:C,onBack:w,onMinimizeRun:N}){var iB,aB,lB,cB,uB,dB,fB,hB;const{authToken:S,tokenProps:j}=Et(),I=((aB=(iB=j.config)==null?void 0:iB.projectFeatures)==null?void 0:aB.features.aiWritingHelpers)!==!1,k=((cB=(lB=j.config)==null?void 0:lB.projectFeatures)==null?void 0:cB.features.analyticalBriefings)!==!1,{currentUser:T,isLoading:_,isError:E}=si(),D=!_&&!E&&!!T,M=!n&&r==="scheduled_report",P=m.useDashboardStore(Xe=>Xe.dashboard),A=m.useDashboardStore(Xe=>Xe.theme),z=m.useDashboardStore(Xe=>Xe.selectedSheetId),O=m.useDashboardStore(Xe=>Xe.filterValues),B=m.useDashboardStore(Xe=>Xe.controlValues),H=m.useDashboardStore(Xe=>Xe.semanticExecutionPayload),R=m.useDashboardStore(Xe=>Xe.cardControlValuesMap),q=m.useDashboardStore(Xe=>Xe.inlineFilterValuesMap),$=m.useDashboardStore(Xe=>Xe.dashboardInputValues),F=m.useDashboardStore(Xe=>{var xt;return(xt=Xe.reportContext)==null?void 0:xt.calendar.tz}),U=m.useInteractionStore(Xe=>Xe.interactionStates),G=e??(j==null?void 0:j.apiServiceUrl),Q=t??(S==null?void 0:S.accessToken),W=v.useMemo(()=>({...Fut,...p}),[p]),L=v.useMemo(()=>Kde({briefing:n,sourceContext:u}),[n,u]),K=v.useMemo(()=>iut(T),[T]),Y=a??crt(F),[V,Z]=v.useState(n??null),[X,te]=v.useState(()=>FU({briefing:n,sourceContext:L,defaultRecipient:K,intent:r,initialAttachments:o,initialName:s,initialMessage:i,timezone:Y})),[re,ie]=v.useState(null),[se,le]=v.useState([]),[ae,xe]=v.useState(null),[fe,be]=v.useState(null),[pe,ye]=v.useState(null),[ce,J]=v.useState(null),[ne,ee]=v.useState(0),[ue,ge]=v.useState(null),[_e,Te]=v.useState(!1),[Ce,Re]=v.useState("edit"),[Ve,Ee]=v.useState(!1),[We,Ie]=v.useState("EMAIL"),[we,de]=v.useState(!1),[Se,Le]=v.useState(null),[Ae,st]=v.useState(null),[$e,Ke]=v.useState([]),[at,ct]=v.useState(!1),[rt,ht]=v.useState(null),[wt,gt]=v.useState(0),[At,Pe]=v.useState(null),[Ze,mt]=v.useState(!1),[ft,yt]=v.useState(!1),[Dt,Mt]=v.useState(null),[bt,Tt]=v.useState(null);v.useEffect(()=>{if(!bt)return;const Xe=window.setTimeout(()=>Tt(null),12e3);return()=>window.clearTimeout(Xe)},[bt]);const Ut=v.useRef(void 0),{activeRunId:un,resetTerminalRun:Qe,startRun:ze,stop:Oe}=bF({apiServiceUrl:G,token:Q,intervalMs:$W,timeoutMs:Lut,fetchRun:({apiServiceUrl:Xe,token:xt,runId:Xt})=>{if(!(V!=null&&V.id))throw new Error("Missing saved item id for run polling.");return W.getBriefingRun(Xe,xt,V.id,Xt)},onRun:Xe=>{be(Xe)},onTerminalRun:Xe=>{Re("result"),xe(null)},onError:Xe=>{xe(`Unable to refresh run status: ${ra(Xe)}`)},onTimeout:()=>{xe("Run status refresh timed out. Refresh the run to check the latest status.")}}),{activeRunId:he,startRun:Be,stop:ot}=bF({apiServiceUrl:G,token:Q,intervalMs:$W,timeoutMs:Out,fetchRun:({apiServiceUrl:Xe,token:xt,runId:Xt})=>W.getBriefingPreviewRun(Xe,xt,Xt),onRun:Xe=>{J(Xe),Xe.status==="SUCCESS"&&ge(xt=>xt??ne)},onTerminalRun:Xe=>{Xe.status==="FAILED"?xe(Xe.error||"Briefing preview failed."):(xe(null),Re("result"))},onError:Xe=>{xe(`Unable to refresh briefing preview status: ${ra(Xe)}`)},onTimeout:Xe=>{J(xt=>(xt==null?void 0:xt.id)===Xe?{...xt,status:"FAILED",completedAt:xt.completedAt??new Date().toISOString(),error:xt.error||"Briefing preview status refresh timed out."}:xt),xe("Briefing preview status refresh timed out.")}}),Rt=!!(V!=null&&V.id),an=(V==null?void 0:V.status)==="PAUSED"||X.schedule.status==="PAUSED",Ne=Rt&&!!(V!=null&&V.scheduleExpr||X.schedule.enabled),Fe=fe??(V==null?void 0:V.latestRun)??null,De=Fe&&wh(Fe.status)&&un===Fe.id?Fe:null,Ue=Fe&&DF(Fe.status)?Fe:null,Nt=ce&&DF(ce.status)?ce:null,it=Ce==="result"&&(Nt||Ue)?"result":Ce==="plan"&&pe?"plan":"edit",Vt=L.detail??(X.source.type==="dashboard"?(P==null?void 0:P.title)??null:"All project data available to this token"),Ot=(V==null?void 0:V.status)??X.schedule.status,Tn=ce!==null&&wh(ce.status)&&he===ce.id,ir=Tn||De!==null,qe=re!==null||ir,nt=it==="edit"&&Ue!==null&&!ir,dt=(ce==null?void 0:ce.status)==="SUCCESS"&&ce.result?ce:null,jt=dt!==null&&ue!==null&&ue!==ne,Ht=Se==="preview"?ce:null,yn=Se==="saved"?Ue:null,_r=yn?ehe(yn):null,Ps=((uB=Ht==null?void 0:Ht.result)==null?void 0:uB.title)??(_r==null?void 0:_r.subject)??(wo(yn==null?void 0:yn.result)&&typeof yn.result.title=="string"?yn.result.title:null)??(V==null?void 0:V.name)??"Briefing preview",Fs=v.useMemo(()=>({dashboard:P,theme:A||"light",filters:P==null?void 0:P.filters,selectedSheetId:z,filterValues:O,inlineFilterValuesMap:q,controlValues:B,controlDefinitions:(P==null?void 0:P.controls)||[],dashboardControls:(P==null?void 0:P.controls)||[],cardControlValuesMap:R,dashboardInputValues:$,semanticExecutionPayload:H,interactionStates:U}),[R,B,P,$,O,U,q,H,z,A]);v.useEffect(()=>{const Xe=(n==null?void 0:n.id)??null;if(Ut.current===Xe)return;Ut.current=Xe,Qe(),Oe(),ot(),Z(n??null);let xt=FU({briefing:n,sourceContext:L,defaultRecipient:K,intent:r,initialAttachments:o,initialName:s,initialMessage:i,timezone:Y});!n&&r==="scheduled_report"&&xt.attachments.length===0&&xt.source.type==="dashboard"&&(xt=pv(xt,{attachments:unt({source:xt.source,dashboard:P,selectedSheetId:z,runtime:Fs})})),te(xt),be(null),ye(null),J(null),ge(null);const Xt=(n==null?void 0:n.latestRun)??null;xe(null),Re("edit"),Xt&&wh(Xt.status)&&ze(Xt)},[Fs,n,P,K,o,i,s,r,Qe,L,z,Y,ze,ot,Oe]);const Os=urt({draft:X,scheduledReport:M,identityResolved:D,userType:T==null?void 0:T.type}),ao=Os.draft,Ls=drt({isNew:!n,intent:r,draft:ao}),Xo=oT(Ls),lp=Os.slackAllowed,Wu=Os.emailEnabled,li=Os.slackEnabled,Ku=Wu&&li,Hn=(fB=(dB=X.delivery.channelConfigs)==null?void 0:dB.SLACK)==null?void 0:fB.slackConfig,Ef=((hB=Hn==null?void 0:Hn.destination)==null?void 0:hB.type)==="channel"?Hn.destination.channelId??"":"",La=$e.find(Xe=>Xe.id===Ef),Gu=(Hn==null?void 0:Hn.threadMentions)??[],Nl=Gu.length>0,Cc=JSON.stringify({recipients:Gu}),Sc=li&&!Wu?"SLACK":Wu&&!li?"EMAIL":We,jl=Sc==="EMAIL"?"SLACK":"EMAIL";v.useEffect(()=>{if(!G||!Q||!li)return;let Xe=!1;return ct(!0),ht(null),Promise.all([r2(G,Q,"/v1/integrations/SLACK/status"),r2(G,Q,"/v1/integrations/slack/channels").catch(xt=>{if(xt instanceof Error&&/not configured/i.test(xt.message))return{channels:[]};throw xt})]).then(([xt,Xt])=>{Xe||(st(xt),Ke(Xt.channels))}).catch(xt=>{Xe||(ht(ra(xt)),Ke([]))}).finally(()=>{Xe||ct(!1)}),()=>{Xe=!0}},[li,G,Q,wt]),v.useEffect(()=>{if(!G||!Q||!li){Pe(null);return}if(!Nl||!(Ae!=null&&Ae.installed)){Pe(null);return}let Xe=!1;return r2(G,Q,"/v1/integrations/slack/mention-status",{method:"POST",headers:{"Content-Type":"application/json"},body:Cc}).then(xt=>{Xe||Pe(xt)}).catch(()=>{Xe||Pe(null)}),()=>{Xe=!0}},[li,Nl,G,Q,Ae==null?void 0:Ae.installed,Cc]);const To=Xe=>{te(xt=>pv(xt,Xe)),le([]),xe(null),V!=null&&V.id||(ye(null),ee(xt=>xt+1),Re("edit"))},fs=()=>!G||!Q?(xe("Missing Semaphor API credentials."),null):{apiServiceUrl:G,token:Q},Yu=async Xe=>{const xt=gF(ao);if(M&&ao.attachments.length===0&&(xt.issues.push({field:"attachments",message:"Add at least one report attachment."}),xt.valid=!1),le(xt.issues),xe(null),!xt.valid)return null;const Xt=fs();if(!Xt)return null;Xe!=null&&Xe.pendingAction&&ie(Xe.pendingAction);try{const qr=V!=null&&V.id?await W.updateBriefing(Xt.apiServiceUrl,Xt.token,V.id,Ude(ao)):await W.createBriefing(Xt.apiServiceUrl,Xt.token,pF(ao));return Z(qr.briefing),te(og(qr.briefing)),b==null||b(qr.briefing),qr.briefing}catch(qr){const mB=zut(qr);return mB.length>0?(le(mB),xe(null)):xe(ra(qr)),null}finally{Xe!=null&&Xe.pendingAction&&ie(null)}},Df=async()=>Yu({pendingAction:"save"}),Ti=()=>{const Xe=gF(ao);return le(Xe.issues),xe(null),Xe.valid?pF(ao):null},$a=async Xe=>{const xt=fs();if(!xt)return null;const Xt=Ti();if(!Xt)return null;ie("plan");try{const qr=await W.previewBriefingPlan(xt.apiServiceUrl,xt.token,Xt);return ye(qr.plan),Xe!=null&&Xe.silent||Re("plan"),qr.plan}catch(qr){return xe(ra(qr)),null}finally{ie(null)}},cp=async()=>{const Xe=fs();if(!Xe)return;const xt=Ti();if(xt)try{const Xt=pe??await $a({silent:!0});if(!Xt)return;ie("preview");const qr=await W.runBriefingPreview(Xe.apiServiceUrl,Xe.token,{draft:xt,planId:Xt.id,requestId:g()});ge(ne),Be(qr.previewRun)}catch(Xt){xe(ra(Xt))}finally{ie(null)}},Nc=async()=>{const Xe=fs();if(Xe){if(!(V!=null&&V.id)){await cp();return}if(qt){xe(`Save your changes before running this ${Xo.noun}.`);return}ie("run"),xe(null),J(null);try{const xt=await W.runBriefingNow(Xe.apiServiceUrl,Xe.token,V.id,{requestId:g()});ze(xt.run),y==null||y(xt)}catch(xt){xe(ra(xt))}finally{ie(null)}}},Mf=async()=>{if(!(V!=null&&V.id))return null;const Xe=fs();if(!Xe)return null;const xt=await W.getBriefing(Xe.apiServiceUrl,Xe.token,V.id);return Z(xt.briefing),te(og(xt.briefing)),b==null||b(xt.briefing),xt.briefing},Ye=async()=>{if(!(V!=null&&V.id)||!(De!=null&&De.id))return;const Xe=fs();if(Xe){ie("cancelRun"),xe(null);try{const xt=await W.cancelBriefingRun(Xe.apiServiceUrl,Xe.token,V.id,De.id);Oe(),be(xt.run),Re("result"),await Mf().catch(()=>null)}catch(xt){xe(ra(xt))}finally{ie(null)}}},Yt=async()=>{if(!Tn||!(ce!=null&&ce.id))return;const Xe=fs();if(Xe){ie("cancelRun"),xe(null);try{const xt=await W.cancelBriefingPreviewRun(Xe.apiServiceUrl,Xe.token,ce.id);ot(),J(xt.previewRun),Re("result")}catch(xt){xe(ra(xt))}finally{ie(null)}}},En=()=>{!V||!De||N==null||N({briefing:{...V,latestRun:De},run:De})},en=async()=>{if(!X.instruction.trim())return;const xt=fs();if(xt){yt(!0),Mt(null);try{const Xt=await W.polishBriefingText(xt.apiServiceUrl,xt.token,X.instruction),qr=X.instruction;To({instruction:Xt}),Tt({previousText:qr})}catch(Xt){Mt(ra(Xt))}finally{yt(!1)}}},sn=()=>{bt&&(To({instruction:bt.previousText}),Tt(null))},me=async Xe=>{if(!(V!=null&&V.id))return;const xt=fs();if(xt){ie("deleteRun"),xe(null);try{await W.deleteBriefingRun(xt.apiServiceUrl,xt.token,V.id,Xe);const Xt=await Mf().catch(()=>null),qr=(Xt==null?void 0:Xt.latestRun)??null;be(qr),qr||Re("edit")}catch(Xt){xe(ra(Xt))}finally{ie(null)}}},je=async Xe=>{if(!(V!=null&&V.id))return;const xt=fs();if(xt){ie(Xe==="PAUSED"?"pause":"resume"),xe(null);try{const Xt=Xe==="PAUSED"?await W.pauseBriefing(xt.apiServiceUrl,xt.token,V.id):await W.resumeBriefing(xt.apiServiceUrl,xt.token,V.id);Z(Xt.briefing),te(og(Xt.briefing)),b==null||b(Xt.briefing)}catch(Xt){xe(ra(Xt))}finally{ie(null)}}},He=X.instruction.split(`
1301
- `).map(Xe=>Xe.trim()).find(Xe=>Xe.length>0),kt=v.useMemo(()=>V?og(V):null,[V]),qt=!!kt&&JSON.stringify(ao)!==JSON.stringify(kt),Dn=X.body.type==="custom_message",ar=Rt&&!k&&X.body.type==="generated_analysis",Ln=X.source.type==="dashboard"||!!(c!=null&&c.length),fr=Dn?Ls?"Message (optional)":"Email body":"What should this briefing investigate?",Ei=Dn?"Write the email body that recipients will see.":"Describe the outcome in business terms. Mention what to watch, when to bother the team, and what to include in the briefing.",$s=Dn?"Sent as-is in the email body. No analysis is generated.":"Tell the analyst what to watch, when to escalate, and what to include.",Zu=Xe=>{var xt,Xt;if(Ie(Xe),Xe==="EMAIL"){To({delivery:{channels:r1(X.delivery.channels,"EMAIL")}});return}To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((xt=X.delivery.channelConfigs)==null?void 0:xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:((Xt=Hn==null?void 0:Hn.destination)==null?void 0:Xt.type)==="channel"?Hn.destination:{type:"channel",channelId:""},postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},gx=()=>{if(Ku){To({delivery:{channels:Put(X.delivery.channels,jl)}});return}Zu(jl)},bx=Xe=>{var Xt;const xt=$e.find(qr=>qr.id===Xe);Ie("SLACK"),To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((Xt=X.delivery.channelConfigs)==null?void 0:Xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:{type:"channel",channelId:Xe,...xt?{channelName:xt.name}:{},...xt?{isPrivate:xt.isPrivate}:{}},postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},wC=Xe=>{var xt,Xt;Ie("SLACK"),To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((xt=X.delivery.channelConfigs)==null?void 0:xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:((Xt=Hn==null?void 0:Hn.destination)==null?void 0:Xt.type)==="channel"?Hn.destination:{type:"channel",channelId:""},threadMentions:Xe,postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},pye=v.useMemo(()=>{const Xe=X.schedule.enabled?tt.describeBriefingSchedule(X.schedule.scheduleExpr,X.schedule.timezone)??"Invalid schedule":"On demand",xt=X.delivery.recipients.length,Xt=xt===0?"No email recipients":`${xt} email recipient${xt===1?"":"s"}`,qr=La?`#${La.name}`:"Slack channel";return Ku?`${Xe} · ${Xt} · ${qr}`:li?`${Xe} · ${La?`#${La.name}`:"Slack channel"}`:`${Xe} · ${Xt}`},[X.delivery.recipients.length,X.schedule.enabled,X.schedule.scheduleExpr,X.schedule.timezone,Ku,li,La]);return l.jsxs("section",{className:m.cn("flex h-full min-h-0 w-full max-w-[480px] flex-col border-l border-border bg-background text-foreground",h),"aria-label":Xo.authorLabel,children:[f?null:l.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[l.jsxs("div",{className:"min-w-0",children:[w?l.jsxs("button",{type:"button",onClick:w,className:"-ml-1 mb-1 inline-flex items-center gap-1 rounded-control px-1 py-0.5 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 rotate-180"}),"Back to ",Xo.plural]}):null,l.jsx("h2",{className:"truncate text-[14px] font-semibold leading-5 text-foreground",children:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[Rt?l.jsx("span",{className:m.cn("inline-flex items-center rounded-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-[0.06em]",Vut(Ot)),children:Ot}):null,C?l.jsx("button",{type:"button","aria-label":Xo.closeLabel,onClick:C,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Me.X,{className:"h-3.5 w-3.5"})}):null]})]}),it!=="edit"?l.jsxs("button",{type:"button",onClick:()=>Re("edit"),className:"flex w-full items-center justify-between gap-2 border-b border-border px-4 py-2.5 text-left transition-colors hover:bg-muted/60",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] text-foreground/80",children:He||X.name||Xo.untitledLabel}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:pye})]}),l.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[Xo.editLabel,l.jsx(Me.ChevronDown,{className:"h-3 w-3 rotate-180"})]})]}):null,De?l.jsx(vut,{}):null,l.jsx(Nut,{pendingAction:re,previewRun:ce,savedActiveRun:De,detailsVisible:Ve,onShowDetails:()=>Ee(Xe=>!Xe),onCancelPreviewRun:Tn?Yt:void 0,onCancelSavedRun:De?Ye:void 0,onMinimizeRun:De&&N?En:void 0}),Ve&&ce&&wh(ce.status)?l.jsx(FW,{run:ce}):Ve&&De?l.jsx(FW,{run:De}):null,l.jsx("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:it==="edit"?l.jsxs(l.Fragment,{children:[ar?l.jsxs("div",{className:"rounded-card border border-amber-200 bg-amber-50 px-3 py-2.5 text-[12px] leading-[1.5] text-amber-900 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-200",children:[l.jsx("div",{className:"font-medium",children:"Analytical briefings are disabled for this project."}),l.jsx("p",{className:"mt-0.5 text-amber-800 dark:text-amber-300",children:"You can pause or delete this briefing while analytical briefings are unavailable."})]}):null,dt?l.jsx(Aut,{previewRun:dt,isStale:jt,onViewOutput:()=>Re("result")}):null,nt&&Ue?l.jsx(yut,{run:Ue,onViewOutput:()=>Re("result"),onDeleteRun:Ue.status==="FAILED"?()=>me(Ue.id):void 0,onRetryRun:Ue.status==="FAILED"&&Rt?()=>{Nc()}:void 0,retryDisabled:qe||Rt&&qt,retryDisabledReason:Rt&&qt?`Save your changes before retrying — Retry uses the saved ${Xo.noun}.`:void 0,deletePending:re==="deleteRun"}):null,Ls?l.jsx(Vnt,{draft:X,onChange:To,onExpand:()=>mt(!0)}):l.jsx(Hnt,{draft:X,onChange:To,onExpand:()=>mt(!0)}),l.jsx(No,{open:Ze,onOpenChange:mt,children:l.jsxs(po,{className:"flex h-[80vh] max-h-[800px] w-[92vw] max-w-[860px] flex-col gap-0 p-0",children:[l.jsxs(Es,{className:"border-b border-border/60 px-5 py-3",children:[l.jsx(go,{className:"text-[14px] font-semibold",children:fr}),Ls?null:l.jsx(Oo,{className:"text-[12px] text-muted-foreground",children:$s})]}),l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-5 py-4",children:[l.jsx("label",{htmlFor:"briefing-instruction-expanded",className:"sr-only",children:fr}),l.jsx("textarea",{id:"briefing-instruction-expanded",autoFocus:!0,className:"min-h-0 flex-1 resize-none bg-transparent text-[14px] leading-[1.6] text-card-foreground/90 outline-none placeholder:text-muted-foreground",value:X.instruction,onChange:Xe=>{To({instruction:Xe.target.value})},placeholder:Ei,"aria-label":fr})]}),l.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 px-5 py-2.5",children:[l.jsx("div",{className:"flex flex-1 items-center gap-2 text-[12px] text-muted-foreground",children:Dt?l.jsx("span",{className:"text-destructive",children:Dt}):bt?l.jsxs("button",{type:"button",onClick:sn,className:"inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-foreground/80 hover:bg-muted hover:text-foreground",children:[l.jsx(UZ,{className:"h-3 w-3"}),"Revert polish"]}):null}),I?l.jsxs("button",{type:"button",onClick:en,disabled:ft||!X.instruction.trim()||!G||!Q,title:"Fix typos, grammar, and minor wording without changing your meaning",className:ou,children:[ft?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin"}):l.jsx(k0,{className:"h-3 w-3"}),ft?"Polishing…":"Polish"]}):null,l.jsx("button",{type:"button",onClick:()=>mt(!1),className:ou,children:"Done"})]})]})}),Ln?l.jsx(ert,{attachments:X.attachments,source:X.source,dashboard:P,selectedSheetId:z,runtime:Fs,availableDashboards:c,disabled:qe,onChange:To}):null,l.jsx(art,{schedule:X.schedule,onChange:To}),l.jsx(grt,{draft:X,effectiveChannels:ao.delivery.channels,reportAuthoring:Ls,slackAllowed:lp,deliveryMode:Sc,secondaryDeliveryMode:jl,hasMultiChannelDelivery:Ku,slackStatus:Ae,slackLoading:at,slackChannels:$e,selectedSlackChannelId:Ef,selectedSlackChannel:La,threadMentions:Gu,slackMentionStatus:At,slackError:rt,apiServiceUrl:G,onChange:To,onDeliveryModeChange:Zu,onSecondaryDeliveryChange:gx,onSlackChannelChange:bx,onSlackMentionsChange:wC,onSlackRefresh:()=>gt(Xe=>Xe+1)}),Dn?null:l.jsxs("div",{children:[l.jsx("div",{className:m.cn(oo,"mb-2"),children:"Scope"}),l.jsx(frt,{source:X.source,resolvedSourceContext:L,sourceDetail:Vt,onChange:Xe=>To({source:Xe})})]})]}):it==="plan"&&pe?l.jsx(put,{previewPlan:pe,previewRun:ce&&ce.status!=="SUCCESS"?ce:null,scopeLabel:L.source.type==="dashboard"?(P==null?void 0:P.title)??L.label:L.label}):it==="result"&&ce?l.jsx(OW,{previewRun:ce,reportMode:Ls,onExpand:()=>{Le("preview"),de(!0)}}):it==="result"&&Ue?l.jsx(LW,{run:Ue,reportMode:Ls,onExpand:()=>{Le("saved"),de(!0)},onDeleteRun:Ue.status==="FAILED"?()=>me(Ue.id):void 0,onRetryRun:Ue.status==="FAILED"&&Rt?()=>{Nc()}:void 0,retryDisabled:qe||Rt&&qt,retryDisabledReason:Rt&&qt?`Save your changes before retrying — Retry uses the saved ${Xo.noun}.`:void 0,deletePending:re==="deleteRun"}):null}),se.length>0||ae?l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-destructive/30 bg-destructive/10 px-4 py-2.5",children:[se.length>0?l.jsxs("div",{role:"alert",className:"text-[12px] leading-[1.5] text-destructive",children:[l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1.5 font-medium",children:[l.jsx(m.Info,{className:"h-3 w-3"}),"Fix these before saving:"]}),l.jsx("ul",{className:"space-y-0.5 pl-4",children:se.map(Xe=>l.jsx("li",{className:"list-disc marker:text-destructive/60",children:Xe.message},`${Xe.field}:${Xe.message}`))})]}):null,ae?l.jsxs("div",{role:"alert",className:"flex items-start gap-1.5 text-[12px] leading-[1.55] text-destructive",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{children:ae})]}):null]}):null,l.jsx(trt,{existing:Rt,activeView:it,scheduledReport:M,scheduleEnabled:X.schedule.enabled,customMessage:Dn,contentNoun:Xo.noun,analyticalBriefingsEnabled:k,analysisUnavailable:ar,canToggleScheduleStatus:Ne,paused:an,busy:qe,draftDirty:qt,hasActiveRun:ir,pendingAction:re,canDiscard:!Rt&&!!C&&!w,onStatusChange:je,onEdit:()=>Re("edit"),onDiscard:()=>C==null?void 0:C(),onPlan:()=>{$a()},onRun:()=>{Nc()},onSave:()=>{Df()}}),l.jsx(No,{open:we,onOpenChange:Xe=>{de(Xe),Xe||Le(null)},children:l.jsxs(po,{className:"flex max-h-[90vh] w-[min(960px,calc(100vw-32px))] max-w-none flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"border-b border-border px-6 py-3 text-left",children:[l.jsx(go,{className:"truncate text-[14px] font-semibold leading-5",children:Ps}),l.jsx(Oo,{className:"text-[12px] text-muted-foreground",children:Xo.expandedDescription})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:Ht?l.jsx(OW,{previewRun:Ht,reportMode:Ls,fullWidth:!0}):_r?l.jsx(fk,{preview:_r,reportMode:Ls}):yn?l.jsx(LW,{run:yn,reportMode:Ls}):null})]})})]})}function fhe({open:e,onOpenChange:t,launchRequest:n,briefing:r,authorProps:o}){return l.jsx(p3,{open:e,onOpenChange:t,children:l.jsxs(gI,{side:"right",hideClose:!0,className:"flex h-full w-full max-w-[480px] flex-col gap-0 overflow-hidden p-0 sm:max-w-[480px]",children:[l.jsx(bI,{className:"sr-only",children:n.title??"Briefing"}),l.jsx(xI,{className:"sr-only",children:"Configure report content, delivery, and schedule."}),e?l.jsx(dhe,{...o,className:m.cn("max-w-none border-0",o==null?void 0:o.className),briefing:r,intent:n.intent,sourceContext:n.sourceContext,initialAttachments:n.initialAttachments,initialName:n.initialName,initialMessage:n.initialMessage,initialTimezone:n.initialTimezone,availableDashboards:n.availableDashboards,title:n.title,onCancel:()=>t(!1)},(r==null?void 0:r.id)??"new"):null]})})}function hhe(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!0}const zz=v.createContext(null);function dT({children:e}){const t=Et(),{currentUser:n,isLoading:r,isError:o}=si(),s=v.useMemo(()=>{var c,u,d;const i=hhe((c=t.tokenProps.config)==null?void 0:c.showBriefings,t.showBriefings);return{surfaceVisible:i,canCreate:i&&(!r&&!o&&!!n)&&tt.canCreateBriefingForUser(n),analyticalBriefingsEnabled:((d=(u=t.tokenProps.config)==null?void 0:u.projectFeatures)==null?void 0:d.features.analyticalBriefings)!==!1,userType:(n==null?void 0:n.type)??null,loading:r,error:o}},[t.showBriefings,t.tokenProps.config,n,o,r]);return l.jsx(zz.Provider,{value:s,children:e})}function Hut({children:e}){return v.useContext(zz)?e:l.jsx(dT,{children:e})}function mhe(){return v.useContext(zz)??{surfaceVisible:!1,canCreate:!1,analyticalBriefingsEnabled:!1,userType:null,loading:!1,error:!0}}const qut=new Set(["table","pivotTable","aggregateTable","matrixTable","detailTable"]);function Uut({card:e,frame:t,exportData:n}){var M,P,A,z;const[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=mhe(),c=m.useDashboardStore(O=>O.dashboard),u=m.useDashboardStore(O=>O.isDashboardEditing),d=m.useDashboardStore(O=>O.isVisualEditing),f=m.useDashboardStore(O=>O.selectedSheetId),h=m.useDashboardStore(O=>O.filterValues),p=m.useDashboardStore(O=>O.inlineFilterValuesMap),g=m.useDashboardStore(O=>O.controlValues),b=m.useDashboardStore(O=>O.cardControlValuesMap),x=m.useDashboardStore(O=>O.dashboardInputValues),y=m.useDashboardStore(O=>O.semanticExecutionPayload),C=m.useDashboardStore(O=>O.theme),w=m.useInteractionStore(O=>O.interactionStates),N=qut.has(e.type),S=((M=e.preferences)==null?void 0:M.allowDownload)!==!1,j=N&&S,I=c==null?void 0:c.id,k=I?{type:"dashboard",dashboardId:I}:null,T=k?rk({source:k,dashboard:c,selectedSheetId:f}).find(O=>O.kind==="card"&&O.cardId===e.id):void 0,_=T?rN({option:T,runtime:{dashboard:c,theme:C||"light",filters:c==null?void 0:c.filters,selectedSheetId:f,filterValues:h,inlineFilterValuesMap:p,controlValues:g,controlDefinitions:(c==null?void 0:c.controls)||[],dashboardControls:(c==null?void 0:c.controls)||[],cardControlValuesMap:b,dashboardInputValues:x,semanticExecutionPayload:y,interactionStates:w}}):void 0,E=a.surfaceVisible&&a.canCreate&&!u&&!d&&(_==null?void 0:_.status)==="ready";if(!j&&!E)return null;const D=(_==null?void 0:_.status)==="ready"?_.attachment:null;return l.jsxs(l.Fragment,{children:[l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(m.Button,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground","aria-label":"Card actions",children:l.jsx(ei,{className:"h-3.5 w-3.5"})})}),l.jsxs(mo,{align:"end",children:[j&&l.jsxs(mn,{onSelect:()=>o(!0),children:[l.jsx(_u,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Download"]}),E?l.jsxs(mn,{onSelect:()=>i(!0),children:[l.jsx(EO,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Schedule this visual…"]}):null]})]}),j&&l.jsx(uI,{isOpen:r,onClose:()=>o(!1),frame:t,card:e,data:n}),k&&D?l.jsx(fhe,{open:s,onOpenChange:i,launchRequest:{intent:"scheduled_report",sourceContext:{source:k,label:((P=e.title)==null?void 0:P.trim())||"Visual",detail:"Schedule this dashboard visual."},initialAttachments:[D],initialName:`${((A=e.title)==null?void 0:A.trim())||"Visual"} report`,initialMessage:`Attached is the latest ${((z=e.title)==null?void 0:z.trim())||"visual"} report.`,title:"Schedule this visual"}}):null]})}function Wut({canEditDashboard:e,isDashboardEditing:t,isMissingConnection:n,onConfigure:r}){const o=e&&!t;return l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-4 py-6 text-center",children:[l.jsx(hZ,{"aria-hidden":"true",className:"h-8 w-8 text-muted-foreground/40",strokeWidth:1.5}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:n?"Connect a data source":"Add fields to see data"}),o?l.jsx(m.Button,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground hover:text-foreground",onClick:r,children:"Edit visual"}):null]})}function Kut(e,t,n,r){var h,p;const o=m.getVisualizationMode(e)==="dynamic",s=v.useMemo(()=>m.buildEffectiveFallbackCard(e,t),[e,t]),{data:i}=Nw(s),a=v.useMemo(()=>(n==null?void 0:n.records)||[],[n==null?void 0:n.records]),c=Mb(s,a),u=v.useMemo(()=>s.type!=="pivotTable"?{kind:"not_loaded"}:Zm({data:n,card:s}),[s,n]),d=Ym(s,u,(h=n==null?void 0:n.metadata)==null?void 0:h.comparisonMetadata),f=v.useMemo(()=>{var g,b;if(!(!o||!((g=n==null?void 0:n.records)!=null&&g.length)||["kpi","text","table","detailTable","pivotTable","aggregateTable","matrixTable","custom"].includes(s.type)))return Db({card:s,data:n.records,cardType:s.type,queryConfig:s.queryConfig,customCfg:s.customCfg,preferences:s.preferences,topoJson:i,comparisonMetadata:(b=n==null?void 0:n.metadata)==null?void 0:b.comparisonMetadata,numericPresentation:c,resultColumns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,temporalPresentation:m.INACTIVE_DYNAMIC_FALLBACK_TEMPORAL_PRESENTATION})},[s,i,o,n==null?void 0:n.records,n==null?void 0:n.columns,n==null?void 0:n.columnKeyMap,(p=n==null?void 0:n.metadata)==null?void 0:p.comparisonMetadata,c,r]);return{isDynamicVisualizationMode:o,fallbackCard:s,tableRecords:a,pivotTableConfig:d,fallbackCfg:f}}const Gut=[];function zW({card:e,frame:t,cardToolbarAction:n}){var Hn,Ef,La,Gu,Nl,Cc,Sc,jl,To,fs,Yu,Df,Ti,$a,cp,Nc,Mf;const{authToken:r,customCards:o,placeholders:s,tokenProps:i}=Et(),{displayPreferences:a,shouldShowElement:c}=pl(),u=Ou(),d=xl(),f=m.useDashboardStore(Ye=>Ye.themeStyle),h=m.useDashboardStore(Ye=>Ye.dashboard),p=m.useDashboardStore(Ye=>Ye.selectedSheetId),g=m.useDashboardStore(Ye=>Ye.isDashboardEditing);m.useDashboardStore(Ye=>Ye.selectedLensId);const b=m.useDashboardStore(Ye=>Ye.dashboard.filters),x=m.useDashboardStore(Ye=>Ye.filterValues),y=m.useDashboardStore(Ye=>Ye.inlineFilterValuesMap),C=m.useDashboardStore(Ye=>Ye.authToken),w=m.useEditorStore(Ye=>Ye.selectedConnectionId),N=m.useEditorStore(Ye=>Ye.selectedDatabaseName),S=m.useEditorStore(Ye=>Ye.selectedSchemaName),j=m.useEditorStore(Ye=>Ye.selectedTableName),I=m.useEditorStore(Ye=>Ye.selectedDatamodelId),k=tt.findCustomVisualConfigCard(t,e),{manifest:T}=kf(((Hn=k==null?void 0:k.customCardPreferences)==null?void 0:Hn.url)||""),_=(Ef=T==null?void 0:T.visuals)==null?void 0:Ef.find(Ye=>{var Yt;return Ye.name===((Yt=k==null?void 0:k.customCardPreferences)==null?void 0:Yt.componentName)}),E=tt.resolveMultiInputType(k,_)==="multiple",D=E&&k?k:e,M=tt.isDeclaredSqlRawTemporalPresentationCard({card:D}),P=m.useDashboardStore(Ye=>Ye.isVisualEditing),A=m.useEditorStore(Ye=>{var Yt,En;return M&&P&&((Yt=Ye.card)==null?void 0:Yt.id)===D.id&&((En=Ye.frame)==null?void 0:En.id)===t.id?Ye.card:void 0}),z=m.getVisualizationMode(D)==="dynamic",O=m.useInteractionStore(Ye=>Ye.interactionStates[D.id]),B=((La=O==null?void 0:O.breadcrumbs)==null?void 0:La.length)>0,H=m.useDashboardStore(Ye=>Ye.inlineFilterValuesMap[D.id]),R=b==null?void 0:b.find(Ye=>Ye.id===t.filterId&&!Ye.hide),{clearSelectedVisual:q}=Rm(),$=Ts(Ye=>Ye.selectedDashboard),F=Ts(Ye=>Ye.initialDashboard),U=$?(Nl=$==null?void 0:$.permissions)==null?void 0:Nl.canEdit:(Gu=F==null?void 0:F.permissions)==null?void 0:Gu.canEdit,G=tt.hasMissingDeclaredSqlCustomDateFormat(D),Q=U&&G,{setSelectedFrameId:W,updateFilter:L,updateFrame:K,setIsDashboardEditing:Y,setIsVisualEditing:V}=m.useDashboardActions(),{handleChartClick:Z}=Wtt(D),{setCard:X,setFrame:te,setQueryResultColumns:re,setActiveTabCardId:ie,setIsDevMode:se,initializeModeDrafts:le,updateDataSource:ae}=m.useEditorActions(),xe=m.useEditorStore(Ye=>Ye.actions.setSelectedConnectionId),fe=m.useEditorStore(Ye=>Ye.actions.setSelectedDatamodelId),be=m.useEditorStore(Ye=>Ye.actions.setSelectedDatabaseName),pe=m.useEditorStore(Ye=>Ye.actions.setSelectedSchemaName),ye=m.useEditorStore(Ye=>Ye.actions.setSelectedTableName),ce=m.useEditorStore(Ye=>Ye.actions.setFilterValues),J=m.useEditorStore(Ye=>Ye.actions.setInlineFilterValuesMap),ne=m.useEditorStore(Ye=>Ye.actions.setApplyFilters),ee=c("showHeader")&&(((Cc=D.customCardPreferences)==null?void 0:Cc.showCardHeader)??!0),ue=v.useMemo(()=>E&&D?{...D,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:D,[D,E]),ge=!(D.connectionId||(Sc=D.dataSource)!=null&&Sc.connectionId),_e=!!(o!=null&&o.find(Ye=>Ye.cardId===e.id&&!!Ye.content)),Te=ut.isCardUnconfigured(D,{skipSetupCheck:E&&!!k||_e});function Ce(){U&&(W(t.id),q(),P_({frame:t,card:e,setFrame:te,setCard:X,setIsDevMode:se,initializeModeDrafts:le,setActiveTabCardId:ie,updateDataSource:ae,setQueryResultColumns:re,setSelectedConnectionId:xe,setSelectedDatabaseName:be,setSelectedSchemaName:pe,setSelectedTableName:ye,setSelectedDatamodelId:fe,setFilterValues:ce,setInlineFilterValuesMap:J,setApplyFilters:ne,setIsDashboardEditing:Y,setIsVisualEditing:V,dashboard:h,selectedSheetId:p,selectedFrameId:t.id,filterValues:x,inlineFilterValuesMap:y,currentSelections:{connectionId:w,databaseName:N,schemaName:S,tableName:j,datamodelId:I}}))}const{isError:Re,isLoading:Ve,isFetching:Ee,fetchStatus:We,cfg:Ie,isRetainingSourceResult:we,isPending:de,data:Se,handleDatapointClick:Le,queryRequestPayload:Ae,pagination:st,comparisonMetadata:$e,resolvedPrimaryDateField:Ke,effectiveCardConfig:at,queryKey:ct}=kw(ue),{fallbackCard:rt,tableRecords:ht,pivotTableConfig:wt,fallbackCfg:gt}=Kut(D,at,Se,f),At=A??rt,Pe=rt.type==="matrixTable",Ze=Pe&&_w(Se),mt=Pe?GR(ct):void 0,[ft,yt]=v.useState(null),[Dt,Mt]=oe.useReducer(aze,{result:null,branchError:null}),{result:bt,branchError:Tt}=Dt,[Ut,un]=v.useState(new Set),Qe=oe.useRef(null),ze=oe.useRef(void 0),Oe=oe.useRef(ct);Oe.current=ct,oe.useEffect(()=>{if(!Pe)return;const Ye=Oe.current,Yt=(Se==null?void 0:Se.matrixResult)||null,En=uze({previousResult:Qe.current,nextResult:Yt,sharesCalendarIdentity:D5(Ye,ze.current)});Mt({type:"replace-result",result:Yt}),En&&(yt(null),un(new Set)),Qe.current=Yt,ze.current=Ye},[Se==null?void 0:Se.matrixResult,Pe,mt]);const he=cI({data:Se,isLoading:Ve,isFetching:Ee}),Be=we,ot=tk({card:rt,fetchStatus:Be?"idle":We,isLoading:Be?!1:Ve,isFetching:Be?!1:Ee,isPending:Be?!1:de,hasRecords:Ze||!!((jl=Se==null?void 0:Se.records)!=null&&jl.length)}),[Rt,an]=v.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:Ne,hierarchyId:Fe}=m.useInteractionStore(m.useShallow(Ye=>{var Yt,En;return{breadcrumbs:((Yt=Ye.interactionStates[D.id])==null?void 0:Yt.breadcrumbs)??Gut,hierarchyId:(En=Ye.interactionStates[D.id])==null?void 0:En.hierarchyId}})),De=(Ye,Yt,En)=>{var He;const en=Ne.length>0?[{mode:"drillUp",trigger:(He=Ye[0])==null?void 0:He.trigger,label:"Drill Up",hierarchyId:Fe}]:[],sn=[];for(const kt of Ye)if(kt.mode==="dynamicDrill"&&kt.availableFields){const qt=kt.availableFields.filter(Dn=>!Ne.some(ar=>{var Ln;return((Ln=ar.toField)==null?void 0:Ln.id)===Dn.id}));for(const Dn of qt)sn.push({mode:"dynamicDrill",trigger:kt.trigger,drillField:Dn,label:Dn.label,availableFields:kt.availableFields})}const me=Ye.filter(kt=>kt.mode!=="dynamicDrill"),je=[...en,...me,...sn];an({open:!0,position:En||{x:0,y:0},interactions:je,context:Yt})},Ue=D,{handlePointerInteraction:Nt,applySelectedInteraction:it}=m.useEventEngine(Ue,t.id,p||"",De),Vt=(Ye,Yt)=>{const En={...e,paginationConfig:{page:Ye+1,pageSize:Yt}},en={...t,cards:t.cards.map(sn=>sn.id===e.id?En:sn)};p&&K(p,en)},Ot=Ye=>{var sn,me,je;const Yt=lse(Ye,(sn=e.config)==null?void 0:sn.metricColumns,(me=e.config)==null?void 0:me.groupByColumns,(je=e.config)==null?void 0:je.detailColumns),En={...e,config:{...e.config||{},sortByColumns:Yt}},en={...t,cards:t.cards.map(He=>He.id===e.id?En:He)};p&&K(p,en)},Tn=Ye=>{const Yt=e.config||{},En={...Yt,sort:Ye,...Yt.matrixIntent?{matrixIntent:{...Yt.matrixIntent,sort:Ye}}:{}},en={...e,config:En},sn={...t,cards:t.cards.map(me=>me.id===e.id?en:me)};Mt({type:"replace-result",result:null}),p&&K(p,sn)},zr=Ye=>{yt(Ye.state),!(!("rowPath"in Ye)||!Ye.isExpanded||!Ae)&&ir(Ye.rowPath)},ir=async Ye=>{if(!Ae||!(Se!=null&&Se.matrixResult))return;const Yt=uo(Ye),En=ct;un(en=>new Set(en).add(Yt));try{const en=await m.postRequest(`${i.apiServiceUrl}/v1/query`,(r==null?void 0:r.accessToken)||(C==null?void 0:C.accessToken)||"",{...Ae,matrixBranchRequest:{axis:"row",path:Ye.map(({instanceId:me,fieldKey:je,value:He})=>({instanceId:me,fieldKey:je,value:He})),depth:Ye.length+1}}),sn=lze(en==null?void 0:en.matrixResult);if(!A_e(Oe.current,En))return;Mt({type:"merge-branch",baseResult:Se.matrixResult,branch:sn})}catch(en){console.error("Failed to fetch matrix branch",en),Mt({type:"reject-branch",error:en})}finally{un(en=>{const sn=new Set(en);return sn.delete(Yt),sn})}};function qe(Ye,Yt){if(Ye.stopPropagation(),!at)return;const En=Ktt({resolvedCardConfig:at,card:Ue,records:(Se==null?void 0:Se.records)||[],chart:Yt,clickEvent:Ye.nativeEvent,columnKeyMap:Se==null?void 0:Se.columnKeyMap,resultColumns:Se==null?void 0:Se.columns,valueFormatPreferences:d});if(!En)return;const en=m.getInteractions(Ue.interactionConfig),sn=m.findAllMatchingV2Interactions(en,En),me=sn.length===1&&sn[0].mode==="clickFilter",je=sn.some(qt=>qt.mode==="dynamicDrill"),He=sn.length>1||je;Ye.button===0&&me&&!He&&Z(Ye.nativeEvent,Yt);const kt={shift:Ye.shiftKey,ctrl:Ye.ctrlKey,meta:Ye.metaKey};Ye.button===0?Nt({context:En,gesture:"leftClick",modifierKeys:kt,position:{x:Ye.clientX,y:Ye.clientY}}):Ye.button===2&&Nt({context:En,gesture:"rightClick",modifierKeys:kt,position:{x:Ye.clientX,y:Ye.clientY}})}function nt(){var Ye,Yt,En;if(E&&k)return li;if(o&&o.length>0){const en=o.find(sn=>sn.cardId===e.id);if(en&&en.replaceDefault){const sn=en.content;if(sn)return l.jsx(sn,{card:e})}}if(!z&&e.type==="kpi"){if(((Ye=t==null?void 0:t.cards)==null?void 0:Ye.length)===1)return l.jsx(of,{card:e,data:Re?[]:(Se==null?void 0:Se.records)||[],isPending:ot.showCardSkeleton,isError:Re,comparisonMetadata:$e,headerTrailingAction:n});if(((Yt=t==null?void 0:t.cards)==null?void 0:Yt.length)>1)return l.jsx(kU,{frame:t,card:e,cardToolbarAction:n})}return!z&&e.type==="text"&&((En=t==null?void 0:t.cards)==null?void 0:En.length)===1?l.jsx(m.ScrollArea,{className:"h-full break-words",children:l.jsx("div",{className:"px-4 py-3",children:l.jsx(sb,{isLoading:ot.showCardSkeleton,card:e,data:(Se==null?void 0:Se.records)||[],inferDynamicTextFromQuery:!0})})}):li}function dt(){if(E&&k)return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ki,{FallbackComponent:SU,children:l.jsx(Wj,{frame:t,card:k})})});if(Te)return l.jsx(Wut,{canEditDashboard:!!U,isDashboardEditing:g,isMissingConnection:ge,onConfigure:Ce});if(Re)return l.jsx(Jb,{showOwnerGuidance:e.type!=="kpi"});if(ot.showGenericLoadingFallback)return rt.type==="table"||rt.type==="detailTable"||rt.type==="matrixTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(dz,{})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})});if(G)return l.jsx(Kue,{onRepair:Q?Ce:void 0});if(Se!=null&&Se.records&&Se.records.length===0&&!z&&!Ze&&rt.type!=="pivotTable")return s!=null&&s.NoRecords?l.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:s.NoRecords}):l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[l.jsx(RO,{className:"h-8 w-8 text-muted-foreground/40"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No results to display"})]});function Ye(){var En,en,sn;if(rt.type==="kpi"){if(((En=t==null?void 0:t.cards)==null?void 0:En.length)===1)return l.jsx(of,{card:rt,data:Re?[]:(Se==null?void 0:Se.records)||[],isPending:de,isError:Re,comparisonMetadata:$e,headerTrailingAction:n});if(((en=t==null?void 0:t.cards)==null?void 0:en.length)>1)return l.jsx(kU,{frame:t,card:rt,cardToolbarAction:n})}if(rt.type==="table"||rt.type==="detailTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(Jd,{card:At,data:ht,resultColumns:Se==null?void 0:Se.columns,columnKeyMap:Se==null?void 0:Se.columnKeyMap,totalsByColumnId:Se==null?void 0:Se.tableTotalsByColumnId,comparisonMetadata:$e,paginationMetadata:st,onPaginationChange:Vt,onSortChange:Ot,isLoading:Ve||Ee,frameId:t.id,sheetId:p||"",onMultipleInteractions:De})});if(rt.type==="matrixTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(SI,{card:rt,result:bt||(Se==null?void 0:Se.matrixResult),isLoading:he,expansionState:ft||void 0,loadingRowPathKeys:Ut,branchError:Tt||void 0,onExpansionChange:zr,onLoadMoreRows:ir,onSortChange:Tn})});if(rt.type==="pivotTable"&&wt)return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ex,{card:rt,data:wt.data,options:wt.options,frameId:t.id,sheetId:p||"",onMultipleInteractions:De,onAggregationChange:me=>{const je=cF(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)},onAggregationLabelChange:me=>{const je=ide(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)}})});if(rt.type==="aggregateTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(NI,{card:rt,data:(Se==null?void 0:Se.records)||[],resultColumns:Se==null?void 0:Se.columns,columnKeyMap:Se==null?void 0:Se.columnKeyMap,groupByColumns:Se==null?void 0:Se.groupByColumns,pivotSchema:Se==null?void 0:Se.pivotSchema,paginationMetadata:st,onPaginationChange:Vt,onAggregationChange:me=>{const je=cF(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)},isLoading:Ve||Ee,frameId:t.id,sheetId:p||"",onMultipleInteractions:De})});if(rt.type==="text")return l.jsx(m.ScrollArea,{className:"h-full break-words",children:l.jsx("div",{className:"px-4 py-3",children:l.jsx(sb,{isLoading:ot.showCardSkeleton,card:rt,data:(Se==null?void 0:Se.records)||[],inferDynamicTextFromQuery:!0})})});if(m.isCustomVisualizationCard(rt)&&((sn=rt.customCardPreferences)!=null&&sn.url))return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ki,{FallbackComponent:SU,children:l.jsx(Wj,{frame:t,card:rt})})});if(o&&o.length>0){const me=o.find(je=>je.cardId===rt.id);if(me&&me.content){const je=me.content;return l.jsx(je,{card:rt})}}const Yt=z?gt:Ie;return Yt?l.jsx(Bw,{cfg:Yt,onChartClick:qe,onDatapointClick:Le}):null}return z?l.jsx(eT,{card:D,records:ht,title:D.title,sql:D.sql,python:D.python,layoutMode:"fill",disablePointerEvents:g,fallback:Ye()}):Ye()}function jt(){if(o&&o.length>0){const Ye=o.find(Yt=>Yt.cardId===e.id);if(Ye&&Ye.footer){const Yt=Ye.footer;if(Yt)return l.jsx(Yt,{card:e})}}return null}function Ht(){var En;if(E&&k)return null;const Ye=t.cards.filter(en=>{var sn;return!((sn=en.tabTitle)!=null&&sn.endsWith("__Header"))&&(en.displayTab===!0||en.displayTab===void 0)}),Yt=f==null?void 0:f.controlInputRadius;return l.jsx(m.Tabs,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:en=>{const sn={...t,activeCardId:en};K(p,sn)},children:l.jsx(m.TabsList,{style:{borderRadius:f==null?void 0:f.controlInputRadius},className:"flex-end flex h-7 flex-wrap items-center border border-border bg-background p-0",children:(En=t.cards.filter(en=>{var sn;return!((sn=en.tabTitle)!=null&&sn.endsWith("__Header"))&&(en.displayTab===!0||en.displayTab===void 0)}))==null?void 0:En.map((en,sn)=>l.jsx(m.TabsTrigger,{className:m.cn("h-full items-center rounded-none px-2.5 text-[12px] data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":sn!==Ye.length-1}),style:{borderTopLeftRadius:sn===0?Yt:0,borderTopRightRadius:sn===Ye.length-1?Yt:0,borderBottomLeftRadius:sn===0?Yt:0,borderBottomRightRadius:sn===Ye.length-1?Yt:0},value:en.id,children:en.tabTitle||en.title},en.id))})})}function yn(){var Yt,En,en,sn,me;let Ye=t.cards.find(je=>je.type==="kpi"&&je.tabTitle===`${e.tabTitle}__Header`);return Ye||(Ye=t.cards.find(je=>je.type==="kpi"&&je.tabTitle==="All__Header")),Ye?l.jsx("div",{className:"flex items-end gap-2",children:l.jsx(Ttt,{renderFilterInfo:()=>{var je,He,kt,qt;return c("showFilterInfo")&&((He=(je=D.preferences)==null?void 0:je.displayOptions)==null?void 0:He.showFilterInfo)!==!1?l.jsx(lF,{cardId:D.id,cardFilters:(kt=D.config)==null?void 0:kt.filters,cardFilterCount:ek(((qt=D.config)==null?void 0:qt.filters)||null),inlineFilters:D.inlineFilters,inlineFilterValues:H,sheetId:p||"",resolvedPrimaryDateField:Ke}):null},card:Ye})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[c("showTitle")&&l.jsx(gb,{"data-rgl-drag-cancel":"",className:m.cn("text-[16px] font-semibold leading-tight tracking-[-0.01em]"),children:l.jsx(Ci,{value:D.title,onSave:()=>{},isEditable:!1,placeholder:"Add title",displayClassName:"text-[16px] font-semibold leading-tight tracking-[-0.01em]",inputClassName:"text-[16px] font-semibold leading-tight tracking-[-0.01em]"})}),c("showTitle")&&((Yt=D.info)==null?void 0:Yt.trim())&&l.jsx(cz,{card:D}),c("showRefreshIndicator")&&D.refreshInterval&&l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{className:"pr-1",children:l.jsx("div",{className:m.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":Ve||Ee})})}),l.jsx(m.TooltipContent,{side:"right",align:"center",children:l.jsx("p",{className:"text-xs",children:`Realtime (${D==null?void 0:D.refreshInterval})`})})]}),c("showFilterInfo")&&((en=(En=D.preferences)==null?void 0:En.displayOptions)==null?void 0:en.showFilterInfo)!==!1&&l.jsx(lF,{cardId:D.id,cardFilters:(sn=D.config)==null?void 0:sn.filters,cardFilterCount:ek(((me=D.config)==null?void 0:me.filters)||null),inlineFilters:D.inlineFilters,inlineFilterValues:H,sheetId:p||"",resolvedPrimaryDateField:Ke}),$e&&D.type!=="table"&&l.jsx(Xoe,{metadata:$e,variant:"compact"})]}),(()=>{var kt;const je=!B&&c("showDescription")&&!!((kt=D.description)!=null&&kt.trim()),He=B&&c("showBreadcrumbs");return!je&&!He?null:l.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[je&&l.jsx("div",{className:"text-[12px] leading-snug text-muted-foreground",children:l.jsx(Ci,{value:(D.description||"").trim(),onSave:()=>{},isEditable:!1,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})}),He&&l.jsx(Xtt,{cardId:D.id})]})})()]})}if(!e.id)return null;const _r=((fs=(To=D.preferences)==null?void 0:To.displayOptions)==null?void 0:fs.showChrome)??!0,Ps=((Df=(Yu=D.preferences)==null?void 0:Yu.displayOptions)==null?void 0:Df.allowScroll)??!0,Fs=(($a=(Ti=D.preferences)==null?void 0:Ti.displayOptions)==null?void 0:$a.showInlineFilterBar)??!0,Os=Jtt(D),ao=G$(D),Ls=_r?"px-5 pb-3":"px-3 pb-3",Xo=D.type==="table"||D.type==="pivotTable"||D.type==="aggregateTable"||D.type==="matrixTable"||D.type==="detailTable",lp=!gf(a.mode),Wu=jt(),li=_r?l.jsxs(l.Fragment,{children:[ee?l.jsx(IO,{className:m.cn("space-y-0 px-5 pb-3 pt-4",D.inlineFilters&&D.inlineFilters.length>0&&"pb-3",Xo&&"border-b border-border/60"),style:u.cardGutterStyle,children:l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[l.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:yn()}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("div",{children:R&&c("showFilters")&&l.jsxs("div",{style:{borderRadius:(Nc=(cp=f==null?void 0:f.chart)==null?void 0:cp.options)==null?void 0:Nc.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!m.isDateDataType(R.dataType)&&l.jsx(m.Label,{className:"my-1 shrink-0 px-3",children:l.jsx(Ci,{value:R.title||R.column,onSave:Ye=>L({...R,title:Ye}),isEditable:g,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),l.jsx(GI,{filter:R})]})}),t.cards.length>1&&c("showTabs")&&Ht(),lp&&l.jsx(Uut,{card:D,frame:t,exportData:D.type==="matrixTable"&&bt?{...Se,matrixResult:bt}:Se})]})]})}):l.jsx("div",{className:"h-8"}),(Os||Fs&&D.inlineFilters&&D.inlineFilters.length>0)&&l.jsx("div",{className:m.cn("px-5 pb-2 pt-2",Xo&&"border-b border-border/60"),style:u.cardGutterStyle,children:l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[Fs&&D.inlineFilters&&D.inlineFilters.length>0&&l.jsx(lde,{card:D,sheetId:p||""}),Os&&l.jsx(ont,{card:D})]})}),l.jsx(TO,{"data-role":"card-content",className:m.cn("relative flex min-h-0 grow flex-col",Xo?"p-0 [&_.data-table-scroll-container]:border-0 [&_.data-table-scroll-container]:bg-transparent":"px-5 pb-4 pt-2"),style:Xo?void 0:u.cardGutterStyle,children:dt()}),ao&&e.type!=="kpi"&&l.jsx("div",{className:Ls,style:u.cardGutterStyle,children:l.jsx(fF,{card:D,mode:"dashboard"})}),c("showFooter")&&Wu&&l.jsx(iZ,{children:Wu})]}):l.jsxs(l.Fragment,{children:[dt(),ao&&e.type!=="kpi"&&l.jsx("div",{className:Ls,style:u.cardGutterStyle,children:l.jsx(fF,{card:D,mode:"dashboard"})})]}),Ku=()=>_r&&Ps?"flex h-full flex-col":_r&&!Ps?"flex h-full flex-col overflow-hidden":!_r&&!Ps?"h-full":"h-full overflow-auto";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative h-full",children:[l.jsx("div",{className:m.cn(Ku(),{"animate-pulse":Ve||Ee}),children:nt()}),ot.showStaleDataOverlay&&l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/50",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})})]}),Rt.context&&l.jsx(Utt,{open:Rt.open,onOpenChange:Ye=>{an(Yt=>({...Yt,open:Ye}))},position:Rt.position,interactions:Rt.interactions,selectedConditions:Rt.context.conditions,drillHierarchies:(Mf=D.interactionConfig)==null?void 0:Mf.drillHierarchies,cardId:D.id,card:D,onSelectInteraction:Ye=>{Rt.context&&it(Ye,Rt.context),an({open:!1,position:null,interactions:[],context:null})}})]})}function phe({card:e,frame:t,cardToolbarAction:n}){var c,u;const r=tt.findCustomVisualConfigCard(t,e),{manifest:o}=kf(((c=r==null?void 0:r.customCardPreferences)==null?void 0:c.url)||""),s=v.useMemo(()=>{var d;return(d=o==null?void 0:o.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=r==null?void 0:r.customCardPreferences)==null?void 0:h.componentName)})},[o,(u=r==null?void 0:r.customCardPreferences)==null?void 0:u.componentName]),a=tt.resolveMultiInputType(r,s)==="multiple"&&r?r:e;return a.displayPreferences?l.jsx(tT,{displayPreferences:a.displayPreferences,children:l.jsx(zW,{card:e,frame:t,cardToolbarAction:n})}):l.jsx(zW,{card:e,frame:t,cardToolbarAction:n})}phe.displayName="DashboardCard";const ghe=oe.memo(phe);function Yut({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:o,isFetching:s,data:i,cfg:a,pagination:c,comparisonMetadata:u,effectiveCardConfig:d}=kw(e),f=m.useDashboardStore(k=>k.themeStyle);m.useDashboardStore(k=>k.selectedSheetId);const h=m.getVisualizationMode(e)==="dynamic",p=m.buildEffectiveFallbackCard(e,d),{data:g}=Nw(p),b=v.useMemo(()=>p.type!=="pivotTable"?{kind:"not_loaded"}:Zm({data:i,card:p}),[i,p]),x=Ym(p,b,u),y=v.useMemo(()=>(i==null?void 0:i.records)||[],[i==null?void 0:i.records]),C=Mb(p,y),w=p.type==="matrixTable"&&_w(i),N=cI({data:i,isLoading:o,isFetching:s}),S=v.useMemo(()=>{var k;if(!(!h||!((k=i==null?void 0:i.records)!=null&&k.length)||["kpi","text","table","detailTable","pivotTable","aggregateTable","matrixTable","custom"].includes(p.type)))return Db({card:p,data:i.records,cardType:p.type,queryConfig:p.queryConfig,customCfg:p.customCfg,preferences:p.preferences,topoJson:g,comparisonMetadata:u,numericPresentation:C,resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,temporalPresentation:m.INACTIVE_DYNAMIC_FALLBACK_TEMPORAL_PRESENTATION})},[i==null?void 0:i.records,i==null?void 0:i.columns,i==null?void 0:i.columnKeyMap,p,g,C,f,u,h]),j=h?S:a;if((o||s)&&!w)return l.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-2.5 p-12",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading visual…"})]});if(r)return l.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:l.jsx("p",{className:"text-[13px] font-medium text-destructive",children:"Failed to load visual"})});function I(){function k(){var T;return p.type==="kpi"?l.jsx(of,{card:p,data:(i==null?void 0:i.records)||[],isPending:o||s,comparisonMetadata:u}):p.type==="table"||p.type==="detailTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(Jd,{card:p,data:y,resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,totalsByColumnId:i==null?void 0:i.tableTotalsByColumnId,comparisonMetadata:u,isLoading:o||s,paginationMetadata:c})}):p.type==="matrixTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(SI,{card:p,result:i==null?void 0:i.matrixResult,isLoading:N})}):p.type==="pivotTable"&&x?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ex,{card:p,data:x.data,options:x.options,onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):p.type==="aggregateTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(NI,{card:p,data:(i==null?void 0:i.records)||[],resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,groupByColumns:i==null?void 0:i.groupByColumns,pivotSchema:i==null?void 0:i.pivotSchema,paginationMetadata:c,onAggregationChange:()=>{},isLoading:o||s})}):p.type==="text"?l.jsx(m.ScrollArea,{className:"overflow-y-auto break-words pr-2",children:l.jsx(sb,{isLoading:o||s,card:p,data:(i==null?void 0:i.records)||[]})}):m.isCustomVisualizationCard(p)&&((T=p.customCardPreferences)!=null&&T.url)?l.jsx(ki,{FallbackComponent:Xw,children:l.jsx(Wj,{frame:t,card:p})}):j?l.jsx(Bw,{cfg:j,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return m.getVisualizationMode(e)==="dynamic"?l.jsx(eT,{card:e,records:y,title:e.title,sql:e.sql,python:e.python,layoutMode:"fill",fallback:k()}):k()}return l.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsx("h3",{className:"text-[15px] font-semibold tracking-tight",children:e.title}),e.description&&l.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:e.description})]}),l.jsx("div",{className:"min-h-0 flex-1 p-4",children:I()})]})}function Zut(e){return l.jsx(ki,{FallbackComponent:Xw,children:l.jsx(Yut,{...e})})}function bhe({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:o,isError:s,error:i}=Qk(e,{enabled:!!e}),a=m.useInteractionStore(f=>f.setInteractionState),c=m.useInteractionStore(f=>f.resetInteractionState),u=v.useMemo(()=>{var f;return r?tt.parseFrameObject((r==null?void 0:r.frameObject)??((f=r==null?void 0:r.visual)==null?void 0:f.frameObject)):null},[r]),d=v.useMemo(()=>tt.getActiveFrameCard(u),[u]);return v.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const g={...m.createInitialInteractionState(),contextMode:n};a(d.id,g);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...m.createInitialInteractionState(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{c(d.id)}},[d,t,n,a,c]),o?l.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-2.5 p-12",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading visual…"})]}):s?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 p-12 text-center",children:[l.jsx("p",{className:"text-[13px] font-medium text-destructive",children:"Failed to load insight"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!u||!d?l.jsx("div",{className:"flex items-center justify-center p-12",children:l.jsx("p",{className:"text-[13px] text-muted-foreground",children:"This insight has no visual data to display"})}):l.jsx("div",{className:"h-full w-full",children:l.jsx(Zut,{card:d,frame:u,showTitle:!1})})}function Xut({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?l.jsxs(xi,{variant:"outline",className:"gap-1 whitespace-nowrap text-[11px] font-medium",children:[l.jsx(Vd,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((o,s)=>{var a,c;const i=((a=s.field)==null?void 0:a.label)||((c=s.field)==null?void 0:c.name)||"Unknown";return o[i]||(o[i]=[]),o[i].push(s),o},{});e.length;const r=Object.keys(n).length;return l.jsx(m.TooltipProvider,{children:l.jsxs(m.Tooltip,{delayDuration:200,children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs(xi,{variant:"outline",className:"cursor-help gap-1 whitespace-nowrap text-[11px] font-medium",children:[l.jsx(Vd,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),l.jsx(m.TooltipContent,{side:"bottom",align:"start",className:"max-w-md",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Applied filters"}),l.jsx("div",{className:"space-y-1",children:Object.entries(n).map(([o,s])=>l.jsxs("div",{className:"text-[12px]",children:[l.jsxs("span",{className:"font-medium",children:[o,":"]})," ",s.map((i,a)=>l.jsxs("span",{children:[ode(i),a<s.length-1?", ":""]},a))]},o))}),t&&l.jsx("div",{className:"border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground",children:Qut(t)})]})})]})})}function Qut(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 xhe(e,t={}){const{enabled:n=!0}=t,{data:r}=Qk(e,{enabled:n&&!!e});return v.useMemo(()=>{if(!r)return{title:"",description:void 0};const s=tt.getActiveCardFromVisualResource(r);return s?{title:s.title,description:s.description}:{title:"",description:void 0}},[r])}function Jut({cardId:e,children:t}){const n=m.useInteractionStore(s=>s.replacedCards[e]),r=m.useInteractionStore(s=>s.restoreCard),o=xhe((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?l.jsxs("div",{className:"flex h-full w-full flex-col",children:[l.jsxs("div",{className:"border-b border-border bg-muted/30",children:[l.jsx("div",{className:"flex items-baseline gap-2 px-3 pb-1.5 pt-3",children:o.title&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"truncate text-[15px] font-semibold tracking-tight",children:o.title}),o.description&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-muted-foreground/70",children:"·"}),l.jsx("span",{className:"truncate text-[12px] text-muted-foreground",children:o.description})]})]})}),l.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-2",children:[l.jsxs(m.Button,{variant:"ghost",size:"xs",onClick:()=>r(e),className:"shrink-0",children:[l.jsx(Xv,{className:"h-3.5 w-3.5"}),"Back"]}),l.jsx(Xut,{filters:n.filters,contextMode:n.contextMode})]})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(bhe,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):l.jsx(l.Fragment,{children:t})}function edt(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function yhe({frame:e,footer:t,className:n,style:r,...o}){var E,D;const s=v.useRef(null),[i,a]=v.useState(!1),c=m.useDashboardStore(M=>M.themeStyle),u=Ou(),{customCards:d}=Et(),f=m.useDashboardStore(M=>M.isVisualEditing),h=m.useDashboardStore(M=>M.selectedFrameId),p=m.useDashboardStore(M=>M.isDashboardEditing),{setSelectedFrameId:g}=m.useDashboardActions(),{clearSelectedVisual:b}=Rm(),{setSelectedConnectionId:x,setSelectedDatabaseName:y,setSelectedSchemaName:C,setSelectedTableName:w,setCard:N}=m.useEditorActions();v.useEffect(()=>{if(h!==e.id||!p||f)return;const M=s.current;if(!M)return;const P=edt(M),A=()=>P?P.scrollHeight:document.documentElement.scrollHeight,z=()=>P?P.scrollTop:window.scrollY,O=()=>P?P.getBoundingClientRect():{top:0,bottom:window.innerHeight},B=()=>{const K=M.getBoundingClientRect(),Y=O(),V=1;return K.height>=Y.bottom-Y.top?K.top<=Y.top+V&&K.bottom>=Y.bottom-V:K.top>=Y.top-V&&K.bottom<=Y.bottom+V},H=1200,R=3,q=2e3;let $=0,F=0,U=Number.NaN;const G=performance.now(),Q=K=>{M.scrollIntoView({behavior:K,block:"center",inline:"nearest"})},W=()=>{let K=0,Y=Number.NaN;const V=performance.now(),Z=()=>{const X=z();K=X===Y?K+1:0,Y=X;const te=K>=R,re=performance.now()-V>=q;if(!te&&!re){$=requestAnimationFrame(Z);return}B()||Q("auto")};$=requestAnimationFrame(Z)},L=()=>{const K=A();F=K===U?F+1:0,U=K;const Y=performance.now()-G>=H;if(F<R&&!Y){$=requestAnimationFrame(L);return}Q("smooth"),W()};return $=requestAnimationFrame(L),()=>cancelAnimationFrame($)},[h,e.id,p,f]);const S=e.cards.find(M=>M.id===e.activeCardId),j=d==null?void 0:d.some(M=>M.cardId===(S==null?void 0:S.id)&&M.replaceDefault===!0&&!!M.content),I=p||((D=(E=S==null?void 0:S.preferences)==null?void 0:E.displayOptions)==null?void 0:D.showCardToolbar)!==!1,k=(S==null?void 0:S.type)==="kpi"&&!m.isDynamicVisualizationMode(S)&&!j,T=I&&k?l.jsx(aF,{frame:e,isHovered:i,variant:"inline-kpi"}):void 0;function _(M){M.stopPropagation(),g(e.id),b(),S&&N(S),S!=null&&S.connectionId&&x(S==null?void 0:S.connectionId),S!=null&&S.lastSelectedDatabase&&y(S==null?void 0:S.lastSelectedDatabase),S!=null&&S.lastSelectedSchema&&C(S==null?void 0:S.lastSelectedSchema),S!=null&&S.lastSelectedTable&&w(S==null?void 0:S.lastSelectedTable)}return l.jsx(ki,{FallbackComponent:JI,children:l.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":S==null?void 0:S.id,onClick:_,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{borderRadius:c==null?void 0:c.cardBorderRadius,...u.cardFrameStyle,...r},className:m.cn("relative flex h-full flex-col rounded-sm border bg-card text-card-foreground shadow-sm focus-visible:outline-none",{"border-dashed border-foreground/50":h===e.id&&p},c==null?void 0:c.dashboardCard,n,"semaphor-card-frame"),...o,children:[I&&!k&&l.jsx(aF,{frame:e,isHovered:i}),S&&l.jsx(Jut,{cardId:S.id,children:l.jsx(ghe,{card:S,frame:e,cardToolbarAction:T},S.id)})]})})}yhe.displayName="DashboardFrame";const tdt=v.memo(yhe);function BW(e){return e.type==="dataset"&&"domainId"in e}function ur(e,t){const n=BW(e),r=BW(t);if(n||r)return!n||!r||e.domainId!==t.domainId?!1:e.id&&t.id?e.id===t.id:e.name===t.name;if("id"in e&&"id"in t&&e.id&&t.id)return e.id===t.id;const o=e.database||"",s=t.database||"",i=e.schema||"",a=t.schema||"",c=e.connectionType||"",u=t.connectionType||"",d=e.dbObjectType||"",f=t.dbObjectType||"",h=d.length>0&&f.length>0;return e.type===t.type&&e.connectionId===t.connectionId&&c===u&&o===s&&i===a&&e.name===t.name&&(!h||d===f)}function rl(e){return e||[]}function Bz(e){return e.reduce((t,n)=>(t.some(r=>ur(r,n))||t.push(n),t),[])}function ndt(e,t){var n;if((n=e.sheets)!=null&&n.length)return t&&e.sheets.find(r=>r.id===t)||e.sheets[0]}function vhe(e,t){const n=ndt(e,t);if(!n)return[];const r=(n.frames||[]).flatMap(s=>{var a;const i=tt.getActiveFrameCard(s);return rl((a=i==null?void 0:i.dataSource)==null?void 0:a.selectedEntities)}),o=(n.cards||[]).flatMap(s=>{var i;return rl((i=s==null?void 0:s.dataSource)==null?void 0:i.selectedEntities)});return Bz([...r,...o])}function rdt(e,t){const n=(e||"").trim();return n.length>0?`dashboard:${n}`:t||"dashboard:draft"}function odt(e){const t=(e||"").trim();return t.length>0?`dashboard:${t}`:null}function whe({overrides:e,dashboardId:t,draftScopeKey:n}){const r=odt(t),o=rdt(t,n),s=r!==null?e[r]:void 0,i=e[o];return{selectedEntities:s!==void 0?s:i,hasManualOverride:s!==void 0||i!==void 0,activeScopeKey:o}}function sdt(e){return e?e.mode==="auto"||e.mode==="fixed"?e.mode:"fixed":"auto"}function idt({currentAIContext:e,manualSelectedEntities:t,hasManualOverride:n,dashboardAIContext:r,derivedSelectedSheetEntities:o}){return{...e,selectedEntities:Che({manualSelectedEntities:t,hasManualOverride:n,dashboardAIContext:r,derivedSelectedSheetEntities:o})}}function Che({manualSelectedEntities:e,hasManualOverride:t,dashboardAIContext:n,derivedSelectedSheetEntities:r}){return t?rl(e):sdt(n)==="fixed"?rl(n==null?void 0:n.selectedEntities):rl(r)}function VW({manualSelectedEntities:e,dashboardAIContext:t,derivedSelectedSheetEntities:n}){return Bz([...rl(e),...rl(t==null?void 0:t.selectedEntities),...rl(n)])}function fT(e){const t=m.useCurrentAIContext(),n=m.useDashboardStore(A=>A.dashboard),r=m.useDashboardStore(A=>A.selectedSheetId),o=m.useDashboardStore(A=>A.dashboardAssistantDraftScopeKey),s=m.useDashboardStore(A=>A.dashboard.aiContext),i=m.useDashboardStore(A=>A.dashboard.id||null),a=m.useAIInteractionStore(A=>A.dashboardEntitySelectionOverrides),c=m.useAIInteractionStore(A=>A.hasEditorEntitySelectionOverride),u=v.useMemo(()=>whe({overrides:a,dashboardId:i,draftScopeKey:o}),[o,a,i]),d=u==null?void 0:u.selectedEntities,f=!!(u!=null&&u.hasManualOverride),{setCurrentAIContext:h,setHasEditorEntitySelectionOverride:p,setDashboardEntitySelectionOverride:g,clearDashboardEntitySelectionOverride:b}=m.useAIActions(),x=rl(t.selectedEntities),y=v.useMemo(()=>vhe(n,r),[n,r]),C=v.useMemo(()=>Che({manualSelectedEntities:d,hasManualOverride:f,dashboardAIContext:s,derivedSelectedSheetEntities:y}),[d,f,s,y]),w=e==="dashboard"?C:e==="editor"?x.length>0?x:c?[]:C:x,N=e==="dashboard"?VW({manualSelectedEntities:f?d:[],dashboardAIContext:s,derivedSelectedSheetEntities:y}):e==="editor"?VW({manualSelectedEntities:x.length>0?x:C,dashboardAIContext:s,derivedSelectedSheetEntities:y}):rl(s==null?void 0:s.selectedEntities),S=v.useCallback(A=>{if(e==="dashboard"&&(u!=null&&u.activeScopeKey)){g(u.activeScopeKey,A);return}e==="editor"&&p(!0),h({...t,selectedEntities:A})},[e,t,u,p,h,g]),j=v.useCallback(()=>{e==="dashboard"&&(u!=null&&u.activeScopeKey)&&b(u.activeScopeKey)},[e,b,u]),I=v.useCallback(A=>w.some(z=>ur(z,A)),[w]),k=v.useCallback(A=>{if(w.some(O=>ur(O,A))){S(w.filter(O=>!ur(O,A)));return}S([...w,A])},[w,S]),T=v.useCallback(A=>{w.some(z=>ur(z,A))||S([...w,A])},[w,S]),_=v.useCallback(A=>{S(w.filter(z=>!ur(z,A)))},[w,S]),E=v.useCallback(A=>{A.length!==0&&S(w.filter(z=>!A.some(O=>ur(z,O))))},[w,S]),D=v.useCallback(()=>{S(N)},[N,S]),M=v.useCallback(()=>{S([])},[S]),P=v.useCallback(()=>{if(e!=="dashboard"){if(e==="editor"&&!c&&x.length===0&&w.length>0){S(w);return}e!=="editor"&&w.length===0&&S(N)}},[e,N,c,x.length,w,S]);return{selectedEntities:w,availableEntities:N,setSelectedEntities:S,applyDashboardDefaultEntities:j,hasDashboardEntitySelectionOverride:f,isEntitySelected:I,toggleEntity:k,addEntityIfMissing:T,removeEntity:_,removeEntities:E,selectAllEntities:D,clearAllEntities:M,syncWithGlobalContext:P}}function She(){var N;const e=m.useDashboardStore(S=>S.isDashboardEditing),t=m.useDashboardStore(S=>S.selectedSheetId),n=m.useDashboardStore(S=>S.dashboard),r=n==null?void 0:n.sheets,o=r==null?void 0:r.find(S=>S.id===t),s=m.useEditorStore(S=>S.card),i=m.useEditorStore(S=>S.selectedConnectionId),{selectedEntities:a}=fT("dashboard"),c=lz(),{addFrame:u,setSelectedFrameId:d,setIsVisualEditing:f}=m.useDashboardActions(),{setFrame:h,setCard:p,setActiveTabCardId:g,clearModeDrafts:b,initializeModeDrafts:x,clearEditorContext:y}=m.useEditorActions();function C(){const S=s==null?void 0:s.dataSource;if(S)return S;const j=a[0],I=j==null?void 0:j.type;if(j)return{connectionId:j.connectionId,connectionType:j.connectionType,type:I,selectedEntities:[j]}}async function w(S){const j=(S==null?void 0:S.sheetId)||t,I=r==null?void 0:r.find(D=>D.id===j);if(!I){console.warn("Cannot add frame: No sheet found");return}if(m.isDocumentSheet(I)){console.warn("Cannot add frame: Document sheets do not accept dashboard frames");return}if(!(!I.frames||I.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const T=C(),_={id:ut.v4(),title:"Title",type:"bar",connectionId:i||"",dataSource:T,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},E={id:ut.v4(),cards:[_],activeCardId:_.id};if(j){try{await c(j,E)}catch(D){console.warn("Adding new frame without refreshed semantic metadata:",D),u(j,E)}d(E.id)}return S!=null&&S.openVisualEditor&&(b(),y(),h(E),p(_),g(_.id),f(!0),x(_)),E}return{handleAddNewFrame:w,canAddFrame:e||!((N=o==null?void 0:o.frames)!=null&&N.length)}}function adt({sheetId:e}){const{handleAddNewFrame:t}=She(),n=m.useDashboardStore(s=>s.themeStyle),r=Ou(),o=()=>{t({openVisualEditor:!0,sheetId:e})};return l.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",style:r.gridContainerPadding?{padding:r.gridContainerPadding[0]}:void 0,children:l.jsxs("button",{onClick:o,style:{borderRadius:n==null?void 0:n.cardBorderRadius,...r.cardFrameStyle},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-card text-card-foreground transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[l.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:l.jsx(Mr,{className:"h-6 w-6 text-primary"})}),l.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}const ldt={string:m.Type,number:bb,date:Ka,boolean:Kve,json:jve,geo:Ave,calculated:fZ},HW={string:"text",number:"number",date:"date",boolean:"boolean",json:"json",geo:"geo",calculated:"calculated"};function cdt(e){const t=(e||"").toLowerCase();return t==="calculated"?"calculated":m.getDataType(t)}function oC({dataType:e,calculated:t,className:n}){const r=cdt(e),o=ldt[r]??m.Type,s=t?`calculated · ${HW[r]}`:HW[r];return l.jsxs("span",{"aria-hidden":"true",title:s,className:m.cn("relative inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",n),children:[l.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.75}),t&&l.jsx("span",{className:"absolute -bottom-[3px] -right-[3px] rounded-full bg-background px-[1px] font-mono text-[9px] font-semibold italic leading-none text-foreground/70",children:"ƒ"})]})}function hk(e){const t=(e||"").toLowerCase()==="calculated";return l.jsx(oC,{dataType:e,calculated:t})}const qW="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",UW="h-8 w-full justify-start gap-2 px-2.5 text-[13px] font-normal";function udt({value:e,onChange:t,metrics:n,attributes:r}){const o=(s,i)=>(e==null?void 0:e.field.id)===s.id&&(e==null?void 0:e.type)===i;return l.jsx(m.TooltipProvider,{children:l.jsxs("div",{className:"space-y-4",children:[n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:qW,children:"Value of metric"}),l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Info,{className:"h-3.5 w-3.5 text-muted-foreground"})}),l.jsxs(m.TooltipContent,{className:"max-w-xs",children:[l.jsx("p",{className:"mb-1 text-[12px] font-medium",children:"Captures intersection of all dimensions"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>{const i=o(s,"metric");return l.jsxs(m.Button,{variant:i?"default":"outline",size:"sm",className:m.cn(UW,i&&"font-medium"),onClick:()=>t({type:"metric",field:s}),children:[hk(s.dataType),l.jsx("span",{className:"truncate",children:s.label}),i&&l.jsx(m.Check,{className:"ml-auto h-3.5 w-3.5"})]},s.id)})})]}),r.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:qW,children:"Value of attribute"}),l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Info,{className:"h-3.5 w-3.5 text-muted-foreground"})}),l.jsxs(m.TooltipContent,{className:"max-w-xs",children:[l.jsx("p",{className:"mb-1 text-[12px] font-medium",children:"Captures only this dimension"}),l.jsx("p",{className:"text-[12px] 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)`})]})]})]}),l.jsx("div",{className:"space-y-1",children:r.map(s=>{const i=o(s,"attribute");return l.jsxs(m.Button,{variant:i?"default":"outline",size:"sm",className:m.cn(UW,i&&"font-medium"),onClick:()=>t({type:"attribute",field:s}),children:[hk(s.dataType),l.jsx("span",{className:"truncate",children:s.label}),i&&l.jsx(m.Check,{className:"ml-auto h-3.5 w-3.5"})]},s.id)})})]}),n.length===0&&r.length===0&&l.jsx("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:"No metrics or attributes available in this chart"})]})})}const vv="h-auto py-1.5";function Qs({label:e,description:t,children:n,className:r}){return l.jsxs("div",{className:m.cn("space-y-2",r),children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(m.Label,{className:"text-[13px] font-medium",children:e}),t&&l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:t})]}),n]})}const WW=[{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 ddt({value:e,onChange:t}){const n=WW.find(r=>r.value===e);return l.jsx("div",{className:"space-y-2",children:l.jsxs(m.Select,{value:e,onValueChange:t,children:[l.jsx(m.SelectTrigger,{size:"sm",className:"w-full",children:l.jsx(m.SelectValue,{placeholder:"Choose action…",children:n&&l.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=nk(n.value);return l.jsx(r,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})})(),l.jsx("span",{children:n.label})]})})}),l.jsx(m.SelectContent,{children:WW.map(r=>{const o=nk(r.value);return l.jsx(m.SelectItem,{value:r.value,className:vv,children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(o,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx("span",{className:"text-[13px] font-medium leading-[1.35]",children:r.label}),l.jsx("span",{className:"text-[12px] leading-[1.35] text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}const fdt=[{value:"all-cards",label:"All cards",description:"Apply filter to all cards in the dashboard"},{value:"specific-cards",label:"Only specific cards",description:"Apply filter to selected cards only",picker:{label:"Cards to filter",description:"Select which cards should receive the filter"}},{value:"all-except-specific",label:"All cards except specific ones",description:"Apply filter to all cards, excluding selected ones",picker:{label:"Cards to exclude",description:"Select which cards should be excluded from filtering"}}];function hdt({interaction:e,onUpdate:t}){const[n,r]=v.useState(""),o=m.useCurrentSheetActiveCards(),s=v.useId(),i=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",a=f=>{const h={};switch(f){case"all-cards":h.applyToCardIds=void 0,h.excludeCardIds=void 0;break;case"specific-cards":h.applyToCardIds=[],h.excludeCardIds=void 0;break;case"all-except-specific":h.applyToCardIds=void 0,h.excludeCardIds=[];break}t({...e,...h})},c=(f,h)=>{if(h==="specific-cards"){const p=e.applyToCardIds||[],g=p.includes(f)?p.filter(b=>b!==f):[...p,f];t({...e,applyToCardIds:g})}else if(h==="all-except-specific"){const p=e.excludeCardIds||[],g=p.includes(f)?p.filter(b=>b!==f):[...p,f];t({...e,excludeCardIds:g})}},u=v.useMemo(()=>{if(!n.trim())return o;const f=n.toLowerCase();return o==null?void 0:o.filter(h=>{var p;return(p=h==null?void 0:h.title)==null?void 0:p.toLowerCase().includes(f)})},[n,o]),d=i();return l.jsxs("div",{className:"space-y-4",children:[l.jsx(Qs,{label:"Filter scope",description:"Choose which cards should receive the filter",children:l.jsx(yu,{value:d,onValueChange:f=>a(f),className:"space-y-0.5",children:fdt.map(f=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-start gap-2.5 rounded-control px-2 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Xs,{value:f.value,id:`${s}-${f.value}`,className:"mt-0.5"}),l.jsxs("div",{className:"flex-1 space-y-0.5",children:[l.jsx(m.Label,{htmlFor:`${s}-${f.value}`,className:"cursor-pointer text-[13px] font-medium",children:f.label}),l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:f.description})]})]}),d===f.value&&f.picker&&l.jsxs("div",{className:"ml-[26px] mt-2 space-y-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(m.Label,{className:"text-[13px] font-medium",children:f.picker.label}),l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:f.picker.description})]}),l.jsx(m.Input,{size:"sm",placeholder:"Search cards…",value:n,onChange:h=>r(h.target.value)}),l.jsx("div",{className:"max-h-40 overflow-y-auto rounded-card border border-border/60",children:u&&u.length>0?u.map(h=>{const g=((f.value==="specific-cards"?e.applyToCardIds:e.excludeCardIds)||[]).includes(h.id),b=`${s}-${f.value}-${h.id}`;return l.jsxs("div",{className:"flex items-start gap-2.5 px-2.5 py-2 transition-colors odd:bg-muted/30 hover:bg-muted/50",children:[l.jsx(In,{id:b,checked:g,onCheckedChange:()=>c(h.id,f.value),className:"mt-0.5"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx(m.Label,{htmlFor:b,className:"cursor-pointer text-[13px] font-normal",children:h.title}),h.description&&l.jsx("p",{className:"mt-0.5 line-clamp-1 text-[12px] text-muted-foreground",children:h.description})]})]},h.id)}):l.jsx("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]},f.value))})}),l.jsx(Qs,{label:"Menu label",description:"How this interaction appears when multiple actions are available",children:l.jsx(m.Input,{size:"sm",value:e.label||"",onChange:f=>t({...e,label:f.target.value}),placeholder:sp(e.mode)})})]})}function mdt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const hT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ox(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Vz(e){return"nodeType"in e}function ii(e){var t,n;return e?ox(e)?e:Vz(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Hz(e){const{Document:t}=ii(e);return e instanceof t}function sC(e){return ox(e)?!1:e instanceof ii(e).HTMLElement}function Nhe(e){return e instanceof ii(e).SVGElement}function sx(e){return e?ox(e)?e.document:Vz(e)?Hz(e)?e:sC(e)||Nhe(e)?e.ownerDocument:document:document:document}const ul=hT?v.useLayoutEffect:v.useEffect;function mT(e){const t=v.useRef(e);return ul(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function pdt(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function wv(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ul(()=>{n.current!==e&&(n.current=e)},t),n}function iC(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function mk(e){const t=mT(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function pk(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let o2={};function aC(e,t){return v.useMemo(()=>{if(t)return t;const n=o2[e]==null?0:o2[e]+1;return o2[e]=n,e+"-"+n},[e,t])}function jhe(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,u]of a){const d=s[c];d!=null&&(s[c]=d+e*u)}return s},{...t})}}const xg=jhe(1),Cv=jhe(-1);function gdt(e){return"clientX"in e&&"clientY"in e}function pT(e){if(!e)return!1;const{KeyboardEvent:t}=ii(e.target);return t&&e instanceof t}function bdt(e){if(!e)return!1;const{TouchEvent:t}=ii(e.target);return t&&e instanceof t}function gk(e){if(bdt(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 gdt(e)?{x:e.clientX,y:e.clientY}:null}const Xi=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[Xi.Translate.toString(e),Xi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),KW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xdt(e){return e.matches(KW)?e:e.querySelector(KW)}const ydt={display:"none"};function vdt(e){let{id:t,value:n}=e;return v.createElement("div",{id:t,style:ydt},n)}function wdt(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={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 v.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Cdt(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const khe=v.createContext(null);function Sdt(e){const t=v.useContext(khe);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ndt(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const jdt={draggable:`
1301
+ `).map(Xe=>Xe.trim()).find(Xe=>Xe.length>0),kt=v.useMemo(()=>V?og(V):null,[V]),qt=!!kt&&JSON.stringify(ao)!==JSON.stringify(kt),Dn=X.body.type==="custom_message",ar=Rt&&!k&&X.body.type==="generated_analysis",Ln=X.source.type==="dashboard"||!!(c!=null&&c.length),fr=Dn?Ls?"Message (optional)":"Email body":"What should this briefing investigate?",Ei=Dn?"Write the email body that recipients will see.":"Describe the outcome in business terms. Mention what to watch, when to bother the team, and what to include in the briefing.",$s=Dn?"Sent as-is in the email body. No analysis is generated.":"Tell the analyst what to watch, when to escalate, and what to include.",Zu=Xe=>{var xt,Xt;if(Ie(Xe),Xe==="EMAIL"){To({delivery:{channels:r1(X.delivery.channels,"EMAIL")}});return}To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((xt=X.delivery.channelConfigs)==null?void 0:xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:((Xt=Hn==null?void 0:Hn.destination)==null?void 0:Xt.type)==="channel"?Hn.destination:{type:"channel",channelId:""},postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},gx=()=>{if(Ku){To({delivery:{channels:Put(X.delivery.channels,jl)}});return}Zu(jl)},bx=Xe=>{var Xt;const xt=$e.find(qr=>qr.id===Xe);Ie("SLACK"),To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((Xt=X.delivery.channelConfigs)==null?void 0:Xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:{type:"channel",channelId:Xe,...xt?{channelName:xt.name}:{},...xt?{isPrivate:xt.isPrivate}:{}},postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},wC=Xe=>{var xt,Xt;Ie("SLACK"),To({delivery:{channels:r1(X.delivery.channels,"SLACK"),channelConfigs:{...X.delivery.channelConfigs??{},SLACK:{...((xt=X.delivery.channelConfigs)==null?void 0:xt.SLACK)??{},formatProfile:"concise",slackConfig:{...Hn??{},destination:((Xt=Hn==null?void 0:Hn.destination)==null?void 0:Xt.type)==="channel"?Hn.destination:{type:"channel",channelId:""},threadMentions:Xe,postThreadDetail:(Hn==null?void 0:Hn.postThreadDetail)??!0,includeDashboardLink:!0,includeBriefingLink:!0}}}}})},pye=v.useMemo(()=>{const Xe=X.schedule.enabled?tt.describeBriefingSchedule(X.schedule.scheduleExpr,X.schedule.timezone)??"Invalid schedule":"On demand",xt=X.delivery.recipients.length,Xt=xt===0?"No email recipients":`${xt} email recipient${xt===1?"":"s"}`,qr=La?`#${La.name}`:"Slack channel";return Ku?`${Xe} · ${Xt} · ${qr}`:li?`${Xe} · ${La?`#${La.name}`:"Slack channel"}`:`${Xe} · ${Xt}`},[X.delivery.recipients.length,X.schedule.enabled,X.schedule.scheduleExpr,X.schedule.timezone,Ku,li,La]);return l.jsxs("section",{className:m.cn("flex h-full min-h-0 w-full max-w-[480px] flex-col border-l border-border bg-background text-foreground",h),"aria-label":Xo.authorLabel,children:[f?null:l.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[l.jsxs("div",{className:"min-w-0",children:[w?l.jsxs("button",{type:"button",onClick:w,className:"-ml-1 mb-1 inline-flex items-center gap-1 rounded-control px-1 py-0.5 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 rotate-180"}),"Back to ",Xo.plural]}):null,l.jsx("h2",{className:"truncate text-[14px] font-semibold leading-5 text-foreground",children:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[Rt?l.jsx("span",{className:m.cn("inline-flex items-center rounded-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-[0.06em]",Vut(Ot)),children:Ot}):null,C?l.jsx("button",{type:"button","aria-label":Xo.closeLabel,onClick:C,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Me.X,{className:"h-3.5 w-3.5"})}):null]})]}),it!=="edit"?l.jsxs("button",{type:"button",onClick:()=>Re("edit"),className:"flex w-full items-center justify-between gap-2 border-b border-border px-4 py-2.5 text-left transition-colors hover:bg-muted/60",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] text-foreground/80",children:He||X.name||Xo.untitledLabel}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:pye})]}),l.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[Xo.editLabel,l.jsx(Me.ChevronDown,{className:"h-3 w-3 rotate-180"})]})]}):null,De?l.jsx(vut,{}):null,l.jsx(Nut,{pendingAction:re,previewRun:ce,savedActiveRun:De,detailsVisible:Ve,onShowDetails:()=>Ee(Xe=>!Xe),onCancelPreviewRun:Tn?Yt:void 0,onCancelSavedRun:De?Ye:void 0,onMinimizeRun:De&&N?En:void 0}),Ve&&ce&&wh(ce.status)?l.jsx(FW,{run:ce}):Ve&&De?l.jsx(FW,{run:De}):null,l.jsx("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:it==="edit"?l.jsxs(l.Fragment,{children:[ar?l.jsxs("div",{className:"rounded-card border border-amber-200 bg-amber-50 px-3 py-2.5 text-[12px] leading-[1.5] text-amber-900 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-200",children:[l.jsx("div",{className:"font-medium",children:"Analytical briefings are disabled for this project."}),l.jsx("p",{className:"mt-0.5 text-amber-800 dark:text-amber-300",children:"You can pause or delete this briefing while analytical briefings are unavailable."})]}):null,dt?l.jsx(Aut,{previewRun:dt,isStale:jt,onViewOutput:()=>Re("result")}):null,nt&&Ue?l.jsx(yut,{run:Ue,onViewOutput:()=>Re("result"),onDeleteRun:Ue.status==="FAILED"?()=>me(Ue.id):void 0,onRetryRun:Ue.status==="FAILED"&&Rt?()=>{Nc()}:void 0,retryDisabled:qe||Rt&&qt,retryDisabledReason:Rt&&qt?`Save your changes before retrying — Retry uses the saved ${Xo.noun}.`:void 0,deletePending:re==="deleteRun"}):null,Ls?l.jsx(Vnt,{draft:X,onChange:To,onExpand:()=>mt(!0)}):l.jsx(Hnt,{draft:X,onChange:To,onExpand:()=>mt(!0)}),l.jsx(No,{open:Ze,onOpenChange:mt,children:l.jsxs(po,{className:"flex h-[80vh] max-h-[800px] w-[92vw] max-w-[860px] flex-col gap-0 p-0",children:[l.jsxs(Es,{className:"border-b border-border/60 px-5 py-3",children:[l.jsx(go,{className:"text-[14px] font-semibold",children:fr}),Ls?null:l.jsx(Oo,{className:"text-[12px] text-muted-foreground",children:$s})]}),l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-5 py-4",children:[l.jsx("label",{htmlFor:"briefing-instruction-expanded",className:"sr-only",children:fr}),l.jsx("textarea",{id:"briefing-instruction-expanded",autoFocus:!0,className:"min-h-0 flex-1 resize-none bg-transparent text-[14px] leading-[1.6] text-card-foreground/90 outline-none placeholder:text-muted-foreground",value:X.instruction,onChange:Xe=>{To({instruction:Xe.target.value})},placeholder:Ei,"aria-label":fr})]}),l.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 px-5 py-2.5",children:[l.jsx("div",{className:"flex flex-1 items-center gap-2 text-[12px] text-muted-foreground",children:Dt?l.jsx("span",{className:"text-destructive",children:Dt}):bt?l.jsxs("button",{type:"button",onClick:sn,className:"inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-foreground/80 hover:bg-muted hover:text-foreground",children:[l.jsx(UZ,{className:"h-3 w-3"}),"Revert polish"]}):null}),I?l.jsxs("button",{type:"button",onClick:en,disabled:ft||!X.instruction.trim()||!G||!Q,title:"Fix typos, grammar, and minor wording without changing your meaning",className:ou,children:[ft?l.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin"}):l.jsx(k0,{className:"h-3 w-3"}),ft?"Polishing…":"Polish"]}):null,l.jsx("button",{type:"button",onClick:()=>mt(!1),className:ou,children:"Done"})]})]})}),Ln?l.jsx(ert,{attachments:X.attachments,source:X.source,dashboard:P,selectedSheetId:z,runtime:Fs,availableDashboards:c,disabled:qe,onChange:To}):null,l.jsx(art,{schedule:X.schedule,onChange:To}),l.jsx(grt,{draft:X,effectiveChannels:ao.delivery.channels,reportAuthoring:Ls,slackAllowed:lp,deliveryMode:Sc,secondaryDeliveryMode:jl,hasMultiChannelDelivery:Ku,slackStatus:Ae,slackLoading:at,slackChannels:$e,selectedSlackChannelId:Ef,selectedSlackChannel:La,threadMentions:Gu,slackMentionStatus:At,slackError:rt,apiServiceUrl:G,onChange:To,onDeliveryModeChange:Zu,onSecondaryDeliveryChange:gx,onSlackChannelChange:bx,onSlackMentionsChange:wC,onSlackRefresh:()=>gt(Xe=>Xe+1)}),Dn?null:l.jsxs("div",{children:[l.jsx("div",{className:m.cn(oo,"mb-2"),children:"Scope"}),l.jsx(frt,{source:X.source,resolvedSourceContext:L,sourceDetail:Vt,onChange:Xe=>To({source:Xe})})]})]}):it==="plan"&&pe?l.jsx(put,{previewPlan:pe,previewRun:ce&&ce.status!=="SUCCESS"?ce:null,scopeLabel:L.source.type==="dashboard"?(P==null?void 0:P.title)??L.label:L.label}):it==="result"&&ce?l.jsx(OW,{previewRun:ce,reportMode:Ls,onExpand:()=>{Le("preview"),de(!0)}}):it==="result"&&Ue?l.jsx(LW,{run:Ue,reportMode:Ls,onExpand:()=>{Le("saved"),de(!0)},onDeleteRun:Ue.status==="FAILED"?()=>me(Ue.id):void 0,onRetryRun:Ue.status==="FAILED"&&Rt?()=>{Nc()}:void 0,retryDisabled:qe||Rt&&qt,retryDisabledReason:Rt&&qt?`Save your changes before retrying — Retry uses the saved ${Xo.noun}.`:void 0,deletePending:re==="deleteRun"}):null}),se.length>0||ae?l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-destructive/30 bg-destructive/10 px-4 py-2.5",children:[se.length>0?l.jsxs("div",{role:"alert",className:"text-[12px] leading-[1.5] text-destructive",children:[l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1.5 font-medium",children:[l.jsx(m.Info,{className:"h-3 w-3"}),"Fix these before saving:"]}),l.jsx("ul",{className:"space-y-0.5 pl-4",children:se.map(Xe=>l.jsx("li",{className:"list-disc marker:text-destructive/60",children:Xe.message},`${Xe.field}:${Xe.message}`))})]}):null,ae?l.jsxs("div",{role:"alert",className:"flex items-start gap-1.5 text-[12px] leading-[1.55] text-destructive",children:[l.jsx(m.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{children:ae})]}):null]}):null,l.jsx(trt,{existing:Rt,activeView:it,scheduledReport:M,scheduleEnabled:X.schedule.enabled,customMessage:Dn,contentNoun:Xo.noun,analyticalBriefingsEnabled:k,analysisUnavailable:ar,canToggleScheduleStatus:Ne,paused:an,busy:qe,draftDirty:qt,hasActiveRun:ir,pendingAction:re,canDiscard:!Rt&&!!C&&!w,onStatusChange:je,onEdit:()=>Re("edit"),onDiscard:()=>C==null?void 0:C(),onPlan:()=>{$a()},onRun:()=>{Nc()},onSave:()=>{Df()}}),l.jsx(No,{open:we,onOpenChange:Xe=>{de(Xe),Xe||Le(null)},children:l.jsxs(po,{className:"flex max-h-[90vh] w-[min(960px,calc(100vw-32px))] max-w-none flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"border-b border-border px-6 py-3 text-left",children:[l.jsx(go,{className:"truncate text-[14px] font-semibold leading-5",children:Ps}),l.jsx(Oo,{className:"text-[12px] text-muted-foreground",children:Xo.expandedDescription})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:Ht?l.jsx(OW,{previewRun:Ht,reportMode:Ls,fullWidth:!0}):_r?l.jsx(fk,{preview:_r,reportMode:Ls}):yn?l.jsx(LW,{run:yn,reportMode:Ls}):null})]})})]})}function fhe({open:e,onOpenChange:t,launchRequest:n,briefing:r,authorProps:o}){return l.jsx(p3,{open:e,onOpenChange:t,children:l.jsxs(gI,{side:"right",hideClose:!0,className:"flex h-full w-full max-w-[480px] flex-col gap-0 overflow-hidden p-0 sm:max-w-[480px]",children:[l.jsx(bI,{className:"sr-only",children:n.title??"Briefing"}),l.jsx(xI,{className:"sr-only",children:"Configure report content, delivery, and schedule."}),e?l.jsx(dhe,{...o,className:m.cn("max-w-none border-0",o==null?void 0:o.className),briefing:r,intent:n.intent,sourceContext:n.sourceContext,initialAttachments:n.initialAttachments,initialName:n.initialName,initialMessage:n.initialMessage,initialTimezone:n.initialTimezone,availableDashboards:n.availableDashboards,title:n.title,onCancel:()=>t(!1)},(r==null?void 0:r.id)??"new"):null]})})}function hhe(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!0}const zz=v.createContext(null);function dT({children:e}){const t=Et(),{currentUser:n,isLoading:r,isError:o}=si(),s=v.useMemo(()=>{var c,u,d;const i=hhe((c=t.tokenProps.config)==null?void 0:c.showBriefings,t.showBriefings);return{surfaceVisible:i,canCreate:i&&(!r&&!o&&!!n)&&tt.canCreateBriefingForUser(n),analyticalBriefingsEnabled:((d=(u=t.tokenProps.config)==null?void 0:u.projectFeatures)==null?void 0:d.features.analyticalBriefings)!==!1,userType:(n==null?void 0:n.type)??null,loading:r,error:o}},[t.showBriefings,t.tokenProps.config,n,o,r]);return l.jsx(zz.Provider,{value:s,children:e})}function Hut({children:e}){return v.useContext(zz)?e:l.jsx(dT,{children:e})}function mhe(){return v.useContext(zz)??{surfaceVisible:!1,canCreate:!1,analyticalBriefingsEnabled:!1,userType:null,loading:!1,error:!0}}const qut=new Set(["table","pivotTable","aggregateTable","matrixTable","detailTable"]);function Uut({card:e,frame:t,exportData:n}){var M,P,A,z;const[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=mhe(),c=m.useDashboardStore(O=>O.dashboard),u=m.useDashboardStore(O=>O.isDashboardEditing),d=m.useDashboardStore(O=>O.isVisualEditing),f=m.useDashboardStore(O=>O.selectedSheetId),h=m.useDashboardStore(O=>O.filterValues),p=m.useDashboardStore(O=>O.inlineFilterValuesMap),g=m.useDashboardStore(O=>O.controlValues),b=m.useDashboardStore(O=>O.cardControlValuesMap),x=m.useDashboardStore(O=>O.dashboardInputValues),y=m.useDashboardStore(O=>O.semanticExecutionPayload),C=m.useDashboardStore(O=>O.theme),w=m.useInteractionStore(O=>O.interactionStates),N=qut.has(e.type),S=((M=e.preferences)==null?void 0:M.allowDownload)!==!1,j=N&&S,I=c==null?void 0:c.id,k=I?{type:"dashboard",dashboardId:I}:null,T=k?rk({source:k,dashboard:c,selectedSheetId:f}).find(O=>O.kind==="card"&&O.cardId===e.id):void 0,_=T?rN({option:T,runtime:{dashboard:c,theme:C||"light",filters:c==null?void 0:c.filters,selectedSheetId:f,filterValues:h,inlineFilterValuesMap:p,controlValues:g,controlDefinitions:(c==null?void 0:c.controls)||[],dashboardControls:(c==null?void 0:c.controls)||[],cardControlValuesMap:b,dashboardInputValues:x,semanticExecutionPayload:y,interactionStates:w}}):void 0,E=a.surfaceVisible&&a.canCreate&&!u&&!d&&(_==null?void 0:_.status)==="ready";if(!j&&!E)return null;const D=(_==null?void 0:_.status)==="ready"?_.attachment:null;return l.jsxs(l.Fragment,{children:[l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(m.Button,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground","aria-label":"Card actions",children:l.jsx(ei,{className:"h-3.5 w-3.5"})})}),l.jsxs(mo,{align:"end",children:[j&&l.jsxs(mn,{onSelect:()=>o(!0),children:[l.jsx(_u,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Download"]}),E?l.jsxs(mn,{onSelect:()=>i(!0),children:[l.jsx(EO,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Schedule this visual…"]}):null]})]}),j&&l.jsx(uI,{isOpen:r,onClose:()=>o(!1),frame:t,card:e,data:n}),k&&D?l.jsx(fhe,{open:s,onOpenChange:i,launchRequest:{intent:"scheduled_report",sourceContext:{source:k,label:((P=e.title)==null?void 0:P.trim())||"Visual",detail:"Schedule this dashboard visual."},initialAttachments:[D],initialName:`${((A=e.title)==null?void 0:A.trim())||"Visual"} report`,initialMessage:`Attached is the latest ${((z=e.title)==null?void 0:z.trim())||"visual"} report.`,title:"Schedule this visual"}}):null]})}function Wut({canEditDashboard:e,isDashboardEditing:t,isMissingConnection:n,onConfigure:r}){const o=e&&!t;return l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-4 py-6 text-center",children:[l.jsx(hZ,{"aria-hidden":"true",className:"h-8 w-8 text-muted-foreground/40",strokeWidth:1.5}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:n?"Connect a data source":"Add fields to see data"}),o?l.jsx(m.Button,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground hover:text-foreground",onClick:r,children:"Edit visual"}):null]})}function Kut(e,t,n,r){var h,p;const o=m.getVisualizationMode(e)==="dynamic",s=v.useMemo(()=>m.buildEffectiveFallbackCard(e,t),[e,t]),{data:i}=Nw(s),a=v.useMemo(()=>(n==null?void 0:n.records)||[],[n==null?void 0:n.records]),c=Mb(s,a),u=v.useMemo(()=>s.type!=="pivotTable"?{kind:"not_loaded"}:Zm({data:n,card:s}),[s,n]),d=Ym(s,u,(h=n==null?void 0:n.metadata)==null?void 0:h.comparisonMetadata),f=v.useMemo(()=>{var g,b;if(!(!o||!((g=n==null?void 0:n.records)!=null&&g.length)||["kpi","text","table","detailTable","pivotTable","aggregateTable","matrixTable","custom"].includes(s.type)))return Db({card:s,data:n.records,cardType:s.type,queryConfig:s.queryConfig,customCfg:s.customCfg,preferences:s.preferences,topoJson:i,comparisonMetadata:(b=n==null?void 0:n.metadata)==null?void 0:b.comparisonMetadata,numericPresentation:c,resultColumns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,temporalPresentation:m.INACTIVE_DYNAMIC_FALLBACK_TEMPORAL_PRESENTATION})},[s,i,o,n==null?void 0:n.records,n==null?void 0:n.columns,n==null?void 0:n.columnKeyMap,(p=n==null?void 0:n.metadata)==null?void 0:p.comparisonMetadata,c,r]);return{isDynamicVisualizationMode:o,fallbackCard:s,tableRecords:a,pivotTableConfig:d,fallbackCfg:f}}const Gut=[];function zW({card:e,frame:t,cardToolbarAction:n}){var Hn,Ef,La,Gu,Nl,Cc,Sc,jl,To,fs,Yu,Df,Ti,$a,cp,Nc,Mf;const{authToken:r,customCards:o,placeholders:s,tokenProps:i}=Et(),{displayPreferences:a,shouldShowElement:c}=pl(),u=Ou(),d=xl(),f=m.useDashboardStore(Ye=>Ye.themeStyle),h=m.useDashboardStore(Ye=>Ye.dashboard),p=m.useDashboardStore(Ye=>Ye.selectedSheetId),g=m.useDashboardStore(Ye=>Ye.isDashboardEditing);m.useDashboardStore(Ye=>Ye.selectedLensId);const b=m.useDashboardStore(Ye=>Ye.dashboard.filters),x=m.useDashboardStore(Ye=>Ye.filterValues),y=m.useDashboardStore(Ye=>Ye.inlineFilterValuesMap),C=m.useDashboardStore(Ye=>Ye.authToken),w=m.useEditorStore(Ye=>Ye.selectedConnectionId),N=m.useEditorStore(Ye=>Ye.selectedDatabaseName),S=m.useEditorStore(Ye=>Ye.selectedSchemaName),j=m.useEditorStore(Ye=>Ye.selectedTableName),I=m.useEditorStore(Ye=>Ye.selectedDatamodelId),k=tt.findCustomVisualConfigCard(t,e),{manifest:T}=kf(((Hn=k==null?void 0:k.customCardPreferences)==null?void 0:Hn.url)||""),_=(Ef=T==null?void 0:T.visuals)==null?void 0:Ef.find(Ye=>{var Yt;return Ye.name===((Yt=k==null?void 0:k.customCardPreferences)==null?void 0:Yt.componentName)}),E=tt.resolveMultiInputType(k,_)==="multiple",D=E&&k?k:e,M=tt.isDeclaredSqlRawTemporalPresentationCard({card:D}),P=m.useDashboardStore(Ye=>Ye.isVisualEditing),A=m.useEditorStore(Ye=>{var Yt,En;return M&&P&&((Yt=Ye.card)==null?void 0:Yt.id)===D.id&&((En=Ye.frame)==null?void 0:En.id)===t.id?Ye.card:void 0}),z=m.getVisualizationMode(D)==="dynamic",O=m.useInteractionStore(Ye=>Ye.interactionStates[D.id]),B=((La=O==null?void 0:O.breadcrumbs)==null?void 0:La.length)>0,H=m.useDashboardStore(Ye=>Ye.inlineFilterValuesMap[D.id]),R=b==null?void 0:b.find(Ye=>Ye.id===t.filterId&&!Ye.hide),{clearSelectedVisual:q}=Rm(),$=Ts(Ye=>Ye.selectedDashboard),F=Ts(Ye=>Ye.initialDashboard),U=$?(Nl=$==null?void 0:$.permissions)==null?void 0:Nl.canEdit:(Gu=F==null?void 0:F.permissions)==null?void 0:Gu.canEdit,G=tt.hasMissingDeclaredSqlCustomDateFormat(D),Q=U&&G,{setSelectedFrameId:W,updateFilter:L,updateFrame:K,setIsDashboardEditing:Y,setIsVisualEditing:V}=m.useDashboardActions(),{handleChartClick:Z}=Wtt(D),{setCard:X,setFrame:te,setQueryResultColumns:re,setActiveTabCardId:ie,setIsDevMode:se,initializeModeDrafts:le,updateDataSource:ae}=m.useEditorActions(),xe=m.useEditorStore(Ye=>Ye.actions.setSelectedConnectionId),fe=m.useEditorStore(Ye=>Ye.actions.setSelectedDatamodelId),be=m.useEditorStore(Ye=>Ye.actions.setSelectedDatabaseName),pe=m.useEditorStore(Ye=>Ye.actions.setSelectedSchemaName),ye=m.useEditorStore(Ye=>Ye.actions.setSelectedTableName),ce=m.useEditorStore(Ye=>Ye.actions.setFilterValues),J=m.useEditorStore(Ye=>Ye.actions.setInlineFilterValuesMap),ne=m.useEditorStore(Ye=>Ye.actions.setApplyFilters),ee=c("showHeader")&&(((Cc=D.customCardPreferences)==null?void 0:Cc.showCardHeader)??!0),ue=v.useMemo(()=>E&&D?{...D,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:D,[D,E]),ge=!(D.connectionId||(Sc=D.dataSource)!=null&&Sc.connectionId),_e=!!(o!=null&&o.find(Ye=>Ye.cardId===e.id&&!!Ye.content)),Te=ut.isCardUnconfigured(D,{skipSetupCheck:E&&!!k||_e});function Ce(){U&&(W(t.id),q(),P_({frame:t,card:e,setFrame:te,setCard:X,setIsDevMode:se,initializeModeDrafts:le,setActiveTabCardId:ie,updateDataSource:ae,setQueryResultColumns:re,setSelectedConnectionId:xe,setSelectedDatabaseName:be,setSelectedSchemaName:pe,setSelectedTableName:ye,setSelectedDatamodelId:fe,setFilterValues:ce,setInlineFilterValuesMap:J,setApplyFilters:ne,setIsDashboardEditing:Y,setIsVisualEditing:V,dashboard:h,selectedSheetId:p,selectedFrameId:t.id,filterValues:x,inlineFilterValuesMap:y,currentSelections:{connectionId:w,databaseName:N,schemaName:S,tableName:j,datamodelId:I}}))}const{isError:Re,isLoading:Ve,isFetching:Ee,fetchStatus:We,cfg:Ie,isRetainingSourceResult:we,isPending:de,data:Se,handleDatapointClick:Le,queryRequestPayload:Ae,pagination:st,comparisonMetadata:$e,resolvedPrimaryDateField:Ke,effectiveCardConfig:at,queryKey:ct}=kw(ue),{fallbackCard:rt,tableRecords:ht,pivotTableConfig:wt,fallbackCfg:gt}=Kut(D,at,Se,f),At=A??rt,Pe=rt.type==="matrixTable",Ze=Pe&&_w(Se),mt=Pe?GR(ct):void 0,[ft,yt]=v.useState(null),[Dt,Mt]=oe.useReducer(aze,{result:null,branchError:null}),{result:bt,branchError:Tt}=Dt,[Ut,un]=v.useState(new Set),Qe=oe.useRef(null),ze=oe.useRef(void 0),Oe=oe.useRef(ct);Oe.current=ct,oe.useEffect(()=>{if(!Pe)return;const Ye=Oe.current,Yt=(Se==null?void 0:Se.matrixResult)||null,En=uze({previousResult:Qe.current,nextResult:Yt,sharesCalendarIdentity:D5(Ye,ze.current)});Mt({type:"replace-result",result:Yt}),En&&(yt(null),un(new Set)),Qe.current=Yt,ze.current=Ye},[Se==null?void 0:Se.matrixResult,Pe,mt]);const he=cI({data:Se,isLoading:Ve,isFetching:Ee}),Be=we,ot=tk({card:rt,fetchStatus:Be?"idle":We,isLoading:Be?!1:Ve,isFetching:Be?!1:Ee,isPending:Be?!1:de,hasRecords:Ze||!!((jl=Se==null?void 0:Se.records)!=null&&jl.length)}),[Rt,an]=v.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:Ne,hierarchyId:Fe}=m.useInteractionStore(m.useShallow(Ye=>{var Yt,En;return{breadcrumbs:((Yt=Ye.interactionStates[D.id])==null?void 0:Yt.breadcrumbs)??Gut,hierarchyId:(En=Ye.interactionStates[D.id])==null?void 0:En.hierarchyId}})),De=(Ye,Yt,En)=>{var He;const en=Ne.length>0?[{mode:"drillUp",trigger:(He=Ye[0])==null?void 0:He.trigger,label:"Drill Up",hierarchyId:Fe}]:[],sn=[];for(const kt of Ye)if(kt.mode==="dynamicDrill"&&kt.availableFields){const qt=kt.availableFields.filter(Dn=>!Ne.some(ar=>{var Ln;return((Ln=ar.toField)==null?void 0:Ln.id)===Dn.id}));for(const Dn of qt)sn.push({mode:"dynamicDrill",trigger:kt.trigger,drillField:Dn,label:Dn.label,availableFields:kt.availableFields})}const me=Ye.filter(kt=>kt.mode!=="dynamicDrill"),je=[...en,...me,...sn];an({open:!0,position:En||{x:0,y:0},interactions:je,context:Yt})},Ue=D,{handlePointerInteraction:Nt,applySelectedInteraction:it}=m.useEventEngine(Ue,t.id,p||"",De),Vt=(Ye,Yt)=>{const En={...e,paginationConfig:{page:Ye+1,pageSize:Yt}},en={...t,cards:t.cards.map(sn=>sn.id===e.id?En:sn)};p&&K(p,en)},Ot=Ye=>{var sn,me,je;const Yt=lse(Ye,(sn=e.config)==null?void 0:sn.metricColumns,(me=e.config)==null?void 0:me.groupByColumns,(je=e.config)==null?void 0:je.detailColumns),En={...e,config:{...e.config||{},sortByColumns:Yt}},en={...t,cards:t.cards.map(He=>He.id===e.id?En:He)};p&&K(p,en)},Tn=Ye=>{const Yt=e.config||{},En={...Yt,sort:Ye,...Yt.matrixIntent?{matrixIntent:{...Yt.matrixIntent,sort:Ye}}:{}},en={...e,config:En},sn={...t,cards:t.cards.map(me=>me.id===e.id?en:me)};Mt({type:"replace-result",result:null}),p&&K(p,sn)},zr=Ye=>{yt(Ye.state),!(!("rowPath"in Ye)||!Ye.isExpanded||!Ae)&&ir(Ye.rowPath)},ir=async Ye=>{if(!Ae||!(Se!=null&&Se.matrixResult))return;const Yt=uo(Ye),En=ct;un(en=>new Set(en).add(Yt));try{const en=await m.postRequest(`${i.apiServiceUrl}/v1/query`,(r==null?void 0:r.accessToken)||(C==null?void 0:C.accessToken)||"",{...Ae,matrixBranchRequest:{axis:"row",path:Ye.map(({instanceId:me,fieldKey:je,value:He})=>({instanceId:me,fieldKey:je,value:He})),depth:Ye.length+1}}),sn=lze(en==null?void 0:en.matrixResult);if(!A_e(Oe.current,En))return;Mt({type:"merge-branch",baseResult:Se.matrixResult,branch:sn})}catch(en){console.error("Failed to fetch matrix branch",en),Mt({type:"reject-branch",error:en})}finally{un(en=>{const sn=new Set(en);return sn.delete(Yt),sn})}};function qe(Ye,Yt){if(Ye.stopPropagation(),!at)return;const En=Ktt({resolvedCardConfig:at,card:Ue,records:(Se==null?void 0:Se.records)||[],chart:Yt,clickEvent:Ye.nativeEvent,columnKeyMap:Se==null?void 0:Se.columnKeyMap,resultColumns:Se==null?void 0:Se.columns,valueFormatPreferences:d});if(!En)return;const en=m.getInteractions(Ue.interactionConfig),sn=m.findAllMatchingV2Interactions(en,En),me=sn.length===1&&sn[0].mode==="clickFilter",je=sn.some(qt=>qt.mode==="dynamicDrill"),He=sn.length>1||je;Ye.button===0&&me&&!He&&Z(Ye.nativeEvent,Yt);const kt={shift:Ye.shiftKey,ctrl:Ye.ctrlKey,meta:Ye.metaKey};Ye.button===0?Nt({context:En,gesture:"leftClick",modifierKeys:kt,position:{x:Ye.clientX,y:Ye.clientY}}):Ye.button===2&&Nt({context:En,gesture:"rightClick",modifierKeys:kt,position:{x:Ye.clientX,y:Ye.clientY}})}function nt(){var Ye,Yt,En;if(E&&k)return li;if(o&&o.length>0){const en=o.find(sn=>sn.cardId===e.id);if(en&&en.replaceDefault){const sn=en.content;if(sn)return l.jsx(sn,{card:e})}}if(!z&&e.type==="kpi"){if(((Ye=t==null?void 0:t.cards)==null?void 0:Ye.length)===1)return l.jsx(of,{card:e,data:Re?[]:(Se==null?void 0:Se.records)||[],isPending:ot.showCardSkeleton,isError:Re,comparisonMetadata:$e,headerTrailingAction:n});if(((Yt=t==null?void 0:t.cards)==null?void 0:Yt.length)>1)return l.jsx(kU,{frame:t,card:e,cardToolbarAction:n})}return!z&&e.type==="text"&&((En=t==null?void 0:t.cards)==null?void 0:En.length)===1?l.jsx(m.ScrollArea,{className:"h-full break-words",children:l.jsx("div",{className:"px-4 py-3",children:l.jsx(sb,{isLoading:ot.showCardSkeleton,card:e,data:(Se==null?void 0:Se.records)||[],inferDynamicTextFromQuery:!0})})}):li}function dt(){if(E&&k)return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ki,{FallbackComponent:SU,children:l.jsx(Wj,{frame:t,card:k})})});if(Te)return l.jsx(Wut,{canEditDashboard:!!U,isDashboardEditing:g,isMissingConnection:ge,onConfigure:Ce});if(Re)return l.jsx(Jb,{showOwnerGuidance:e.type!=="kpi"});if(ot.showGenericLoadingFallback)return rt.type==="table"||rt.type==="detailTable"||rt.type==="matrixTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(dz,{})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})});if(G)return l.jsx(Kue,{onRepair:Q?Ce:void 0});if(Se!=null&&Se.records&&Se.records.length===0&&!z&&!Ze&&rt.type!=="pivotTable")return s!=null&&s.NoRecords?l.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:s.NoRecords}):l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[l.jsx(RO,{className:"h-8 w-8 text-muted-foreground/40"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No results to display"})]});function Ye(){var En,en,sn;if(rt.type==="kpi"){if(((En=t==null?void 0:t.cards)==null?void 0:En.length)===1)return l.jsx(of,{card:rt,data:Re?[]:(Se==null?void 0:Se.records)||[],isPending:de,isError:Re,comparisonMetadata:$e,headerTrailingAction:n});if(((en=t==null?void 0:t.cards)==null?void 0:en.length)>1)return l.jsx(kU,{frame:t,card:rt,cardToolbarAction:n})}if(rt.type==="table"||rt.type==="detailTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(Jd,{card:At,data:ht,resultColumns:Se==null?void 0:Se.columns,columnKeyMap:Se==null?void 0:Se.columnKeyMap,totalsByColumnId:Se==null?void 0:Se.tableTotalsByColumnId,comparisonMetadata:$e,paginationMetadata:st,onPaginationChange:Vt,onSortChange:Ot,isLoading:Ve||Ee,frameId:t.id,sheetId:p||"",onMultipleInteractions:De})});if(rt.type==="matrixTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(SI,{card:rt,result:bt||(Se==null?void 0:Se.matrixResult),isLoading:he,expansionState:ft||void 0,loadingRowPathKeys:Ut,branchError:Tt||void 0,onExpansionChange:zr,onLoadMoreRows:ir,onSortChange:Tn})});if(rt.type==="pivotTable"&&wt)return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ex,{card:rt,data:wt.data,options:wt.options,frameId:t.id,sheetId:p||"",onMultipleInteractions:De,onAggregationChange:me=>{const je=cF(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)},onAggregationLabelChange:me=>{const je=ide(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)}})});if(rt.type==="aggregateTable")return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(NI,{card:rt,data:(Se==null?void 0:Se.records)||[],resultColumns:Se==null?void 0:Se.columns,columnKeyMap:Se==null?void 0:Se.columnKeyMap,groupByColumns:Se==null?void 0:Se.groupByColumns,pivotSchema:Se==null?void 0:Se.pivotSchema,paginationMetadata:st,onPaginationChange:Vt,onAggregationChange:me=>{const je=cF(me,e.config),He={...e,config:je},kt={...t,cards:t.cards.map(qt=>qt.id===e.id?He:qt)};p&&K(p,kt)},isLoading:Ve||Ee,frameId:t.id,sheetId:p||"",onMultipleInteractions:De})});if(rt.type==="text")return l.jsx(m.ScrollArea,{className:"h-full break-words",children:l.jsx("div",{className:"px-4 py-3",children:l.jsx(sb,{isLoading:ot.showCardSkeleton,card:rt,data:(Se==null?void 0:Se.records)||[],inferDynamicTextFromQuery:!0})})});if(m.isCustomVisualizationCard(rt)&&((sn=rt.customCardPreferences)!=null&&sn.url))return l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ki,{FallbackComponent:SU,children:l.jsx(Wj,{frame:t,card:rt})})});if(o&&o.length>0){const me=o.find(je=>je.cardId===rt.id);if(me&&me.content){const je=me.content;return l.jsx(je,{card:rt})}}const Yt=z?gt:Ie;return Yt?l.jsx(Bw,{cfg:Yt,onChartClick:qe,onDatapointClick:Le}):null}return z?l.jsx(eT,{card:D,records:ht,title:D.title,sql:D.sql,python:D.python,layoutMode:"fill",disablePointerEvents:g,fallback:Ye()}):Ye()}function jt(){if(o&&o.length>0){const Ye=o.find(Yt=>Yt.cardId===e.id);if(Ye&&Ye.footer){const Yt=Ye.footer;if(Yt)return l.jsx(Yt,{card:e})}}return null}function Ht(){var En;if(E&&k)return null;const Ye=t.cards.filter(en=>{var sn;return!((sn=en.tabTitle)!=null&&sn.endsWith("__Header"))&&(en.displayTab===!0||en.displayTab===void 0)}),Yt=f==null?void 0:f.controlInputRadius;return l.jsx(m.Tabs,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:en=>{const sn={...t,activeCardId:en};K(p,sn)},children:l.jsx(m.TabsList,{style:{borderRadius:f==null?void 0:f.controlInputRadius},className:"flex-end flex h-7 flex-wrap items-center border border-border bg-background p-0",children:(En=t.cards.filter(en=>{var sn;return!((sn=en.tabTitle)!=null&&sn.endsWith("__Header"))&&(en.displayTab===!0||en.displayTab===void 0)}))==null?void 0:En.map((en,sn)=>l.jsx(m.TabsTrigger,{className:m.cn("h-full items-center rounded-none px-2.5 text-[12px] data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":sn!==Ye.length-1}),style:{borderTopLeftRadius:sn===0?Yt:0,borderTopRightRadius:sn===Ye.length-1?Yt:0,borderBottomLeftRadius:sn===0?Yt:0,borderBottomRightRadius:sn===Ye.length-1?Yt:0},value:en.id,children:en.tabTitle||en.title},en.id))})})}function yn(){var Yt,En,en,sn,me;let Ye=t.cards.find(je=>je.type==="kpi"&&je.tabTitle===`${e.tabTitle}__Header`);return Ye||(Ye=t.cards.find(je=>je.type==="kpi"&&je.tabTitle==="All__Header")),Ye?l.jsx("div",{className:"flex items-end gap-2",children:l.jsx(Ttt,{renderFilterInfo:()=>{var je,He,kt,qt;return c("showFilterInfo")&&((He=(je=D.preferences)==null?void 0:je.displayOptions)==null?void 0:He.showFilterInfo)!==!1?l.jsx(lF,{cardId:D.id,cardFilters:(kt=D.config)==null?void 0:kt.filters,cardFilterCount:ek(((qt=D.config)==null?void 0:qt.filters)||null),inlineFilters:D.inlineFilters,inlineFilterValues:H,sheetId:p||"",resolvedPrimaryDateField:Ke}):null},card:Ye})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[c("showTitle")&&l.jsx(gb,{"data-rgl-drag-cancel":"",className:m.cn("text-[16px] font-semibold leading-tight tracking-[-0.01em]"),children:l.jsx(Ci,{value:D.title,onSave:()=>{},isEditable:!1,placeholder:"Add title",displayClassName:"text-[16px] font-semibold leading-tight tracking-[-0.01em]",inputClassName:"text-[16px] font-semibold leading-tight tracking-[-0.01em]"})}),c("showTitle")&&((Yt=D.info)==null?void 0:Yt.trim())&&l.jsx(cz,{card:D}),c("showRefreshIndicator")&&D.refreshInterval&&l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{className:"pr-1",children:l.jsx("div",{className:m.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":Ve||Ee})})}),l.jsx(m.TooltipContent,{side:"right",align:"center",children:l.jsx("p",{className:"text-xs",children:`Realtime (${D==null?void 0:D.refreshInterval})`})})]}),c("showFilterInfo")&&((en=(En=D.preferences)==null?void 0:En.displayOptions)==null?void 0:en.showFilterInfo)!==!1&&l.jsx(lF,{cardId:D.id,cardFilters:(sn=D.config)==null?void 0:sn.filters,cardFilterCount:ek(((me=D.config)==null?void 0:me.filters)||null),inlineFilters:D.inlineFilters,inlineFilterValues:H,sheetId:p||"",resolvedPrimaryDateField:Ke}),$e&&D.type!=="table"&&l.jsx(Xoe,{metadata:$e,variant:"compact"})]}),(()=>{var kt;const je=!B&&c("showDescription")&&!!((kt=D.description)!=null&&kt.trim()),He=B&&c("showBreadcrumbs");return!je&&!He?null:l.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[je&&l.jsx("div",{className:"text-[12px] leading-snug text-muted-foreground",children:l.jsx(Ci,{value:(D.description||"").trim(),onSave:()=>{},isEditable:!1,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})}),He&&l.jsx(Xtt,{cardId:D.id})]})})()]})}if(!e.id)return null;const _r=((fs=(To=D.preferences)==null?void 0:To.displayOptions)==null?void 0:fs.showChrome)??!0,Ps=((Df=(Yu=D.preferences)==null?void 0:Yu.displayOptions)==null?void 0:Df.allowScroll)??!0,Fs=(($a=(Ti=D.preferences)==null?void 0:Ti.displayOptions)==null?void 0:$a.showInlineFilterBar)??!0,Os=Jtt(D),ao=G$(D),Ls=_r?"px-5 pb-3":"px-3 pb-3",Xo=D.type==="table"||D.type==="pivotTable"||D.type==="aggregateTable"||D.type==="matrixTable"||D.type==="detailTable",lp=!gf(a.mode),Wu=jt(),li=_r?l.jsxs(l.Fragment,{children:[ee?l.jsx(IO,{className:m.cn("space-y-0 px-5 pb-3 pt-4",D.inlineFilters&&D.inlineFilters.length>0&&"pb-3",Xo&&"border-b border-border/60"),style:u.cardGutterStyle,children:l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[l.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:yn()}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("div",{children:R&&c("showFilters")&&l.jsxs("div",{style:{borderRadius:(Nc=(cp=f==null?void 0:f.chart)==null?void 0:cp.options)==null?void 0:Nc.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!m.isDateDataType(R.dataType)&&l.jsx(m.Label,{className:"my-1 shrink-0 px-3",children:l.jsx(Ci,{value:R.title||R.column,onSave:Ye=>L({...R,title:Ye}),isEditable:g,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),l.jsx(GI,{filter:R})]})}),t.cards.length>1&&c("showTabs")&&Ht(),lp&&l.jsx(Uut,{card:D,frame:t,exportData:D.type==="matrixTable"&&bt?{...Se,matrixResult:bt}:Se})]})]})}):l.jsx("div",{className:"h-8"}),(Os||Fs&&D.inlineFilters&&D.inlineFilters.length>0)&&l.jsx("div",{className:m.cn("px-5 pb-2 pt-2",Xo&&"border-b border-border/60"),style:u.cardGutterStyle,children:l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[Fs&&D.inlineFilters&&D.inlineFilters.length>0&&l.jsx(lde,{card:D,sheetId:p||""}),Os&&l.jsx(ont,{card:D})]})}),l.jsx(TO,{"data-role":"card-content",className:m.cn("relative flex min-h-0 grow flex-col",Xo?"p-0 [&_.data-table-scroll-container]:border-0 [&_.data-table-scroll-container]:bg-transparent":"px-5 pb-4 pt-2"),style:Xo?void 0:u.cardGutterStyle,children:dt()}),ao&&e.type!=="kpi"&&l.jsx("div",{className:Ls,style:u.cardGutterStyle,children:l.jsx(fF,{card:D,mode:"dashboard"})}),c("showFooter")&&Wu&&l.jsx(iZ,{children:Wu})]}):l.jsxs(l.Fragment,{children:[dt(),ao&&e.type!=="kpi"&&l.jsx("div",{className:Ls,style:u.cardGutterStyle,children:l.jsx(fF,{card:D,mode:"dashboard"})})]}),Ku=()=>_r&&Ps?"flex h-full flex-col":_r&&!Ps?"flex h-full flex-col overflow-hidden":!_r&&!Ps?"h-full":"h-full overflow-auto";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative h-full",children:[l.jsx("div",{className:m.cn(Ku(),{"animate-pulse":Ve||Ee}),children:nt()}),ot.showStaleDataOverlay&&l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/50",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})})]}),Rt.context&&l.jsx(Utt,{open:Rt.open,onOpenChange:Ye=>{an(Yt=>({...Yt,open:Ye}))},position:Rt.position,interactions:Rt.interactions,selectedConditions:Rt.context.conditions,drillHierarchies:(Mf=D.interactionConfig)==null?void 0:Mf.drillHierarchies,cardId:D.id,card:D,onSelectInteraction:Ye=>{Rt.context&&it(Ye,Rt.context),an({open:!1,position:null,interactions:[],context:null})}})]})}function phe({card:e,frame:t,cardToolbarAction:n}){var c,u;const r=tt.findCustomVisualConfigCard(t,e),{manifest:o}=kf(((c=r==null?void 0:r.customCardPreferences)==null?void 0:c.url)||""),s=v.useMemo(()=>{var d;return(d=o==null?void 0:o.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=r==null?void 0:r.customCardPreferences)==null?void 0:h.componentName)})},[o,(u=r==null?void 0:r.customCardPreferences)==null?void 0:u.componentName]),a=tt.resolveMultiInputType(r,s)==="multiple"&&r?r:e;return a.displayPreferences?l.jsx(tT,{displayPreferences:a.displayPreferences,children:l.jsx(zW,{card:e,frame:t,cardToolbarAction:n})}):l.jsx(zW,{card:e,frame:t,cardToolbarAction:n})}phe.displayName="DashboardCard";const ghe=oe.memo(phe);function Yut({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:o,isFetching:s,data:i,cfg:a,pagination:c,comparisonMetadata:u,effectiveCardConfig:d}=kw(e),f=m.useDashboardStore(k=>k.themeStyle);m.useDashboardStore(k=>k.selectedSheetId);const h=m.getVisualizationMode(e)==="dynamic",p=m.buildEffectiveFallbackCard(e,d),{data:g}=Nw(p),b=v.useMemo(()=>p.type!=="pivotTable"?{kind:"not_loaded"}:Zm({data:i,card:p}),[i,p]),x=Ym(p,b,u),y=v.useMemo(()=>(i==null?void 0:i.records)||[],[i==null?void 0:i.records]),C=Mb(p,y),w=p.type==="matrixTable"&&_w(i),N=cI({data:i,isLoading:o,isFetching:s}),S=v.useMemo(()=>{var k;if(!(!h||!((k=i==null?void 0:i.records)!=null&&k.length)||["kpi","text","table","detailTable","pivotTable","aggregateTable","matrixTable","custom"].includes(p.type)))return Db({card:p,data:i.records,cardType:p.type,queryConfig:p.queryConfig,customCfg:p.customCfg,preferences:p.preferences,topoJson:g,comparisonMetadata:u,numericPresentation:C,resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,temporalPresentation:m.INACTIVE_DYNAMIC_FALLBACK_TEMPORAL_PRESENTATION})},[i==null?void 0:i.records,i==null?void 0:i.columns,i==null?void 0:i.columnKeyMap,p,g,C,f,u,h]),j=h?S:a;if((o||s)&&!w)return l.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-2.5 p-12",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading visual…"})]});if(r)return l.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:l.jsx("p",{className:"text-[13px] font-medium text-destructive",children:"Failed to load visual"})});function I(){function k(){var T;return p.type==="kpi"?l.jsx(of,{card:p,data:(i==null?void 0:i.records)||[],isPending:o||s,comparisonMetadata:u}):p.type==="table"||p.type==="detailTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(Jd,{card:p,data:y,resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,totalsByColumnId:i==null?void 0:i.tableTotalsByColumnId,comparisonMetadata:u,isLoading:o||s,paginationMetadata:c})}):p.type==="matrixTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(SI,{card:p,result:i==null?void 0:i.matrixResult,isLoading:N})}):p.type==="pivotTable"&&x?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(ex,{card:p,data:x.data,options:x.options,onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):p.type==="aggregateTable"?l.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:l.jsx(NI,{card:p,data:(i==null?void 0:i.records)||[],resultColumns:i==null?void 0:i.columns,columnKeyMap:i==null?void 0:i.columnKeyMap,groupByColumns:i==null?void 0:i.groupByColumns,pivotSchema:i==null?void 0:i.pivotSchema,paginationMetadata:c,onAggregationChange:()=>{},isLoading:o||s})}):p.type==="text"?l.jsx(m.ScrollArea,{className:"overflow-y-auto break-words pr-2",children:l.jsx(sb,{isLoading:o||s,card:p,data:(i==null?void 0:i.records)||[]})}):m.isCustomVisualizationCard(p)&&((T=p.customCardPreferences)!=null&&T.url)?l.jsx(ki,{FallbackComponent:Xw,children:l.jsx(Wj,{frame:t,card:p})}):j?l.jsx(Bw,{cfg:j,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return m.getVisualizationMode(e)==="dynamic"?l.jsx(eT,{card:e,records:y,title:e.title,sql:e.sql,python:e.python,layoutMode:"fill",fallback:k()}):k()}return l.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsx("h3",{className:"text-[15px] font-semibold tracking-tight",children:e.title}),e.description&&l.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:e.description})]}),l.jsx("div",{className:"min-h-0 flex-1 p-4",children:I()})]})}function Zut(e){return l.jsx(ki,{FallbackComponent:Xw,children:l.jsx(Yut,{...e})})}function bhe({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:o,isError:s,error:i}=Qk(e,{enabled:!!e}),a=m.useInteractionStore(f=>f.setInteractionState),c=m.useInteractionStore(f=>f.resetInteractionState),u=v.useMemo(()=>{var f;return r?tt.parseFrameObject((r==null?void 0:r.frameObject)??((f=r==null?void 0:r.visual)==null?void 0:f.frameObject)):null},[r]),d=v.useMemo(()=>tt.getActiveFrameCard(u),[u]);return v.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const g={...m.createInitialInteractionState(),contextMode:n};a(d.id,g);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...m.createInitialInteractionState(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{c(d.id)}},[d,t,n,a,c]),o?l.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-2.5 p-12",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading visual…"})]}):s?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 p-12 text-center",children:[l.jsx("p",{className:"text-[13px] font-medium text-destructive",children:"Failed to load insight"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!u||!d?l.jsx("div",{className:"flex items-center justify-center p-12",children:l.jsx("p",{className:"text-[13px] text-muted-foreground",children:"This insight has no visual data to display"})}):l.jsx("div",{className:"h-full w-full",children:l.jsx(Zut,{card:d,frame:u,showTitle:!1})})}function Xut({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?l.jsxs(xi,{variant:"outline",className:"gap-1 whitespace-nowrap text-[11px] font-medium",children:[l.jsx(Vd,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((o,s)=>{var a,c;const i=((a=s.field)==null?void 0:a.label)||((c=s.field)==null?void 0:c.name)||"Unknown";return o[i]||(o[i]=[]),o[i].push(s),o},{});e.length;const r=Object.keys(n).length;return l.jsx(m.TooltipProvider,{children:l.jsxs(m.Tooltip,{delayDuration:200,children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs(xi,{variant:"outline",className:"cursor-help gap-1 whitespace-nowrap text-[11px] font-medium",children:[l.jsx(Vd,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),l.jsx(m.TooltipContent,{side:"bottom",align:"start",className:"max-w-md",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Applied filters"}),l.jsx("div",{className:"space-y-1",children:Object.entries(n).map(([o,s])=>l.jsxs("div",{className:"text-[12px]",children:[l.jsxs("span",{className:"font-medium",children:[o,":"]})," ",s.map((i,a)=>l.jsxs("span",{children:[ode(i),a<s.length-1?", ":""]},a))]},o))}),t&&l.jsx("div",{className:"border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground",children:Qut(t)})]})})]})})}function Qut(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 xhe(e,t={}){const{enabled:n=!0}=t,{data:r}=Qk(e,{enabled:n&&!!e});return v.useMemo(()=>{if(!r)return{title:"",description:void 0};const s=tt.getActiveCardFromVisualResource(r);return s?{title:s.title,description:s.description}:{title:"",description:void 0}},[r])}function Jut({cardId:e,children:t}){const n=m.useInteractionStore(s=>s.replacedCards[e]),r=m.useInteractionStore(s=>s.restoreCard),o=xhe((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?l.jsxs("div",{className:"flex h-full w-full flex-col",children:[l.jsxs("div",{className:"border-b border-border bg-muted/30",children:[l.jsx("div",{className:"flex items-baseline gap-2 px-3 pb-1.5 pt-3",children:o.title&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"truncate text-[15px] font-semibold tracking-tight",children:o.title}),o.description&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-muted-foreground/70",children:"·"}),l.jsx("span",{className:"truncate text-[12px] text-muted-foreground",children:o.description})]})]})}),l.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-2",children:[l.jsxs(m.Button,{variant:"ghost",size:"xs",onClick:()=>r(e),className:"shrink-0",children:[l.jsx(Xv,{className:"h-3.5 w-3.5"}),"Back"]}),l.jsx(Xut,{filters:n.filters,contextMode:n.contextMode})]})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(bhe,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):l.jsx(l.Fragment,{children:t})}function edt(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function yhe({frame:e,footer:t,className:n,style:r,...o}){var E,D;const s=v.useRef(null),[i,a]=v.useState(!1),c=m.useDashboardStore(M=>M.themeStyle),u=Ou(),{customCards:d}=Et(),f=m.useDashboardStore(M=>M.isVisualEditing),h=m.useDashboardStore(M=>M.selectedFrameId),p=m.useDashboardStore(M=>M.isDashboardEditing),{setSelectedFrameId:g}=m.useDashboardActions(),{clearSelectedVisual:b}=Rm(),{setSelectedConnectionId:x,setSelectedDatabaseName:y,setSelectedSchemaName:C,setSelectedTableName:w,setCard:N}=m.useEditorActions();v.useEffect(()=>{if(h!==e.id||!p||f)return;const M=s.current;if(!M)return;const P=edt(M),A=()=>P?P.scrollHeight:document.documentElement.scrollHeight,z=()=>P?P.scrollTop:window.scrollY,O=()=>P?P.getBoundingClientRect():{top:0,bottom:window.innerHeight},B=()=>{const K=M.getBoundingClientRect(),Y=O(),V=1;return K.height>=Y.bottom-Y.top?K.top<=Y.top+V&&K.bottom>=Y.bottom-V:K.top>=Y.top-V&&K.bottom<=Y.bottom+V},H=1200,R=3,q=2e3;let $=0,F=0,U=Number.NaN;const G=performance.now(),Q=K=>{M.scrollIntoView({behavior:K,block:"center",inline:"nearest"})},W=()=>{let K=0,Y=Number.NaN;const V=performance.now(),Z=()=>{const X=z();K=X===Y?K+1:0,Y=X;const te=K>=R,re=performance.now()-V>=q;if(!te&&!re){$=requestAnimationFrame(Z);return}B()||Q("auto")};$=requestAnimationFrame(Z)},L=()=>{const K=A();F=K===U?F+1:0,U=K;const Y=performance.now()-G>=H;if(F<R&&!Y){$=requestAnimationFrame(L);return}Q("smooth"),W()};return $=requestAnimationFrame(L),()=>cancelAnimationFrame($)},[h,e.id,p,f]);const S=e.cards.find(M=>M.id===e.activeCardId),j=d==null?void 0:d.some(M=>M.cardId===(S==null?void 0:S.id)&&M.replaceDefault===!0&&!!M.content),I=p||((D=(E=S==null?void 0:S.preferences)==null?void 0:E.displayOptions)==null?void 0:D.showCardToolbar)!==!1,k=(S==null?void 0:S.type)==="kpi"&&!m.isDynamicVisualizationMode(S)&&!j,T=I&&k?l.jsx(aF,{frame:e,isHovered:i,variant:"inline-kpi"}):void 0;function _(M){M.stopPropagation(),g(e.id),b(),S&&N(S),S!=null&&S.connectionId&&x(S==null?void 0:S.connectionId),S!=null&&S.lastSelectedDatabase&&y(S==null?void 0:S.lastSelectedDatabase),S!=null&&S.lastSelectedSchema&&C(S==null?void 0:S.lastSelectedSchema),S!=null&&S.lastSelectedTable&&w(S==null?void 0:S.lastSelectedTable)}return l.jsx(ki,{FallbackComponent:JI,children:l.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":S==null?void 0:S.id,onClick:_,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{borderRadius:c==null?void 0:c.cardBorderRadius,...u.cardFrameStyle,...r},className:m.cn("relative flex h-full flex-col overflow-clip rounded-sm border bg-card text-card-foreground shadow-sm focus-visible:outline-none",{"border-dashed border-foreground/50":h===e.id&&p},c==null?void 0:c.dashboardCard,n,"semaphor-card-frame"),...o,children:[I&&!k&&l.jsx(aF,{frame:e,isHovered:i}),S&&l.jsx(Jut,{cardId:S.id,children:l.jsx(ghe,{card:S,frame:e,cardToolbarAction:T},S.id)})]})})}yhe.displayName="DashboardFrame";const tdt=v.memo(yhe);function BW(e){return e.type==="dataset"&&"domainId"in e}function ur(e,t){const n=BW(e),r=BW(t);if(n||r)return!n||!r||e.domainId!==t.domainId?!1:e.id&&t.id?e.id===t.id:e.name===t.name;if("id"in e&&"id"in t&&e.id&&t.id)return e.id===t.id;const o=e.database||"",s=t.database||"",i=e.schema||"",a=t.schema||"",c=e.connectionType||"",u=t.connectionType||"",d=e.dbObjectType||"",f=t.dbObjectType||"",h=d.length>0&&f.length>0;return e.type===t.type&&e.connectionId===t.connectionId&&c===u&&o===s&&i===a&&e.name===t.name&&(!h||d===f)}function rl(e){return e||[]}function Bz(e){return e.reduce((t,n)=>(t.some(r=>ur(r,n))||t.push(n),t),[])}function ndt(e,t){var n;if((n=e.sheets)!=null&&n.length)return t&&e.sheets.find(r=>r.id===t)||e.sheets[0]}function vhe(e,t){const n=ndt(e,t);if(!n)return[];const r=(n.frames||[]).flatMap(s=>{var a;const i=tt.getActiveFrameCard(s);return rl((a=i==null?void 0:i.dataSource)==null?void 0:a.selectedEntities)}),o=(n.cards||[]).flatMap(s=>{var i;return rl((i=s==null?void 0:s.dataSource)==null?void 0:i.selectedEntities)});return Bz([...r,...o])}function rdt(e,t){const n=(e||"").trim();return n.length>0?`dashboard:${n}`:t||"dashboard:draft"}function odt(e){const t=(e||"").trim();return t.length>0?`dashboard:${t}`:null}function whe({overrides:e,dashboardId:t,draftScopeKey:n}){const r=odt(t),o=rdt(t,n),s=r!==null?e[r]:void 0,i=e[o];return{selectedEntities:s!==void 0?s:i,hasManualOverride:s!==void 0||i!==void 0,activeScopeKey:o}}function sdt(e){return e?e.mode==="auto"||e.mode==="fixed"?e.mode:"fixed":"auto"}function idt({currentAIContext:e,manualSelectedEntities:t,hasManualOverride:n,dashboardAIContext:r,derivedSelectedSheetEntities:o}){return{...e,selectedEntities:Che({manualSelectedEntities:t,hasManualOverride:n,dashboardAIContext:r,derivedSelectedSheetEntities:o})}}function Che({manualSelectedEntities:e,hasManualOverride:t,dashboardAIContext:n,derivedSelectedSheetEntities:r}){return t?rl(e):sdt(n)==="fixed"?rl(n==null?void 0:n.selectedEntities):rl(r)}function VW({manualSelectedEntities:e,dashboardAIContext:t,derivedSelectedSheetEntities:n}){return Bz([...rl(e),...rl(t==null?void 0:t.selectedEntities),...rl(n)])}function fT(e){const t=m.useCurrentAIContext(),n=m.useDashboardStore(A=>A.dashboard),r=m.useDashboardStore(A=>A.selectedSheetId),o=m.useDashboardStore(A=>A.dashboardAssistantDraftScopeKey),s=m.useDashboardStore(A=>A.dashboard.aiContext),i=m.useDashboardStore(A=>A.dashboard.id||null),a=m.useAIInteractionStore(A=>A.dashboardEntitySelectionOverrides),c=m.useAIInteractionStore(A=>A.hasEditorEntitySelectionOverride),u=v.useMemo(()=>whe({overrides:a,dashboardId:i,draftScopeKey:o}),[o,a,i]),d=u==null?void 0:u.selectedEntities,f=!!(u!=null&&u.hasManualOverride),{setCurrentAIContext:h,setHasEditorEntitySelectionOverride:p,setDashboardEntitySelectionOverride:g,clearDashboardEntitySelectionOverride:b}=m.useAIActions(),x=rl(t.selectedEntities),y=v.useMemo(()=>vhe(n,r),[n,r]),C=v.useMemo(()=>Che({manualSelectedEntities:d,hasManualOverride:f,dashboardAIContext:s,derivedSelectedSheetEntities:y}),[d,f,s,y]),w=e==="dashboard"?C:e==="editor"?x.length>0?x:c?[]:C:x,N=e==="dashboard"?VW({manualSelectedEntities:f?d:[],dashboardAIContext:s,derivedSelectedSheetEntities:y}):e==="editor"?VW({manualSelectedEntities:x.length>0?x:C,dashboardAIContext:s,derivedSelectedSheetEntities:y}):rl(s==null?void 0:s.selectedEntities),S=v.useCallback(A=>{if(e==="dashboard"&&(u!=null&&u.activeScopeKey)){g(u.activeScopeKey,A);return}e==="editor"&&p(!0),h({...t,selectedEntities:A})},[e,t,u,p,h,g]),j=v.useCallback(()=>{e==="dashboard"&&(u!=null&&u.activeScopeKey)&&b(u.activeScopeKey)},[e,b,u]),I=v.useCallback(A=>w.some(z=>ur(z,A)),[w]),k=v.useCallback(A=>{if(w.some(O=>ur(O,A))){S(w.filter(O=>!ur(O,A)));return}S([...w,A])},[w,S]),T=v.useCallback(A=>{w.some(z=>ur(z,A))||S([...w,A])},[w,S]),_=v.useCallback(A=>{S(w.filter(z=>!ur(z,A)))},[w,S]),E=v.useCallback(A=>{A.length!==0&&S(w.filter(z=>!A.some(O=>ur(z,O))))},[w,S]),D=v.useCallback(()=>{S(N)},[N,S]),M=v.useCallback(()=>{S([])},[S]),P=v.useCallback(()=>{if(e!=="dashboard"){if(e==="editor"&&!c&&x.length===0&&w.length>0){S(w);return}e!=="editor"&&w.length===0&&S(N)}},[e,N,c,x.length,w,S]);return{selectedEntities:w,availableEntities:N,setSelectedEntities:S,applyDashboardDefaultEntities:j,hasDashboardEntitySelectionOverride:f,isEntitySelected:I,toggleEntity:k,addEntityIfMissing:T,removeEntity:_,removeEntities:E,selectAllEntities:D,clearAllEntities:M,syncWithGlobalContext:P}}function She(){var N;const e=m.useDashboardStore(S=>S.isDashboardEditing),t=m.useDashboardStore(S=>S.selectedSheetId),n=m.useDashboardStore(S=>S.dashboard),r=n==null?void 0:n.sheets,o=r==null?void 0:r.find(S=>S.id===t),s=m.useEditorStore(S=>S.card),i=m.useEditorStore(S=>S.selectedConnectionId),{selectedEntities:a}=fT("dashboard"),c=lz(),{addFrame:u,setSelectedFrameId:d,setIsVisualEditing:f}=m.useDashboardActions(),{setFrame:h,setCard:p,setActiveTabCardId:g,clearModeDrafts:b,initializeModeDrafts:x,clearEditorContext:y}=m.useEditorActions();function C(){const S=s==null?void 0:s.dataSource;if(S)return S;const j=a[0],I=j==null?void 0:j.type;if(j)return{connectionId:j.connectionId,connectionType:j.connectionType,type:I,selectedEntities:[j]}}async function w(S){const j=(S==null?void 0:S.sheetId)||t,I=r==null?void 0:r.find(D=>D.id===j);if(!I){console.warn("Cannot add frame: No sheet found");return}if(m.isDocumentSheet(I)){console.warn("Cannot add frame: Document sheets do not accept dashboard frames");return}if(!(!I.frames||I.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const T=C(),_={id:ut.v4(),title:"Title",type:"bar",connectionId:i||"",dataSource:T,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},E={id:ut.v4(),cards:[_],activeCardId:_.id};if(j){try{await c(j,E)}catch(D){console.warn("Adding new frame without refreshed semantic metadata:",D),u(j,E)}d(E.id)}return S!=null&&S.openVisualEditor&&(b(),y(),h(E),p(_),g(_.id),f(!0),x(_)),E}return{handleAddNewFrame:w,canAddFrame:e||!((N=o==null?void 0:o.frames)!=null&&N.length)}}function adt({sheetId:e}){const{handleAddNewFrame:t}=She(),n=m.useDashboardStore(s=>s.themeStyle),r=Ou(),o=()=>{t({openVisualEditor:!0,sheetId:e})};return l.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",style:r.gridContainerPadding?{padding:r.gridContainerPadding[0]}:void 0,children:l.jsxs("button",{onClick:o,style:{borderRadius:n==null?void 0:n.cardBorderRadius,...r.cardFrameStyle},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-card text-card-foreground transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[l.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:l.jsx(Mr,{className:"h-6 w-6 text-primary"})}),l.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}const ldt={string:m.Type,number:bb,date:Ka,boolean:Kve,json:jve,geo:Ave,calculated:fZ},HW={string:"text",number:"number",date:"date",boolean:"boolean",json:"json",geo:"geo",calculated:"calculated"};function cdt(e){const t=(e||"").toLowerCase();return t==="calculated"?"calculated":m.getDataType(t)}function oC({dataType:e,calculated:t,className:n}){const r=cdt(e),o=ldt[r]??m.Type,s=t?`calculated · ${HW[r]}`:HW[r];return l.jsxs("span",{"aria-hidden":"true",title:s,className:m.cn("relative inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",n),children:[l.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.75}),t&&l.jsx("span",{className:"absolute -bottom-[3px] -right-[3px] rounded-full bg-background px-[1px] font-mono text-[9px] font-semibold italic leading-none text-foreground/70",children:"ƒ"})]})}function hk(e){const t=(e||"").toLowerCase()==="calculated";return l.jsx(oC,{dataType:e,calculated:t})}const qW="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",UW="h-8 w-full justify-start gap-2 px-2.5 text-[13px] font-normal";function udt({value:e,onChange:t,metrics:n,attributes:r}){const o=(s,i)=>(e==null?void 0:e.field.id)===s.id&&(e==null?void 0:e.type)===i;return l.jsx(m.TooltipProvider,{children:l.jsxs("div",{className:"space-y-4",children:[n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:qW,children:"Value of metric"}),l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Info,{className:"h-3.5 w-3.5 text-muted-foreground"})}),l.jsxs(m.TooltipContent,{className:"max-w-xs",children:[l.jsx("p",{className:"mb-1 text-[12px] font-medium",children:"Captures intersection of all dimensions"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>{const i=o(s,"metric");return l.jsxs(m.Button,{variant:i?"default":"outline",size:"sm",className:m.cn(UW,i&&"font-medium"),onClick:()=>t({type:"metric",field:s}),children:[hk(s.dataType),l.jsx("span",{className:"truncate",children:s.label}),i&&l.jsx(m.Check,{className:"ml-auto h-3.5 w-3.5"})]},s.id)})})]}),r.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:qW,children:"Value of attribute"}),l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Info,{className:"h-3.5 w-3.5 text-muted-foreground"})}),l.jsxs(m.TooltipContent,{className:"max-w-xs",children:[l.jsx("p",{className:"mb-1 text-[12px] font-medium",children:"Captures only this dimension"}),l.jsx("p",{className:"text-[12px] 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)`})]})]})]}),l.jsx("div",{className:"space-y-1",children:r.map(s=>{const i=o(s,"attribute");return l.jsxs(m.Button,{variant:i?"default":"outline",size:"sm",className:m.cn(UW,i&&"font-medium"),onClick:()=>t({type:"attribute",field:s}),children:[hk(s.dataType),l.jsx("span",{className:"truncate",children:s.label}),i&&l.jsx(m.Check,{className:"ml-auto h-3.5 w-3.5"})]},s.id)})})]}),n.length===0&&r.length===0&&l.jsx("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:"No metrics or attributes available in this chart"})]})})}const vv="h-auto py-1.5";function Qs({label:e,description:t,children:n,className:r}){return l.jsxs("div",{className:m.cn("space-y-2",r),children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(m.Label,{className:"text-[13px] font-medium",children:e}),t&&l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:t})]}),n]})}const WW=[{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 ddt({value:e,onChange:t}){const n=WW.find(r=>r.value===e);return l.jsx("div",{className:"space-y-2",children:l.jsxs(m.Select,{value:e,onValueChange:t,children:[l.jsx(m.SelectTrigger,{size:"sm",className:"w-full",children:l.jsx(m.SelectValue,{placeholder:"Choose action…",children:n&&l.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=nk(n.value);return l.jsx(r,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})})(),l.jsx("span",{children:n.label})]})})}),l.jsx(m.SelectContent,{children:WW.map(r=>{const o=nk(r.value);return l.jsx(m.SelectItem,{value:r.value,className:vv,children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(o,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx("span",{className:"text-[13px] font-medium leading-[1.35]",children:r.label}),l.jsx("span",{className:"text-[12px] leading-[1.35] text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}const fdt=[{value:"all-cards",label:"All cards",description:"Apply filter to all cards in the dashboard"},{value:"specific-cards",label:"Only specific cards",description:"Apply filter to selected cards only",picker:{label:"Cards to filter",description:"Select which cards should receive the filter"}},{value:"all-except-specific",label:"All cards except specific ones",description:"Apply filter to all cards, excluding selected ones",picker:{label:"Cards to exclude",description:"Select which cards should be excluded from filtering"}}];function hdt({interaction:e,onUpdate:t}){const[n,r]=v.useState(""),o=m.useCurrentSheetActiveCards(),s=v.useId(),i=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",a=f=>{const h={};switch(f){case"all-cards":h.applyToCardIds=void 0,h.excludeCardIds=void 0;break;case"specific-cards":h.applyToCardIds=[],h.excludeCardIds=void 0;break;case"all-except-specific":h.applyToCardIds=void 0,h.excludeCardIds=[];break}t({...e,...h})},c=(f,h)=>{if(h==="specific-cards"){const p=e.applyToCardIds||[],g=p.includes(f)?p.filter(b=>b!==f):[...p,f];t({...e,applyToCardIds:g})}else if(h==="all-except-specific"){const p=e.excludeCardIds||[],g=p.includes(f)?p.filter(b=>b!==f):[...p,f];t({...e,excludeCardIds:g})}},u=v.useMemo(()=>{if(!n.trim())return o;const f=n.toLowerCase();return o==null?void 0:o.filter(h=>{var p;return(p=h==null?void 0:h.title)==null?void 0:p.toLowerCase().includes(f)})},[n,o]),d=i();return l.jsxs("div",{className:"space-y-4",children:[l.jsx(Qs,{label:"Filter scope",description:"Choose which cards should receive the filter",children:l.jsx(yu,{value:d,onValueChange:f=>a(f),className:"space-y-0.5",children:fdt.map(f=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-start gap-2.5 rounded-control px-2 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Xs,{value:f.value,id:`${s}-${f.value}`,className:"mt-0.5"}),l.jsxs("div",{className:"flex-1 space-y-0.5",children:[l.jsx(m.Label,{htmlFor:`${s}-${f.value}`,className:"cursor-pointer text-[13px] font-medium",children:f.label}),l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:f.description})]})]}),d===f.value&&f.picker&&l.jsxs("div",{className:"ml-[26px] mt-2 space-y-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(m.Label,{className:"text-[13px] font-medium",children:f.picker.label}),l.jsx("p",{className:"text-[12px] leading-[1.5] text-muted-foreground",children:f.picker.description})]}),l.jsx(m.Input,{size:"sm",placeholder:"Search cards…",value:n,onChange:h=>r(h.target.value)}),l.jsx("div",{className:"max-h-40 overflow-y-auto rounded-card border border-border/60",children:u&&u.length>0?u.map(h=>{const g=((f.value==="specific-cards"?e.applyToCardIds:e.excludeCardIds)||[]).includes(h.id),b=`${s}-${f.value}-${h.id}`;return l.jsxs("div",{className:"flex items-start gap-2.5 px-2.5 py-2 transition-colors odd:bg-muted/30 hover:bg-muted/50",children:[l.jsx(In,{id:b,checked:g,onCheckedChange:()=>c(h.id,f.value),className:"mt-0.5"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx(m.Label,{htmlFor:b,className:"cursor-pointer text-[13px] font-normal",children:h.title}),h.description&&l.jsx("p",{className:"mt-0.5 line-clamp-1 text-[12px] text-muted-foreground",children:h.description})]})]},h.id)}):l.jsx("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]},f.value))})}),l.jsx(Qs,{label:"Menu label",description:"How this interaction appears when multiple actions are available",children:l.jsx(m.Input,{size:"sm",value:e.label||"",onChange:f=>t({...e,label:f.target.value}),placeholder:sp(e.mode)})})]})}function mdt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const hT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ox(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Vz(e){return"nodeType"in e}function ii(e){var t,n;return e?ox(e)?e:Vz(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Hz(e){const{Document:t}=ii(e);return e instanceof t}function sC(e){return ox(e)?!1:e instanceof ii(e).HTMLElement}function Nhe(e){return e instanceof ii(e).SVGElement}function sx(e){return e?ox(e)?e.document:Vz(e)?Hz(e)?e:sC(e)||Nhe(e)?e.ownerDocument:document:document:document}const ul=hT?v.useLayoutEffect:v.useEffect;function mT(e){const t=v.useRef(e);return ul(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function pdt(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function wv(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ul(()=>{n.current!==e&&(n.current=e)},t),n}function iC(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function mk(e){const t=mT(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function pk(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let o2={};function aC(e,t){return v.useMemo(()=>{if(t)return t;const n=o2[e]==null?0:o2[e]+1;return o2[e]=n,e+"-"+n},[e,t])}function jhe(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,u]of a){const d=s[c];d!=null&&(s[c]=d+e*u)}return s},{...t})}}const xg=jhe(1),Cv=jhe(-1);function gdt(e){return"clientX"in e&&"clientY"in e}function pT(e){if(!e)return!1;const{KeyboardEvent:t}=ii(e.target);return t&&e instanceof t}function bdt(e){if(!e)return!1;const{TouchEvent:t}=ii(e.target);return t&&e instanceof t}function gk(e){if(bdt(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 gdt(e)?{x:e.clientX,y:e.clientY}:null}const Xi=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[Xi.Translate.toString(e),Xi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),KW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xdt(e){return e.matches(KW)?e:e.querySelector(KW)}const ydt={display:"none"};function vdt(e){let{id:t,value:n}=e;return v.createElement("div",{id:t,style:ydt},n)}function wdt(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={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 v.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Cdt(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const khe=v.createContext(null);function Sdt(e){const t=v.useContext(khe);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ndt(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const jdt={draggable:`
1302
1302
  To pick up a draggable item, press the space bar.
1303
1303
  While dragging, use the arrow keys to move the item.
1304
1304
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -1401,4 +1401,4 @@ Defaulting to \`null\`.`}var cxe=sxe,ekt=axe;const K4=oe.forwardRef(({className:
1401
1401
  More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const c=s?` (code: ${s})`:"",u=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1402
1402
 
1403
1403
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function eB({errorMessage:e}){return l.jsxs("div",{className:"flex items-start gap-2 rounded-control border border-red-300 bg-red-50/60 p-2 text-[12px] text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:[l.jsx(Fo,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"whitespace-pre-wrap break-words leading-[1.55]",children:y_t(e)})]})}function v_t({error:e,resetErrorBoundary:t}){return l.jsxs("div",{className:"my-3 space-y-2 rounded-control border border-border/60 bg-muted/20 p-2.5",children:[l.jsx(eB,{errorMessage:e==null?void 0:e.message}),l.jsx("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:t,children:"Try again"})]})}function w_t({text:e,files:t}){return l.jsxs(Mxe,{who:"You",children:[e&&l.jsx("div",{className:"whitespace-pre-line text-[13px] leading-[1.55] text-foreground",children:e}),t&&t.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 pt-0.5",children:t.map(n=>l.jsx(nkt,{file:n},n.id))})]})}function C_t({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(Nkt,{children:JSON.stringify(o,null,2)})]})]})}function Rxe(e,t){return!e||e.role!=="assistant"?!1:(e.parts??[]).some(r=>{if(!r)return!1;switch(r.type){case"text":return typeof r.text=="string"&&r.text.trim().length>0;case"reasoning":return typeof r.text=="string"&&r.text.trim().length>0||r.state==="streaming";case"error":return!0;default:return typeof r.type=="string"&&(r.type.startsWith("tool-")||r.type==="dynamic-tool")?J4(r,t):!1}})}function UG(){return l.jsx("span",{className:"relative grid h-2 w-2 shrink-0 place-items-center",children:l.jsx("span",{className:"absolute inset-0 animate-pulse rounded-full bg-muted-foreground/70"})})}function S_t({status:e,errorMessage:t,activeToolText:n}){return n?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(UG,{}),l.jsx("span",{children:n})]}):e==="submitted"||e==="streaming"?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(UG,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(eB,{errorMessage:t}):null}function N_t(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(o=>o.type==="text"&&typeof o.text=="string"&&o.text.trim().length>0))}))==null?void 0:t.id:void 0}function j_t({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,C,w,N;const u=N_t(n),d=e.id===u;if(e.role==="user"){const S=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],j=((C=e.parts)==null?void 0:C.filter(T=>T.type==="file"))||[],I=S.map(T=>T.text).join(`
1404
- `).trim(),k=j.map((T,_)=>{var M,P;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(w_t,{text:I||void 0,files:k.length>0?k:void 0})}const f=((w=e.parts)==null?void 0:w.filter(S=>S.type==="reasoning"))||[],h=f.length>0,p=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Nu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(ju,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(ku,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(OG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=b_t(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(OG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:M,value:P},A)=>l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(C_t,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(eB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&J4(S,r)?l.jsx(ki,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(v_t,{error:T,resetErrorBoundary:_}),children:l.jsx(f_t,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?Rxe(e,r)?l.jsxs(Mxe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const k_t=8,__t=24,I_t=20;function T_t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Axe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),C=v.useRef(!1),w=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(__t);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=Rxe(D,t),P=T_t(a,c,u,M),A=Iw({count:e.length,getScrollElement:()=>b.current,estimateSize:H=>{const R=e[H];return(R==null?void 0:R.role)==="user"?88:180},getItemKey:H=>{const R=e[H];return(R==null?void 0:R.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:k_t,overscan:6,gap:20,paddingEnd:P?_+I_t:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const R=H.isAtEnd();I(q=>q===R?q:R),R&&T(0)}}),z=v.useCallback((H="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,A.scrollToEnd({behavior:H})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{C.current||(C.current=!0,z("auto"))},[z]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,z("auto"))},[e.length,g,z]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!A.isAtEnd()&&T(R=>R+e.length-H),e.length===0&&(T(0),I(!0),C.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const H=x.current;if(!H||!P)return;const R=()=>{const $=Math.ceil(H.getBoundingClientRect().height);$>0&&E(F=>F===$?F:$)};if(R(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(R);return q.observe(H),()=>q.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:B},children:[O.map(H=>{const R=e[H.index];return R?l.jsx("div",{ref:A.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(j_t,{message:R,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),P&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(S_t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>z("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(rs,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function E_t(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const D_t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function M_t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,C]=v.useState(0),w=n??b,{isLocalDev:N,isConsoleMode:S}=$m(),j=N||S||a,I=v.useRef(null);m.useDashboardStore(ue=>ue.dashboard.aiScopeTables),m.useDashboardStore(ue=>ue.isDashboardEditing);const k=m.useDashboardStore(ue=>ue.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=m.useDashboardActions(),D=lz(),{clearAssistantMessageContexts:M}=m.useAIActions(),{clearQueue:P}=m.useQueueActions(),{clearFileAttachments:A,getFileAttachments:z}=m.useFileActions(),O=m.useFileAttachments("dashboard"),B=m.useEditorStore(ue=>ue.card.dataSource),{assistantProfile:H}=Qbe(),R=m.useDashboardStore(ue=>ue.handleOpenAssistantProfile),{selectedEntities:q,applyDashboardDefaultEntities:$}=fT("dashboard"),{sendMessage:F,isLoading:U,messages:G,setMessages:Q,status:W,stop:L,errorMessage:K,clearError:Y}=Pjt({dynamicVisualMode:f}),V=v.useCallback(()=>{C(ue=>ue+1)},[]),Z=v.useCallback(ue=>{r==null||r(ue),n===void 0&&x(ue)},[n,r]),X=v.useCallback(()=>{Z(!w)},[w,Z]);v.useEffect(()=>{if(!w)return;function ue(ge){ge.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[w,Z]);const[te,re]=v.useState(""),ie=ue=>{re(ue.target.value)};async function se({sql:ue,cardTitle:ge,connectionId:_e,cardType:Te,python:Ce,cardConfig:Re,dataSource:Ve,customVisualPreferences:Ee,visualizationMode:We,dynamicCardPreferences:Ie}){if(!k)return;const we=We==="dynamic",de=ut.hasValidCardConfig(Re),Se=_e||(Ve==null?void 0:Ve.connectionId)||"",Le=Ve?{...Ve,connectionId:Se||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:Se?{connectionId:Se,connectionType:"",mode:"database",selectedEntities:[]}:mb,st=!(de&&(!we||(Ie==null?void 0:Ie.provenance)==="card-config"||(Ie==null?void 0:Ie.provenance)==="query_spec")),$e=st?E_t(ue):"",Ke=st?Ce:"",at={id:ut.v4(),title:ge||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...we&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:$e,python:Ke,dataSource:Le,config:Re,connectionId:Se,visualizationMode:We,dynamicCardPreferences:Ie,customCardPreferences:Ee?{url:Ee.url,componentName:Ee.componentName,pluginChartType:Ee.pluginChartType,settings:Ee.settings,type:"component"}:void 0},ct={id:ut.v4(),cards:[at],activeCardId:at.id};try{await D(k,ct,"end"),E(!0),_(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),et.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const le=ue=>{ue.preventDefault();const ge=te.trim();if(!ge&&O.length===0)return;const _e=[];ge&&_e.push({type:"text",text:ge}),O.forEach(Te=>{Te.data&&_e.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),F({role:"user",parts:_e}),re(""),A("dashboard"),V()};v.useEffect(()=>{var ue;e&&((ue=I.current)==null||ue.focus())},[e]),pxe({assistantType:"dashboard",status:W,isLoading:U,sendMessage:F});const{hasActiveTools:ae,activeToolText:xe}=gxe(G);function fe(ue){const ge={role:"user",parts:[{type:"text",text:ue.title+" "+ue.subtitle}]};F(ge),V()}function be(ue){F({role:"user",parts:[{type:"text",text:ue}]}),V()}function pe(ue){F({role:"user",parts:[{type:"text",text:ue}]}),V()}const ye=v.useCallback(async()=>{const ue=JSON.stringify(G??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ue),et.success("Conversation copied")}catch(ge){console.error("Failed to copy conversation",ge),et.error("Unable to copy conversation")}},[G]),ce=(te==null?void 0:te.length)===0&&(G==null?void 0:G.filter(ue=>ue.role==="user").length)===0;function J(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ne(){return l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(su,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Pm,{className:"size-3.5"})})}),l.jsxs(mo,{align:"end",children:[l.jsx(Ca,{children:"Options"}),l.jsx(Ia,{}),l.jsx(sd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(sd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(sd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ia,{}),l.jsx(Ca,{children:"Dynamic Visuals"}),l.jsx(sd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(sd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(sd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ee=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[J(),R&&l.jsxs("button",{type:"button",onClick:R,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ne(),j&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ye,children:"Copy Conversation"}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:X,children:w?l.jsx(Ft.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const ue=G.filter(ge=>ge.role==="assistant").map(ge=>ge.id).filter(ge=>!!ge);Q([]),P("dashboard"),Y(),M(ue)},children:l.jsx(LO,{className:"h-3.5 w-3.5"})}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Me.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Axe,{messages:G,showTools:a,showSystemMessage:u,onAddToDashboard:se,onQuickReply:pe,disableQuickReplies:U,status:W,errorMessage:K,activeToolText:U&&ae?xe:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&ce&&l.jsx(Tge,{onClick:fe,placeholders:D_t}),ce&&H&&l.jsx(Jbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:be}),l.jsx(mxe,{assistantType:"dashboard"}),l.jsx(Q4,{ref:I,setInput:re,stop:L,input:te,handleInputChange:ie,handleSubmit:ue=>{le(ue)},isLoading:U,status:W,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(X4,{incomingSelectedEntities:q,open:p,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ue=>$()})]});return w&&o?vr.createPortal(l.jsx(tx,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ee})}),o):ee}function R_t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),o=tde(),s=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(A_t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),et.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=P_t(p);if(g!=null&&g.id){const b=Que(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),et.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function A_t(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function P_t(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function F_t(e,t){switch(e.interactionMode){case"drillToDetail":O_t(e,t);break;case"drillThrough":L_t(e,t);break;case"drillToURL":$_t(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function O_t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function L_t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function $_t(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function z_t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(No,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ade,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(bhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function B_t(){const e=m.useInteractionStore(N=>N.interactionStates),t=m.useInteractionStore(N=>N.setInteractionState),n=m.useInteractionStore(N=>N.clearLastInteractionEvent),r=m.useInteractionStore(N=>N.replaceCardWithInsight),o=m.useInteractionStore(N=>N.setPendingDrillThrough),s=m.useInteractionStore(N=>N.pendingDrillThrough),i=m.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Rm(),d=m.useDashboardStore(N=>N.dashboard),f=m.useDashboardStore(N=>N.filterValues),{data:h,isLoading:p}=XX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xhe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),C=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...m.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(m.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{F_t(j,C)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,C]),v.useEffect(()=>{if(!(!s||!h||p))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(z_t,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function V_t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=H_t(uz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function H_t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function q_t(e){return e?`Back to ${e}`:"Back"}function U_t(){var y,C,w,N,S;const e=m.useInteractionStore(j=>j.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(j=>j.actions.goBackFromDrill),n=m.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Rm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(w=(C=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:C.filterGroups)==null?void 0:w[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};V_t(f);const x=q_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(xi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Me.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(Xv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function W_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function K_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:p,transform:g,transition:b,isDragging:x}=cx({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Xi.Translate.toString(g),transition:b,opacity:x?.5:1,zIndex:x?10:void 0};return l.jsx("div",{ref:p,style:y,...f,children:l.jsx(H$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const WG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",G_t=[];function Pxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(W=>{var L;return(L=W.dashboard)==null?void 0:L.sheets}),u=m.useDashboardStore(W=>W.dashboard),d=m.useDashboardStore(W=>W.dashboardInputValues),f=m.useDashboardStore(W=>W.filterValues),h=m.useDashboardStore(W=>W.controlValues),p=m.useDashboardStore(W=>W.inlineFilterValuesMap),g=m.useDashboardStore(W=>W.cardControlValuesMap),b=m.useDashboardStore(W=>W.selectedSheetId),x=m.useDashboardStore(W=>W.selectedSheetId?W.documentInputRuntimeBySheetId[W.selectedSheetId]:void 0),y=m.useDashboardStore(W=>W.isDownloadingPdf),C=m.useDashboardStore(W=>W.reportContext),{authToken:w,tokenProps:N}=Et(),S=c==null?void 0:c.find(W=>W.id===b),j=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),I=m.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?dx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?rge(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(bC):(k==null?void 0:k.inputs)||G_t,[k,T,_]),M=C==null?void 0:C.calendar.tz,P=v.useMemo(()=>epe(D),[D]),A=v.useMemo(()=>Qme(D,M),[D,M]),z=v.useMemo(()=>Jme(D),[D]),O=x?x.filterValuesByInputId:A,B=v.useMemo(()=>npe(O,D),[D,O]),H=x?x.controlValuesByInputId:z,R=v.useMemo(()=>I?E&&S&&k?tZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(W=>W.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:M}):ope(D,B,H,P,P):[],[k,D,S,I,u,g,h,f,p,d,H,B,P,M,E]),q=!!S,$=j.length>0,F=((c==null?void 0:c.length)||0)>1||I,U=i.sheetSelection==="current"&&(!q||I&&R.length>0)||i.sheetSelection==="all"&&!$;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!$&&a(W=>({...W,sheetSelection:"current"}))},[$,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Q(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!q){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!$){et.error("No dashboard sheets are available to export");return}s(!0);const W=i.sheetSelection==="current"&&I,L=W?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",K=et.loading(L);try{if(W){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(R.length>0){et.dismiss(K),et.error(`Set ${R.join(", ")} before exporting`);return}const V=new Date().toISOString(),Z=E?nZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:V,timezone:M}).snapshot:void 0;await rL(N.apiServiceUrl,w,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:Z,...Z?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:B,controlValuesByInputId:H,generatedAt:V}}})}else{const V=goe();await ste(N.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,V)}et.dismiss(K);const Y=W?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";et.success(Y,{duration:2e3}),G()}catch(Y){et.dismiss(K),et.error("Failed to download PDF",{description:L_(Y,"Please try again or contact support."),descriptionClassName:O_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",Y)}finally{s(!1)}}return l.jsx(No,{open:e,onOpenChange:W=>{if(!W){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Es,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[F&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:WG,children:"Export scope"}),l.jsxs(yu,{value:i.sheetSelection,onValueChange:W=>a({...i,sheetSelection:W}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!q&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"current",id:"scope-current",disabled:!q}),I?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!$&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"all",id:"scope-all",disabled:!$}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:R.length>0?`Set ${R.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(In,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:W=>{a({...i,protectPdf:W,password:W?i.password:""}),W||r(!1)}}),l.jsx(Jv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(m.Label,{htmlFor:"pdf-password",className:WG,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:W=>a({...i,password:W.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:W=>{W.key==="Enter"&&i.password&&Q()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Uk,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(il,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:Q,disabled:o||y||U,children:o?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(_u,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Fxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_u,{className:m.cn("size-4",e)})}),l.jsx(Pxe,{open:i,onOpenChange:a})]})}function KG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Y_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=cx({id:`control:${e.id}`,disabled:!n}),d={transform:Xi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(wpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function GG(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function YG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Z_t(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return YG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=YG(t,n).filter(a=>!s.has(a));return[...o,...i]}function X_t(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Q_t(e){return m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function J_t(e){return Oxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function Oxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=X_t(e.dashboard,t);return m.removeShadowedCompatibilityInputs(m.buildNormalizedDashboardInputs({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Q_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function eIt(e,t){return"toolbar"}function tIt(){const e=ml("interactive"),t=m.useDashboardStore(V=>V.selectedSheetId),n=m.useDashboardStore(V=>V.dashboard.filters),r=m.useDashboardStore(V=>V.dashboard.filterLayout),o=m.useDashboardStore(V=>V.isDashboardEditing),s=m.useDashboardStore(V=>V.controlValues),i=m.useDashboardStore(V=>V.filterValues);m.useDashboardStore(V=>V.filteringCards);const a=m.useDashboardStore(V=>V.inlineFilterValuesMap),c=m.useDashboardStore(V=>V.dashboardInputValues),u=m.useInteractionStore(V=>V.clearAllClickFilters),d=m.useInteractionStore(V=>Object.entries(V.interactionStates).reduce((Z,[X,te])=>{var re;return X===m.DRILL_CONTEXT_CARD_ID?Z:Z+(((re=te.appliedClickFilters)==null?void 0:re.length)??0)},0)),f=m.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,removeFilter:x,setControlValue:y,setFilterLayout:C,setFilterValues:w,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=m.useDashboardActions(),j=gT(db(ax,{activationConstraint:{distance:5}})),I=m.useDashboardStore(V=>V.dashboard),k=J_t({dashboard:I,selectedSheetId:t}).filter(V=>eIt(V.filter)==="toolbar"),T=Oxe({dashboard:I,selectedSheetId:t}),_=k.map(V=>V.filter),E=new Map(k.map(V=>[`filter:${V.filter.id}`,V])),D=ent(I),M=D.filter(V=>!V.hidden&&mv(V)==="toolbar"),P=D.filter(V=>!V.hidden&&mv(V)==="advanced"),A=Z_t(r==null?void 0:r.toolbarItemOrder,_,M),z=new Map(_.map(V=>[`filter:${V.id}`,V])),O=new Map(M.map(V=>[`control:${V.id}`,V]));function B(V){const{active:Z,over:X}=V;if(!X||Z.id===X.id)return;const te=String(Z.id),re=String(X.id),ie=A.findIndex(ye=>ye===te),se=A.findIndex(ye=>ye===re);if(ie===-1||se===-1)return;const le=lx(A,ie,se);C({toolbarItemOrder:le});const ae=new Set((n||[]).map(ye=>ye.id)),xe=A.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),fe=le.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),be=A.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),pe=le.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(KG(n||[],xe,fe)),g(KG(I.controls||[],be,pe))}const H=(r==null?void 0:r.toolbarWrap)??!1,R=(r==null?void 0:r.showDownloadButton)??!1,q=T.filter(U2),$=T.filter(V=>{if(U2(V))return!1;const Z=m.getDashboardInputRuntimeSlot(c,V,{sheetId:t});return(Z==null?void 0:Z.status)==="set"||(Z==null?void 0:Z.status)==="cleared"}),F=new Set([...q,...$].map(V=>V.filter.id)),U=(i==null?void 0:i.filter(V=>!F.has(V.filterId)&&GG(V)).length)??0,G=[...q,...$],Q=G.filter(V=>{const Z=m.hydrateAuthoredDashboardInputSlot({dashboard:I,input:V,runtimeValues:c,target:{sheetId:t}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"&&GG(Z.value.filterValue)}).length,W=a?Object.values(a).reduce((V,Z)=>V+((Z==null?void 0:Z.length)??0),0):0,L=U+Q+W+d,K=G.some(V=>V.forceSelection),Y=()=>{w([]),G.forEach(V=>{p(V,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([V,Z])=>{Z==null||Z.forEach(X=>{f(V,X.filterId)})})};return!_.length&&!M.length&&!P.length&&!R&&L===0?null:l.jsx("div",{className:"z-20 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(dC,{sensors:j,collisionDetection:lC,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",H?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(fC,{items:A,strategy:Kz,children:l.jsx(qF,{className:"gap-3 pr-0",wrap:H,children:A.map(V=>{const Z=z.get(V);if(Z){const te=E.get(V),re=te&&U2(te),ie=re&&te.definitionOrigin==="dashboardFilter";return l.jsx(K_t,{filter:Z,isEditing:o,storageOptions:re?{storageTarget:"dashboardInput",dashboardInput:te,sheetId:t??void 0}:void 0,inputVariableName:re?te.variableName:void 0,isDashboardFilterReference:ie,onUpdateFilter:re?(se,le)=>{S(te.id,se,le)}:void 0,onRemoveFilter:re?()=>{if(te.definitionOrigin==="dashboardFilter"){x(Z.id);return}w((i||[]).filter(se=>se.filterId!==Z.id)),b(te.id)}:void 0},V)}const X=O.get(V);return X?l.jsx(Y_t,{control:X,value:s==null?void 0:s[X.id],isEditing:o,onChange:te=>y(X.id,te)},V):null})})}),P.length>0&&l.jsx(pde,{title:"",controls:P,values:s,onChange:(V,Z)=>y(V.id,Z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),L>0&&l.jsxs("button",{type:"button",onClick:Y,"aria-label":K?"Reset filters":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Me.X,{className:"h-3 w-3"}),K?"Reset filters":"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:L})]}),R&&l.jsx("div",{className:m.cn(L>0?"ml-1.5":"ml-auto"),children:l.jsx(Fxe,{})})]})})})}function Lxe(){var J,ne;const{showAssistant:e,tokenProps:t,renderMode:n}=Et(),r=W_t((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:o}=$m(),s=(ne=o==null?void 0:o.cardDisplay)==null?void 0:ne.mode,i=gf(s),a=dee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Svt({initialPosition:"bottom-right"}),y=Ah(ee=>ee.setFullscreen),C=Ah(ee=>ee.setPanelOpen),w=Ah(ee=>ee.setContainer),N=eJ("dashboard"),S=tJ(),j=nJ("dashboard"),I=N.isOpen,k=S==="dashboard",T=m.useDashboardStore(ee=>ee.isVisualEditing),_=m.useDashboardStore(ee=>ee.themeStyle),E=Ou(),D=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.sheets}),M=m.useDashboardStore(ee=>ee.showFilters),P=m.useDashboardStore(ee=>ee.isDashboardEditing),A=m.useDashboardStore(ee=>ee.selectedSheetId),z=D==null?void 0:D.find(ee=>ee.id===A),O=m.useDashboardStore(ee=>{var ue,ge,_e;return(_e=(ge=(ue=ee.dashboard)==null?void 0:ue.sheets)==null?void 0:ge.find(Te=>Te.id===ee.selectedSheetId))==null?void 0:_e.kind}),B=m.useDashboardStore(ee=>{var ue,ge;return((ge=(ue=ee.dashboard)==null?void 0:ue.summary)==null?void 0:ge.position)||"top"}),H=O==="document",R=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.id}),{getDefaultSheetId:q,setDefaultSheetId:$,clearDefaultSheetId:F}=$Y(R),[U,G]=v.useState(null),{setSelectedSheetId:Q,setSheetTitle:W,addSheet:L,setSheets:K,duplicateSheet:Y}=m.useDashboardActions();R_t(u);const{setActiveAssistantType:V}=m.useAIActions();v.useEffect(()=>{if(R){const ee=q();G(ee)}},[R,q]),v.useEffect(()=>{I?V("dashboard"):S==="dashboard"&&y(null)},[I,V,S,y]),v.useEffect(()=>{var ee;I||(ee=c.current)==null||ee.resize(0)},[I]);function Z(ee){var ue,ge;ee?((ue=c.current)==null||ue.resize(40),C("dashboard",!0),y("dashboard"),V("dashboard")):(C("dashboard",!1),y(null),(ge=c.current)==null||ge.resize(0),V(null))}function X(ee="dashboard"){const ue={id:ut.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:m.createDefaultDocumentDefinition()}:{}};L(ue),Q(ue.id)}function te(ee){const ue=Y(ee);ue&&(et.success("Sheet duplicated"),requestAnimationFrame(()=>{var _e;const ge=(_e=d.current)==null?void 0:_e.querySelector(`[data-sheet-id="${ue}"]`);ge==null||ge.focus(),ge==null||ge.scrollIntoView({block:"nearest",inline:"nearest"})}))}function re(ee,ue){if(!R)return;U===ee?(F(),G(null),et.success("Default sheet cleared")):($(ee),G(ee),et.success(`"${ue}" set as default sheet`))}function ie(ee){var ue;ee<1?(C("dashboard",!1),y(null),V(null),(ue=c.current)==null||ue.resize(0)):(I||C("dashboard",!0),V("dashboard"))}function se(){return(_==null?void 0:_.canvasTheme)==="muted"||!(_!=null&&_.canvasTheme)?"hsl(var(--semaphor-muted))":(_==null?void 0:_.canvasTheme)==="clear"?"":_==null?void 0:_.canvasTheme}const le=(ee,ue)=>{ee.dataTransfer.setData("tabIndex",ue.toString())},ae=ee=>{ee.preventDefault()},xe=(ee,ue)=>{const ge=ee.dataTransfer.getData("tabIndex");if(ge===ue.toString())return;const _e=Array.from(D||[]),[Te]=_e.splice(parseInt(ge),1);_e.splice(ue,0,Te),K(_e)},fe=r===!0&&!i&&!I&&!T&&!M;function be(){if(D&&D.length>1||P)return l.jsx("div",{className:"relative flex w-full items-stretch",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{ref:d,className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((ee,ue)=>{const ge=A===ee.id,_e=U===ee.id;return l.jsxs("div",{className:"relative flex shrink-0 items-center",children:[l.jsxs(m.TabsTrigger,{"data-sheet-id":ee.id,draggable:!0,onDragStart:Te=>le(Te,ue),onDragOver:ae,onDrop:Te=>xe(Te,ue),onClick:()=>Q(ee.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none",P&&ge&&"pr-9","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ee.id,children:[ee.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Kj,{enabled:P&&ge,text:ee.title,onSave:Te=>W(ee.id,Te),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":_e?"Clear default sheet":"Set as default sheet",title:_e?"Clear default sheet":"Set as default sheet",onClick:Te=>{Te.stopPropagation(),re(ee.id,ee.title||"Sheet")},onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Te.stopPropagation(),re(ee.id,ee.title||"Sheet"))},className:m.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ge||_e?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(VZ,{className:m.cn("h-3 w-3 transition-colors",_e?"fill-current text-amber-500":"text-muted-foreground")})})]}),P&&ge&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":`Sheet actions for ${ee.title||"Sheet"}`,className:"absolute right-2 inline-flex h-4 w-4 items-center justify-center rounded-[4px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground",children:l.jsx(ei,{className:"h-3 w-3"})})}),l.jsxs(mo,{align:"start",className:"w-44",children:[l.jsxs(mn,{onSelect:()=>te(ee.id),children:[l.jsx(zd,{className:"h-4 w-4"}),"Duplicate sheet"]}),l.jsxs(mn,{disabled:D.length<=1,onSelect:()=>h(!0),children:[l.jsx(_a,{className:"h-4 w-4"}),"Delete sheet"]})]})]})]},ee.id)}),P&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(mo,{align:"start",className:"w-48",children:[l.jsxs(mn,{onSelect:()=>X("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(mn,{onSelect:()=>X("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function pe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ee=>l.jsx(m.TabsContent,{style:{backgroundColor:se(),...E.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(HK,{sheet:ee})},ee.id))})}function ye(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",_==null?void 0:_.dashboardTabsContainer),onValueChange:ee=>{Q(ee)},value:A||void 0,children:[be(),B==="top"&&!H&&l.jsx(sF,{}),A&&!H&&l.jsx(tIt,{}),H?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:pe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:pe()}),B==="bottom"&&!H&&l.jsx(sF,{}),l.jsx(Nvt,{open:f,setOpen:h})]})}const ce=v.useCallback(ee=>{w("dashboard",ee)},[w]);return D?a&&A&&!H?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&H&&z?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(HK,{sheet:z})}):l.jsxs(l.Fragment,{children:[l.jsx(B_t,{}),l.jsx(U_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Ige,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GF,{children:ye()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Cvt,{open:I,onTabClick:Z,withHandle:!0,disabled:!I}),l.jsx(GF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ie,defaultSize:I?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(M_t,{open:I,setOpen:Z,isFullscreen:k,onFullscreenChange:ee=>y(ee?"dashboard":null),fullscreenContainer:j})})})]})]}),l.jsx("div",{ref:ce,className:m.cn("absolute inset-0",!k&&"pointer-events-none")}),fe&&l.jsx("div",{className:m.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:b(),children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{g.current||Z(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Pve,{className:"h-5 w-5"})})})]})]}):null}const $xe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ig.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(tx,{...u,ref:d,className:a,style:c,children:i})}));$xe.displayName="AppearanceProvider";const zxe=v.createContext({openBrandStudioPreview:()=>{}}),nIt=zxe.Provider;function rIt(){return v.useContext(zxe)}function oIt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ig.normalizeTheme(t),[s,i]=v.useState(()=>sIt(n)||o),a=v.useCallback(u=>{const d=ig.normalizeTheme(u);iIt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ig.ThemeProviderContext.Provider,{...r,value:c,children:e})}function sIt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ig.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function iIt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const aIt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function tB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=Et(),s=Kv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),C=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=Kn({queryKey:WX({resourceType:ho.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:C,appearance:i})},[i,C]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:C,appearance:w.data})},[w.data,C]);const N=(x==null?void 0:x.scopeKey)===C?x.appearance:null,S=i!==void 0?i:w.data!==void 0?w.data:N,j=v.useMemo(()=>Em.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(oIt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(nIt,{value:T,children:l.jsx($xe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(aIt,{appearance:d,onDraftChange:b,onSave:M=>{p(M),b(M),f(M)},onCancel:k})})})]})})})})}function Bxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(HX.Provider,{value:r,children:l.jsx(tT,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function lIt(e=2e3,t=500){const n=M0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function nB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=lIt(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function Vxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:e,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"dashboard",componentId:e.id}),l.jsx(tB,{appearance:e.appearance,children:l.jsx(Bxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(i5,{...e,type:"dashboard",children:l.jsx(Lxe,{})})})})})]})})})}function cIt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function uIt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=$m(),r=gf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=m.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=cIt([t,s,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Ci,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(V$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Me.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function dIt(){const e=m.useDashboardStore(r=>r.dashboard.filters),t=m.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:m.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(uIt,{filter:r}),l.jsx(GI,{filter:r})]},r.id))}):null}function fIt(){var s;const e=m.useDashboardStore(i=>i.dashboard),t=m.useDashboardStore(i=>i.selectedSheetId),n=m.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=m.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(dIt,{}),l.jsx(Lxe,{})]})})}const hIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-rUeEbuQf.cjs"))),mIt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-CbXkxxl5.cjs"))),pIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-CzWhgrtq.cjs")));function gIt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(a=>a.isVisualEditing),o=m.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:n,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"surfboard",componentId:n.id}),l.jsxs(tB,{appearance:s,children:[l.jsx(BCe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(Bxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(pIt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(hIt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(i5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(mIt,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(fIt,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Hxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),bIt=Bi.getSupportedCurrencyCodes(),xIt=bIt.filter(e=>!Hxe.has(e)),qxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],ZG="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=qxe.find(n=>n.value===e))==null?void 0:t.label)??e}function yIt(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(m.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(m.SelectTrigger,{id:e,size:"xs",children:l.jsx(m.SelectValue,{children:c})}),l.jsxs(m.SelectContent,{children:[l.jsx(m.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),qxe.map(u=>l.jsx(m.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function vIt({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Bi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,p={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:p,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,C=G2(_=>$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateStyle:_},calendar:{tz:"UTC"}})}).text),w=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(m.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:s,size:"xs",children:l.jsx(m.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:yIt(e.locale)})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(m.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(m.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:C,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:w,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(m.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:i,size:"xs",children:l.jsx(m.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Hxe].map(_=>l.jsx(m.SelectItem,{value:_,children:_},_)),xIt.map(_=>l.jsx(m.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function Uxe(e){return uO.add(e),()=>{uO.delete(e)}}function rB(){uO.forEach(e=>{e()})}var wIt=Object.defineProperty,CIt=(e,t,n)=>t in e?wIt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y1=(e,t,n)=>CIt(e,typeof t!="symbol"?t+"":t,n);const SIt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},NIt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},jIt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function kIt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Wxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const _It={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Wxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},IIt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},TIt={stringify:e=>e,parse:e=>e},Z2={string:TIt,number:IIt,boolean:SIt,function:NIt,method:_It,json:jIt},sy=Symbol.for("r2wc.render"),v1=Symbol.for("r2wc.connected"),Kf=Symbol.for("r2wc.context"),Di=Symbol.for("r2wc.props");function EIt(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=kIt(p);d[p]=g,f[g]=p}for(const p of a)u[p]=Array.isArray(t.events)?{}:t.events[p];class h extends HTMLElement{constructor(){super(),y1(this,s,!0),y1(this,o),y1(this,r,{}),y1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Di].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],C=y?Z2[y]:null;if(y==="method"){const w=Wxe(b);Object.defineProperty(this[Di].container,w,{enumerable:!0,configurable:!0,get(){return this[Di][w]},set(N){this[Di][w]=N,this[sy]()}}),this[Di][g]=C.parse(x,b,this)}C!=null&&C.parse&&x&&(this[Di][g]=C.parse(x,b,this))}for(const g of a)this[Di][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[v1]=!0,this[sy]()}disconnectedCallback(){this[v1]=!1,this[Kf]&&n.unmount(this[Kf]),delete this[Kf]}attributeChangedCallback(g,b,x){const y=f[g],C=c[y],w=C?Z2[C]:null;y in c&&w!=null&&w.parse&&x&&(this[Di][y]=w.parse(x,g,this),this[sy]())}[(s=v1,o=Kf,r=Di,sy)](){this[v1]&&(this[Kf]?n.update(this[Kf],this[Di]):this[Kf]=n.mount(this.container,e,this[Di]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[Di][p]},set(x){this[Di][p]=x;const y=b?Z2[b]:null;if(y!=null&&y.stringify){const C=y.stringify(x,g,this);this.getAttribute(g)!==C&&this.setAttribute(g,C)}else this[sy]()}})}return h}function DIt(e,t,n){const r=xye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function MIt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function RIt({root:e}){e.unmount()}function AIt(e,t={}){return EIt(e,t,{mount:DIt,update:MIt,unmount:RIt})}const PIt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},FIt=AIt(Vxe,{props:PIt}),OIt=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(g4,{context:t})," "]})});var Kxe="Toggle",Gxe=oe.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=m.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Kxe});return l.jsx(m.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:m.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Gxe.displayName=Kxe;var Yxe=Gxe;const LIt=m.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Zxe=oe.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Yxe,{ref:o,className:m.cn(LIt({variant:t,size:n,className:e})),...r}));Zxe.displayName=Yxe.displayName;function oB(){var c,u;const e=m.useEditorStore(d=>d.card),t=m.useEditorStore(d=>d.frame),n=v.useMemo(()=>tt.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=kf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=tt.resolveMultiInputType(n,o),i=v.useMemo(()=>tt.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:tt.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:tt.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Xxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const p=h??t;u.current=!0,a.current=p,s(p)},[t]);return{value:o,onChange:f,flush:d}}const $It=300;function zIt({onExpand:e},t){const n=m.useEditorStore(w=>w.card.sql),r=m.useEditorStore(w=>w.sqlGen),o=m.useEditorStore(w=>w.card),s=oB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=m.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Cb(u),f=Br(),h=v.useRef(d);h.current=d;const p=v.useRef(r);p.current=r;const g=v.useCallback(w=>{i(w)},[i]),{value:b,onChange:x,flush:y}=Xxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:$It});v.useEffect(()=>Uxe(y),[y]);function C(w){x(w),m.isObjectEmpty(p.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(m.CodeEditor,{ref:t,value:b??"",onValueChange:C,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:w=>{w.key==="Enter"&&w.shiftKey&&(w.preventDefault(),rB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const BIt=v.forwardRef(zIt),VIt=300;function HIt(e,t){const n=m.useEditorStore(g=>g.card.python),r=m.useEditorStore(g=>g.card),o=oB(),{setCardPython:s,setRunSql:i}=m.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Cb(a),u=Br(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:p}=Xxe({storeValue:n,defaultValue:tt.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:VIt});return v.useEffect(()=>Uxe(p),[p]),l.jsx(m.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),rB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const qIt=v.forwardRef(HIt),Qxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),UIt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),WIt=Array.from(Qxe).join(", "),KIt=3,GIt="Self-heal",YIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function ZIt({card:e}){var $,F,U,G,Q;const t=xl(),[n,r]=v.useState({}),{authToken:o}=Et(),s=m.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Ww(i),[i]),c=m.useEditorStore(W=>W.frame),u=m.useEditorStore(W=>W.inlineFilterValuesMap[e.id]),d=m.useEditorStore(W=>W.actions.setCardInlineFilterValue),f=m.useEditorStore(W=>W.actions.removeCardInlineFilterValue),h=e,{getCard:p,manifest:g}=kf((($=h.customCardPreferences)==null?void 0:$.url)||""),b=(F=g==null?void 0:g.visuals)==null?void 0:F.find(W=>{var L;return W.name===((L=h.customCardPreferences)==null?void 0:L.componentName)}),x=tt.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>tt.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),C=v.useMemo(()=>{const W=y.findIndex(L=>(L==null?void 0:L.id)===e.id);return W<0?-1:tt.getSlotIndexForCard(e,W)},[y,e]),w=v.useMemo(()=>x!=="multiple"||C<0?e.type:tt.getEffectiveCardTypeForSlot(e,C,b==null?void 0:b.slots)??e.type,[x,C,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,x]),{data:S,effectiveCardConfig:j}=Cb(N),I=m.useInteractionStore(W=>W.interactionStates),k=m.useDashboardStore(W=>{var L;return(L=W.dashboard)==null?void 0:L.id}),T=m.useDashboardStore(W=>W.dashboard.filters),_=m.useDashboardStore(W=>W.filterValues),E=m.useDashboardStore(W=>W.selectedSheetId),D=v.useMemo(()=>q$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:W=>d(e.id,W),removeInlineFilterValue:W=>f(e.id,W)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:P}=v.useMemo(()=>v_({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((W,L)=>{const K=tt.normalizeMultiInputPayload(L);r(Y=>({...Y,[W]:K}))},[]),z=(U=h.customCardPreferences)==null?void 0:U.componentName,O=z?p(z):null,B=Uj((G=h.customCardPreferences)==null?void 0:G.settings,h),H=v.useMemo(()=>tt.buildSlotOrderedCards(y),[y]),R=v.useMemo(()=>H.map((W,L)=>tt.getEffectiveCardTypeForSlot(W,L,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),q=v.useMemo(()=>K$(x==="multiple"?W$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,x,t]);return z?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&x==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Due({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:q,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D}),O&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((W,L)=>{if(!W)return null;const K=tt.getSlotIndexForCard(W,L),Y=tt.getEffectiveCardTypeForSlot(W,K,b==null?void 0:b.slots);return l.jsx(p$,{onDataChange:A,card:W,effectiveCardType:Y},`${W.id}-${K}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...U$({configCard:h,slotOrderedCards:H,slotTypes:R,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:q})})})]})]},(Q=h.customCardPreferences)==null?void 0:Q.componentName)}):null}const XIt=v.memo(ZIt),QIt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Jxe=["PageUp","PageDown"],eye=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],tye={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},px="Slider",[dO,JIt,eTt]=m.createCollection(px),[nye]=m.createContextScope(px,[eTt]),[tTt,ZT]=nye(px),rye=oe.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=oe.useRef(new Set),y=oe.useRef(0),w=i==="horizontal"?nTt:rTt,[N=[],S]=m.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...x.current][y.current])==null||M.focus(),f(E)}}),j=oe.useRef(N);function I(E){const D=lTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const P=fTt(s),A=hTt(Math.round((E-r)/s)*s+r,P),z=m.clamp(A,[r,o]);S((O=[])=>{const B=iTt(O,z,D);if(dTt(B,c*s)){y.current=B.indexOf(z);const H=String(B)!==String(O);return H&&M&&h(B),H?B:O}else return O})}return l.jsx(tTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:p,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Jxe.includes(E.key)||E.shiftKey&&eye.includes(E.key)?10:1,z=y.current,O=N[z],B=s*A*D;_(O+B,z,{commit:!0})}}})})})})});rye.displayName=px;var[oye,sye]=nye(px,{startEdge:"left",endEdge:"right",size:"width",direction:1}),nTt=oe.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=oe.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=oe.useRef(void 0),b=m.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function C(w){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=sB(S,y?[n,r]:[r,n]);return g.current=N,I(w-N.left)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(iye,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const N=C(w.clientX);i==null||i(N)},onSlideMove:w=>{const N=C(w.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const S=tye[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:S?-1:1})}})})}),rTt=oe.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=oe.useRef(null),f=m.useComposedRefs(t,d),h=oe.useRef(void 0),p=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=sB(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(iye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=tye[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),iye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=ZT(px,n);return l.jsx(m.Primitive.span,{...u,ref:t,onKeyDown:m.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Jxe.concat(eye).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),aye="SliderTrack",lye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(aye,n);return l.jsx(m.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});lye.displayName=aye;var fO="SliderRange",cye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(fO,n),s=sye(fO,n),i=oe.useRef(null),a=m.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>fye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});cye.displayName=fO;var hO="SliderThumb",uye=oe.forwardRef((e,t)=>{const n=JIt(e.__scopeSlider),[r,o]=oe.useState(null),s=m.useComposedRefs(t,a=>o(a)),i=oe.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(oTt,{...e,ref:s,index:i})}),oTt=oe.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=ZT(hO,n),a=sye(hO,n),[c,u]=oe.useState(null),d=m.useComposedRefs(t,C=>u(C)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:fye(p,i.min,i.max),b=aTt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?cTt(x,g,a.direction):0;return oe.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(dO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(dye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});uye.displayName=hO;var sTt="RadioBubbleInput",dye=oe.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=oe.useRef(null),s=m.useComposedRefs(o,r),i=m.usePrevious(t);return oe.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});dye.displayName=sTt;function iTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function fye(e,t,n){const s=100/(n-t)*(e-t);return m.clamp(s,[0,100])}function aTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function lTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function cTt(e,t,n){const r=e/2,s=sB([0,50],[0,r]);return(r-s(t)*n)*n}function uTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function dTt(e,t){if(t>0){const n=uTt(e);return Math.min(...n)>=t}return!0}function sB(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function fTt(e){return(String(e).split(".")[1]||"").length}function hTt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var hye=rye,mTt=lye,pTt=cye,gTt=uye;const mye=oe.forwardRef(({className:e,...t},n)=>l.jsxs(hye,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(pTt,{className:"absolute h-full bg-primary"})}),l.jsx(gTt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));mye.displayName=hye.displayName;exports.Accordion=a4;exports.AccordionContent=kv;exports.AccordionItem=Nv;exports.AccordionTrigger=jv;exports.AddDataPicker=X4;exports.AggregateTable=NI;exports.Alert=lL;exports.AlertDescription=cL;exports.AlertDialog=mf;exports.AlertDialogAction=Pu;exports.AlertDialogCancel=Fu;exports.AlertDialogContent=Eu;exports.AlertDialogDescription=Au;exports.AlertDialogFooter=Mu;exports.AlertDialogHeader=Du;exports.AlertDialogTitle=Ru;exports.AlertDialogTrigger=a1e;exports.AlertTitle=Ite;exports.ArrowDown=rs;exports.ArrowDownIcon=HQe;exports.ArrowLeft=Xv;exports.ArrowRight=Qv;exports.ArrowUp=vs;exports.ArrowUpIcon=UQe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Axe;exports.AxisConfigurator=Km;exports.BackgroundRunPill=wut;exports.Badge=xi;exports.Bell=N1;exports.BookType=uZ;exports.BriefingAuthor=dhe;exports.BriefingAuthorDialog=fhe;exports.BriefingUiCapabilitiesBoundary=Hut;exports.BriefingUiCapabilitiesProvider=dT;exports.BriefingsApiError=eC;exports.BulletChartIcon=kxe;exports.CSS=Xi;exports.CalculatedFieldEditor=Vme;exports.Calculator=fZ;exports.Calendar=Ka;exports.CalendarClock=EO;exports.Card=SN;exports.CardContent=TO;exports.CardHeader=IO;exports.CardSummary=fF;exports.CardTitle=gb;exports.ChartArea=SR;exports.ChartColumnIncreasing=mZ;exports.ChartColumnStacked=pZ;exports.ChartJsVisual=Bw;exports.ChartLine=gZ;exports.ChartNoAxesGantt=xZ;exports.ChartPie=yZ;exports.ChartScatter=vZ;exports.ChatInputWithContext=Q4;exports.Checkbox=In;exports.ChevronLeft=Am;exports.ChevronsUpDown=SZ;exports.Circle=DO;exports.CircleAlert=ja;exports.CircleCheck=NZ;exports.CircleHelp=jZ;exports.Clock=kZ;exports.CodeHighlighter=$d;exports.CodeXml=j1;exports.Collapsible=Nu;exports.CollapsibleContent=ku;exports.CollapsibleTrigger=ju;exports.ColorField=ha;exports.Command=wT;exports.CommandEmpty=ST;exports.CommandGroup=NT;exports.CommandInput=Xz;exports.CommandItem=jT;exports.CommandList=CT;exports.CommandSeparator=ame;exports.ComparisonMetadataBadge=Xoe;exports.Container=i5;exports.ControlDefaultValueEditor=fpe;exports.ControlDefinitionOptionsEditor=dpe;exports.ControlIdInput=ape;exports.ControlVisibilitySettings=abt;exports.Copy=zd;exports.CopyButton=Ld;exports.CopyPlus=NR;exports.Cross2Icon=YQe;exports.CustomFilterPopover=V$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Kre;exports.Dashboard=Vxe;exports.DashboardCard=ghe;exports.DashboardCreateDialogBase=yQ;exports.DashboardExportDialog=Pxe;exports.DashboardPlus=gIt;exports.DashboardWC=FIt;exports.DataTableConditionalFormattingSettings=tge;exports.DataTablePagination=pI;exports.Database=Go;exports.DateRangePicker=L$;exports.DefaultChatTransport=B4;exports.Dialog=No;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=il;exports.DialogHeader=Es;exports.DialogTitle=go;exports.DialogTrigger=gQ;exports.DisplayFormatPreferencesFields=vIt;exports.DisplayPreferencesProvider=tT;exports.DndContext=dC;exports.Donut=_Z;exports.Download=_u;exports.DownloadPdf=Fxe;exports.DragOverlay=Khe;exports.DropdownMenu=Co;exports.DropdownMenuCheckboxItem=sd;exports.DropdownMenuContent=mo;exports.DropdownMenuItem=mn;exports.DropdownMenuLabel=Ca;exports.DropdownMenuRadioGroup=mCe;exports.DropdownMenuRadioItem=VX;exports.DropdownMenuSeparator=Ia;exports.DropdownMenuSub=XO;exports.DropdownMenuSubContent=Zk;exports.DropdownMenuSubTrigger=Yk;exports.DropdownMenuTrigger=So;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Kj;exports.EditableText=Ci;exports.EditorCustomVisual=XIt;exports.Ellipsis=ei;exports.EllipsisVertical=Pm;exports.ErrorBoundary=ki;exports.ExportError=Rb;exports.ExternalLink=Bd;exports.EyeOff=Uk;exports.Fallback=JI;exports.FallbackVisual=Xw;exports.FeedbackCategory=df;exports.FeedbackDialog=Fv;exports.FieldsList=g4;exports.FieldsSection=OIt;exports.FileCode=IZ;exports.FileText=ti;exports.Filter=Vd;exports.FilterComponent=GI;exports.FilterInfo=lF;exports.FilterableFieldsPanel=qme;exports.Grid3x3=jR;exports.GripVertical=Iu;exports.HEATMAP_PRESET_PALETTES=$A;exports.Hash=bb;exports.House=TZ;exports.HoverCard=Qm;exports.HoverCardContent=wu;exports.HoverCardTrigger=Qd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Qxe;exports.INLINE_ALLOWED_TOOL_LIST=WIt;exports.INLINE_BLOCKED_MUTATING_TOOLS=UIt;exports.IconButton=su;exports.IconForFieldType=cN;exports.Inbox=RO;exports.InfoHover=cz;exports.InlineFilterBar=lde;exports.KPICard=of;exports.KeyboardSensor=cC;exports.Layers=Om;exports.Link=AO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=KIt;exports.Map=RZ;exports.Markdown=Rz;exports.MatrixTableVisual=SI;exports.MdStackedLineChart=Nxe;exports.MultiInputEmptyRenderer=p$;exports.PanelResizeHandle=VT;exports.Pause=AZ;exports.PenLine=IR;exports.Pencil=TR;exports.PendingMessagesDisplay=mxe;exports.PersistedDynamicVisual=eT;exports.PiChartPolar=vxe;exports.Pin=FZ;exports.PinOff=PZ;exports.PivotTableTanstack=ex;exports.Placeholders=Tge;exports.Play=OZ;exports.Plus=Mr;exports.PointerSensor=ax;exports.Progress=K4;exports.PythonEditor=qIt;exports.RECOVERABLE_SQL_ERROR_CODES=YIt;exports.Radar=LZ;exports.RadioGroup=yu;exports.RadioGroupItem=Xs;exports.RefreshCw=ka;exports.ResizableHandle=wvt;exports.ResizablePanel=GF;exports.ResizablePanelGroup=Ige;exports.ResourceEditDialog=ZQ;exports.ResourceType=ho;exports.Rows3=$Z;exports.RunCompletionBanner=Cut;exports.SELF_HEAL_TIMELINE_STEP=GIt;exports.SeedQuestions=Jbe;exports.SemaphorContext=Wv;exports.SemaphorContextProvider=wO;exports.SemaphorQueryClient=LY;exports.SemaphorReadyIndicator=nB;exports.SemaphorStyleWrapper=tx;exports.Send=FO;exports.SendHorizontal=zZ;exports.Settings=OO;exports.Settings2=ff;exports.Share2=BZ;exports.ShareDialog=YQ;exports.Sheet=p3;exports.SheetContent=gI;exports.SheetDescription=xI;exports.SheetHeader=Boe;exports.SheetTitle=bI;exports.SheetTrigger=g4e;exports.Slider=mye;exports.SortableContext=fC;exports.Sparkles=k0;exports.SqlEditor=BIt;exports.Square=$O;exports.SquarePen=LO;exports.Star=VZ;exports.StructuralParticipantSelector=lpe;exports.SummaryCard=sF;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Fd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ga;exports.TableBody=Xd;exports.TableCell=Wn;exports.TableColumnVisibilitySettings=Hpe;exports.TableHead=vo;exports.TableHeader=Xm;exports.TablePresentationSettings=Upe;exports.TableRow=Fr;exports.TableSkeleton=dz;exports.TableVisual=Jd;exports.Tag=HZ;exports.TbChartBubble=wxe;exports.TbChartFunnel=Cxe;exports.TbChartTreemap=Sxe;exports.TextCard=sb;exports.Textarea=Bm;exports.TiSortNumerically=jxe;exports.Toggle=Zxe;exports.Tornado=qZ;exports.Trash2=_a;exports.TriangleAlert=Fo;exports.TypeGlyph=oC;exports.UXProvider=tB;exports.Undo2=UZ;exports.User=BO;exports.Users=Wk;exports.UsersRound=VO;exports.VisualErrorState=Wue;exports.Zap=ER;exports.applyBriefingFormPatch=pv;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Xre;exports.arrayMove=lx;exports.briefingFormDraftToCreateRequest=pF;exports.briefingFormDraftToUpdateRequest=Ude;exports.briefingToFormDraft=og;exports.briefingTone=Er;exports.buildCardControlUsageById=cbt;exports.buildCustomCardTheme=Ww;exports.buildDashboardControlUsageById=lbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=ppe;exports.buildFilterFieldMeta=pO;exports.buildFilterSemanticContext=gO;exports.buildInlineFilterNodes=q$;exports.buildMultiInputCustomVisualProps=U$;exports.buildMultiInputTemporalPresentationInputs=W$;exports.calculateCardFilterValues=y_;exports.calculateContextAwareFilters=v_;exports.calculateFieldState=e3;exports.canEditLocalCalculatedFields=f4;exports.canUserAccessVisuals=hNe;exports.canUserCreateDashboards=QQ;exports.canUserEdit=uNe;exports.canUserManageDashboards=fNe;exports.canUserManageGroups=mNe;exports.canUserUseFilters=dNe;exports.cancelBriefingPreviewRun=Rde;exports.cancelBriefingRun=Pde;exports.cancelExport=P$e;exports.chartSupportsDataLabels=qne;exports.chartSupportsLegend=Vne;exports.chartTypes=YT;exports.cleanupKpiMetricComparisonMode=gme;exports.cloneLinkedFrameWithSourceMapping=ytt;exports.closestCenter=lC;exports.commitSharedCalculatedFields=th;exports.createAssistantConversationId=Wp;exports.createAssistantRequestId=Xbe;exports.createBriefing=jde;exports.createBriefingFormDraft=mF;exports.createChartConfig=Db;exports.createCustomVisualTemporalBucketFormatter=K$;exports.createDashboardControlInputFromControl=l0t;exports.createExport=boe;exports.currencyPresentationTargetKey=va;exports.dedup=gjt;exports.dedupeContextEntities=Bz;exports.deleteBriefing=Ide;exports.deleteBriefingRun=Fde;exports.diagnoseCurrencyPresentationBindings=Q0e;exports.doesStoredFilterMatchField=Ag;exports.downloadDocumentPdf=rL;exports.downloadPdf=ste;exports.extractTableMetadata=n4;exports.fieldAlreadyExists=Jre;exports.flexRender=vi;exports.flushPendingEditorDrafts=rB;exports.formatDisplayFormula=opt;exports.formatFileSize=L$e;exports.getAutoDetectedChartIcon=Gkt;exports.getBriefing=Nde;exports.getBriefingArtifact=Nnt;exports.getBriefingEvidence=jnt;exports.getBriefingPreviewRun=Mde;exports.getBriefingRun=Ade;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=SDe;exports.getChartIconByType=Ykt;exports.getColorForValue=JR;exports.getCoreRowModel=fI;exports.getDefaultAxisConfig=oA;exports.getDefaultChartColors=Wm;exports.getDefaultDataLabelsConfig=Cw;exports.getDefaultLegendConfig=FL;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=jw;exports.getDocumentSectionEditorCard=Bgt;exports.getDocumentSheetDashboardInputs=dx;exports.getDownloadUrl=A$e;exports.getEntityIcon=Ok;exports.getErrorMessage=Obe;exports.getExportStatus=R$e;exports.getExports=M$e;exports.getExpressionFieldKind=af;exports.getFieldExpressionAnnotation=r4;exports.getFilterCount=ek;exports.getFilterSourceDatabase=pY;exports.getGranularityOptionsForFieldType=ipe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=cI;exports.getMetricDisplayLabel=$3e;exports.getNewField=ooe;exports.getPaginationRowModel=hI;exports.getRoleBasedDisplayOverrides=XQ;exports.getRunningTotalOrderByCandidates=_mt;exports.getSelectedDateFilterColumn=uue;exports.getSemanticDomainLabel=hxe;exports.getSortedRowModel=Loe;exports.getTableConditionalFormattingColumnOptions=Ype;exports.getTableOutputColumnOptions=Zpe;exports.handleAggregationChange=cF;exports.handleAggregationLabelChange=ide;exports.hasFlatTableTotalsBehavior=Um;exports.hasMatrixResultData=_w;exports.horizontalListSortingStrategy=Kz;exports.inferSemanticDomainIdFromSelectedEntities=Fk;exports.isActiveBriefingRunStatus=sk;exports.isCardSummaryVisibleOnCard=G$;exports.isCurrencyPresentationControl=Z0e;exports.isDefaultColor=LTe;exports.isDevPaginationSwitchableCard=poe;exports.isEligibleFlatTableTotalsCard=hw;exports.isExportComplete=O$e;exports.isExportInProgress=F$e;exports.isInAiScopeArray=pjt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=jmt;exports.isPresentationCurrencyBinding=Yv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=soe;exports.isStructuralControlBinding=Y0e;exports.isSubtotalEnabledAggregateTable=t4;exports.isSupportedDocumentTableCardType=Vgt;exports.isTableType=cDe;exports.isTerminalBriefingRunStatus=ok;exports.lastAssistantMessageIsCompleteWithToolCalls=Rbe;exports.listBriefingRuns=Snt;exports.listBriefingTenantSummaries=Cnt;exports.listBriefings=wnt;exports.merge=sc;exports.mergeAxisConfig=sA;exports.normalizeConditionalFormatting=z5;exports.normalizeContextFormatMode=Eee;exports.pauseBriefing=kde;exports.pivotData=gw;exports.polishBriefingText=Ode;exports.prepareFeedbackData=GT;exports.previewBriefingPlan=Ede;exports.remarkGfm=Oz;exports.removeFromScopeArray=bjt;exports.resolveCurrencyPresentationTargetFormat=Aee;exports.resolveDashboardBriefingsVisibility=hhe;exports.resolveDashboardControlsVisibility=xNe;exports.resolveDashboardTitleEditability=bNe;exports.resolveDomainCalculatedFieldForEdit=Jpt;exports.resolveMatrixCardMeasureInstances=qk;exports.resolvePendingPivotTableResultState=h$e;exports.resolveTablePresentationStyle=S3;exports.resumeBriefing=_de;exports.runBriefingNow=Tde;exports.runBriefingPreview=Dde;exports.sanitizeAIScope=Fbe;exports.saveCalculatedFieldToCardScope=zF;exports.saveCalculatedFieldToSharedScope=Hme;exports.saveCalculatedFieldToSheetScope=BF;exports.seedSemanticMetricFormatDefaults=xme;exports.setTableColumnVisibility=yoe;exports.setupEditorWithCard=P_;exports.showAllTableColumns=z$e;exports.showJoinRequiredNotification=Qre;exports.sortByColumnsToSortState=ase;exports.sortStateToSortByColumns=lse;exports.sortableKeyboardCoordinates=Yz;exports.supportsLiveNumericPresentation=Gv;exports.supportsMetricTransformForMetric=bme;exports.supportsTableConditionalFormatting=Wpe;exports.toEntityArray=rl;exports.ue=et;exports.updateBriefing=rT;exports.useActiveExports=NNe;exports.useActiveToolStatus=gxe;exports.useAddFrameWithFreshSemanticExecutionPayload=lz;exports.useAddNewFrame=She;exports.useAssistantContainer=nJ;exports.useAssistantContextEntities=fT;exports.useAssistantLayoutStore=Ah;exports.useAssistantPanel=eJ;exports.useAssistantProfile=Qbe;exports.useAutoSubmitQueue=pxe;exports.useBrandStudioPreview=rIt;exports.useBriefingRunPolling=bF;exports.useBriefingUiCapabilities=mhe;exports.useCalendarContext=Z3e;exports.useCard=r$e;exports.useCardNumericPresentation=Pa;exports.useCardSummary=Y$;exports.useChartNumericPresentation=Mb;exports.useChat=Pbe;exports.useColumns=Qz;exports.useCreateVisualWithFrame=uSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=kf;exports.useCustomVisualsQuery=B$;exports.useDashboardAppearance=Ou;exports.useDashboardById=XX;exports.useDashboardInteractionMode=nde;exports.useDashboardPreferences=$m;exports.useDashboardQuery=Kv;exports.useDashboardStructuralParticipants=gpe;exports.useDashboardSummary=Lue;exports.useDataColumns=vme;exports.useDateFilterHook=vYe;exports.useDefaultDashboardMutation=qX;exports.useDisplayPreferences=pl;exports.useDroppable=Whe;exports.useEditorAside=kT;exports.useEditorCardQuery=Cb;exports.useEffectiveEditorCardType=oB;exports.useEnsureReactGlobals=Mle;exports.useExportActions=rJ;exports.useExportStore=s_;exports.useFieldManagement=yme;exports.useFilterableFields=hme;exports.useFullscreenAssistant=tJ;exports.useGroupMembers=f1e;exports.useGroups=o5;exports.useHasDashboardId=oJ;exports.useInProgressExportsCount=jNe;exports.useJoinabilityMap=e4;exports.useManagementActions=Rm;exports.useManagementStore=Ts;exports.useMutation=Is;exports.usePivotTableConfig=Ym;exports.usePluginQuery=Cue;exports.useQuery=Kn;exports.useQueryClient=Br;exports.useReactTable=mI;exports.useResolveExistingFrameSemanticExecutionPayload=Stt;exports.useResolvedDefaultCurrency=r3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=n3;exports.useResourceManagement=JO;exports.useResourceUpdateState=QX;exports.useScopedFields=fme;exports.useSelectedVisual=F0e;exports.useSemanticDomains=G4;exports.useSemaphorContext=Et;exports.useSensor=db;exports.useSensors=gT;exports.useSortable=cx;exports.useStarredChartsStore=QIt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=Qoe;exports.useTextFilterHook=ZUe;exports.useTheme=gY;exports.useTimezone=bl;exports.useTopoJson=Nw;exports.useUnifiedUsers=r_;exports.useUpdateResource=KX;exports.useUpdateVisualMutation=dSe;exports.useUserPreferences=vQ;exports.useVisualById=Qk;exports.useVisualManagement=cSe;exports.validateBriefingFormDraft=gF;exports.validateFieldForChartType=pme;exports.verticalListSortingStrategy=Gz;
1404
+ `).trim(),k=j.map((T,_)=>{var M,P;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(w_t,{text:I||void 0,files:k.length>0?k:void 0})}const f=((w=e.parts)==null?void 0:w.filter(S=>S.type==="reasoning"))||[],h=f.length>0,p=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Nu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(ju,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(ku,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(OG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=b_t(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(OG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:M,value:P},A)=>l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(C_t,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(eB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&J4(S,r)?l.jsx(ki,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(v_t,{error:T,resetErrorBoundary:_}),children:l.jsx(f_t,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?Rxe(e,r)?l.jsxs(Mxe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const k_t=8,__t=24,I_t=20;function T_t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Axe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),C=v.useRef(!1),w=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(__t);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=Rxe(D,t),P=T_t(a,c,u,M),A=Iw({count:e.length,getScrollElement:()=>b.current,estimateSize:H=>{const R=e[H];return(R==null?void 0:R.role)==="user"?88:180},getItemKey:H=>{const R=e[H];return(R==null?void 0:R.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:k_t,overscan:6,gap:20,paddingEnd:P?_+I_t:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const R=H.isAtEnd();I(q=>q===R?q:R),R&&T(0)}}),z=v.useCallback((H="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,A.scrollToEnd({behavior:H})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{C.current||(C.current=!0,z("auto"))},[z]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,z("auto"))},[e.length,g,z]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!A.isAtEnd()&&T(R=>R+e.length-H),e.length===0&&(T(0),I(!0),C.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const H=x.current;if(!H||!P)return;const R=()=>{const $=Math.ceil(H.getBoundingClientRect().height);$>0&&E(F=>F===$?F:$)};if(R(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(R);return q.observe(H),()=>q.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:B},children:[O.map(H=>{const R=e[H.index];return R?l.jsx("div",{ref:A.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(j_t,{message:R,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),P&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(S_t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>z("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(rs,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function E_t(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const D_t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function M_t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,C]=v.useState(0),w=n??b,{isLocalDev:N,isConsoleMode:S}=$m(),j=N||S||a,I=v.useRef(null);m.useDashboardStore(ue=>ue.dashboard.aiScopeTables),m.useDashboardStore(ue=>ue.isDashboardEditing);const k=m.useDashboardStore(ue=>ue.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=m.useDashboardActions(),D=lz(),{clearAssistantMessageContexts:M}=m.useAIActions(),{clearQueue:P}=m.useQueueActions(),{clearFileAttachments:A,getFileAttachments:z}=m.useFileActions(),O=m.useFileAttachments("dashboard"),B=m.useEditorStore(ue=>ue.card.dataSource),{assistantProfile:H}=Qbe(),R=m.useDashboardStore(ue=>ue.handleOpenAssistantProfile),{selectedEntities:q,applyDashboardDefaultEntities:$}=fT("dashboard"),{sendMessage:F,isLoading:U,messages:G,setMessages:Q,status:W,stop:L,errorMessage:K,clearError:Y}=Pjt({dynamicVisualMode:f}),V=v.useCallback(()=>{C(ue=>ue+1)},[]),Z=v.useCallback(ue=>{r==null||r(ue),n===void 0&&x(ue)},[n,r]),X=v.useCallback(()=>{Z(!w)},[w,Z]);v.useEffect(()=>{if(!w)return;function ue(ge){ge.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[w,Z]);const[te,re]=v.useState(""),ie=ue=>{re(ue.target.value)};async function se({sql:ue,cardTitle:ge,connectionId:_e,cardType:Te,python:Ce,cardConfig:Re,dataSource:Ve,customVisualPreferences:Ee,visualizationMode:We,dynamicCardPreferences:Ie}){if(!k)return;const we=We==="dynamic",de=ut.hasValidCardConfig(Re),Se=_e||(Ve==null?void 0:Ve.connectionId)||"",Le=Ve?{...Ve,connectionId:Se||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:Se?{connectionId:Se,connectionType:"",mode:"database",selectedEntities:[]}:mb,st=!(de&&(!we||(Ie==null?void 0:Ie.provenance)==="card-config"||(Ie==null?void 0:Ie.provenance)==="query_spec")),$e=st?E_t(ue):"",Ke=st?Ce:"",at={id:ut.v4(),title:ge||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...we&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:$e,python:Ke,dataSource:Le,config:Re,connectionId:Se,visualizationMode:We,dynamicCardPreferences:Ie,customCardPreferences:Ee?{url:Ee.url,componentName:Ee.componentName,pluginChartType:Ee.pluginChartType,settings:Ee.settings,type:"component"}:void 0},ct={id:ut.v4(),cards:[at],activeCardId:at.id};try{await D(k,ct,"end"),E(!0),_(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),et.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const le=ue=>{ue.preventDefault();const ge=te.trim();if(!ge&&O.length===0)return;const _e=[];ge&&_e.push({type:"text",text:ge}),O.forEach(Te=>{Te.data&&_e.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),F({role:"user",parts:_e}),re(""),A("dashboard"),V()};v.useEffect(()=>{var ue;e&&((ue=I.current)==null||ue.focus())},[e]),pxe({assistantType:"dashboard",status:W,isLoading:U,sendMessage:F});const{hasActiveTools:ae,activeToolText:xe}=gxe(G);function fe(ue){const ge={role:"user",parts:[{type:"text",text:ue.title+" "+ue.subtitle}]};F(ge),V()}function be(ue){F({role:"user",parts:[{type:"text",text:ue}]}),V()}function pe(ue){F({role:"user",parts:[{type:"text",text:ue}]}),V()}const ye=v.useCallback(async()=>{const ue=JSON.stringify(G??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ue),et.success("Conversation copied")}catch(ge){console.error("Failed to copy conversation",ge),et.error("Unable to copy conversation")}},[G]),ce=(te==null?void 0:te.length)===0&&(G==null?void 0:G.filter(ue=>ue.role==="user").length)===0;function J(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ne(){return l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(su,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Pm,{className:"size-3.5"})})}),l.jsxs(mo,{align:"end",children:[l.jsx(Ca,{children:"Options"}),l.jsx(Ia,{}),l.jsx(sd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(sd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(sd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ia,{}),l.jsx(Ca,{children:"Dynamic Visuals"}),l.jsx(sd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(sd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(sd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ee=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[J(),R&&l.jsxs("button",{type:"button",onClick:R,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ne(),j&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ye,children:"Copy Conversation"}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:X,children:w?l.jsx(Ft.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const ue=G.filter(ge=>ge.role==="assistant").map(ge=>ge.id).filter(ge=>!!ge);Q([]),P("dashboard"),Y(),M(ue)},children:l.jsx(LO,{className:"h-3.5 w-3.5"})}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Me.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Axe,{messages:G,showTools:a,showSystemMessage:u,onAddToDashboard:se,onQuickReply:pe,disableQuickReplies:U,status:W,errorMessage:K,activeToolText:U&&ae?xe:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&ce&&l.jsx(Tge,{onClick:fe,placeholders:D_t}),ce&&H&&l.jsx(Jbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:be}),l.jsx(mxe,{assistantType:"dashboard"}),l.jsx(Q4,{ref:I,setInput:re,stop:L,input:te,handleInputChange:ie,handleSubmit:ue=>{le(ue)},isLoading:U,status:W,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(X4,{incomingSelectedEntities:q,open:p,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ue=>$()})]});return w&&o?vr.createPortal(l.jsx(tx,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ee})}),o):ee}function R_t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),o=tde(),s=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(A_t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),et.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=P_t(p);if(g!=null&&g.id){const b=Que(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),et.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function A_t(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function P_t(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function F_t(e,t){switch(e.interactionMode){case"drillToDetail":O_t(e,t);break;case"drillThrough":L_t(e,t);break;case"drillToURL":$_t(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function O_t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function L_t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function $_t(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function z_t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(No,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ade,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(bhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function B_t(){const e=m.useInteractionStore(N=>N.interactionStates),t=m.useInteractionStore(N=>N.setInteractionState),n=m.useInteractionStore(N=>N.clearLastInteractionEvent),r=m.useInteractionStore(N=>N.replaceCardWithInsight),o=m.useInteractionStore(N=>N.setPendingDrillThrough),s=m.useInteractionStore(N=>N.pendingDrillThrough),i=m.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Rm(),d=m.useDashboardStore(N=>N.dashboard),f=m.useDashboardStore(N=>N.filterValues),{data:h,isLoading:p}=XX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xhe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),C=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...m.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(m.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{F_t(j,C)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,C]),v.useEffect(()=>{if(!(!s||!h||p))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(z_t,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function V_t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=H_t(uz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function H_t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function q_t(e){return e?`Back to ${e}`:"Back"}function U_t(){var y,C,w,N,S;const e=m.useInteractionStore(j=>j.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(j=>j.actions.goBackFromDrill),n=m.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Rm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(w=(C=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:C.filterGroups)==null?void 0:w[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};V_t(f);const x=q_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(xi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Me.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(Xv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function W_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function K_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:p,transform:g,transition:b,isDragging:x}=cx({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Xi.Translate.toString(g),transition:b,opacity:x?.5:1,zIndex:x?10:void 0};return l.jsx("div",{ref:p,style:y,...f,children:l.jsx(H$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const WG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",G_t=[];function Pxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(W=>{var L;return(L=W.dashboard)==null?void 0:L.sheets}),u=m.useDashboardStore(W=>W.dashboard),d=m.useDashboardStore(W=>W.dashboardInputValues),f=m.useDashboardStore(W=>W.filterValues),h=m.useDashboardStore(W=>W.controlValues),p=m.useDashboardStore(W=>W.inlineFilterValuesMap),g=m.useDashboardStore(W=>W.cardControlValuesMap),b=m.useDashboardStore(W=>W.selectedSheetId),x=m.useDashboardStore(W=>W.selectedSheetId?W.documentInputRuntimeBySheetId[W.selectedSheetId]:void 0),y=m.useDashboardStore(W=>W.isDownloadingPdf),C=m.useDashboardStore(W=>W.reportContext),{authToken:w,tokenProps:N}=Et(),S=c==null?void 0:c.find(W=>W.id===b),j=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),I=m.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?dx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?rge(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(bC):(k==null?void 0:k.inputs)||G_t,[k,T,_]),M=C==null?void 0:C.calendar.tz,P=v.useMemo(()=>epe(D),[D]),A=v.useMemo(()=>Qme(D,M),[D,M]),z=v.useMemo(()=>Jme(D),[D]),O=x?x.filterValuesByInputId:A,B=v.useMemo(()=>npe(O,D),[D,O]),H=x?x.controlValuesByInputId:z,R=v.useMemo(()=>I?E&&S&&k?tZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(W=>W.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:M}):ope(D,B,H,P,P):[],[k,D,S,I,u,g,h,f,p,d,H,B,P,M,E]),q=!!S,$=j.length>0,F=((c==null?void 0:c.length)||0)>1||I,U=i.sheetSelection==="current"&&(!q||I&&R.length>0)||i.sheetSelection==="all"&&!$;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!$&&a(W=>({...W,sheetSelection:"current"}))},[$,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Q(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!q){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!$){et.error("No dashboard sheets are available to export");return}s(!0);const W=i.sheetSelection==="current"&&I,L=W?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",K=et.loading(L);try{if(W){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(R.length>0){et.dismiss(K),et.error(`Set ${R.join(", ")} before exporting`);return}const V=new Date().toISOString(),Z=E?nZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:V,timezone:M}).snapshot:void 0;await rL(N.apiServiceUrl,w,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:Z,...Z?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:B,controlValuesByInputId:H,generatedAt:V}}})}else{const V=goe();await ste(N.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,V)}et.dismiss(K);const Y=W?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";et.success(Y,{duration:2e3}),G()}catch(Y){et.dismiss(K),et.error("Failed to download PDF",{description:L_(Y,"Please try again or contact support."),descriptionClassName:O_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",Y)}finally{s(!1)}}return l.jsx(No,{open:e,onOpenChange:W=>{if(!W){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Es,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[F&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:WG,children:"Export scope"}),l.jsxs(yu,{value:i.sheetSelection,onValueChange:W=>a({...i,sheetSelection:W}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!q&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"current",id:"scope-current",disabled:!q}),I?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!$&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"all",id:"scope-all",disabled:!$}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:R.length>0?`Set ${R.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(In,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:W=>{a({...i,protectPdf:W,password:W?i.password:""}),W||r(!1)}}),l.jsx(Jv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(m.Label,{htmlFor:"pdf-password",className:WG,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:W=>a({...i,password:W.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:W=>{W.key==="Enter"&&i.password&&Q()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Uk,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(il,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:Q,disabled:o||y||U,children:o?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(_u,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Fxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_u,{className:m.cn("size-4",e)})}),l.jsx(Pxe,{open:i,onOpenChange:a})]})}function KG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Y_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=cx({id:`control:${e.id}`,disabled:!n}),d={transform:Xi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(wpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function GG(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function YG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Z_t(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return YG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=YG(t,n).filter(a=>!s.has(a));return[...o,...i]}function X_t(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Q_t(e){return m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function J_t(e){return Oxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function Oxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=X_t(e.dashboard,t);return m.removeShadowedCompatibilityInputs(m.buildNormalizedDashboardInputs({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Q_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function eIt(e,t){return"toolbar"}function tIt(){const e=ml("interactive"),t=m.useDashboardStore(V=>V.selectedSheetId),n=m.useDashboardStore(V=>V.dashboard.filters),r=m.useDashboardStore(V=>V.dashboard.filterLayout),o=m.useDashboardStore(V=>V.isDashboardEditing),s=m.useDashboardStore(V=>V.controlValues),i=m.useDashboardStore(V=>V.filterValues);m.useDashboardStore(V=>V.filteringCards);const a=m.useDashboardStore(V=>V.inlineFilterValuesMap),c=m.useDashboardStore(V=>V.dashboardInputValues),u=m.useInteractionStore(V=>V.clearAllClickFilters),d=m.useInteractionStore(V=>Object.entries(V.interactionStates).reduce((Z,[X,te])=>{var re;return X===m.DRILL_CONTEXT_CARD_ID?Z:Z+(((re=te.appliedClickFilters)==null?void 0:re.length)??0)},0)),f=m.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,removeFilter:x,setControlValue:y,setFilterLayout:C,setFilterValues:w,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=m.useDashboardActions(),j=gT(db(ax,{activationConstraint:{distance:5}})),I=m.useDashboardStore(V=>V.dashboard),k=J_t({dashboard:I,selectedSheetId:t}).filter(V=>eIt(V.filter)==="toolbar"),T=Oxe({dashboard:I,selectedSheetId:t}),_=k.map(V=>V.filter),E=new Map(k.map(V=>[`filter:${V.filter.id}`,V])),D=ent(I),M=D.filter(V=>!V.hidden&&mv(V)==="toolbar"),P=D.filter(V=>!V.hidden&&mv(V)==="advanced"),A=Z_t(r==null?void 0:r.toolbarItemOrder,_,M),z=new Map(_.map(V=>[`filter:${V.id}`,V])),O=new Map(M.map(V=>[`control:${V.id}`,V]));function B(V){const{active:Z,over:X}=V;if(!X||Z.id===X.id)return;const te=String(Z.id),re=String(X.id),ie=A.findIndex(ye=>ye===te),se=A.findIndex(ye=>ye===re);if(ie===-1||se===-1)return;const le=lx(A,ie,se);C({toolbarItemOrder:le});const ae=new Set((n||[]).map(ye=>ye.id)),xe=A.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),fe=le.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),be=A.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),pe=le.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(KG(n||[],xe,fe)),g(KG(I.controls||[],be,pe))}const H=(r==null?void 0:r.toolbarWrap)??!1,R=(r==null?void 0:r.showDownloadButton)??!1,q=T.filter(U2),$=T.filter(V=>{if(U2(V))return!1;const Z=m.getDashboardInputRuntimeSlot(c,V,{sheetId:t});return(Z==null?void 0:Z.status)==="set"||(Z==null?void 0:Z.status)==="cleared"}),F=new Set([...q,...$].map(V=>V.filter.id)),U=(i==null?void 0:i.filter(V=>!F.has(V.filterId)&&GG(V)).length)??0,G=[...q,...$],Q=G.filter(V=>{const Z=m.hydrateAuthoredDashboardInputSlot({dashboard:I,input:V,runtimeValues:c,target:{sheetId:t}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"&&GG(Z.value.filterValue)}).length,W=a?Object.values(a).reduce((V,Z)=>V+((Z==null?void 0:Z.length)??0),0):0,L=U+Q+W+d,K=G.some(V=>V.forceSelection),Y=()=>{w([]),G.forEach(V=>{p(V,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([V,Z])=>{Z==null||Z.forEach(X=>{f(V,X.filterId)})})};return!_.length&&!M.length&&!P.length&&!R&&L===0?null:l.jsx("div",{className:"z-20 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(dC,{sensors:j,collisionDetection:lC,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",H?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(fC,{items:A,strategy:Kz,children:l.jsx(qF,{className:"gap-3 pr-0",wrap:H,children:A.map(V=>{const Z=z.get(V);if(Z){const te=E.get(V),re=te&&U2(te),ie=re&&te.definitionOrigin==="dashboardFilter";return l.jsx(K_t,{filter:Z,isEditing:o,storageOptions:re?{storageTarget:"dashboardInput",dashboardInput:te,sheetId:t??void 0}:void 0,inputVariableName:re?te.variableName:void 0,isDashboardFilterReference:ie,onUpdateFilter:re?(se,le)=>{S(te.id,se,le)}:void 0,onRemoveFilter:re?()=>{if(te.definitionOrigin==="dashboardFilter"){x(Z.id);return}w((i||[]).filter(se=>se.filterId!==Z.id)),b(te.id)}:void 0},V)}const X=O.get(V);return X?l.jsx(Y_t,{control:X,value:s==null?void 0:s[X.id],isEditing:o,onChange:te=>y(X.id,te)},V):null})})}),P.length>0&&l.jsx(pde,{title:"",controls:P,values:s,onChange:(V,Z)=>y(V.id,Z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),L>0&&l.jsxs("button",{type:"button",onClick:Y,"aria-label":K?"Reset filters":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Me.X,{className:"h-3 w-3"}),K?"Reset filters":"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:L})]}),R&&l.jsx("div",{className:m.cn(L>0?"ml-1.5":"ml-auto"),children:l.jsx(Fxe,{})})]})})})}function Lxe(){var J,ne;const{showAssistant:e,tokenProps:t,renderMode:n}=Et(),r=W_t((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:o}=$m(),s=(ne=o==null?void 0:o.cardDisplay)==null?void 0:ne.mode,i=gf(s),a=dee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Svt({initialPosition:"bottom-right"}),y=Ah(ee=>ee.setFullscreen),C=Ah(ee=>ee.setPanelOpen),w=Ah(ee=>ee.setContainer),N=eJ("dashboard"),S=tJ(),j=nJ("dashboard"),I=N.isOpen,k=S==="dashboard",T=m.useDashboardStore(ee=>ee.isVisualEditing),_=m.useDashboardStore(ee=>ee.themeStyle),E=Ou(),D=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.sheets}),M=m.useDashboardStore(ee=>ee.showFilters),P=m.useDashboardStore(ee=>ee.isDashboardEditing),A=m.useDashboardStore(ee=>ee.selectedSheetId),z=D==null?void 0:D.find(ee=>ee.id===A),O=m.useDashboardStore(ee=>{var ue,ge,_e;return(_e=(ge=(ue=ee.dashboard)==null?void 0:ue.sheets)==null?void 0:ge.find(Te=>Te.id===ee.selectedSheetId))==null?void 0:_e.kind}),B=m.useDashboardStore(ee=>{var ue,ge;return((ge=(ue=ee.dashboard)==null?void 0:ue.summary)==null?void 0:ge.position)||"top"}),H=O==="document",R=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.id}),{getDefaultSheetId:q,setDefaultSheetId:$,clearDefaultSheetId:F}=$Y(R),[U,G]=v.useState(null),{setSelectedSheetId:Q,setSheetTitle:W,addSheet:L,setSheets:K,duplicateSheet:Y}=m.useDashboardActions();R_t(u);const{setActiveAssistantType:V}=m.useAIActions();v.useEffect(()=>{if(R){const ee=q();G(ee)}},[R,q]),v.useEffect(()=>{I?V("dashboard"):S==="dashboard"&&y(null)},[I,V,S,y]),v.useEffect(()=>{var ee;I||(ee=c.current)==null||ee.resize(0)},[I]);function Z(ee){var ue,ge;ee?((ue=c.current)==null||ue.resize(40),C("dashboard",!0),y("dashboard"),V("dashboard")):(C("dashboard",!1),y(null),(ge=c.current)==null||ge.resize(0),V(null))}function X(ee="dashboard"){const ue={id:ut.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:m.createDefaultDocumentDefinition()}:{}};L(ue),Q(ue.id)}function te(ee){const ue=Y(ee);ue&&(et.success("Sheet duplicated"),requestAnimationFrame(()=>{var _e;const ge=(_e=d.current)==null?void 0:_e.querySelector(`[data-sheet-id="${ue}"]`);ge==null||ge.focus(),ge==null||ge.scrollIntoView({block:"nearest",inline:"nearest"})}))}function re(ee,ue){if(!R)return;U===ee?(F(),G(null),et.success("Default sheet cleared")):($(ee),G(ee),et.success(`"${ue}" set as default sheet`))}function ie(ee){var ue;ee<1?(C("dashboard",!1),y(null),V(null),(ue=c.current)==null||ue.resize(0)):(I||C("dashboard",!0),V("dashboard"))}function se(){return(_==null?void 0:_.canvasTheme)==="muted"||!(_!=null&&_.canvasTheme)?"hsl(var(--semaphor-muted))":(_==null?void 0:_.canvasTheme)==="clear"?"":_==null?void 0:_.canvasTheme}const le=(ee,ue)=>{ee.dataTransfer.setData("tabIndex",ue.toString())},ae=ee=>{ee.preventDefault()},xe=(ee,ue)=>{const ge=ee.dataTransfer.getData("tabIndex");if(ge===ue.toString())return;const _e=Array.from(D||[]),[Te]=_e.splice(parseInt(ge),1);_e.splice(ue,0,Te),K(_e)},fe=r===!0&&!i&&!I&&!T&&!M;function be(){if(D&&D.length>1||P)return l.jsx("div",{className:"relative flex w-full items-stretch",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{ref:d,className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((ee,ue)=>{const ge=A===ee.id,_e=U===ee.id;return l.jsxs("div",{className:"relative flex shrink-0 items-center",children:[l.jsxs(m.TabsTrigger,{"data-sheet-id":ee.id,draggable:!0,onDragStart:Te=>le(Te,ue),onDragOver:ae,onDrop:Te=>xe(Te,ue),onClick:()=>Q(ee.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none",P&&ge&&"pr-9","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ee.id,children:[ee.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Kj,{enabled:P&&ge,text:ee.title,onSave:Te=>W(ee.id,Te),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":_e?"Clear default sheet":"Set as default sheet",title:_e?"Clear default sheet":"Set as default sheet",onClick:Te=>{Te.stopPropagation(),re(ee.id,ee.title||"Sheet")},onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Te.stopPropagation(),re(ee.id,ee.title||"Sheet"))},className:m.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ge||_e?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(VZ,{className:m.cn("h-3 w-3 transition-colors",_e?"fill-current text-amber-500":"text-muted-foreground")})})]}),P&&ge&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":`Sheet actions for ${ee.title||"Sheet"}`,className:"absolute right-2 inline-flex h-4 w-4 items-center justify-center rounded-[4px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground",children:l.jsx(ei,{className:"h-3 w-3"})})}),l.jsxs(mo,{align:"start",className:"w-44",children:[l.jsxs(mn,{onSelect:()=>te(ee.id),children:[l.jsx(zd,{className:"h-4 w-4"}),"Duplicate sheet"]}),l.jsxs(mn,{disabled:D.length<=1,onSelect:()=>h(!0),children:[l.jsx(_a,{className:"h-4 w-4"}),"Delete sheet"]})]})]})]},ee.id)}),P&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(mo,{align:"start",className:"w-48",children:[l.jsxs(mn,{onSelect:()=>X("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(mn,{onSelect:()=>X("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function pe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ee=>l.jsx(m.TabsContent,{style:{backgroundColor:se(),...E.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(HK,{sheet:ee})},ee.id))})}function ye(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",_==null?void 0:_.dashboardTabsContainer),onValueChange:ee=>{Q(ee)},value:A||void 0,children:[be(),B==="top"&&!H&&l.jsx(sF,{}),A&&!H&&l.jsx(tIt,{}),H?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:pe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:pe()}),B==="bottom"&&!H&&l.jsx(sF,{}),l.jsx(Nvt,{open:f,setOpen:h})]})}const ce=v.useCallback(ee=>{w("dashboard",ee)},[w]);return D?a&&A&&!H?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&H&&z?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(HK,{sheet:z})}):l.jsxs(l.Fragment,{children:[l.jsx(B_t,{}),l.jsx(U_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Ige,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GF,{children:ye()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Cvt,{open:I,onTabClick:Z,withHandle:!0,disabled:!I}),l.jsx(GF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ie,defaultSize:I?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(M_t,{open:I,setOpen:Z,isFullscreen:k,onFullscreenChange:ee=>y(ee?"dashboard":null),fullscreenContainer:j})})})]})]}),l.jsx("div",{ref:ce,className:m.cn("absolute inset-0",!k&&"pointer-events-none")}),fe&&l.jsx("div",{className:m.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:b(),children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{g.current||Z(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Pve,{className:"h-5 w-5"})})})]})]}):null}const $xe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ig.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(tx,{...u,ref:d,className:a,style:c,children:i})}));$xe.displayName="AppearanceProvider";const zxe=v.createContext({openBrandStudioPreview:()=>{}}),nIt=zxe.Provider;function rIt(){return v.useContext(zxe)}function oIt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ig.normalizeTheme(t),[s,i]=v.useState(()=>sIt(n)||o),a=v.useCallback(u=>{const d=ig.normalizeTheme(u);iIt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ig.ThemeProviderContext.Provider,{...r,value:c,children:e})}function sIt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ig.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function iIt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const aIt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function tB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=Et(),s=Kv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),C=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=Kn({queryKey:WX({resourceType:ho.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:C,appearance:i})},[i,C]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:C,appearance:w.data})},[w.data,C]);const N=(x==null?void 0:x.scopeKey)===C?x.appearance:null,S=i!==void 0?i:w.data!==void 0?w.data:N,j=v.useMemo(()=>Em.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(oIt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(nIt,{value:T,children:l.jsx($xe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(aIt,{appearance:d,onDraftChange:b,onSave:M=>{p(M),b(M),f(M)},onCancel:k})})})]})})})})}function Bxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(HX.Provider,{value:r,children:l.jsx(tT,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function lIt(e=2e3,t=500){const n=M0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function nB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=lIt(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function Vxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:e,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"dashboard",componentId:e.id}),l.jsx(tB,{appearance:e.appearance,children:l.jsx(Bxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(i5,{...e,type:"dashboard",children:l.jsx(Lxe,{})})})})})]})})})}function cIt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function uIt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=$m(),r=gf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=m.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=cIt([t,s,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Ci,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(V$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Me.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function dIt(){const e=m.useDashboardStore(r=>r.dashboard.filters),t=m.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:m.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(uIt,{filter:r}),l.jsx(GI,{filter:r})]},r.id))}):null}function fIt(){var s;const e=m.useDashboardStore(i=>i.dashboard),t=m.useDashboardStore(i=>i.selectedSheetId),n=m.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=m.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(dIt,{}),l.jsx(Lxe,{})]})})}const hIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-DfbxzqR2.cjs"))),mIt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-CiuJ6CVM.cjs"))),pIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-CkBPnsxB.cjs")));function gIt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(a=>a.isVisualEditing),o=m.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:n,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"surfboard",componentId:n.id}),l.jsxs(tB,{appearance:s,children:[l.jsx(BCe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(Bxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(pIt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(hIt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(i5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(mIt,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(fIt,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Hxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),bIt=Bi.getSupportedCurrencyCodes(),xIt=bIt.filter(e=>!Hxe.has(e)),qxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],ZG="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=qxe.find(n=>n.value===e))==null?void 0:t.label)??e}function yIt(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(m.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(m.SelectTrigger,{id:e,size:"xs",children:l.jsx(m.SelectValue,{children:c})}),l.jsxs(m.SelectContent,{children:[l.jsx(m.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),qxe.map(u=>l.jsx(m.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function vIt({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Bi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,p={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:p,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,C=G2(_=>$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateStyle:_},calendar:{tz:"UTC"}})}).text),w=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(m.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:s,size:"xs",children:l.jsx(m.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:yIt(e.locale)})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(m.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(m.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:C,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:w,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(m.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:i,size:"xs",children:l.jsx(m.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Hxe].map(_=>l.jsx(m.SelectItem,{value:_,children:_},_)),xIt.map(_=>l.jsx(m.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function Uxe(e){return uO.add(e),()=>{uO.delete(e)}}function rB(){uO.forEach(e=>{e()})}var wIt=Object.defineProperty,CIt=(e,t,n)=>t in e?wIt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y1=(e,t,n)=>CIt(e,typeof t!="symbol"?t+"":t,n);const SIt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},NIt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},jIt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function kIt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Wxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const _It={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Wxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},IIt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},TIt={stringify:e=>e,parse:e=>e},Z2={string:TIt,number:IIt,boolean:SIt,function:NIt,method:_It,json:jIt},sy=Symbol.for("r2wc.render"),v1=Symbol.for("r2wc.connected"),Kf=Symbol.for("r2wc.context"),Di=Symbol.for("r2wc.props");function EIt(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=kIt(p);d[p]=g,f[g]=p}for(const p of a)u[p]=Array.isArray(t.events)?{}:t.events[p];class h extends HTMLElement{constructor(){super(),y1(this,s,!0),y1(this,o),y1(this,r,{}),y1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Di].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],C=y?Z2[y]:null;if(y==="method"){const w=Wxe(b);Object.defineProperty(this[Di].container,w,{enumerable:!0,configurable:!0,get(){return this[Di][w]},set(N){this[Di][w]=N,this[sy]()}}),this[Di][g]=C.parse(x,b,this)}C!=null&&C.parse&&x&&(this[Di][g]=C.parse(x,b,this))}for(const g of a)this[Di][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[v1]=!0,this[sy]()}disconnectedCallback(){this[v1]=!1,this[Kf]&&n.unmount(this[Kf]),delete this[Kf]}attributeChangedCallback(g,b,x){const y=f[g],C=c[y],w=C?Z2[C]:null;y in c&&w!=null&&w.parse&&x&&(this[Di][y]=w.parse(x,g,this),this[sy]())}[(s=v1,o=Kf,r=Di,sy)](){this[v1]&&(this[Kf]?n.update(this[Kf],this[Di]):this[Kf]=n.mount(this.container,e,this[Di]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[Di][p]},set(x){this[Di][p]=x;const y=b?Z2[b]:null;if(y!=null&&y.stringify){const C=y.stringify(x,g,this);this.getAttribute(g)!==C&&this.setAttribute(g,C)}else this[sy]()}})}return h}function DIt(e,t,n){const r=xye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function MIt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function RIt({root:e}){e.unmount()}function AIt(e,t={}){return EIt(e,t,{mount:DIt,update:MIt,unmount:RIt})}const PIt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},FIt=AIt(Vxe,{props:PIt}),OIt=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(g4,{context:t})," "]})});var Kxe="Toggle",Gxe=oe.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=m.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Kxe});return l.jsx(m.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:m.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Gxe.displayName=Kxe;var Yxe=Gxe;const LIt=m.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Zxe=oe.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Yxe,{ref:o,className:m.cn(LIt({variant:t,size:n,className:e})),...r}));Zxe.displayName=Yxe.displayName;function oB(){var c,u;const e=m.useEditorStore(d=>d.card),t=m.useEditorStore(d=>d.frame),n=v.useMemo(()=>tt.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=kf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=tt.resolveMultiInputType(n,o),i=v.useMemo(()=>tt.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:tt.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:tt.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Xxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const p=h??t;u.current=!0,a.current=p,s(p)},[t]);return{value:o,onChange:f,flush:d}}const $It=300;function zIt({onExpand:e},t){const n=m.useEditorStore(w=>w.card.sql),r=m.useEditorStore(w=>w.sqlGen),o=m.useEditorStore(w=>w.card),s=oB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=m.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Cb(u),f=Br(),h=v.useRef(d);h.current=d;const p=v.useRef(r);p.current=r;const g=v.useCallback(w=>{i(w)},[i]),{value:b,onChange:x,flush:y}=Xxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:$It});v.useEffect(()=>Uxe(y),[y]);function C(w){x(w),m.isObjectEmpty(p.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(m.CodeEditor,{ref:t,value:b??"",onValueChange:C,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:w=>{w.key==="Enter"&&w.shiftKey&&(w.preventDefault(),rB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const BIt=v.forwardRef(zIt),VIt=300;function HIt(e,t){const n=m.useEditorStore(g=>g.card.python),r=m.useEditorStore(g=>g.card),o=oB(),{setCardPython:s,setRunSql:i}=m.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Cb(a),u=Br(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:p}=Xxe({storeValue:n,defaultValue:tt.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:VIt});return v.useEffect(()=>Uxe(p),[p]),l.jsx(m.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),rB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const qIt=v.forwardRef(HIt),Qxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),UIt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),WIt=Array.from(Qxe).join(", "),KIt=3,GIt="Self-heal",YIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function ZIt({card:e}){var $,F,U,G,Q;const t=xl(),[n,r]=v.useState({}),{authToken:o}=Et(),s=m.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Ww(i),[i]),c=m.useEditorStore(W=>W.frame),u=m.useEditorStore(W=>W.inlineFilterValuesMap[e.id]),d=m.useEditorStore(W=>W.actions.setCardInlineFilterValue),f=m.useEditorStore(W=>W.actions.removeCardInlineFilterValue),h=e,{getCard:p,manifest:g}=kf((($=h.customCardPreferences)==null?void 0:$.url)||""),b=(F=g==null?void 0:g.visuals)==null?void 0:F.find(W=>{var L;return W.name===((L=h.customCardPreferences)==null?void 0:L.componentName)}),x=tt.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>tt.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),C=v.useMemo(()=>{const W=y.findIndex(L=>(L==null?void 0:L.id)===e.id);return W<0?-1:tt.getSlotIndexForCard(e,W)},[y,e]),w=v.useMemo(()=>x!=="multiple"||C<0?e.type:tt.getEffectiveCardTypeForSlot(e,C,b==null?void 0:b.slots)??e.type,[x,C,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,x]),{data:S,effectiveCardConfig:j}=Cb(N),I=m.useInteractionStore(W=>W.interactionStates),k=m.useDashboardStore(W=>{var L;return(L=W.dashboard)==null?void 0:L.id}),T=m.useDashboardStore(W=>W.dashboard.filters),_=m.useDashboardStore(W=>W.filterValues),E=m.useDashboardStore(W=>W.selectedSheetId),D=v.useMemo(()=>q$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:W=>d(e.id,W),removeInlineFilterValue:W=>f(e.id,W)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:P}=v.useMemo(()=>v_({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((W,L)=>{const K=tt.normalizeMultiInputPayload(L);r(Y=>({...Y,[W]:K}))},[]),z=(U=h.customCardPreferences)==null?void 0:U.componentName,O=z?p(z):null,B=Uj((G=h.customCardPreferences)==null?void 0:G.settings,h),H=v.useMemo(()=>tt.buildSlotOrderedCards(y),[y]),R=v.useMemo(()=>H.map((W,L)=>tt.getEffectiveCardTypeForSlot(W,L,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),q=v.useMemo(()=>K$(x==="multiple"?W$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,x,t]);return z?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&x==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Due({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:q,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D}),O&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((W,L)=>{if(!W)return null;const K=tt.getSlotIndexForCard(W,L),Y=tt.getEffectiveCardTypeForSlot(W,K,b==null?void 0:b.slots);return l.jsx(p$,{onDataChange:A,card:W,effectiveCardType:Y},`${W.id}-${K}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...U$({configCard:h,slotOrderedCards:H,slotTypes:R,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:q})})})]})]},(Q=h.customCardPreferences)==null?void 0:Q.componentName)}):null}const XIt=v.memo(ZIt),QIt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Jxe=["PageUp","PageDown"],eye=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],tye={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},px="Slider",[dO,JIt,eTt]=m.createCollection(px),[nye]=m.createContextScope(px,[eTt]),[tTt,ZT]=nye(px),rye=oe.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=oe.useRef(new Set),y=oe.useRef(0),w=i==="horizontal"?nTt:rTt,[N=[],S]=m.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...x.current][y.current])==null||M.focus(),f(E)}}),j=oe.useRef(N);function I(E){const D=lTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const P=fTt(s),A=hTt(Math.round((E-r)/s)*s+r,P),z=m.clamp(A,[r,o]);S((O=[])=>{const B=iTt(O,z,D);if(dTt(B,c*s)){y.current=B.indexOf(z);const H=String(B)!==String(O);return H&&M&&h(B),H?B:O}else return O})}return l.jsx(tTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:p,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Jxe.includes(E.key)||E.shiftKey&&eye.includes(E.key)?10:1,z=y.current,O=N[z],B=s*A*D;_(O+B,z,{commit:!0})}}})})})})});rye.displayName=px;var[oye,sye]=nye(px,{startEdge:"left",endEdge:"right",size:"width",direction:1}),nTt=oe.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=oe.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=oe.useRef(void 0),b=m.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function C(w){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=sB(S,y?[n,r]:[r,n]);return g.current=N,I(w-N.left)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(iye,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const N=C(w.clientX);i==null||i(N)},onSlideMove:w=>{const N=C(w.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const S=tye[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:S?-1:1})}})})}),rTt=oe.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=oe.useRef(null),f=m.useComposedRefs(t,d),h=oe.useRef(void 0),p=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=sB(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(iye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=tye[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),iye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=ZT(px,n);return l.jsx(m.Primitive.span,{...u,ref:t,onKeyDown:m.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Jxe.concat(eye).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),aye="SliderTrack",lye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(aye,n);return l.jsx(m.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});lye.displayName=aye;var fO="SliderRange",cye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(fO,n),s=sye(fO,n),i=oe.useRef(null),a=m.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>fye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});cye.displayName=fO;var hO="SliderThumb",uye=oe.forwardRef((e,t)=>{const n=JIt(e.__scopeSlider),[r,o]=oe.useState(null),s=m.useComposedRefs(t,a=>o(a)),i=oe.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(oTt,{...e,ref:s,index:i})}),oTt=oe.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=ZT(hO,n),a=sye(hO,n),[c,u]=oe.useState(null),d=m.useComposedRefs(t,C=>u(C)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:fye(p,i.min,i.max),b=aTt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?cTt(x,g,a.direction):0;return oe.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(dO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(dye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});uye.displayName=hO;var sTt="RadioBubbleInput",dye=oe.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=oe.useRef(null),s=m.useComposedRefs(o,r),i=m.usePrevious(t);return oe.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});dye.displayName=sTt;function iTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function fye(e,t,n){const s=100/(n-t)*(e-t);return m.clamp(s,[0,100])}function aTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function lTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function cTt(e,t,n){const r=e/2,s=sB([0,50],[0,r]);return(r-s(t)*n)*n}function uTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function dTt(e,t){if(t>0){const n=uTt(e);return Math.min(...n)>=t}return!0}function sB(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function fTt(e){return(String(e).split(".")[1]||"").length}function hTt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var hye=rye,mTt=lye,pTt=cye,gTt=uye;const mye=oe.forwardRef(({className:e,...t},n)=>l.jsxs(hye,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(pTt,{className:"absolute h-full bg-primary"})}),l.jsx(gTt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));mye.displayName=hye.displayName;exports.Accordion=a4;exports.AccordionContent=kv;exports.AccordionItem=Nv;exports.AccordionTrigger=jv;exports.AddDataPicker=X4;exports.AggregateTable=NI;exports.Alert=lL;exports.AlertDescription=cL;exports.AlertDialog=mf;exports.AlertDialogAction=Pu;exports.AlertDialogCancel=Fu;exports.AlertDialogContent=Eu;exports.AlertDialogDescription=Au;exports.AlertDialogFooter=Mu;exports.AlertDialogHeader=Du;exports.AlertDialogTitle=Ru;exports.AlertDialogTrigger=a1e;exports.AlertTitle=Ite;exports.ArrowDown=rs;exports.ArrowDownIcon=HQe;exports.ArrowLeft=Xv;exports.ArrowRight=Qv;exports.ArrowUp=vs;exports.ArrowUpIcon=UQe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Axe;exports.AxisConfigurator=Km;exports.BackgroundRunPill=wut;exports.Badge=xi;exports.Bell=N1;exports.BookType=uZ;exports.BriefingAuthor=dhe;exports.BriefingAuthorDialog=fhe;exports.BriefingUiCapabilitiesBoundary=Hut;exports.BriefingUiCapabilitiesProvider=dT;exports.BriefingsApiError=eC;exports.BulletChartIcon=kxe;exports.CSS=Xi;exports.CalculatedFieldEditor=Vme;exports.Calculator=fZ;exports.Calendar=Ka;exports.CalendarClock=EO;exports.Card=SN;exports.CardContent=TO;exports.CardHeader=IO;exports.CardSummary=fF;exports.CardTitle=gb;exports.ChartArea=SR;exports.ChartColumnIncreasing=mZ;exports.ChartColumnStacked=pZ;exports.ChartJsVisual=Bw;exports.ChartLine=gZ;exports.ChartNoAxesGantt=xZ;exports.ChartPie=yZ;exports.ChartScatter=vZ;exports.ChatInputWithContext=Q4;exports.Checkbox=In;exports.ChevronLeft=Am;exports.ChevronsUpDown=SZ;exports.Circle=DO;exports.CircleAlert=ja;exports.CircleCheck=NZ;exports.CircleHelp=jZ;exports.Clock=kZ;exports.CodeHighlighter=$d;exports.CodeXml=j1;exports.Collapsible=Nu;exports.CollapsibleContent=ku;exports.CollapsibleTrigger=ju;exports.ColorField=ha;exports.Command=wT;exports.CommandEmpty=ST;exports.CommandGroup=NT;exports.CommandInput=Xz;exports.CommandItem=jT;exports.CommandList=CT;exports.CommandSeparator=ame;exports.ComparisonMetadataBadge=Xoe;exports.Container=i5;exports.ControlDefaultValueEditor=fpe;exports.ControlDefinitionOptionsEditor=dpe;exports.ControlIdInput=ape;exports.ControlVisibilitySettings=abt;exports.Copy=zd;exports.CopyButton=Ld;exports.CopyPlus=NR;exports.Cross2Icon=YQe;exports.CustomFilterPopover=V$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Kre;exports.Dashboard=Vxe;exports.DashboardCard=ghe;exports.DashboardCreateDialogBase=yQ;exports.DashboardExportDialog=Pxe;exports.DashboardPlus=gIt;exports.DashboardWC=FIt;exports.DataTableConditionalFormattingSettings=tge;exports.DataTablePagination=pI;exports.Database=Go;exports.DateRangePicker=L$;exports.DefaultChatTransport=B4;exports.Dialog=No;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=il;exports.DialogHeader=Es;exports.DialogTitle=go;exports.DialogTrigger=gQ;exports.DisplayFormatPreferencesFields=vIt;exports.DisplayPreferencesProvider=tT;exports.DndContext=dC;exports.Donut=_Z;exports.Download=_u;exports.DownloadPdf=Fxe;exports.DragOverlay=Khe;exports.DropdownMenu=Co;exports.DropdownMenuCheckboxItem=sd;exports.DropdownMenuContent=mo;exports.DropdownMenuItem=mn;exports.DropdownMenuLabel=Ca;exports.DropdownMenuRadioGroup=mCe;exports.DropdownMenuRadioItem=VX;exports.DropdownMenuSeparator=Ia;exports.DropdownMenuSub=XO;exports.DropdownMenuSubContent=Zk;exports.DropdownMenuSubTrigger=Yk;exports.DropdownMenuTrigger=So;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Kj;exports.EditableText=Ci;exports.EditorCustomVisual=XIt;exports.Ellipsis=ei;exports.EllipsisVertical=Pm;exports.ErrorBoundary=ki;exports.ExportError=Rb;exports.ExternalLink=Bd;exports.EyeOff=Uk;exports.Fallback=JI;exports.FallbackVisual=Xw;exports.FeedbackCategory=df;exports.FeedbackDialog=Fv;exports.FieldsList=g4;exports.FieldsSection=OIt;exports.FileCode=IZ;exports.FileText=ti;exports.Filter=Vd;exports.FilterComponent=GI;exports.FilterInfo=lF;exports.FilterableFieldsPanel=qme;exports.Grid3x3=jR;exports.GripVertical=Iu;exports.HEATMAP_PRESET_PALETTES=$A;exports.Hash=bb;exports.House=TZ;exports.HoverCard=Qm;exports.HoverCardContent=wu;exports.HoverCardTrigger=Qd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Qxe;exports.INLINE_ALLOWED_TOOL_LIST=WIt;exports.INLINE_BLOCKED_MUTATING_TOOLS=UIt;exports.IconButton=su;exports.IconForFieldType=cN;exports.Inbox=RO;exports.InfoHover=cz;exports.InlineFilterBar=lde;exports.KPICard=of;exports.KeyboardSensor=cC;exports.Layers=Om;exports.Link=AO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=KIt;exports.Map=RZ;exports.Markdown=Rz;exports.MatrixTableVisual=SI;exports.MdStackedLineChart=Nxe;exports.MultiInputEmptyRenderer=p$;exports.PanelResizeHandle=VT;exports.Pause=AZ;exports.PenLine=IR;exports.Pencil=TR;exports.PendingMessagesDisplay=mxe;exports.PersistedDynamicVisual=eT;exports.PiChartPolar=vxe;exports.Pin=FZ;exports.PinOff=PZ;exports.PivotTableTanstack=ex;exports.Placeholders=Tge;exports.Play=OZ;exports.Plus=Mr;exports.PointerSensor=ax;exports.Progress=K4;exports.PythonEditor=qIt;exports.RECOVERABLE_SQL_ERROR_CODES=YIt;exports.Radar=LZ;exports.RadioGroup=yu;exports.RadioGroupItem=Xs;exports.RefreshCw=ka;exports.ResizableHandle=wvt;exports.ResizablePanel=GF;exports.ResizablePanelGroup=Ige;exports.ResourceEditDialog=ZQ;exports.ResourceType=ho;exports.Rows3=$Z;exports.RunCompletionBanner=Cut;exports.SELF_HEAL_TIMELINE_STEP=GIt;exports.SeedQuestions=Jbe;exports.SemaphorContext=Wv;exports.SemaphorContextProvider=wO;exports.SemaphorQueryClient=LY;exports.SemaphorReadyIndicator=nB;exports.SemaphorStyleWrapper=tx;exports.Send=FO;exports.SendHorizontal=zZ;exports.Settings=OO;exports.Settings2=ff;exports.Share2=BZ;exports.ShareDialog=YQ;exports.Sheet=p3;exports.SheetContent=gI;exports.SheetDescription=xI;exports.SheetHeader=Boe;exports.SheetTitle=bI;exports.SheetTrigger=g4e;exports.Slider=mye;exports.SortableContext=fC;exports.Sparkles=k0;exports.SqlEditor=BIt;exports.Square=$O;exports.SquarePen=LO;exports.Star=VZ;exports.StructuralParticipantSelector=lpe;exports.SummaryCard=sF;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Fd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ga;exports.TableBody=Xd;exports.TableCell=Wn;exports.TableColumnVisibilitySettings=Hpe;exports.TableHead=vo;exports.TableHeader=Xm;exports.TablePresentationSettings=Upe;exports.TableRow=Fr;exports.TableSkeleton=dz;exports.TableVisual=Jd;exports.Tag=HZ;exports.TbChartBubble=wxe;exports.TbChartFunnel=Cxe;exports.TbChartTreemap=Sxe;exports.TextCard=sb;exports.Textarea=Bm;exports.TiSortNumerically=jxe;exports.Toggle=Zxe;exports.Tornado=qZ;exports.Trash2=_a;exports.TriangleAlert=Fo;exports.TypeGlyph=oC;exports.UXProvider=tB;exports.Undo2=UZ;exports.User=BO;exports.Users=Wk;exports.UsersRound=VO;exports.VisualErrorState=Wue;exports.Zap=ER;exports.applyBriefingFormPatch=pv;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Xre;exports.arrayMove=lx;exports.briefingFormDraftToCreateRequest=pF;exports.briefingFormDraftToUpdateRequest=Ude;exports.briefingToFormDraft=og;exports.briefingTone=Er;exports.buildCardControlUsageById=cbt;exports.buildCustomCardTheme=Ww;exports.buildDashboardControlUsageById=lbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=ppe;exports.buildFilterFieldMeta=pO;exports.buildFilterSemanticContext=gO;exports.buildInlineFilterNodes=q$;exports.buildMultiInputCustomVisualProps=U$;exports.buildMultiInputTemporalPresentationInputs=W$;exports.calculateCardFilterValues=y_;exports.calculateContextAwareFilters=v_;exports.calculateFieldState=e3;exports.canEditLocalCalculatedFields=f4;exports.canUserAccessVisuals=hNe;exports.canUserCreateDashboards=QQ;exports.canUserEdit=uNe;exports.canUserManageDashboards=fNe;exports.canUserManageGroups=mNe;exports.canUserUseFilters=dNe;exports.cancelBriefingPreviewRun=Rde;exports.cancelBriefingRun=Pde;exports.cancelExport=P$e;exports.chartSupportsDataLabels=qne;exports.chartSupportsLegend=Vne;exports.chartTypes=YT;exports.cleanupKpiMetricComparisonMode=gme;exports.cloneLinkedFrameWithSourceMapping=ytt;exports.closestCenter=lC;exports.commitSharedCalculatedFields=th;exports.createAssistantConversationId=Wp;exports.createAssistantRequestId=Xbe;exports.createBriefing=jde;exports.createBriefingFormDraft=mF;exports.createChartConfig=Db;exports.createCustomVisualTemporalBucketFormatter=K$;exports.createDashboardControlInputFromControl=l0t;exports.createExport=boe;exports.currencyPresentationTargetKey=va;exports.dedup=gjt;exports.dedupeContextEntities=Bz;exports.deleteBriefing=Ide;exports.deleteBriefingRun=Fde;exports.diagnoseCurrencyPresentationBindings=Q0e;exports.doesStoredFilterMatchField=Ag;exports.downloadDocumentPdf=rL;exports.downloadPdf=ste;exports.extractTableMetadata=n4;exports.fieldAlreadyExists=Jre;exports.flexRender=vi;exports.flushPendingEditorDrafts=rB;exports.formatDisplayFormula=opt;exports.formatFileSize=L$e;exports.getAutoDetectedChartIcon=Gkt;exports.getBriefing=Nde;exports.getBriefingArtifact=Nnt;exports.getBriefingEvidence=jnt;exports.getBriefingPreviewRun=Mde;exports.getBriefingRun=Ade;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=SDe;exports.getChartIconByType=Ykt;exports.getColorForValue=JR;exports.getCoreRowModel=fI;exports.getDefaultAxisConfig=oA;exports.getDefaultChartColors=Wm;exports.getDefaultDataLabelsConfig=Cw;exports.getDefaultLegendConfig=FL;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=jw;exports.getDocumentSectionEditorCard=Bgt;exports.getDocumentSheetDashboardInputs=dx;exports.getDownloadUrl=A$e;exports.getEntityIcon=Ok;exports.getErrorMessage=Obe;exports.getExportStatus=R$e;exports.getExports=M$e;exports.getExpressionFieldKind=af;exports.getFieldExpressionAnnotation=r4;exports.getFilterCount=ek;exports.getFilterSourceDatabase=pY;exports.getGranularityOptionsForFieldType=ipe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=cI;exports.getMetricDisplayLabel=$3e;exports.getNewField=ooe;exports.getPaginationRowModel=hI;exports.getRoleBasedDisplayOverrides=XQ;exports.getRunningTotalOrderByCandidates=_mt;exports.getSelectedDateFilterColumn=uue;exports.getSemanticDomainLabel=hxe;exports.getSortedRowModel=Loe;exports.getTableConditionalFormattingColumnOptions=Ype;exports.getTableOutputColumnOptions=Zpe;exports.handleAggregationChange=cF;exports.handleAggregationLabelChange=ide;exports.hasFlatTableTotalsBehavior=Um;exports.hasMatrixResultData=_w;exports.horizontalListSortingStrategy=Kz;exports.inferSemanticDomainIdFromSelectedEntities=Fk;exports.isActiveBriefingRunStatus=sk;exports.isCardSummaryVisibleOnCard=G$;exports.isCurrencyPresentationControl=Z0e;exports.isDefaultColor=LTe;exports.isDevPaginationSwitchableCard=poe;exports.isEligibleFlatTableTotalsCard=hw;exports.isExportComplete=O$e;exports.isExportInProgress=F$e;exports.isInAiScopeArray=pjt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=jmt;exports.isPresentationCurrencyBinding=Yv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=soe;exports.isStructuralControlBinding=Y0e;exports.isSubtotalEnabledAggregateTable=t4;exports.isSupportedDocumentTableCardType=Vgt;exports.isTableType=cDe;exports.isTerminalBriefingRunStatus=ok;exports.lastAssistantMessageIsCompleteWithToolCalls=Rbe;exports.listBriefingRuns=Snt;exports.listBriefingTenantSummaries=Cnt;exports.listBriefings=wnt;exports.merge=sc;exports.mergeAxisConfig=sA;exports.normalizeConditionalFormatting=z5;exports.normalizeContextFormatMode=Eee;exports.pauseBriefing=kde;exports.pivotData=gw;exports.polishBriefingText=Ode;exports.prepareFeedbackData=GT;exports.previewBriefingPlan=Ede;exports.remarkGfm=Oz;exports.removeFromScopeArray=bjt;exports.resolveCurrencyPresentationTargetFormat=Aee;exports.resolveDashboardBriefingsVisibility=hhe;exports.resolveDashboardControlsVisibility=xNe;exports.resolveDashboardTitleEditability=bNe;exports.resolveDomainCalculatedFieldForEdit=Jpt;exports.resolveMatrixCardMeasureInstances=qk;exports.resolvePendingPivotTableResultState=h$e;exports.resolveTablePresentationStyle=S3;exports.resumeBriefing=_de;exports.runBriefingNow=Tde;exports.runBriefingPreview=Dde;exports.sanitizeAIScope=Fbe;exports.saveCalculatedFieldToCardScope=zF;exports.saveCalculatedFieldToSharedScope=Hme;exports.saveCalculatedFieldToSheetScope=BF;exports.seedSemanticMetricFormatDefaults=xme;exports.setTableColumnVisibility=yoe;exports.setupEditorWithCard=P_;exports.showAllTableColumns=z$e;exports.showJoinRequiredNotification=Qre;exports.sortByColumnsToSortState=ase;exports.sortStateToSortByColumns=lse;exports.sortableKeyboardCoordinates=Yz;exports.supportsLiveNumericPresentation=Gv;exports.supportsMetricTransformForMetric=bme;exports.supportsTableConditionalFormatting=Wpe;exports.toEntityArray=rl;exports.ue=et;exports.updateBriefing=rT;exports.useActiveExports=NNe;exports.useActiveToolStatus=gxe;exports.useAddFrameWithFreshSemanticExecutionPayload=lz;exports.useAddNewFrame=She;exports.useAssistantContainer=nJ;exports.useAssistantContextEntities=fT;exports.useAssistantLayoutStore=Ah;exports.useAssistantPanel=eJ;exports.useAssistantProfile=Qbe;exports.useAutoSubmitQueue=pxe;exports.useBrandStudioPreview=rIt;exports.useBriefingRunPolling=bF;exports.useBriefingUiCapabilities=mhe;exports.useCalendarContext=Z3e;exports.useCard=r$e;exports.useCardNumericPresentation=Pa;exports.useCardSummary=Y$;exports.useChartNumericPresentation=Mb;exports.useChat=Pbe;exports.useColumns=Qz;exports.useCreateVisualWithFrame=uSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=kf;exports.useCustomVisualsQuery=B$;exports.useDashboardAppearance=Ou;exports.useDashboardById=XX;exports.useDashboardInteractionMode=nde;exports.useDashboardPreferences=$m;exports.useDashboardQuery=Kv;exports.useDashboardStructuralParticipants=gpe;exports.useDashboardSummary=Lue;exports.useDataColumns=vme;exports.useDateFilterHook=vYe;exports.useDefaultDashboardMutation=qX;exports.useDisplayPreferences=pl;exports.useDroppable=Whe;exports.useEditorAside=kT;exports.useEditorCardQuery=Cb;exports.useEffectiveEditorCardType=oB;exports.useEnsureReactGlobals=Mle;exports.useExportActions=rJ;exports.useExportStore=s_;exports.useFieldManagement=yme;exports.useFilterableFields=hme;exports.useFullscreenAssistant=tJ;exports.useGroupMembers=f1e;exports.useGroups=o5;exports.useHasDashboardId=oJ;exports.useInProgressExportsCount=jNe;exports.useJoinabilityMap=e4;exports.useManagementActions=Rm;exports.useManagementStore=Ts;exports.useMutation=Is;exports.usePivotTableConfig=Ym;exports.usePluginQuery=Cue;exports.useQuery=Kn;exports.useQueryClient=Br;exports.useReactTable=mI;exports.useResolveExistingFrameSemanticExecutionPayload=Stt;exports.useResolvedDefaultCurrency=r3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=n3;exports.useResourceManagement=JO;exports.useResourceUpdateState=QX;exports.useScopedFields=fme;exports.useSelectedVisual=F0e;exports.useSemanticDomains=G4;exports.useSemaphorContext=Et;exports.useSensor=db;exports.useSensors=gT;exports.useSortable=cx;exports.useStarredChartsStore=QIt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=Qoe;exports.useTextFilterHook=ZUe;exports.useTheme=gY;exports.useTimezone=bl;exports.useTopoJson=Nw;exports.useUnifiedUsers=r_;exports.useUpdateResource=KX;exports.useUpdateVisualMutation=dSe;exports.useUserPreferences=vQ;exports.useVisualById=Qk;exports.useVisualManagement=cSe;exports.validateBriefingFormDraft=gF;exports.validateFieldForChartType=pme;exports.verticalListSortingStrategy=Gz;