@flesler/cursor-canvas-web 1.2.1 → 1.3.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("@mantine/core"),j=require("react"),k=require("./host-tokens-Cjzmp0z_.cjs"),D=require("@mantine/charts"),w={success:"#1F8A65",danger:"#CF2D56",warning:"#E8A33D",info:"#2E79B5",neutral:"#8888A8",added:"#1F8A65",deleted:"#CF2D56",renamed:"#5A6CC0"},te={success:"green",danger:"red",warning:"orange",info:"blue",neutral:"gray",added:"green",deleted:"red",renamed:"indigo"};function g(){const t=p.useComputedColorScheme("light")==="dark"?"dark":"light";return k.resolveThemeForColorScheme(t)}const ne={verticalAlign:"bottom",align:"center"},re={legend:{justifyContent:"center"}};function G(){const t=g().chart.sequence;return(n,o)=>n?w[n]:t[o%t.length]}function oe(){const t=g().text.primary;return{textColor:t,barLabelColor:t}}function se(e,t){return e.map((n,o)=>{const a={category:n};for(const s of t)a[s.name]=s.data[o]??0;return a})}function ae(e,t){return e.map((n,o)=>({name:n.name,color:t(n.tone,o)}))}function ie(e,t){return n=>`${t??""}${n}${e??""}`}function pe(e,t){if(e!=null&&e.length)return e.map(n=>({...t?{x:n.value}:{y:n.value},label:n.label,color:n.tone?w[n.tone]:w.neutral}))}const ye=new Set(["log","symlog","pow","sqrt"]);function ge(e){const{scale:t}=e;return typeof t!="string"||!ye.has(t)?e:{...e,type:e.type??"number",allowDataOverflow:e.allowDataOverflow??!0,allowDecimals:e.allowDecimals??!0,domain:e.domain??[1,"dataMax"]}}function le(e){const t=pe(e.referenceLines,!!e.horizontal);let n;if(!e.stacked&&!e.normalized){const s=e.beginAtZero!==!1;n=[e.yMin??(s?0:"auto"),e.yMax??"auto"]}const o=e.valueAxis?ge(e.valueAxis):void 0;if(!n&&!o)return{referenceLines:t};const a={...n&&{domain:n},...o};return e.horizontal?{xAxisProps:a,referenceLines:t}:{yAxisProps:a,referenceLines:t}}function xe(e,t,n){return e!==void 0?e:t.length===1&&n.length<=8}const Q=14;function me(e){return e.length<=Q?e:`${e.slice(0,Q-1)}…`}function be(e){var s;const t=typeof e.x=="number"?e.x:Number(e.x)||0,n=typeof e.y=="number"?e.y:Number(e.y)||0,o=String(((s=e.payload)==null?void 0:s.value)??""),a=me(o);return r.jsx("g",{transform:`translate(${t},${n})`,children:r.jsxs("text",{x:-10,y:0,dy:4,textAnchor:"end",fill:"currentColor",fontSize:12,children:[r.jsx("title",{children:o}),a]})})}function je(e){return{fontWeight:700,fill:e}}function ve(){return{yAxisProps:{tick:be,width:96},barChartProps:{margin:{right:32}}}}function Se(){return{barChartProps:{margin:{top:22}}}}function ke({categories:e,series:t,height:n=240,fill:o,valueSuffix:a,valuePrefix:s,showValues:c,showHoverGuide:f=!0,beginAtZero:d,yMin:l,yMax:u,referenceLines:x,style:b,extra:h,smooth:C}){const L=(h==null?void 0:h.smooth)??C,T=G(),P=oe(),M=se(e,t),E=ae(t,T),v=!!(o&&(h!=null&&h.stacked)),F=le({beginAtZero:d,yMin:l,yMax:u,referenceLines:x,horizontal:!1,stacked:v,valueAxis:h==null?void 0:h.valueAxis}),A={h:n,data:M,dataKey:"category",series:E,curveType:L?"monotone":"linear",withLegend:t.length>1,legendProps:ne,valueFormatter:ie(a,s),withPointLabels:c??e.length<=20,tooltipProps:f?void 0:{cursor:!1},styles:{...re,legendItemName:{color:P.textColor}},...P,...F,style:b};return o?r.jsx(D.AreaChart,{...A,type:v?"stacked":"default"}):r.jsx(D.LineChart,{...A})}function Ce({categories:e,series:t,height:n=240,stacked:o,horizontal:a,normalized:s,valueSuffix:c,valuePrefix:f,showValues:d,beginAtZero:l,yMin:u,yMax:x,referenceLines:b,style:h,extra:C}){const L=G(),T=oe(),P=se(e,t),M=s?"percent":o?"stacked":"default",E=le({beginAtZero:l,yMin:u,yMax:x,referenceLines:b,horizontal:a,stacked:o,normalized:s,valueAxis:C==null?void 0:C.valueAxis}),v=!o&&!s&&xe(d,t,e);return r.jsx(D.BarChart,{h:n,data:P,dataKey:"category",series:ae(t,L),type:M,orientation:a?"vertical":"horizontal",withLegend:t.length>1,legendProps:ne,valueFormatter:ie(c,f),withBarValueLabel:v,...v?{valueLabelProps:je(T.barLabelColor)}:{},...a?ve():v?Se():{},styles:{...re,legendItemName:{color:T.textColor}},...T,...E,style:h})}const we=180,Te=540;function Le(e,t){if(t<=0)return"0%";const n=e/t*100;return n<10&&Math.abs(n-Math.round(n))>.05?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function Pe(e){return Math.max(28,Math.round(e*.22))}function Ae(e){return e.map(t=>({dataKey:t.name,value:t.name,color:t.color,type:"circle"}))}function Me(e,t){return e.map(n=>({name:n.name,color:n.color,label:`${n.name} ${Le(n.value,t)}`}))}function Be({total:e,family:t,primary:n,subtitle:o}){return r.jsxs("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"central",fontFamily:t,children:[r.jsx("tspan",{x:"50%",dy:"-0.4em",fontSize:20,fontWeight:600,fill:n,children:e}),r.jsx("tspan",{x:"50%",dy:"1.55em",fontSize:16,fontWeight:500,fill:o,children:"Total"})]})}function De({data:e,size:t=200,donut:n,style:o}){const[a,s]=j.useState(null),c=g(),f=G(),d=e.map((h,C)=>({name:h.label,value:h.value,color:f(h.tone,C)})),l=d.reduce((h,C)=>h+C.value,0),u={startAngle:we,endAngle:Te},x=h=>({opacity:a===null||a===h?1:.35}),b=n?r.jsx(D.DonutChart,{data:d,size:t,thickness:Pe(t),withTooltip:!0,cellProps:h=>x(h.name),...u,children:r.jsx(Be,{total:l,family:c.typography.fontFamily,primary:c.text.primary,subtitle:c.text.secondary})}):r.jsx(D.PieChart,{data:d,size:t,withTooltip:!0,withLabelsLine:!1,cellProps:h=>x(h.name),...u});return r.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",...o},children:[r.jsx("div",{style:{width:"100%",height:t,minHeight:t,display:"flex",alignItems:"center",justifyContent:"center"},children:b}),r.jsx(D.ChartLegend,{payload:Ae(d),series:Me(d,l),legendPosition:"bottom",centered:!0,onHighlight:s,mt:"sm",w:"100%",styles:{legend:{justifyContent:"center",gap:12,color:c.text.primary},legendItemName:{color:c.text.primary}}})]})}function Ee(e){const{nodes:t,edges:n,direction:o="vertical",nodeWidth:a=160,nodeHeight:s=40,rankGap:c=64,nodeGap:f=48,padding:d=24}=e,l=t.map(i=>i.id),u=new Set(l),x=new Map;for(const i of l)x.set(i,[]);for(const i of n)u.has(i.from)&&u.has(i.to)&&x.get(i.from).push(i.to);const b=0,h=1,C=2,L=new Map(l.map(i=>[i,b])),T=new Set,P=(i,y)=>`${i}\0${y}`,M=i=>{L.set(i,h);for(const y of x.get(i)??[]){const m=L.get(y);m===h?T.add(P(i,y)):m===b&&M(y)}L.set(i,C)};for(const i of l)L.get(i)===b&&M(i);const E=n.filter(i=>u.has(i.from)&&u.has(i.to)&&!T.has(P(i.from,i.to))),v=new Map(l.map(i=>[i,0])),F=new Map(l.map(i=>[i,[]]));for(const i of E)F.get(i.from).push(i.to),v.set(i.to,(v.get(i.to)??0)+1);const A=new Map(l.map(i=>[i,0])),N=l.filter(i=>(v.get(i)??0)===0);for(;N.length>0;){const i=N.shift(),y=A.get(i);for(const m of F.get(i))A.set(m,Math.max(A.get(m),y+1)),v.set(m,v.get(m)-1),v.get(m)===0&&N.push(m)}const B=new Map;for(const i of l){const y=A.get(i);B.has(y)||B.set(y,[]),B.get(y).push(i)}const R=[...B.keys()].sort((i,y)=>i-y),S=o==="vertical",$=i=>i*(S?a:s)+Math.max(0,i-1)*f,q=Math.max(0,...R.map(i=>$(B.get(i).length))),H=new Map,K=[];R.forEach((i,y)=>{const m=B.get(i),z=$(m.length),_=d+(q-z)/2,I=d+y*((S?s:a)+c);m.forEach((U,Z)=>{const J=_+Z*((S?a:s)+f),fe=S?J:I,he=S?I:J;H.set(U,{id:U,x:fe,y:he,rank:i,order:Z})}),K.push({rank:i,x:S?_:I,y:S?I:_,width:S?z:a,height:S?s:z,nodeIds:m})});const V=(i,y)=>i?S?{x:i.x+a/2,y:y==="source"?i.y+s:i.y}:{x:y==="source"?i.x+a:i.x,y:i.y+s/2}:{x:0,y:0},ue=n.filter(i=>u.has(i.from)&&u.has(i.to)).map(i=>{const y=V(H.get(i.from),"source"),m=V(H.get(i.to),"target");return{from:i.from,to:i.to,sourceX:y.x,sourceY:y.y,targetX:m.x,targetY:m.y,isBackEdge:T.has(P(i.from,i.to))}}),X=d*2+R.length*(S?s:a)+Math.max(0,R.length-1)*c,Y=d*2+q;return{nodes:[...H.values()],edges:ue,ranks:K,direction:o,width:S?Y:X,height:S?X:Y}}function Fe({additions:e=0,deletions:t=0,style:n}){return e===0&&t===0?null:r.jsxs("span",{style:{display:"inline-flex",gap:8,fontVariantNumeric:"tabular-nums",fontSize:12,fontWeight:600,...n},children:[e>0&&r.jsxs("span",{style:{color:w.added},children:["+",e]}),t>0&&r.jsxs("span",{style:{color:w.deleted},children:["-",t]})]})}const Re={added:"+",removed:"-",unchanged:" "};function He({lines:e,showLineNumbers:t=!0,coloredLineNumbers:n=!0,showAccentStrip:o=!0,style:a}){const s=g(),c=l=>l==="added"?s.diff.insertedLine:l==="removed"?s.diff.removedLine:"transparent",f=l=>l==="added"?s.diff.stripAdded:l==="removed"?s.diff.stripRemoved:"transparent",d=l=>n&&l==="added"?w.added:n&&l==="removed"?w.deleted:s.text.tertiary;return r.jsx("div",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:12.5,lineHeight:"18px",color:s.text.primary,overflowX:"auto",...a},children:e.map((l,u)=>r.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:c(l.type),borderLeft:o?`3px solid ${f(l.type)}`:void 0},children:[t&&r.jsx("span",{style:{flex:"0 0 auto",width:40,textAlign:"right",paddingRight:10,userSelect:"none",color:d(l.type)},children:l.lineNumber??""}),r.jsx("span",{style:{flex:"0 0 auto",width:14,textAlign:"center",userSelect:"none",color:d(l.type)},children:Re[l.type]}),r.jsx("pre",{style:{margin:0,padding:"0 8px",whiteSpace:"pre",fontFamily:"inherit"},children:l.content})]},u))})}function Ie({status:e}){const t=g(),n=e==="completed"?w.success:e==="in_progress"?t.accent.primary:e==="cancelled"?w.danger:t.text.tertiary;return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",style:{flex:"0 0 auto",marginTop:3},"aria-hidden":!0,children:[r.jsx("circle",{cx:7,cy:7,r:6,stroke:n,strokeWidth:1.4}),e==="completed"&&r.jsx("path",{d:"M4 7.2l2 2 4-4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}),e==="in_progress"&&r.jsx("circle",{cx:7,cy:7,r:3,fill:n}),e==="cancelled"&&r.jsx("path",{d:"M4.8 4.8l4.4 4.4M9.2 4.8l-4.4 4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round"})]})}function ce({todos:e,dimmedTodoIds:t,onTodoClick:n,style:o}){const a=g();return e.length===0?null:r.jsx("div",{style:{display:"flex",flexDirection:"column",...o},children:e.map(s=>{const c=t==null?void 0:t.has(s.id);return r.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(s),style:{display:"flex",gap:8,alignItems:"flex-start",width:"100%",textAlign:"left",padding:"4px 6px",background:"transparent",border:"none",cursor:n?"pointer":"default",color:a.text.primary,fontSize:14,lineHeight:"20px",opacity:c?.45:1},children:[r.jsx(Ie,{status:s.status}),r.jsx("span",{style:{textDecoration:s.status==="cancelled"?"line-through":void 0,color:s.status==="cancelled"?a.text.tertiary:void 0},children:s.content})]},s.id)})})}function Ne({todos:e,dimmedTodoIds:t,defaultExpanded:n=!1,onTodoClick:o,style:a}){const s=g(),[c,f]=j.useState(n);if(e.length===0)return null;const d=e.filter(l=>l.status==="completed").length;return r.jsxs("div",{style:{border:`1px solid ${s.stroke.primary}`,borderRadius:6,overflow:"hidden",...a},children:[r.jsxs("button",{type:"button",onClick:()=>f(l=>!l),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:s.fill.secondary,border:"none",cursor:"pointer",color:s.text.secondary,fontSize:12,fontWeight:600},children:[r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:c?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{children:"Todos"}),r.jsx("span",{style:{flex:1}}),r.jsxs("span",{children:[d," of ",e.length," Done"]})]}),c&&r.jsx("div",{style:{padding:6},children:r.jsx(ce,{todos:e,dimmedTodoIds:t,onTodoClick:o})})]})}function ze(e,t){const n=`canvas:${e}`,[o,a]=j.useState(()=>{if(typeof localStorage>"u")return t;try{const c=localStorage.getItem(n);return c===null?t:JSON.parse(c)}catch{return t}}),s=j.useCallback(c=>{a(f=>{const d=typeof c=="function"?c(f):c;try{localStorage==null||localStorage.setItem(n,JSON.stringify(d))}catch{}return d})},[n]);return[o,s]}function _e(){return j.useCallback(e=>{},[])}function Ge(e,t){return{...e,...t}}function O(e,t,n){const o=e.typography[t];return{fontFamily:e.typography.fontFamily,fontSize:o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,color:e.text.primary,margin:0,...n}}function Oe({children:e,style:t}){const n=g();return r.jsx(p.Title,{order:1,style:O(n,"h1",t),children:e})}function We({children:e,style:t}){const n=g();return r.jsx(p.Title,{order:2,style:O(n,"h2",t),children:e})}function $e({children:e,style:t}){const n=g();return r.jsx(p.Title,{order:3,style:O(n,"h3",t),children:e})}const qe={normal:400,medium:500,semibold:600,bold:700};function Ke({children:e,tone:t="primary",size:n="body",as:o="p",weight:a="normal",italic:s,truncate:c,style:f}){const d=g();return r.jsx(p.Text,{component:o,size:n==="small"?"xs":"sm",fw:qe[a],c:t==="primary"?void 0:d.text[t],truncate:c,style:{fontStyle:s?"italic":void 0,...t==="primary"?{color:d.text.primary}:void 0,fontFamily:d.typography.fontFamily,...f},children:e})}function Ve({children:e,style:t}){const n=g();return r.jsx("code",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:"0.92em",color:n.text.primary,background:n.fill.secondary,borderRadius:n.radius.sm,padding:"1px 4px",...t},children:e})}function Xe({children:e,href:t,style:n}){const o=g();return r.jsx("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:o.text.link,...n},children:e})}function Ye({children:e,gap:t,style:n}){return r.jsx(p.Stack,{gap:t,style:n,children:e})}const ee={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch","space-between":"space-between"};function Ue({children:e,gap:t,align:n="center",justify:o="start",wrap:a=!1,style:s}){return r.jsx(p.Group,{gap:t,align:ee[n],justify:ee[o],wrap:a?"wrap":"nowrap",style:s,children:e})}function Ze(){return r.jsx("div",{style:{flex:1}})}function Je({children:e,columns:t,gap:n=16,align:o,style:a}){const s=typeof t=="number"?`repeat(${t}, minmax(0, 1fr))`:t;return r.jsx("div",{style:{display:"grid",gridTemplateColumns:s,gap:n,alignItems:o,...a},children:e})}function Qe({style:e}){return r.jsx(p.Divider,{style:e})}const W=j.createContext({collapsible:!1,open:!0,toggle:()=>{}});function et({children:e,variant:t="default",collapsible:n=!1,defaultOpen:o=!0,open:a,onOpenChange:s,style:c}){const f=g(),[d,l]=j.useState(o),u=a??d,x=j.useCallback(()=>{const b=!u;a===void 0&&l(b),s==null||s(b)},[u,a,s]);return r.jsx(p.Card,{withBorder:t!=="borderless",radius:f.radius.md,padding:0,style:{background:f.bg.elevated,borderColor:f.stroke.secondary,...c},children:r.jsx(W.Provider,{value:{collapsible:n,open:u,toggle:x},children:e})})}function tt({children:e,trailing:t,style:n}){const o=g(),{collapsible:a,open:s,toggle:c}=j.useContext(W);return r.jsxs("div",{onClick:a?c:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 14px",borderBottom:`1px solid ${o.stroke.secondary}`,fontSize:o.typography.small.fontSize,fontWeight:o.typography.h3.fontWeight,color:o.text.primary,fontFamily:o.typography.fontFamily,cursor:a?"pointer":void 0,userSelect:a?"none":void 0,...n},children:[r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[a&&r.jsx(de,{expanded:s}),e]}),t!=null&&r.jsx("span",{children:t})]})}function nt({children:e,style:t}){const{collapsible:n,open:o}=j.useContext(W);return n&&!o?null:r.jsx("div",{style:{padding:14,...t},children:e})}function de({expanded:e}){return r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:e?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})})}function rt({value:e,label:t,tone:n,style:o}){const a=g();return r.jsxs("div",{style:o,children:[r.jsx(p.Text,{fz:22,fw:700,lh:1.2,style:{color:n?w[n]:a.text.primary,fontFamily:a.typography.fontFamily},children:e}),r.jsx(p.Text,{fz:12,style:{color:a.text.tertiary,fontFamily:a.typography.fontFamily},children:t})]})}function ot({children:e,active:t,tone:n="neutral",size:o="md",leadingContent:a,keyboardHint:s,title:c,style:f,onClick:d}){return r.jsx(p.Badge,{color:te[n],variant:t?"filled":"light",size:o==="sm"?"sm":"md",leftSection:a,rightSection:s,title:c,onClick:d,style:{cursor:d?"pointer":void 0,textTransform:"none",...f},children:e})}function st({children:e,tone:t="neutral",title:n,icon:o,style:a}){return r.jsx(p.Alert,{color:te[t],title:n,icon:o,variant:"light",style:a,children:e})}const at={success:"rgba(31,138,101,0.12)",danger:"rgba(207,45,86,0.12)",warning:"rgba(232,163,61,0.14)",info:"rgba(46,121,181,0.12)",neutral:"rgba(136,136,168,0.12)"};function it({headers:e,rows:t,columnAlign:n,rowTone:o,framed:a=!0,striped:s,stickyHeader:c,style:f,emptyMessage:d}){return r.jsxs(p.Table,{withTableBorder:a,withColumnBorders:!1,striped:s,stickyHeader:c,highlightOnHover:!0,style:f,children:[r.jsx(p.Table.Thead,{children:r.jsx(p.Table.Tr,{children:e.map((l,u)=>r.jsx(p.Table.Th,{ta:(n==null?void 0:n[u])??"left",children:l},u))})}),r.jsx(p.Table.Tbody,{children:t.length===0?r.jsx(p.Table.Tr,{children:r.jsx(p.Table.Td,{colSpan:e.length,ta:"center",c:"dimmed",children:d??"No data"})}):t.map((l,u)=>{const x=o==null?void 0:o[u];return r.jsx(p.Table.Tr,{style:x?{background:at[x]}:void 0,children:e.map((b,h)=>r.jsx(p.Table.Td,{ta:(n==null?void 0:n[h])??"left",children:l[h]},h))},u)})})]})}const lt={primary:"filled",secondary:"default",ghost:"subtle"};function ct({children:e,variant:t="secondary",disabled:n,type:o="button",style:a,onClick:s}){return r.jsx(p.Button,{variant:lt[t],color:t==="primary"?"accent":void 0,size:"xs",disabled:n,type:o,onClick:s,style:a,children:e})}function dt({children:e,onClick:t,disabled:n,title:o,variant:a="default",size:s="md",style:c}){return r.jsx(p.ActionIcon,{variant:a==="circle"?"light":"subtle",radius:a==="circle"?"xl":"sm",size:s==="sm"?"sm":"md",color:"gray",disabled:n,title:o,"aria-label":o,onClick:t,style:c,children:e})}function ut({value:e,onChange:t,options:n,placeholder:o,disabled:a,style:s}){return r.jsx(p.Select,{value:e,data:n,placeholder:o,disabled:a,allowDeselect:!1,onChange:c=>{c!==null&&(t==null||t(c))},style:s})}function ft({checked:e,onChange:t,disabled:n,label:o,style:a}){return r.jsx(p.Checkbox,{checked:e,disabled:n,label:o,onChange:s=>t==null?void 0:t(s.currentTarget.checked),style:a})}function ht({checked:e,onChange:t,disabled:n,size:o="sm",style:a}){return r.jsx(p.Switch,{checked:e,disabled:n,size:o==="sm"?"sm":"md",onChange:s=>t==null?void 0:t(s.currentTarget.checked),style:a})}function pt({value:e,onChange:t,placeholder:n,disabled:o,type:a,style:s}){return r.jsx(p.TextInput,{value:e,placeholder:n,disabled:o,type:a,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:s})}function yt({value:e,onChange:t,placeholder:n,disabled:o,rows:a=3,style:s}){return r.jsx(p.Textarea,{value:e,placeholder:n,disabled:o,autosize:!0,minRows:a,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:s})}function gt({color:e,style:t}){const n=g();return r.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:4,background:n.category[e],flex:"0 0 auto",...t}})}function xt({segments:e,total:t,topLeftLabel:n,topRightLabel:o,style:a}){const s=g(),c=t>0?t:1,f=e.reduce((l,u)=>l+(Number.isFinite(u.value)&&u.value>0?u.value:0),0),d=Math.max(0,c-f);return r.jsxs("div",{style:a,children:[(n!=null||o!=null)&&r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:s.text.secondary,marginBottom:6},children:[r.jsx("span",{children:n}),r.jsx("span",{children:o})]}),r.jsxs("div",{style:{display:"flex",gap:2,height:8},children:[e.map((l,u)=>{const x=Number.isFinite(l.value)&&l.value>0?l.value:0,b=s.category[l.color??k.usageColorSequence[u%k.usageColorSequence.length]];return r.jsx("div",{style:{width:`${x/c*100}%`,background:b,borderRadius:3}},l.id)}),d>0&&r.jsx("div",{style:{width:`${d/c*100}%`,background:s.fill.tertiary,borderRadius:3}})]})]})}function mt({title:e,leading:t,count:n,trailing:o,children:a,defaultOpen:s=!1,style:c}){const f=g(),[d,l]=j.useState(s);return r.jsxs("div",{style:c,children:[r.jsxs("div",{onClick:()=>l(u=>!u),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",cursor:"pointer",userSelect:"none",color:f.text.primary,fontSize:14},children:[r.jsx(de,{expanded:d}),t,r.jsx("span",{style:{fontWeight:500},children:e}),n!=null&&r.jsx("span",{style:{color:f.text.tertiary,fontSize:12},children:n}),r.jsx("span",{style:{flex:1}}),o!=null&&r.jsx("span",{style:{color:f.text.tertiary},children:o})]}),d&&r.jsx("div",{style:{paddingLeft:18,paddingBottom:4},children:a})]})}Object.defineProperty(exports,"useEffect",{enumerable:!0,get:()=>j.useEffect});Object.defineProperty(exports,"useMemo",{enumerable:!0,get:()=>j.useMemo});Object.defineProperty(exports,"useRef",{enumerable:!0,get:()=>j.useRef});Object.defineProperty(exports,"useState",{enumerable:!0,get:()=>j.useState});exports.canvasPaletteDark=k.canvasPaletteDark;exports.canvasPaletteGrokDark=k.canvasPaletteGrokDark;exports.canvasPaletteGrokLight=k.canvasPaletteGrokLight;exports.canvasPaletteLight=k.canvasPaletteLight;exports.canvasTokens=k.canvasTokens;exports.canvasTokensLight=k.canvasTokensLight;exports.categoryPaletteDark=k.categoryPaletteDark;exports.categoryPaletteLight=k.categoryPaletteLight;exports.colorPalette=k.colorPalette;exports.usageColorSequence=k.usageColorSequence;exports.BarChart=Ce;exports.Button=ct;exports.Callout=st;exports.Card=et;exports.CardBody=nt;exports.CardHeader=tt;exports.Checkbox=ft;exports.Code=Ve;exports.CollapsibleSection=mt;exports.DiffStats=Fe;exports.DiffView=He;exports.Divider=Qe;exports.Grid=Je;exports.H1=Oe;exports.H2=We;exports.H3=$e;exports.IconButton=dt;exports.LineChart=ke;exports.Link=Xe;exports.PieChart=De;exports.Pill=ot;exports.Row=Ue;exports.Select=ut;exports.Spacer=Ze;exports.Stack=Ye;exports.Stat=rt;exports.Swatch=gt;exports.Table=it;exports.Text=Ke;exports.TextArea=yt;exports.TextInput=pt;exports.TodoList=ce;exports.TodoListCard=Ne;exports.Toggle=ht;exports.UsageBar=xt;exports.computeDAGLayout=Ee;exports.mergeStyle=Ge;exports.useCanvasAction=_e;exports.useCanvasState=ze;exports.useHostTheme=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("@mantine/core"),m=require("react"),k=require("./host-tokens-Lz69pkRj.cjs"),D=require("@mantine/charts"),w={success:"#1F8A65",danger:"#CF2D56",warning:"#E8A33D",info:"#2E79B5",neutral:"#8888A8",added:"#1F8A65",deleted:"#CF2D56",renamed:"#5A6CC0"},ne={success:"green",danger:"red",warning:"orange",info:"blue",neutral:"gray",added:"green",deleted:"red",renamed:"indigo"};function y(){const t=p.useComputedColorScheme("light")==="dark"?"dark":"light";return k.resolveThemeForColorScheme(t)}const re={verticalAlign:"bottom",align:"center"},oe={legend:{justifyContent:"center"}};function G(){const t=y().chart.sequence;return(n,o)=>n?w[n]:t[o%t.length]}function se(){const t=y().text.primary;return{textColor:t,barLabelColor:t}}function ae(e,t){return e.map((n,o)=>{const a={category:n};for(const s of t)a[s.name]=s.data[o]??0;return a})}function ie(e,t){return e.map((n,o)=>({name:n.name,color:t(n.tone,o)}))}function le(e,t){return n=>`${t??""}${n}${e??""}`}function xe(e,t){if(e!=null&&e.length)return e.map(n=>({...t?{x:n.value}:{y:n.value},label:n.label,color:n.tone?w[n.tone]:w.neutral}))}const ye=new Set(["log","symlog","pow","sqrt"]);function ge(e){const{scale:t}=e;return typeof t!="string"||!ye.has(t)?e:{...e,type:e.type??"number",allowDataOverflow:e.allowDataOverflow??!0,allowDecimals:e.allowDecimals??!0,domain:e.domain??[1,"dataMax"]}}function ce(e){const t=xe(e.referenceLines,!!e.horizontal);let n;if(!e.stacked&&!e.normalized){const s=e.beginAtZero!==!1;n=[e.yMin??(s?0:"auto"),e.yMax??"auto"]}const o=e.valueAxis?ge(e.valueAxis):void 0;if(!n&&!o)return{referenceLines:t};const a={...n&&{domain:n},...o};return e.horizontal?{xAxisProps:a,referenceLines:t}:{yAxisProps:a,referenceLines:t}}function me(e,t,n){return e!==void 0?e:t.length===1&&n.length<=8}const Q=14;function be(e){return e.length<=Q?e:`${e.slice(0,Q-1)}…`}function je(e){var s;const t=typeof e.x=="number"?e.x:Number(e.x)||0,n=typeof e.y=="number"?e.y:Number(e.y)||0,o=String(((s=e.payload)==null?void 0:s.value)??""),a=be(o);return r.jsx("g",{transform:`translate(${t},${n})`,children:r.jsxs("text",{x:-10,y:0,dy:4,textAnchor:"end",fill:"currentColor",fontSize:12,children:[r.jsx("title",{children:o}),a]})})}function ve(e){return{fontWeight:700,fill:e}}function Se(){return{yAxisProps:{tick:je,width:96},barChartProps:{margin:{right:32}}}}function ke(){return{barChartProps:{margin:{top:22}}}}function Ce({categories:e,series:t,height:n=240,fill:o,valueSuffix:a,valuePrefix:s,showValues:c,showHoverGuide:f=!0,beginAtZero:d,yMin:l,yMax:u,referenceLines:g,style:j,extra:h,smooth:C}){const T=(h==null?void 0:h.smooth)??C,L=G(),P=se(),M=ae(e,t),E=ie(t,L),v=!!(o&&(h!=null&&h.stacked)),F=ce({beginAtZero:d,yMin:l,yMax:u,referenceLines:g,horizontal:!1,stacked:v,valueAxis:h==null?void 0:h.valueAxis}),A={h:n,data:M,dataKey:"category",series:E,curveType:T?"monotone":"linear",withLegend:t.length>1,legendProps:re,valueFormatter:le(a,s),withPointLabels:c??e.length<=20,tooltipProps:f?void 0:{cursor:!1},styles:{...oe,legendItemName:{color:P.textColor}},...F,style:j};return o?r.jsx(D.AreaChart,{...A,type:v?"stacked":"default"}):r.jsx(D.LineChart,{...A})}function we({categories:e,series:t,height:n=240,stacked:o,horizontal:a,normalized:s,valueSuffix:c,valuePrefix:f,showValues:d,beginAtZero:l,yMin:u,yMax:g,referenceLines:j,style:h,extra:C}){const T=G(),L=se(),P=ae(e,t),M=s?"percent":o?"stacked":"default",E=ce({beginAtZero:l,yMin:u,yMax:g,referenceLines:j,horizontal:a,stacked:o,normalized:s,valueAxis:C==null?void 0:C.valueAxis}),v=!o&&!s&&me(d,t,e);return r.jsx(D.BarChart,{h:n,data:P,dataKey:"category",series:ie(t,T),type:M,orientation:a?"vertical":"horizontal",withLegend:t.length>1,legendProps:re,valueFormatter:le(c,f),withBarValueLabel:v,...v?{valueLabelProps:ve(L.barLabelColor)}:{},...a?Se():v?ke():{},styles:{...oe,legendItemName:{color:L.textColor}},...E,style:h})}const Te=180,Le=540;function Pe(e,t){if(t<=0)return"0%";const n=e/t*100;return n<10&&Math.abs(n-Math.round(n))>.05?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function Ae(e){return Math.max(28,Math.round(e*.22))}function Me(e){return e.map(t=>({dataKey:t.name,value:t.name,color:t.color,type:"circle"}))}function Be(e,t){return e.map(n=>({name:n.name,color:n.color,label:`${n.name} ${Pe(n.value,t)}`}))}function De({total:e,family:t,primary:n,subtitle:o}){return r.jsxs("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"central",fontFamily:t,children:[r.jsx("tspan",{x:"50%",dy:"-0.4em",fontSize:20,fontWeight:600,fill:n,children:e}),r.jsx("tspan",{x:"50%",dy:"1.55em",fontSize:16,fontWeight:500,fill:o,children:"Total"})]})}function Ee({data:e,size:t=200,donut:n,style:o}){const[a,s]=m.useState(null),c=y(),f=G(),d=e.map((h,C)=>({name:h.label,value:h.value,color:f(h.tone,C)})),l=d.reduce((h,C)=>h+C.value,0),u={startAngle:Te,endAngle:Le},g=h=>({opacity:a===null||a===h?1:.35}),j=n?r.jsx(D.DonutChart,{data:d,size:t,thickness:Ae(t),withTooltip:!0,cellProps:h=>g(h.name),...u,children:r.jsx(De,{total:l,family:c.typography.fontFamily,primary:c.text.primary,subtitle:c.text.secondary})}):r.jsx(D.PieChart,{data:d,size:t,withTooltip:!0,withLabelsLine:!1,cellProps:h=>g(h.name),...u});return r.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",...o},children:[r.jsx("div",{style:{width:"100%",height:t,minHeight:t,display:"flex",alignItems:"center",justifyContent:"center"},children:j}),r.jsx(D.ChartLegend,{payload:Me(d),series:Be(d,l),legendPosition:"bottom",centered:!0,onHighlight:s,mt:"sm",w:"100%",styles:{legend:{justifyContent:"center",gap:12,color:c.text.primary},legendItemName:{color:c.text.primary}}})]})}function Fe(e){const{nodes:t,edges:n,direction:o="vertical",nodeWidth:a=160,nodeHeight:s=40,rankGap:c=64,nodeGap:f=48,padding:d=24}=e,l=t.map(i=>i.id),u=new Set(l),g=new Map;for(const i of l)g.set(i,[]);for(const i of n)u.has(i.from)&&u.has(i.to)&&g.get(i.from).push(i.to);const j=0,h=1,C=2,T=new Map(l.map(i=>[i,j])),L=new Set,P=(i,x)=>`${i}\0${x}`,M=i=>{T.set(i,h);for(const x of g.get(i)??[]){const b=T.get(x);b===h?L.add(P(i,x)):b===j&&M(x)}T.set(i,C)};for(const i of l)T.get(i)===j&&M(i);const E=n.filter(i=>u.has(i.from)&&u.has(i.to)&&!L.has(P(i.from,i.to))),v=new Map(l.map(i=>[i,0])),F=new Map(l.map(i=>[i,[]]));for(const i of E)F.get(i.from).push(i.to),v.set(i.to,(v.get(i.to)??0)+1);const A=new Map(l.map(i=>[i,0])),N=l.filter(i=>(v.get(i)??0)===0);for(;N.length>0;){const i=N.shift(),x=A.get(i);for(const b of F.get(i))A.set(b,Math.max(A.get(b),x+1)),v.set(b,v.get(b)-1),v.get(b)===0&&N.push(b)}const B=new Map;for(const i of l){const x=A.get(i);B.has(x)||B.set(x,[]),B.get(x).push(i)}const I=[...B.keys()].sort((i,x)=>i-x),S=o==="vertical",$=i=>i*(S?a:s)+Math.max(0,i-1)*f,q=Math.max(0,...I.map(i=>$(B.get(i).length))),R=new Map,K=[];I.forEach((i,x)=>{const b=B.get(i),z=$(b.length),_=d+(q-z)/2,H=d+x*((S?s:a)+c);b.forEach((U,Z)=>{const J=_+Z*((S?a:s)+f),he=S?J:H,pe=S?H:J;R.set(U,{id:U,x:he,y:pe,rank:i,order:Z})}),K.push({rank:i,x:S?_:H,y:S?H:_,width:S?z:a,height:S?s:z,nodeIds:b})});const V=(i,x)=>i?S?{x:i.x+a/2,y:x==="source"?i.y+s:i.y}:{x:x==="source"?i.x+a:i.x,y:i.y+s/2}:{x:0,y:0},fe=n.filter(i=>u.has(i.from)&&u.has(i.to)).map(i=>{const x=V(R.get(i.from),"source"),b=V(R.get(i.to),"target");return{from:i.from,to:i.to,sourceX:x.x,sourceY:x.y,targetX:b.x,targetY:b.y,isBackEdge:L.has(P(i.from,i.to))}}),X=d*2+I.length*(S?s:a)+Math.max(0,I.length-1)*c,Y=d*2+q;return{nodes:[...R.values()],edges:fe,ranks:K,direction:o,width:S?Y:X,height:S?X:Y}}function Ie({additions:e=0,deletions:t=0,style:n}){return e===0&&t===0?null:r.jsxs("span",{style:{display:"inline-flex",gap:8,fontVariantNumeric:"tabular-nums",fontSize:12,fontWeight:600,...n},children:[e>0&&r.jsxs("span",{style:{color:w.added},children:["+",e]}),t>0&&r.jsxs("span",{style:{color:w.deleted},children:["-",t]})]})}const Re={added:"+",removed:"-",unchanged:" "};function He({lines:e,showLineNumbers:t=!0,coloredLineNumbers:n=!0,showAccentStrip:o=!0,style:a}){const s=y(),c=l=>l==="added"?s.diff.insertedLine:l==="removed"?s.diff.removedLine:"transparent",f=l=>l==="added"?s.diff.stripAdded:l==="removed"?s.diff.stripRemoved:"transparent",d=l=>n&&l==="added"?w.added:n&&l==="removed"?w.deleted:s.text.tertiary;return r.jsx("div",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:12.5,lineHeight:"18px",color:s.text.primary,overflowX:"auto",...a},children:e.map((l,u)=>r.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:c(l.type),borderLeft:o?`3px solid ${f(l.type)}`:void 0},children:[t&&r.jsx("span",{style:{flex:"0 0 auto",width:40,textAlign:"right",paddingRight:10,userSelect:"none",color:d(l.type)},children:l.lineNumber??""}),r.jsx("span",{style:{flex:"0 0 auto",width:14,textAlign:"center",userSelect:"none",color:d(l.type)},children:Re[l.type]}),r.jsx("pre",{style:{margin:0,padding:"0 8px",whiteSpace:"pre",fontFamily:"inherit"},children:l.content})]},u))})}function Ne({status:e}){const t=y(),n=e==="completed"?w.success:e==="in_progress"?t.accent.primary:e==="cancelled"?w.danger:t.text.tertiary;return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",style:{flex:"0 0 auto",marginTop:3},"aria-hidden":!0,children:[r.jsx("circle",{cx:7,cy:7,r:6,stroke:n,strokeWidth:1.4}),e==="completed"&&r.jsx("path",{d:"M4 7.2l2 2 4-4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}),e==="in_progress"&&r.jsx("circle",{cx:7,cy:7,r:3,fill:n}),e==="cancelled"&&r.jsx("path",{d:"M4.8 4.8l4.4 4.4M9.2 4.8l-4.4 4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round"})]})}function de({todos:e,dimmedTodoIds:t,onTodoClick:n,style:o}){const a=y();return e.length===0?null:r.jsx("div",{style:{display:"flex",flexDirection:"column",...o},children:e.map(s=>{const c=t==null?void 0:t.has(s.id);return r.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(s),style:{display:"flex",gap:8,alignItems:"flex-start",width:"100%",textAlign:"left",padding:"4px 6px",background:"transparent",border:"none",cursor:n?"pointer":"default",color:a.text.primary,fontSize:14,lineHeight:"20px",opacity:c?.45:1},children:[r.jsx(Ne,{status:s.status}),r.jsx("span",{style:{textDecoration:s.status==="cancelled"?"line-through":void 0,color:s.status==="cancelled"?a.text.tertiary:void 0},children:s.content})]},s.id)})})}function ze({todos:e,dimmedTodoIds:t,defaultExpanded:n=!1,onTodoClick:o,style:a}){const s=y(),[c,f]=m.useState(n);if(e.length===0)return null;const d=e.filter(l=>l.status==="completed").length;return r.jsxs("div",{style:{border:`1px solid ${s.stroke.primary}`,borderRadius:6,overflow:"hidden",...a},children:[r.jsxs("button",{type:"button",onClick:()=>f(l=>!l),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:s.fill.secondary,border:"none",cursor:"pointer",color:s.text.secondary,fontSize:12,fontWeight:600},children:[r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:c?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{children:"Todos"}),r.jsx("span",{style:{flex:1}}),r.jsxs("span",{children:[d," of ",e.length," Done"]})]}),c&&r.jsx("div",{style:{padding:6},children:r.jsx(de,{todos:e,dimmedTodoIds:t,onTodoClick:o})})]})}function _e(e,t){const n=`canvas:${e}`,[o,a]=m.useState(()=>{if(typeof localStorage>"u")return t;try{const c=localStorage.getItem(n);return c===null?t:JSON.parse(c)}catch{return t}}),s=m.useCallback(c=>{a(f=>{const d=typeof c=="function"?c(f):c;try{localStorage==null||localStorage.setItem(n,JSON.stringify(d))}catch{}return d})},[n]);return[o,s]}function Ge(){return m.useCallback(e=>{},[])}function Oe(e,t){return{...e,...t}}function O(e,t,n){const o=e.typography[t];return{fontFamily:e.typography.fontFamily,fontSize:o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,color:e.text.primary,margin:0,...n}}function We({children:e,style:t}){const n=y();return r.jsx(p.Title,{order:1,style:O(n,"h1",t),children:e})}function $e({children:e,style:t}){const n=y();return r.jsx(p.Title,{order:2,style:O(n,"h2",t),children:e})}function qe({children:e,style:t}){const n=y();return r.jsx(p.Title,{order:3,style:O(n,"h3",t),children:e})}const Ke={normal:400,medium:500,semibold:600,bold:700},ee=m.createContext(!1);function Ve({children:e,tone:t="primary",size:n="body",as:o="p",weight:a="normal",italic:s,truncate:c,style:f}){const d=y(),u=m.useContext(ee)&&o==="p"?"span":o,g=o==="p";return r.jsx(ee.Provider,{value:!0,children:r.jsx(p.Text,{component:u,size:n==="small"?"xs":"sm",fw:Ke[a],c:t==="primary"?void 0:d.text[t],truncate:c,style:{fontStyle:s?"italic":void 0,...t==="primary"?{color:d.text.primary}:void 0,...g&&u==="span"?{display:"block"}:void 0,fontFamily:d.typography.fontFamily,...f},children:e})})}function Xe({children:e,style:t}){const n=y();return r.jsx("code",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:"0.92em",color:n.text.primary,background:n.fill.secondary,borderRadius:n.radius.sm,padding:"1px 4px",...t},children:e})}function Ye({children:e,href:t,style:n}){const o=y();return r.jsx("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:o.text.link,...n},children:e})}function Ue({children:e,gap:t,style:n}){return r.jsx(p.Stack,{gap:t,style:n,children:e})}const te={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch","space-between":"space-between"};function Ze({children:e,gap:t,align:n="center",justify:o="start",wrap:a=!1,style:s}){return r.jsx(p.Group,{gap:t,align:te[n],justify:te[o],wrap:a?"wrap":"nowrap",style:s,children:e})}function Je(){return r.jsx("div",{style:{flex:1}})}function Qe({children:e,columns:t,gap:n=16,align:o,style:a}){const s=typeof t=="number"?`repeat(${t}, minmax(0, 1fr))`:t;return r.jsx("div",{style:{display:"grid",gridTemplateColumns:s,gap:n,alignItems:o,...a},children:e})}function et({style:e}){return r.jsx(p.Divider,{style:e})}const W=m.createContext({collapsible:!1,open:!0,toggle:()=>{}});function tt({children:e,variant:t="default",collapsible:n=!1,defaultOpen:o=!0,open:a,onOpenChange:s,style:c}){const f=y(),[d,l]=m.useState(o),u=a??d,g=m.useCallback(()=>{const j=!u;a===void 0&&l(j),s==null||s(j)},[u,a,s]);return r.jsx(p.Card,{withBorder:t!=="borderless",radius:f.radius.md,padding:0,style:{background:f.bg.elevated,borderColor:f.stroke.secondary,...c},children:r.jsx(W.Provider,{value:{collapsible:n,open:u,toggle:g},children:e})})}function nt({children:e,trailing:t,style:n}){const o=y(),{collapsible:a,open:s,toggle:c}=m.useContext(W);return r.jsxs("div",{onClick:a?c:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 14px",borderBottom:`1px solid ${o.stroke.secondary}`,fontSize:o.typography.small.fontSize,fontWeight:o.typography.h3.fontWeight,color:o.text.primary,fontFamily:o.typography.fontFamily,cursor:a?"pointer":void 0,userSelect:a?"none":void 0,...n},children:[r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[a&&r.jsx(ue,{expanded:s}),e]}),t!=null&&r.jsx("span",{children:t})]})}function rt({children:e,style:t}){const{collapsible:n,open:o}=m.useContext(W);return n&&!o?null:r.jsx("div",{style:{padding:14,...t},children:e})}function ue({expanded:e}){return r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:e?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})})}function ot({value:e,label:t,tone:n,style:o}){const a=y();return r.jsxs("div",{style:o,children:[r.jsx(p.Text,{fz:22,fw:700,lh:1.2,style:{color:n?w[n]:a.text.primary,fontFamily:a.typography.fontFamily},children:e}),r.jsx(p.Text,{fz:12,style:{color:a.text.tertiary,fontFamily:a.typography.fontFamily},children:t})]})}function st({children:e,active:t,tone:n="neutral",size:o="md",leadingContent:a,keyboardHint:s,title:c,style:f,onClick:d}){return r.jsx(p.Badge,{color:ne[n],variant:t?"filled":"light",size:o==="sm"?"sm":"md",leftSection:a,rightSection:s,title:c,onClick:d,style:{cursor:d?"pointer":void 0,textTransform:"none",...f},children:e})}function at({children:e,tone:t="neutral",title:n,icon:o,style:a}){return r.jsx(p.Alert,{color:ne[t],title:n,icon:o,variant:"light",style:a,children:e})}const it={success:"rgba(31,138,101,0.12)",danger:"rgba(207,45,86,0.12)",warning:"rgba(232,163,61,0.14)",info:"rgba(46,121,181,0.12)",neutral:"rgba(136,136,168,0.12)"};function lt({headers:e,rows:t,columnAlign:n,rowTone:o,framed:a=!0,striped:s,stickyHeader:c,style:f,emptyMessage:d}){return r.jsxs(p.Table,{withTableBorder:a,withColumnBorders:!1,striped:s,stickyHeader:c,highlightOnHover:!0,style:f,children:[r.jsx(p.Table.Thead,{children:r.jsx(p.Table.Tr,{children:e.map((l,u)=>r.jsx(p.Table.Th,{ta:(n==null?void 0:n[u])??"left",children:l},u))})}),r.jsx(p.Table.Tbody,{children:t.length===0?r.jsx(p.Table.Tr,{children:r.jsx(p.Table.Td,{colSpan:e.length,ta:"center",c:"dimmed",children:d??"No data"})}):t.map((l,u)=>{const g=o==null?void 0:o[u];return r.jsx(p.Table.Tr,{style:g?{background:it[g]}:void 0,children:e.map((j,h)=>r.jsx(p.Table.Td,{ta:(n==null?void 0:n[h])??"left",children:l[h]},h))},u)})})]})}const ct={primary:"filled",secondary:"default",ghost:"subtle"};function dt({children:e,variant:t="secondary",disabled:n,type:o="button",style:a,onClick:s}){return r.jsx(p.Button,{variant:ct[t],color:t==="primary"?"accent":void 0,size:"xs",disabled:n,type:o,onClick:s,style:a,children:e})}function ut({children:e,onClick:t,disabled:n,title:o,variant:a="default",size:s="md",style:c}){return r.jsx(p.ActionIcon,{variant:a==="circle"?"light":"subtle",radius:a==="circle"?"xl":"sm",size:s==="sm"?"sm":"md",color:"gray",disabled:n,title:o,"aria-label":o,onClick:t,style:c,children:e})}function ft({value:e,onChange:t,options:n,placeholder:o,disabled:a,style:s}){return r.jsx(p.Select,{value:e,data:n,placeholder:o,disabled:a,allowDeselect:!1,onChange:c=>{c!==null&&(t==null||t(c))},style:s})}function ht({checked:e,onChange:t,disabled:n,label:o,style:a}){return r.jsx(p.Checkbox,{checked:e,disabled:n,label:o,onChange:s=>t==null?void 0:t(s.currentTarget.checked),style:a})}function pt({checked:e,onChange:t,disabled:n,size:o="sm",style:a}){return r.jsx(p.Switch,{checked:e,disabled:n,size:o==="sm"?"sm":"md",onChange:s=>t==null?void 0:t(s.currentTarget.checked),style:a})}function xt({value:e,onChange:t,placeholder:n,disabled:o,type:a,style:s}){return r.jsx(p.TextInput,{value:e,placeholder:n,disabled:o,type:a,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:s})}function yt({value:e,onChange:t,placeholder:n,disabled:o,rows:a=3,style:s}){return r.jsx(p.Textarea,{value:e,placeholder:n,disabled:o,autosize:!0,minRows:a,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:s})}function gt({color:e,style:t}){const n=y();return r.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:4,background:n.category[e],flex:"0 0 auto",...t}})}function mt({segments:e,total:t,topLeftLabel:n,topRightLabel:o,style:a}){const s=y(),c=t>0?t:1,f=e.reduce((l,u)=>l+(Number.isFinite(u.value)&&u.value>0?u.value:0),0),d=Math.max(0,c-f);return r.jsxs("div",{style:a,children:[(n!=null||o!=null)&&r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:s.text.secondary,marginBottom:6},children:[r.jsx("span",{children:n}),r.jsx("span",{children:o})]}),r.jsxs("div",{style:{display:"flex",gap:2,height:8},children:[e.map((l,u)=>{const g=Number.isFinite(l.value)&&l.value>0?l.value:0,j=s.category[l.color??k.usageColorSequence[u%k.usageColorSequence.length]];return r.jsx("div",{style:{width:`${g/c*100}%`,background:j,borderRadius:3}},l.id)}),d>0&&r.jsx("div",{style:{width:`${d/c*100}%`,background:s.fill.tertiary,borderRadius:3}})]})]})}function bt({title:e,leading:t,count:n,trailing:o,children:a,defaultOpen:s=!1,style:c}){const f=y(),[d,l]=m.useState(s);return r.jsxs("div",{style:c,children:[r.jsxs("div",{onClick:()=>l(u=>!u),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",cursor:"pointer",userSelect:"none",color:f.text.primary,fontSize:14},children:[r.jsx(ue,{expanded:d}),t,r.jsx("span",{style:{fontWeight:500},children:e}),n!=null&&r.jsx("span",{style:{color:f.text.tertiary,fontSize:12},children:n}),r.jsx("span",{style:{flex:1}}),o!=null&&r.jsx("span",{style:{color:f.text.tertiary},children:o})]}),d&&r.jsx("div",{style:{paddingLeft:18,paddingBottom:4},children:a})]})}Object.defineProperty(exports,"useEffect",{enumerable:!0,get:()=>m.useEffect});Object.defineProperty(exports,"useMemo",{enumerable:!0,get:()=>m.useMemo});Object.defineProperty(exports,"useRef",{enumerable:!0,get:()=>m.useRef});Object.defineProperty(exports,"useState",{enumerable:!0,get:()=>m.useState});exports.canvasPaletteDark=k.canvasPaletteDark;exports.canvasPaletteGrokDark=k.canvasPaletteGrokDark;exports.canvasPaletteGrokLight=k.canvasPaletteGrokLight;exports.canvasPaletteLight=k.canvasPaletteLight;exports.canvasTokens=k.canvasTokens;exports.canvasTokensLight=k.canvasTokensLight;exports.categoryPaletteDark=k.categoryPaletteDark;exports.categoryPaletteLight=k.categoryPaletteLight;exports.colorPalette=k.colorPalette;exports.usageColorSequence=k.usageColorSequence;exports.BarChart=we;exports.Button=dt;exports.Callout=at;exports.Card=tt;exports.CardBody=rt;exports.CardHeader=nt;exports.Checkbox=ht;exports.Code=Xe;exports.CollapsibleSection=bt;exports.DiffStats=Ie;exports.DiffView=He;exports.Divider=et;exports.Grid=Qe;exports.H1=We;exports.H2=$e;exports.H3=qe;exports.IconButton=ut;exports.LineChart=Ce;exports.Link=Ye;exports.PieChart=Ee;exports.Pill=st;exports.Row=Ze;exports.Select=ft;exports.Spacer=Je;exports.Stack=Ue;exports.Stat=ot;exports.Swatch=gt;exports.Table=lt;exports.Text=Ve;exports.TextArea=yt;exports.TextInput=xt;exports.TodoList=de;exports.TodoListCard=ze;exports.Toggle=pt;exports.UsageBar=mt;exports.computeDAGLayout=Fe;exports.mergeStyle=Oe;exports.useCanvasAction=Ge;exports.useCanvasState=_e;exports.useHostTheme=y;