yamchart 0.10.1 → 0.10.2

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 (82) hide show
  1. package/dist/{advisor-5TJDNAY7.js → advisor-5F73GF54.js} +12 -12
  2. package/dist/{chunk-S2CH4HUZ.js → chunk-25ES7MGF.js} +4 -4
  3. package/dist/{chunk-QUIDZO5G.js → chunk-5CRXV5PQ.js} +22 -6
  4. package/dist/chunk-5CRXV5PQ.js.map +1 -0
  5. package/dist/chunk-7HWFVUGP.js +1239 -0
  6. package/dist/chunk-7HWFVUGP.js.map +1 -0
  7. package/dist/{chunk-5FHV22X2.js → chunk-PYVROL7Z.js} +4 -4
  8. package/dist/{chunk-64CI3HSY.js → chunk-UOSOZT47.js} +15 -8
  9. package/dist/{chunk-64CI3HSY.js.map → chunk-UOSOZT47.js.map} +1 -1
  10. package/dist/{chunk-ZBCQNWVN.js → chunk-WVSDQNAN.js} +5 -5
  11. package/dist/{chunk-UFDQ3C7Q.js → chunk-X3UG6T3Q.js} +257 -257
  12. package/dist/chunk-X3UG6T3Q.js.map +1 -0
  13. package/dist/{connection-utils-FEUWER5I.js → connection-utils-HNX3473B.js} +5 -5
  14. package/dist/{describe-MEP72B56.js → describe-KDGXFPDQ.js} +7 -7
  15. package/dist/{dev-H6SJZ5UA.js → dev-KOWFGDOP.js} +933 -127
  16. package/dist/dev-KOWFGDOP.js.map +1 -0
  17. package/dist/dev-supervisor-JXLVGEHP.js +43 -0
  18. package/dist/dev-supervisor-JXLVGEHP.js.map +1 -0
  19. package/dist/{dist-5DQO6L2S.js → dist-LK3ZG74Q.js} +5 -5
  20. package/dist/{dist-PPAD6KOM.js → dist-WMP7BFKP.js} +24 -2
  21. package/dist/{dist-XNCED7JW.js → dist-YB5RBWCC.js} +4 -4
  22. package/dist/index.js +65 -42
  23. package/dist/index.js.map +1 -1
  24. package/dist/{init-SECXKD5G.js → init-TJJVKMEN.js} +24 -5
  25. package/dist/init-TJJVKMEN.js.map +1 -0
  26. package/dist/public/assets/DataView-BfwnWnLH.js +9 -0
  27. package/dist/public/assets/{EventManagement-BnmeJDQl.js → EventManagement-BIkVUSCe.js} +2 -2
  28. package/dist/public/assets/ExplorePage-CeaAulqT.js +1 -0
  29. package/dist/public/assets/{LoginPage-CzaFkkjg.js → LoginPage-4WeNcdRi.js} +1 -1
  30. package/dist/public/assets/{PublicViewer-irjxqH6a.js → PublicViewer-CkW-G56D.js} +1 -1
  31. package/dist/public/assets/{SetupWizard-ConWIcmy.js → SetupWizard-CwTr3PCy.js} +1 -1
  32. package/dist/public/assets/{ShareManagement-CP4wdwLR.js → ShareManagement-DSon6CoC.js} +1 -1
  33. package/dist/public/assets/{SourceDetailView-DZS5518E.js → SourceDetailView-BA4XVKqV.js} +1 -1
  34. package/dist/public/assets/UserManagement-BWD2Ugkv.js +1 -0
  35. package/dist/public/assets/{index-C1X8RW4Z.css → index-Cb4omrVn.css} +1 -1
  36. package/dist/public/assets/{index-jlfTO7f5.js → index-iR9gLdl9.js} +41 -41
  37. package/dist/public/assets/{index.es-CgnvEWi5.js → index.es-BuEtjxhO.js} +1 -1
  38. package/dist/public/assets/{jspdf.es.min-Cw5WefMt.js → jspdf.es.min-CScx2_oK.js} +3 -3
  39. package/dist/public/index.html +2 -2
  40. package/dist/{query-2H3YOPI2.js → query-7XHKSZ5H.js} +5 -5
  41. package/dist/sample-YNSJ3I3T.js +76 -0
  42. package/dist/sample-YNSJ3I3T.js.map +1 -0
  43. package/dist/{search-IPE4ISFB.js → search-NKRXXLRS.js} +7 -7
  44. package/dist/semantic-DD7P4634.js +30 -0
  45. package/dist/{semantic-K3MYXXJI.js → semantic-NBAX4WU4.js} +39 -4
  46. package/dist/semantic-NBAX4WU4.js.map +1 -0
  47. package/dist/{source-resolver-HZQLOODU.js → source-resolver-7NY3KEZ2.js} +7 -7
  48. package/dist/source-resolver-7NY3KEZ2.js.map +1 -0
  49. package/dist/{sync-warehouse-TUNULDUY.js → sync-warehouse-PK7HXW7U.js} +15 -11
  50. package/dist/sync-warehouse-PK7HXW7U.js.map +1 -0
  51. package/dist/{tables-K5NAN2WK.js → tables-WQTRZSXR.js} +7 -7
  52. package/dist/templates/default/docs/yamchart-reference.md +26 -0
  53. package/dist/{test-SRHVOXZB.js → test-MKNKUR3N.js} +19 -7
  54. package/dist/test-MKNKUR3N.js.map +1 -0
  55. package/package.json +5 -5
  56. package/dist/chunk-QUIDZO5G.js.map +0 -1
  57. package/dist/chunk-UFDQ3C7Q.js.map +0 -1
  58. package/dist/chunk-ZIY22VO7.js +0 -1190
  59. package/dist/chunk-ZIY22VO7.js.map +0 -1
  60. package/dist/dev-H6SJZ5UA.js.map +0 -1
  61. package/dist/init-SECXKD5G.js.map +0 -1
  62. package/dist/public/assets/DataView-DUCz_96y.js +0 -9
  63. package/dist/public/assets/ExplorePage-kk4z9ldZ.js +0 -1
  64. package/dist/public/assets/UserManagement-AubGd9hl.js +0 -1
  65. package/dist/sample-ODUGGSFA.js +0 -42
  66. package/dist/sample-ODUGGSFA.js.map +0 -1
  67. package/dist/semantic-K3MYXXJI.js.map +0 -1
  68. package/dist/sync-warehouse-TUNULDUY.js.map +0 -1
  69. package/dist/test-SRHVOXZB.js.map +0 -1
  70. /package/dist/{advisor-5TJDNAY7.js.map → advisor-5F73GF54.js.map} +0 -0
  71. /package/dist/{chunk-S2CH4HUZ.js.map → chunk-25ES7MGF.js.map} +0 -0
  72. /package/dist/{chunk-5FHV22X2.js.map → chunk-PYVROL7Z.js.map} +0 -0
  73. /package/dist/{chunk-ZBCQNWVN.js.map → chunk-WVSDQNAN.js.map} +0 -0
  74. /package/dist/{connection-utils-FEUWER5I.js.map → connection-utils-HNX3473B.js.map} +0 -0
  75. /package/dist/{describe-MEP72B56.js.map → describe-KDGXFPDQ.js.map} +0 -0
  76. /package/dist/{dist-5DQO6L2S.js.map → dist-LK3ZG74Q.js.map} +0 -0
  77. /package/dist/{dist-PPAD6KOM.js.map → dist-WMP7BFKP.js.map} +0 -0
  78. /package/dist/{dist-XNCED7JW.js.map → dist-YB5RBWCC.js.map} +0 -0
  79. /package/dist/{query-2H3YOPI2.js.map → query-7XHKSZ5H.js.map} +0 -0
  80. /package/dist/{search-IPE4ISFB.js.map → search-NKRXXLRS.js.map} +0 -0
  81. /package/dist/{source-resolver-HZQLOODU.js.map → semantic-DD7P4634.js.map} +0 -0
  82. /package/dist/{tables-K5NAN2WK.js.map → tables-WQTRZSXR.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{t as xe,u as he,v as me,e as be,w as $,j as t,x as E,E as ce,M as fe,y as ve,z as je,I as Ce,a as S}from"./index-jlfTO7f5.js";import{a as s}from"./echarts-DtOYsfLX.js";const ge=`
1
+ import{v as xe,u as he,w as me,f as be,x as J,j as t,y as E,E as ce,M as fe,z as ve,I as je,J as Ce,b as S}from"./index-iR9gLdl9.js";import{a as s}from"./echarts-DtOYsfLX.js";const ge=`
2
2
  .rdp-root {
3
3
  --rdp-accent-color: var(--yc-color-primary, #2563eb);
4
4
  --rdp-accent-background-color: color-mix(in srgb, var(--yc-color-primary, #2563eb) 15%, transparent);
@@ -15,4 +15,4 @@ import{t as xe,u as he,v as me,e as be,w as $,j as t,x as E,E as ce,M as fe,y as
15
15
  border: 2px solid var(--yc-color-primary, #2563eb);
16
16
  }
17
17
  .rdp-day_button:hover { background-color: var(--yc-color-surface-hover, #e5e7eb) !important; }
18
- `;function L({selected:h,onSelect:m,onClose:n}){const x=s.useRef(null);return s.useEffect(()=>{function y(b){x.current&&!x.current.contains(b.target)&&n()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]),t.jsxs("div",{ref:x,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},onClick:y=>y.stopPropagation(),children:[t.jsx("style",{children:ge}),t.jsx(je,{mode:"single",numberOfMonths:1,selected:h,defaultMonth:h,onSelect:y=>{y&&m(Ce(y,"yyyy-MM-dd"))}})]})}function De(){var oe,le;const h=xe(),m=he(e=>e.auth),n=m.status==="disabled"||m.status==="authenticated"&&(m.user.role==="admin"||m.user.role==="editor"),{data:x,isLoading:y}=me({queryKey:["chartEvents"],queryFn:()=>S.getChartEvents()}),b=(x==null?void 0:x.events)??[],{data:i}=be(),ne=new Set(["line","bar","area","combo"]),w=((i==null?void 0:i.charts)??[]).filter(e=>ne.has(e.type)).map(e=>e.name),f=s.useMemo(()=>Object.fromEntries(((i==null?void 0:i.charts)??[]).map(e=>[e.name,e.title])),[i==null?void 0:i.charts]),[k,G]=s.useState(null),[c,j]=s.useState(null),[C,M]=s.useState(""),[O,D]=s.useState(!1),[o,u]=s.useState({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),[A,I]=s.useState(""),[J,K]=s.useState(!1),[U,P]=s.useState(!1),[X,R]=s.useState(null),[Y,B]=s.useState(null),[N,_]=s.useState(!1),[q,z]=s.useState(""),[g,F]=s.useState(null),Q=s.useRef(null);s.useEffect(()=>{var e;c&&((e=Q.current)==null||e.focus())},[c]);const W=s.useRef(null);s.useEffect(()=>{if(k===null)return;function e(r){W.current&&!W.current.contains(r.target)&&(G(null),I(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const T=s.useRef(null);s.useEffect(()=>{if(!N)return;function e(r){T.current&&!T.current.contains(r.target)&&(_(!1),z(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);const v=$({mutationFn:({index:e,event:r})=>S.updateChartEvent(e,r),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),de=$({mutationFn:e=>S.deleteChartEvent(e),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),ie=$({mutationFn:e=>S.createChartEvent(e),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]})}});function Z(e,r,a){n&&(j({index:e,field:r}),M(a))}function V(){var a;if(!c)return;if(c.field==="date"||c.field==="endDate"){j(null);return}const e=b[c.index];if(!e)return;const r={...e,[c.field]:C};if(e[c.field]===C||!e[c.field]&&!C){j(null);return}v.mutate({index:c.index,event:{date:r.date,label:r.label,...r.description?{description:r.description}:{},...r.color?{color:r.color}:{},...r.endDate?{endDate:r.endDate}:{},...(a=r.charts)!=null&&a.length?{charts:r.charts}:{}}}),j(null)}function ee(e){e.key==="Enter"&&V(),e.key==="Escape"&&j(null)}function ue(e){F(e)}function ye(){g!==null&&(de.mutate(g),F(null))}function te(){!o.date.trim()||!o.label.trim()||ie.mutate({date:o.date.trim(),label:o.label.trim(),...o.description.trim()?{description:o.description.trim()}:{},...o.color.trim()?{color:o.color.trim()}:{},...o.endDate.trim()?{endDate:o.endDate.trim()}:{},...o.charts.length>0?{charts:o.charts}:{}})}function re(e){e.key==="Enter"&&te(),e.key==="Escape"&&(D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}))}return y?t.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):t.jsxs("div",{className:"p-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Events"}),n&&t.jsx("button",{onClick:()=>D(!0),disabled:O,className:"px-3 py-1.5 text-sm rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Add event"})]}),b.length===0&&!O?t.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No events yet. Add events to annotate your time series charts with milestones, launches, and incidents."}):t.jsx("div",{className:"rounded-lg",style:{border:"1px solid var(--yc-color-border)"},children:t.jsxs("table",{className:"w-full text-sm table-fixed",style:{overflow:"visible"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"16%"}}),t.jsx("col",{style:{width:"20%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"18%"}}),n&&t.jsx("col",{style:{width:48}})]}),t.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)"},children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--yc-color-text-muted)"},children:"#"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"End Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Label"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Description"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Color"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Charts"}),n&&t.jsx("th",{className:"px-4 py-2"})]})}),t.jsxs("tbody",{children:[O&&t.jsxs("tr",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 5%, transparent)"},children:[t.jsx("td",{className:"px-3 py-2 text-right",style:{color:"var(--yc-color-text-muted)"},children:"—"}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>K(!J),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.date?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.date||"Select date"}),J&&t.jsx(L,{selected:o.date?E(o.date,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,date:e}),K(!1)},onClose:()=>K(!1)})]}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>P(!U),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.endDate||"—"}),U&&t.jsx(L,{selected:o.endDate?E(o.endDate,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,endDate:e}),P(!1)},onClose:()=>P(!1)})]}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.label,onChange:e=>u({...o,label:e.target.value}),onKeyDown:re,placeholder:"Event label",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.description,onChange:e=>u({...o,description:e.target.value}),onKeyDown:re,placeholder:"Optional",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx(ce,{value:o.color,onChange:e=>u({...o,color:e}),themePalette:(oe=i==null?void 0:i.theme)==null?void 0:oe.palette})}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>_(!N),className:"text-sm truncate max-w-full text-left",style:{color:o.charts.length>0?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:o.charts.length>0?o.charts.map(e=>f[e]??e).join(", "):"All charts"}),N&&(()=>{const e=q.toLowerCase(),r=e?w.filter(a=>(f[a]??a).toLowerCase().includes(e)||a.toLowerCase().includes(e)):w;return t.jsxs("div",{ref:T,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:a=>a.stopPropagation(),children:[t.jsx("input",{type:"text",value:q,onChange:a=>z(a.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!q&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.length===0,onChange:()=>u({...o,charts:[]})}),"All charts"]}),r.map(a=>t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.includes(a),onChange:()=>{const l=o.charts.includes(a)?o.charts.filter(p=>p!==a):[...o.charts,a];u({...o,charts:l})}}),f[a]??a]},a)),r.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})()]}),t.jsx("td",{className:"px-4 py-2",children:t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:te,disabled:!o.date.trim()||!o.label.trim(),className:"text-xs px-2 py-1 rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Save"}),t.jsx("button",{onClick:()=>{D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),_(!1),z("")},className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"})]})})]}),b.map((e,r)=>{var a;return t.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[t.jsx("td",{className:"px-3 py-3 text-right",style:{color:"var(--yc-color-text-muted)"},children:r+1}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>{n&&R(X===r?null:r)},children:[e.date,X===r&&t.jsx(L,{selected:(()=>{try{return E(e.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:l=>{R(null),l!==e.date&&v.mutate({index:r,event:{...e,date:l}})},onClose:()=>R(null)})]}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:e.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>{n&&B(Y===r?null:r)},children:[e.endDate||"—",Y===r&&t.jsx(L,{selected:(()=>{try{return e.endDate?E(e.endDate,"yyyy-MM-dd",new Date):void 0}catch{return}})(),onSelect:l=>{B(null),l!==e.endDate&&v.mutate({index:r,event:{...e,endDate:l}})},onClose:()=>B(null)})]}),t.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"label",e.label),children:(c==null?void 0:c.index)===r&&c.field==="label"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.label}),t.jsx("td",{className:"px-4 py-3",style:{color:e.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"description",e.description??""),children:(c==null?void 0:c.index)===r&&c.field==="description"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,placeholder:"Add description",className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.description?t.jsx(fe,{components:{p:({children:l})=>t.jsx("span",{children:l}),a:({href:l,children:p})=>t.jsx("a",{href:l,onClick:d=>d.stopPropagation(),...l&&!l.startsWith("#")?{target:"_blank",rel:"noopener noreferrer"}:{},style:{color:"var(--yc-color-primary, #3b82f6)",textDecoration:"underline"},children:p})},children:e.description}):"—"}),t.jsx("td",{className:"px-4 py-3",children:n?t.jsx(ce,{value:e.color??"",onChange:l=>{var p;v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...l?{color:l}:{},...e.endDate?{endDate:e.endDate}:{},...(p=e.charts)!=null&&p.length?{charts:e.charts}:{}}})},themePalette:(a=i==null?void 0:i.theme)==null?void 0:a.palette}):t.jsxs("span",{className:"flex items-center gap-2",children:[e.color&&t.jsx("span",{className:"w-4 h-4 rounded-full border inline-block flex-shrink-0",style:{backgroundColor:e.color,borderColor:"var(--yc-color-border)"}}),t.jsx("span",{style:{color:e.color?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:e.color||"—"})]})}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text-secondary)",cursor:n?"pointer":"default"},onClick:()=>{n&&(G(k===r?null:r),I(""))},children:[k===r?(()=>{const l=A.toLowerCase(),p=l?w.filter(d=>(f[d]??d).toLowerCase().includes(l)||d.toLowerCase().includes(l)):w;return t.jsxs("div",{ref:W,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:d=>d.stopPropagation(),children:[t.jsx("input",{type:"text",value:A,onChange:d=>I(d.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!A&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:!e.charts||e.charts.length===0,onChange:()=>{v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{}}})}}),"All charts"]}),p.map(d=>{var ae;return t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:((ae=e.charts)==null?void 0:ae.includes(d))??!1,onChange:()=>{const H=e.charts??[],se=H.includes(d)?H.filter(pe=>pe!==d):[...H,d];v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{},...se.length>0?{charts:se}:{}}})}}),f[d]??d]},d)}),p.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})():null,e.charts&&e.charts.length>0?e.charts.map(l=>f[l]??l).join(", "):t.jsx("span",{style:{color:"var(--yc-color-text-muted)"},children:"All charts"})]}),n&&t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx("button",{onClick:()=>ue(r),title:"Delete event",className:"hover:opacity-80",style:{color:"var(--yc-color-danger, #ef4444)"},children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]},r)})]})]})}),t.jsx(ve,{open:g!==null,title:"Delete event",message:`Delete "${g!==null?(le=b[g])==null?void 0:le.label:""}"? This cannot be undone.`,onConfirm:ye,onCancel:()=>F(null)})]})}export{De as EventManagement};
18
+ `;function L({selected:h,onSelect:m,onClose:n}){const x=s.useRef(null);return s.useEffect(()=>{function y(b){x.current&&!x.current.contains(b.target)&&n()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]),t.jsxs("div",{ref:x,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},onClick:y=>y.stopPropagation(),children:[t.jsx("style",{children:ge}),t.jsx(je,{mode:"single",numberOfMonths:1,selected:h,defaultMonth:h,onSelect:y=>{y&&m(Ce(y,"yyyy-MM-dd"))}})]})}function De(){var oe,le;const h=xe(),m=he(e=>e.auth),n=m.status==="disabled"||m.status==="authenticated"&&(m.user.role==="admin"||m.user.role==="editor"),{data:x,isLoading:y}=me({queryKey:["chartEvents"],queryFn:()=>S.getChartEvents()}),b=(x==null?void 0:x.events)??[],{data:i}=be(),ne=new Set(["line","bar","area","combo"]),w=((i==null?void 0:i.charts)??[]).filter(e=>ne.has(e.type)).map(e=>e.name),f=s.useMemo(()=>Object.fromEntries(((i==null?void 0:i.charts)??[]).map(e=>[e.name,e.title])),[i==null?void 0:i.charts]),[k,$]=s.useState(null),[c,j]=s.useState(null),[C,M]=s.useState(""),[O,D]=s.useState(!1),[o,u]=s.useState({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),[A,I]=s.useState(""),[G,K]=s.useState(!1),[U,P]=s.useState(!1),[X,R]=s.useState(null),[Y,B]=s.useState(null),[N,_]=s.useState(!1),[q,z]=s.useState(""),[g,F]=s.useState(null),Q=s.useRef(null);s.useEffect(()=>{var e;c&&((e=Q.current)==null||e.focus())},[c]);const W=s.useRef(null);s.useEffect(()=>{if(k===null)return;function e(r){W.current&&!W.current.contains(r.target)&&($(null),I(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const T=s.useRef(null);s.useEffect(()=>{if(!N)return;function e(r){T.current&&!T.current.contains(r.target)&&(_(!1),z(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);const v=J({mutationFn:({index:e,event:r})=>S.updateChartEvent(e,r),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),de=J({mutationFn:e=>S.deleteChartEvent(e),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),ie=J({mutationFn:e=>S.createChartEvent(e),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]})}});function Z(e,r,a){n&&(j({index:e,field:r}),M(a))}function V(){var a;if(!c)return;if(c.field==="date"||c.field==="endDate"){j(null);return}const e=b[c.index];if(!e)return;const r={...e,[c.field]:C};if(e[c.field]===C||!e[c.field]&&!C){j(null);return}v.mutate({index:c.index,event:{date:r.date,label:r.label,...r.description?{description:r.description}:{},...r.color?{color:r.color}:{},...r.endDate?{endDate:r.endDate}:{},...(a=r.charts)!=null&&a.length?{charts:r.charts}:{}}}),j(null)}function ee(e){e.key==="Enter"&&V(),e.key==="Escape"&&j(null)}function ue(e){F(e)}function ye(){g!==null&&(de.mutate(g),F(null))}function te(){!o.date.trim()||!o.label.trim()||ie.mutate({date:o.date.trim(),label:o.label.trim(),...o.description.trim()?{description:o.description.trim()}:{},...o.color.trim()?{color:o.color.trim()}:{},...o.endDate.trim()?{endDate:o.endDate.trim()}:{},...o.charts.length>0?{charts:o.charts}:{}})}function re(e){e.key==="Enter"&&te(),e.key==="Escape"&&(D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}))}return y?t.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):t.jsxs("div",{className:"p-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Events"}),n&&t.jsx("button",{onClick:()=>D(!0),disabled:O,className:"px-3 py-1.5 text-sm rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Add event"})]}),b.length===0&&!O?t.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No events yet. Add events to annotate your time series charts with milestones, launches, and incidents."}):t.jsx("div",{className:"rounded-lg",style:{border:"1px solid var(--yc-color-border)"},children:t.jsxs("table",{className:"w-full text-sm table-fixed",style:{overflow:"visible"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"16%"}}),t.jsx("col",{style:{width:"20%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"18%"}}),n&&t.jsx("col",{style:{width:48}})]}),t.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)"},children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--yc-color-text-muted)"},children:"#"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"End Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Label"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Description"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Color"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Charts"}),n&&t.jsx("th",{className:"px-4 py-2"})]})}),t.jsxs("tbody",{children:[O&&t.jsxs("tr",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 5%, transparent)"},children:[t.jsx("td",{className:"px-3 py-2 text-right",style:{color:"var(--yc-color-text-muted)"},children:"—"}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>K(!G),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.date?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.date||"Select date"}),G&&t.jsx(L,{selected:o.date?E(o.date,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,date:e}),K(!1)},onClose:()=>K(!1)})]}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>P(!U),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.endDate||"—"}),U&&t.jsx(L,{selected:o.endDate?E(o.endDate,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,endDate:e}),P(!1)},onClose:()=>P(!1)})]}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.label,onChange:e=>u({...o,label:e.target.value}),onKeyDown:re,placeholder:"Event label",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.description,onChange:e=>u({...o,description:e.target.value}),onKeyDown:re,placeholder:"Optional",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx(ce,{value:o.color,onChange:e=>u({...o,color:e}),themePalette:(oe=i==null?void 0:i.theme)==null?void 0:oe.palette})}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>_(!N),className:"text-sm truncate max-w-full text-left",style:{color:o.charts.length>0?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:o.charts.length>0?o.charts.map(e=>f[e]??e).join(", "):"All charts"}),N&&(()=>{const e=q.toLowerCase(),r=e?w.filter(a=>(f[a]??a).toLowerCase().includes(e)||a.toLowerCase().includes(e)):w;return t.jsxs("div",{ref:T,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:a=>a.stopPropagation(),children:[t.jsx("input",{type:"text",value:q,onChange:a=>z(a.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!q&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.length===0,onChange:()=>u({...o,charts:[]})}),"All charts"]}),r.map(a=>t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.includes(a),onChange:()=>{const l=o.charts.includes(a)?o.charts.filter(p=>p!==a):[...o.charts,a];u({...o,charts:l})}}),f[a]??a]},a)),r.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})()]}),t.jsx("td",{className:"px-4 py-2",children:t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:te,disabled:!o.date.trim()||!o.label.trim(),className:"text-xs px-2 py-1 rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Save"}),t.jsx("button",{onClick:()=>{D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),_(!1),z("")},className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"})]})})]}),b.map((e,r)=>{var a;return t.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[t.jsx("td",{className:"px-3 py-3 text-right",style:{color:"var(--yc-color-text-muted)"},children:r+1}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>{n&&R(X===r?null:r)},children:[e.date,X===r&&t.jsx(L,{selected:(()=>{try{return E(e.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:l=>{R(null),l!==e.date&&v.mutate({index:r,event:{...e,date:l}})},onClose:()=>R(null)})]}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:e.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>{n&&B(Y===r?null:r)},children:[e.endDate||"—",Y===r&&t.jsx(L,{selected:(()=>{try{return e.endDate?E(e.endDate,"yyyy-MM-dd",new Date):void 0}catch{return}})(),onSelect:l=>{B(null),l!==e.endDate&&v.mutate({index:r,event:{...e,endDate:l}})},onClose:()=>B(null)})]}),t.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"label",e.label),children:(c==null?void 0:c.index)===r&&c.field==="label"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.label}),t.jsx("td",{className:"px-4 py-3",style:{color:e.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"description",e.description??""),children:(c==null?void 0:c.index)===r&&c.field==="description"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,placeholder:"Add description",className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.description?t.jsx(fe,{components:{p:({children:l})=>t.jsx("span",{children:l}),a:({href:l,children:p})=>t.jsx("a",{href:l,onClick:d=>d.stopPropagation(),...l&&!l.startsWith("#")?{target:"_blank",rel:"noopener noreferrer"}:{},style:{color:"var(--yc-color-primary, #3b82f6)",textDecoration:"underline"},children:p})},children:e.description}):"—"}),t.jsx("td",{className:"px-4 py-3",children:n?t.jsx(ce,{value:e.color??"",onChange:l=>{var p;v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...l?{color:l}:{},...e.endDate?{endDate:e.endDate}:{},...(p=e.charts)!=null&&p.length?{charts:e.charts}:{}}})},themePalette:(a=i==null?void 0:i.theme)==null?void 0:a.palette}):t.jsxs("span",{className:"flex items-center gap-2",children:[e.color&&t.jsx("span",{className:"w-4 h-4 rounded-full border inline-block flex-shrink-0",style:{backgroundColor:e.color,borderColor:"var(--yc-color-border)"}}),t.jsx("span",{style:{color:e.color?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:e.color||"—"})]})}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text-secondary)",cursor:n?"pointer":"default"},onClick:()=>{n&&($(k===r?null:r),I(""))},children:[k===r?(()=>{const l=A.toLowerCase(),p=l?w.filter(d=>(f[d]??d).toLowerCase().includes(l)||d.toLowerCase().includes(l)):w;return t.jsxs("div",{ref:W,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:d=>d.stopPropagation(),children:[t.jsx("input",{type:"text",value:A,onChange:d=>I(d.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!A&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:!e.charts||e.charts.length===0,onChange:()=>{v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{}}})}}),"All charts"]}),p.map(d=>{var ae;return t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:((ae=e.charts)==null?void 0:ae.includes(d))??!1,onChange:()=>{const H=e.charts??[],se=H.includes(d)?H.filter(pe=>pe!==d):[...H,d];v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{},...se.length>0?{charts:se}:{}}})}}),f[d]??d]},d)}),p.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})():null,e.charts&&e.charts.length>0?e.charts.map(l=>f[l]??l).join(", "):t.jsx("span",{style:{color:"var(--yc-color-text-muted)"},children:"All charts"})]}),n&&t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx("button",{onClick:()=>ue(r),title:"Delete event",className:"hover:opacity-80",style:{color:"var(--yc-color-danger, #ef4444)"},children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]},r)})]})]})}),t.jsx(ve,{open:g!==null,title:"Delete event",message:`Delete "${g!==null?(le=b[g])==null?void 0:le.label:""}"? This cannot be undone.`,onConfirm:ye,onCancel:()=>F(null)})]})}export{De as EventManagement};
@@ -0,0 +1 @@
1
+ import{j as e,k,K as E,N as B,w as M,O as W,Q as $,b as D}from"./index-iR9gLdl9.js";import{a}from"./echarts-DtOYsfLX.js";const T=["What data do I have?","Show me recent trends","What are the top items by revenue?","Compare this month to last month"];function P({summary:t,onPromptClick:i}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12 gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Ask questions about your data in plain English"})]}),t&&(t.tableCount>0||t.modelCount>0)&&e.jsxs("div",{className:"rounded-xl px-5 py-4 w-full max-w-md flex flex-col gap-3",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Connected data"}),e.jsxs("div",{className:"flex gap-6",children:[t.tableCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.tableCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.tableCount===1?"table":"tables"})]}),t.modelCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.modelCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.modelCount===1?"model":"models"})]})]}),t.connections.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.connections.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:l.name},l.name))})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-center max-w-lg",children:T.map(l=>e.jsx("button",{onClick:()=>i(l),className:"text-sm px-3 py-1.5 rounded-full transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",color:"var(--yc-color-text)",border:"1px solid var(--yc-color-border)"},children:l},l))})]})}function R({summary:t,onTableClick:i}){const[l,x]=a.useState(new Set),[n,h]=a.useState(new Set),v=s=>{x(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},f=s=>{h(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},y=((t==null?void 0:t.connections)??[]).map(s=>({connection:s.name,tables:((t==null?void 0:t.tables)??[]).filter(o=>o.connection===s.name)})),u=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col h-full overflow-y-auto",style:{borderRight:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)"},children:[e.jsx("div",{className:"px-3 py-2 flex items-center",style:{borderBottom:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Catalog"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[y.map(s=>e.jsxs("div",{children:[e.jsxs("button",{className:"w-full flex items-center gap-1.5 px-3 py-1.5 hover:opacity-80 text-left",onClick:()=>v(s.connection),children:[e.jsx(g,{expanded:l.has(s.connection)}),e.jsx(I,{}),e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--yc-color-text)"},children:s.connection}),e.jsx("span",{className:"ml-auto text-xs",style:{color:"var(--yc-color-text-secondary)"},children:s.tables.length})]}),l.has(s.connection)&&e.jsx("div",{children:s.tables.map(o=>{const c=`${s.connection}:${o.name}`,m=n.has(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 pl-6 pr-2 py-1 group",children:[e.jsxs("button",{className:"flex items-center gap-1 flex-1 min-w-0 hover:opacity-80 text-left",onClick:()=>f(c),children:[e.jsx(g,{expanded:m}),e.jsx(A,{}),e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:o.schema?`${o.schema}.${o.name}`:o.name})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(o.schema?`${o.schema}.${o.name}`:o.name),title:`Ask about ${o.name}`,children:"Ask"})]}),m&&o.columns.length>0&&e.jsx("div",{className:"pl-12 pb-1",children:o.columns.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 pr-2",children:[e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:d.name}),d.type&&e.jsx("span",{className:"text-xs ml-auto flex-shrink-0",style:{color:"var(--yc-color-text-secondary)"},children:d.type})]},d.name))})]},c)})})]},s.connection)),u.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Models"})}),u.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 pr-2 py-1.5 group",children:[e.jsx(O,{}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:s.name}),s.description&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text-secondary)"},children:s.description})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(s.name),title:`Ask about ${s.name}`,children:"Ask"})]},s.name))]}),!t||y.length===0&&u.length===0?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsxs("p",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:["No catalog data available. Run ",e.jsx("code",{className:"font-mono",children:"yamchart sync-warehouse"})," to populate."]})}):null]})]})}function g({expanded:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function I(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function A(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18M9 3v18"})]})}function O(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function q(){const t=k(n=>n.savedCharts),[i,l]=a.useState(!1),x=a.useRef(null);return a.useEffect(()=>{if(!i)return;function n(h){x.current&&!x.current.contains(h.target)&&l(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[i]),t.length===0?null:e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>l(n=>!n),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),e.jsxs("span",{children:[t.length," saved ",t.length===1?"chart":"charts"]}),e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold text-white",style:{background:"var(--yc-color-primary)"},children:t.length})]}),i&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg shadow-lg z-50 py-1",style:{background:"var(--yc-color-bg)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Saved charts"}),t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-primary)",flexShrink:0},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{className:"text-sm truncate",style:{color:"var(--yc-color-text)"},children:n})]},n))]})]})}function V(){const t=E(),{messages:i,isStreaming:l,savedCharts:x,openPanel:n,setPanelMode:h,snapshotExploreHistory:v,clearConversation:f}=k(),[y,u]=a.useState(!0),[s,o]=a.useState(void 0),c=a.useRef(null);a.useEffect(()=>(h("explore"),n({type:"explore"}),()=>{h("panel")}),[h,n]),a.useEffect(()=>{var r;(r=c.current)==null||r.scrollIntoView({behavior:"smooth"})},[i]);const m=a.useCallback((r,p,S)=>{v(p),h("panel");const L=r==="chart"?"charts":"dashboards";window.location.hash=`/${L}/${encodeURIComponent(p)}${S?"?edit=true":""}`,n({type:r==="chart"?"chart":"dashboard",name:p})},[v,h,n]),{sendMessage:d}=B(m),{data:j}=M({queryKey:["catalog-summary"],queryFn:()=>D.getCatalogSummary(),staleTime:6e4,retry:!1}),b=a.useCallback(r=>{o(`Tell me about the ${r} table`)},[]),w=a.useCallback(r=>{d(r)},[d]),N=a.useCallback(r=>{d(r),o(void 0)},[d]),C=a.useCallback(()=>{const r=x.join(", ");d(`Build a dashboard using these charts: ${r}. Arrange them in a logical layout.`)},[x,d]);return t==="sm"?e.jsx("div",{className:"flex items-center justify-center h-screen px-6",style:{background:"var(--yc-color-bg)"},children:e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-lg font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Desktop required"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Data Explorer is designed for larger screens. Please open it on a desktop or laptop."})]})}):e.jsxs("div",{className:"flex h-screen overflow-hidden",style:{background:"var(--yc-color-bg)"},children:[y&&e.jsx(R,{summary:j??null,onTableClick:b}),e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--yc-color-border)"},children:[e.jsxs("a",{href:"#/",className:"flex items-center gap-1.5 text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:r=>{r.preventDefault(),window.location.hash="/"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Dashboards"]}),e.jsx("div",{className:"w-px h-4 mx-1",style:{background:"var(--yc-color-border)"}}),e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:()=>u(r=>!r),title:y?"Hide catalog":"Show catalog",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(q,{}),e.jsxs("button",{disabled:x.length===0||l,onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity disabled:opacity-40",style:{background:"var(--yc-color-primary)",color:"#fff"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Build Dashboard"]}),i.length>0&&e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:f,title:"New conversation",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 flex flex-col gap-3 min-h-0",children:i.length===0?e.jsx(P,{summary:j??null,onPromptClick:w}):e.jsxs(e.Fragment,{children:[i.map((r,p)=>e.jsx(W,{message:r,isStreaming:l&&p===i.length-1&&r.role==="assistant",onSendMessage:d},p)),e.jsx("div",{ref:c})]})}),e.jsx("div",{className:"px-6 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx($,{onSend:N,placeholder:"Ask about your data...",disabled:l,initialValue:s})})]})]})}export{V as default};
@@ -1 +1 @@
1
- import{u,j as e,A as p}from"./index-jlfTO7f5.js";import{a as r}from"./echarts-DtOYsfLX.js";const f="",g={google:"Google",microsoft:"Microsoft",oidc:"SSO"};function j(){const m=u(o=>o.login),l=u(o=>o.providers),[a,x]=r.useState(""),[t,b]=r.useState(""),[c,s]=r.useState(""),[n,d]=r.useState(!1);r.useEffect(()=>{window.location.hash.includes("error=account_conflict")&&(s("An account with this email already exists. Please sign in with your password."),window.location.hash="#/")},[]);const y=async o=>{o.preventDefault(),s(""),d(!0);try{await m(a,t)}catch(i){i instanceof p?s(i.message):s("An unexpected error occurred")}finally{d(!1)}},h=o=>{window.location.href=`${f}/api/auth/sso/${o}`};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Sign in to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Enter your credentials to access dashboards."}),c&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:c}),l.length>0&&e.jsxs("div",{className:"space-y-2 mb-6",children:[l.map(o=>e.jsxs("button",{onClick:()=>h(o),className:"w-full py-2 px-4 text-sm font-medium rounded-md hover:bg-black/5",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:["Sign in with ",g[o]??o]},o)),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t",style:{borderColor:"var(--yc-color-border)"}})}),e.jsx("div",{className:"relative flex justify-center text-xs",style:{color:"var(--yc-color-text-muted)"},children:e.jsx("span",{className:"px-2",style:{backgroundColor:"var(--yc-color-surface)"},children:"or"})})]})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:o=>x(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"password",type:"password",value:t,onChange:o=>b(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Password"})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Signing in...":"Sign in"})]})]})})}export{j as LoginPage};
1
+ import{u,j as e,A as p}from"./index-iR9gLdl9.js";import{a as r}from"./echarts-DtOYsfLX.js";const f="",g={google:"Google",microsoft:"Microsoft",oidc:"SSO"};function j(){const m=u(o=>o.login),l=u(o=>o.providers),[a,x]=r.useState(""),[t,b]=r.useState(""),[c,s]=r.useState(""),[n,d]=r.useState(!1);r.useEffect(()=>{window.location.hash.includes("error=account_conflict")&&(s("An account with this email already exists. Please sign in with your password."),window.location.hash="#/")},[]);const y=async o=>{o.preventDefault(),s(""),d(!0);try{await m(a,t)}catch(i){i instanceof p?s(i.message):s("An unexpected error occurred")}finally{d(!1)}},h=o=>{window.location.href=`${f}/api/auth/sso/${o}`};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Sign in to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Enter your credentials to access dashboards."}),c&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:c}),l.length>0&&e.jsxs("div",{className:"space-y-2 mb-6",children:[l.map(o=>e.jsxs("button",{onClick:()=>h(o),className:"w-full py-2 px-4 text-sm font-medium rounded-md hover:bg-black/5",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:["Sign in with ",g[o]??o]},o)),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t",style:{borderColor:"var(--yc-color-border)"}})}),e.jsx("div",{className:"relative flex justify-center text-xs",style:{color:"var(--yc-color-text-muted)"},children:e.jsx("span",{className:"px-2",style:{backgroundColor:"var(--yc-color-surface)"},children:"or"})})]})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:o=>x(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"password",type:"password",value:t,onChange:o=>b(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Password"})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Signing in...":"Sign in"})]})]})})}export{j as LoginPage};
@@ -1 +1 @@
1
- import{j as e,c as ee,b as re,d as te,e as se,f as ae,g as K,h as le,a as R,F as oe,S as ce,i as ne,C as ie,D as de,k as he,T as xe,G as ue,W as me,l as ye,m as fe,H as ve,n as ge,o as je,p as pe,P as be,q as Ce,B as we,L as ke,r as Ne,s as De}from"./index-jlfTO7f5.js";import{a as m}from"./echarts-DtOYsfLX.js";function Fe({title:s,description:l,loading:r=!1,error:i=null,cached:t,durationMs:c,hasDrillDown:N,onRefresh:a,children:v}){return e.jsxs("div",{className:"chart-container",children:[e.jsxs("div",{className:"flex items-start justify-between p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:s}),N&&e.jsxs("svg",{className:"w-4 h-4 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:[e.jsx("title",{children:"Right-click to drill down"}),e.jsx("path",{fillRule:"evenodd",d:"M5.22 14.78a.75.75 0 001.06 0l7.22-7.22v5.69a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75h-7.5a.75.75 0 000 1.5h5.69l-7.22 7.22a.75.75 0 000 1.06z",clipRule:"evenodd"})]})]}),l&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t!==void 0&&e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:t?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:t?"Cached":"Fresh"}),c!==void 0&&e.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:[c,"ms"]}),a&&e.jsx("button",{onClick:a,disabled:r,className:"p-1.5 hover:bg-black/5 rounded transition-colors disabled:opacity-50",style:{color:"var(--yc-color-text-muted)"},title:"Refresh",children:e.jsx("svg",{className:ee("w-4 h-4",r&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),e.jsx("div",{className:"p-4",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",style:{color:"var(--yc-color-danger)"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Failed to load chart"}),e.jsx("p",{className:"text-sm mt-1",children:i.message})]})}):v})]})}const Le={day:{label:"Date",format:"%b %d, %Y"},week:{label:"Week Starting",format:"%b %d"},month:{label:"Month",format:"%b '%y"},quarter:{label:"Quarter",format:"quarter"},year:{label:"Year",format:"%Y"}};function Se({chartName:s}){const[l,r]=m.useState(!1),i=async()=>{const t=`{{${s}}}`;try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(c){console.error("Failed to copy:",c)}};return e.jsx("button",{onClick:i,className:"text-sm flex items-center gap-1.5 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:`Copy {{${s}}} for use in markdown widgets`,children:l?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",style:{color:"var(--yc-color-success)"},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{style:{color:"var(--yc-color-success)"},children:"Copied!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("span",{children:"Copy Reference"})]})})}function S(s,l){if(!l)return s.toLocaleString();const r=l.decimals??0;switch(l.type){case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:l.currency||"USD",minimumFractionDigits:r,maximumFractionDigits:r}).format(s);case"percent":return new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}).format(s/100);default:return s.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}}function Ae(s,l){const r=s>=0?"+":"";return l==="percent_change"?`${r}${s.toFixed(1)}%`:`${r}${s.toLocaleString()}`}function Me({data:s,config:l,title:r,comparison:i}){var w,k,L;if(!(s!=null&&s[0])||!((w=l.value)!=null&&w.field))return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-muted)"},children:"No data available"});const t=s[0],c=t[l.value.field],N=S(c,l.format);let a=null,v="percent_change",g,D,p;if(i)a=i.change,v=i.changeType,g=i.currentPeriodLabel,D=i.previousPeriodLabel,p=S(i.previousValue,l.format);else if((k=l.comparison)!=null&&k.enabled&&l.comparison.field){const h=t[l.comparison.field];v=l.comparison.type,h&&h!==0&&(v==="percent_change"?a=(c-h)/h*100:a=c-h,p=S(h,l.format))}const y=l.goal,b=y&&y.value!==0?Math.max(0,Math.min(c/y.value*100,100)):null,F=y?c>=y.value?"var(--yc-color-success)":"var(--yc-color-danger)":void 0;return e.jsxs("div",{className:"h-80 flex flex-col items-center justify-center p-8",children:[e.jsxs("div",{className:"text-6xl font-bold tabular-nums",style:{color:"var(--yc-color-text)"},children:[N,l.unit&&e.jsx("span",{className:"text-3xl font-normal ml-2",style:{color:"var(--yc-color-text-muted)"},children:l.unit})]}),g&&e.jsx("div",{className:"text-sm mt-2",style:{color:"var(--yc-color-text-muted)"},children:g}),r&&e.jsx("div",{className:"text-lg mt-3",style:{color:"var(--yc-color-text-secondary)"},children:r}),a!==null&&e.jsxs("div",{className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-medium px-3 py-1 rounded",style:a>=0?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 15%, transparent)",color:"var(--yc-color-danger)"},children:Ae(a,v)}),p&&e.jsxs("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:["vs ",p]}),!p&&((L=l.comparison)==null?void 0:L.label)&&e.jsx("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:l.comparison.label})]}),D&&e.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:D})]}),y&&b!==null&&e.jsxs("div",{className:"mt-4 w-full max-w-[280px]",children:[y.show_progress&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",style:{color:"var(--yc-color-text-muted)"},children:[e.jsxs("span",{children:[S(c,l.format)," / ",S(y.value,l.format)]}),e.jsxs("span",{children:[b.toFixed(0),"%"]})]}),e.jsx("div",{className:"w-full h-2 rounded-full",style:{backgroundColor:"var(--yc-color-surface-hover)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${b}%`,backgroundColor:F}})})]}),y.label&&e.jsx("div",{className:"text-sm mt-1 text-center",style:{color:"var(--yc-color-text-muted)"},children:y.label})]})]})}function _e({chartName:s,drillParams:l}){var O,P,W,U,H,I,q,z;const{data:r,isLoading:i}=re(s),{data:t,isLoading:c,error:N}=te(s),{data:a}=se(),v=ae(),g=K(o=>o.getEffectiveFilters),D=K(o=>o.setChartFilter),p=le(),y=i||c,b=l==null?void 0:l._from,F=l?Object.fromEntries(Object.entries(l).filter(([o])=>!o.startsWith("_"))):{},w=Object.keys(F).length>0,k=Object.entries(F).map(([o,u])=>`${o}: ${u}`).join(", ");m.useEffect(()=>{if(w)for(const[o,u]of Object.entries(F))D(s,o,u)},[s,w]);const L=((O=t==null?void 0:t.meta)==null?void 0:O.serverPaginated)===!0,[h,A]=m.useState(null),M=m.useRef(!0);m.useEffect(()=>{A(null),M.current=!0},[(P=t==null?void 0:t.meta)==null?void 0:P.cacheKey]);const Y=m.useCallback(async(o,u,n,j)=>{if(M.current&&o===0&&!n){M.current=!1;return}M.current=!1,A(d=>({rows:(d==null?void 0:d.rows)??[],page:o,loading:!0}));try{const d=g(s),$={...Object.fromEntries(Object.entries(d).filter(([Ee,G])=>G!=null&&G!=="")),_server_paginated:!0,_page:o,_page_size:u,...n?{_sort_field:n,_sort_dir:j??"asc"}:{}},T=await R.queryChart(s,$);A({rows:T.rows,summaryValues:T.summaryValues,page:o,loading:!1})}catch{A(d=>d?{...d,loading:!1}:null)}},[s,g]),X=m.useMemo(()=>{var n;if(!t||((n=r==null?void 0:r.chart)==null?void 0:n.type)!=="table")return;const o=g(s),u=Object.fromEntries(Object.entries(o).filter(([j,d])=>d!=null&&d!==""));return R.getExportUrl(s,u)},[t,r,s,g]),[x,_]=m.useState(null),C=m.useCallback((o,u,n)=>{_({x:n.x,y:n.y,field:o,value:u})},[]),Q=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.model))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams;if(x.allFields)for(const[$,T]of Object.entries(x.allFields))n.set($,T);else n.set(u,x.value);n.set("_from",s),window.location.hash=`/charts/${s}/detail?${n.toString()}`,_(null)},[x,r,s]),J=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.chart))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams({[u]:x.value,_from:s});window.location.hash=`/charts/${r.drillDown.chart}?${n.toString()}`,_(null)},[x,r,s]),B=g(s).granularity,f=B?Le[B]:void 0,V=f==null?void 0:f.label,E=f==null?void 0:f.format;if(i)return e.jsxs("div",{className:"chart-container animate-pulse",children:[e.jsx("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:e.jsx("div",{className:"h-6 rounded w-48",style:{backgroundColor:"var(--yc-color-surface-hover)"}})}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"h-80 rounded",style:{backgroundColor:"var(--yc-color-surface-hover)"}})})]});if(!r)return e.jsxs("div",{className:"chart-container p-8 text-center",style:{color:"var(--yc-color-text-secondary)"},children:["Chart not found: ",s]});const Z=()=>{var u;if(!t)return e.jsx("div",{className:"h-80 rounded animate-pulse",style:{backgroundColor:"var(--yc-color-surface-hover)"}});const o=r.chart.type;switch(o){case"line":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ke,{data:t.rows,columns:t.columns,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"bar":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(we,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"area":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(Ce,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"pie":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing pie chart configuration"}):e.jsx(be,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"donut":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing donut chart configuration"}):e.jsx(pe,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,centerValue:r.chart.centerValue,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"scatter":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(je,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"combo":if(!r.chart.x)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ge,{data:t.rows,xAxis:n,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"kpi":return e.jsx(Me,{data:t.rows,config:r.chart,title:r.title,comparison:t.comparison});case"heatmap":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(ve,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"funnel":return e.jsx(fe,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"sankey":return e.jsx(ye,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"waterfall":return e.jsx(me,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"gauge":return e.jsx(ue,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"table":return e.jsx(xe,{data:(h==null?void 0:h.rows)??t.rows,columns:t.columns,chartConfig:r.chart,height:"100%",loading:c||((h==null?void 0:h.loading)??!1),serverPaginated:L,totalCount:(u=t.meta)==null?void 0:u.totalCount,serverSummaryValues:(h==null?void 0:h.summaryValues)??t.summaryValues,onServerPageChange:L?Y:void 0,exportUrl:X});default:return e.jsxs("div",{className:"h-80 flex items-center justify-center text-gray-500",children:['Chart type "',o,'" not yet implemented']})}};return e.jsxs("div",{className:"space-y-4",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[e.jsx("button",{onClick:()=>{window.location.hash=`/charts/${b}`},className:"transition-colors hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:b}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:r.title}),k&&e.jsxs("span",{style:{color:"var(--yc-color-text-muted)"},children:["(",k,")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[r.parameters.length>0?e.jsx(oe,{parameters:r.parameters,chartName:s}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{chartName:s}),e.jsx(ce,{resourceType:"chart",resourceName:s}),p&&e.jsxs("button",{onClick:()=>ne.getState().openPanel({type:"chart",name:s}),className:"text-sm flex items-center gap-1 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:"Ask AI about this chart",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Ask AI"]})]})]}),e.jsx(Fe,{title:r.title,description:r.description,loading:y,cached:t==null?void 0:t.meta.cached,durationMs:t==null?void 0:t.meta.durationMs,hasDrillDown:!!((W=r.drillDown)!=null&&W.chart),onRefresh:()=>v(s),children:e.jsx(ie,{isLoading:c,error:N,data:t==null?void 0:t.rows,onRetry:()=>v(s),children:Z()})}),w&&t&&e.jsx(de,{data:t.rows,columns:t.columns,drillDownColumns:(U=r.drillDown)==null?void 0:U.columns,filterDisplay:k,chartName:s}),x&&e.jsx(he,{x:x.x,y:x.y,field:x.field,value:x.value,allFields:x.allFields,onViewDetails:(H=r.drillDown)!=null&&H.model?Q:void 0,onGoToChart:(I=r.drillDown)!=null&&I.chart?J:void 0,detailModel:(q=r.drillDown)==null?void 0:q.model,targetChart:(z=r.drillDown)==null?void 0:z.chart,onClose:()=>_(null)})]})}function Re({parsed:s}){const l=s.params.token,[r,i]=m.useState(null),[t,c]=m.useState(!1);return m.useEffect(()=>{if(!l){i("No share token provided");return}R.getPublicConfig(l).then(()=>c(!0)).catch(()=>i("This link has expired or been revoked"))},[l]),r?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-gray-400 text-lg",children:r})})}):t?e.jsx(Ne,{value:l??null,children:e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"var(--yc-color-bg, #f9fafb)"},children:[s.type==="public_chart"?e.jsx("div",{className:"max-w-7xl mx-auto py-6 px-4",children:e.jsx(_e,{chartName:s.name})}):e.jsx(De,{dashboardId:s.name,initialTab:s.params.tab}),e.jsx("div",{className:"text-center py-4 text-xs",style:{color:"var(--yc-color-text-muted, #9ca3af)"},children:"Shared via yamchart"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})})}export{Re as PublicViewer};
1
+ import{j as e,c as ee,d as re,e as te,f as se,g as ae,h as K,i as le,b as R,F as oe,S as ce,k as ne,C as ie,D as de,l as he,T as xe,G as ue,W as me,m as ye,n as fe,H as ve,o as ge,p as je,q as pe,P as be,r as Ce,B as we,L as ke,s as Ne,t as De}from"./index-iR9gLdl9.js";import{a as m}from"./echarts-DtOYsfLX.js";function Fe({title:s,description:l,loading:r=!1,error:i=null,cached:t,durationMs:c,hasDrillDown:N,onRefresh:a,children:v}){return e.jsxs("div",{className:"chart-container",children:[e.jsxs("div",{className:"flex items-start justify-between p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:s}),N&&e.jsxs("svg",{className:"w-4 h-4 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:[e.jsx("title",{children:"Right-click to drill down"}),e.jsx("path",{fillRule:"evenodd",d:"M5.22 14.78a.75.75 0 001.06 0l7.22-7.22v5.69a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75h-7.5a.75.75 0 000 1.5h5.69l-7.22 7.22a.75.75 0 000 1.06z",clipRule:"evenodd"})]})]}),l&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t!==void 0&&e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:t?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:t?"Cached":"Fresh"}),c!==void 0&&e.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:[c,"ms"]}),a&&e.jsx("button",{onClick:a,disabled:r,className:"p-1.5 hover:bg-black/5 rounded transition-colors disabled:opacity-50",style:{color:"var(--yc-color-text-muted)"},title:"Refresh",children:e.jsx("svg",{className:ee("w-4 h-4",r&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),e.jsx("div",{className:"p-4",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",style:{color:"var(--yc-color-danger)"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Failed to load chart"}),e.jsx("p",{className:"text-sm mt-1",children:i.message})]})}):v})]})}const Le={day:{label:"Date",format:"%b %d, %Y"},week:{label:"Week Starting",format:"%b %d"},month:{label:"Month",format:"%b '%y"},quarter:{label:"Quarter",format:"quarter"},year:{label:"Year",format:"%Y"}};function Se({chartName:s}){const[l,r]=m.useState(!1),i=async()=>{const t=`{{${s}}}`;try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(c){console.error("Failed to copy:",c)}};return e.jsx("button",{onClick:i,className:"text-sm flex items-center gap-1.5 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:`Copy {{${s}}} for use in markdown widgets`,children:l?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",style:{color:"var(--yc-color-success)"},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{style:{color:"var(--yc-color-success)"},children:"Copied!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("span",{children:"Copy Reference"})]})})}function S(s,l){if(!l)return s.toLocaleString();const r=l.decimals??0;switch(l.type){case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:l.currency||"USD",minimumFractionDigits:r,maximumFractionDigits:r}).format(s);case"percent":return new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}).format(s/100);default:return s.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}}function Ae(s,l){const r=s>=0?"+":"";return l==="percent_change"?`${r}${s.toFixed(1)}%`:`${r}${s.toLocaleString()}`}function Me({data:s,config:l,title:r,comparison:i}){var w,k,L;if(!(s!=null&&s[0])||!((w=l.value)!=null&&w.field))return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-muted)"},children:"No data available"});const t=s[0],c=t[l.value.field],N=S(c,l.format);let a=null,v="percent_change",g,D,p;if(i)a=i.change,v=i.changeType,g=i.currentPeriodLabel,D=i.previousPeriodLabel,p=S(i.previousValue,l.format);else if((k=l.comparison)!=null&&k.enabled&&l.comparison.field){const h=t[l.comparison.field];v=l.comparison.type,h&&h!==0&&(v==="percent_change"?a=(c-h)/h*100:a=c-h,p=S(h,l.format))}const y=l.goal,b=y&&y.value!==0?Math.max(0,Math.min(c/y.value*100,100)):null,F=y?c>=y.value?"var(--yc-color-success)":"var(--yc-color-danger)":void 0;return e.jsxs("div",{className:"h-80 flex flex-col items-center justify-center p-8",children:[e.jsxs("div",{className:"text-6xl font-bold tabular-nums",style:{color:"var(--yc-color-text)"},children:[N,l.unit&&e.jsx("span",{className:"text-3xl font-normal ml-2",style:{color:"var(--yc-color-text-muted)"},children:l.unit})]}),g&&e.jsx("div",{className:"text-sm mt-2",style:{color:"var(--yc-color-text-muted)"},children:g}),r&&e.jsx("div",{className:"text-lg mt-3",style:{color:"var(--yc-color-text-secondary)"},children:r}),a!==null&&e.jsxs("div",{className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-medium px-3 py-1 rounded",style:a>=0?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 15%, transparent)",color:"var(--yc-color-danger)"},children:Ae(a,v)}),p&&e.jsxs("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:["vs ",p]}),!p&&((L=l.comparison)==null?void 0:L.label)&&e.jsx("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:l.comparison.label})]}),D&&e.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:D})]}),y&&b!==null&&e.jsxs("div",{className:"mt-4 w-full max-w-[280px]",children:[y.show_progress&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",style:{color:"var(--yc-color-text-muted)"},children:[e.jsxs("span",{children:[S(c,l.format)," / ",S(y.value,l.format)]}),e.jsxs("span",{children:[b.toFixed(0),"%"]})]}),e.jsx("div",{className:"w-full h-2 rounded-full",style:{backgroundColor:"var(--yc-color-surface-hover)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${b}%`,backgroundColor:F}})})]}),y.label&&e.jsx("div",{className:"text-sm mt-1 text-center",style:{color:"var(--yc-color-text-muted)"},children:y.label})]})]})}function _e({chartName:s,drillParams:l}){var O,P,W,U,H,I,q,z;const{data:r,isLoading:i}=re(s),{data:t,isLoading:c,error:N}=te(s),{data:a}=se(),v=ae(),g=K(o=>o.getEffectiveFilters),D=K(o=>o.setChartFilter),p=le(),y=i||c,b=l==null?void 0:l._from,F=l?Object.fromEntries(Object.entries(l).filter(([o])=>!o.startsWith("_"))):{},w=Object.keys(F).length>0,k=Object.entries(F).map(([o,u])=>`${o}: ${u}`).join(", ");m.useEffect(()=>{if(w)for(const[o,u]of Object.entries(F))D(s,o,u)},[s,w]);const L=((O=t==null?void 0:t.meta)==null?void 0:O.serverPaginated)===!0,[h,A]=m.useState(null),M=m.useRef(!0);m.useEffect(()=>{A(null),M.current=!0},[(P=t==null?void 0:t.meta)==null?void 0:P.cacheKey]);const Y=m.useCallback(async(o,u,n,j)=>{if(M.current&&o===0&&!n){M.current=!1;return}M.current=!1,A(d=>({rows:(d==null?void 0:d.rows)??[],page:o,loading:!0}));try{const d=g(s),$={...Object.fromEntries(Object.entries(d).filter(([Ee,G])=>G!=null&&G!=="")),_server_paginated:!0,_page:o,_page_size:u,...n?{_sort_field:n,_sort_dir:j??"asc"}:{}},T=await R.queryChart(s,$);A({rows:T.rows,summaryValues:T.summaryValues,page:o,loading:!1})}catch{A(d=>d?{...d,loading:!1}:null)}},[s,g]),X=m.useMemo(()=>{var n;if(!t||((n=r==null?void 0:r.chart)==null?void 0:n.type)!=="table")return;const o=g(s),u=Object.fromEntries(Object.entries(o).filter(([j,d])=>d!=null&&d!==""));return R.getExportUrl(s,u)},[t,r,s,g]),[x,_]=m.useState(null),C=m.useCallback((o,u,n)=>{_({x:n.x,y:n.y,field:o,value:u})},[]),Q=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.model))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams;if(x.allFields)for(const[$,T]of Object.entries(x.allFields))n.set($,T);else n.set(u,x.value);n.set("_from",s),window.location.hash=`/charts/${s}/detail?${n.toString()}`,_(null)},[x,r,s]),J=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.chart))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams({[u]:x.value,_from:s});window.location.hash=`/charts/${r.drillDown.chart}?${n.toString()}`,_(null)},[x,r,s]),B=g(s).granularity,f=B?Le[B]:void 0,V=f==null?void 0:f.label,E=f==null?void 0:f.format;if(i)return e.jsxs("div",{className:"chart-container animate-pulse",children:[e.jsx("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:e.jsx("div",{className:"h-6 rounded w-48",style:{backgroundColor:"var(--yc-color-surface-hover)"}})}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"h-80 rounded",style:{backgroundColor:"var(--yc-color-surface-hover)"}})})]});if(!r)return e.jsxs("div",{className:"chart-container p-8 text-center",style:{color:"var(--yc-color-text-secondary)"},children:["Chart not found: ",s]});const Z=()=>{var u;if(!t)return e.jsx("div",{className:"h-80 rounded animate-pulse",style:{backgroundColor:"var(--yc-color-surface-hover)"}});const o=r.chart.type;switch(o){case"line":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ke,{data:t.rows,columns:t.columns,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"bar":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(we,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"area":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(Ce,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"pie":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing pie chart configuration"}):e.jsx(be,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"donut":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing donut chart configuration"}):e.jsx(pe,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,centerValue:r.chart.centerValue,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"scatter":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(je,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"combo":if(!r.chart.x)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ge,{data:t.rows,xAxis:n,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"kpi":return e.jsx(Me,{data:t.rows,config:r.chart,title:r.title,comparison:t.comparison});case"heatmap":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(ve,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"funnel":return e.jsx(fe,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"sankey":return e.jsx(ye,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"waterfall":return e.jsx(me,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"gauge":return e.jsx(ue,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"table":return e.jsx(xe,{data:(h==null?void 0:h.rows)??t.rows,columns:t.columns,chartConfig:r.chart,height:"100%",loading:c||((h==null?void 0:h.loading)??!1),serverPaginated:L,totalCount:(u=t.meta)==null?void 0:u.totalCount,serverSummaryValues:(h==null?void 0:h.summaryValues)??t.summaryValues,onServerPageChange:L?Y:void 0,exportUrl:X});default:return e.jsxs("div",{className:"h-80 flex items-center justify-center text-gray-500",children:['Chart type "',o,'" not yet implemented']})}};return e.jsxs("div",{className:"space-y-4",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[e.jsx("button",{onClick:()=>{window.location.hash=`/charts/${b}`},className:"transition-colors hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:b}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:r.title}),k&&e.jsxs("span",{style:{color:"var(--yc-color-text-muted)"},children:["(",k,")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[r.parameters.length>0?e.jsx(oe,{parameters:r.parameters,chartName:s}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{chartName:s}),e.jsx(ce,{resourceType:"chart",resourceName:s}),p&&e.jsxs("button",{onClick:()=>ne.getState().openPanel({type:"chart",name:s}),className:"text-sm flex items-center gap-1 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:"Ask AI about this chart",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Ask AI"]})]})]}),e.jsx(Fe,{title:r.title,description:r.description,loading:y,cached:t==null?void 0:t.meta.cached,durationMs:t==null?void 0:t.meta.durationMs,hasDrillDown:!!((W=r.drillDown)!=null&&W.chart),onRefresh:()=>v(s),children:e.jsx(ie,{isLoading:c,error:N,data:t==null?void 0:t.rows,onRetry:()=>v(s),children:Z()})}),w&&t&&e.jsx(de,{data:t.rows,columns:t.columns,drillDownColumns:(U=r.drillDown)==null?void 0:U.columns,filterDisplay:k,chartName:s}),x&&e.jsx(he,{x:x.x,y:x.y,field:x.field,value:x.value,allFields:x.allFields,onViewDetails:(H=r.drillDown)!=null&&H.model?Q:void 0,onGoToChart:(I=r.drillDown)!=null&&I.chart?J:void 0,detailModel:(q=r.drillDown)==null?void 0:q.model,targetChart:(z=r.drillDown)==null?void 0:z.chart,onClose:()=>_(null)})]})}function Re({parsed:s}){const l=s.params.token,[r,i]=m.useState(null),[t,c]=m.useState(!1);return m.useEffect(()=>{if(!l){i("No share token provided");return}R.getPublicConfig(l).then(()=>c(!0)).catch(()=>i("This link has expired or been revoked"))},[l]),r?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-gray-400 text-lg",children:r})})}):t?e.jsx(Ne,{value:l??null,children:e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"var(--yc-color-bg, #f9fafb)"},children:[s.type==="public_chart"?e.jsx("div",{className:"max-w-7xl mx-auto py-6 px-4",children:e.jsx(_e,{chartName:s.name})}):e.jsx(De,{dashboardId:s.name,initialTab:s.params.tab}),e.jsx("div",{className:"text-center py-4 text-xs",style:{color:"var(--yc-color-text-muted, #9ca3af)"},children:"Shared via yamchart"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})})}export{Re as PublicViewer};
@@ -1 +1 @@
1
- import{u as g,j as e,A as h}from"./index-jlfTO7f5.js";import{a as o}from"./echarts-DtOYsfLX.js";function j(){const m=g(r=>r.setup),[a,b]=o.useState(""),[l,x]=o.useState(""),[t,p]=o.useState(""),[c,y]=o.useState(""),[n,s]=o.useState(""),[d,u]=o.useState(!1),f=async r=>{if(r.preventDefault(),s(""),t!==c){s("Passwords do not match");return}if(t.length<8){s("Password must be at least 8 characters");return}u(!0);try{await m(a,l,t)}catch(i){i instanceof h?s(i.message):s("An unexpected error occurred")}finally{u(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Welcome to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Create your admin account to get started."}),n&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:n}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{id:"name",type:"text",value:l,onChange:r=>x(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Your Name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"setup-email",type:"email",value:a,onChange:r=>b(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"admin@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"setup-password",type:"password",value:t,onChange:r=>p(r.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"At least 8 characters"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm Password"}),e.jsx("input",{id:"confirm-password",type:"password",value:c,onChange:r=>y(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Confirm password"})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Creating account...":"Create Admin Account"})]})]})})}export{j as SetupWizard};
1
+ import{u as g,j as e,A as h}from"./index-iR9gLdl9.js";import{a as o}from"./echarts-DtOYsfLX.js";function j(){const m=g(r=>r.setup),[a,b]=o.useState(""),[l,x]=o.useState(""),[t,p]=o.useState(""),[c,y]=o.useState(""),[n,s]=o.useState(""),[d,u]=o.useState(!1),f=async r=>{if(r.preventDefault(),s(""),t!==c){s("Passwords do not match");return}if(t.length<8){s("Password must be at least 8 characters");return}u(!0);try{await m(a,l,t)}catch(i){i instanceof h?s(i.message):s("An unexpected error occurred")}finally{u(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Welcome to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Create your admin account to get started."}),n&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:n}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{id:"name",type:"text",value:l,onChange:r=>x(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Your Name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"setup-email",type:"email",value:a,onChange:r=>b(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"admin@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"setup-password",type:"password",value:t,onChange:r=>p(r.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"At least 8 characters"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm Password"}),e.jsx("input",{id:"confirm-password",type:"password",value:c,onChange:r=>y(r.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Confirm password"})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Creating account...":"Create Admin Account"})]})]})})}export{j as SetupWizard};
@@ -1 +1 @@
1
- import{j as e,a as c}from"./index-jlfTO7f5.js";import{a as s}from"./echarts-DtOYsfLX.js";function h(){const[o,a]=s.useState([]),[l,d]=s.useState(!0),n=async()=>{try{const r=await c.listShareLinks();a(r.links)}catch(r){console.error("Failed to load share links:",r)}finally{d(!1)}};s.useEffect(()=>{n()},[]);const i=async r=>{try{await c.revokeShareLink(r),a(t=>t.filter(x=>x.id!==r))}catch(t){console.error("Failed to revoke share link:",t)}};return l?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):e.jsxs("div",{className:"p-6 max-w-4xl",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Shared Links"}),o.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No active share links."}):e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full text-sm yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-right px-3 py-2 font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Resource"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Created"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Expires"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:o.map((r,t)=>e.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[e.jsx("td",{className:"px-3 py-3 text-right yc-row-num w-10",children:t+1}),e.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)"},children:r.resource_name}),e.jsx("td",{className:"px-4 py-3 capitalize",style:{color:"var(--yc-color-text-secondary)"},children:r.resource_type}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:new Date(r.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:r.expires_at?new Date(r.expires_at).toLocaleDateString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:()=>i(r.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Revoke"})})]},r.id))})]})})]})}export{h as ShareManagement};
1
+ import{j as e,b as c}from"./index-iR9gLdl9.js";import{a as s}from"./echarts-DtOYsfLX.js";function h(){const[o,a]=s.useState([]),[l,d]=s.useState(!0),n=async()=>{try{const r=await c.listShareLinks();a(r.links)}catch(r){console.error("Failed to load share links:",r)}finally{d(!1)}};s.useEffect(()=>{n()},[]);const i=async r=>{try{await c.revokeShareLink(r),a(t=>t.filter(x=>x.id!==r))}catch(t){console.error("Failed to revoke share link:",t)}};return l?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):e.jsxs("div",{className:"p-6 max-w-4xl",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Shared Links"}),o.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No active share links."}):e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full text-sm yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-right px-3 py-2 font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Resource"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Created"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Expires"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:o.map((r,t)=>e.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[e.jsx("td",{className:"px-3 py-3 text-right yc-row-num w-10",children:t+1}),e.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)"},children:r.resource_name}),e.jsx("td",{className:"px-4 py-3 capitalize",style:{color:"var(--yc-color-text-secondary)"},children:r.resource_type}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:new Date(r.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:r.expires_at?new Date(r.expires_at).toLocaleDateString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:()=>i(r.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Revoke"})})]},r.id))})]})})]})}export{h as ShareManagement};
@@ -1 +1 @@
1
- import{v as g,j as e,t as S,w as b}from"./index-jlfTO7f5.js";import{a as u}from"./echarts-DtOYsfLX.js";import{a as w,c as k,u as C,d as R,b as z}from"./data-3vtzSuAZ.js";function B(o){return o==null?"—":`${(o*100).toFixed(1)}%`}function N(o){return!o||o.length===0?"—":o.slice(0,3).map(r=>`${String(r.value)} (${r.count})`).join(", ")}function T({table:o}){const r=o.columns.some(t=>t.nullRate!==void 0||t.distinctCount!==void 0||t.topValues&&t.topValues.length>0),n={textAlign:"left",padding:"6px 12px",fontSize:"12px",fontWeight:600,color:"var(--yc-color-text-secondary)",borderBottom:"1px solid var(--yc-color-border)"},s={padding:"6px 12px",fontSize:"13px",color:"var(--yc-color-text)",borderBottom:"1px solid var(--yc-color-border)"};return e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:n,children:"Column"}),e.jsx("th",{style:n,children:"Type"}),r&&e.jsx("th",{style:n,children:"Null rate"}),r&&e.jsx("th",{style:n,children:"Distinct"}),r&&e.jsx("th",{style:n,children:"Top values"})]})}),e.jsx("tbody",{children:o.columns.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{...s,fontFamily:"monospace"},children:t.name}),e.jsx("td",{style:{...s,color:"var(--yc-color-text-secondary)"},children:t.type}),r&&e.jsx("td",{style:s,children:B(t.nullRate)}),r&&e.jsx("td",{style:s,children:t.distinctCount??"—"}),r&&e.jsx("td",{style:{...s,color:"var(--yc-color-text-secondary)"},children:N(t.topValues)})]},t.name))})]})}function F({connection:o}){const{data:r,isLoading:n,error:s}=g({queryKey:["source-tables",o],queryFn:()=>w(o),enabled:!!o}),[t,c]=u.useState(null),i=(r==null?void 0:r.find(l=>l.table===t))??null;return s?e.jsx("p",{className:"text-sm p-4",style:{color:"var(--yc-color-danger)"},children:"Failed to load tables."}):n?e.jsx("p",{className:"text-sm p-4",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):!r||r.length===0?e.jsxs("p",{className:"text-sm p-4",style:{color:"var(--yc-color-text-secondary)"},children:["No tables found for this source. Run ",e.jsx("code",{children:"yamchart sync-warehouse"})," or"," ",e.jsx("code",{children:"yamchart sync-dbt"})," to populate the catalog."]}):e.jsxs("div",{style:{display:"flex",gap:"16px",height:"100%"},children:[e.jsx("div",{style:{width:"240px",flexShrink:0,borderRight:"1px solid var(--yc-color-border)",overflowY:"auto"},children:r.map(l=>e.jsx("button",{onClick:()=>c(l.table),style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",fontSize:"13px",fontFamily:"monospace",background:t===l.table?"var(--yc-color-bg)":"none",border:"none",borderLeft:t===l.table?"2px solid var(--yc-color-primary)":"2px solid transparent",color:t===l.table?"var(--yc-color-text)":"var(--yc-color-text-secondary)",cursor:"pointer"},children:l.table},l.table))}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:"4px"},children:i?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",style:{color:"var(--yc-color-text)",fontFamily:"monospace"},children:i.table}),e.jsx(T,{table:i})]}):e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Select a table to view its columns."})})]})}function m({initial:o,onSave:r,onCancel:n}){const[s,t]=u.useState((o==null?void 0:o.title)??""),[c,i]=u.useState((o==null?void 0:o.content)??""),l=()=>{!s.trim()||!c.trim()||r(s.trim(),c.trim())},x={width:"100%",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"var(--yc-color-bg)",color:"var(--yc-color-text)",boxSizing:"border-box"};return e.jsxs("div",{style:{border:"1px solid var(--yc-color-border)",borderRadius:"8px",padding:"16px",marginBottom:"12px",background:"var(--yc-color-bg)"},children:[e.jsx("input",{type:"text",placeholder:"Title",value:s,onChange:p=>t(p.target.value),style:{...x,marginBottom:"8px"}}),e.jsx("textarea",{placeholder:"Business context (e.g. revenue is invoiced cash-basis)",value:c,onChange:p=>i(p.target.value),rows:4,style:{...x,resize:"vertical",fontFamily:"inherit"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"10px"},children:[e.jsx("button",{onClick:l,disabled:!s.trim()||!c.trim(),style:{padding:"6px 14px",fontSize:"13px",borderRadius:"6px",border:"none",background:"var(--yc-color-primary)",color:"#fff",cursor:s.trim()&&c.trim()?"pointer":"not-allowed",opacity:s.trim()&&c.trim()?1:.5},children:"Save"}),e.jsx("button",{onClick:n,style:{padding:"6px 14px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-text)",cursor:"pointer"},children:"Cancel"})]})]})}function K({doc:o,onEdit:r,onDelete:n}){const s=o.source==="ui";return e.jsx("div",{style:{border:"1px solid var(--yc-color-border)",borderRadius:"8px",padding:"14px 16px",marginBottom:"10px",background:"var(--yc-color-bg)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"var(--yc-color-text)"},children:o.title}),o.source==="file"&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 7px",borderRadius:"4px",background:"var(--yc-color-bg-secondary)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:"from Git"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--yc-color-text-secondary)",margin:0,whiteSpace:"pre-wrap"},children:o.content})]}),s&&e.jsxs("div",{style:{display:"flex",gap:"6px",flexShrink:0},children:[e.jsx("button",{onClick:()=>r(o),title:"Edit",style:{fontSize:"12px",padding:"4px 10px",borderRadius:"5px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-text-secondary)",cursor:"pointer"},children:"Edit"}),e.jsx("button",{onClick:()=>n(o.id),title:"Delete",style:{fontSize:"12px",padding:"4px 10px",borderRadius:"5px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-danger)",cursor:"pointer"},children:"Delete"})]})]})})}function E({connection:o}){const r=S(),[n,s]=u.useState(!1),[t,c]=u.useState(null),{data:i,isLoading:l,error:x}=g({queryKey:["knowledge",o],queryFn:()=>z(o),enabled:!!o}),p=()=>r.invalidateQueries({queryKey:["knowledge",o]}),v=b({mutationFn:({title:a,content:d})=>k(o,a,d),onSuccess:()=>{s(!1),p()}}),f=b({mutationFn:({id:a,title:d,content:y})=>C(a,{title:d,content:y}),onSuccess:()=>{c(null),p()}}),j=b({mutationFn:a=>R(a),onSuccess:p});if(x)return e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load knowledge docs."});if(l)return e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"});const h=i??[];return e.jsxs("div",{children:[!n&&!t&&e.jsx("button",{onClick:()=>s(!0),style:{marginBottom:"16px",padding:"7px 14px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-primary)",cursor:"pointer",fontWeight:500},children:"+ Add context"}),n&&e.jsx(m,{onSave:(a,d)=>v.mutate({title:a,content:d}),onCancel:()=>s(!1)}),h.length===0&&!n?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No knowledge docs yet. Click “Add context” to document business rules for this source."}):h.map(a=>(t==null?void 0:t.id)===a.id?e.jsx(m,{initial:{title:a.title,content:a.content},onSave:(d,y)=>f.mutate({id:a.id,title:d,content:y}),onCancel:()=>c(null)},a.id):e.jsx(K,{doc:a,onEdit:d=>{s(!1),c(d)},onDelete:d=>j.mutate(d)},a.id))]})}function V({connection:o}){const r=(()=>{const l=window.location.hash.split("?")[1];return(l?new URLSearchParams(l).get("sub"):null)==="knowledge"?"knowledge":"tables"})(),[n,s]=u.useState(r),t=()=>{window.location.hash="/data?tab=sources"},c=l=>{s(l),window.location.hash=`/data/sources/${encodeURIComponent(o)}?sub=${l}`},i=(l,x)=>e.jsx("button",{onClick:()=>c(l),style:{color:n===l?"var(--yc-color-primary)":"var(--yc-color-text-secondary)",borderBottom:n===l?"2px solid var(--yc-color-primary)":"2px solid transparent",paddingBottom:"6px",marginRight:"16px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:n===l?600:400},children:x},l);return e.jsxs("div",{className:"flex flex-col h-full w-full",children:[e.jsxs("div",{style:{padding:"16px 24px 0"},children:[e.jsx("button",{onClick:t,style:{fontSize:"13px",color:"var(--yc-color-text-secondary)",background:"none",border:"none",padding:0,cursor:"pointer",marginBottom:"8px"},children:"← Data Sources"}),e.jsx("h2",{className:"text-lg font-semibold mb-3",style:{color:"var(--yc-color-text)"},children:o}),e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--yc-color-border)"},children:[i("tables","Tables"),i("knowledge","Knowledge")]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",style:{padding:"16px 24px"},children:[n==="tables"&&e.jsx(F,{connection:o}),n==="knowledge"&&e.jsx(E,{connection:o})]})]})}export{V as SourceDetailView,V as default};
1
+ import{w as g,j as e,v as S,x as b}from"./index-iR9gLdl9.js";import{a as u}from"./echarts-DtOYsfLX.js";import{a as w,c as k,u as C,d as R,b as z}from"./data-3vtzSuAZ.js";function B(o){return o==null?"—":`${(o*100).toFixed(1)}%`}function N(o){return!o||o.length===0?"—":o.slice(0,3).map(r=>`${String(r.value)} (${r.count})`).join(", ")}function T({table:o}){const r=o.columns.some(t=>t.nullRate!==void 0||t.distinctCount!==void 0||t.topValues&&t.topValues.length>0),n={textAlign:"left",padding:"6px 12px",fontSize:"12px",fontWeight:600,color:"var(--yc-color-text-secondary)",borderBottom:"1px solid var(--yc-color-border)"},s={padding:"6px 12px",fontSize:"13px",color:"var(--yc-color-text)",borderBottom:"1px solid var(--yc-color-border)"};return e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:n,children:"Column"}),e.jsx("th",{style:n,children:"Type"}),r&&e.jsx("th",{style:n,children:"Null rate"}),r&&e.jsx("th",{style:n,children:"Distinct"}),r&&e.jsx("th",{style:n,children:"Top values"})]})}),e.jsx("tbody",{children:o.columns.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{...s,fontFamily:"monospace"},children:t.name}),e.jsx("td",{style:{...s,color:"var(--yc-color-text-secondary)"},children:t.type}),r&&e.jsx("td",{style:s,children:B(t.nullRate)}),r&&e.jsx("td",{style:s,children:t.distinctCount??"—"}),r&&e.jsx("td",{style:{...s,color:"var(--yc-color-text-secondary)"},children:N(t.topValues)})]},t.name))})]})}function F({connection:o}){const{data:r,isLoading:n,error:s}=g({queryKey:["source-tables",o],queryFn:()=>w(o),enabled:!!o}),[t,c]=u.useState(null),i=(r==null?void 0:r.find(l=>l.table===t))??null;return s?e.jsx("p",{className:"text-sm p-4",style:{color:"var(--yc-color-danger)"},children:"Failed to load tables."}):n?e.jsx("p",{className:"text-sm p-4",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):!r||r.length===0?e.jsxs("p",{className:"text-sm p-4",style:{color:"var(--yc-color-text-secondary)"},children:["No tables found for this source. Run ",e.jsx("code",{children:"yamchart sync-warehouse"})," or"," ",e.jsx("code",{children:"yamchart sync-dbt"})," to populate the catalog."]}):e.jsxs("div",{style:{display:"flex",gap:"16px",height:"100%"},children:[e.jsx("div",{style:{width:"240px",flexShrink:0,borderRight:"1px solid var(--yc-color-border)",overflowY:"auto"},children:r.map(l=>e.jsx("button",{onClick:()=>c(l.table),style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",fontSize:"13px",fontFamily:"monospace",background:t===l.table?"var(--yc-color-bg)":"none",border:"none",borderLeft:t===l.table?"2px solid var(--yc-color-primary)":"2px solid transparent",color:t===l.table?"var(--yc-color-text)":"var(--yc-color-text-secondary)",cursor:"pointer"},children:l.table},l.table))}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:"4px"},children:i?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",style:{color:"var(--yc-color-text)",fontFamily:"monospace"},children:i.table}),e.jsx(T,{table:i})]}):e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Select a table to view its columns."})})]})}function m({initial:o,onSave:r,onCancel:n}){const[s,t]=u.useState((o==null?void 0:o.title)??""),[c,i]=u.useState((o==null?void 0:o.content)??""),l=()=>{!s.trim()||!c.trim()||r(s.trim(),c.trim())},x={width:"100%",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"var(--yc-color-bg)",color:"var(--yc-color-text)",boxSizing:"border-box"};return e.jsxs("div",{style:{border:"1px solid var(--yc-color-border)",borderRadius:"8px",padding:"16px",marginBottom:"12px",background:"var(--yc-color-bg)"},children:[e.jsx("input",{type:"text",placeholder:"Title",value:s,onChange:p=>t(p.target.value),style:{...x,marginBottom:"8px"}}),e.jsx("textarea",{placeholder:"Business context (e.g. revenue is invoiced cash-basis)",value:c,onChange:p=>i(p.target.value),rows:4,style:{...x,resize:"vertical",fontFamily:"inherit"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"10px"},children:[e.jsx("button",{onClick:l,disabled:!s.trim()||!c.trim(),style:{padding:"6px 14px",fontSize:"13px",borderRadius:"6px",border:"none",background:"var(--yc-color-primary)",color:"#fff",cursor:s.trim()&&c.trim()?"pointer":"not-allowed",opacity:s.trim()&&c.trim()?1:.5},children:"Save"}),e.jsx("button",{onClick:n,style:{padding:"6px 14px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-text)",cursor:"pointer"},children:"Cancel"})]})]})}function K({doc:o,onEdit:r,onDelete:n}){const s=o.source==="ui";return e.jsx("div",{style:{border:"1px solid var(--yc-color-border)",borderRadius:"8px",padding:"14px 16px",marginBottom:"10px",background:"var(--yc-color-bg)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"var(--yc-color-text)"},children:o.title}),o.source==="file"&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 7px",borderRadius:"4px",background:"var(--yc-color-bg-secondary)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:"from Git"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--yc-color-text-secondary)",margin:0,whiteSpace:"pre-wrap"},children:o.content})]}),s&&e.jsxs("div",{style:{display:"flex",gap:"6px",flexShrink:0},children:[e.jsx("button",{onClick:()=>r(o),title:"Edit",style:{fontSize:"12px",padding:"4px 10px",borderRadius:"5px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-text-secondary)",cursor:"pointer"},children:"Edit"}),e.jsx("button",{onClick:()=>n(o.id),title:"Delete",style:{fontSize:"12px",padding:"4px 10px",borderRadius:"5px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-danger)",cursor:"pointer"},children:"Delete"})]})]})})}function E({connection:o}){const r=S(),[n,s]=u.useState(!1),[t,c]=u.useState(null),{data:i,isLoading:l,error:x}=g({queryKey:["knowledge",o],queryFn:()=>z(o),enabled:!!o}),p=()=>r.invalidateQueries({queryKey:["knowledge",o]}),v=b({mutationFn:({title:a,content:d})=>k(o,a,d),onSuccess:()=>{s(!1),p()}}),f=b({mutationFn:({id:a,title:d,content:y})=>C(a,{title:d,content:y}),onSuccess:()=>{c(null),p()}}),j=b({mutationFn:a=>R(a),onSuccess:p});if(x)return e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load knowledge docs."});if(l)return e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"});const h=i??[];return e.jsxs("div",{children:[!n&&!t&&e.jsx("button",{onClick:()=>s(!0),style:{marginBottom:"16px",padding:"7px 14px",fontSize:"13px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",background:"none",color:"var(--yc-color-primary)",cursor:"pointer",fontWeight:500},children:"+ Add context"}),n&&e.jsx(m,{onSave:(a,d)=>v.mutate({title:a,content:d}),onCancel:()=>s(!1)}),h.length===0&&!n?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No knowledge docs yet. Click “Add context” to document business rules for this source."}):h.map(a=>(t==null?void 0:t.id)===a.id?e.jsx(m,{initial:{title:a.title,content:a.content},onSave:(d,y)=>f.mutate({id:a.id,title:d,content:y}),onCancel:()=>c(null)},a.id):e.jsx(K,{doc:a,onEdit:d=>{s(!1),c(d)},onDelete:d=>j.mutate(d)},a.id))]})}function V({connection:o}){const r=(()=>{const l=window.location.hash.split("?")[1];return(l?new URLSearchParams(l).get("sub"):null)==="knowledge"?"knowledge":"tables"})(),[n,s]=u.useState(r),t=()=>{window.location.hash="/data?tab=sources"},c=l=>{s(l),window.location.hash=`/data/sources/${encodeURIComponent(o)}?sub=${l}`},i=(l,x)=>e.jsx("button",{onClick:()=>c(l),style:{color:n===l?"var(--yc-color-primary)":"var(--yc-color-text-secondary)",borderBottom:n===l?"2px solid var(--yc-color-primary)":"2px solid transparent",paddingBottom:"6px",marginRight:"16px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:n===l?600:400},children:x},l);return e.jsxs("div",{className:"flex flex-col h-full w-full",children:[e.jsxs("div",{style:{padding:"16px 24px 0"},children:[e.jsx("button",{onClick:t,style:{fontSize:"13px",color:"var(--yc-color-text-secondary)",background:"none",border:"none",padding:0,cursor:"pointer",marginBottom:"8px"},children:"← Data Sources"}),e.jsx("h2",{className:"text-lg font-semibold mb-3",style:{color:"var(--yc-color-text)"},children:o}),e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--yc-color-border)"},children:[i("tables","Tables"),i("knowledge","Knowledge")]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",style:{padding:"16px 24px"},children:[n==="tables"&&e.jsx(F,{connection:o}),n==="knowledge"&&e.jsx(E,{connection:o})]})]})}export{V as SourceDetailView,V as default};
@@ -0,0 +1 @@
1
+ import{a as P,j as e,b,A as j}from"./index-iR9gLdl9.js";import{a as l}from"./echarts-DtOYsfLX.js";function K(){var A;const[d,N]=l.useState([]),[h,C]=l.useState(!0),[v,g]=l.useState(!1),[x,k]=l.useState(""),[a,f]=l.useState(null),[i,c]=l.useState([]),[m,y]=l.useState(!1),[w,s]=l.useState(null),u=P(t=>t.addToast),p=async()=>{try{const{users:t}=await b.authListUsers();N(t)}catch{k("Failed to load users")}finally{C(!1)}};l.useEffect(()=>{p()},[]);const E=async(t,r)=>{try{await b.authUpdateUser(t,{role:r}),await p()}catch(o){u(o instanceof j?o.message:"Failed to update role","error")}},L=t=>{s(t)},D=async t=>{s(null);try{await b.authDeleteUser(t),await p()}catch(r){u(r instanceof j?r.message:"Failed to delete user","error")}},M=t=>{if(a===t.id)f(null),c([]);else{f(t.id);const r=JSON.parse(t.attributes||"{}");c(Object.entries(r).map(([o,n])=>({key:o,value:n})))}},S=(t,r,o)=>{c(n=>n.map((U,I)=>I===t?{...U,[r]:o}:U))},R=()=>{c(t=>[...t,{key:"",value:""}])},F=t=>{c(r=>r.filter((o,n)=>n!==t))},O=async()=>{if(a){y(!0);try{const t={};for(const{key:r,value:o}of i){const n=r.trim();n&&(t[n]=o)}await b.authUpdateUser(a,{attributes:t}),await p(),c(Object.entries(t).map(([r,o])=>({key:r,value:o})))}catch(t){u(t instanceof j?t.message:"Failed to save attributes","error")}finally{y(!1)}}};return h?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading users..."}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:"User Management"}),e.jsx("button",{onClick:()=>g(!0),className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700",children:"Add User"})]}),x&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:x}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-right text-xs font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Created"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:"var(--yc-color-border)"},children:d.map((t,r)=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"px-3 py-3 text-right text-sm yc-row-num w-10",children:r+1}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text)"},children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:t.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:t.role,onChange:o=>E(t.id,o.target.value),className:"text-sm border rounded px-2 py-1",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>M(t),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:a===t.id?"Hide Attrs":"Attrs"}),w===t.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm?"}),e.jsx("button",{onClick:()=>D(t.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Yes, delete"}),e.jsx("button",{onClick:()=>s(null),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>L(t.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Delete"})]})]},t.id))})]})}),a&&e.jsxs("div",{className:"mt-4 rounded-lg p-4",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--yc-color-text-secondary)"},children:["Attributes for ",(A=d.find(t=>t.id===a))==null?void 0:A.name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:R,className:"px-3 py-1 text-xs font-medium rounded hover:opacity-80",style:{color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 50%, transparent)"},children:"Add Attribute"}),e.jsx("button",{onClick:O,disabled:m,className:"px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded hover:bg-blue-700 disabled:opacity-50",children:m?"Saving...":"Save"})]})]}),i.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:'No attributes. Click "Add Attribute" to define key-value pairs for row-level security.'}):e.jsx("div",{className:"space-y-2",children:i.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key (e.g. department)",value:t.key,onChange:o=>S(r,"key",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("input",{type:"text",placeholder:"Value (e.g. Sales)",value:t.value,onChange:o=>S(r,"value",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("button",{onClick:()=>F(r),className:"p-1.5 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},title:"Remove attribute",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r))})]}),v&&e.jsx(T,{onClose:()=>g(!1),onCreated:p})]})}function T({onClose:d,onCreated:N}){const[h,C]=l.useState(""),[v,g]=l.useState(""),[x,k]=l.useState(""),[a,f]=l.useState("viewer"),[i,c]=l.useState(""),[m,y]=l.useState(!1),w=async s=>{s.preventDefault(),c(""),y(!0);try{await b.authCreateUser({email:h,name:v,password:x,role:a}),N(),d()}catch(u){c(u instanceof j?u.message:"Failed to create user")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:d,children:e.jsxs("div",{className:"rounded-lg shadow-lg p-6 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)"},onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Add User"}),i&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:i}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{type:"text",value:v,onChange:s=>g(s.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{type:"email",value:h,onChange:s=>C(s.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:["Temporary Password ",e.jsx("span",{style:{color:"var(--yc-color-text-secondary)"},children:"(optional)"})]}),e.jsx("input",{type:"password",value:x,onChange:s=>k(s.target.value),minLength:8,placeholder:"Leave blank to invite via SSO",className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--yc-color-text-secondary)"},children:"Leave blank to invite an SSO user — they sign in with their provider, no password."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Role"}),e.jsxs("select",{value:a,onChange:s=>f(s.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:d,className:"px-4 py-2 text-sm hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Creating...":"Create User"})]})]})]})})}export{K as UserManagement};