@graphysdk/react-renderer 1.9.0-beta.1795707432298 → 1.9.0-beta.1795773309240

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.
@@ -0,0 +1 @@
1
+ require('./rich-text-editor-module.css');const i=require("./history-chords-B2-10FJz.cjs"),o=require("./start-arrow-button-B1mfKZVJ.cjs");let x=require("@graphysdk/viz-engine"),f=require("react"),t=require("react/jsx-runtime"),k=require("@tiptap/react"),Y=require("@tiptap/core"),xe=require("@tiptap/extension-bold"),M=require("@tiptap/extension-document"),ge=require("@tiptap/extension-hard-break"),me=require("@tiptap/extension-heading"),be=require("@tiptap/extension-italic"),Te=require("@tiptap/extension-link"),ve=require("@tiptap/extension-text"),ye=require("@tiptap/extension-text-align"),N=require("@tiptap/extension-text-style"),Fe=require("@tiptap/extension-underline"),w=require("@tiptap/extensions"),Z=require("@tiptap/extension-paragraph");var Q=e=>(0,t.jsx)(i.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M17 12H7"}),(0,t.jsx)("path",{d:"M19 19H5"})]})}),ee=e=>(0,t.jsx)(i.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M21 12H9"}),(0,t.jsx)("path",{d:"M21 19H7"})]})}),te=e=>(0,t.jsx)(i.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M15 12H3"}),(0,t.jsx)("path",{d:"M17 19H3"})]})}),ke=({textColor:e,...n})=>(0,t.jsxs)(i.Icon,{...n,children:[(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M6 4h12"}),(0,t.jsx)("path",{d:"M12 4v12"})]}),(0,t.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var ne=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:n})=>({id:e,key:n,fontFamily:i.RICH_TEXT_FONT_FAMILIES[e]??e})),Se=e=>ne.find(n=>n.id===(e??"modern"))??null;var re=[{size:12,key:"graph.annotations.textToolbar.fontSize.small"},{size:15,key:"graph.annotations.textToolbar.fontSize.medium"},{size:18,key:"graph.annotations.textToolbar.fontSize.large"},{size:24,key:"graph.annotations.textToolbar.fontSize.extraLarge"},{size:30,key:"graph.annotations.textToolbar.fontSize.huge"}],je=e=>re.find(n=>n.size===(e??15))??null,Ce=e=>`${e}px`,Ae=[{alignment:"left",Icon:te},{alignment:"center",Icon:Q},{alignment:"right",Icon:ee}],Ee=({annotation:e,textBox:n,panelRect:r,frameElement:c})=>{const a=i.useI18n(),{commands:s}=i.useGraphContext(),d=o.useRemoveAnnotation(r),u=i.useSceneSelector(l=>l.spec.styles.overrides),p=i.useSceneSelector(l=>(0,x.readStyleCoord)(l.spec)),h=i.useEditorStore(),g=o.useToolbarPopups(),S=o.usePlaceholderWidthFit(),b=(0,x.resolveTextAnnotationStyle)(i.useStyleReaderTree(),e.id),T=o.readTextAnnotationStyle(e.content),m=i.useEditorState(l=>l.caret?.editor??null),_=(0,k.useEditorState)({editor:m,selector:()=>o.readPickedFontSize(m)}),y=(0,k.useEditorState)({editor:m,selector:()=>o.readPickedFont(m)}),j=Se(T.font??y),A=je(T.fontSize??_),C=i.useTextAnnotationTextColor(b),L=T.color??C,I=(0,f.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),P=(l,v)=>{const F=(0,x.findStyleRule)(u,{select:I},p)?.declarations??{};s.dispatch(new x.SetStyleRuleCommand({list:"overrides",rule:{select:I,declarations:{...F,...l}}}),v)},H=(l,v)=>{s.dispatch(new x.UpdateAnnotationCommand({kind:"text",id:e.id,patch:l}),v)},E=()=>h.getState().caret?.editor?.getJSON()??e.content,D=(l,v)=>{const F=E(),z=h.getState().caret?.editor??null;if(z!==null&&!o.hasStyleableText(F)){z.chain().focus().setMark(o.TEXT_STYLE_MARK,l).run();return}H({content:o.applyTextStyle(F,l)},v)},se=()=>{d(e.id),c.focus({preventScroll:!0})},ce=l=>P(_e(l),{transient:!0}),de=l=>P({fillAlpha:l},{transient:!0}),O=b.fill!==o.TRANSPARENT_COLOR,ue=l=>D({color:l===x.AUTO_COLOR?void 0:l},{transient:!0}),pe=l=>()=>{o.hasStyleableText(E())||G({font:l}),D({font:l}),g.close()},fe=l=>()=>{o.hasStyleableText(E())||G({fontSize:l}),D({fontSize:l}),g.close()},G=l=>{const v=(n.x+(0,x.alignUnitFractions)(e.align).x*n.width)/r.width,F=S({annotationId:e.id,anchorX:v,align:e.align,panelWidth:r.width,minWidth:e.width,pickedFontSize:l.fontSize??_,pickedFont:l.font??y});F>e.width&&H({width:F})},he=l=>{const v=h.getState().caret?.editor??null;if(v===null||o.hasStyleableText(E())){H({content:o.applyTextAlignment(E(),l)});return}const F=v.state.storedMarks;v.chain().focus().setTextAlign(l).command(({tr:z})=>(z.setStoredMarks(F),!0)).run()};return(0,t.jsxs)(o.SelectionToolbar.Root,{anchorBox:n,panelRect:r,frameElement:c,label:a("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,t.jsx)(o.FloatingToolbar.ColorPicker,{color:(0,x.toPaintColor)(b.fill),label:a("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:ce,opacity:O?b.fillAlpha:void 0,onOpacityChange:O?de:void 0,...g.bind("background"),children:(0,t.jsx)(o.FloatingToolbar.Swatch,{color:O?(0,x.toPaintColor)(b.fill):o.TRANSPARENT_SWATCH_FILL,opacity:O?b.fillAlpha:void 0})}),(0,t.jsx)(o.FloatingToolbar.ColorPicker,{color:T.color??x.AUTO_COLOR,label:a("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:ue,...g.bind("color"),children:(0,t.jsx)(ke,{size:"sm",textColor:L,title:""})}),(0,t.jsx)(o.FloatingToolbar.Dropdown,{label:a("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,t.jsx)("span",{style:{fontFamily:j?.fontFamily},children:"Aa"}),...g.bind("font"),children:ne.map(l=>(0,t.jsx)(o.FloatingToolbar.MenuItem,{selected:l.id===j?.id,onClick:pe(l.id),children:(0,t.jsx)("span",{style:{fontFamily:l.fontFamily},children:a(l.key)})},l.id))}),(0,t.jsx)(o.FloatingToolbar.Dropdown,{label:a("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:A===null?"":a(A.key),...g.bind("fontSize"),children:re.map(l=>(0,t.jsx)(o.FloatingToolbar.MenuItem,{selected:l.size===A?.size,onClick:fe(l.size),children:(0,t.jsx)("span",{style:{fontSize:Ce(l.size)},children:a(l.key)})},l.size))}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsx)(Le,{current:T.alignment??"center",onPick:he}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsx)(o.StartArrowButton,{annotationId:e.id}),(0,t.jsx)(o.FloatingToolbar.Button,{label:a("graph.annotations.textToolbar.remove"),onClick:se,children:(0,t.jsx)(o.TrashIcon,{size:"sm",title:""})})]})},_e=e=>e==="transparent"?{fill:o.TRANSPARENT_COLOR}:{fill:e,fillAlpha:o.isCanvasColor(e)?x.TEXT_ANNOTATION_FADE_ALPHA:1},Le=({current:e,onPick:n})=>{const r=i.useI18n(),c=a=>()=>n(a);return(0,t.jsx)(t.Fragment,{children:Ae.map(a=>(0,t.jsx)(o.FloatingToolbar.Button,{label:r(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:c(a.alignment),children:(0,t.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},Ie="data-variant",oe=Z.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Ie]:e.variant}:{}}}}}),Pe=Y.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:n}=e.state;if(!n.empty)return!1;const{$from:r}=n;return r.depth!==1||r.parentOffset!==0?!1:r.index(0)===1}}}}),q=()=>[ve.Text,w.UndoRedo,me.Heading.configure({levels:[1,2,3]}),xe.Bold,be.Italic,Fe.Underline,ye.TextAlign.configure({types:["heading","paragraph"]}),Te.Link.configure({openOnClick:!1,autolink:!0}),N.TextStyle,N.Color,ge.HardBreak],Oe=({titlePlaceholder:e,subtitlePlaceholder:n,showTitle:r,showSubtitle:c})=>[Me({showTitle:r,showSubtitle:c}),oe,...q(),N.FontFamily,Pe.configure({showTitle:r}),w.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:s})=>{if(r&&a===0)return e;const d=r?s.state.doc.firstChild?.nodeSize??-1:0;return c&&a===d?n:""}})],ze=({placeholder:e})=>[M.Document,oe,...q(),N.FontFamily,w.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Me=({showTitle:e,showSubtitle:n})=>e&&n?M.Document.extend({content:"block{2,}"}):M.Document,ae=(e,n)=>{if(n===null)return;let r=null;try{r=e.view.posAtCoords({left:n.x,top:n.y})}catch{r=null}e.commands.focus(r===null?"end":r.pos,{scrollIntoView:!1})},Ne="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Re=`'Aeonik', 'Aeonik Fallback', ${i.DEFAULT_FONT_FAMILY}`,we="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",He="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",U=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:i.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Re},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Ne},{id:"technical",label:"Technical",preview:"00",fontFamily:we},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:He}],De=e=>e?U.find(n=>n.fontFamily===e)??null:null,Be=({editor:e,currentFontFamily:n,open:r,onOpenChange:c})=>{const a=i.useI18n(),s=De(n)??U[0],d=u=>{e.chain().focus().setFontFamily(u.fontFamily).run()};return(0,t.jsx)(o.FloatingToolbar.Dropdown,{label:a("graph.toolbar.font.ariaLabel"),trigger:(0,t.jsx)("span",{style:{fontFamily:s?.fontFamily},children:s?.preview}),open:r,onOpenChange:c,children:U.map(u=>(0,t.jsx)(o.FloatingToolbar.MenuItem,{selected:u.id===s?.id,onClick:()=>d(u),children:(0,t.jsx)("span",{style:{fontFamily:u.fontFamily},children:u.label})},u.id))})},ie={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:i.vars.fontTextEditorBody},K=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:i.vars.fontTextEditorH6},ie,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:i.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:i.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:i.vars.fontTextEditorH1}],Ue=({editor:e,activeStyle:n,open:r,onOpenChange:c})=>{const a=i.useI18n(),s=K.find(d=>d.id===n)??ie;return(0,t.jsx)(o.FloatingToolbar.Dropdown,{label:a("graph.toolbar.heading.ariaLabel"),trigger:a(s.translationKey),open:r,onOpenChange:c,children:K.map(d=>(0,t.jsx)(o.FloatingToolbar.MenuItem,{selected:d.id===s.id,onClick:()=>qe(e,d.id),children:(0,t.jsx)(We,{font:d.previewFont,children:a(d.translationKey)})},d.id))})},qe=(e,n)=>{switch(n){case"caption":e.chain().focus().setNode("paragraph",{variant:"caption"}).run();return;case"text":e.chain().focus().setNode("paragraph",{variant:null}).run();return;case"h1":e.chain().focus().setHeading({level:1}).run();return;case"h2":e.chain().focus().setHeading({level:2}).run();return;case"h3":e.chain().focus().setHeading({level:3}).run()}},We=({font:e,children:n})=>(0,t.jsx)("span",{style:{font:e,margin:0},children:n}),Ge=e=>(0,t.jsx)(i.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),Ke=e=>(0,t.jsx)(i.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M18 6 6 18"}),(0,t.jsx)("path",{d:"m6 6 12 12"})]})}),$e=e=>!e.content||e.content.length===0?!0:e.content.every(n=>!n.content||n.content.length===0),Xe=e=>{const{$from:n}=e.state.selection,r=n.parent.textContent,c=n.parentOffset,a=n.start();let s=c;for(;s>0&&$(r[s-1]);)s-=1;let d=c;for(;d<r.length&&$(r[d]);)d+=1;return{from:a+s,to:a+d}},$=e=>e!==void 0&&/\S/.test(e),Ve="fop13s0",Je="fop13s1 uz3g760",X="fop13s2 l9kff6 l9kff3",Ye=({editor:e,currentUrl:n,active:r,open:c,onOpenChange:a})=>{const s=i.useI18n(),[d,u]=(0,f.useState)(""),p=(0,f.useRef)(null);(0,f.useEffect)(()=>{c&&u(n??"")},[c,n]);const h=()=>{Ze(e,d),a(!1)},g=()=>{u(""),a(!1)},S=T=>{u(T.target.value)},b=T=>{T.key==="Enter"&&(T.preventDefault(),h())};return(0,t.jsxs)(o.FloatingToolbar.Submenu,{open:c,onOpenChange:a,children:[(0,t.jsx)(o.FloatingToolbar.SubmenuTrigger,{label:s("graph.toolbar.formatting.link"),pressed:r,children:(0,t.jsx)(Ge,{})}),(0,t.jsx)(o.FloatingToolbar.SubmenuContent,{align:"end",initialFocus:p,children:(0,t.jsxs)("div",{className:Ve,children:[(0,t.jsx)("input",{ref:p,type:"url",value:d,placeholder:s("graph.toolbar.link.placeholder"),"aria-label":s("graph.toolbar.link.urlLabel"),className:Je,onChange:S,onKeyDown:b}),(0,t.jsx)("button",{type:"button","aria-label":s("common.cancel"),className:X,onClick:g,children:(0,t.jsx)(Ke,{})}),(0,t.jsx)("button",{type:"button","aria-label":s("graph.toolbar.link.apply"),className:X,onClick:h,children:(0,t.jsx)(o.CheckIcon,{})})]})})]})},Ze=(e,n)=>{const r=n.trim(),{selection:c}=e.state;if(!r){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!c.empty){e.chain().focus().setLink({href:r}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:r}).run();return}const a=Xe(e);e.chain().focus().setTextSelection(a).setLink({href:r}).run()},Qe=({editor:e,activeAlignment:n="left"})=>{const r=i.useI18n();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.FloatingToolbar.Button,{label:r("graph.toolbar.textAlign.left"),pressed:n==="left",onClick:()=>e.chain().focus().setTextAlign("left").run(),children:(0,t.jsx)(te,{})}),(0,t.jsx)(o.FloatingToolbar.Button,{label:r("graph.toolbar.textAlign.center"),pressed:n==="center",onClick:()=>e.chain().focus().setTextAlign("center").run(),children:(0,t.jsx)(Q,{})}),(0,t.jsx)(o.FloatingToolbar.Button,{label:r("graph.toolbar.textAlign.right"),pressed:n==="right",onClick:()=>e.chain().focus().setTextAlign("right").run(),children:(0,t.jsx)(ee,{})})]})},et=({editor:e})=>({bold:e?.isActive("bold")??!1,italic:e?.isActive("italic")??!1,underlined:e?.isActive("underline")??!1,linked:e?.isActive("link")??!1,linkUrl:e?.getAttributes("link").href??null,color:e?.getAttributes("textStyle").color??null,fontFamily:e?.getAttributes("textStyle").fontFamily??null,fontSize:tt(e),textAlign:nt(e)}),tt=e=>e?e.isActive("heading",{level:1})?"h1":e.isActive("heading",{level:2})?"h2":e.isActive("heading",{level:3})?"h3":e.isActive("paragraph",{variant:"caption"})?"caption":"text":"text",nt=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",rt=({editor:e})=>{const n=i.useI18n(),[r,c]=(0,f.useState)(!1),[a,s]=(0,f.useState)(null),d=a!==null,u=y=>j=>{s(j?y:null)},p=(0,f.useRef)(null),{width:h,height:g,setElement:S}=i.useResizeObserver(),b=e?.view.dom??null,T=(0,f.useMemo)(()=>({x:0,y:0,width:h,height:g}),[h,g]),m=(0,k.useEditorState)({editor:e,selector:et});if((0,f.useEffect)(()=>(S(b),()=>S(null)),[S,b]),(0,f.useEffect)(()=>{if(!e)return;const y=()=>c(!0),j=({event:A})=>{const{relatedTarget:C,currentTarget:L}=A,I=C instanceof Node&&p.current?.contains(C),P=C instanceof Node&&L instanceof Node&&L.contains(C);!I&&!P&&c(!1)};return e.on("focus",y),e.on("blur",j),()=>{e.off("focus",y),e.off("blur",j)}},[e]),!e||b===null||!r&&!d)return null;const _=()=>{p.current?.contains(document.activeElement)&&e.commands.focus()};return(0,t.jsx)(o.AnchoredPopover,{frameElement:b,boundary:T,side:"bottom",align:"start",takesFocus:!1,onEscape:_,children:(0,t.jsxs)(o.PlacedToolbar,{ref:p,...o.MENU_STAMP,children:[(0,t.jsxs)(o.FloatingToolbar.Group,{children:[(0,t.jsx)(o.FloatingToolbar.ColorPicker,{color:m?.color??null,onChange:y=>e.chain().setColor(y).run(),open:a==="color",onOpenChange:u("color")}),(0,t.jsx)(Be,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:u("fontFamily")})]}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsx)(o.FloatingToolbar.Group,{children:(0,t.jsx)(Ue,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:u("fontSize")})}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsxs)(o.FloatingToolbar.Group,{children:[(0,t.jsx)(o.FloatingToolbar.Button,{label:n("graph.toolbar.formatting.bold"),pressed:m?.bold??!1,onClick:()=>e.chain().focus().toggleBold().run(),children:(0,t.jsx)("strong",{children:"B"})}),(0,t.jsx)(o.FloatingToolbar.Button,{label:n("graph.toolbar.formatting.italic"),pressed:m?.italic??!1,onClick:()=>e.chain().focus().toggleItalic().run(),children:(0,t.jsx)("em",{children:"I"})}),(0,t.jsx)(o.FloatingToolbar.Button,{label:n("graph.toolbar.formatting.underline"),pressed:m?.underlined??!1,onClick:()=>e.chain().focus().toggleUnderline().run(),children:(0,t.jsx)("u",{children:"U"})})]}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsx)(o.FloatingToolbar.Group,{children:(0,t.jsx)(Qe,{editor:e,activeAlignment:m?.textAlign})}),(0,t.jsx)(o.FloatingToolbar.Separator,{}),(0,t.jsx)(o.FloatingToolbar.Group,{children:(0,t.jsx)(Ye,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:u("link")})})]})})},ot="_1uy50v30",le=({editor:e,ariaLabel:n})=>(0,t.jsxs)("div",{className:ot,children:[(0,t.jsx)(rt,{editor:e}),(0,t.jsx)(k.EditorContent,{editor:e,"aria-label":n})]}),at=200,W=({content:e,extensions:n,editable:r,onUpdate:c,updateDebounceMs:a=at})=>{const s=(0,f.useRef)(V(e)),d=(0,f.useRef)(s.current),u=i.useDebouncedCallback(h=>{d.current=h,c?.(h)},a),p=(0,k.useEditor)({extensions:n,content:s.current,editable:r,immediatelyRender:!1,onUpdate:({editor:h})=>{const g=h.getJSON();if(B(d.current,g))return u.cancel();u.run(g)}});return(0,f.useEffect)(()=>{p?.setEditable(r)},[p,r]),(0,f.useEffect)(()=>{if(!p)return;const h=V(e);B(d.current,h)||(d.current=h,!B(p.getJSON(),h)&&(u.cancel(),it(p,h)))},[p,e,u]),(0,f.useEffect)(()=>()=>u.flush(),[u]),p},V=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,it=(e,n)=>{const{from:r,to:c}=e.state.selection;e.commands.setContent(n,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(r,a),to:Math.min(c,a)})},B=(e,n)=>JSON.stringify(R(e))===JSON.stringify(R(n)),R=e=>Array.isArray(e)?e.map(R):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([n,r])=>[n,R(r)]).filter(([,n])=>!lt(n)).sort(([n],[r])=>String(n).localeCompare(String(r)))),lt=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,st=({caption:e,captionStyle:n})=>{const{dispatch:r}=i.useGraphCommands(),c=i.useEditorStore(),a=W({content:e,extensions:(0,f.useMemo)(()=>ze({placeholder:i.CAPTION_PLACEHOLDER}),[]),editable:!0,onUpdate:s=>{const d=$e(s)?null:s;r(new x.SetContentCaptionCommand({caption:d}))}});return(0,f.useLayoutEffect)(()=>{a!==null&&ae(a,c.getState().takePendingTextCaret("caption"))},[a,c]),(0,t.jsx)("div",{"data-testid":"caption-editor",style:i.toHtmlTextCss(n),children:a===null?(0,t.jsx)(i.CaptionTextSurface,{caption:e}):(0,t.jsx)(le,{editor:a,ariaLabel:"Chart caption"})})},ct=e=>[M.Document,Z.Paragraph,...q(),ut,w.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],dt=({annotation:e})=>{const n=i.useI18n(),{dispatch:r}=i.useGraphCommands(),c=i.useEditorStore(),a=(0,f.useMemo)(()=>ct(n("graph.annotations.text.placeholder")),[n]),s=W({content:e.content,extensions:a,editable:!0,onUpdate:p=>{r(new x.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:p}}))}});(0,f.useEffect)(()=>{const{setCaretEditor:p}=c.getState();return p(s),()=>p(null)},[s,c]),(0,f.useEffect)(()=>{s?.commands.focus("end",{scrollIntoView:!1})},[s]);const d=(0,k.useEditorState)({editor:s,selector:({editor:p})=>o.readPickedFontSize(p)}),u=(0,k.useEditorState)({editor:s,selector:({editor:p})=>o.readPickedFont(p)});return(0,t.jsx)(k.EditorContent,{"aria-label":n("graph.annotations.text.editLabel"),className:i.editor,editor:s,style:{...d===null?{}:{fontSize:`calc(${d}px * ${i.vars.textScale})`},...u===null?{}:{fontFamily:i.resolveRichTextFontFamily(u)}},"data-testid":"text-annotation-editor"})},J=e=>{const n=i.resolveRichTextFontFamily(e);return n===void 0?{}:{style:`font-family: ${n}`}},ut=Y.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>J(e.fontFamily)},font:{default:null,renderHTML:e=>J(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${i.vars.textScale})`}:{}}}}]}}),pt=({title:e,showTitle:n,showSubtitle:r,subtitle:c})=>{const{dispatch:a}=i.useGraphCommands(),s=i.useEditorStore(),d=(0,f.useMemo)(()=>Oe({titlePlaceholder:i.TITLE_PLACEHOLDER,subtitlePlaceholder:i.TITLE_PLACEHOLDER,showTitle:n,showSubtitle:r}),[n,r]),u=W({content:(0,f.useMemo)(()=>i.buildTitleEditorDoc({title:e,showTitle:n,subtitle:c,showSubtitle:r}),[e,n,c,r]),extensions:d,editable:!0,onUpdate:p=>{const h=i.splitTitleEditorDoc(p,n);n&&a(new x.SetContentTitleCommand({title:h.title})),r&&a(new x.SetContentSubtitleCommand({subtitle:h.subtitle}))}});return(0,f.useLayoutEffect)(()=>{u!==null&&ae(u,s.getState().takePendingTextCaret("header"))},[u,s]),(0,t.jsx)("div",{className:i.textStyleEditor,"data-testid":"title-editor",children:u===null?(0,t.jsx)(i.HeaderTextSurface,{title:e,showTitle:n,showSubtitle:r,subtitle:c}):(0,t.jsx)(le,{editor:u,ariaLabel:"Chart title and subtitle"})})};exports.CaptionEditor=st;exports.TextAnnotationEditor=dt;exports.TextToolbar=Ee;exports.TitleEditor=pt;
@@ -1 +1 @@
1
- ._70l3rt0{justify-content:center;align-items:center;gap:var(--graphy-space-xs);block-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;display:inline-flex}._70l3rt0:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._70l3rt0[data-popup-open]{background:var(--graphy-toolbar-button-background-color-selected)}._70l3rt1{white-space:nowrap;align-items:center;display:inline-flex}._70l3rt2{flex-shrink:0;block-size:10px;inline-size:10px}._70l3rt3{z-index:var(--graphy-z-index-toolbar-popover)}._70l3rt4{min-inline-size:180px;padding:var(--graphy-space-xs);background:var(--graphy-overlay-background);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-border-10));border-radius:var(--graphy-radii-md);box-shadow:var(--graphy-elevation-md);color:var(--graphy-text-primary);outline:none;flex-direction:column;display:flex}._70l3rt5{padding:var(--graphy-space-sm) var(--graphy-space-md);border-radius:var(--graphy-radii-sm);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-menu-item-label);-webkit-user-select:none;user-select:none;outline:none;align-items:center;display:flex}._70l3rt5[data-highlighted]{background:var(--graphy-toolbar-button-background-color-hovered)}._70l3rt5[data-selected=true]{background:var(--graphy-toolbar-button-background-color-selected)}.fop13s0{block-size:34px;min-inline-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;justify-content:center;align-items:center;display:inline-flex}.fop13s0:hover{background:var(--graphy-toolbar-button-background-color-hovered)}.fop13s0[data-active=true],.fop13s0[data-popup-open]{background:var(--graphy-toolbar-button-background-color-selected)}.fop13s1{z-index:var(--graphy-z-index-toolbar-popover)}.fop13s2{align-items:center;gap:var(--graphy-space-xs);padding:var(--graphy-space-xs);background:var(--graphy-overlay-background);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-border-10));border-radius:var(--graphy-radii-md);box-shadow:var(--graphy-elevation-md);color:var(--graphy-text-primary);outline:none;display:flex}.fop13s3{inline-size:220px;padding:var(--graphy-space-xs) var(--graphy-space-sm);background:var(--graphy-gray-80);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-gray-70));border-radius:var(--graphy-radii-md);color:var(--graphy-text-primary);font:var(--graphy-font-input);outline:none}.fop13s3:focus{outline:max(1px, var(--graphy-editor-border-width,1px)) solid var(--graphy-gray-60);outline-offset:calc(-1 * max(1px, var(--graphy-editor-border-width,1px)))}.fop13s4{background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;block-size:32px;min-inline-size:32px;color:var(--graphy-text-primary);border:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.fop13s4:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._1d66w570{block-size:34px;min-inline-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;justify-content:center;align-items:center;display:inline-flex}._1d66w570:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._1d66w570[data-pressed]{background:var(--graphy-toolbar-button-background-color-selected)}._1d66w571{z-index:var(--graphy-z-index-toolbar-tooltip)}._1u34vl40{z-index:var(--graphy-z-index-toolbar)}._1uy50v30 .ProseMirror{outline:none}._1uy50v30 .ProseMirror .is-empty:before{content:attr(data-placeholder);color:currentColor;opacity:.4;float:left;pointer-events:none;height:0}._1uy50v30 .ProseMirror h1,._1uy50v30 .ProseMirror h2,._1uy50v30 .ProseMirror h3,._1uy50v30 .ProseMirror h4,._1uy50v30 .ProseMirror h5,._1uy50v30 .ProseMirror h6,._1uy50v30 .ProseMirror p{font:inherit;color:inherit;margin:0}._1uy50v30 .ProseMirror p[data-variant=caption]{font:inherit;color:inherit}._1uy50v30 .ProseMirror a{text-underline-offset:.15em;cursor:text;text-decoration:underline}
1
+ .fop13s0{align-items:center;gap:var(--graphy-space-xs);display:flex}.fop13s1{cursor:text;inline-size:220px}._1uy50v30 .ProseMirror{outline:none}._1uy50v30 .ProseMirror .is-empty:before{content:attr(data-placeholder);color:currentColor;opacity:.4;float:left;pointer-events:none;height:0}._1uy50v30 .ProseMirror h1,._1uy50v30 .ProseMirror h2,._1uy50v30 .ProseMirror h3,._1uy50v30 .ProseMirror h4,._1uy50v30 .ProseMirror h5,._1uy50v30 .ProseMirror h6,._1uy50v30 .ProseMirror p{font:inherit;color:inherit;margin:0}._1uy50v30 .ProseMirror p[data-variant=caption]{font:inherit;color:inherit}._1uy50v30 .ProseMirror a{text-underline-offset:.15em;cursor:text;text-decoration:underline}
@@ -0,0 +1 @@
1
+ require('./start-arrow-button.css');const d=require("./history-chords-B2-10FJz.cjs");let c=require("@graphysdk/viz-engine"),f=require("react"),n=require("react/jsx-runtime"),ko=require("zustand/react/shallow"),Ao=require("lodash-es"),Mo=require("@vanilla-extract/dynamic"),X=require("clsx");X=d.__toESM(X,1);let yr=require("react-dom"),le=require("@base-ui/react/tooltip"),E=require("@base-ui/react/popover"),Gt=require("react-colorful"),Ee=require("@base-ui/react/number-field"),br=require("@base-ui/react/radio"),Cr=require("@base-ui/react/radio-group"),q=require("@base-ui/react/select"),fe=require("@base-ui/react/slider"),Ht=require("@base-ui/react/switch"),Lo=require("@base-ui/react/input"),Ro=require("@base-ui/react/direction-provider"),ue=require("@base-ui/react/menu"),te=require("@base-ui/react/toolbar");var jr=(e,t)=>{if(e.scope!=="observation")return null;const r=(0,c.findLayerById)(t.layers,e.layerId);if(r===void 0)return null;const[o]=(0,c.resolveObservationsTarget)({layer:r,target:e,parsingLocale:t.config.parsingLocale});if(o===void 0)return null;const a=r.data.getAt(o);if(a===null)return null;const i=(0,c.createObservationAnchorBuilder)(r)(a);return i===null?null:{layer:r,observation:a,observationIndex:o,at:i}},Sr=e=>{const t=d.useSceneSelector((0,ko.useShallow)(r=>({layers:r.layers,config:r.config})));return(0,f.useMemo)(()=>jr(e,t),[e,t])},_o=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),No=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Eo=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Fo=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Do=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Bo=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...e,children:(0,n.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),ht=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})}),wr=(0,f.createContext)(null),Pr=({labelId:e,controlId:t,children:r})=>{const o=(0,f.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,n.jsx)(wr.Provider,{value:o,children:r})},U=({id:e,ariaLabel:t,ariaLabelledBy:r},o=!0)=>{const a=(0,f.useContext)(wr),i=(0,f.useId)(),[l]=(0,f.useState)(()=>o?a?.claimControlId(i)??!1:!1),s=e??(l?a?.controlId:void 0),u=r??(t===void 0?a?.labelId:void 0);return{...s!==void 0&&{id:s},...t!==void 0&&{"aria-label":t},...u!==void 0&&{"aria-labelledby":u}}},re="_18ja6qr0",ae=({children:e})=>{const{themeValues:t}=d.useThemeContext();return(0,n.jsx)(d.PortalThemeProvider,{style:(0,f.useMemo)(()=>(0,Mo.assignInlineVars)({[d.vars.fontFamily]:t.fontFamily,[d.vars.fontFamilyHeading]:t.fontFamilyHeading,[d.vars.textScale]:t.textScale}),[t]),children:e})};var Go="srewh00",Ho="srewh01",Vo="srewh02",zo={pointer:null,focus:null,last:"pointer"},Ir=(0,f.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),nt=({className:e,children:t})=>{const[r,o]=(0,f.useState)(!1),[a,i]=(0,f.useState)(!1),[l,s]=(0,f.useState)(zo),u=(0,f.useCallback)((x,j)=>{i(!1),s(y=>({...y,[j]:x,last:j}))},[]),h=(0,f.useCallback)((x,j)=>{s(y=>y[j]===x?{...y,[j]:null}:y)},[]),p=(0,f.useCallback)(()=>i(!0),[]),m=Wo(l),g=(0,f.useMemo)(()=>({hovered:r,dismissed:a,reachedTooltipId:m,reach:u,release:h,dismiss:p}),[r,a,m,u,h,p]),C=x=>{x.pointerType!=="touch"&&(o(!0),i(!1))};return(0,n.jsx)("div",{className:e,onPointerEnter:C,onPointerLeave:()=>o(!1),children:(0,n.jsx)(Ir.Provider,{value:g,children:t})})},W=({label:e,checked:t=!1,side:r,delay:o,nameTrigger:a=!0,suppressed:i=!1,layer:l="popup",children:s})=>{const{hovered:u,dismissed:h,reachedTooltipId:p,reach:m,release:g,dismiss:C}=(0,f.useContext)(Ir),x=(0,f.useId)(),[j,y]=(0,f.useState)(!1),S=u?!h&&(p===x||t&&p===null):j,P=l==="toolbar"?Vo:Ho;(0,f.useEffect)(()=>()=>{g(x,"pointer"),g(x,"focus")},[x,g]);const I=(O,w)=>{w.reason==="escape-key"&&(C(),w.allowPropagation()),y(O)};return(0,n.jsxs)(le.Tooltip.Root,{open:S&&!i,onOpenChange:I,disableHoverablePopup:!0,children:[(0,n.jsx)(le.Tooltip.Trigger,{render:s,delay:o,...a?{"aria-label":e}:{},onPointerEnter:O=>O.pointerType!=="touch"&&m(x,"pointer"),onPointerLeave:()=>g(x,"pointer"),onFocus:()=>m(x,"focus"),onBlur:()=>g(x,"focus")}),(0,n.jsx)(le.Tooltip.Portal,{container:d.resolvePortalContainer(),className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(le.Tooltip.Positioner,{side:r,sideOffset:6,className:P,children:(0,n.jsx)(le.Tooltip.Popup,{className:Go,children:e})})})})]})},Wo=({pointer:e,focus:t,last:r})=>r==="focus"?t??e:e??t,$o="woi4bh0",Uo="woi4bh1";var qo={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Tr=({label:e,icon:t,onClick:r,variant:o="default",expanded:a,disabled:i,side:l,delay:s,tooltip:u,pressed:h,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:C,id:x})=>{const j=U({id:x,ariaLabel:g,ariaLabelledBy:C}),y=o==="tile",S=(0,n.jsxs)("button",{type:"button",className:qo[o],disabled:i,"aria-expanded":a,"aria-pressed":h,onClick:r,onPointerEnter:p,onPointerLeave:m,...j,children:[t!==void 0&&(0,n.jsx)("span",{className:(0,X.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,n.jsx)("span",{className:y?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,n.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,n.jsx)(ht,{size:"sm"})})]});return u!==void 0?(0,n.jsx)(W,{label:u,side:l,delay:s,nameTrigger:!1,children:S}):o==="icon"&&g!==void 0&&(l!==void 0||s!==void 0)?(0,n.jsx)(W,{label:g,side:l,delay:s,children:S}):S},Ko={accent:"var(--graphy-editor-accent, var(--graphy-editor-default-accent))",surface:"var(--graphy-editor-surface, var(--graphy-editor-default-surface))",text:"var(--graphy-editor-text, var(--graphy-editor-default-text))",textSecondary:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 70%)",textDisabled:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",sunken:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 5%)",raised:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 7%)",border:"var(--graphy-editor-border, color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 12%))",borderWidth:"var(--graphy-editor-border-width, 1px)",fontFamily:"var(--graphy-editor-font-family, var(--graphy-font-family))",borderStrong:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",focus:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 55.00000000000001%)",focusWidth:"2px",shadow:"var(--graphy-editor-default-shadow)"},Zo="linear-gradient(to top right, transparent calc(50% - 1px), var(--graphy-alert) calc(50% - 1px), var(--graphy-alert) calc(50% + 1px), transparent calc(50% + 1px))",Yo="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var Or="_14ty2ng0",Vt="_14ty2ng1",Xo="_14ty2ng2",Jo="_14ty2ng3",kr="_14ty2ng4",Qo="_14ty2ng5",ea="_14ty2ng6",ot="transparent",Ar=e=>{const t=`1px solid ${Ko.borderStrong}`;return e==="transparent"?{background:Zo,border:t}:e===c.AUTO_COLOR?{background:Yo,border:t}:{background:e,border:t}},Mr=({title:e,colors:t,value:r,onChange:o,trailing:a,clearable:i=!1,names:l,side:s,delay:u,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const C=d.useI18n(),x=U({id:p,ariaLabel:m,ariaLabelledBy:g},!1),j=a!==void 0||i,y=S=>{const P=S==="transparent"?C("graph.colorDropdown.transparent"):S,I=l?.[S],O=(0,n.jsx)("button",{type:"button","aria-label":I??P,className:Jo,"data-active":pt(S,r),disabled:h,onMouseDown:w=>w.preventDefault(),onClick:()=>o(S),children:(0,n.jsx)("span",{className:kr,style:Ar(S)})},S);return I===void 0?O:(0,n.jsx)(W,{label:I,side:s,delay:u,children:O},S)};return(0,n.jsxs)("div",{className:Or,children:[e!==void 0&&(0,n.jsx)("div",{className:"_14ty2ng1",children:e}),(0,n.jsxs)("div",{className:Xo,...x,children:[t.map(y),j&&(0,n.jsxs)("span",{className:"_14ty2ng5",children:[(0,n.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&y("transparent")]})]})]})},pt=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),Lr="data-graphy-chart-chrome",ta="data-graphy-keyboard-input",ra="data-graphy-chart-menu",mt={[ra]:""},Rr="data-graphy-selection-toolbar",na={[Rr]:""},gt=e=>({[Lr]:e}),xe=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,_r=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,oa=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Nr=(e,t,r)=>e instanceof Node&&(t.contains(e)||xe(e,r)),aa="cml7ha0",Er=(0,f.createContext)(null),ia=({children:e})=>{const{chartId:t}=d.useGraphContext(),[r]=(0,f.useState)(d.resolvePortalContainer),[o,a]=(0,f.useState)(null);return r===null?null:(0,n.jsxs)(n.Fragment,{children:[(0,yr.createPortal)((0,n.jsx)("div",{ref:a,className:aa,...gt(t)}),r),(0,n.jsx)(Er.Provider,{value:o,children:e})]})},$e=()=>(0,f.useContext)(Er),sa="_178jeit0",la="_178jeit1 _14ty2ng3",ca="_178jeit2 _14ty2ng4",da="_178jeit3",ua="_178jeit4",ha="_178jeit5",pa="_178jeit6",ma="_178jeit7",ga={side:"flip",align:"shift",fallbackAxisSide:"end"},Fr=({value:e,onChange:t,onCommit:r,popupAttributes:o,variant:a="default"})=>{const i=d.useI18n(),l=$e(),[s,u]=(0,f.useState)(!1),h=g=>{u(g),g||r?.()},p=e!==null&&d.isValidCssColor(e)?e:"#000000",m=d.isHex(p)?p.toUpperCase():"#000000";return(0,n.jsxs)(E.Popover.Root,{open:s,onOpenChange:h,children:[a==="chip"?(0,n.jsx)(E.Popover.Trigger,{className:la,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,n.jsx)("span",{className:ca})}):(0,n.jsxs)("div",{className:Or,children:[(0,n.jsx)("div",{className:Vt,children:i("graph.colorDropdown.custom")}),(0,n.jsxs)(E.Popover.Trigger,{className:da,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,n.jsx)("span",{className:kr,style:Ar(p)}),(0,n.jsx)("span",{className:ua,children:m})]})]}),(0,n.jsx)(E.Popover.Portal,{container:l??d.resolvePortalContainer(),className:re,children:(0,n.jsx)(d.PortalThemeProvider,{children:(0,n.jsx)(E.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:ga,collisionPadding:12,disableAnchorTracking:a==="chip",className:sa,children:(0,n.jsxs)(E.Popover.Popup,{className:ha,onMouseDown:g=>g.preventDefault(),...o,children:[(0,n.jsx)("div",{className:Vt,children:i("graph.colorDropdown.pickColor")}),(0,n.jsx)(Gt.HexColorPicker,{color:m,onChange:t,className:pa}),(0,n.jsx)(Gt.HexColorInput,{color:m,onChange:t,prefixed:!0,className:ma,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Ue=(0,f.createContext)(null),va=()=>{const e=(0,f.useContext)(Ue);if(!e)throw new Error("An editing section must sit inside an <EditorPanel.Root> bound to a graph — pass it a `handle`, or render the panel inside a <GraphProvider>.");return e},qe=({children:e,onKeyDown:t,...r})=>{const o=(0,f.useContext)(Ue),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const l=d.resolveHistoryStep(i.nativeEvent);l&&(i.preventDefault(),l==="undo"?o.undo():o.redo())};return(0,n.jsx)("div",{onKeyDown:a,...r,children:e})},fa="_6fidqf0 uz3g760",xa="_6fidqf1 uz3g761",Dr=({value:e,onChange:t,onCommit:r,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:l})=>{const s=U({id:l,ariaLabel:a,ariaLabelledBy:i}),u=h=>{const p=ba(h.currentTarget.value);p!==void 0&&t(p)};return(0,n.jsx)(qe,{className:fa,children:(0,n.jsx)("input",{type:"date",className:xa,value:ya(e),onChange:u,onBlur:r,disabled:o,...s})})},ya=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},ba=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},zt=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v12"}),(0,n.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),Ca="a1l6m80 woi4bh6 woi4bh5",ja="a1l6m81 _14ty2ng3",Sa="a1l6m82",Br=({label:e,accept:t,onFile:r,disabled:o,id:a,variant:i="default"})=>{const l=(0,f.useId)(),s=a??l,u=i==="chip",h=(0,n.jsx)("input",{id:s,type:"file",accept:t,disabled:o,"aria-label":u?e:void 0,className:Sa,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&r(m)}});return u?(0,n.jsx)(W,{label:e,children:(0,n.jsxs)("label",{htmlFor:s,className:ja,children:[(0,n.jsx)(zt,{size:"xs"}),h]})}):(0,n.jsxs)("label",{htmlFor:s,className:Ca,children:[(0,n.jsx)("span",{className:$o,children:(0,n.jsx)(zt,{})}),(0,n.jsx)("span",{className:Uo,children:e}),h]})},Gr="keyboard",Ke=e=>{const t=(0,f.useRef)(!1),r=(0,f.useRef)(!1),o=()=>{t.current=!1,r.current&&(r.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){r.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){r.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},wa="eh8dvc0",Pa="eh8dvc1 uz3g760",Ia="eh8dvc2 uz3g761";var Hr=({value:e,onChange:t,onCommit:r,min:o,max:a,step:i,placeholder:l,prefix:s,suffix:u,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:C})=>{const x=U({id:C,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:j,gestureHandlers:y}=Ke(r);return(0,n.jsx)(Ee.NumberField.Root,{className:wa,value:e,onValueChange:S=>t(S),onValueCommitted:(S,P)=>{j(P.reason===Gr)},min:o,max:a,step:i,disabled:h,children:(0,n.jsxs)(qe,{className:Pa,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[s!==void 0&&(0,n.jsx)("span",{className:"eh8dvc3",children:s}),(0,n.jsx)(Ee.NumberField.Input,{className:Ia,placeholder:l,...y,"aria-invalid":p===!0?!0:void 0,...x}),u!==void 0&&(0,n.jsx)("span",{className:"eh8dvc3",children:u})]})})},Ta="_1b7s5f0",se={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Oa="_1b7s5f7";var ka=6,Vr=({options:e,value:t,onChange:r,onCommit:o,columns:a,itemLayout:i="tile",disabled:l,ariaLabel:s,ariaLabelledBy:u,id:h})=>{const p=U({id:h,ariaLabel:s,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",C=i==="icon",x=i==="track",j=i==="chip",{commitAfterChange:y,gestureHandlers:S}=Ke(o);return(0,n.jsx)(Cr.RadioGroup,{className:(0,X.default)(Ta,Aa(a??e.length),C&&"_1b7s5f9",x&&"_1b7s5fb",j&&"_1b7s5fd"),value:t,onValueChange:P=>{r(P),y()},...S,disabled:l,...p,children:e.map(P=>{const I=(0,n.jsxs)(br.Radio.Root,{value:P.value,disabled:P.disabled,className:(0,X.default)(Oa,g&&"_1b7s5f8",C&&"_1b7s5fa",x&&"_1b7s5fc",j&&"_1b7s5fe"),style:{gridRow:P.gridRow,gridColumn:P.gridColumn},"aria-label":m?void 0:P.label,children:[P.icon,m&&(0,n.jsx)("span",{className:"_1b7s5ff",children:P.label})]},P.value);if(!g&&!C&&!j)return I;const O=(C||j)&&P.value===t;return(0,n.jsx)(W,{label:P.label,checked:O,children:I},P.value)})})},Aa=e=>{switch(Math.min(Math.max(Math.round(e),1),ka)){case 1:return se[1];case 2:return se[2];case 3:return se[3];case 4:return se[4];case 5:return se[5];default:return se[6]}},zr=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),Ma="_1g5x15w0 uz3g760",La="_1g5x15w1",Ra="_1g5x15w2",Wt="_1g5x15w3",_a="_1g5x15w4",Na="_1g5x15w5",Ea="_1g5x15w6",Fa="_1g5x15w7";var Wr=({options:e,value:t,onChange:r,placeholder:o,disabled:a,hasError:i,ariaLabel:l,ariaLabelledBy:s,id:u})=>{const h=U({id:u,ariaLabel:l,ariaLabelledBy:s}),p=$e();return(0,n.jsxs)(q.Select.Root,{value:t,onValueChange:m=>m!==null&&r(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,n.jsxs)(q.Select.Trigger,{className:Ma,"data-error":i===!0,...h,children:[(0,n.jsx)(q.Select.Value,{className:La,children:m=>Da(e,m,o)}),(0,n.jsx)(q.Select.Icon,{className:Wt,children:(0,n.jsx)(ht,{size:"sm"})})]}),(0,n.jsx)(q.Select.Portal,{container:p??d.resolvePortalContainer(),className:re,children:(0,n.jsx)(d.PortalThemeProvider,{children:(0,n.jsx)(q.Select.Positioner,{className:_a,sideOffset:4,alignItemWithTrigger:!1,children:(0,n.jsx)(q.Select.Popup,{className:Na,children:e.map(m=>(0,n.jsxs)(q.Select.Item,{value:m.value,disabled:m.disabled,className:Ea,children:[m.icon,(0,n.jsxs)("span",{className:Fa,children:[(0,n.jsx)(q.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,n.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,n.jsx)(q.Select.ItemIndicator,{className:Wt,children:(0,n.jsx)(zr,{size:"sm"})})]},m.value))})})})})]})},Da=(e,t,r)=>t===null?(0,n.jsx)("span",{className:Ra,children:r}):Ba(e,t),Ba=(e,t)=>e.find(r=>r.value===t)?.label??t,Ga="vod76w0",Ha="vod76w1",Va="vod76w2",za="vod76w3",Wa="vod76w4",$a="vod76w5";var $r=({value:e,onChange:t,onCommit:r,min:o,max:a,step:i,suffix:l,formatValue:s,showValue:u=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=U({ariaLabel:p,ariaLabelledBy:m},!1),C=Ua(e,l,s),{commitUnlessHeldKey:x,gestureHandlers:j}=Ke(r);return(0,n.jsxs)("div",{className:Ga,children:[(0,n.jsx)(fe.Slider.Root,{className:Ha,value:e,onValueChange:y=>t(y),onValueCommitted:(y,S)=>{x(S.reason===Gr)},min:o,max:a,step:i,disabled:h,children:(0,n.jsx)(fe.Slider.Control,{className:Va,children:(0,n.jsxs)(fe.Slider.Track,{className:za,children:[(0,n.jsx)(fe.Slider.Indicator,{className:Wa}),(0,n.jsx)(fe.Slider.Thumb,{className:$a,...j,...g})]})})}),u&&(0,n.jsx)("span",{className:"vod76w6",children:C})]})},Ua=(e,t,r)=>r!==void 0?r(e):`${e}${t??""}`,qa=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})}),Ka="cnu9yl0",Za="_1n6f4bd0 cnu9yl1",Ya="_1n6f4bd1",Xa="_1n6f4bd2",Ja="_1n6f4bd3 uz3g761";var Qa=1e-9,Ur=e=>{const{value:t,onChange:r,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:l,disabled:s,ariaLabel:u,ariaLabelledBy:h,id:p}=e,{min:m,max:g,findAbove:C,findBelow:x}=ei(e),j=U({id:p,ariaLabel:u,ariaLabelledBy:h}),y=d.useI18n(),S=i??y("editor.accessibility.decrease"),P=l??y("editor.accessibility.increase"),[I,O]=(0,f.useState)(t),[w,A]=(0,f.useState)(t);t!==w&&(A(t),O(t));const M=t===null?void 0:x(t),b=t===null?void 0:C(t),R=N=>{N!==void 0&&(O(N),r(N))},V=N=>{const L=N===null?null:Math.min(Math.max(N,m),g);if(L!==null&&L!==t){r(L);return}O(t)},$=N=>{N.blur(),N.focus()};return(0,n.jsxs)("div",{className:Ka,children:[(0,n.jsx)($t,{label:S,icon:(0,n.jsx)(d.MinusIcon,{}),disabled:s===!0||M===void 0,onPress:()=>R(M)}),(0,n.jsx)(Ee.NumberField.Root,{className:Ya,value:I,onValueChange:O,onValueCommitted:V,min:m,max:g,disabled:s,readOnly:!a,children:(0,n.jsxs)(qe,{className:Xa,"data-disabled":s===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,n.jsx)(Ee.NumberField.Input,{className:Ja,onKeyDown:N=>{const L=N.currentTarget;if(N.key==="Enter"){$(L);return}if(N.key!=="ArrowUp"&&N.key!=="ArrowDown"||(N.preventBaseUIHandler(),N.preventDefault(),N.repeat))return;const v=I??t;v!==null&&($(L),R(N.key==="ArrowUp"?C(v):x(v)))},...j}),o!==void 0&&(0,n.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,n.jsx)($t,{label:P,icon:(0,n.jsx)(qa,{}),disabled:s===!0||b===void 0,onPress:()=>R(b)})]})},$t=({label:e,icon:t,disabled:r,onPress:o})=>(0,n.jsx)(W,{label:e,children:(0,n.jsx)("button",{type:"button",className:Za,"aria-label":e,"aria-disabled":r?!0:void 0,"data-disabled":r?"":void 0,onClick:r?void 0:o,children:t})}),ei=e=>{if(e.stops!==void 0){const{stops:s}=e,u=s[0],h=s.at(-1);if(u===void 0||h===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:u,max:h,findAbove:p=>s.find(m=>m>p),findBelow:p=>s.filter(m=>m<p).at(-1)}}const{step:t,min:r,max:o}=e;if(!(t>0))return{min:r,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(Ut(t),Ut(r)),i=s=>Math.min(Math.max(Number(s.toFixed(a)),r),o),l=(s,u)=>{const h=(s-r)/t,p=Math.round(h);return Math.abs(h-p)<Qa?p:u(h)};return{min:r,max:o,findAbove:s=>{if(!(s>=o))return i(r+(l(s,Math.floor)+1)*t)},findBelow:s=>{if(!(s<=r))return i(r+(l(s,Math.ceil)-1)*t)}}},Ut=e=>String(e).split(".")[1]?.length??0,ti="_1hyrlw60",ri="_1hyrlw61",qr=({checked:e,onChange:t,disabled:r,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const l=U({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,n.jsx)(Ht.Switch.Root,{checked:e,onCheckedChange:s=>t(s),disabled:r,className:ti,...l,children:(0,n.jsx)(Ht.Switch.Thumb,{className:ri})})},ni="uz3g761",oi="tpcnun0 uz3g760",Kr=({value:e,onChange:t,onCommit:r,placeholder:o,disabled:a,hasError:i,ariaLabel:l,ariaLabelledBy:s,id:u})=>{const h=U({id:u,ariaLabel:l,ariaLabelledBy:s});return(0,n.jsx)(qe,{className:oi,"data-error":i===!0,children:(0,n.jsx)(Lo.Input,{className:ni,value:e,onValueChange:p=>t(p),onBlur:r,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},ai="cnu9yl0",ii="cnu9yl1";var Zr=({options:e,value:t,onChange:r,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:l,ariaLabel:s,ariaLabelledBy:u,id:h})=>{const p=U({id:h,ariaLabel:s,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:C}=Ke(o);return(0,n.jsx)(Cr.RadioGroup,{className:ai,value:t,onValueChange:x=>{r(x),g()},...C,disabled:l,...p,children:e.map(x=>{const j=si(x,m),y=(0,n.jsxs)(br.Radio.Root,{value:x.value,disabled:x.disabled,className:(0,X.default)(ii,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":j,children:[x.icon,Yr(x,m)&&(0,n.jsx)("span",{className:"cnu9yl4",children:x.label})]},x.value);return j===void 0?y:(0,n.jsx)(W,{label:j,checked:x.value===t,children:y},x.value)})})},Yr=(e,t)=>e.icon===void 0||t,si=(e,t)=>{if(!Yr(e,t))return e.label},li={ToggleGroup:Zr,Switch:qr,Slider:$r,RadioGrid:Vr,Button:Tr,TextField:Kr,NumberField:Hr,Stepper:Ur,Select:Wr,ColorSwatches:Mr,CustomColor:Fr,DateField:Dr,FileInput:Br},at=(0,f.createContext)(li),ci=({controls:e,children:t})=>{const r=(0,f.useContext)(at),o=(0,f.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??r.ToggleGroup,Switch:e?.Switch??r.Switch,Slider:e?.Slider??r.Slider,RadioGrid:e?.RadioGrid??r.RadioGrid,Button:e?.Button??r.Button,TextField:e?.TextField??r.TextField,NumberField:e?.NumberField??r.NumberField,Stepper:e?.Stepper??r.Stepper,Select:e?.Select??r.Select,ColorSwatches:e?.ColorSwatches??r.ColorSwatches,CustomColor:e?.CustomColor??r.CustomColor,DateField:e?.DateField??r.DateField,FileInput:e?.FileInput??r.FileInput}),[r,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,n.jsx)(at.Provider,{value:o,children:t})},D=()=>(0,f.useContext)(at),qt={stack:"pr583x0",grid:"pr583x1"},Kt="pr583x2",di={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},_=({label:e,layout:t="grid",icon:r,children:o})=>{const a=(0,f.useId)(),i=(0,f.useId)();return e===void 0?(0,n.jsx)(nt,{className:qt[t],children:(0,n.jsx)("div",{className:Kt,children:o})}):(0,n.jsxs)(nt,{className:qt[t],children:[(0,n.jsxs)("label",{id:a,htmlFor:i,className:di[r===void 0?"plain":"withIcon"],children:[r!==void 0&&(0,n.jsx)("span",{"aria-hidden":"true",children:r}),e]}),(0,n.jsx)("div",{className:Kt,children:(0,n.jsx)(Pr,{labelId:a,controlId:i,children:o})})]})},vt=({target:e})=>{const t=d.useGraphHandle();return t===null?null:(0,n.jsx)(ui,{graph:t,axis:e.axis})};vt.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var ui=({graph:e,axis:t})=>{const r=d.useHandleScene(e),o=d.useI18n(),{NumberField:a,TextField:i,ToggleGroup:l}=D(),s=r?.guides.axes.find(b=>b.scaledAesthetic===t);if((0,f.useEffect)(()=>()=>e.commands.commit(),[e.commands]),r===null||s?.geometry!=="linear")return null;const u=!s.visible,h=s.visible||s.showGrid,p=r.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=r.guides.legends.drawn.some(b=>b.position==="left"||b.position==="right"),C=t!=="x"&&p==="continuous"&&(s.position==="left"||s.position==="right")&&!g,x=t==="x"?void 0:r.scales[t]?.spec,j=x?.scaleType==="continuous"?x:void 0,y=j!==void 0&&(s.position==="left"||s.position==="right")&&!(0,c.isZeroAnchoredAxis)(r,t),S=j?.transform==="log"?"log":"linear",P=y&&j.transform!=="log",I=j?.domainMin??null,O=j!==void 0&&(s.position==="left"||s.position==="right")&&j.transform!=="log",w=j?.domainMax??null,A=r.config.axes[t]?.label??s.label??"",M=b=>{const R=t==="ySecondary"?{axis:t,label:b}:{axis:t,label:b};e.commands.dispatch(new c.SetAxisLabelCommand(R),{transient:!0})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_,{label:o("editor.axesPanel.controls.title"),children:(0,n.jsx)(i,{value:A,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:M,onCommit:e.commands.commit,disabled:u})}),m&&(0,n.jsx)(_,{label:o("editor.axesPanel.controls.labels"),children:(0,n.jsx)(l,{value:s.tickMode,disabled:!h,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,n.jsx)(Bo,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,n.jsx)(Do,{})}],onChange:b=>{const R=b==="edges"?"edges":"auto";e.commands.dispatch(new c.SetAxisTickModeCommand({axis:t,tickMode:R,keepSecondaryAxis:!0}))}})}),C&&(0,n.jsx)(_,{label:o("editor.axesPanel.controls.position"),children:(0,n.jsx)(l,{value:s.position,disabled:u,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,n.jsx)(_o,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,n.jsx)(No,{})}],onChange:b=>{if(b!=="left"&&b!=="right")return;const R=t==="y"?b:b==="left"?"right":"left";e.commands.dispatch(new c.SetAxisPositionCommand({axis:"y",position:R}))}})}),y&&(0,n.jsx)(_,{label:o("editor.axesPanel.controls.scale"),children:(0,n.jsx)(l,{value:S,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,n.jsx)(Eo,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,n.jsx)(Fo,{})}],onChange:b=>{e.commands.dispatch(new c.SetScaleTransformCommand({scaledAesthetic:t,transform:b==="log"?"log":"linear"}))}})}),P&&(0,n.jsx)(_,{label:o("editor.axesPanel.controls.startFrom"),children:(0,n.jsx)(a,{value:I,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:b=>{e.commands.dispatch(new c.SetScaleDomainCommand({scaledAesthetic:t,domainMin:b}),{transient:!0})},onCommit:e.commands.commit})}),O&&(0,n.jsx)(_,{label:o("editor.axesPanel.controls.endAt"),children:(0,n.jsx)(a,{value:w,placeholder:o("editor.axesPanel.endAt.auto"),onChange:b=>{e.commands.dispatch(new c.SetScaleDomainCommand({scaledAesthetic:t,domainMax:b}),{transient:!0})},onCommit:e.commands.commit})})]})},hi={narrow:3,regular:6,wide:11},pi=({barWidth:e,...t})=>{const r=hi[e];return(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("rect",{x:(18-r)/2,y:3,width:r,height:12,fill:"currentColor"})})},mi=6,K=({target:e})=>{const{commands:t,findGeom:r}=d.useGraphContext(),o=d.useI18n(),a=d.useStyleReaderTree(),i=d.useSceneSelector(p=>p),l=Jr(e,i,r);(0,f.useEffect)(()=>()=>t.commit(),[t]);const s=(0,f.useMemo)(()=>(0,c.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(l===null)return null;const u=(p,m)=>{const g=l[0]?.part;t.dispatch(new c.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=l[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,n.jsx)(Xr,{label:h,palette:(0,c.readColorChoices)(i.scales.color),selectedColor:s,paint:u,commit:()=>t.commit()})},Xr=({label:e,palette:t,selectedColor:r,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:l}=D();return(0,n.jsx)(_,{label:e,layout:"stack",children:(0,n.jsx)(i,{colors:gi(t.slice(0,mi),r),value:r,onChange:s=>o(s,!1),trailing:(0,n.jsx)(l,{variant:"chip",value:r,onChange:s=>o(s,!0),onCommit:a})})})};K.hasRows=(e,{scene:t,findGeom:r})=>Jr(e,t,r)!==null;var Jr=(e,t,r)=>{if((0,c.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,c.readObservationsColorPart)({layers:t.layers,target:e});return(0,c.readObservationsColorRoute)(t.spec,e,r,o)},gi=(e,t)=>t===null||e.some(r=>pt(r,t))?e:[...e,t],Ye=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],ft=({target:e})=>{const t=d.useSceneSelector(g=>g),r=d.useGraphCommands(),o=d.useI18n(),{ToggleGroup:a}=D(),i=(0,c.findLayerById)(t.spec.layers,e.layerId),l=(0,c.isLayerSpecOf)(i,"bar")?i:null,s=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,u=g=>{const C=Ye.find(({name:x})=>x===g);C!==void 0&&r.dispatch(new c.SetBarWidthCommand({layerId:e.layerId,width:C.width}))},h=Ye.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,n.jsx)(pi,{barWidth:g})})),p=l===null?null:(0,c.resolveBarBandFraction)(l.params,t.coordSystem.type),m=Ye.find(({width:g})=>g===p)?.name??"";return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(K,{target:e}),l!==null&&!s?(0,n.jsx)(_,{label:o("editor.graphPanel.barSection.thickness"),children:(0,n.jsx)(a,{value:m,options:h,onChange:u})}):null]})};ft.hasRows=K.hasRows;var vi={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},fi=({curve:e,...t})=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("path",{d:vi[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),xi={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},yi=({missingValues:e,...t})=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("path",{d:xi[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Zt={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Qr=(e,t,r)=>{if(!r.hasCapability(e.geom,t)||bi(e))return Zt;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&r.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},bi=e=>{const t=(0,c.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},en=(e,t)=>{switch(t){case"gap":return e("editor.graphPanel.treatEmptyValues.leaveGap.label");case"zero":return e("editor.graphPanel.treatEmptyValues.fillZero.label");case"connect":return e("editor.graphPanel.treatEmptyValues.connectGaps.label");default:return t}},Ci=.1,it=["gap","zero","connect"],xt=(e,t,r)=>{const o=(0,c.findLayerById)(e.spec.layers,r);if(!(0,c.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,c.buildLayerStyleAddress)(o.geom,o.id),l=(0,c.readStyleCoord)(e.spec),s=e.spec.styles.overrides,u=(0,c.combineKindStyleDeclarations)(s,i,l),h=(0,c.combineKindStyleDeclarations)((0,c.readStyleRulesBeneath)(s,i,l),i,l),p=typeof u?.strokeWidth=="number"?u.strokeWidth:null,m=ji(o,e.spec.layers),g=a?[]:wi(o),C=g.length>1,x=o.geom==="line"&&!a,j=x?Ii(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&Si(e,t,m.id),pointLayerId:m?.id??null,showFill:x?j>0:null,drawnFillAlpha:j,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??Pi(e,t,o)??c.DEFAULT_STROKE_WIDTH_PX,missingValues:C?o.params.missingValues:null,missingValueOptions:C?g:[]}},ji=(e,t)=>(0,c.filterLayersByGeoms)(t,"point").find(r=>(0,c.isCompanionLayer)(r,[e])),Si=(e,t,r)=>{const o=(0,c.findLayerById)(e.layers,r);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},wi=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(r=>r!=="gap"):t},Pi=(e,t,r)=>{const o=(0,c.findLayerById)(e.layers,r.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},Ii=(e,t,r)=>{const o=(0,c.findLayerById)(e.layers,r.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Ti=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),Oi=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,n.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,n.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,n.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,n.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),tn=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,n.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,n.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,n.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,n.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,n.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,n.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),ki=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),Ai=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,n.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Mi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),Li=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),Ri=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),_i=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Ni=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Ei=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,n.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,n.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,n.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,n.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,n.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,n.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Fi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Di=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"currentColor",children:[(0,n.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,n.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Bi=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),Gi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",strokeOpacity:"0.3",strokeWidth:".8"}),(0,n.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",strokeOpacity:"0.8",strokeWidth:"1.2"})]})}),Hi=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeOpacity:"0.3",strokeWidth:".8"}),(0,n.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",fill:"currentColor",fillOpacity:"0.6"})]}),Vi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,n.jsxs)("g",{strokeOpacity:"0.2",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),zi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsx)("path",{fill:"currentColor",fillOpacity:"0.75",d:"M8.4 7.31 8.4 1.01A7 7 0 0 1 13.85 4.16ZM8.8 8 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8ZM8.4 8.69 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59ZM7.6 8.69 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74ZM7.2 8 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31ZM7.6 7.31 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52Z"})}),Wi=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"currentColor",children:[(0,n.jsx)("path",{fillOpacity:"0.35",d:"M8.4 3.82 8.4 1.01A7 7 0 0 1 13.85 4.16L11.42 5.56A4.2 4.2 0 0 0 8.4 3.82ZM11.46 6.47 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8L11.46 9.53A3.78 3.78 0 0 0 11.46 6.47ZM10.69 10.01 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59L8.4 11.34A3.36 3.36 0 0 0 10.69 10.01ZM7.6 10.85 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74L5.73 9.77A2.88 2.88 0 0 0 7.6 10.85ZM5.7 8.87 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31L5.7 7.13A2.46 2.46 0 0 0 5.7 8.87ZM6.41 6.62 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52L7.6 5.94A2.1 2.1 0 0 0 6.41 6.62Z"}),(0,n.jsx)("path",{fillOpacity:"0.9",d:"M8.4 7.31 8.4 3.82A4.2 4.2 0 0 1 11.42 5.56ZM8.8 8 11.46 6.47A3.78 3.78 0 0 1 11.46 9.53ZM8.4 8.69 10.69 10.01A3.36 3.36 0 0 1 8.4 11.34ZM7.6 8.69 7.6 10.85A2.88 2.88 0 0 1 5.73 9.77ZM7.2 8 5.7 8.87A2.46 2.46 0 0 1 5.7 7.13ZM7.6 7.31 6.41 6.62A2.1 2.1 0 0 1 7.6 5.94Z"})]})}),$i=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 16 16",...e,children:(0,n.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,n.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,n.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,n.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,n.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,n.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,n.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,n.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Ui=.55,qi=.15,Fe=[{name:"column",icon:Ri,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Ni,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:_i,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Ai,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Li,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Mi,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:tn,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:ki,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Ei,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:$i,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Bi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Fi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Ui}},{name:"radialBar",icon:Vi,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:qi}},{name:"rose",icon:zi,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:Wi,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Gi,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Hi,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Di,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Ki=.05,rn=(e,t)=>(0,c.isComboGraphType)(e)?(0,c.canBecomeCombo)(t):e.geom==="tile"?(0,c.canBecomeHeatmap)(t):!0,De=e=>e===null?null:Fe.find(t=>Zi(t.summary,e))??null,nn=(e,t)=>t===null||(0,c.isComboGraphType)(e)?e:e.position==="dodge"&&on(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Be(e.innerRadius)||t.coordType!=="polar"||!Be(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},on=e=>!(0,c.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Zi=(e,t)=>{if((0,c.isComboGraphType)(e)||(0,c.isComboGraphType)(t))return(0,c.isComboGraphType)(e)&&(0,c.isComboGraphType)(t);const r=e.position===t.position||e.position==="dodge"&&on(t);return e.coordType!==t.coordType||e.geom!==t.geom||!r?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Be(e.innerRadius)===Be(t.innerRadius)},Be=e=>e>=Ki;var Yi="_1a90obs1",Xi=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Ti},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Oi},{summary:{coordType:"cartesian",comboType:"lines"},icon:tn}],Ji=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Qi=4,es={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},ts={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},rs=()=>{const e=d.useSceneSelector(A=>A.spec),t=d.useSceneSelector(({layers:A})=>A.some(M=>(0,c.hasMultipleGroups)(M.data,M.mapping))),r=d.useGraphCommands(),o=d.useI18n(),{Button:a,RadioGrid:i}=D(),[l,s]=(0,f.useState)(!1),u=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!l)return;const A=({target:M,detail:b})=>{b>0&&os(M)&&u.current?.contains(M)&&s(!1)};return document.addEventListener("click",A),()=>document.removeEventListener("click",A)},[l]);const h=(0,c.readGraphType)(e);if(h===null)return null;const p=as(h),m=Ge(h),g=De(h),C=p??g,x=o(C===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${C.name}`),j=(p===void 0?g:Xt(p,m))?.icon,y=p!==void 0&&p.arrangements.length>1,S=y&&(t||p.name==="combo"),P=()=>s(!l),I=({summary:A})=>{r.dispatch(new c.SetGraphTypeCommand(nn(A,h)),{transient:!0})},O=A=>{const M=Yt.find(b=>b.name===A);M!==void 0&&I(Xt(M,y?m:null))},w=Yt.map(({name:A,arrangements:[M]})=>({value:A,label:o(`editor.graphTypes.${A}`),icon:(0,n.jsx)(M.icon,{size:"md"}),disabled:!rn(M.summary,e)}));return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_,{label:o("editor.overlayMenu.chartType"),children:j===void 0?(0,n.jsx)(a,{label:x,expanded:l,onClick:P}):(0,n.jsx)(a,{variant:"icon",icon:(0,n.jsx)(j,{size:"sm"}),ariaLabel:x,expanded:l,onClick:P})}),l&&(0,n.jsx)(_,{layout:"stack",children:(0,n.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,n.jsx)(i,{options:w,value:p?.name??"",onChange:O,onCommit:r.commit,columns:Qi,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),S&&(0,n.jsx)(ns,{type:p,arrangement:m,onPick:I,onCommit:r.commit})]})},an=(e,t)=>(0,c.isComboGraphType)(e)||(0,c.isComboGraphType)(t)?(0,c.isComboGraphType)(e)&&(0,c.isComboGraphType)(t):e.coordType==="polar"?De(e)===De(t):e.coordType===t.coordType&&e.geom===t.geom,sn=Ji.flatMap(([e,t])=>{const r=Fe.find(o=>o.name===t);return r===void 0?[]:[{name:e,arrangements:[r,...[...Fe,...Xi].filter(o=>o!==r&&an(r.summary,o.summary))]}]}),Yt=sn.filter(({name:e})=>e!=="combo"),ns=({type:e,arrangement:t,onPick:r,onCommit:o})=>{const a=d.useI18n(),{ToggleGroup:i}=D(),l=e.arrangements.map(({summary:u,icon:h})=>{const p=Ge(u);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,n.jsx)(h,{size:"sm"})}}),s=u=>{const h=e.arrangements.find(({summary:p})=>Ge(p)===u);h!==void 0&&r(h)};return(0,n.jsx)(_,{label:a("editor.overlayMenu.arrange"),children:(0,n.jsx)("div",{className:Yi,children:(0,n.jsx)(i,{options:l,value:t,onChange:s,onCommit:o})})})},os=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,Ge=e=>(0,c.isComboGraphType)(e)?ts[e.comboType]:es[e.position],Xt=(e,t)=>e.arrangements.find(({summary:r})=>Ge(r)===t)??e.arrangements[0],as=e=>sn.find(({arrangements:[t]})=>an(t.summary,e)),is=()=>{const e=d.useSceneSelector(s=>s.scales.color),t=d.useGraphCommands(),r=d.useI18n(),[o,a]=(0,f.useState)(null);(0,f.useEffect)(()=>()=>t.commit(),[t]);const i=(0,c.readColorChoices)(e),l=(0,c.readColormapColor)(e,o===null?i:[o,...i]);return(l===null?[{label:r("editor.overlayMenu.lowColor"),color:(0,c.readDivergingColor)(e,"low"),buildRange:s=>(0,c.buildDivergingRange)(e,"low",s)},{label:r("editor.overlayMenu.highColor"),color:(0,c.readDivergingColor)(e,"high"),buildRange:s=>(0,c.buildDivergingRange)(e,"high",s)}]:[{label:r("editor.overlayMenu.fillColor"),color:l,buildRange:s=>(0,c.buildColormapRange)(e,s)}]).map(({label:s,color:u,buildRange:h})=>{if(u===null)return null;const p=(m,g)=>{const C=h(m);C!==null&&(a(m),t.dispatch(new c.SetScaleRangeCommand({scaledAesthetic:"color",range:C}),g?{transient:!0}:void 0))};return(0,n.jsx)(Xr,{label:s,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},s)})},ln=({lineStyle:e,...t})=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,n.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,n.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,n.jsxs)("g",{fill:"currentColor",children:[(0,n.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,n.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,n.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),cn=({lineWidth:e,...t})=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),ss={small:2,medium:3.8,large:5.6},ls=({pointSize:e,...t})=>(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("circle",{cx:9,cy:9,r:ss[e],fill:"currentColor"})});var cs=({symbol:e,...t})=>{const r=(0,c.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,n.jsx)(d.Icon,{viewBox:"0 0 18 18",...t,children:(0,n.jsx)("path",{d:r.path,fill:"currentColor",transform:`translate(${o+r.offsetX} ${o+r.offsetY})`})})},ds="_1yjsaqt0",us="_1yjsaqt1",hs="_1yjsaqt2",ps="_1yjsaqt3";var jd=512*1024,ms=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const r=new FileReader;r.onerror=()=>t({rejection:"undecodable"}),r.onload=()=>{const o=r.result;if(typeof o!="string"||!o.startsWith("data:image/")){t({rejection:"undecodable"});return}const a=new Image;a.onload=()=>t({image:o}),a.onerror=()=>t({rejection:"undecodable"}),a.src=o},r.readAsDataURL(e)}),Jt=["solid","dashed","dotted"],Xe=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Je=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],gs=["circle","square","diamond","triangle","cross","star"],dn=({widthPx:e,onChange:t})=>{const r=d.useI18n(),{ToggleGroup:o}=D(),a=i=>{const l=Xe.find(({name:s})=>s===i);l!==void 0&&t(l.widthPx)};return(0,n.jsx)(_,{label:r("editor.graphPanel.lineThickness.label"),children:(0,n.jsx)(o,{value:Xe.find(i=>i.widthPx===e)?.name??"",options:Xe.map(({name:i,widthPx:l})=>({value:i,label:r(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,n.jsx)(cn,{lineWidth:l})})),onChange:a})})},un=({lineStyle:e,onChange:t})=>{const r=d.useI18n(),{ToggleGroup:o}=D(),a=i=>{const l=Jt.find(s=>s===i);l!==void 0&&t(l)};return(0,n.jsx)(_,{label:r("editor.fineTunePanel.lineStyleSection.title"),children:(0,n.jsx)(o,{value:e??"",options:Jt.map(i=>({value:i,label:r(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,n.jsx)(ln,{lineStyle:i})})),onChange:a})})},yt=({symbol:e,coordType:t,onChange:r})=>{const o=d.useI18n(),{RadioGrid:a}=D(),[i,l]=(0,f.useState)(null),s=(0,f.useContext)(Ue),u=d.useGlyphRegistry(),h=d.useGeomRendererResolver(),p=s?s.getPointSymbols(t):h("point",t)?.symbols,m=s?new Map(s.getGlyphs().map(({name:w,definition:A})=>[w,A])):u;if(p===void 0||p.length===0)return null;const g=w=>typeof w=="string"&&p.includes(w),C=w=>g(w)||(0,c.isImageSymbol)(w)||!(0,c.isGeometricSymbol)(w)&&m.has(w),x=w=>!(0,c.isGeometricSymbol)(w)||gs.some(A=>A===w),j=[...m.keys()].filter(w=>!(0,c.isGeometricSymbol)(w)&&!g(w)),y=[...p.filter(x),...j],S=e===null?"":we(e),P=e===null||y.some(w=>we(w)===S)||!C(e)?y:[...y,e],I=w=>(0,c.isGeometricSymbol)(w)?o(`editor.graphPanel.pointSymbol.symbols.${w}`):(0,c.isImageSymbol)(w)?o("editor.graphPanel.pointSymbol.custom"):w,O=w=>{l(null);const A=P.find(M=>we(M)===w);A!==void 0&&r(A)};return(0,n.jsx)(_,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,n.jsxs)("div",{className:ds,children:[(0,n.jsxs)("div",{className:us,children:[(0,n.jsx)(a,{itemLayout:"chip",value:S,options:P.map(w=>({value:we(w),label:I(w),icon:(0,n.jsx)(fs,{symbol:w,glyphs:m})})),onChange:O}),(0,n.jsxs)("span",{className:Qo,children:[(0,n.jsx)("span",{className:ea,"aria-hidden":"true"}),(0,n.jsx)(vs,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:w=>{l(null),r(w)},onReject:l})]})]}),i!==null&&(0,n.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},bt=({sizePx:e,onChange:t})=>{const r=d.useI18n(),{ToggleGroup:o}=D(),a=i=>{const l=Je.find(({name:s})=>s===i);l!==void 0&&t(l.sizePx)};return(0,n.jsx)(_,{label:r("editor.graphPanel.pointSize.label"),children:(0,n.jsx)(o,{value:Je.find(i=>i.sizePx===e)?.name??"",options:Je.map(({name:i})=>({value:i,label:r(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,n.jsx)(ls,{pointSize:i})})),onChange:a})})},vs=({label:e,onChange:t,onReject:r})=>{const{FileInput:o}=D(),a=i=>{ms(i).then(l=>{"image"in l?t({image:l.image}):r(l.rejection)})};return(0,n.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},fs=({symbol:e,glyphs:t})=>{if((0,c.isGeometricSymbol)(e))return(0,n.jsx)(cs,{symbol:e});const r=xs(e,t);if(r!==null&&d.tintsGlyphImage(r))return(0,n.jsx)("span",{className:ps,style:{maskImage:`url(${JSON.stringify(r)})`}});if(r!==null)return(0,n.jsx)("img",{className:hs,src:r,alt:""});const o=18/2;return(0,n.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,n.jsx)(d.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},we=e=>typeof e=="string"?e:e.image,xs=(e,t)=>{if((0,c.isImageSymbol)(e))return e.image;const r=t.get(e);return r!==void 0&&typeof r!="function"&&"image"in r?r.image:null},hn=(0,f.createContext)({}),ys=hn.Provider,bs=()=>(0,f.useContext)(hn),Cs="_1qh3fon0",st="theme",js=3,Pe=14,Qt=9,pn=()=>{const e=d.useSceneSelector(p=>p.scales.color),t=bs(),r=d.useGraphCommands(),o=d.useI18n(),{RadioGrid:a}=D();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:l}=e,s=Object.entries(t),u=[{value:st,label:o("editor.overlayMenu.themePalette"),icon:(0,n.jsx)(er,{colors:i})},...s.map(([p,m])=>({value:lt(p),label:p,icon:(0,n.jsx)(er,{colors:m})}))],h=p=>{const m=s.find(([C])=>lt(C)===p);if(p!==st&&m===void 0)return;const g=m===void 0?null:[...m[1]];r.dispatch(new c.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,n.jsx)(_,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,n.jsx)(a,{options:u,value:Ss(l.range,s),onChange:h,onCommit:r.commit,columns:4,itemLayout:"track"})})},lt=e=>`preset:${e}`,Ss=(e,t)=>{if(e===null)return st;const r=t.find(([,o])=>(0,Ao.isEqual)(o,e));return r===void 0?"":lt(r[0])},er=({colors:e})=>{const t=e.slice(0,js),r=Pe/2,o=Pe+(t.length-1)*Qt;return(0,n.jsx)("svg",{width:o,height:Pe,viewBox:`0 0 ${o} ${Pe}`,"aria-hidden":"true",children:t.map((a,i)=>(0,n.jsx)("circle",{className:Cs,cx:r+i*Qt,cy:r,r:r-.5,fill:a},i)).reverse()})},tr=["smooth","linear"],rr=["auto","inside","outside"],Ct=()=>{const e=d.useSceneSelector(v=>v),t=d.useStyleReaderTree(),r=d.useDataLabelPlacementResolver(),o=d.useGraphCommands(),a=d.useI18n(),{Switch:i,ToggleGroup:l}=D(),s=mn(e.layers,e.coordSystem.type,r),u=v=>s.filter(({support:k})=>v(k)).map(({layer:k})=>k),h=ws(e,t),p=h.filter(v=>v.smooth!==null),m=h.filter(v=>v.missingValues!==null&&v.missingValueOptions.length>1),g=it.filter(v=>m.some(k=>k.missingValueOptions.includes(v))),C=Os(p),x=ks(m),j=v=>{o.dispatch(new c.SequenceCommand({commands:h.map(k=>new c.ToggleLinePointsCommand({layerId:k.layerId,showPoints:v}))}))},y=v=>{const k=tr.find(B=>B===v);k!==void 0&&o.dispatch(new c.SequenceCommand({commands:p.map(B=>new c.SetLineCurveCommand({layerId:B.layerId,curve:k}))}))},S=u(v=>v.supportsPosition),P=Ie(S.map(v=>v.dataLabels.position))??"",I=v=>{const k=rr.find(B=>B===v);k!==void 0&&o.dispatch(new c.SequenceCommand({commands:S.map(B=>new c.SetDataLabelsCommand({layerId:B.id,position:k}))}))},O=v=>{const k=it.find(G=>G===v);if(k===void 0)return;const B=m.filter(G=>G.missingValueOptions.includes(k)).map(G=>new c.SetLineMissingValuesCommand({layerId:G.layerId,missingValues:k}));B.length!==0&&o.dispatch(new c.SequenceCommand({commands:B}))},w=h.filter(v=>v.showFill!==null),A=h.filter(v=>v.showPoints),M=Ps(e,t,h),b=w.some(v=>Is(e,v)),R=v=>{v.length>0&&o.dispatch(new c.SequenceCommand({commands:v}))},V=v=>{R(h.map(k=>new c.SetLineStyleCommand({layerId:k.layerId,strokeWidth:v})))},$=v=>{R(h.map(k=>new c.SetLineStyleCommand({layerId:k.layerId,lineStyle:v})))},N=v=>{R(w.map(k=>new c.SetLineStyleCommand({layerId:k.layerId,showFill:v,drawnFillAlpha:k.drawnFillAlpha})))},L=v=>{R(A.flatMap(({pointLayerId:k})=>k===null?[]:[new c.SetPointSizeCommand({layerId:k,size:v})]))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(rs,{}),(0,n.jsx)(Te,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(v=>v.supportsDataLabels),isOn:v=>v.showDataLabels,buildCommand:(v,k)=>new c.ToggleDataLabelsCommand({layerId:v,showDataLabels:k})}),S.length>0&&(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,n.jsx)(l,{value:P,options:rr.map(v=>({value:v,label:a(`editor.graphPanel.graphOptions.labelPositions.${v}`)})),onChange:I})}),(0,n.jsx)(Te,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(v=>v.supportsPercentages),isOn:v=>v.format==="percentage",buildCommand:(v,k)=>new c.SetDataLabelsFormatCommand({layerId:v,format:k?"percentage":"absolute"})}),(0,n.jsx)(Te,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(v=>v.supportsStackTotals),isOn:v=>v.showStackTotals,buildCommand:(v,k)=>new c.ToggleStackTotalsCommand({layerId:v,showStackTotals:k})}),(0,n.jsx)(Te,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(v=>v.supportsCategoryLabels),isOn:v=>v.showCategoryLabels,buildCommand:(v,k)=>new c.ToggleCategoryLabelsCommand({layerId:v,showCategoryLabels:k})}),(0,n.jsx)(_,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,n.jsx)(i,{checked:e.config.content.showTitle,onChange:v=>o.dispatch(new c.ToggleContentVisibilityCommand({part:"title",visible:v}))})}),(0,n.jsx)(_,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,n.jsx)(i,{checked:e.config.content.showSubtitle,onChange:v=>o.dispatch(new c.ToggleContentVisibilityCommand({part:"subtitle",visible:v}))})}),(0,n.jsx)(_,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,n.jsx)(i,{checked:e.config.content.showCaption,onChange:v=>o.dispatch(new c.ToggleContentVisibilityCommand({part:"caption",visible:v}))})}),p.length>0&&(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,n.jsx)(l,{value:C,options:tr.map(v=>({value:v,label:a(`editor.graphPanel.graphOptions.curves.${v}`),icon:(0,n.jsx)(fi,{curve:v})})),onChange:y})}),g.length>1&&(0,n.jsx)(_,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,n.jsx)(l,{value:x,options:g.map(v=>({value:v,label:en(a,v),icon:(0,n.jsx)(yi,{missingValues:v})})),onChange:O})}),h.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(dn,{widthPx:Ie(M.map(v=>v.strokeWidth)),onChange:V}),(0,n.jsx)(un,{lineStyle:Ie(M.map(v=>v.lineStyle)),onChange:$})]}),w.length>0&&(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,n.jsx)(i,{checked:b,onChange:N})}),h.length>0&&(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,n.jsx)(i,{checked:A.length>0,onChange:j})}),A.length>0&&(0,n.jsx)(bt,{sizePx:Ie(Ts(e,t,A)),onChange:L}),(0,n.jsx)(pn,{}),(0,n.jsx)(is,{})]})};Ct.hasRows=(e,{scene:t,dataLabelPlacement:r})=>(0,c.readGraphType)(t.spec)!==null||mn(t.layers,t.coordSystem.type,r).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,c.isLayerSpecOf)(o,"line","area"));var mn=(e,t,r)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:Qr(o,t,r)})),ws=(e,t)=>{const r=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=xt(e,t,o.id);a!==null&&r.push(a)}return r},Ps=(e,t,r)=>r.flatMap(o=>{const a=(0,c.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const l=t.geom.line(a);return Array.from(a.data,s=>({strokeWidth:l.get("strokeWidth",s),lineStyle:(0,c.toDashPreset)(l.get("dashArray",s))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,l=>({strokeWidth:i.get("strokeWidth",l),lineStyle:(0,c.toDashPreset)(i.get("dashArray",l))}))}),Is=(e,t)=>{if(t.showFill===!0)return!0;const r=(0,c.buildLayerStyleAddress)("line",t.layerId),o=(0,c.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,c.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,c.createStyleRuleMatcher)({...r,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},Ts=(e,t,r)=>r.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,c.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,l=>i.get("size",l)).filter(l=>l>0)}),Ie=e=>{const[t]=e;return t!==void 0&&e.every(r=>r===t)?t:null},Os=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ks=e=>{const[t,...r]=e,o=t?.missingValues??null;return o===null?"":r.every(a=>a.missingValues===o)?o:""},Te=({label:e,layers:t,isOn:r,buildCommand:o})=>{const a=d.useGraphCommands(),{Switch:i}=D();if(t.length===0)return null;const l=s=>{a.dispatch(new c.SequenceCommand({commands:t.map(u=>o(u.id,s))}))};return(0,n.jsx)(_,{label:e,children:(0,n.jsx)(i,{checked:t.some(s=>r(s.dataLabels)),onChange:l})})},As=(e,t)=>{const r=(0,c.findLayerById)(t.layers,e);if(r===void 0)return null;const o=(0,c.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,c.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==r.id?a:r;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},Oe=(e,t)=>{for(const r of e){const o=t(r);if(o!==void 0)return o}return null},Ms=({geom:e,coord:t,position:r},o,a="style",i=null)=>{for(const l of o){const s=nr(or(l.layers,e)?.[t]?.[r],a),u=s!==void 0?s:nr(or(l.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},Ls=e=>typeof e=="object"&&("style"in e||"annotate"in e),nr=(e,t)=>e==null?e:Ls(e)?e[t]:t==="style"?e:void 0,or=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,ct=["solid","dashed","dotted"],Rs=.5,gn=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",vn=(e,t)=>{const r=e.guides.axes.filter(gn);if(r.length===0)return null;const o=t.gridLine.y().resolve();return{axes:r,stylable:e.coordSystem.type!=="polar",lineStyle:(0,c.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},_s=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const r=t.axes.find(o=>o.scaledAesthetic===e);return r===void 0||!r.showGrid},fn=(e,t="both")=>new c.SetGridLineStyleCommand({axis:t,lineStyle:e}),xn=(e,t="both")=>new c.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Qe=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],jt=({target:e})=>{const t=d.useSceneSelector(y=>y),r=d.useStyleReaderTree(),o=vn(t,r),a=d.useI18n(),i=d.useGraphCommands(),{ToggleGroup:l}=D();if(o===null||!o.stylable)return null;const s=e.axis==="both"?"y":e.axis,u=r.gridLine[s]().resolve(),h=(0,c.toDashPreset)(u.dashArray),p=_s(e.axis,o),m=ct.map(y=>({value:y,label:a(`editor.graphPanel.gridSection.lineStyles.${y}`),icon:(0,n.jsx)(ln,{lineStyle:y})})),g=Qe.map(({name:y,widthPx:S})=>({value:y,label:a(`editor.graphPanel.gridSection.lineWidths.${y}`),icon:(0,n.jsx)(cn,{lineWidth:S})})),C=Qe.find(({widthPx:y})=>y===u.strokeWidth)?.name??"",x=y=>{const S=ct.find(P=>P===y);S!==void 0&&i.dispatch(fn(S,e.axis))},j=y=>{const S=Qe.find(({name:P})=>P===y);S!==void 0&&i.dispatch(xn(S.widthPx,e.axis))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,n.jsx)(l,{value:h,options:m,onChange:x,disabled:p})}),(0,n.jsx)(_,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,n.jsx)(l,{value:C,options:g,onChange:j,disabled:p})})]})};jt.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const r=t.guides.axes.filter(gn);return r.length===0?!1:e.axis==="both"?!0:r.some(o=>o.scaledAesthetic===e.axis)};var ar=[{position:"top",align:"start",gridRow:1,gridColumn:1},{position:"top",align:"center",gridRow:1,gridColumn:2},{position:"top",align:"end",gridRow:1,gridColumn:3},{position:"right",align:"center",gridRow:2,gridColumn:3},{position:"bottom",align:"end",gridRow:3,gridColumn:3},{position:"bottom",align:"center",gridRow:3,gridColumn:2},{position:"bottom",align:"start",gridRow:3,gridColumn:1},{position:"left",align:"center",gridRow:2,gridColumn:1}],Ns={start:"Start",center:"Center",end:"End"},yn=()=>{const e=d.useSceneSelector(u=>u.guides.legends.drawn[0]),t=d.useGraphCommands(),r=d.useI18n(),{RadioGrid:o}=D(),a=e===void 0,i=a?"":et(e),l=ar.map(u=>{const h=et(u);return{value:h,label:r(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,n.jsx)(d.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Fs(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:Es(e,u)}}),s=u=>{const h=ar.find(p=>et(p)===u);h!==void 0&&t.dispatch(new c.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,n.jsx)(_,{label:r("editor.axesPanel.controls.position"),children:(0,n.jsx)(Ro.DirectionProvider,{direction:"ltr",children:(0,n.jsx)("div",{dir:"ltr",children:(0,n.jsx)(o,{options:l,value:i,onChange:s,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},et=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Ns[t]}`,Es=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Fs=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,bn=(e,t,r,o)=>{const a=jn(e,r,o)?.size;if(typeof a=="number")return a;const i=(0,c.findLayerById)(e.layers,r);return i?.geom==="point"?t.geom.point(i).get("size"):c.DEFAULT_POINT_SIZE_PX},Cn=(e,t,r,o)=>{const a=jn(e,r,o)?.symbol;if(a!==void 0)return a;const i=(0,c.findLayerById)(e.layers,r);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},jn=(e,t,r)=>r===void 0?void 0:(0,c.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,c.buildLayerStyleAddress)("point",t),when:{where:r}},(0,c.readStyleCoord)(e.spec)),He=({target:e})=>{const t=d.useGraphHandle();return t===null?null:(0,n.jsx)(Ds,{graph:t,target:e})};He.hasRows=(e,{scene:t})=>e.scope==="group"&&Sn(t,e.layerId)!==null;var Ds=({graph:e,target:t})=>{const r=d.useHandleScene(e),o=d.useStyleReaderTree(),a=d.useI18n(),{Switch:i}=D(),l=r===null?null:Sn(r,t.layerId),s=r===null||l===null?null:xt(r,o,l.id);if(r===null||l===null||s===null)return null;const u=Vs(r,t),h=u===void 0?{}:{where:u},p=u===void 0||l.geom!=="line"?void 0:Hs(r,s.layerId,u),m=p===void 0?s.showFill:p>0,g=u===void 0?null:Bs(r,l.geom,s.layerId,u),C=u===void 0?s.strokeWidth:g??Gs(r,o,t)??s.strokeWidth,x=s.pointLayerId===null?null:bn(r,o,s.pointLayerId,u),j=s.pointLayerId===null?null:Cn(r,o,s.pointLayerId,u),y=x!==null&&x>0,S=b=>{e.commands.dispatch(new c.ToggleLinePointsCommand({layerId:s.layerId,showPoints:b,...h}))},P=b=>{e.commands.dispatch(new c.SetLineStyleCommand({layerId:s.layerId,showFill:b,drawnFillAlpha:s.drawnFillAlpha,...h}))},I=b=>{e.commands.dispatch(new c.SetLineStyleCommand({layerId:s.layerId,strokeWidth:b,...h}))},O=b=>{s.pointLayerId!==null&&e.commands.dispatch(new c.SetPointSizeCommand({layerId:s.pointLayerId,size:b,...h}))},w=b=>{s.pointLayerId!==null&&e.commands.dispatch(new c.SetPointSymbolCommand({layerId:s.pointLayerId,symbol:b,...h}))},A=b=>{e.commands.dispatch(new c.SetLineStyleCommand({layerId:s.layerId,lineStyle:b,...h}))},M=(0,c.readObservationsColorRoute)(r.spec,t)?.some(b=>b.geomKind==="line"||b.geomKind==="area")===!0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(K,{target:t}),(0,n.jsx)(dn,{widthPx:C,onChange:I}),M&&(0,n.jsx)(un,{lineStyle:zs(r,o,t),onChange:A}),s.showFill!==null&&(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,n.jsx)(i,{checked:m===!0,onChange:P})}),(0,n.jsx)(_,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,n.jsx)(i,{checked:y,onChange:S})}),y&&(0,n.jsx)(bt,{sizePx:x,onChange:O}),y&&(0,n.jsx)(yt,{symbol:j,coordType:r.coordSystem.type,onChange:w})]})},Bs=(e,t,r,o)=>{const a=(t==="line"?(0,c.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,c.buildLayerStyleAddress)("line",r),when:{where:o}},(0,c.readStyleCoord)(e.spec)):(0,c.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,c.buildLayerStyleAddress)("area",r),when:{where:o}},(0,c.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Gs=(e,t,r)=>{const o=(0,c.findLayerById)(e.layers,r.layerId),a=o===void 0?void 0:(0,c.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,c.resolveObservationsTarget)({layer:a,target:r,parsingLocale:e.config.parsingLocale}),l=i===void 0?void 0:a.data.getAt(i)??void 0,s=a.geom==="line"?t.geom.line(a).get("strokeWidth",l):t.geom.area(a).get("strokeWidth",l);return typeof s=="number"?s:null},Hs=(e,t,r)=>{const o=(0,c.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,c.buildLayerStyleAddress)("line",t),when:{where:r}},(0,c.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},Vs=(e,t)=>(0,c.readObservationsColorRoute)(e.spec,t)?.find(r=>r.geomKind==="line"||r.geomKind==="area")?.where,zs=(e,t,r)=>{const o=(0,c.findLayerById)(e.layers,r.layerId),a=o===void 0?void 0:(0,c.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,c.resolveObservationsTarget)({layer:a,target:r,parsingLocale:e.config.parsingLocale}),l=i===void 0?null:a.data.getAt(i);return(0,c.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",l??void 0):t.geom.area(a).get("dashArray",l??void 0))},Sn=(e,t)=>{const r=(0,c.findLayerById)(e.spec.layers,t);if(r===void 0)return null;const o=(0,c.findHostLayer)(r,e.spec.layers);return(0,c.isLayerSpecOf)(o,"line","area")?o:null},wn=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{fill:"currentColor",fillOpacity:".8",d:"M2.333 3h11.334v8.667c-2 0-4 .333-5.667 2.333-2-2-3.667-2.333-5.667-2.333z",opacity:".12"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M3.325 3.156a.836.836 0 0 0-.836.836v6.832c0 .462.375.836.836.836h2.131a.5.5 0 0 1 .352.145L8 13.975l2.193-2.17a.5.5 0 0 1 .352-.145h2.13a.84.84 0 0 0 .836-.836V3.992a.84.84 0 0 0-.836-.836zm-1.836.836c0-1.014.822-1.836 1.836-1.836h9.35c1.015 0 1.836.825 1.836 1.836v6.832a1.84 1.84 0 0 1-1.836 1.836H10.75l-2.398 2.374a.5.5 0 0 1-.704 0L5.25 12.66H3.325a1.836 1.836 0 0 1-1.836-1.836z",clipRule:"evenodd"}),(0,n.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M8 4.505a.5.5 0 0 1 .5.5v2.172h2.171a.5.5 0 0 1 0 1H8.5v2.171a.5.5 0 0 1-1 0V8.177H5.329a.5.5 0 0 1 0-1H7.5V5.005a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]}),Ws="_1aafi1g0",$s="_1aafi1g1",ir=({children:e})=>(0,n.jsxs)("span",{className:Ws,"aria-hidden":"true",children:[e,(0,n.jsx)("span",{className:$s})]}),tt=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 15 14",...e,children:(0,n.jsx)("path",{d:"M14.0146 5.20703C14.2118 5.40459 14.2121 5.72447 14.0146 5.92187L12.3291 7.6084C12.2343 7.70313 12.1047 7.75579 11.9707 7.75586C11.8369 7.75573 11.708 7.70291 11.6133 7.6084L9.92773 5.92187C9.73024 5.72438 9.73031 5.40457 9.92773 5.20703C10.1253 5.0095 10.445 5.0095 10.6426 5.20703L11.4658 6.03027L11.4658 1.68652L7.75586 1.68652L7.75586 12.6455C7.75563 12.9246 7.5291 13.1512 7.25 13.1514L2.5293 13.1514C2.2501 13.1514 2.02367 12.9247 2.02344 12.6455L2.02344 5.00781C0.868958 4.77348 0.000106647 3.7528 -1.10559e-07 2.5293C-4.95071e-08 1.13259 1.13261 9.74645e-05 2.5293 -5.23256e-07C3.92588 0.000220668 5.05859 1.13267 5.05859 2.5293C5.05849 3.75251 4.1892 4.77219 3.03516 5.00684L3.03516 12.1396L6.74414 12.1396L6.74414 1.18066C6.74414 0.901394 6.97076 0.674939 7.25 0.674804L11.9707 0.674805C12.2499 0.674939 12.4766 0.901394 12.4766 1.18066L12.4766 6.03027L13.2998 5.20703C13.4973 5.0095 13.8171 5.0095 14.0146 5.20703ZM4.04687 2.5293C4.04687 1.69137 3.36717 1.01194 2.5293 1.01172C1.69132 1.01182 1.01172 1.6913 1.01172 2.5293C1.01184 3.36719 1.6914 4.04678 2.5293 4.04687C3.36709 4.04665 4.04675 3.36712 4.04687 2.5293ZM14.5 11.2969C14.4998 12.6935 13.3673 13.8262 11.9707 13.8262C10.5742 13.826 9.4416 12.6934 9.44141 11.2969C9.44141 9.90018 10.574 8.7677 11.9707 8.76758C13.3675 8.76758 14.5 9.90011 14.5 11.2969ZM13.4883 11.2969C13.4883 10.4588 12.8088 9.7793 11.9707 9.7793C11.1327 9.77942 10.4531 10.4589 10.4531 11.2969C10.4533 12.1347 11.1329 12.8143 11.9707 12.8145C12.8086 12.8145 13.4881 12.1348 13.4883 11.2969Z",fill:"currentColor",fillOpacity:"0.8"})}),sr=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{d:"M5.01683 15.3331C4.84407 15.3343 4.67292 15.2997 4.51421 15.2314C4.3555 15.1632 4.21268 15.0627 4.09476 14.9365L3.88656 14.7283L3.62877 14.8968L3.19253 15.3331H0L2.24072 13.0923L2.03251 12.8445C1.89423 12.7191 1.78392 12.566 1.70875 12.3952C1.63359 12.2244 1.59526 12.0396 1.59626 11.853C1.59579 11.6818 1.63078 11.5124 1.69904 11.3554C1.76729 11.1984 1.86733 11.0573 1.99285 10.9409L11.2036 1.73012C11.3215 1.60384 11.4643 1.5034 11.623 1.43514C11.7817 1.36688 11.9529 1.33228 12.1257 1.33353C12.2969 1.33245 12.4665 1.36716 12.6236 1.43546C12.7807 1.50375 12.9218 1.60412 13.0378 1.73012L15.1496 3.92126C15.2748 4.03899 15.3745 4.1811 15.4427 4.33882C15.5108 4.49654 15.546 4.66655 15.546 4.83837C15.546 5.01019 15.5108 5.1802 15.4427 5.33792C15.3745 5.49564 15.2748 5.63774 15.1496 5.75548L5.93889 14.9662C5.81806 15.0866 5.67403 15.1812 5.51552 15.2443C5.35702 15.3074 5.18736 15.3376 5.01683 15.3331ZM2.48858 11.9125L5.01683 14.4407L9.47843 9.97913L6.95019 7.4608L2.48858 11.9125ZM7.68388 6.72712L10.2022 9.24544L14.644 4.80367L12.1257 2.28534L7.68388 6.72712Z",fill:"currentColor",fillOpacity:"0.8"})]}),Pn=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{opacity:"0.12",d:"M13.5948 4.29016C13.8724 6.22367 12.5301 8.01618 10.5966 8.29384C8.66309 8.57151 6.87058 7.22918 6.59292 5.29567C6.31525 3.36216 7.65758 1.56965 9.59109 1.29198C11.5246 1.01432 13.3171 2.35665 13.5948 4.29016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.71886 3.51052C6.25611 1.3626 8.43287 0.0568985 10.5808 0.594151C12.7287 1.1314 14.0344 3.30817 13.4972 5.45609C13.0316 7.31748 11.3347 8.54637 9.49237 8.49145L7.50898 12.492C7.46485 12.581 7.40179 12.6548 7.32702 12.7108C7.20005 12.8073 7.03703 12.8532 6.87248 12.8303C6.80957 12.822 6.74697 12.8038 6.68687 12.7749C6.39369 12.6342 6.26689 12.2915 6.3923 11.9963L7.63393 7.97371C6.10249 7.10872 5.27136 5.29962 5.71886 3.51052ZM10.2785 1.80253C8.79799 1.4322 7.29756 2.33222 6.92723 3.81277C6.55691 5.29332 7.45692 6.79375 8.93747 7.16408C10.418 7.5344 11.9185 6.63439 12.2888 5.15384C12.6591 3.67329 11.7591 2.17285 10.2785 1.80253Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{d:"M5.42977 11.1572C5.70072 11.104 5.8772 10.8411 5.82393 10.5702C5.77067 10.2992 5.50784 10.1227 5.23688 10.176C4.31848 10.3565 3.57421 10.6423 3.04695 11.0266C2.51409 11.4149 2.16666 11.936 2.16666 12.557C2.16666 13.0322 2.41215 13.4327 2.74425 13.7433C3.07553 14.0531 3.52776 14.3091 4.04484 14.5137C5.08193 14.9239 6.48048 15.1666 7.99999 15.1666C9.5195 15.1666 10.9181 14.9239 11.9551 14.5137C12.4722 14.3091 12.9244 14.0531 13.2557 13.7433C13.5878 13.4327 13.8333 13.0322 13.8333 12.557C13.8333 11.936 13.4859 11.4149 12.953 11.0266C12.4258 10.6423 11.6815 10.3565 10.7631 10.176C10.4921 10.1227 10.2293 10.2992 10.176 10.5702C10.1228 10.8411 10.2993 11.104 10.5702 11.1572C11.4079 11.3219 11.997 11.5672 12.364 11.8347C12.7255 12.0981 12.8333 12.3496 12.8333 12.557C12.8333 12.6643 12.7803 12.8187 12.5727 13.013C12.3642 13.2079 12.0354 13.4065 11.5873 13.5838C10.6941 13.9371 9.426 14.1666 7.99999 14.1666C6.57398 14.1666 5.30586 13.9371 4.41267 13.5838C3.9646 13.4065 3.63578 13.2079 3.4273 13.013C3.21964 12.8187 3.16666 12.6643 3.16666 12.557C3.16666 12.3496 3.2745 12.0981 3.63595 11.8347C4.00299 11.5672 4.59206 11.3219 5.42977 11.1572Z",fill:"currentColor",fillOpacity:"0.8"})]}),In=e=>(0,n.jsxs)(d.Icon,{viewBox:"0 0 16 16",...e,children:[(0,n.jsx)("path",{opacity:"0.12",d:"M1.33334 8.00016C1.33334 4.31826 4.31811 1.3335 8.00001 1.3335C11.6819 1.3335 14.6667 4.31826 14.6667 8.00016C14.6667 11.6821 11.6819 14.6668 8.00001 14.6668C4.31811 14.6668 1.33334 11.6821 1.33334 8.00016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{d:"M5.7328 9.69963C5.56696 9.47884 5.25352 9.43429 5.03273 9.60013C4.81193 9.76598 4.76739 10.0794 4.93323 10.3002C5.63175 11.2302 6.74548 11.8333 7.99993 11.8333C9.25438 11.8333 10.3681 11.2302 11.0666 10.3002C11.2325 10.0794 11.1879 9.76598 10.9671 9.60013C10.7463 9.43429 10.4329 9.47884 10.2671 9.69963C9.74929 10.3889 8.92657 10.8333 7.99993 10.8333C7.07329 10.8333 6.25057 10.3889 5.7328 9.69963Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{d:"M6.66668 6.66658C6.66668 7.03478 6.3682 7.33325 6.00001 7.33325C5.63182 7.33325 5.33334 7.03478 5.33334 6.66658C5.33334 6.29839 5.63182 5.99992 6.00001 5.99992C6.3682 5.99992 6.66668 6.29839 6.66668 6.66658Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{d:"M10 7.33325C10.3682 7.33325 10.6667 7.03478 10.6667 6.66658C10.6667 6.29839 10.3682 5.99992 10 5.99992C9.63182 5.99992 9.33334 6.29839 9.33334 6.66658C9.33334 7.03478 9.63182 7.33325 10 7.33325Z",fill:"currentColor",fillOpacity:"0.8"}),(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00001 0.833252C4.04197 0.833252 0.833344 4.04188 0.833344 7.99992C0.833344 11.958 4.04197 15.1666 8.00001 15.1666C11.9581 15.1666 15.1667 11.958 15.1667 7.99992C15.1667 4.04188 11.9581 0.833252 8.00001 0.833252ZM14.1667 7.99992C14.1667 11.4057 11.4058 14.1666 8.00001 14.1666C4.59425 14.1666 1.83334 11.4057 1.83334 7.99992C1.83334 4.59416 4.59425 1.83325 8.00001 1.83325C11.4058 1.83325 14.1667 4.59416 14.1667 7.99992Z",fill:"currentColor",fillOpacity:"0.8"})]}),Us=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,c.hasMultipleGroups)(e.data,e.mapping))return t;const r=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:r?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Tn=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,c.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},On=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,c.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},qs=()=>[{scope:"group",labelKey:"pieSlice"}];function Ks(e,t){if(e.type==="polar"&&!Zs(t))return qs();switch(t.geom){case"bar":return Us(t);case"line":case"area":return Tn(t);case"point":return On(t);default:return[]}}var Zs=e=>{const t=(0,c.readVariableName)(e.mapping.x);return t!==null&&t!==c.CONSTANT_VARIABLES.x},Ys=(e,t,r,o)=>{const a=[],i=Xs(e,t,r,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const l=Js(e,t,r,o);return l!==null&&a.push({id:"onward",categoryLabel:l.label,predicate:l.predicate}),a},kn=(e,t,r)=>{const o=t.find(a=>Ve(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:r!==null&&Ve(e.predicate,r)?"observation":null},Xs=(e,t,r,o)=>{const a=(0,c.readVariableName)(e.mapping.y),i=(0,c.readVariableName)(e.mapping.x);if(a===null||i===null||i===c.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const l=An(t,a);return l===null||!rl(e,a,l)?null:{variable:a,value:l,label:Mn(e,a,l,r,o)}},Js=(e,t,r,o)=>{const a=(0,c.readVariableName)(e.mapping.x);if(a===null||a===c.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const l=Qs(e,t);if(l===null)return null;const s=el(e,a,l),u=s.findIndex(m=>ye(m)===ye(i));if(u<0||u>=s.length-1)return null;const h={variable:a,oneOf:s.slice(u)},p=l.length===0?h:{and:[h,...l]};return{label:Mn(e,a,i,r,o),predicate:p}},Qs=(e,t)=>{const r=[];for(const o of(0,c.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;r.push({variable:o,eq:a})}return r},el=(e,t,r)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!tl(i,r))continue;const l=i[t]??null;if(l===null)continue;const s=i[c.POSITION_VARIABLES.x],u=typeof s=="number"?s:a,h=ye(l),p=o.get(h);(p===void 0||u<p.position)&&o.set(h,{value:l,position:u})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},tl=(e,t)=>t.every(r=>ye(e[r.variable]??null)===ye(r.eq)),rl=(e,t,r)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=An(a,t);if(i!==null&&i>r)return!0}return!1},An=(e,t)=>{const r=e[c.POSITION_VARIABLES.yRaw],o=typeof r=="number"?r:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Mn=(e,t,r,o,a)=>{const i=(0,c.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(r);return i.length>0?i:String(r)},ye=e=>e instanceof Date?String(e.getTime()):String(e),Ve=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&lr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&lr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Ve(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&ce(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&cr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&ce(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&ce(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&ce(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&ce(e.gte,t.gte):"range"in e&&"range"in t&&cr(e.range,t.range),lr=(e,t)=>e.length===t.length&&e.every((r,o)=>{const a=t[o];return a!==void 0&&Ve(r,a)}),cr=(e,t)=>e.length===t.length&&e.every((r,o)=>{const a=t[o];return a!==void 0&&ce(r,a)}),ce=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,nl=(e,t)=>{const r=d.useSceneSelector(a=>a.spec.highlights),o=d.useSceneSelector(a=>a.config.parsingLocale);return(0,f.useMemo)(()=>(0,c.findHighlightsAtObservation)({layer:e,highlights:r,observation:t,parsingLocale:o}),[e,r,t,o])},ol={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},al=e=>(0,c.isObservationAttachmentKind)(e.kind)&&ol[e.kind],St=(e,t)=>{const{offsetWidth:r}=e;return r<=0||t<=0?1:t/r},Ln=e=>St(e,e.getBoundingClientRect().width),Rn=(e,t)=>{const{offsetWidth:r,offsetHeight:o}=e;return r<=0||o<=0?t:{width:r,height:o}},oe=(e,t)=>t>0?e/t:0,_n=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?c.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(t.width-e.x)/e.width),maxY:Math.max(1,(t.height-e.y)/e.height)},il=(e,t)=>({minX:Math.min(e.minX,t.x),minY:Math.min(e.minY,t.y),maxX:Math.max(e.maxX,t.x),maxY:Math.max(e.maxY,t.y)}),sl=(e,t)=>{const r=t.getBoundingClientRect(),o=Rn(t,r),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:r;return _n(e,a)},ll=e=>e.anchorType!=="panel",ke=(e,t)=>{const{x:r,y:o}=(0,c.projectAnchorToPanel)(e,t);return{anchorType:"panel",x:oe(r,t.width),y:oe(o,t.height)}},dr=(e,t)=>{const r=(0,c.projectRegionToPanel)(e,t);return{anchorType:"panel",x:oe(r.x,t.width),y:oe(r.y,t.height),width:oe(r.width,t.width),height:oe(r.height,t.height)}},Nn=(0,f.createContext)(e=>new c.RemoveAnnotationCommand({id:e})),cl=(e,t,r,o)=>{const a=s=>s.anchorType==="annotation"&&s.ref===e,i=[];for(const s of t.textAnnotations){if(!a(s.at))continue;const u=r.textAnnotations.find(h=>h.id===s.id);u!==void 0&&i.push(new c.UpdateAnnotationCommand({kind:"text",id:s.id,patch:{at:ke(u.at,o)}}))}for(const s of t.stickers){if(!a(s.at))continue;const u=r.stickers.find(h=>h.id===s.id);u!==void 0&&i.push(new c.UpdateAnnotationCommand({kind:"sticker",id:s.id,patch:{at:ke(u.at,o)}}))}for(const s of t.arrows){const u=a(s.start),h=a(s.end);if(!u&&!h)continue;const p=r.arrows.find(g=>g.id===s.id);if(p===void 0)continue;const m={...u?{start:ke(p.start,o)}:{},...h?{end:ke(p.end,o)}:{}};i.push(new c.UpdateAnnotationCommand({kind:"arrow",id:s.id,patch:m}))}for(const s of t.shapes){if(!a(s.region))continue;const u=r.shapes.find(h=>h.id===s.id);u!==void 0&&i.push(new c.UpdateAnnotationCommand({kind:"shape",id:s.id,patch:{region:dr(u.region,o)}}))}for(const s of t.images){if(!a(s.region))continue;const u=r.images.find(h=>h.id===s.id);u!==void 0&&i.push(new c.UpdateAnnotationCommand({kind:"image",id:s.id,patch:{region:dr(u.region,o)}}))}const l=new c.RemoveAnnotationCommand({id:e});return i.length===0?l:new c.SequenceCommand({commands:[...i,l]},{description:l.metadata.description})},En=e=>{const t=d.useLatestRef({spec:d.useSceneSelector(r=>r.spec.annotations),scene:d.useResolvedAnnotations(e),panelRect:e});return(0,f.useCallback)(r=>{const o=t.current;return cl(r,o.spec,o.scene,o.panelRect)},[t])},Fn=e=>{const{commands:t}=d.useGraphContext(),r=En(e);return(0,f.useCallback)(o=>t.dispatch(r(o)),[t,r])},dl=()=>(0,f.useContext)(Nn),wt=()=>{const e=d.useEditorStore(),{selectionStore:t}=d.useGraphContext();return(0,f.useCallback)((r,o)=>{t.getState().clearSelection();const a=e.getState();a.setPlotMenu(null),a.claimInteraction({kind:"arrow-draw",heads:"end",...r,pointer:d.readClickPoint(o)})},[e,t])},Dn=(e,t)=>(0,f.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:r,numberFormat:o}=e.config,a=t??r,i=e.guides.colorGroups.map(l=>{const s=(0,c.createValueFormatter)({valueFormat:l.valueFormat,locale:a,numberFormat:o}),u=l.value instanceof Date?l.value.getTime():l.value;return{value:u,option:{value:String(u),label:l.label??s(l.value)}}});return{options:i.map(({option:l})=>l),findValue:l=>i.find(s=>s.option.value===l)?.value}},[e,t]),Bn=({scene:e,layer:t,observation:r,groupOptions:o,locale:a,t:i})=>{const l=ut(e,t,r,o);return{observation:i(pl(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Gn(e,t,r,a)}),group:l===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:l})}},dt=({scene:e,layer:t,observation:r,groupOptions:o,locale:a,t:i},l)=>{const s=(0,c.getGroupVariables)(t.data,t.mapping),u=Gn(e,t,r,a);switch(l){case"observation":{const h=s.length===0?null:ut(e,t,r,o),p=ul(h,u,i);return{whole:p,value:p}}case"xValue":return ur((0,c.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=ut(e,t,r,o)??i("editor.overlayMenu.all");return ur(hl(e,s),h,i)}default:return l}},ul=(e,t,r)=>e===null?t:t===""?e:r("editor.overlayMenu.groupAtBand",{group:e,band:t}),ur=(e,t,r)=>({whole:e===null||e===""?t:r("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),hl=(e,t)=>{const[r,...o]=t;return r===void 0||o.length>0?null:e.guides.variableLabels[r]??null},pl=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,c.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Gn=(e,t,r,o)=>{const a=(0,c.findAxisGuide)(e.guides,"x");return(0,c.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,c.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,c.createXValueReader)(t.data,t.mapping)(r),r)},ut=(e,t,r,o)=>{const a=(0,c.getGroupVariables)(t.data,t.mapping);return a.length===0?ml(t,r)??gl(e,t):a.map(i=>vl(r[i]??null,o)).join(", ")},ml=(e,t)=>{const r=(0,c.readColorPart)(e,t);return r===void 0?void 0:e.styles.parts[r]?.label},gl=(e,t)=>{const r=(0,c.readVariableName)(t.mapping.y),o=r===null?void 0:e.guides.variableLabels[r];return o===void 0||o===""?null:o},vl=(e,t)=>{const r=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===r)?.label??r},Hn="vez73g0",ze="vez73g1",Vn="vez73g2",fl="vez73g3",zn="vez73g4";var xl="vez73g6",yl="vez73g7",bl="vez73g8",Wn="vez73g9",$n="vez73ga",Un=[Vn,xl,zn,fl],Cl=Un.map(e=>`.${e}`).join(", "),jl=Un.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),qn=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const r=e.currentTarget,o=t.closest(`.${ze}, ${Cl}`),a=t.closest(`.${ze}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],l=i.indexOf(t);if(l<0)return;e.preventDefault();const s=getComputedStyle(o).direction==="rtl";i[(l+(e.key==="ArrowRight"?1:-1)*(s?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=r.querySelector(jl);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),r.querySelector('[aria-expanded="true"]')?.focus())},Pt={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Kn=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 24 24",...e,children:(0,n.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Pt})}),Sl=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 24 24",...e,children:(0,n.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Pt})}),wl=e=>(0,n.jsx)(d.Icon,{viewBox:"0 0 24 24",...e,children:(0,n.jsx)("path",{d:"M5 19L19 5",...Pt})}),Y={side:"top",delay:200},Zn={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Pn},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:wn},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:In}},Yn=new Set(["barSeries","lineSeries","scatterSeries"]),Pl=new Set(["bar","linePoint","scatterPoint","pieSlice"]),It=e=>{const t=({target:r})=>{const o=Sr(r);return o===null?null:(0,n.jsx)(Tl,{anchor:o,readHighlightOptions:e})};return t.hasRows=(r,{scene:o})=>jr(r,o)!==null,t},_e=It((e,t)=>Ks(t,e)),hr=It(Tn),Il=It(On),Tl=({anchor:e,readHighlightOptions:t})=>{const{layer:r,observation:o,observationIndex:a,at:i}=e,l=wt(),s=d.useI18n(),{dispatch:u,paintPreview:h,clearPreview:p}=d.useGraphCommands(),{selectionStore:m,findGeom:g}=d.useGraphContext(),C=dl(),x=(0,f.useRef)(null),j=(0,f.useRef)(p);j.current=p;const{Button:y}=D(),S=d.useSceneSelector(T=>T),P=S.spec.annotations,I=S.config.parsingLocale,O=S.config.numberFormat,w=d.useFormattingLocale(),A={scene:S,layer:r,observation:o,groupOptions:Dn(S,w),locale:w,t:s},M=dt(A,"xValue").value,b=dt(A,"group").value,R=Bn(A).observation,V=(0,f.useMemo)(()=>(0,c.createObservationAnchorParser)(r,I),[r,I]),$=(0,c.findObservationAttachment)(P,i,V,(0,f.useMemo)(()=>(0,c.createObservationAnchorLander)({layers:S.layers,coordSystem:S.coordSystem,findGeom:g,readAnchor:V}),[S.layers,S.coordSystem,g,V])),N=$!==null&&al($)?$:null,L=x.current,v=N!==null&&L?.key.startsWith("sticker:")===!0&&N.kind==="sticker"?null:N,k=v?.kind==="comment"?v.annotation.content:null,B=k===null?"":Hl(k)??void 0,[G,Ze]=(0,f.useState)(()=>Bl(N?.kind)),pe=nl(r,o),z=S.coordSystem,J=t(r,z),me=J.length===0?[]:Ys(r,o,w,O),ge=x.current?.heldHighlight,ne=ge===void 0?pe:[...pe,ge],Z=(0,f.useMemo)(()=>(0,c.inferDifferenceArrowEndpoints)({layer:r,at:i,coordSystem:z}),[r,i,z]),je=Nl({layer:r,observation:o,highlights:ne,highlightOptions:J,reaches:me,previewedChoiceId:x.current?.choiceId,scopeLabel:T=>Fl(s,T,M,b,R),scopeDescription:T=>Dl(s,T,pr(s,r,J),M,b,J.some(F=>Yn.has(F.labelKey))),atLeastLabel:T=>s("graph.annotations.highlights.atLeast",{value:T}),atLeastDescription:T=>s("graph.annotations.highlights.atLeastDescription",{noun:pr(s,r,J),value:T}),onwardLabel:T=>s("graph.annotations.highlights.onward",{label:T}),onwardDescription:T=>s("graph.annotations.highlights.onwardDescription",{label:T})}),Po=(0,c.buildObservationPredicate)(r,o),Io=new Set(je?.available.map(T=>T.id)??[]),Et=pe.filter(T=>{const F=kn(T,me,Po);return F===null||!Io.has(F)}).at(-1),Q=()=>{x.current!==null&&(x.current=null,j.current())};(0,f.useEffect)(()=>()=>Q(),[]);const Ft=(T,F,ee,ve)=>{x.current?.key!==T&&(Q(),x.current={key:T,choiceId:ee,heldHighlight:ve},h(F)||(x.current=null))},ie=T=>{Q(),u(T),m.getState().clearSelection()},Dt=(T,F)=>{if(x.current?.key===T){x.current=null,j.current(),u(F),m.getState().clearSelection();return}ie(F)},To=(T,F,ee,ve)=>({onPointerEnter:()=>Ft(T,F,ee,ve),onPointerLeave:Q,onClick:()=>Dt(T,F)}),Se=T=>{Q(),Ze(F=>F===T?null:T)},Bt=T=>{if(Z===null)return;Q();const F=(0,c.areAnchorsEqual)(Z.start,i)?Z.end:Z.start,ee=new c.AddAnnotationCommand({kind:"differenceArrow",annotation:{...c.DIFFERENCE_ARROW_DEFAULTS,start:i,end:F,label:T}});u(ee),m.getState().setSelection([{kind:"annotation",id:ee.params.annotation.id}])};return(0,n.jsxs)("div",{className:Hn,role:"toolbar","aria-label":s("graph.annotations.baseMenu.annotate"),onKeyDown:T=>{if(v!==null&&Gl(T)){ie(C(v.annotation.id));return}qn(T)},children:[(0,n.jsxs)("div",{className:ze,children:[je!==null&&(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.highlight"),icon:(0,n.jsx)(sr,{}),expanded:G==="highlight",onClick:()=>Se("highlight")}),Et!==void 0&&(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.removeHighlight"),icon:(0,n.jsx)(ir,{children:(0,n.jsx)(sr,{})}),onClick:()=>ie(new c.RemoveHighlightCommand({id:Et.id}))}),v!==null&&(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s(Zn[v.kind].phrase),icon:(0,n.jsx)(ir,{children:Ol(v.kind)}),onClick:()=>ie(C(v.annotation.id))}),v===null&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.pinNumber"),icon:(0,n.jsx)(Pn,{}),onClick:()=>ie(new c.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:i}}))}),(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.addNote"),icon:(0,n.jsx)(wn,{}),expanded:G==="comment",onClick:()=>Se("comment")})]}),Z!==null&&(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.differenceArrow"),icon:(0,n.jsx)(tt,{}),expanded:G==="difference",onClick:()=>Se("difference")}),(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.arrowFromHere"),icon:(0,n.jsx)(Kn,{}),onClick:(...T)=>{Q(),l({start:{...i,anchorType:"observation",align:"auto"},startObservationIndex:a},T[0])}}),v===null&&(0,n.jsx)(y,{variant:"icon",...Y,ariaLabel:s("graph.annotations.baseMenu.addSticker"),icon:(0,n.jsx)(In,{}),expanded:G==="sticker",onClick:()=>Se("sticker")})]}),G==="comment"&&B!==void 0&&(0,n.jsx)("div",{className:"vez73g6",children:(0,n.jsx)(kl,{at:i,onRun:ie,annotationId:v?.kind==="comment"?v.annotation.id:void 0,initialText:B})}),G==="sticker"&&(0,n.jsx)("div",{className:"vez73g2",children:(0,n.jsx)(Al,{at:i,showPreview:Ft,dropPreview:Q,keepPreview:Dt,annotationId:v?.kind==="sticker"?v.annotation.id:void 0})}),G==="difference"&&(0,n.jsxs)("div",{className:"vez73g4",children:[(0,n.jsx)(y,{variant:"icon",ariaLabel:s("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tt,{size:"sm"}),(0,n.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Bt("relativeDifference")}),(0,n.jsx)(y,{variant:"icon",ariaLabel:s("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tt,{size:"sm"}),(0,n.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Bt("absoluteDifference")})]}),G==="highlight"&&je!==null&&(0,n.jsx)("div",{className:"vez73g3",children:je.available.map(T=>{const F=T.appliedHighlightId,ee=F===void 0?Rl(T,r.id):new c.RemoveHighlightCommand({id:F}),ve=F===void 0?void 0:ne.find(Oo=>Oo.id===F);return(0,n.jsx)(y,{label:T.label,pressed:F!==void 0,tooltip:T.description===T.label?void 0:T.description,...Y,...To(Ml(T.id),ee,F===void 0?T.id:void 0,ve)},T.id)})})]})},Ol=e=>{const t=Zn[e].Icon;return(0,n.jsx)(t,{})},kl=({at:e,onRun:t,annotationId:r,initialText:o=""})=>{const a=d.useI18n(),{Button:i,TextField:l}=D(),[s,u]=(0,f.useState)(o),h=(0,f.useRef)(null),p=s.trim();(0,f.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=Vl(p);t(r===void 0?new c.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new c.UpdateAnnotationCommand({kind:"comment",id:r,patch:{content:g}}))};return(0,n.jsxs)("form",{ref:h,className:yl,onSubmit:g=>{g.preventDefault(),m()},children:[(0,n.jsx)("div",{className:bl,children:(0,n.jsx)(l,{value:s,onChange:u,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,n.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},Al=({at:e,showPreview:t,dropPreview:r,keepPreview:o,annotationId:a})=>{const i=d.useStickerImages();return i===null?null:(0,n.jsx)(n.Fragment,{children:Object.entries(i).map(([l,s])=>{const u=_l(e,l,a);return(0,n.jsx)("button",{type:"button",className:$n,"aria-label":l,onPointerEnter:()=>t(u.key,u.command),onPointerLeave:r,onClick:()=>o(u.key,u.command),children:(0,n.jsx)("img",{className:Wn,src:s,alt:""})},l)})})},Ml=e=>`highlight:${e}`,Ll=e=>`sticker:${e}`,Rl=(e,t)=>new c.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),_l=(e,t,r)=>r===void 0?{key:Ll(t),command:new c.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new c.UpdateAnnotationCommand({kind:"sticker",id:r,patch:{sticker:t}})},Nl=({layer:e,observation:t,highlights:r,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:l,scopeDescription:s,atLeastLabel:u,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,c.buildObservationPredicate)(e,t),C=new Map;for(const I of r){const O=kn(I,a,g);O===null||O===i||C.set(O,I.id)}const x=g===null?[]:o.map(I=>{const O=l(I.labelKey);return{id:I.scope,label:O,description:s(I.labelKey),icon:I.labelKey,predicate:g,scope:I.scope,appliedHighlightId:C.get(I.scope)}}),j=a.map(I=>({...El(I,u,h,p,m),appliedHighlightId:C.get(I.id)})),[y,...S]=x,P=y===void 0?j:[y,...j,...S];return P.length===0?null:{available:P}},El=(e,t,r,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:r(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:o(e.categoryLabel),description:a(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},Fl=(e,t,r,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Pl.has(t))return a;if(t==="barGroup"||t==="barStack")return r===""?i:e("editor.overlayMenu.allOf",{name:r});if(!Yn.has(t))return i;const l=e("editor.overlayMenu.all");return o===""||o===l?i:e("editor.overlayMenu.allOf",{name:o})},pr=(e,t,r)=>{if(t.geom==="point"&&(0,c.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=r.find(a=>a.scope==="observation")??r[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},Dl=(e,t,r,o,a,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&o!==""?e("graph.annotations.highlights.justValue",{label:o}):e("graph.annotations.highlights.justThis",{noun:r});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:r,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:r,name:o});case"barSeries":case"lineSeries":case"scatterSeries":return a===""||a===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:a,noun:r});default:return t}},Bl=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Gl=e=>{if(e.key!=="Delete"&&e.key!=="Backspace")return!1;const t=e.target;return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?!1:(e.preventDefault(),!0)},Hl=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||mr(t)||gr(t)||t.content?.length!==1)return null;const r=t.content[0];return r?.type!=="text"||r.text===void 0||r.content!==void 0||mr(r)||gr(r)?null:r.text},mr=e=>e.marks!==void 0&&e.marks.length>0,gr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Vl=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Tt=({target:e})=>{const t=d.useGraphHandle();return t===null?null:(0,n.jsx)(zl,{graph:t,target:e})};Tt.hasRows=(e,t)=>(0,c.isLayerSpecOf)((0,c.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:K.hasRows(e,t);var zl=({graph:e,target:t})=>{const r=d.useHandleScene(e),o=d.useStyleReaderTree(),a=r===null?void 0:(0,c.findLayerById)(r.spec.layers,t.layerId);if(r===null||!(0,c.isLayerSpecOf)(a,"point"))return(0,n.jsx)(K,{target:t});const i=(0,c.readObservationsColorRoute)(r.spec,t)?.find(u=>u.geomKind==="point")?.where,l=i===void 0?{}:{where:i},s=(0,c.readVariableName)((0,c.findLayerById)(r.layers,a.id)?.mapping.size)!==null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(K,{target:t}),!s&&(0,n.jsx)(bt,{sizePx:bn(r,o,a.id,i),onChange:u=>{e.commands.dispatch(new c.SetPointSizeCommand({layerId:a.id,size:u,...l}))}}),(0,n.jsx)(yt,{symbol:Cn(r,o,a.id,i),coordType:r.coordSystem.type,onChange:u=>{e.commands.dispatch(new c.SetPointSymbolCommand({layerId:a.id,symbol:u,...l}))}})]})},Xn={geoms:{point:{style:Tt,annotate:Il},line:{style:He,annotate:hr},area:{style:He,annotate:hr},bar:{style:ft,annotate:_e},rule:{style:null,annotate:_e},tile:{style:K,annotate:_e}},legend:yn,axis:vt,grid:jt,graph:Ct},Ot=(0,f.createContext)([Xn]),Wl=({editMenus:e,children:t})=>{const r=(0,f.useMemo)(()=>[e??{},Xn],[e]);return(0,n.jsx)(Ot.Provider,{value:r,children:t})},$l=e=>{const t=(0,f.useContext)(Ot),r=d.useSceneSelector(l=>l),{findGeom:o}=d.useGraphContext(),a=d.useDataLabelPlacementResolver(),i=Jn(d.useGraphMode());return(0,f.useMemo)(()=>e===null?null:Qn(e,t,{scene:r,dataLabelPlacement:a,findGeom:o},i),[e,t,r,a,o,i])},Ul=()=>{const e=(0,f.useContext)(Ot),{store:t,findGeom:r}=d.useGraphContext(),o=d.useDataLabelPlacementResolver(),a=Jn(d.useGraphMode());return(0,f.useCallback)(i=>Qn(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:r},a)!==null,[e,t,o,r,a])},Jn=e=>e===d.GRAPH_MODES.annotate?"annotate":"style",Qn=(e,t,r,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=As(e.layerId,r.scene),i=a===null?null:Ms(a,t,o,o==="annotate"?_e:K);return i===null||i.hasRows?.(e,r)===!1?null:(0,n.jsx)(i,{target:e})}case"legend":{const a=Oe(t,i=>i.legend);return a===null||a.hasRows?.(e,r)===!1?null:(0,n.jsx)(a,{target:e})}case"axis":{const a=Oe(t,i=>i.axis);return a===null||a.hasRows?.(e,r)===!1?null:(0,n.jsx)(a,{target:e})}case"grid":{const a=Oe(t,i=>i.grid);return a===null||a.hasRows?.(e,r)===!1?null:(0,n.jsx)(a,{target:e})}case"graph":{const a=Oe(t,i=>i.graph);return a===null||a.hasRows?.(e,r)===!1?null:(0,n.jsx)(a,{target:e})}default:return e}},ql="kwvn4c0",Kl="kwvn4c1",Zl=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const r=e.getBoundingClientRect(),o=St(e,r.width);return new DOMRect(r.left+t.x*o,r.top+t.y*o,t.width*o,t.height*o)}}),Yl=({side:e,boundary:t,spans:r,anchor:o,rightToLeft:a})=>{if(!Jl(e))return 0;const i=r[e];if(e==="left"||e==="right")return vr(i.from-t.y,o.height,t.height);const l=a?t.x+t.width-i.to:i.from-t.x;return vr(l,o.width,t.width)},Xl=()=>{const[e,t]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{t(!0)},[]),e},Jl=e=>d.SIDE_KEYS.some(t=>t===e),vr=(e,t,r)=>r===0?0:e*t/r,eo={x:8,y:8},to=(0,f.createContext)("bottom"),Ql={side:"flip",align:"shift",fallbackAxisSide:"end"},ec="start",tc={right:Ql,bottom:{side:"flip",align:"shift",fallbackAxisSide:"none"}},rc=()=>(0,f.useContext)(to),ro=({frameElement:e,boundary:t,side:r="right",align:o,spans:a,clearance:i=eo,takesFocus:l=!0,onEscape:s,children:u})=>{const h=$e(),p=Xl(),[m,g]=(0,f.useState)(null),C=(0,f.useRef)(null),x=(0,f.useCallback)(b=>{C.current=b,g(b)},[]),j=(0,f.useRef)(null);(0,f.useLayoutEffect)(()=>()=>{m?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[m,e]);const{x:y,y:S,width:P,height:I}=t,O=(0,f.useMemo)(()=>({box:{x:y,y:S,width:P,height:I},spans:a}),[y,S,P,I,a]),w=(0,f.useMemo)(()=>Zl(e,O.box),[e,O]),A=(b,R)=>{b||(R.cancel(),R.reason==="escape-key"&&s())},M=l?mt:void 0;return(0,n.jsx)(E.Popover.Root,{open:p,modal:!1,onOpenChange:A,children:(0,n.jsx)(E.Popover.Portal,{container:h,className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(E.Popover.Positioner,{ref:j,anchor:w,side:r,align:o??ec,sideOffset:({side:b})=>b==="top"||b==="bottom"?i.y:i.x,alignOffset:({side:b,anchor:R})=>O.spans===void 0?0:Yl({side:b,boundary:O.box,spans:O.spans,anchor:R,rightToLeft:nc(j.current)}),collisionAvoidance:tc[r],sticky:!0,className:ql,...M,children:(0,n.jsx)(E.Popover.Popup,{ref:x,className:Kl,initialFocus:l?C:!1,finalFocus:!1,"data-testid":"anchored-popover",render:(b,R)=>(0,n.jsx)("div",{...b,children:(0,n.jsx)(to.Provider,{value:R.side,children:b.children})}),children:u})})})})})},nc=e=>e!==null&&getComputedStyle(e).direction==="rtl",oc=2,ac=()=>{const e=d.useI18n(),t=d.useStyleReaderTree(),r=d.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:l,minWidth:s,paddingInline:u,pickedFontSize:h=null,pickedFont:p=null})=>{if(l<=0)return s;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),C=h===null?m.fontSize:h*g,x=d.resolveRichTextFontFamily(p)??m.fontFamily,j=(r.measureText(e("graph.annotations.text.placeholder"),(0,c.toFontSpec)({...m,fontSize:C,fontFamily:x},d.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+oc)/l;return Math.max(s,Math.min(j,ic(a,(0,c.alignUnitFractions)(i).x)))}},ic=(e,t)=>{const r=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(r,o)},no=()=>{const e=d.useI18n();return(0,f.useMemo)(()=>({...Object.fromEntries(ao.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[d.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[d.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},oo=()=>{const e=d.useSceneSelector(t=>t.scales.color);return(0,f.useMemo)(()=>!e||e.kind!=="visual"?[]:[...new Set(e.palette)],[e])},sc=e=>e!=="canvasDefault"&&e!=="canvasInverse",ao=[{color:"#000000",phrase:"canvasBlack"},...d.CANVAS_COLOR_KEYS.filter(sc).map(e=>({color:d.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],kt=ao.map(e=>e.color),io=(e,t)=>{const{config:r,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=r.legend,i=a==="none";return{hidden:i,hide:new c.SetLegendPositionCommand({position:"none"}),show:new c.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(l=>l.scaledAesthetic==="ySecondary")?.visible:r.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new c.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new c.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=r.axes[a].grid,l=i===!1;return{hidden:l,hide:new c.SetGridVisibilityCommand({axis:a,visible:!1}),show:new c.SetGridVisibilityCommand({axis:a,visible:l?!0:i})}}case"observations":case"graph":return null;default:return e}},so=()=>{const e=Ul(),{store:t}=d.useGraphContext();return(0,f.useCallback)(r=>e(r)||io(r,t.getState().scene)!==null,[e,t])},lo=(e,t)=>e.geom==="boxplot"&&(0,c.getScaledAesthetic)(t,"outlier")!==null,lc=()=>{const e=d.useGraphSelection();return We(e)},We=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},co=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M7 17 17 7"}),(0,n.jsx)("path",{d:"M7 7h10v10"})]})}),cc=e=>(0,n.jsx)(d.Icon,{...e,children:(0,n.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M4 7h16"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,n.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),uo={kind:"chrome-popup"},dc="center",be="textStyle",ho=new Set(["paragraph","heading"]),uc=e=>fo(mo(e)?.fontSize)??null,hc=e=>go(mo(e))??null,pc=e=>{const t=vo(e),r=fc(e);return{color:Ae(t.map(o=>xc(rt(o)?.color))),font:Ae(t.map(o=>go(rt(o)))),fontSize:Ae(t.map(o=>fo(rt(o)?.fontSize))),alignment:Ae(r.map(o=>yc(o.attrs?.textAlign)))}},mc=(e,t)=>At(e,r=>r.type==="text"?vc(r,t):r),po=e=>vo(e).length>0,gc=(e,t)=>At(e,r=>ho.has(r.type??"")?{...r,attrs:{...r.attrs,textAlign:t}}:r),mo=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===be)?.attrs},At=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(r=>At(r,t))}),vc=(e,t)=>{const r=e.marks??[],o=r.find(i=>i.type===be),a={type:be,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...r,a]:r.map(i=>i===o?a:i)}},rt=e=>e.marks?.find(t=>t.type===be)?.attrs,go=e=>d.readRichTextFontId(e?.font)??d.readRichTextFontId(e?.fontFamily),vo=e=>Mt(e,t=>t.type==="text"),fc=e=>Mt(e,t=>ho.has(t.type??"")),Mt=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(r=>Mt(r,t))],Ae=e=>{const[t,...r]=e;return t===void 0?null:r.every(o=>o===t)?t:null},xc=e=>typeof e=="string"&&e.length>0?e:void 0,fo=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,yc=e=>e==="left"||e==="center"||e==="right"?e:void 0,xo=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),yo=(e,t,r,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const s=t.textAnnotations.find(u=>u.id===a.annotationId);if(s===void 0||po(s.content))return}const l=a.placementCommandId;l!==null&&o!==null&&o.readTopCommandId()===l&&o.undo()||r(a.annotationId)},bc=(e,t,r)=>{const o=[];for(let a=e.layers.length-1;a>=0;a-=1){const i=e.layers[a];i===void 0||!i.interactive||i.attachment!==null||o.push(...Cc(i,e,t,r))}return o},fr=(e,t)=>{if(t===null)return-1;const r=(0,c.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===r)},Cc=(e,t,r,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const l=e.data.getAt(i);if(l===null||lo(e,l))continue;const s=(0,c.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(s===null||!o(s))continue;const u=r.resolve(e.geom,l,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(u===null)continue;const h=jc(l,t.coordSystem,u);a.push({x:u.x,target:s,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:l,x:h.x,y:h.y}})}return a.sort((i,l)=>i.x-l.x),a},jc=(e,t,r)=>{if(t.type!=="polar")return r;const o=e[c.POSITION_VARIABLES.x],a=e[c.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?r:{x:o,y:a}},Sc=(e,t)=>{const{selectionStore:r,chartId:o,history:a,store:i,anchorResolver:l}=d.useGraphContext(),{store:s,engine:u,overlayRef:h}=d.useHoverContext(),p=so(),m=d.useEditorStore(),g=d.useLatestRef(d.useSceneSelector(M=>M.spec.annotations.textAnnotations)),C=(0,f.useRef)(null),x=(0,f.useRef)(null),j=(0,f.useRef)(!0),y=(0,f.useRef)(new WeakSet),{showAnnotations:S,showMenuTriggerOnHover:P}=d.MODE_RULES[d.useGraphMode()],I=Fn(t),O=(0,f.useCallback)(M=>{const{selection:b}=r.getState(),R=S?We(b):null;R!==null&&(M.preventDefault(),I(R),e.focus({preventScroll:!0}))},[e,I,r,S]),w=(0,f.useCallback)(M=>{if(xe(M.target,o))return;const b=S?We(r.getState().selection):null;b!==null&&g.current.some(R=>R.id===b)&&(M.preventDefault(),m.getState().setCaret(b))},[m,r,g,o,S]),A=(0,f.useCallback)(M=>{const b=m.getState(),R=b.standingInteraction?.kind;if(R!==void 0){R!=="chrome-popup"&&R!=="arrow-draw"&&R!=="box-draw"&&b.releaseInteraction(R);return}if(b.caret!==null){yo(m,i.getState().scene.annotations,I,xo(a)),b.setCaret(null),e.focus({preventScroll:!0});return}return xe(M.target,o)?e.focus({preventScroll:!0}):r.getState().clearSelection()},[m,r,e,o,i,I,a]);(0,f.useEffect)(()=>{const M=L=>{if(!Nr(L.target,e,o)||_r(L.target))return;const v=Lt(L.target),k=m.getState(),B=k.caret!==null&&!xe(L.target,o);if(v&&!B)return;const G=()=>P&&L.target===e&&!v&&!L.metaKey&&!L.ctrlKey&&!L.altKey&&!L.shiftKey&&k.standingInteraction===null&&r.getState().selection.length===0,Ze=()=>{if(!G())return;const z=bc(i.getState().scene,l,p);if(z.length===0)return;const J=s.getState().hover.primary,me=L.key==="ArrowRight"||L.key==="ArrowDown"?1:-1,ge=C.current===null?fr(z,J):fr(z,C.current.primary),ne=z[ge<0?me>0?0:z.length-1:Math.min(z.length-1,Math.max(0,ge+me))];if(ne!==void 0){if(x.current===null){const Z=de(J);Z!==null&&!Ne(Z,de(ne.primary))&&(x.current=Z)}C.current=ne,L.preventDefault(),b(ne)}},pe=()=>{if(!G())return;const z=C.current;z!==null&&(C.current=null,x.current=null,L.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),r.getState().setSelection([z.target]))};switch(L.key){case"Escape":return A(L);case"Enter":return v||(w(L),m.getState().caret!==null)?void 0:pe();case"Delete":case"Backspace":return v?void 0:O(L);case"n":case"N":if(L.metaKey||L.ctrlKey||L.altKey||v||!P||L.target!==e||k.standingInteraction!==null)return;L.preventDefault(),r.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return Ze();default:return}},b=L=>{const v=Pc(u,L,i.getState().scene.coordSystem,kc(u,h.current));y.current.add(v),s.getState().setHoverState(v)},R=s.subscribe(L=>{const v=C.current;if(v===null||y.current.has(L.hover))return;const k=L.hover.primary;if(k===null){if(j.current){b(v);return}C.current=null,x.current=null;return}const B=de(k);if(Ne(B,de(v.primary))){x.current=B;return}if(Ne(B,x.current)){b(v);return}C.current=null,x.current=null}),V=h.current,$=()=>{j.current=!0},N=L=>{j.current=!1,!(C.current===null||wc(L,V,s))&&(C.current=null,x.current=null,s.getState().setHoverState(c.RESTING_HOVER_STATE))};return V?.addEventListener("pointerenter",$),V?.addEventListener("pointerleave",N),document.addEventListener("keydown",M),()=>{R(),V?.removeEventListener("pointerenter",$),V?.removeEventListener("pointerleave",N),document.removeEventListener("keydown",M)}},[e,O,w,A,o,m,P,r,i,l,p,s,u,h])},Lt=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e.closest("[data-text-entry]")!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),wc=(e,t,r)=>{if(t===null)return!1;const o=r.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,c.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},de=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,c.readObservationIndex)(e)},Pc=(e,t,r,o)=>{const a=Ic(t.primary,r,o);if(a!==null){const i=e.query(a,{tolerance:d.ANNOTATE_ON_THE_MARK});if(Ne(de(i.primary),de(t.primary)))return{primary:i.primary,group:[...i.group],related:new Map(i.related),intersection:i.intersection}}return{primary:t.primary,group:[],related:new Map}},Ic=(e,t,r)=>{if(!e.anchored)return null;switch(t.type){case"polar":return Tc(e.x,e.y,r);case"cartesian":return Oc(e);default:return t}},Tc=(e,t,r)=>{const o=(0,c.polarToUnit)(e,t);return r>=1?{x:.5+o.x/(2*r),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*r/2}},Oc=e=>{const{observation:t,x:r,y:o}=e,a=Me(t,c.POSITION_VARIABLES.xMin),i=Me(t,c.POSITION_VARIABLES.xMax),l=Me(t,c.POSITION_VARIABLES.yMin),s=Me(t,c.POSITION_VARIABLES.yMax);return a===null||i===null||l===null||s===null?{x:r,y:o}:[a,i,l,s].every(u=>u>=0&&u<=1)?{x:(a+i)/2,y:(l+s)/2}:null},kc=(e,t)=>{const r=t?.getBoundingClientRect();return r===void 0||r.width<=0||r.height<=0?1:(e.setViewport({width:r.width,height:r.height}),r.width/r.height)},Me=(e,t)=>{const r=e[t];return typeof r=="number"&&Number.isFinite(r)?r:null},Ne=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Ac="linear-gradient(to top right, transparent calc(50% - 1px), var(--graphy-alert) calc(50% - 1px), var(--graphy-alert) calc(50% + 1px), transparent calc(50% + 1px))",Mc="d0bl00 l9kff6 l9kff3";var bo="d0bl03",Co="d0bl04",Lc=.01,Rc=e=>kt.some(t=>t.toLowerCase()===e.toLowerCase()),_c=({color:e,onChange:t,open:r,onOpenChange:o,children:a,label:i,popupAttributes:l,opacity:s,onOpacityChange:u,hasTransparentOption:h=!1,hasAutomaticOption:p=!1,tooltipSide:m="bottom"})=>{const g=d.useI18n(),{ColorSwatches:C,Slider:x}=D(),j=no(),y=oo(),S=[...p?[c.AUTO_COLOR]:[],...h?[ot]:[],...kt],P={...j,[ot]:g("graph.colorDropdown.transparent"),[c.AUTO_COLOR]:g("graph.colorDropdown.automatic")},I=b=>{t(b),o(!1)},O=y.length>0,w=O?y:S,A=e!==null&&!xr(S,e)&&!xr(y,e)?[...w,e]:w,M=(0,n.jsx)(Ec,{value:e,onChange:t,popupAttributes:l});return(0,n.jsxs)(E.Popover.Root,{open:r,onOpenChange:o,children:[(0,n.jsx)(W,{label:i??g("graph.toolbar.color.label"),side:m,suppressed:r,layer:"toolbar",children:(0,n.jsx)(E.Popover.Trigger,{render:(0,n.jsx)(te.Toolbar.Button,{}),className:Mc,onMouseDown:b=>b.preventDefault(),children:a??(0,n.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})})}),(0,n.jsx)(E.Popover.Portal,{container:d.resolvePortalContainer(),className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(E.Popover.Positioner,{sideOffset:6,align:"start",className:bo,children:(0,n.jsxs)(E.Popover.Popup,{className:Co,initialFocus:Nc,onMouseDown:b=>b.preventDefault(),...l,children:[(0,n.jsx)(C,{title:g("graph.colorDropdown.colors"),colors:O?S:A,names:P,value:e,onChange:I,trailing:O?void 0:M}),O&&(0,n.jsx)(C,{title:g("graph.colorDropdown.chartColors"),colors:A,names:P,value:e,onChange:I,trailing:M}),s!==void 0&&u!==void 0&&(0,n.jsxs)("div",{className:"_14ty2ng0",children:[(0,n.jsx)("div",{className:"_14ty2ng1",children:g("graph.colorDropdown.opacity")}),(0,n.jsx)(x,{value:s,onChange:u,min:0,max:1,step:Lc,showValue:!1,ariaLabel:g("graph.colorDropdown.opacity")})]})]})})})})]})},Nc=e=>e==="keyboard",Ec=({value:e,onChange:t,popupAttributes:r})=>{const{CustomColor:o}=D(),{themeValues:a}=d.useThemeContext();return(0,n.jsx)(o,{variant:"chip",value:e===null||e===c.AUTO_COLOR?null:d.resolveCanvasColor(e,a),onChange:t,popupAttributes:r})},xr=(e,t)=>e.some(r=>pt(r,t)),Fc="l9kff0",Dc="l9kff1",Bc="l9kff2",Gc="l9kff4 l9kff3",Hc="l9kff5",jo="l9kff6 l9kff3",Vc="xn24px0",zc="xn24px1",Wc="xn24px2",So=({children:e,popupAttributes:t})=>(0,n.jsx)(ue.Menu.Portal,{container:d.resolvePortalContainer(),className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(ue.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Vc,children:(0,n.jsx)(ue.Menu.Popup,{className:zc,onMouseDown:r=>r.preventDefault(),...t,children:e})})})}),$c=({children:e,selected:t=!1,disabled:r=!1,onClick:o})=>(0,n.jsx)(ue.Menu.Item,{className:Wc,"data-selected":t,disabled:r,onClick:o,children:e}),Uc="d0bl03",qc="d0bl00 l9kff6 l9kff3",Kc="_1r8zpuq0 d0bl04",Zc="_1r8zpuq1",Yc="_1r8zpuq2";var Xc=({value:e,onChange:t,label:r,open:o,onOpenChange:a,popupAttributes:i,showTooltip:l=!1,tooltipSide:s="bottom"})=>{const u=d.useStickerImages(),h=u?.[e],p=g=>{g!==e&&t(g),a(!1)},m=(0,n.jsx)(E.Popover.Trigger,{render:(0,n.jsx)(te.Toolbar.Button,{}),"aria-label":r,className:qc,onMouseDown:g=>g.preventDefault(),children:h===void 0?e:(0,n.jsx)("img",{className:Yc,src:h,alt:""})});return(0,n.jsxs)(E.Popover.Root,{open:o,onOpenChange:a,children:[l?(0,n.jsx)(W,{label:r,side:s,suppressed:o,layer:"toolbar",children:m}):m,(0,n.jsx)(E.Popover.Portal,{container:d.resolvePortalContainer(),className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(E.Popover.Positioner,{sideOffset:6,align:"start",className:Uc,children:(0,n.jsx)(E.Popover.Popup,{className:Kc,onMouseDown:g=>g.preventDefault(),...i,children:(0,n.jsx)("div",{className:Zc,role:"group","aria-label":r,children:u!==null&&Object.entries(u).map(([g,C])=>(0,n.jsx)("button",{type:"button","aria-label":g,"aria-pressed":g===e,className:"_1r8zpuq3 _14ty2ng3","data-active":g===e,onClick:()=>p(g),children:(0,n.jsx)("img",{className:"_1r8zpuq4",src:C,alt:""})},g))})})})})})]})},he=(0,f.createContext)("bottom"),Rt=(0,f.createContext)({open:!1,priorFocus:{current:null}}),Le=new WeakMap,_t=e=>e.preventDefault(),Jc=e=>{Lt(e.target)||e.preventDefault()},Qc=({label:e,pressed:t,disabled:r,onClick:o,children:a})=>(0,n.jsx)(W,{label:e,side:(0,f.useContext)(he),layer:"toolbar",children:(0,n.jsx)(te.Toolbar.Button,{className:jo,"aria-pressed":t,disabled:r,onClick:o,onMouseDown:_t,children:a})}),ed=({open:e,defaultOpen:t=!1,onOpenChange:r,...o})=>{const[a,i]=(0,f.useState)(t),l=(0,f.useRef)(null),s=e??a,u=(0,f.useMemo)(()=>({open:s,priorFocus:l}),[s]),h=(p,m)=>{p&&(l.current=document.activeElement),i(p),r?.(p,m)};return(0,n.jsx)(Rt.Provider,{value:u,children:(0,n.jsx)(E.Popover.Root,{...o,open:s,onOpenChange:h})})},td=({label:e,trigger:t,open:r,onOpenChange:o,disabled:a=!1,children:i})=>{const l=Ce();return(0,n.jsxs)(ue.Menu.Root,{open:r,modal:!1,onOpenChange:o,children:[(0,n.jsx)(W,{label:e,side:(0,f.useContext)(he),suppressed:r,layer:"toolbar",children:(0,n.jsxs)(ue.Menu.Trigger,{render:(0,n.jsx)(te.Toolbar.Button,{}),className:Gc,disabled:a,onMouseDown:_t,children:[t,(0,n.jsx)(ht,{size:"sm"})]})}),(0,n.jsx)(So,{popupAttributes:{...l,...mt},children:i})]})},rd=({color:e,opacity:t})=>(0,n.jsx)("span",{className:Hc,style:{background:t===void 0?e:d.transparentizeCss(e,t)}}),nd=({label:e,pressed:t,disabled:r,children:o})=>(0,n.jsx)(W,{label:e,side:(0,f.useContext)(he),suppressed:(0,f.useContext)(Rt).open,layer:"toolbar",children:(0,n.jsx)(E.Popover.Trigger,{render:(0,n.jsx)(te.Toolbar.Button,{}),className:jo,"aria-pressed":t,disabled:r,onMouseDown:_t,children:o})}),Ce=()=>{const e=(0,f.useContext)(d.GraphContext);return e===null?{}:gt(e.chartId)},Nt=()=>{const e=d.useOptionalEditorStore();return(0,f.useEffect)(()=>{if(e===null)return;const{claimInteraction:t,releaseInteraction:r}=e.getState();return Le.set(e,(Le.get(e)??0)+1),t(uo),()=>{const o=(Le.get(e)??1)-1;Le.set(e,o),o===0&&r("chrome-popup")}},[e]),null},od=({tooltipSide:e,...t})=>{const r=Ce(),o=(0,f.useContext)(he);return(0,n.jsxs)(n.Fragment,{children:[t.open&&(0,n.jsx)(Nt,{}),(0,n.jsx)(_c,{...t,tooltipSide:e??o,popupAttributes:r})]})},ad=e=>{const t=Ce(),r=(0,f.useContext)(he);return(0,n.jsxs)(n.Fragment,{children:[e.open&&(0,n.jsx)(Nt,{}),(0,n.jsx)(Xc,{...e,popupAttributes:t,showTooltip:!0,tooltipSide:r})]})},id=({align:e="start",initialFocus:t,children:r})=>{const o=Ce(),{priorFocus:a}=(0,f.useContext)(Rt),i=(0,f.useRef)(null),l=s=>{if(s==="keyboard")return!0;const u=a.current,{activeElement:h,body:p}=document;return(h===p||(i.current?.contains(h)??!1))&&u instanceof HTMLElement&&u!==p?u:!1};return(0,n.jsx)(E.Popover.Portal,{container:d.resolvePortalContainer(),className:re,children:(0,n.jsx)(ae,{children:(0,n.jsx)(E.Popover.Positioner,{sideOffset:6,align:e,className:bo,children:(0,n.jsxs)(E.Popover.Popup,{ref:i,className:Co,initialFocus:t,finalFocus:l,onMouseDown:Jc,...o,children:[(0,n.jsx)(Nt,{}),r]})})})})},sd=({className:e,tooltipSide:t="bottom",...r})=>{const o=Ce();return(0,n.jsx)(le.Tooltip.Provider,{children:(0,n.jsx)(he.Provider,{value:t,children:(0,n.jsx)(te.Toolbar.Root,{...r,...o,className:(0,X.default)(Fc,e)})})})},ld=({className:e,...t})=>(0,n.jsx)(te.Toolbar.Group,{...t,className:(0,X.default)(Dc,e)}),cd=({className:e,...t})=>(0,n.jsx)(te.Toolbar.Separator,{...t,className:(0,X.default)(Bc,e)}),dd=({children:e})=>{const t=d.resolvePortalContainer();return t===null?null:(0,yr.createPortal)((0,n.jsx)(ae,{children:e}),t)},H={Portal:dd,Root:sd,Group:ld,Separator:cd,Button:Qc,Submenu:ed,SubmenuTrigger:nd,SubmenuContent:id,Dropdown:td,ColorPicker:od,StickerPicker:ad,Swatch:rd,MenuPopup:So,MenuItem:$c},ud={Portal:H.Portal,Root:H.Root,Group:H.Group,Separator:H.Separator,Button:H.Button,Submenu:H.Submenu,SubmenuTrigger:H.SubmenuTrigger,SubmenuContent:H.SubmenuContent,Dropdown:H.Dropdown,MenuItem:H.MenuItem,ColorPicker:H.ColorPicker,Swatch:H.Swatch},wo=e=>{const t=rc()==="top"?"top":"bottom";return(0,n.jsx)(H.Root,{...e,tooltipSide:t})},hd=({anchorBox:e,avoidBoxes:t,toolbarSize:r,gap:o,viewport:a})=>t.length===0||r!==null&&pd(e,r,o,a).every(i=>!t.some(l=>md(i,l)))?e:gd([e,...t]),pd=(e,t,r,o)=>{const a=e.x+e.width/2-t.width/2,i=Math.max(o.x,Math.min(a,o.x+o.width-t.width));return[{x:i,y:e.y+e.height+r,...t},{x:i,y:e.y-r-t.height,...t}]},md=(e,t)=>e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y,gd=e=>{const t=Math.min(...e.map(i=>i.x)),r=Math.min(...e.map(i=>i.y)),o=Math.max(...e.map(i=>i.x+i.width)),a=Math.max(...e.map(i=>i.y+i.height));return{x:t,y:r,width:o-t,height:a-r}},vd=[],Re=5,fd=(e,t)=>{const r=e.getBoundingClientRect(),{clientWidth:o,clientHeight:a}=document.documentElement;return{x:(Re-r.left)/t,y:(Re-r.top)/t,width:(o-2*Re)/t,height:(a-2*Re)/t}},xd=({frameElement:e,anchorBox:t,avoidBoxes:r=vd,panelRect:o,label:a,testId:i,children:l})=>{const[s,u]=(0,f.useState)(null),[h,p]=(0,f.useState)(null);(0,f.useLayoutEffect)(()=>{if(s===null)return;const j=()=>{const S={width:s.offsetWidth,height:s.offsetHeight};p(P=>P?.width===S.width&&P.height===S.height?P:S)};j();const y=new ResizeObserver(j);return y.observe(s),()=>y.disconnect()},[s]);const m=Ln(e),g=j=>({...j,x:o.x+j.x,y:o.y+j.y}),C=hd({anchorBox:g(t),avoidBoxes:r.map(g),toolbarSize:h&&{width:h.width/m,height:h.height/m},gap:eo.y/m,viewport:fd(e,m)}),x=()=>e.focus({preventScroll:!0});return(0,n.jsx)(ro,{frameElement:e,boundary:C,side:"bottom",align:"center",takesFocus:!1,onEscape:x,children:(0,n.jsx)(wo,{ref:u,"aria-label":a,"data-testid":i,...na,children:l})})},yd={Root:xd},bd=()=>{const{commands:e}=d.useGraphContext(),t=d.useEditorStore(),[r,o]=(0,f.useState)(null);(0,f.useEffect)(()=>()=>e.commit(),[e]),(0,f.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:l}=t.getState();return r===null?l("chrome-popup"):i(uo),()=>l("chrome-popup")},[t,r]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:r===i,onOpenChange:l=>l?o(i):a()}),close:a}},Cd=({annotationId:e})=>{const t=d.useI18n(),r=wt();return d.useEditorState(o=>o.caret?.annotationId===e)?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(H.Button,{label:t("graph.annotations.baseMenu.arrowFromHere"),onClick:o=>r({start:{anchorType:"annotation",ref:e,align:"auto"}},o),children:(0,n.jsx)(co,{size:"sm",title:""})}),(0,n.jsx)(H.Separator,{})]})};Object.defineProperty(exports,"AnchoredPopover",{enumerable:!0,get:function(){return ro}});Object.defineProperty(exports,"ArrowLineIcon",{enumerable:!0,get:function(){return wl}});Object.defineProperty(exports,"ArrowOneWayIcon",{enumerable:!0,get:function(){return Kn}});Object.defineProperty(exports,"ArrowTwoWayIcon",{enumerable:!0,get:function(){return Sl}});Object.defineProperty(exports,"ArrowUpRightIcon",{enumerable:!0,get:function(){return co}});Object.defineProperty(exports,"AxisEditMenu",{enumerable:!0,get:function(){return vt}});Object.defineProperty(exports,"BarEditMenu",{enumerable:!0,get:function(){return ft}});Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return Tr}});Object.defineProperty(exports,"CANVAS_COLOR_PRESETS",{enumerable:!0,get:function(){return kt}});Object.defineProperty(exports,"CHART_CHROME_ATTRIBUTE",{enumerable:!0,get:function(){return Lr}});Object.defineProperty(exports,"ChartChromeRoot",{enumerable:!0,get:function(){return ia}});Object.defineProperty(exports,"ChartEditMenu",{enumerable:!0,get:function(){return Ct}});Object.defineProperty(exports,"CheckIcon",{enumerable:!0,get:function(){return zr}});Object.defineProperty(exports,"ColorRow",{enumerable:!0,get:function(){return K}});Object.defineProperty(exports,"ColorSwatches",{enumerable:!0,get:function(){return Mr}});Object.defineProperty(exports,"ControlRegistryProvider",{enumerable:!0,get:function(){return ci}});Object.defineProperty(exports,"ControlTooltip",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"ControlTooltipArea",{enumerable:!0,get:function(){return nt}});Object.defineProperty(exports,"CustomColor",{enumerable:!0,get:function(){return Fr}});Object.defineProperty(exports,"DEFAULT_TEXT_ALIGNMENT",{enumerable:!0,get:function(){return dc}});Object.defineProperty(exports,"DateField",{enumerable:!0,get:function(){return Dr}});Object.defineProperty(exports,"EditMenuRegistryProvider",{enumerable:!0,get:function(){return Wl}});Object.defineProperty(exports,"FileInput",{enumerable:!0,get:function(){return Br}});Object.defineProperty(exports,"FloatingToolbar",{enumerable:!0,get:function(){return H}});Object.defineProperty(exports,"GRAPH_TYPE_OPTIONS",{enumerable:!0,get:function(){return Fe}});Object.defineProperty(exports,"GRID_LINE_STYLES",{enumerable:!0,get:function(){return ct}});Object.defineProperty(exports,"GRID_LINE_WIDTH_STEP_PX",{enumerable:!0,get:function(){return Rs}});Object.defineProperty(exports,"GridEditMenu",{enumerable:!0,get:function(){return jt}});Object.defineProperty(exports,"KEYBOARD_INPUT_ATTRIBUTE",{enumerable:!0,get:function(){return ta}});Object.defineProperty(exports,"LINE_WIDTH_STEP_PX",{enumerable:!0,get:function(){return Ci}});Object.defineProperty(exports,"LegendEditMenu",{enumerable:!0,get:function(){return yn}});Object.defineProperty(exports,"LineEditMenu",{enumerable:!0,get:function(){return He}});Object.defineProperty(exports,"MENU_STAMP",{enumerable:!0,get:function(){return mt}});Object.defineProperty(exports,"MISSING_VALUES",{enumerable:!0,get:function(){return it}});Object.defineProperty(exports,"NumberField",{enumerable:!0,get:function(){return Hr}});Object.defineProperty(exports,"PalettePresetsProvider",{enumerable:!0,get:function(){return ys}});Object.defineProperty(exports,"PaletteRow",{enumerable:!0,get:function(){return pn}});Object.defineProperty(exports,"PanelGraphContext",{enumerable:!0,get:function(){return Ue}});Object.defineProperty(exports,"PlacedToolbar",{enumerable:!0,get:function(){return wo}});Object.defineProperty(exports,"PointEditMenu",{enumerable:!0,get:function(){return Tt}});Object.defineProperty(exports,"PointSymbolRow",{enumerable:!0,get:function(){return yt}});Object.defineProperty(exports,"PublicFloatingToolbar",{enumerable:!0,get:function(){return ud}});Object.defineProperty(exports,"RadioGrid",{enumerable:!0,get:function(){return Vr}});Object.defineProperty(exports,"RemoveAnnotationCommandContext",{enumerable:!0,get:function(){return Nn}});Object.defineProperty(exports,"Row",{enumerable:!0,get:function(){return _}});Object.defineProperty(exports,"RowLabelingProvider",{enumerable:!0,get:function(){return Pr}});Object.defineProperty(exports,"SELECTION_TOOLBAR_ATTRIBUTE",{enumerable:!0,get:function(){return Rr}});Object.defineProperty(exports,"Select",{enumerable:!0,get:function(){return Wr}});Object.defineProperty(exports,"SelectionToolbar",{enumerable:!0,get:function(){return yd}});Object.defineProperty(exports,"Slider",{enumerable:!0,get:function(){return $r}});Object.defineProperty(exports,"StartArrowButton",{enumerable:!0,get:function(){return Cd}});Object.defineProperty(exports,"Stepper",{enumerable:!0,get:function(){return Ur}});Object.defineProperty(exports,"Switch",{enumerable:!0,get:function(){return qr}});Object.defineProperty(exports,"TEXT_STYLE_MARK",{enumerable:!0,get:function(){return be}});Object.defineProperty(exports,"TRANSPARENT_COLOR",{enumerable:!0,get:function(){return ot}});Object.defineProperty(exports,"TRANSPARENT_SWATCH_FILL",{enumerable:!0,get:function(){return Ac}});Object.defineProperty(exports,"TextField",{enumerable:!0,get:function(){return Kr}});Object.defineProperty(exports,"ToggleGroup",{enumerable:!0,get:function(){return Zr}});Object.defineProperty(exports,"TrashIcon",{enumerable:!0,get:function(){return cc}});Object.defineProperty(exports,"applyTextAlignment",{enumerable:!0,get:function(){return gc}});Object.defineProperty(exports,"applyTextStyle",{enumerable:!0,get:function(){return mc}});Object.defineProperty(exports,"buildGridLineStyleCommand",{enumerable:!0,get:function(){return fn}});Object.defineProperty(exports,"buildGridLineWidthCommand",{enumerable:!0,get:function(){return xn}});Object.defineProperty(exports,"canBecomeGraphType",{enumerable:!0,get:function(){return rn}});Object.defineProperty(exports,"choices",{enumerable:!0,get:function(){return Vn}});Object.defineProperty(exports,"differenceChoices",{enumerable:!0,get:function(){return zn}});Object.defineProperty(exports,"discardEmptyTextCaret",{enumerable:!0,get:function(){return yo}});Object.defineProperty(exports,"findGraphTypeOption",{enumerable:!0,get:function(){return De}});Object.defineProperty(exports,"hasAttachment",{enumerable:!0,get:function(){return ll}});Object.defineProperty(exports,"hasStyleableText",{enumerable:!0,get:function(){return po}});Object.defineProperty(exports,"includePointInBounds",{enumerable:!0,get:function(){return il}});Object.defineProperty(exports,"isBoxplotOutlier",{enumerable:!0,get:function(){return lo}});Object.defineProperty(exports,"isCanvasColor",{enumerable:!0,get:function(){return Rc}});Object.defineProperty(exports,"isWithinAnyChartChrome",{enumerable:!0,get:function(){return oa}});Object.defineProperty(exports,"isWithinChart",{enumerable:!0,get:function(){return Nr}});Object.defineProperty(exports,"isWithinChartChrome",{enumerable:!0,get:function(){return xe}});Object.defineProperty(exports,"isWithinMenu",{enumerable:!0,get:function(){return _r}});Object.defineProperty(exports,"isWithinTextEntry",{enumerable:!0,get:function(){return Lt}});Object.defineProperty(exports,"measureFrameScale",{enumerable:!0,get:function(){return Ln}});Object.defineProperty(exports,"missingValueLabel",{enumerable:!0,get:function(){return en}});Object.defineProperty(exports,"moveStripFocus",{enumerable:!0,get:function(){return qn}});Object.defineProperty(exports,"normalizeToPanelExtent",{enumerable:!0,get:function(){return oe}});Object.defineProperty(exports,"readAnnotationPlacementHistory",{enumerable:!0,get:function(){return xo}});Object.defineProperty(exports,"readContainerFractionBounds",{enumerable:!0,get:function(){return _n}});Object.defineProperty(exports,"readContainerFractionBoundsFor",{enumerable:!0,get:function(){return sl}});Object.defineProperty(exports,"readDataLabelsSupport",{enumerable:!0,get:function(){return Qr}});Object.defineProperty(exports,"readFrameLayoutSize",{enumerable:!0,get:function(){return Rn}});Object.defineProperty(exports,"readFrameScale",{enumerable:!0,get:function(){return St}});Object.defineProperty(exports,"readGridEditModel",{enumerable:!0,get:function(){return vn}});Object.defineProperty(exports,"readLevelNames",{enumerable:!0,get:function(){return Bn}});Object.defineProperty(exports,"readLevelTitle",{enumerable:!0,get:function(){return dt}});Object.defineProperty(exports,"readLineEditModel",{enumerable:!0,get:function(){return xt}});Object.defineProperty(exports,"readPickedFont",{enumerable:!0,get:function(){return hc}});Object.defineProperty(exports,"readPickedFontSize",{enumerable:!0,get:function(){return uc}});Object.defineProperty(exports,"readSelectedAnnotationId",{enumerable:!0,get:function(){return We}});Object.defineProperty(exports,"readTargetVisibility",{enumerable:!0,get:function(){return io}});Object.defineProperty(exports,"readTextAnnotationStyle",{enumerable:!0,get:function(){return pc}});Object.defineProperty(exports,"resolveGraphTypeSummary",{enumerable:!0,get:function(){return nn}});Object.defineProperty(exports,"stampChartChrome",{enumerable:!0,get:function(){return gt}});Object.defineProperty(exports,"stickerButton",{enumerable:!0,get:function(){return $n}});Object.defineProperty(exports,"stickerImage",{enumerable:!0,get:function(){return Wn}});Object.defineProperty(exports,"strip",{enumerable:!0,get:function(){return Hn}});Object.defineProperty(exports,"tools",{enumerable:!0,get:function(){return ze}});Object.defineProperty(exports,"useAnnotateAnchor",{enumerable:!0,get:function(){return Sr}});Object.defineProperty(exports,"useBuildRemoveAnnotationCommand",{enumerable:!0,get:function(){return En}});Object.defineProperty(exports,"useCanvasColorNames",{enumerable:!0,get:function(){return no}});Object.defineProperty(exports,"useChartChromeContainer",{enumerable:!0,get:function(){return $e}});Object.defineProperty(exports,"useControls",{enumerable:!0,get:function(){return D}});Object.defineProperty(exports,"useEditMenu",{enumerable:!0,get:function(){return $l}});Object.defineProperty(exports,"useGroupOptions",{enumerable:!0,get:function(){return Dn}});Object.defineProperty(exports,"useHasOverlayMenu",{enumerable:!0,get:function(){return so}});Object.defineProperty(exports,"usePaletteColors",{enumerable:!0,get:function(){return oo}});Object.defineProperty(exports,"usePanelGraph",{enumerable:!0,get:function(){return va}});Object.defineProperty(exports,"usePlaceholderWidthFit",{enumerable:!0,get:function(){return ac}});Object.defineProperty(exports,"useRemoveAnnotation",{enumerable:!0,get:function(){return Fn}});Object.defineProperty(exports,"useSelectedAnnotationId",{enumerable:!0,get:function(){return lc}});Object.defineProperty(exports,"useSelectionShortcuts",{enumerable:!0,get:function(){return Sc}});Object.defineProperty(exports,"useStartArrowDraw",{enumerable:!0,get:function(){return wt}});Object.defineProperty(exports,"useToolbarPopups",{enumerable:!0,get:function(){return bd}});