@graphysdk/react-renderer 1.9.0-beta.1794847602792 → 1.9.0-beta.1794918324427

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.
package/dist/editable.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-BTq1oiCN.cjs");let d=require("@graphysdk/viz-engine"),f=require("react"),r=require("react/jsx-runtime"),ys=require("motion/react"),se=require("zustand/react/shallow"),pe=require("lodash-es"),ve=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let Re=require("@floating-ui/react-dom"),yn=require("react-dom"),le=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),or=require("react-colorful"),ar=require("@base-ui/react/number-field"),Oo=require("@base-ui/react/radio"),_o=require("@base-ui/react/radio-group"),ue=require("@base-ui/react/select"),Oe=require("@base-ui/react/slider"),ir=require("@base-ui/react/switch"),Ss=require("@base-ui/react/input"),Sn=require("@base-ui/react/direction-provider"),No=require("@tiptap/core"),Cs=require("@tiptap/extension-bold"),pt=require("@tiptap/extension-document"),ws=require("@tiptap/extension-hard-break"),js=require("@tiptap/extension-heading"),Ts=require("@tiptap/extension-italic"),As=require("@tiptap/extension-link"),ks=require("@tiptap/extension-text"),Ps=require("@tiptap/extension-text-align"),mt=require("@tiptap/extension-text-style"),Ls=require("@tiptap/extension-underline"),Tt=require("@tiptap/extensions"),Do=require("@tiptap/extension-paragraph"),Ce=require("@tiptap/react"),fe=require("@base-ui/react/toolbar"),re=require("@base-ui/react/menu"),Is=require("@base-ui/react/toggle"),De=require("@base-ui/react/accordion"),Es=require("@base-ui/react/separator");var Fo=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,d.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),a=o===void 0?void 0:n.data.getAt(o);if(a==null)return null;const i=(0,d.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,at:i}},Bo=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,f.useMemo)(()=>Fo(e,t),[e,t])},Ms=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Rs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Os=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),_s=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ns=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ds=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ve=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),Go=(0,f.createContext)(null),zo=({labelId:e,controlId:t,children:n})=>{const o=(0,f.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(Go.Provider,{value:o,children:n})},be=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,f.useContext)(Go),i=(0,f.useId)(),[s]=(0,f.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),u=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...u!==void 0&&{"aria-labelledby":u}}},xe="_18ja6qr0",Cn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,f.useMemo)(()=>(0,ve.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Ho="srewh00",Fs="srewh01",Bs={pointer:null,focus:null,last:"pointer"},Vo=(0,f.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),Zt=({className:e,children:t})=>{const[n,o]=(0,f.useState)(!1),[a,i]=(0,f.useState)(!1),[s,l]=(0,f.useState)(Bs),u=(0,f.useCallback)((x,b)=>{i(!1),l(C=>({...C,[b]:x,last:b}))},[]),h=(0,f.useCallback)((x,b)=>{l(C=>C[b]===x?{...C,[b]:null}:C)},[]),p=(0,f.useCallback)(()=>i(!0),[]),m=Gs(s),g=(0,f.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:m,reach:u,release:h,dismiss:p}),[n,a,m,u,h,p]),v=x=>{x.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(Vo.Provider,{value:g,children:t})})},we=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,children:i})=>{const{hovered:s,dismissed:l,reachedTooltipId:u,reach:h,release:p,dismiss:m}=(0,f.useContext)(Vo),g=(0,f.useId)(),[v,x]=(0,f.useState)(!1),b=s?!l&&(u===g||t&&u===null):v;(0,f.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const C=(y,P)=>{P.reason==="escape-key"&&(m(),P.allowPropagation()),x(y)};return(0,r.jsxs)(le.Tooltip.Root,{open:b,onOpenChange:C,disableHoverablePopup:!0,children:[(0,r.jsx)(le.Tooltip.Trigger,{render:i,delay:o,...a?{"aria-label":e}:{},onPointerEnter:y=>y.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(le.Tooltip.Positioner,{side:n,sideOffset:6,className:Fs,children:(0,r.jsx)(le.Tooltip.Popup,{className:Ho,children:e})})})})]})},Gs=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,zs="woi4bh0",Hs="woi4bh1";var Vs={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},$o=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:u,onPointerEnter:h,onPointerLeave:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const x=be({id:v,ariaLabel:m,ariaLabelledBy:g}),b=o==="tile",C=(0,r.jsxs)("button",{type:"button",className:Vs[o],disabled:i,"aria-expanded":a,onClick:n,onPointerEnter:h,onPointerLeave:p,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:b?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Ve,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(we,{label:u,side:s,delay:l,nameTrigger:!1,children:C}):o==="icon"&&m!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(we,{label:m,side:s,delay:l,children:C}):C},sr={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%))",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)"},$s="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))",Ws="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Wo="_14ty2ng0",lr="_14ty2ng1",Us="_14ty2ng2",qs="_14ty2ng3",Uo="_14ty2ng4",Ks="_14ty2ng5",Xs="_14ty2ng6",gt="transparent",qo=e=>e==="transparent"?{background:$s,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:Ws,border:`1px solid ${sr.border}`}:{background:e,border:`1px solid ${sr.border}`},Ko=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:u,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),x=be({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=a!==void 0||i,C=y=>{const P=y==="transparent"?v("graph.colorDropdown.transparent"):y,w=s?.[y],k=(0,r.jsx)("button",{type:"button","aria-label":w??P,className:qs,"data-active":wn(y,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>o(y),children:(0,r.jsx)("span",{className:Uo,style:qo(y)})},y);return w===void 0?k:(0,r.jsx)(we,{label:w,side:l,delay:u,children:k},y)};return(0,r.jsxs)("div",{className:Wo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Us,...x,children:[t.map(C),b&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&C("transparent")]})]})]})},wn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),Ys="data-graphy-chart-chrome",Zs="data-graphy-chart-menu",Js={[Zs]:""},At=e=>({[Ys]:e}),Be=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,vt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Jt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Le=(e,t,n)=>e instanceof Node&&(t.contains(e)||Be(e,n)),Qs="cml7ha0",Xo=(0,f.createContext)(null),el=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,f.useState)(c.resolvePortalContainer),[o,a]=(0,f.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,yn.createPortal)((0,r.jsx)("div",{ref:a,className:Qs,...At(t)}),n),(0,r.jsx)(Xo.Provider,{value:o,children:e})]})},kt=()=>(0,f.useContext)(Xo),tl="_178jeit0",nl="_178jeit1 _14ty2ng3",rl="_178jeit2 _14ty2ng4",ol="_178jeit3",al="_178jeit4",il="_178jeit5",sl="_178jeit6",ll="_178jeit7",cl={side:"flip",align:"shift",fallbackAxisSide:"end"},Yo=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=kt(),[l,u]=(0,f.useState)(!1),h=g=>{u(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:h,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:nl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:rl})}):(0,r.jsxs)("div",{className:Wo,children:[(0,r.jsx)("div",{className:lr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:ol,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Uo,style:qo(p)}),(0,r.jsx)("span",{className:al,children:m})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:cl,collisionPadding:12,disableAnchorTracking:a==="chip",className:tl,children:(0,r.jsxs)(Q.Popover.Popup,{className:il,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:lr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(or.HexColorPicker,{color:m,onChange:t,className:sl}),(0,r.jsx)(or.HexColorInput,{color:m,onChange:t,prefixed:!0,className:ll,onMouseDown:g=>g.stopPropagation()})]})})})})]})},cr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),dl="a1l6m80 woi4bh6 woi4bh5",ul="a1l6m81 _14ty2ng3",hl="a1l6m82",Zo=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,f.useId)(),l=a??s,u=i==="chip",h=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":u?e:void 0,className:hl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(we,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:ul,children:[(0,r.jsx)(cr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:dl,children:[(0,r.jsx)("span",{className:zs,children:(0,r.jsx)(cr,{})}),(0,r.jsx)("span",{className:Hs,children:e}),h]})},Pt=(0,f.createContext)(null),q=()=>{const e=(0,f.useContext)(Pt);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},Jo=({children:e,onKeyDown:t,...n})=>{const o=(0,f.useContext)(Pt),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?o.undo():o.redo())};return(0,r.jsx)("div",{onKeyDown:a,...n,children:e})},Qo="keyboard",Lt=e=>{const t=(0,f.useRef)(!1),n=(0,f.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},pl="eh8dvc0",ml="eh8dvc1 uz3g760",gl="eh8dvc2 uz3g761";var ea=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:u,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const x=be({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:C}=Lt(n);return(0,r.jsx)(ar.NumberField.Root,{className:pl,value:e,onValueChange:y=>t(y),onValueCommitted:(y,P)=>{b(P.reason===Qo)},min:o,max:a,step:i,disabled:h,children:(0,r.jsxs)(Jo,{className:ml,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(ar.NumberField.Input,{className:gl,placeholder:s,...C,"aria-invalid":p===!0?!0:void 0,...x}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},vl="_1b7s5f0",Te={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},xl="_1b7s5f7";var fl=6,ta=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=be({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",x=i==="track",b=i==="chip",{commitAfterChange:C,gestureHandlers:y}=Lt(o);return(0,r.jsx)(_o.RadioGroup,{className:(0,me.default)(vl,bl(a??e.length),v&&"_1b7s5f9",x&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:P=>{n(P),C()},...y,disabled:s,...p,children:e.map(P=>{const w=(0,r.jsxs)(Oo.Radio.Root,{value:P.value,disabled:P.disabled,className:(0,me.default)(xl,g&&"_1b7s5f8",v&&"_1b7s5fa",x&&"_1b7s5fc",b&&"_1b7s5fe"),style:{gridRow:P.gridRow,gridColumn:P.gridColumn},"aria-label":m?void 0:P.label,children:[P.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:P.label})]},P.value);if(!g&&!v&&!b)return w;const k=(v||b)&&P.value===t;return(0,r.jsx)(we,{label:P.label,checked:k,children:w},P.value)})})},bl=e=>{switch(Math.min(Math.max(Math.round(e),1),fl)){case 1:return Te[1];case 2:return Te[2];case 3:return Te[3];case 4:return Te[4];case 5:return Te[5];default:return Te[6]}},na=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),yl="_1g5x15w0 uz3g760",Sl="_1g5x15w1",Cl="_1g5x15w2",dr="_1g5x15w3",wl="_1g5x15w4",jl="_1g5x15w5",Tl="_1g5x15w6",Al="_1g5x15w7";var ra=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=be({id:u,ariaLabel:s,ariaLabelledBy:l}),p=kt();return(0,r.jsxs)(ue.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(ue.Select.Trigger,{className:yl,"data-error":i===!0,...h,children:[(0,r.jsx)(ue.Select.Value,{className:Sl,children:m=>kl(e,m,o)}),(0,r.jsx)(ue.Select.Icon,{className:dr,children:(0,r.jsx)(Ve,{size:"sm"})})]}),(0,r.jsx)(ue.Select.Portal,{container:p??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ue.Select.Positioner,{className:wl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(ue.Select.Popup,{className:jl,children:e.map(m=>(0,r.jsxs)(ue.Select.Item,{value:m.value,disabled:m.disabled,className:Tl,children:[m.icon,(0,r.jsxs)("span",{className:Al,children:[(0,r.jsx)(ue.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(ue.Select.ItemIndicator,{className:dr,children:(0,r.jsx)(na,{size:"sm"})})]},m.value))})})})})]})},kl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Cl,children:n}):Pl(e,t),Pl=(e,t)=>e.find(n=>n.value===t)?.label??t,Ll="vod76w0",Il="vod76w1",El="vod76w2",Ml="vod76w3",Rl="vod76w4",Ol="vod76w5";var oa=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:u=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=be({ariaLabel:p,ariaLabelledBy:m},!1),v=_l(e,s,l),{commitUnlessHeldKey:x,gestureHandlers:b}=Lt(n);return(0,r.jsxs)("div",{className:Ll,children:[(0,r.jsx)(Oe.Slider.Root,{className:Il,value:e,onValueChange:C=>t(C),onValueCommitted:(C,y)=>{x(y.reason===Qo)},min:o,max:a,step:i,disabled:h,children:(0,r.jsx)(Oe.Slider.Control,{className:El,children:(0,r.jsxs)(Oe.Slider.Track,{className:Ml,children:[(0,r.jsx)(Oe.Slider.Indicator,{className:Rl}),(0,r.jsx)(Oe.Slider.Thumb,{className:Ol,...b,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},_l=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Nl="_1hyrlw60",Dl="_1hyrlw61",aa=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=be({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(ir.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:Nl,...s,children:(0,r.jsx)(ir.Switch.Thumb,{className:Dl})})},Fl="uz3g761",Bl="tpcnun0 uz3g760",ia=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=be({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Jo,{className:Bl,"data-error":i===!0,children:(0,r.jsx)(Ss.Input,{className:Fl,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},Gl="cnu9yl0",zl="cnu9yl1";var jn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=be({id:h,ariaLabel:l,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=Lt(o);return(0,r.jsx)(_o.RadioGroup,{className:Gl,value:t,onValueChange:x=>{n(x),g()},...v,disabled:s,...p,children:e.map(x=>{const b=Hl(x,m),C=(0,r.jsxs)(Oo.Radio.Root,{value:x.value,disabled:x.disabled,className:(0,me.default)(zl,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[x.icon,sa(x,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:x.label})]},x.value);return b===void 0?C:(0,r.jsx)(we,{label:b,checked:x.value===t,children:C},x.value)})})},sa=(e,t)=>e.icon===void 0||t,Hl=(e,t)=>{if(!sa(e,t))return e.label},Vl={ToggleGroup:jn,Switch:aa,Slider:oa,RadioGrid:ta,Button:$o,TextField:ia,NumberField:ea,Select:ra,ColorSwatches:Ko,CustomColor:Yo,FileInput:Zo},Qt=(0,f.createContext)(Vl),la=({controls:e,children:t})=>{const n=(0,f.useContext)(Qt),o=(0,f.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.FileInput]);return(0,r.jsx)(Qt.Provider,{value:o,children:t})},F=()=>(0,f.useContext)(Qt),ur={stack:"pr583x0",grid:"pr583x1"},hr="pr583x2",$l={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},I=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,f.useId)(),i=(0,f.useId)();return e===void 0?(0,r.jsx)(Zt,{className:ur[t],children:(0,r.jsx)("div",{className:hr,children:o})}):(0,r.jsxs)(Zt,{className:ur[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:$l[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:hr,children:(0,r.jsx)(zo,{labelId:a,controlId:i,children:o})})]})},Tn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Wl,{graph:t,axis:e.axis})};Tn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var Wl=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=F(),l=n?.guides.axes.find(E=>E.scaledAesthetic===t);if((0,f.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const u=!l.visible,h=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(E=>E.position==="left"||E.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,x=t==="x"?void 0:n.scales[t]?.spec,b=x?.scaleType==="continuous"?x:void 0,C=b!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),y=b?.transform==="log"?"log":"linear",P=C&&b.transform!=="log",w=b?.domainMin??null,k=b!==void 0&&(l.position==="left"||l.position==="right")&&b.transform!=="log",T=b?.domainMax??null,L=n.config.axes[t]?.label??l.label??"",M=E=>{const B=t==="ySecondary"?{axis:t,label:E}:{axis:t,label:E};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:L,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:M,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!h,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Ds,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Ns,{})}],onChange:E=>{const B=E==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:u,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(Ms,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(Rs,{})}],onChange:E=>{if(E!=="left"&&E!=="right")return;const B=t==="y"?E:E==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),C&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:y,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Os,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(_s,{})}],onChange:E=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:E==="log"?"log":"linear"}))}})}),P&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:w,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:E}),{transient:!0})},onCommit:e.commands.commit})}),k&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:E}),{transient:!0})},onCommit:e.commands.commit})})]})},Ul={narrow:3,regular:6,wide:11},ql=({barWidth:e,...t})=>{const n=Ul[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},Kl=6,ge=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=da(e,i,n);(0,f.useEffect)(()=>()=>t.commit(),[t]);const l=(0,f.useMemo)(()=>(0,d.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const u=(p,m)=>{const g=s[0]?.part;t.dispatch(new d.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(ca,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},ca=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=F();return(0,r.jsx)(I,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Xl(t.slice(0,Kl),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ge.hasRows=(e,{scene:t,findGeom:n})=>da(e,t,n)!==null;var da=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,o)},Xl=(e,t)=>t===null||e.some(n=>wn(n,t))?e:[...e,t],Dt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],An=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=F(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,u=g=>{const v=Dt.find(({name:x})=>x===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=Dt.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(ql,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Dt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:e}),s!==null&&!l?(0,r.jsx)(I,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:h,onChange:u})}):null]})};An.hasRows=ge.hasRows;var Yl={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},Zl=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Yl[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Jl={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Ql=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Jl[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),pr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ua=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||ec(e))return pr;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&n.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},ec=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},ha=(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}};var en=["gap","zero","connect"],kn=(e,t,n)=>{const o=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(o.geom,o.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,u=(0,d.combineKindStyleDeclarations)(l,i,s),h=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof u?.strokeWidth=="number"?u.strokeWidth:null,m=tc(o,e.spec.layers),g=a?[]:rc(o),v=g.length>1,x=o.geom==="line"&&!a,b=x?ac(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&nc(e,t,m.id),pointLayerId:m?.id??null,showFill:x?b>0:null,drawnFillAlpha:b,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??oc(e,t,o)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},tc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),nc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},rc=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},oc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},ac=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},ic=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),sc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),pa=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),lc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.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"})]}),cc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),dc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.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,r.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"})]})}),uc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.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,r.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"})]})}),hc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),pc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),mc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),gc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),vc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),xc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),fc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),bc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),yc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),Sc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Cc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.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"})}),wc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.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,r.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"})]})}),jc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Tc=.55,Ac=.15,Ge=[{name:"column",icon:hc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:mc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:pc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:cc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:uc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:dc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:pa,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:lc,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:gc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:jc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:fc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:vc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Tc}},{name:"radialBar",icon:Sc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Ac}},{name:"rose",icon:Cc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:wc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:bc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:yc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:xc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],kc=.05,ma=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,xt=e=>e===null?null:Ge.find(t=>Pc(t.summary,e))??null,ga=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&va(t)?{...e,position:"identity"}:e.coordType!=="polar"||!ft(e.innerRadius)||t.coordType!=="polar"||!ft(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},va=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Pc=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&va(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&ft(e.innerRadius)===ft(t.innerRadius)},ft=e=>e>=kc;var Lc="_1a90obs1",Ic=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:ic},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:sc},{summary:{coordType:"cartesian",comboType:"lines"},icon:pa}],Ec=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Mc=4,Rc={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Oc={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},_c=()=>{const e=c.useSceneSelector(L=>L.spec),t=c.useSceneSelector(({layers:L})=>L.some(M=>(0,d.hasMultipleGroups)(M.data,M.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=F(),[s,l]=(0,f.useState)(!1),u=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!s)return;const L=({target:M,detail:E})=>{E>0&&Dc(M)&&u.current?.contains(M)&&l(!1)};return document.addEventListener("click",L),()=>document.removeEventListener("click",L)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=Fc(h),m=bt(h),g=xt(h),v=p??g,x=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),b=(p===void 0?g:gr(p,m))?.icon,C=p!==void 0&&p.arrangements.length>1,y=C&&(t||p.name==="combo"),P=()=>l(!s),w=({summary:L})=>{n.dispatch(new d.SetGraphTypeCommand(ga(L,h)),{transient:!0})},k=L=>{const M=mr.find(E=>E.name===L);M!==void 0&&w(gr(M,C?m:null))},T=mr.map(({name:L,arrangements:[M]})=>({value:L,label:o(`editor.graphTypes.${L}`),icon:(0,r.jsx)(M.icon,{size:"md"}),disabled:!ma(M.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(a,{label:x,expanded:s,onClick:P}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:x,expanded:s,onClick:P})}),s&&(0,r.jsx)(I,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:k,onCommit:n.commit,columns:Mc,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),y&&(0,r.jsx)(Nc,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},xa=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?xt(e)===xt(t):e.coordType===t.coordType&&e.geom===t.geom,fa=Ec.flatMap(([e,t])=>{const n=Ge.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ge,...Ic].filter(o=>o!==n&&xa(n.summary,o.summary))]}]}),mr=fa.filter(({name:e})=>e!=="combo"),Nc=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=F(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=bt(u);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),l=u=>{const h=e.arrangements.find(({summary:p})=>bt(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(I,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Lc,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},Dc=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,bt=e=>(0,d.isComboGraphType)(e)?Oc[e.comboType]:Rc[e.position],gr=(e,t)=>e.arrangements.find(({summary:n})=>bt(n)===t)??e.arrangements[0],Fc=e=>fa.find(({arrangements:[t]})=>xa(t.summary,e)),Bc=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,f.useState)(null);(0,f.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:u,buildRange:h})=>{if(u===null)return null;const p=(m,g)=>{const v=h(m);v!==null&&(a(m),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(ca,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},ba=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),ya=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),Gc={small:2,medium:3.8,large:5.6},zc=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:Gc[e],fill:"currentColor"})});var Hc=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},Vc="_1yjsaqt0",$c="_1yjsaqt1",Wc="_1yjsaqt2",Uc="_1yjsaqt3";var wf=512*1024,qc=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const n=new FileReader;n.onerror=()=>t({rejection:"undecodable"}),n.onload=()=>{const o=n.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},n.readAsDataURL(e)}),vr=["solid","dashed","dotted"],Ft=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Bt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],Kc=["circle","square","diamond","triangle","cross","star"],Sa=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=Ft.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:Ft.find(i=>i.widthPx===e)?.name??"",options:Ft.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(ya,{lineWidth:s})})),onChange:a})})},Ca=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=vr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(I,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:vr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(ba,{lineStyle:i})})),onChange:a})})},Pn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=F(),[i,s]=(0,f.useState)(null),l=(0,f.useContext)(Pt),u=c.useGlyphRegistry(),h=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):h("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:T,definition:L})=>[T,L])):u;if(p===void 0||p.length===0)return null;const g=T=>typeof T=="string"&&p.includes(T),v=T=>g(T)||(0,d.isImageSymbol)(T)||!(0,d.isGeometricSymbol)(T)&&m.has(T),x=T=>!(0,d.isGeometricSymbol)(T)||Kc.some(L=>L===T),b=[...m.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!g(T)),C=[...p.filter(x),...b],y=e===null?"":Ze(e),P=e===null||C.some(T=>Ze(T)===y)||!v(e)?C:[...C,e],w=T=>(0,d.isGeometricSymbol)(T)?o(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,d.isImageSymbol)(T)?o("editor.graphPanel.pointSymbol.custom"):T,k=T=>{s(null);const L=P.find(M=>Ze(M)===T);L!==void 0&&n(L)};return(0,r.jsx)(I,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:Vc,children:[(0,r.jsxs)("div",{className:$c,children:[(0,r.jsx)(a,{itemLayout:"chip",value:y,options:P.map(T=>({value:Ze(T),label:w(T),icon:(0,r.jsx)(Yc,{symbol:T,glyphs:m})})),onChange:k}),(0,r.jsxs)("span",{className:Ks,children:[(0,r.jsx)("span",{className:Xs,"aria-hidden":"true"}),(0,r.jsx)(Xc,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:T=>{s(null),n(T)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},Ln=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=Bt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:Bt.find(i=>i.sizePx===e)?.name??"",options:Bt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(zc,{pointSize:i})})),onChange:a})})},Xc=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=F(),a=i=>{qc(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},Yc=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(Hc,{symbol:e});const n=Zc(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:Uc,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:Wc,src:n,alt:""});const o=18/2;return(0,r.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},Ze=e=>typeof e=="string"?e:e.image,Zc=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},wa=(0,f.createContext)({}),Jc=wa.Provider,Qc=()=>(0,f.useContext)(wa),ed="_1qh3fon0",tn="theme",td=3,Je=14,xr=9,ja=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=Qc(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=F();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),u=[{value:tn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(fr,{colors:i})},...l.map(([p,m])=>({value:nn(p),label:p,icon:(0,r.jsx)(fr,{colors:m})}))],h=p=>{const m=l.find(([v])=>nn(v)===p);if(p!==tn&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(I,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:u,value:nd(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},nn=e=>`preset:${e}`,nd=(e,t)=>{if(e===null)return tn;const n=t.find(([,o])=>(0,pe.isEqual)(o,e));return n===void 0?"":nn(n[0])},fr=({colors:e})=>{const t=e.slice(0,td),n=Je/2,o=Je+(t.length-1)*xr;return(0,r.jsx)("svg",{width:o,height:Je,viewBox:`0 0 ${o} ${Je}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:ed,cx:n+i*xr,cy:n,r:n-.5,fill:a},i)).reverse()})},br=["smooth","linear"],yr=["auto","inside","outside"],In=()=>{const e=c.useSceneSelector(S=>S),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=F(),l=Ta(e.layers,e.coordSystem.type,n),u=S=>l.filter(({support:O})=>S(O)).map(({layer:O})=>O),h=rd(e,t),p=h.filter(S=>S.smooth!==null),m=h.filter(S=>S.missingValues!==null&&S.missingValueOptions.length>1),g=en.filter(S=>m.some(O=>O.missingValueOptions.includes(S))),v=sd(p),x=ld(m),b=S=>{o.dispatch(new d.SequenceCommand({commands:h.map(O=>new d.ToggleLinePointsCommand({layerId:O.layerId,showPoints:S}))}))},C=S=>{const O=br.find(z=>z===S);O!==void 0&&o.dispatch(new d.SequenceCommand({commands:p.map(z=>new d.SetLineCurveCommand({layerId:z.layerId,curve:O}))}))},y=u(S=>S.supportsPosition),P=Qe(y.map(S=>S.dataLabels.position))??"",w=S=>{const O=yr.find(z=>z===S);O!==void 0&&o.dispatch(new d.SequenceCommand({commands:y.map(z=>new d.SetDataLabelsCommand({layerId:z.id,position:O}))}))},k=S=>{const O=en.find(X=>X===S);if(O===void 0)return;const z=m.filter(X=>X.missingValueOptions.includes(O)).map(X=>new d.SetLineMissingValuesCommand({layerId:X.layerId,missingValues:O}));z.length!==0&&o.dispatch(new d.SequenceCommand({commands:z}))},T=h.filter(S=>S.showFill!==null),L=h.filter(S=>S.showPoints),M=od(e,t,h),E=T.some(S=>ad(e,S)),B=S=>{S.length>0&&o.dispatch(new d.SequenceCommand({commands:S}))},N=S=>{B(h.map(O=>new d.SetLineStyleCommand({layerId:O.layerId,strokeWidth:S})))},R=S=>{B(h.map(O=>new d.SetLineStyleCommand({layerId:O.layerId,lineStyle:S})))},A=S=>{B(T.map(O=>new d.SetLineStyleCommand({layerId:O.layerId,showFill:S,drawnFillAlpha:O.drawnFillAlpha})))},j=S=>{B(L.flatMap(({pointLayerId:O})=>O===null?[]:[new d.SetPointSizeCommand({layerId:O,size:S})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(_c,{}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(S=>S.supportsDataLabels),isOn:S=>S.showDataLabels,buildCommand:(S,O)=>new d.ToggleDataLabelsCommand({layerId:S,showDataLabels:O})}),y.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:P,options:yr.map(S=>({value:S,label:a(`editor.graphPanel.graphOptions.labelPositions.${S}`)})),onChange:w})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(S=>S.supportsPercentages),isOn:S=>S.format==="percentage",buildCommand:(S,O)=>new d.SetDataLabelsFormatCommand({layerId:S,format:O?"percentage":"absolute"})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(S=>S.supportsStackTotals),isOn:S=>S.showStackTotals,buildCommand:(S,O)=>new d.ToggleStackTotalsCommand({layerId:S,showStackTotals:O})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(S=>S.supportsCategoryLabels),isOn:S=>S.showCategoryLabels,buildCommand:(S,O)=>new d.ToggleCategoryLabelsCommand({layerId:S,showCategoryLabels:O})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:S=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:S}))})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:S=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:S}))})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:S=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:S}))})}),p.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:br.map(S=>({value:S,label:a(`editor.graphPanel.graphOptions.curves.${S}`),icon:(0,r.jsx)(Zl,{curve:S})})),onChange:C})}),g.length>1&&(0,r.jsx)(I,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:x,options:g.map(S=>({value:S,label:ha(a,S),icon:(0,r.jsx)(Ql,{missingValues:S})})),onChange:k})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Sa,{widthPx:Qe(M.map(S=>S.strokeWidth)),onChange:N}),(0,r.jsx)(Ca,{lineStyle:Qe(M.map(S=>S.lineStyle)),onChange:R})]}),T.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:E,onChange:A})}),h.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:L.length>0,onChange:b})}),L.length>0&&(0,r.jsx)(Ln,{sizePx:Qe(id(e,t,L)),onChange:j}),(0,r.jsx)(ja,{}),(0,r.jsx)(Bc,{})]})};In.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||Ta(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,d.isLayerSpecOf)(o,"line","area"));var Ta=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:ua(o,t,n)})),rd=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=kn(e,t,o.id);a!==null&&n.push(a)}return n},od=(e,t,n)=>n.flatMap(o=>{const a=(0,d.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),ad=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),o=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,d.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},id=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,d.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),Qe=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},sd=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ld=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},et=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=F();if(t.length===0)return null;const s=l=>{a.dispatch(new d.SequenceCommand({commands:t.map(u=>o(u.id,l))}))};return(0,r.jsx)(I,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},cd=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,d.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,d.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},tt=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},dd=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Sr(Cr(s.layers,e)?.[t]?.[n],a),u=l!==void 0?l:Sr(Cr(s.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},ud=e=>typeof e=="object"&&("style"in e||"annotate"in e),Sr=(e,t)=>e==null?e:ud(e)?e[t]:t==="style"?e:void 0,Cr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,yt=["solid","dashed","dotted"];var Aa=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",ka=(e,t)=>{const n=e.guides.axes.filter(Aa);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},hd=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const n=t.axes.find(o=>o.scaledAesthetic===e);return n===void 0||!n.showGrid},Pa=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),La=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Gt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],En=({target:e})=>{const t=c.useSceneSelector(C=>C),n=c.useStyleReaderTree(),o=ka(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=F();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,u=n.gridLine[l]().resolve(),h=(0,d.toDashPreset)(u.dashArray),p=hd(e.axis,o),m=yt.map(C=>({value:C,label:a(`editor.graphPanel.gridSection.lineStyles.${C}`),icon:(0,r.jsx)(ba,{lineStyle:C})})),g=Gt.map(({name:C,widthPx:y})=>({value:C,label:a(`editor.graphPanel.gridSection.lineWidths.${C}`),icon:(0,r.jsx)(ya,{lineWidth:y})})),v=Gt.find(({widthPx:C})=>C===u.strokeWidth)?.name??"",x=C=>{const y=yt.find(P=>P===C);y!==void 0&&i.dispatch(Pa(y,e.axis))},b=C=>{const y=Gt.find(({name:P})=>P===C);y!==void 0&&i.dispatch(La(y.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:x,disabled:p})}),(0,r.jsx)(I,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:b,disabled:p})})]})};En.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(Aa);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var wr=[{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}],pd={start:"Start",center:"Center",end:"End"},Ia=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=F(),a=e===void 0,i=a?"":zt(e),s=wr.map(u=>{const h=zt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${gd(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:md(e,u)}}),l=u=>{const h=wr.find(p=>zt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(I,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Sn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},zt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${pd[t]}`,md=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",gd=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ea=(e,t,n,o)=>{const a=Ra(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},Ma=(e,t,n,o)=>{const a=Ra(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},Ra=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),St=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(vd,{graph:t,target:e})};St.hasRows=(e,{scene:t})=>e.scope==="group"&&Oa(t,e.layerId)!==null;var vd=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=F(),s=n===null?null:Oa(n,t.layerId),l=n===null||s===null?null:kn(n,o,s.id);if(n===null||s===null||l===null)return null;const u=yd(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:bd(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:xd(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??fd(n,o,t)??l.strokeWidth,x=l.pointLayerId===null?null:Ea(n,o,l.pointLayerId,u),b=l.pointLayerId===null?null:Ma(n,o,l.pointLayerId,u),C=x!==null&&x>0,y=E=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:E,...h}))},P=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:E,drawnFillAlpha:l.drawnFillAlpha,...h}))},w=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:E,...h}))},k=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:E,...h}))},T=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:E,...h}))},L=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:E,...h}))},M=(0,d.readObservationsColorRoute)(n.spec,t)?.some(E=>E.geomKind==="line"||E.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:t}),(0,r.jsx)(Sa,{widthPx:v,onChange:w}),M&&(0,r.jsx)(Ca,{lineStyle:Sd(n,o,t),onChange:L}),l.showFill!==null&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:P})}),(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:C,onChange:y})}),C&&(0,r.jsx)(Ln,{sizePx:x,onChange:k}),C&&(0,r.jsx)(Pn,{symbol:b,coordType:n.coordSystem.type,onChange:T})]})},xd=(e,t,n,o)=>{const a=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},fd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},bd=(e,t,n)=>{const o=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},yd=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Sd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,d.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},Oa=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(o,"line","area")?o:null},_a=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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"})]}),Cd="_1aafi1g0",wd="_1aafi1g1",jr=({children:e})=>(0,r.jsxs)("span",{className:Cd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:wd})]}),Ht=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.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"})}),Tr=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.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"})]}),Na=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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"})]}),Da=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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,r.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,r.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"})]}),jd=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Fa=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ba=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Td=()=>[{scope:"group",labelKey:"pieSlice"}];function Ad(e,t){if(e.type==="polar"&&!kd(t))return Td();switch(t.geom){case"bar":return jd(t);case"line":case"area":return Fa(t);case"point":return Ba(t);default:return[]}}var kd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Pd=(e,t,n,o)=>{const a=[],i=Ld(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Id(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},Ga=(e,t)=>{const n=t.find(o=>Mn(e.predicate,o.predicate));return n===void 0?e.scope:n.id},Ld=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(a===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=za(t,a);return s===null||!Od(e,a,s)?null:{variable:a,value:s,label:Ha(e,a,s,n,o)}},Id=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.x);if(a===null||a===d.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 s=Ed(e,t);if(s===null)return null;const l=Md(e,a,s),u=l.findIndex(m=>ze(m)===ze(i));if(u<0||u>=l.length-1)return null;const h={variable:a,oneOf:l.slice(u)},p=s.length===0?h:{and:[h,...s]};return{label:Ha(e,a,i,n,o),predicate:p}},Ed=(e,t)=>{const n=[];for(const o of(0,d.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Md=(e,t,n)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!Rd(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],u=typeof l=="number"?l:a,h=ze(s),p=o.get(h);(p===void 0||u<p.position)&&o.set(h,{value:s,position:u})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Rd=(e,t)=>t.every(n=>ze(e[n.variable]??null)===ze(n.eq)),Od=(e,t,n)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=za(a,t);if(i!==null&&i>n)return!0}return!1},za=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Ha=(e,t,n,o,a)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},ze=e=>e instanceof Date?String(e.getTime()):String(e),Mn=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Ar(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Ar(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Mn(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&ke(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&kr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&ke(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&ke(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&ke(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&ke(e.gte,t.gte):"range"in e&&"range"in t&&kr(e.range,t.range),Ar=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Mn(n,a)}),kr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&ke(n,a)}),ke=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,_d=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,f.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},Nd={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Dd=e=>(0,d.isObservationAttachmentKind)(e.kind)&&Nd[e.kind],It=(e,t)=>(0,f.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),u=s.value instanceof Date?s.value.getTime():s.value;return{value:u,option:{value:String(u),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),Va=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=on(e,t,n,o);return{observation:i(Gd(e,t)),xValue:i("editor.overlayMenu.allOf",{name:$a(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},rn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=$a(e,t,n,a);switch(s){case"observation":{const h=l.length===0?null:on(e,t,n,o),p=Fd(h,u,i);return{whole:p,value:p}}case"xValue":return Pr((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=on(e,t,n,o)??i("editor.overlayMenu.all");return Pr(Bd(e,l),h,i)}default:return s}},Fd=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Pr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),Bd=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},Gd=(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,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},$a=(e,t,n,o)=>{const a=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},on=(e,t,n,o)=>{const a=(0,d.getGroupVariables)(t.data,t.mapping);return a.length===0?zd(t,n)??Hd(e,t):a.map(i=>Vd(n[i]??null,o)).join(", ")},zd=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Hd=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},Vd=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},$d="vez73g0",an="vez73g1",Wd="vez73g2",Ud="vez73g3",qd="vez73g4";var Kd="vez73g6",Xd="vez73g7",Yd="vez73g8",Zd="vez73g9",Jd="vez73ga",Wa=[Wd,Kd,qd,Ud],Qd=Wa.map(e=>`.${e}`).join(", "),eu=Wa.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ua=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${an}, ${Qd}`),a=t.closest(`.${an}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(o).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=n.querySelector(eu);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Se={side:"top",delay:200},qa={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Na},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:_a},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Da}},Ka=new Set(["barSeries","lineSeries","scatterSeries"]),tu=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Rn=e=>{const t=({target:n})=>{const o=Bo(n);return o===null?null:(0,r.jsx)(ru,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>Fo(n,o)!==null,t},ct=Rn((e,t)=>Ad(t,e)),Lr=Rn(Fa),nu=Rn(Ba),ru=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,at:a}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:u}=c.useGraphCommands(),{selectionStore:h,findGeom:p}=c.useGraphContext(),m=(0,f.useRef)(null),g=(0,f.useRef)(u);g.current=u;const{Button:v}=F(),x=c.useSceneSelector(G=>G),b=x.spec.annotations,C=x.config.parsingLocale,y=x.config.numberFormat,P=c.useFormattingLocale(),w={scene:x,layer:n,observation:o,groupOptions:It(x,P),locale:P,t:i},k=rn(w,"xValue").value,T=rn(w,"group").value,L=Va(w).observation,M=(0,f.useMemo)(()=>(0,d.createObservationAnchorParser)(n,C),[n,C]),E=(0,d.findObservationAttachment)(b,a,M,(0,f.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:x.layers,coordSystem:x.coordSystem,findGeom:p,readAnchor:M}),[x.layers,x.coordSystem,p,M])),B=E!==null&&Dd(E)?E:null,N=m.current,R=B!==null&&N?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,A=R?.kind==="comment"?R.annotation.content:null,j=A===null?"":xu(A)??void 0,[S,O]=(0,f.useState)(()=>gu(B?.kind)),z=_d(n,o),X=x.coordSystem,te=t(n,X),K=te.length===0?[]:Pd(n,o,P,y),_=(N?.choiceId===void 0?z:z.filter(G=>Ga(G,K)!==N.choiceId)).at(-1),H=(0,f.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:X}),[n,a,X]),W=uu({layer:n,observation:o,highlights:z,highlightOptions:te,reaches:K,previewedChoiceId:m.current?.choiceId,scopeLabel:G=>pu(i,G,k,T,L),scopeDescription:G=>mu(i,G,Ir(i,n,te),k,T,te.some(oe=>Ka.has(oe.labelKey))),atLeastLabel:G=>i("graph.annotations.highlights.atLeast",{value:G}),atLeastDescription:G=>i("graph.annotations.highlights.atLeastDescription",{noun:Ir(i,n,te),value:G}),onwardLabel:G=>i("graph.annotations.highlights.onward",{label:G}),onwardDescription:G=>i("graph.annotations.highlights.onwardDescription",{label:G})}),U=()=>{m.current!==null&&(m.current=null,g.current())};(0,f.useEffect)(()=>()=>U(),[]);const ce=(G,oe,ye)=>{m.current?.key!==G&&(U(),m.current={key:G,choiceId:ye},l(oe)||(m.current=null))},de=G=>{U(),s(G),h.getState().clearSelection()},$=(G,oe)=>{if(m.current?.key===G){m.current=null,g.current(),s(oe),h.getState().clearSelection();return}de(oe)},Z=(G,oe,ye)=>({onPointerEnter:()=>ce(G,oe,ye),onPointerLeave:U,onClick:()=>$(G,oe)}),ae=G=>{U(),O(oe=>oe===G?null:G)},je=G=>{if(H===null)return;U();const oe=(0,d.areAnchorsEqual)(H.start,a)?H.end:H.start,ye=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:a,end:oe,label:G}});s(ye),h.getState().setSelection([{kind:"annotation",id:ye.params.annotation.id}])};return(0,r.jsxs)("div",{className:$d,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:G=>{if(R!==null&&vu(G)){de(new d.RemoveAnnotationCommand({id:R.annotation.id}));return}Ua(G)},children:[(0,r.jsxs)("div",{className:an,children:[W!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Tr,{}),expanded:S==="highlight",onClick:()=>ae("highlight")}),_!==void 0&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(jr,{children:(0,r.jsx)(Tr,{})}),onClick:()=>de(new d.RemoveHighlightCommand({id:_.id}))}),R!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i(qa[R.kind].phrase),icon:(0,r.jsx)(jr,{children:ou(R.kind)}),onClick:()=>de(new d.RemoveAnnotationCommand({id:R.annotation.id}))}),R===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Na,{}),onClick:()=>de(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(_a,{}),expanded:S==="comment",onClick:()=>ae("comment")})]}),H!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Ht,{}),expanded:S==="difference",onClick:()=>ae("difference")}),R===null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Da,{}),expanded:S==="sticker",onClick:()=>ae("sticker")})]}),S==="comment"&&j!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(au,{at:a,onRun:de,annotationId:R?.kind==="comment"?R.annotation.id:void 0,initialText:j})}),S==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(iu,{at:a,showPreview:ce,dropPreview:U,keepPreview:$,annotationId:R?.kind==="sticker"?R.annotation.id:void 0})}),S==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ht,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>je("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ht,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>je("absoluteDifference")})]}),S==="highlight"&&W!==null&&(0,r.jsx)("div",{className:"vez73g3",children:W.available.map(G=>(0,r.jsx)(v,{label:G.label,tooltip:G.description===G.label?void 0:G.description,...Se,...Z(su(G.id),cu(G,n.id),G.id)},G.id))})]})},ou=e=>{const t=qa[e].Icon;return(0,r.jsx)(t,{})},au=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=F(),[l,u]=(0,f.useState)(o),h=(0,f.useRef)(null),p=l.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=fu(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:Xd,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:Yd,children:(0,r.jsx)(s,{value:l,onChange:u,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},iu=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>(0,r.jsx)(r.Fragment,{children:Object.entries(c.STICKER_ASSETS).map(([i,s])=>{const l=du(e,i,a);return(0,r.jsx)("button",{type:"button",className:Jd,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>o(l.key,l.command),children:(0,r.jsx)("img",{className:Zd,src:s.src,alt:""})},i)})}),su=e=>`highlight:${e}`,lu=e=>`sticker:${e}`,cu=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),du=(e,t,n)=>n===void 0?{key:lu(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},uu=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:u,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,d.buildObservationPredicate)(e,t),v=new Set(n.flatMap(w=>{const k=Ga(w,a);return k===i?[]:[k]})),x=g===null?[]:o.filter(w=>!v.has(w.scope)).map(w=>{const k=s(w.labelKey);return{id:w.scope,label:k,description:l(w.labelKey),icon:w.labelKey,predicate:g,scope:w.scope}}),b=a.flatMap(w=>v.has(w.id)?[]:[hu(w,u,h,p,m)]),[C,...y]=x,P=C===void 0?b:[C,...b,...y];return P.length===0?null:{available:P}},hu=(e,t,n,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(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}},pu=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(tu.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Ka.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Ir=(e,t,n)=>{if(t.geom==="point"&&(0,d.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},mu=(e,t,n,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:n});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,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:n});default:return t}},gu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,vu=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)},xu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Er(t)||Mr(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Er(n)||Mr(n)?null:n.text},Er=e=>e.marks!==void 0&&e.marks.length>0,Mr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,fu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),On=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(bu,{graph:t,target:e})};On.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ge.hasRows(e,t);var bu=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(a,"point"))return(0,r.jsx)(ge,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(u=>u.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:t}),!l&&(0,r.jsx)(Ln,{sizePx:Ea(n,o,a.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:a.id,size:u,...s}))}}),(0,r.jsx)(Pn,{symbol:Ma(n,o,a.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:a.id,symbol:u,...s}))}})]})},Xa={geoms:{point:{style:On,annotate:nu},line:{style:St,annotate:Lr},area:{style:St,annotate:Lr},bar:{style:An,annotate:ct},rule:{style:null,annotate:ct},tile:{style:ge,annotate:ct}},legend:Ia,axis:Tn,grid:En,graph:In},_n=(0,f.createContext)([Xa]),yu=({editMenus:e,children:t})=>{const n=(0,f.useMemo)(()=>[e??{},Xa],[e]);return(0,r.jsx)(_n.Provider,{value:n,children:t})},Su=e=>{const t=(0,f.useContext)(_n),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=Ya(c.useGraphMode());return(0,f.useMemo)(()=>e===null?null:Za(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Cu=()=>{const e=(0,f.useContext)(_n),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=Ya(c.useGraphMode());return(0,f.useCallback)(i=>Za(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},Ya=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",Za=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=cd(e.layerId,n.scene),i=a===null?null:dd(a,t,o,o==="annotate"?ct:ge);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=tt(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=tt(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=tt(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=tt(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},wu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},ju={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Tu={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون الشكل",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"السماكة",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"بداية السهم",endArrowhead:"نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",box:"إضافة مربع",arrowOneWay:"اتجاه واحد",arrowTwoWay:"اتجاهان",arrowLine:"خط"},textMenu:{title:"تعليق",placeholder:"قل ما حدث…",addButton:"إضافة"},highlights:{menuTitle:"تمييز",labels:{bar:"شريط",barGroup:"مجموعة",barStack:"مكدس",barSeries:"سلسلة",line:"خط",linePoint:"نقطة",lineSeries:"سلسلة",scatterPoint:"نقطة",scatterSeries:"سلسلة",pieSlice:"شريحة",pointOrBar:"نقطة / شريط",lineOrSeries:"خط / سلسلة"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`تمييز كل ${e} عند ${t} أو أكثر`,onward:({label:e})=>`${e} فصاعداً`,onwardDescription:({label:e})=>`تمييز ${e} وكل ما بعده`,justThis:({noun:e})=>`تمييز هذه ${e} فقط`,justValue:({label:e})=>`تمييز ${e} فقط`,everyNamed:({name:e,noun:t})=>`تمييز كل ${e} ${t}`,everyIn:({noun:e,name:t})=>`تمييز كل ${e} في ${t}`,wholeGroup:"تمييز المجموعة كلها",wholeStack:"تمييز المكدس كله",wholeSeries:"تمييز السلسلة كلها",nouns:{bubble:"فقاعة"}},stickerMenu:{title:"إضافة ملصق"},delete:"حذف",arrow:{thickness:{label:"السمك",thin:"رفيع",medium:"متوسط",thick:"سميك"},arrowhead:{startPoint:"نقطة البداية",endPoint:"نقطة النهاية",lineArrow:"سهم الخط",none:"بدون"},lineStyle:{label:"نمط الخط",solid:"صلب",dotted:"منقط"},stickerEffect:"تأثير الملصق",toolbarAriaLabel:"شريط أدوات السهم الحر",editorAriaLabel:"محرر السهم"},differenceArrow:{type:{proportion:"النسبة",difference:({absoluteDifference:e})=>`الفرق (${e})`,increase:({absoluteDifference:e})=>`الزيادة (${e})`,decrease:({absoluteDifference:e})=>`النقصان (${e})`,percentageChange:({percentageChange:e})=>`تغيير النسبة المئوية (${e})`,percentIncrease:({percentageChange:e})=>`زيادة النسبة المئوية (${e})`,percentDecrease:({percentageChange:e})=>`نقصان النسبة المئوية (${e})`},size:{label:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},flipArrow:"عكس السهم",color:"اللون",toolbarAriaLabel:"شريط أدوات سهم الفرق",editorAriaLabel:"محرر سهم الفرق"},shape:{color:"اللون",border:{label:"الحدود",none:"بدون",thin:({value:e})=>`رفيع (${e})`,medium:({value:e})=>`متوسط (${e})`,thick:({value:e})=>`سميك (${e})`}}}},Au={common:wu,editor:ju,graph:Tu},ku={save:"Save",cancel:"Cancel",confirm:"Confirm",delete:"Delete",confirmDelete:e=>`Are you sure you want to delete ${e.item}?`,abbreviations:{thousands:"k",millions:"m",billions:"b"}},Pu={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Lu={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Shape colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start of the arrow",endArrowhead:"End of the arrow",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",box:"Add box",arrowOneWay:"One way",arrowTwoWay:"Two way",arrowLine:"Line"},textMenu:{title:"Annotate",placeholder:"Say what happened…",addButton:"Add"},highlights:{menuTitle:"Highlight",labels:{bar:"bar",barGroup:"group",barStack:"stack",barSeries:"series",line:"line",linePoint:"point",lineSeries:"series",scatterPoint:"point",scatterSeries:"series",pieSlice:"slice",pointOrBar:"point / bar",lineOrSeries:"line / series"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Highlight every ${e} at ${t} or more`,onward:({label:e})=>`${e} onward`,onwardDescription:({label:e})=>`Highlight ${e} and everything after`,justThis:({noun:e})=>`Highlight just this ${e}`,justValue:({label:e})=>`Highlight just ${e}`,everyNamed:({name:e,noun:t})=>`Highlight every ${e} ${t}`,everyIn:({noun:e,name:t})=>`Highlight every ${e} in ${t}`,wholeGroup:"Highlight the whole group",wholeStack:"Highlight the whole stack",wholeSeries:"Highlight the whole series",nouns:{bubble:"bubble"}},stickerMenu:{title:"Add sticker"},delete:"Delete",arrow:{thickness:{label:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},arrowhead:{startPoint:"Start point",endPoint:"End point",lineArrow:"Line arrow",none:"None"},lineStyle:{label:"Line style",solid:"Solid",dotted:"Dotted"},stickerEffect:"Sticker effect",toolbarAriaLabel:"Free-form arrow toolbar",editorAriaLabel:"Arrow editor"},differenceArrow:{type:{proportion:"Proportion",difference:({absoluteDifference:e})=>`Difference (${e})`,increase:({absoluteDifference:e})=>`Increase (${e})`,decrease:({absoluteDifference:e})=>`Decrease (${e})`,percentageChange:({percentageChange:e})=>`Percentage change (${e})`,percentIncrease:({percentageChange:e})=>`Percent increase (${e})`,percentDecrease:({percentageChange:e})=>`Percent decrease (${e})`},size:{label:"Size",small:"Small",medium:"Medium",large:"Large"},flipArrow:"Flip arrow",color:"Color",toolbarAriaLabel:"Difference arrow toolbar",editorAriaLabel:"Difference arrow editor"},shape:{color:"Color",border:{label:"Border",none:"None",thin:({value:e})=>`Thin (${e})`,medium:({value:e})=>`Medium (${e})`,thick:({value:e})=>`Thick (${e})`}}}},Iu={common:ku,editor:Pu,graph:Lu},Eu={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Mu={editor:Eu},Ru={save:"Guardar",cancel:"Cancelar",confirm:"Confirmar",delete:"Eliminar",confirmDelete:e=>`Tem a certeza que deseja eliminar ${e.item}?`,abbreviations:{thousands:"mil",millions:"M",billions:"MM"}},Ou={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},_u={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor da forma",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Início da seta",endArrowhead:"Fim da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",box:"Adicionar caixa",arrowOneWay:"Um sentido",arrowTwoWay:"Dois sentidos",arrowLine:"Linha"},textMenu:{title:"Anotar",placeholder:"Diga o que aconteceu…",addButton:"Adicionar"},highlights:{menuTitle:"Realçar",labels:{bar:"Barra",barGroup:"Grupo",barStack:"Pilha",barSeries:"Série",line:"Linha",linePoint:"Ponto",lineSeries:"Série",scatterPoint:"Ponto",scatterSeries:"Série",pieSlice:"Fatia",pointOrBar:"Ponto / barra",lineOrSeries:"Linha / série"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Realçar cada ${e} em ${t} ou mais`,onward:({label:e})=>`${e} em diante`,onwardDescription:({label:e})=>`Realçar ${e} e tudo a seguir`,justThis:({noun:e})=>`Realçar apenas esta ${e}`,justValue:({label:e})=>`Realçar apenas ${e}`,everyNamed:({name:e,noun:t})=>`Realçar cada ${e} ${t}`,everyIn:({noun:e,name:t})=>`Realçar cada ${e} em ${t}`,wholeGroup:"Realçar o grupo inteiro",wholeStack:"Realçar a pilha inteira",wholeSeries:"Realçar a série inteira",nouns:{bubble:"bolha"}},stickerMenu:{title:"Adicionar autocolante"},delete:"Eliminar",arrow:{thickness:{label:"Espessura",thin:"Fina",medium:"Média",thick:"Grossa"},arrowhead:{startPoint:"Ponto inicial",endPoint:"Ponto final",lineArrow:"Seta de linha",none:"Nenhuma"},lineStyle:{label:"Estilo de linha",solid:"Sólida",dotted:"Pontilhada"},stickerEffect:"Efeito de autocolante",toolbarAriaLabel:"Barra de ferramentas de seta livre",editorAriaLabel:"Editor de seta"},differenceArrow:{type:{proportion:"Proporção",difference:({absoluteDifference:e})=>`Diferença (${e})`,increase:({absoluteDifference:e})=>`Aumento (${e})`,decrease:({absoluteDifference:e})=>`Diminuição (${e})`,percentageChange:({percentageChange:e})=>`Variação percentual (${e})`,percentIncrease:({percentageChange:e})=>`Aumento percentual (${e})`,percentDecrease:({percentageChange:e})=>`Diminuição percentual (${e})`},size:{label:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},flipArrow:"Inverter seta",color:"Cor",toolbarAriaLabel:"Barra de ferramentas de seta de diferença",editorAriaLabel:"Editor de seta de diferença"},shape:{color:"Cor",border:{label:"Contorno",none:"Nenhum",thin:({value:e})=>`Fino (${e})`,medium:({value:e})=>`Médio (${e})`,thick:({value:e})=>`Grosso (${e})`}}}},Nu={common:Ru,editor:Ou,graph:_u},Du={"en-GB":Iu,"en-US":Mu,ar:Au,"pt-PT":Nu},Fu=[Du,c.dictionaries],Nn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:Fu,...t,children:(0,r.jsx)(Bu,{children:e})}),Bu=({children:e})=>(0,r.jsx)(Sn.DirectionProvider,{direction:c.useTextDirection(),children:e}),Gu="data-variant",Ja=Do.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Gu]:e.variant}:{}}}}}),zu=No.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:t}=e.state;if(!t.empty)return!1;const{$from:n}=t;return n.depth!==1||n.parentOffset!==0?!1:n.index(0)===1}}}}),Dn=()=>[ks.Text,Tt.UndoRedo,js.Heading.configure({levels:[1,2,3]}),Cs.Bold,Ts.Italic,Ls.Underline,Ps.TextAlign.configure({types:["heading","paragraph"]}),As.Link.configure({openOnClick:!1,autolink:!0}),mt.TextStyle,mt.Color,ws.HardBreak],Hu=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[$u({showTitle:n,showSubtitle:o}),Ja,...Dn(),mt.FontFamily,zu.configure({showTitle:n}),Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:i})=>{if(n&&a===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return o&&a===s?t:""}})],Vu=({placeholder:e})=>[pt.Document,Ja,...Dn(),mt.FontFamily,Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],$u=({showTitle:e,showSubtitle:t})=>e&&t?pt.Document.extend({content:"block{2,}"}):pt.Document,Qa=()=>{const e=c.useI18n();return(0,f.useMemo)(()=>({...Object.fromEntries(ti.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ei=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,f.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const o=e.map(n);typeof o=="string"&&t.add(o)}return[...t]},[e])},Wu=e=>e!=="canvasDefault"&&e!=="canvasInverse",ti=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(Wu).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Fn=ti.map(e=>e.color);var Uu="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))",qu="d0bl00";var Ku="d0bl03",Xu="d0bl04",Yu=.01,Zu=e=>Fn.some(t=>t.toLowerCase()===e.toLowerCase()),Ju=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:u,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=c.useI18n(),{ColorSwatches:g,Slider:v}=F(),x=Qa(),b=ei(),C=[...p?[d.AUTO_COLOR]:[],...h?[gt]:[],...Fn],y={...x,[gt]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},P=M=>{t(M),o(!1)},w=b.length>0,k=w?b:C,T=e!==null&&!Rr(C,e)&&!Rr(b,e)?[...k,e]:k,L=(0,r.jsx)(Qu,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(fe.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:qu,onMouseDown:M=>M.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Ku,children:(0,r.jsxs)(Q.Popover.Popup,{className:Xu,onMouseDown:M=>M.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?C:T,names:y,value:e,onChange:P,trailing:w?void 0:L}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:y,value:e,onChange:P,trailing:L}),l!==void 0&&u!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(v,{value:l,onChange:u,min:0,max:1,step:Yu,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},Qu=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=F(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===d.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},Rr=(e,t)=>e.some(n=>wn(n,t)),eh="l9kff0",th="l9kff1",nh="l9kff2",rh="xn24px0",oh="xn24px1",ah="xn24px2",ih=({children:e,popupAttributes:t})=>(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:rh,children:(0,r.jsx)(re.Menu.Popup,{className:oh,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),sh=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(re.Menu.Item,{className:ah,"data-selected":t,disabled:n,onClick:o,children:e}),lh=({className:e,...t})=>(0,r.jsx)(le.Tooltip.Provider,{children:(0,r.jsx)(fe.Toolbar.Root,{...t,className:(0,me.default)(eh,e)})}),ch=({className:e,...t})=>(0,r.jsx)(fe.Toolbar.Group,{...t,className:(0,me.default)(th,e)}),dh=({className:e,...t})=>(0,r.jsx)(fe.Toolbar.Separator,{...t,className:(0,me.default)(nh,e)}),uh=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,yn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},J={Portal:uh,Root:lh,Group:ch,Separator:dh,Button:fe.Toolbar.Button,ColorPicker:Ju,MenuPopup:ih,MenuItem:sh},hh="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",ph=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,mh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",gh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",sn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:ph},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:hh},{id:"technical",label:"Technical",preview:"00",fontFamily:mh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:gh}],vh=e=>e?sn.find(t=>t.fontFamily===e)??null:null,ni="_70l3rt0",ri="_70l3rt1",oi="_70l3rt3",ai="_70l3rt4",ii="_70l3rt5",xh=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=vh(t)??sn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(re.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(fe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:ni,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:ri,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:oi,children:(0,r.jsx)(re.Menu.Popup,{className:ai,onMouseDown:l=>l.preventDefault(),children:sn.map(l=>(0,r.jsx)(re.Menu.Item,{className:ii,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},si={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},Or=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},si,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],fh=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Or.find(s=>s.id===t)??si;return(0,r.jsxs)(re.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(fe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:ni,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:ri,children:a(i.translationKey)}),(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:oi,children:(0,r.jsx)(re.Menu.Popup,{className:ai,onMouseDown:s=>s.preventDefault(),children:Or.map(s=>(0,r.jsx)(re.Menu.Item,{className:ii,"data-selected":s.id===i.id,onClick:()=>bh(e,s.id),children:(0,r.jsx)(yh,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},bh=(e,t)=>{switch(t){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()}},yh=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),Sh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),Ch=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),wh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),jh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&_r(n[i-1]);)i-=1;let s=o;for(;s<n.length&&_r(n[s]);)s+=1;return{from:a+i,to:a+s}},_r=e=>e!==void 0&&/\S/.test(e),Th="fop13s0",Ah="fop13s1",kh="fop13s2",Ph="fop13s3",Nr="fop13s4",Lh=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,f.useState)(""),u=(0,f.useRef)(null);(0,f.useEffect)(()=>{o&&l(t??"")},[o,t]);const h=()=>{Ih(e,s),a(!1)},p=()=>{l(""),a(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),h())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(fe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Th,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(Sh,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:Ah,children:(0,r.jsxs)(Q.Popover.Popup,{className:kh,initialFocus:u,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:u,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:Ph,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Nr,onClick:p,children:(0,r.jsx)(Ch,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Nr,onClick:h,children:(0,r.jsx)(na,{})})]})})})})]})},Ih=(e,t)=>{const n=t.trim(),{selection:o}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!o.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const a=jh(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},li=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),ci=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),di=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),Eh="_1d66w570",Mh="_1d66w571",Ie=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(le.Tooltip.Root,{children:[(0,r.jsx)(le.Tooltip.Trigger,{render:(0,r.jsx)(Is.Toggle,{render:(0,r.jsx)(fe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:Eh,onMouseDown:a,children:o}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(le.Tooltip.Positioner,{sideOffset:6,className:Mh,children:(0,r.jsx)(le.Tooltip.Popup,{className:Ho,children:e})})})})]})},Rh=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(di,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(li,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(ci,{})})]})},Oh="_1u34vl40",_h=({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:Nh(e),textAlign:Dh(e)}),Nh=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",Dh=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",Fh=8,Bh=8,Gh=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,f.useState)(!1),[a,i]=(0,f.useState)(null),s=a!==null,l=v=>x=>{i(x?v:null)},{refs:u,floatingStyles:h}=(0,Re.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Re.offset)(Fh),(0,Re.flip)(),(0,Re.shift)({padding:Bh})],whileElementsMounted:Re.autoUpdate}),p=(0,f.useRef)(null),m=(0,Ce.useEditorState)({editor:e,selector:_h}),g=(0,f.useCallback)(v=>{p.current=v,u.setFloating(v)},[u]);return(0,f.useEffect)(()=>{e&&u.setReference(e.view.dom)},[e,u]),(0,f.useEffect)(()=>{if(!e)return;const v=()=>o(!0),x=({event:b})=>{const{relatedTarget:C,currentTarget:y}=b,P=C instanceof Node&&p.current?.contains(C),w=C instanceof Node&&y instanceof Node&&y.contains(C);!P&&!w&&o(!1)};return e.on("focus",v),e.on("blur",x),()=>{e.off("focus",v),e.off("blur",x)}},[e]),!e||!n&&!s?null:(0,r.jsx)(J.Portal,{children:(0,r.jsxs)(J.Root,{ref:g,className:Oh,style:h,children:[(0,r.jsxs)(J.Group,{children:[(0,r.jsx)(J.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(xh,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(fh,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(J.Separator,{}),(0,r.jsxs)(J.Group,{children:[(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.bold"),active:m?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.italic"),active:m?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.underline"),active:m?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(Rh,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(Lh,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},zh="_1uy50v30",ui=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:zh,children:[(0,r.jsx)(Gh,{editor:e}),(0,r.jsx)(Ce.EditorContent,{editor:e,"aria-label":t})]}),Hh=200,Bn=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=Hh})=>{const i=(0,f.useRef)(Dr(e)),s=(0,f.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,o?.(h)},a),u=(0,Ce.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Vt(s.current,p))return l.cancel();l.run(p)}});return(0,f.useEffect)(()=>{u?.setEditable(n)},[u,n]),(0,f.useEffect)(()=>{if(!u)return;const h=Dr(e);Vt(s.current,h)||(s.current=h,!Vt(u.getJSON(),h)&&(l.cancel(),Vh(u,h)))},[u,e,l]),(0,f.useEffect)(()=>()=>l.flush(),[l]),u},Dr=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Vh=(e,t)=>{const{from:n,to:o}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,a),to:Math.min(o,a)})},Vt=(e,t)=>JSON.stringify(Ct(e))===JSON.stringify(Ct(t)),Ct=e=>Array.isArray(e)?e.map(Ct):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ct(n)]).filter(([,t])=>!$h(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),$h=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Wh=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=Bn({content:e,extensions:(0,f.useMemo)(()=>Vu({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=wh(a)?null:a;n(new d.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(ui,{editor:o,ariaLabel:"Chart caption"})})};var He="textStyle",hi=new Set(["paragraph","heading"]),pi=e=>fi(gi(e)?.fontSize)??null,mi=e=>vi(gi(e))??null,Uh=e=>{const t=xi(e),n=Yh(e);return{color:nt(t.map(o=>Zh($t(o)?.color))),font:nt(t.map(o=>vi($t(o)))),fontSize:nt(t.map(o=>fi($t(o)?.fontSize))),alignment:nt(n.map(o=>Jh(o.attrs?.textAlign)))}},qh=(e,t)=>Gn(e,n=>n.type==="text"?Xh(n,t):n),Fe=e=>xi(e).length>0,Kh=(e,t)=>Gn(e,n=>hi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),gi=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===He)?.attrs},Gn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>Gn(n,t))}),Xh=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===He),a={type:He,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},$t=e=>e.marks?.find(t=>t.type===He)?.attrs,vi=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),xi=e=>zn(e,t=>t.type==="text"),Yh=e=>zn(e,t=>hi.has(t.type??"")),zn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>zn(n,t))],nt=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},Zh=e=>typeof e=="string"&&e.length>0?e:void 0,fi=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Jh=e=>e==="left"||e==="center"||e==="right"?e:void 0,Qh=e=>[pt.Document,Do.Paragraph,...Dn(),t0,Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],e0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,f.useMemo)(()=>Qh(t("graph.annotations.text.placeholder")),[t]),i=Bn({content:e.content,extensions:a,editable:!0,onUpdate:u=>{n(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:u}}))}});(0,f.useEffect)(()=>{const{setCaretEditor:u}=o.getState();return u(i),()=>u(null)},[i,o]),(0,f.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>pi(u)}),l=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>mi(u)});return(0,r.jsx)(Ce.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},Fr=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},t0=No.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Fr(e.fontFamily)},font:{default:null,renderHTML:e=>Fr(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),n0=3,r0=({title:e,showTitle:t,subtitle:n,showSubtitle:o})=>{const a=[];return t&&a.push({type:"heading",attrs:{level:n0},content:a0(e)}),o&&a.push(...i0(n)),{type:"doc",content:a}},o0=e=>{const[t,...n]=e.content??[];return{title:s0(t?.content??[]),subtitle:l0(n)}},Hn=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Hn)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),a0=e=>e===null?[]:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e.type==="doc"&&e.content?e.content.flatMap(t=>t.content??[]):e.type==="text"||e.type==="hardBreak"?[e]:e.content??[],i0=e=>e===null?[{type:"paragraph"}]:typeof e=="string"?e===""?[{type:"paragraph"}]:[{type:"paragraph",content:[{type:"text",text:e}]}]:e.type==="doc"&&e.content?e.content.length===0?[{type:"paragraph"}]:e.content.map(Br):[Br(e)],Br=e=>e.type==="paragraph"?e:{type:"paragraph",content:e.content??[e]},s0=e=>{if(e.length===0)return null;const[t]=e;return t&&e.length===1&&t.type==="text"&&(!t.marks||t.marks.length===0)?t.text??null:{type:"paragraph",content:e.map(Hn)}},l0=e=>{const t=e.filter(o=>(o.content??[]).length>0);if(t.length===0)return null;const[n]=t;if(n&&t.length===1&&n.type==="paragraph"){const o=n.content??[],[a]=o;if(a&&o.length===1&&a.type==="text"&&(!a.marks||a.marks.length===0))return a.text??null}return{type:"doc",content:t.map(Hn)}},c0="uwf6lt0",d0={fontFamily:"var(--uwf6lt1)",fontSize:"var(--uwf6lt2)",fontWeight:"var(--uwf6lt3)",fontStyle:"var(--uwf6lt4)",letterSpacing:"var(--uwf6lt5)",lineHeight:"var(--uwf6lt6)",textColor:"var(--uwf6lt7)",textTransform:"var(--uwf6lt8)",textDecoration:"var(--uwf6lt9)",textShadow:"var(--uwf6lta)",textOutline:"var(--uwf6ltb)"},u0={fontFamily:"var(--uwf6ltc)",fontSize:"var(--uwf6ltd)",fontWeight:"var(--uwf6lte)",fontStyle:"var(--uwf6ltf)",letterSpacing:"var(--uwf6ltg)",lineHeight:"var(--uwf6lth)",textColor:"var(--uwf6lti)",textTransform:"var(--uwf6ltj)",textDecoration:"var(--uwf6ltk)",textShadow:"var(--uwf6ltl)",textOutline:"var(--uwf6ltm)"},h0=({title:e,showTitle:t,showSubtitle:n,subtitle:o,headingStyle:a,subtitleStyle:i})=>{const{dispatch:s}=c.useGraphCommands(),l=(0,f.useMemo)(()=>Hu({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),u=Bn({content:(0,f.useMemo)(()=>r0({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:l,editable:!0,onUpdate:h=>{const p=o0(h);t&&s(new d.SetContentTitleCommand({title:p.title})),n&&s(new d.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:c0,"data-testid":"title-editor",style:{...c.assignTextStyleVars(d0,a),...c.assignTextStyleVars(u0,i)},children:(0,r.jsx)(ui,{editor:u,ariaLabel:"Chart title and subtitle"})})},bi={Title:h0,Caption:Wh,TextAnnotation:e0},p0={Title:null,Caption:null,TextAnnotation:bi.TextAnnotation},m0=e=>c.MODE_RULES[e].editTextInline?bi:p0,g0="_10igzta0",v0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,yn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:g0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),x0="kwvn4c0",f0="kwvn4c1",Vn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},yi=e=>Vn(e,e.getBoundingClientRect().width),ln=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},b0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=Vn(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),y0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!C0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Gr(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return Gr(s,o.width,t.width)},S0=()=>{const[e,t]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{t(!0)},[]),e},C0=e=>c.SIDE_KEYS.some(t=>t===e),Gr=(e,t,n)=>n===0?0:e*t/n,w0={x:8,y:8},j0={side:"flip",align:"shift",fallbackAxisSide:"end"},Si=({frameElement:e,boundary:t,spans:n,clearance:o=w0,onEscape:a,children:i})=>{const s=kt(),l=S0(),[u,h]=(0,f.useState)(null),p=(0,f.useRef)(null),m=(0,f.useCallback)(k=>{p.current=k,h(k)},[]),g=(0,f.useRef)(null);(0,f.useLayoutEffect)(()=>()=>{u?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[u,e]);const{x:v,y:x,width:b,height:C}=t,y=(0,f.useMemo)(()=>({box:{x:v,y:x,width:b,height:C},spans:n}),[v,x,b,C,n]),P=(0,f.useMemo)(()=>b0(e,y.box),[e,y]),w=(k,T)=>{k||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:w,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:xe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:g,anchor:P,side:"right",align:"start",sideOffset:({side:k})=>k==="top"||k==="bottom"?o.y:o.x,alignOffset:({side:k,anchor:T})=>y0({side:k,boundary:y.box,spans:y.spans,anchor:T,rightToLeft:T0(g.current)}),collisionAvoidance:j0,sticky:!0,className:x0,...Js,children:(0,r.jsx)(Q.Popover.Popup,{ref:m,className:f0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},T0=e=>e!==null&&getComputedStyle(e).direction==="rtl",A0=2,Ci=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:u,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),v=h===null?m.fontSize:h*g,x=c.resolveRichTextFontFamily(p)??m.fontFamily,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:x},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+A0)/s;return Math.max(l,Math.min(b,k0(a,(0,d.alignUnitFractions)(i).x)))}},k0=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,o)},wi=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new d.SetLegendPositionCommand({position:"none"}),show:new d.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new d.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new d.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new d.SetGridVisibilityCommand({axis:a,visible:!1}),show:new d.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Me=()=>{const e=Cu(),{store:t}=c.useGraphContext();return(0,f.useCallback)(n=>e(n)||wi(n,t.getState().scene)!==null,[e,t])},$n=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Wn=(e,t,n,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 l=t.textAnnotations.find(u=>u.id===a.annotationId);if(l===void 0||Fe(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(new d.RemoveAnnotationCommand({id:a.annotationId}))},$e=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,P0=(e,t,n)=>{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(...L0(i,e,t,n))}return o},zr=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},L0=(e,t,n,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||$e(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const u=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(u===null)continue;const h=I0(s,t.coordSystem,u);a.push({x:u.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:h.x,y:h.y}})}return a.sort((i,s)=>i.x-s.x),a},I0=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[d.POSITION_VARIABLES.x],a=e[d.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},We=()=>{const e=c.useGraphSelection();return cn(e)},cn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},E0=e=>{const{selectionStore:t,commands:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:u,overlayRef:h}=c.useHoverContext(),p=Me(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(L=>L.spec.annotations.textAnnotations)),v=(0,f.useRef)(null),x=(0,f.useRef)(null),b=(0,f.useRef)(!0),C=(0,f.useRef)(new WeakSet),{showAnnotations:y,showMenuTriggerOnHover:P}=c.MODE_RULES[c.useGraphMode()],w=(0,f.useCallback)(L=>{const{selection:M}=t.getState(),E=y?cn(M):null;E!==null&&(L.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:E})),e.focus({preventScroll:!0}))},[e,n,t,y]),k=(0,f.useCallback)(L=>{if(Be(L.target,o))return;const M=y?cn(t.getState().selection):null;M!==null&&g.current.some(E=>E.id===M)&&(L.preventDefault(),m.getState().setCaret(M))},[m,t,g,o,y]),T=(0,f.useCallback)(L=>{const M=m.getState(),E=M.standingInteraction?.kind;if(E!==void 0){E!=="chrome-popup"&&E!=="arrow-draw"&&E!=="box-draw"&&M.releaseInteraction(E);return}if(M.caret!==null){Wn(m,i.getState().scene.annotations,n.dispatch,$n(a)),M.setCaret(null),e.focus({preventScroll:!0});return}return Be(L.target,o)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,o,i,n,a]);(0,f.useEffect)(()=>{const L=A=>{if(!Le(A.target,e,o)||vt(A.target))return;const j=Ee(A.target),S=m.getState(),O=S.caret!==null&&!Be(A.target,o);if(j&&!O)return;const z=()=>P&&A.target===e&&!j&&!A.metaKey&&!A.ctrlKey&&!A.altKey&&!A.shiftKey&&S.standingInteraction===null&&t.getState().selection.length===0,X=()=>{if(!z())return;const K=P0(i.getState().scene,s,p);if(K.length===0)return;const _=l.getState().hover.primary,H=A.key==="ArrowRight"||A.key==="ArrowDown"?1:-1,W=v.current===null?zr(K,_):zr(K,v.current.primary),U=K[W<0?H>0?0:K.length-1:Math.min(K.length-1,Math.max(0,W+H))];if(U!==void 0){if(x.current===null){const ce=Pe(_);ce!==null&&!dt(ce,Pe(U.primary))&&(x.current=ce)}v.current=U,A.preventDefault(),M(U)}},te=()=>{if(!z())return;const K=v.current;K!==null&&(v.current=null,x.current=null,A.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([K.target]))};switch(A.key){case"Escape":return T(A);case"Enter":return j||(k(A),m.getState().caret!==null)?void 0:te();case"Delete":case"Backspace":return j?void 0:w(A);case"n":case"N":if(A.metaKey||A.ctrlKey||A.altKey||j||!P||A.target!==e||S.standingInteraction!==null)return;A.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return X();default:return}},M=A=>{const j=R0(u,A,i.getState().scene.coordSystem,D0(u,h.current));C.current.add(j),l.getState().setHoverState(j)},E=l.subscribe(A=>{const j=v.current;if(j===null||C.current.has(A.hover))return;const S=A.hover.primary;if(S===null){if(b.current){M(j);return}v.current=null,x.current=null;return}const O=Pe(S);if(dt(O,Pe(j.primary))){x.current=O;return}if(dt(O,x.current)){M(j);return}v.current=null,x.current=null}),B=h.current,N=()=>{b.current=!0},R=A=>{b.current=!1,!(v.current===null||M0(A,B,l))&&(v.current=null,x.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",N),B?.addEventListener("pointerleave",R),document.addEventListener("keydown",L),()=>{E(),B?.removeEventListener("pointerenter",N),B?.removeEventListener("pointerleave",R),document.removeEventListener("keydown",L)}},[e,w,k,T,o,m,P,t,i,s,p,l,u,h])},Ee=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),M0=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,d.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},Pe=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},R0=(e,t,n,o)=>{const a=O0(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(dt(Pe(i.primary),Pe(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}},O0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return _0(e.x,e.y,n);case"cartesian":return N0(e);default:return t}},_0=(e,t,n)=>{const o=(0,d.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},N0=e=>{const{observation:t,x:n,y:o}=e,a=rt(t,d.POSITION_VARIABLES.xMin),i=rt(t,d.POSITION_VARIABLES.xMax),s=rt(t,d.POSITION_VARIABLES.yMin),l=rt(t,d.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(u=>u>=0&&u<=1)?{x:(a+i)/2,y:(s+l)/2}:null},D0=(e,t)=>{const n=t?.getBoundingClientRect();return n===void 0||n.width<=0||n.height<=0?1:(e.setViewport({width:n.width,height:n.height}),n.width/n.height)},rt=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},dt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var F0="_1vbfegu3",Ue={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},B0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Ue})}),G0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Ue})}),z0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Ue})}),H0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...Ue})}),V0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...Ue})}),Un={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},$0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Un})}),W0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Un})}),U0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Un})}),Ae={side:"top",delay:200},Hr=.2,q0={type:"doc",content:[{type:"paragraph"}]},Vr={paddingInline:12,paddingBlock:10},K0=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(X0,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},X0=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:u}=c.useGraphContext(),{Button:h,ColorSwatches:p}=F(),m=Qa(),g=ei(),v=Ci(),[x,b]=(0,f.useState)({kind:"choose"}),C=c.useEditorState(A=>A.standingInteraction?.kind==="box-draw"),y=c.useEditorState(A=>A.standingInteraction?.kind==="arrow-draw"),P=!C&&!y,w=()=>{_e(a),a.getState().setPlotMenu(null)};(0,f.useEffect)(()=>()=>_e(a),[a]),(0,f.useEffect)(()=>{if(!C&&!y)return;const A=j=>{if(j.key!=="Escape"||!Le(j.target,e,s)||vt(j.target))return;const S=Ee(j.target),O=a.getState().caret!==null&&!Be(j.target,s);if(S&&!O)return;const z=a.getState().standingInteraction?.kind;z!=="arrow-draw"&&z!=="box-draw"||(j.preventDefault(),a.getState().releaseInteraction(z))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s,C,y,a,e]);const k={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={top:{from:k.x,to:k.x+k.width},bottom:{from:k.x,to:k.x+k.width},left:{from:k.y,to:k.y+k.height},right:{from:k.y,to:k.y+k.height}},L=A=>{_e(a),b(j=>j.kind===A?{kind:"choose"}:{kind:A})},M=A=>(...j)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:A,start:n,...$r(j[0])})},E=(...A)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}_e(a),b({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...$r(A[0])})},B=()=>{const A=a.getState().standingInteraction?.kind;if((A==="arrow-draw"||A==="box-draw")&&!vt(document.activeElement)){a.getState().releaseInteraction(A);return}w()},N=A=>{_e(a);const j=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:q0,at:{anchorType:"panel",x:n.x,y:n.y},width:Hr}}),S=j.params.annotation.id,O=v({annotationId:S,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Hr,paddingInline:A===null?void 0:Vr.paddingInline}),z=new d.AddAnnotationCommand({kind:"text",annotation:{...j.params.annotation,width:O}});A===null?i.dispatch(z):i.dispatch(new d.SequenceCommand({commands:[z,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:S},declarations:{fill:A,...Vr}}})]})),u.getState().setSelection([{kind:"annotation",id:S}]),a.getState().setCaret(S,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},R=A=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:A}})),w()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:F0,style:{left:k.x,top:k.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),P&&(0,r.jsx)(Si,{frameElement:e,boundary:k,spans:T,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Ua,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(B0,{}),onClick:()=>N(null)}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(G0,{}),expanded:x.kind==="sticky",onClick:()=>L("sticky")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(z0,{}),expanded:x.kind==="arrow",onClick:()=>L("arrow")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(H0,{}),expanded:C,onClick:E}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(V0,{}),expanded:x.kind==="sticker",onClick:()=>L("sticker")})]}),x.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:Fn,names:m,value:null,onChange:N,...Ae}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:N})]}),x.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([A,j])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":A,onClick:()=>R(A),children:(0,r.jsx)("img",{className:"vez73g9",src:j.src,alt:""})},A))}),x.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowOneWay"),onClick:M("end"),children:(0,r.jsx)($0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:M("both"),children:(0,r.jsx)(W0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:M("none"),children:(0,r.jsx)(U0,{})})]})]})})]})},_e=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},$r=e=>{if(typeof e!="object"||e===null)return{};if("detail"in e&&e.detail===0)return{};if(!("clientX"in e)||!("clientY"in e))return{};const{clientX:t,clientY:n}=e;return typeof t!="number"||typeof n!="number"?{}:{pointer:{x:t,y:n}}},qe=e=>e.offset+e.strokeWidth,Wr="http://www.w3.org/2000/svg",Ur=new WeakMap,Y0=(e,t)=>{const n=Z0(e);n.setAttribute("d",t);const{x:o,y:a,width:i,height:s}=n.getBBox();return{x:o,y:a,width:i,height:s}},Z0=e=>{const t=Ur.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Wr,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const o=e.createElementNS(Wr,"path");return n.append(o),e.body.append(n),Ur.set(e,o),o},J0=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=qe(o);switch(e.kind){case"observations":return Wt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>Q0(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Wt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(rp(s),a(s.axis)/2)),i);case"graph":return Wt([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},Q0=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=tp(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>ep(l,s))},ep=(e,t)=>{const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return a<=n||i<=o?[]:[{x:n,y:o,width:a-n,height:i-o}]},tp=(e,t)=>e.kind==="boxes"?e.boxes:np(e.shapes,t),np=(e,t)=>{const n=[],o=new Map;for(const a of e){if(a.kind==="dots"){n.push(...a.centers.map(l=>c.growRect({...l,width:0,height:0},a.size/2)));continue}if(a.pathData==="")continue;const i=a.kind==="stroke"?a.width/2:0;if(!a.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(a.pathData),i));continue}const s=o.get(i)??[];s.push(a.pathData),o.set(i,s)}for(const[a,i]of o)n.push(c.growRect(t(i.join("")),a));return n},rp=e=>{switch(e.kind){case"line":return{x:Math.min(e.from.x,e.to.x),y:Math.min(e.from.y,e.to.y),width:Math.abs(e.to.x-e.from.x),height:Math.abs(e.to.y-e.from.y)};case"ring":return{x:e.center.x-e.radius,y:e.center.y-e.radius,width:e.radius*2,height:e.radius*2}}},Wt=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var op=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const o=e.vertex===null?e.parts:[...e.parts,e.vertex],a=o.reduce((s,l)=>Math.max(s,l.rows.length),0),i=a===1&&e.vertex===null;return a===0||i||a>1e3?null:o.flatMap(s=>ap(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},ap=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),ip=.5,sp={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},lp=(e,t,n)=>e===null||!cp(e)?{top:dn(t),right:un(t),bottom:dn(t),left:un(t)}:{top:ot(e,t,"top",n),right:ot(e,t,"right",n),bottom:ot(e,t,"bottom",n),left:ot(e,t,"left",n)},ot=(e,t,n,o)=>{const a=sp[n],i=n==="left"||n==="right",s=x=>i?x.y:x.x,l=x=>i?x.y+x.height:x.x+x.width;let u=-1/0;for(const x of e)u=Math.max(u,a(x));const h=u-Math.max(o,ip);let p=1/0,m=-1/0;for(const x of e)a(x)<h||(p=Math.min(p,s(x)),m=Math.max(m,l(x)));const g=i?un(t):dn(t),v={from:(0,pe.clamp)(p-o,g.from,g.to),to:(0,pe.clamp)(m+o,g.from,g.to)};return v.from<v.to?v:g},cp=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},dn=e=>({from:e.x,to:e.x+e.width}),un=e=>({from:e.y,to:e.y+e.height}),dp=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,f.useRef)(new Map),u=e?.target??null,h=e?.outline??null;(0,f.useLayoutEffect)(()=>{if(u===null||h===null)return;const m=l.current,g=new Map,x=J0(h,{panelRect:n,look:o,readGridLineWidth:y=>c.readGridLineStyle(i,y).strokeWidth,measurePathBox:y=>{const P=m.get(y)??Y0(t.ownerDocument,y);return g.set(y,P),P},coordSystem:s});if(l.current=g,x===null){a.getState().setSelectedOutline(null);return}const b=lp(op(h,{coordSystem:s,panelRect:n}),x,qe(o)),C=yi(t);a.getState().setSelectedOutline({target:u,frame:x,frameSpans:b,frameScale:C})},[a,i,s,u,h,t,n,o]);const p=e!==null;(0,f.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},qn="var(--_1qfw3e00)",up="_1qfw3e01",hp="_1qfw3e02",qr=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(pp,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),pp=({pathData:e,source:t,...n})=>{const o=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(ys.motion.path,{d:o,...n})},mp="var(--dppmab0)",gp="data-edit-outline-stroke",ji=e=>({[gp]:"",style:(0,ve.assignInlineVars)({[mp]:`${e}px`})}),vp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=Ti(),l=c.useHoverState(u=>e?u.hover.primary:null);return(0,f.useMemo)(()=>{if(l===null)return null;const u=t.find(p=>p.id===l.layerId);if(u===void 0||$e(u,l.observation))return null;const h=(0,d.buildObservationsTarget)({layer:u,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:o});return h===null||!s(h)?null:Ai({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},xp=()=>fp("pin"),fp=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=Ti(),[u]=c.useGraphSelection(),h=u?.kind==="observations"&&u.scope==="observation"?u:null;return(0,f.useMemo)(()=>{if(!t||h===null||!l(h))return null;const p=n.find(v=>v.id===h.layerId);if(p===void 0)return null;const[m]=(0,d.resolveObservationsTarget)({layer:p,target:h,parsingLocale:a}),g=m===void 0?void 0:p.data.getAt(m);return g==null||$e(p,g)?null:Ai({layer:p,observation:g,target:h,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,a,o,i,s,e])},Ti=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,se.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),o=c.useGeomReaderTree(),a=Me();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},Ai=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},bp=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,f.useMemo)(()=>e===null?null:yp(e,t,n),[e,t,n])},ki=(e,t,n)=>{const o=(0,d.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,d.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,d.findCompanionLayers)(o,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},yp=(e,t,n)=>{switch(e.kind){case"observations":{const o=ki(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Sp=()=>{const e=vp(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,o=c.useEditorState(l=>l.standingInteraction),a=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,se.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,f.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:ki(e.target,i,s),[t,e,n,o,a,i,s])};var Kr=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Cp=(e,t)=>{const n=Math.max(e.width,8),o=Math.max(e.height,8),a=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-o/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+o/2);return{x:a,y:i,width:Math.max(0,s-a),height:Math.max(0,l-i)}},wp=[],jp=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),o=c.useEditorState(g=>g.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,d.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,d.readRowScopeKey)(i,a.target.scope,a.observationIndex),u=(0,f.useMemo)(()=>i===void 0||s===null||l===null?null:Tp(t,i,s,l),[t,i,s,l]),h=(0,f.useMemo)(()=>u!==null&&e!==null&&Kr(u,e),[u,e]),p=Me(),m=a!==null&&i!==void 0&&Ap(a,i,n,p)?a.observationIndex:null;return(0,f.useMemo)(()=>{switch(o?.kind){case"observations":{const g=u?.parts[0];if(u===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return h?v===null?null:{...u,parts:wp,vertex:v}:{...u,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,d.readEditTargetKey)(o.target),target:o.target};return e!==null&&Kr(g,e)?null:g}default:return null}},[o,u,h,m,e])},Tp=(e,t,n,o)=>{const a=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},Ap=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},kp=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(Pp(t))],s=l=>{const u=l.getBoundingClientRect();return{x:u.left-a.left,y:u.top-a.top,width:u.width,height:u.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?Ut(l):Ut([(0,d.getBoundingRect)(l)])}case"legend":return Ut([...Lp(i.filter(l=>!Ip(l)))].flatMap(([l,u])=>o[l]==="direct"?u.map(s):[(0,d.getBoundingRect)(u.map(s))]));case"grid":return i.flatMap(l=>{const u=c.readStampedEditTargetInStack([l],e);if(u?.kind!=="grid"||u.target.axis==="both")return[];const{axis:h}=u.target;return t.axis==="both"||h===t.axis?[Ep(l,s(l),h)]:[]})}},Pp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Lp=e=>{const t=new Map;for(const n of e){const o=c.readLegendItemAddress(n);o!==null&&t.set(o.legendIndex,[...t.get(o.legendIndex)??[],n])}return t},Ip=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,Ut=e=>e.map(t=>({kind:"box",rect:t})),Ep=(e,{x:t,y:n,width:o,height:a},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+o/2,y:n+a/2},radius:o/2}:o<1||a<1?o<a?{kind:"line",axis:i,from:{x:t+o/2,y:n},to:{x:t+o/2,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a/2},to:{x:t+o,y:n+a/2}}:Mp(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+o,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a},to:{x:t+o,y:n}},Mp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Rp=[],Op=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(b=>b.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),u=Np(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=_p(t,n),p=(0,f.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,f.useMemo)(()=>m?.map(b=>Xr(b,p,a))??Rp,[m,p,a]),x=(0,f.useMemo)(()=>g===null?null:Xr(g,p,!1),[g,p]);return(0,f.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:x};case"guide":return{kind:"guide",target:e.target,shapes:u};case"graph":return{kind:"graph",frameSize:h}}},[e,v,x,u,h])},_p=(e,t)=>{const[n,o]=(0,f.useState)(()=>ln(e,t));return(0,f.useLayoutEffect)(()=>{o(a=>{const i=ln(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},Xr=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},u=a(e.geom,n.type);return u?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(h=>Cp(h,o))}:{kind:"declared",layer:e,rows:t,shapes:u.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:u.symbols})}},Np=(e,{frameElement:t,frameSize:n})=>{const o=c.useSceneSelector(p=>p.coordSystem.type),a=c.useSceneSelector((0,se.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=c.useSceneSelector(p=>e===null?null:p),[s,l]=(0,f.useState)([]),u=c.useLatestRef(e),h=(0,f.useRef)(!1);return(0,f.useLayoutEffect)(()=>{const p=u.current;if(p===null)return;const m=()=>{const g=kp({frameElement:t,target:p,coordType:o,legendDisplays:a}),v=yi(t);l(g.map(x=>Dp(x,1/v)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,u,o,a,i,n.width,n.height]),s},Dp=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:o,width:a,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:o*t,width:a*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Fp=["x","y"],Bp=(0,f.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=bp(),s=jp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Sp(),m=l||u||h,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(qt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:up,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(qt,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(qt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),qt=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const u=(0,f.useId)(),h=`${u}-shapes`,p=`${u}-hole`,m=Op(t,{frameElement:s,frameSize:a,panelRect:i});return dp(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:h,className:hp,children:(0,r.jsx)(Wp,{outline:m,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${h}`,style:Gp(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:zp(o)}),(0,r.jsx)("use",{href:`#${h}`,style:Hp(o)})]}),t.kind==="observations"&&(0,r.jsx)(Zp,{target:t,look:o,panelRect:i})]}):null},Gp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,ve.assignInlineVars)({[qn]:`${2*e}px`})}),zp=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,ve.assignInlineVars)({[qn]:`${2*qe(e)}px`})}),Hp=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,ve.assignInlineVars)({[qn]:`${2*qe(e)}px`})}},Vp=({dashArray:e,strokeWidth:t})=>{if((0,d.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},Pi=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},$p=(e,t,n)=>{const o=n.offset+qe(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Wp=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=Vp(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(Yr,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(Yr,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(Kp,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:$p(e.frameSize,o,t)})}},Yr=(0,f.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(qp,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Up,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),Up=({shapes:e,layer:t,dashPeriod:n})=>e.map((o,a)=>{const i=o.kind==="dots"||o.key===void 0?String(a):`${o.kind}:${o.key}`;switch(o.kind){case"region":return o.pathData===""?null:(0,r.jsx)(qr,{pathData:o.pathData,fillRule:o.fillRule,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return o.pathData===""?null:(0,r.jsx)(qr,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...ji(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:Pi(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),qp=({boxes:e,borderRadius:t})=>{const n=e.map(o=>c.buildRoundedRectPath(o,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Kp=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Fp.map(s=>{const l=ji(c.readGridLineStyle(a,s).strokeWidth),u=t.map(p=>Xp(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(f.Fragment,{children:[u!==""&&(0,r.jsx)("path",{d:u,...l}),h.map((p,m)=>(0,r.jsx)("path",{d:Yp(p),pathLength:Pi(p.radius,o),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Xp=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Yp=({center:e,radius:t})=>{const n=`${e.x},${e.y-t}`;return`M${n}A${t},${t} 0 0 1 ${`${e.x},${e.y+t}`}A${t},${t} 0 0 1 ${n}`},Zp=({target:e,look:t,panelRect:n})=>{const o=c.useSceneSelector(s=>s.coordSystem),a=e.parts[0];if(e.scope!=="xValue"||a===void 0||a.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Jp(a);return i===null?null:(0,r.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,r.jsx)("line",{...c.readCrosshairLine(o,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Jp=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,d.getXBand)(o),i=o===null?null:(0,d.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},Qp=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),em=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),tm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),nm={observation:Qp,xValue:em,group:tm},rm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(C=>C),i=It(a,o),s=c.useEditorState(C=>C.pressedObservation),l=Me(),u=(0,f.useMemo)(()=>om({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(u===null)return null;const{layer:h,levels:p,names:m}=u,{observationIndex:g,selectedFor:v}=u.pressed,x=p.map(C=>{const y=nm[C];return{value:C,label:m[C],icon:(0,r.jsx)(y,{})}}),b=C=>{const y=p.find(k=>k===C),{parsingLocale:P}=a.config,w=y===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:y,parsingLocale:P});w!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(jn,{value:v.scope,options:x,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},om=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:u}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,d.readReachableLevels)({layer:l,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(v=>{const x=(0,d.buildObservationsTarget)({layer:l,observationIndex:h,scope:v,parsingLocale:m});return x!==null&&i(x)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:Va({scene:e,layer:l,observation:u,groupOptions:n,locale:o,t:a})}},am=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),im=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),sm="_11vjgg60",lm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,f.useState)(null),s=wi(e,o);if(s===null)return null;const{hidden:l,hide:u,show:h}=s,p=()=>{if(l){n.dispatch(a??h);return}i(h),n.dispatch(u)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?im:am;return(0,r.jsx)(we,{label:m,children:(0,r.jsx)("button",{type:"button",className:sm,onClick:p,children:(0,r.jsx)(g,{title:""})})})},cm=(e,t)=>t==="polar"||e==="bar",dm=(e,t)=>e===null||e.key!==t?null:{boundary:{x:e.x,y:e.y,width:0,height:0},spans:{top:{from:e.x,to:e.x},right:{from:e.y,to:e.y},bottom:{from:e.x,to:e.x},left:{from:e.y,to:e.y}}},um="_1j45ehx0",hm="_1j45ehx1",pm="_1j45ehx2",mm="_1j45ehx3",gm=(e,t)=>{switch(e.kind){case"observations":return vm(e.scope,t);case"legend":case"axis":case"grid":return xm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},vm=(e,t)=>{switch(e){case"observation":return t("editor.overlayMenu.observation");case"group":return t("editor.overlayMenu.group");case"xValue":return t("editor.overlayMenu.band");default:return e}},xm=(e,t)=>{switch(e){case"axis":return t("editor.overlayMenu.axis");case"legend":return t("editor.overlayMenu.legend");case"grid":return t("editor.overlayMenu.gridLines");default:return e}},fm=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=It(o,n),i=(0,f.useMemo)(()=>ym({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(bm,{title:i})},bm=({title:e})=>{const t=(0,f.useRef)(null),n=(0,f.useRef)(null),[o,a]=(0,f.useState)(!1),i=(0,f.useCallback)(()=>{const u=t.current,h=n.current;u===null||h===null||a(h.offsetWidth>u.clientWidth)},[]);(0,f.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,f.useCallback)(u=>{t.current=u,s(u)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:pm,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:mm,"aria-hidden":!0,children:e.whole})]})},ym=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=gm(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[u]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),h=u===void 0?null:l.data.getAt(u);return h===null?s:rn({scene:t,layer:l,observation:h,groupOptions:n,locale:o,t:a},e.scope)},Sm=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=Cm(c.useEditorState(p=>p.selectedOutline)),o=c.useEditorState(p=>p.annotatePress),a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=Su(n?.target??null),s=Me(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,f.useMemo)(()=>a&&l!==null?dm(o,l):null,[a,o,l]);if(n===null||l===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(Si,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(Zt,{className:um,children:[(0,r.jsxs)("div",{className:hm,children:[(0,r.jsx)(fm,{target:n.target}),(0,r.jsx)(lm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(rm,{})]}),(0,r.jsx)(f.Fragment,{children:i},l)]})},Cm=e=>{const t=c.useGraphSelection(),[n,o]=(0,f.useState)(e),a=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},wm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,f.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:u}=n;return{frame:s,client:{x:o+s.x*u,y:a+s.y*u,width:s.width*u,height:s.height*u},frameSpans:l,clientSpans:{top:at(l.top,o,u),right:at(l.right,a,u),bottom:at(l.bottom,o,u),left:at(l.left,a,u)}}},[n,o,a]);return(0,f.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,f.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},at=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Li=["start","end"],jm=({anchor:e,point:t,delta:n,bounds:o=d.PANEL_FRACTION_BOUNDS})=>{const a={x:Jr(t.x,n.x,o.minX,o.maxX),y:Jr(t.y,n.y,o.minY,o.maxY)};return{anchor:{...e,x:e.x+a.x,y:e.y+a.y},point:{x:t.x+a.x,y:t.y+a.y}}},Kn=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},Zr=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),Ii=(e,t)=>(0,pe.isEqual)(e,t),Tm=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Am=(e,t,n)=>{const o=(0,d.projectAnchorToPanel)(e,n),a=(0,d.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},Jr=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,pe.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Et=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Ei=(e,t,n,o)=>{const a=e.textAnnotations.find(i=>i.id===t);return a===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(a,n),o)},km="var(--_1am0al60)";var Pm="_1am0al61",Lm="_1am0al62",ee=(e,t)=>t>0?e/t:0,Mi=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?d.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)},Ri=(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)}),he=(e,t)=>{const n=t.getBoundingClientRect(),o=ln(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return Mi(e,a)},Xn=(e,t,n)=>({x:ee(t.x-e.x,n.width),y:ee(t.y-e.y,n.height)}),Im=e=>e.x!==0||e.y!==0,Oi=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Em=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=We(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),u=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),h=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},m=Qr(t,a,p),g=Qr(t,h===a?null:h,p),v=b=>{if(s?.annotationId===b.id){const C=t.shapes.find(y=>y.id===b.id);return C===void 0?b.geometry:c.measureShapeRegion(s.region,o.annotation.shape(C.id).get("strokeWidth"),p.panel)}if(l?.annotationId===b.id){const C=t.arrows.find(y=>y.id===b.id);return C===void 0?b.geometry:c.measureArrowEnds(Kn(C,l,p.panel),p.panel)}return u?.annotationId===b.id?Ei(t,b.id,u,p)??b.geometry:b.geometry},x=b=>{if(i?.annotationId!==b)return e;const C=Oi(i.translation,e);return{x:e.x+C.x,y:e.y+C.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(eo,{annotationId:g.id,geometry:v(g),state:"hovered",origin:x(g.id)}),m!==null&&(0,r.jsx)(eo,{annotationId:m.id,geometry:v(m),state:"selected",origin:x(m.id)})]})},Qr=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},eo=({annotationId:e,geometry:t,state:n,origin:o})=>{const a=c.useStyleReaderTree();if(t===null)return null;const i=a.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,ve.assignInlineVars)({[km]:Et(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(to,{point:t.start,origin:o}),(0,r.jsx)(to,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Pm,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:o.x+t.rect.x-2,top:o.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},to=({point:e,origin:t})=>(0,r.jsx)("span",{className:Lm,style:{left:t.x+e.x,top:t.y+e.y}}),Yn="c44vv80",Mm=({panelRect:e})=>{const t=c.useEditorState(a=>c.readStanding(a,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=Oi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x+o.x,top:e.y+o.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:_m(n,t.annotationId,e)})},Rm=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Ne=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Om={text:(e,t,n)=>Ne(e.textAnnotations,t,o=>(0,r.jsx)(Rm,{annotation:o,panelSize:n})),shape:(e,t,n)=>Ne(e.shapes,t,o=>(0,r.jsx)(Dm,{shape:o,panelSize:n})),image:(e,t,n)=>Ne(e.images,t,o=>(0,r.jsx)(Bm,{image:o,panelSize:n})),arrow:(e,t,n)=>Ne(e.arrows,t,o=>(0,r.jsx)(Nm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Ne(e.stickers,t,o=>(0,r.jsx)(Fm,{sticker:o,panelSize:n}))},_m=(e,t,n)=>{for(const o of Object.values(Om)){const a=o(e,t,n);if(a!==null)return a}return null},Nm=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Dm=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Fm=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Bm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),Gm="_1lp7ph20",zm=({panelRect:e})=>{const t=c.useEditorState(n=>c.readStanding(n,"move-drag")?.placement??c.readStanding(n,"arrow-endpoint-drag")?.placement??null);return t===null?null:(0,r.jsx)(Hm,{placement:t,panelRect:e})},Hm=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),u=e.type==="snapped"?e.point:null,h=e.type==="snapped"?Vm(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:Gm,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(u!==null&&p.x===u.x&&p.y===u.y)return null;const x=o.alpha*(g?1:Math.max(0,1-m/160));return x<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...Kt(o),strokeOpacity:x},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":$m(e),children:[h!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:h.x,y:h.y,width:h.width,height:h.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,d.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...Kt(s)})]}),e.type==="offset"&&(0,r.jsxs)("g",{"data-testid":"snap-tether",children:[(0,r.jsx)("line",{x1:e.targetPoint.x,y1:e.targetPoint.y,x2:e.point.x,y2:e.point.y,...Kt(l)}),(0,r.jsx)("circle",{cx:e.targetPoint.x,cy:e.targetPoint.y,r:l.size/2,fill:(0,d.toPaintColor)(l.fill),fillOpacity:l.alpha,stroke:"none"})]})]})},Kt=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),Vm=e=>e.target.type==="observation"?e.target.box:e.target.rect,$m=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Wm=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(o,a.id),s=(0,d.computeArrow)({arrow:Kn(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Um=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),_i=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),qm=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),Ni=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Mt=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),Km="var(--pvjfpx0)",Xm="var(--pvjfpx1)",Ym="pvjfpx2",Zm="pvjfpx3",Jm="pvjfpx4",Qm="pvjfpx6 pvjfpx5",eg="pvjfpx7 pvjfpx6 pvjfpx5",tg="pvjfpx8 pvjfpx5",it=8,ng=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o})=>{const a=t.y+e.y,i=a+e.height,s=a-8-44,l=i+8,u=o-it-44,h=(0,pe.clamp)(l<=u?l:s,it,u),p=it;return{top:h,left:p,available:Math.max(0,n-it*2),centre:t.x+e.x+e.width/2-p}},rg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,label:a,testId:i,children:s})=>{const{chartId:l}=c.useGraphContext(),u=ng({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o});return(0,r.jsx)("div",{className:Ym,style:{top:u.top,left:u.left,width:u.available},children:(0,r.jsx)(J.Root,{"aria-label":a,className:Zm,"data-testid":i,...At(l),style:(0,ve.assignInlineVars)({[Km]:`${u.centre}px`,[Xm]:`${u.available}px`}),children:s})})},og=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(re.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(J.Button,{}),"aria-label":e,className:tg,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(J.MenuPopup,{popupAttributes:At(s),children:i})]})},ag=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(J.ColorPicker,{...e,popupAttributes:At(t)})},ig=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Jm,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),sg=({label:e,onClick:t,children:n})=>(0,r.jsx)(J.Button,{"aria-label":e,className:Qm,onClick:t,children:n}),lg=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(J.Button,{"aria-label":e,"aria-pressed":t,className:eg,onClick:n,children:o}),V={Root:rg,Dropdown:og,MenuItem:J.MenuItem,ColorPicker:ag,Swatch:ig,IconButton:sg,ToggleButton:lg,Button:J.Button,Separator:J.Separator},cg={kind:"chrome-popup"},Rt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,f.useState)(null);(0,f.useEffect)(()=>()=>e.commit(),[e]),(0,f.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(cg),()=>s("chrome-popup")},[t,n]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?o(i):a()}),close:a}},dg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),ug=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),hg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),pg=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],no=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:_i},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],ro=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:hg},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:dg},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:ug}],mg=(e,t)=>e.find(n=>n.value===t)??e[0];var gg=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(R=>R.spec.styles.overrides),h=c.useSceneSelector(R=>(0,d.readStyleCoord)(R.spec)),p=Rt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=mg(ro,(0,d.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",x=(0,f.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),b=(0,f.useMemo)(()=>({...x,part:"outline"}),[x]),C=(R,A)=>{const j=(0,d.findStyleRule)(u,{select:x},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...j,...R}}}),A)},y=R=>{const A=(0,d.findStyleRule)(u,{select:b},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...A,...R}}}))},P=R=>{C(R),p.close()},w=R=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:R})),p.close()},k=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=R=>C({stroke:R},{transient:!0}),L=R=>P({strokeWidth:R}),M=R=>w({startArrowheadStyle:R}),E=R=>P({dashArray:d.DASH_PRESETS.arrow[R]}),B=R=>w({endArrowheadStyle:R}),N=()=>y(v?{strokeWidth:0,shadow:"none"}:d.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:m.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Ni,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(st,{options:pg,current:m.strokeWidth,onPick:L})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Um,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(st,{options:no,current:e.startArrowheadStyle,onPick:M})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:g?.Icon!==void 0&&(0,r.jsx)(g.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(st,{options:ro,current:(0,d.toDashPreset)(m.dashArray),onPick:E})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(_i,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(st,{options:no,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:N,children:(0,r.jsx)(qm,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:k,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},st=({options:e,current:t,onPick:n})=>{const o=c.useI18n(),a=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)(V.MenuItem,{selected:i.value===t,onClick:a(i.value),children:[(0,r.jsx)("span",{children:o(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},vg="_1me29t10";var xg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ke=class{constructor(e){this.params=e,this.listeners=new AbortController,this.pendingEvent=null,this.scheduledFrame=null,this.hasMoved=!1,this.hasPublished=!1,this.confirmedDrag=!1,this.releasePoint=null,this.handleMove=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.hasMoved=!0,this.scheduledFrame===null&&(this.scheduledFrame=requestAnimationFrame(this.runFrame)))},this.handleUp=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.releasePoint={x:t.clientX,y:t.clientY},this.finish(!0))},this.handleLost=t=>{t.pointerId===this.params.pointerId&&this.finish(!1)},this.runFrame=()=>{this.scheduledFrame=null;const t=this.pendingEvent;if(this.pendingEvent=null,t===null)return;const n=this.params.editorStore.getState();if(this.hasPublished&&this.readOwn(n)===null)return;const o={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,o))return;this.confirmedDrag=!0;const a=this.resolvePreview(o,{altKey:t.altKey});a!==null&&(n.claimInteraction(a),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return xg(e,t)}settle(e){this.pendingEvent=null;const t=this.params.editorStore.getState(),n=this.readOwn(t);n!==null&&t.releaseInteraction(this.kind),e&&n!==null&&this.commit(n),e&&!this.confirmedDrag&&this.params.onClick!==void 0&&(document.activeElement===this.params.handle&&this.params.handle.blur(),this.params.onClick(this.releasePoint??this.params.press))}cancelFrame(){this.scheduledFrame!==null&&(cancelAnimationFrame(this.scheduledFrame),this.scheduledFrame=null)}},hn=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,a),l=e.offset??s,u=(l?.x??0)*(l?.unit==="px"?1:o.width),h=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-u,y:i.y-h}}},Zn=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Di=["center",...Zn],fg=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Di.filter(a=>a!==t)].map(a=>({align:a,point:(0,d.readRectPoint)(o,a)}))},Fi=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image")continue;const l=(0,d.readAnnotationBox)(s,n,o);l!==null&&a.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return a},bg=(e,t,n,o)=>{const a=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:ee(e.point.x-a.x,o.width),y:ee(e.point.y-a.y,o.height)}},yg=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,pe.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Sg=class extends Ke{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:u}=i,h=he(l,u),p=(0,d.clampAnnotationTranslation)(s,Xn(o,e,l),h);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s,frameElement:l}=a(),u=(0,d.findAnnotation)(i,n);if(u!==null){if(t!==void 0&&u.kind==="text"){const h=yg(pn(t,i,n,s),u.annotation);h!==null&&o(new d.UpdateAnnotationCommand({kind:"text",id:n,patch:h}));return}if(t!==void 0&&u.kind==="sticker"){const{anchor:h}=pn(t,i,n,s);if((0,pe.isEqual)(h,u.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}Im(e)&&o(new d.MoveAnnotationCommand({id:n,translation:e,bounds:he(s,l)}))}}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,u=s.stickers.find(g=>g.id===a);if(u===void 0)return null;const h=(0,d.projectAnchorToPanel)(u.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:h.x+p.x,y:h.y+p.y}}],h,hn(e.at,null,u.at,l),n,o,{targetAligns:Zn,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:ee(m.point.x-h.x,l.width),y:ee(m.point.y-h.y,l.height)},placement:m}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:u}=o,h=s.textAnnotations.find(x=>x.id===a);if(h===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:h},l,u);if(p===null)return null;const m=(0,d.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(fg(m,e.align,g),(0,d.readRectPoint)(m,e.align),hn(e.at,e.align,h.at,l),n,o,{targetAligns:Di});return v===null?null:{kind:"move-drag",annotationId:a,translation:bg(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:u,editorStore:h}=this.params,{spec:p,scene:m,panelRect:g,frameElement:v,layers:x,coordSystem:b,measuredBoxes:C,readObservationBox:y}=a,P=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),w=Ri(he(g,v),{x:ee(t.x,g.width),y:ee(t.y,g.height)}),k=this.readOwn(h.getState())?.placement;return(0,d.resolvePointPlacement)({sourcePoints:e,current:o.altKey?null:n,panelRect:g,bounds:w,engine:l,layers:x,coordSystem:b,resolver:u,readObservationBox:y,annotationTargets:o.altKey?[]:Fi(m,P,g,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:k?.type==="snapped"?k.target:null,detachDistance:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!o.altKey,annotation:!o.altKey,free:!0}})}},pn=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,ee(a.x,o.width))),l=Math.max(0,Math.min(1,ee(a.y,o.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*o.width,y:l*o.height},nearby:[]}},ut=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,Bi=(e,t,n)=>{const o=ut(e,t,n);return o?.anchorType==="panel"?o:null},Gi=(e,t)=>e==="start"?{start:t}:{end:t},Cg=(e,t,{scene:n,panelRect:o,measuredBoxes:a,readObservationBox:i})=>{const s=(0,d.projectAnchorToPanel)(t,o),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,d.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,d.readAnnotationBox)(m,o,a);return g===null?l:(0,d.projectBoxToPanel)(g,o)}const{observationIndex:u}=t,{layerId:h}=e;if(u===void 0||h===void 0)return l;const p=i({layerId:h,observationIndex:u});return p===null?l:(0,d.projectBoxToPanel)(p,o)},wg=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},jg=class extends Ke{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:u}=this.params,h=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:x,coordSystem:b,measuredBoxes:C,readObservationBox:y}=h,P=ut(p,n,o);if(P===null)return null;const w={x:e.x-a.x,y:e.y-a.y},k=(0,d.projectAnchorToPanel)(m[o],v),T=Ri(he(v,h.frameElement),{x:ee(k.x,v.width),y:ee(k.y,v.height)}),L=o==="start"?"end":"start",M=ut(p,n,L),E=M===null?void 0:Cg(M,m[L],{scene:g,panelRect:v,measuredBoxes:C,readObservationBox:y}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),N=this.readOwn(u.getState())?.placement,R=S=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:k.x+w.x,y:k.y+w.y}}],current:t.altKey?null:hn(P,null,m[o],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:x,coordSystem:b,resolver:l,readObservationBox:y,annotationTargets:t.altKey?[]:Fi(g,B,v,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:N?.type==="snapped"?N.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:Zn,areaAlign:S,annotationAreaAlign:S,areaSnapDistance:16,facing:E,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),A=R("auto"),j=A?.type==="snapped"&&A.landing==="area"&&wg(A.anchor,M)?R(void 0):A;return j===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:j}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=ut(i,n,e);if(l===null)return;const u=pn(t,i,n,s).anchor;Ii(l,u)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Gi(e,u)}))}},Tg=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useSceneSelector((0,se.useShallow)(x=>({spec:x.spec.annotations,layers:x.layers,coordSystem:x.coordSystem}))),h=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...u,arrow:t,scene:h,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:m}),v=(0,f.useRef)(null);return(0,f.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,f.useCallback)(x=>({onPointerDown:b=>{if(b.button===0&&v.current===null){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{return}b.currentTarget.focus({preventScroll:!0}),b.preventDefault(),v.current=new jg({handle:b.currentTarget,pointerId:b.pointerId,annotationId:e,endpoint:x,press:{x:b.clientX,y:b.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,a])},Ag=[" ","Enter"],oo=4,kg=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(h=>h.spec.annotations),l=c.useLatestRef(s),u=c.useLatestRef(a.dispatch);return(0,f.useEffect)(()=>()=>{for(const h of Li)ao({editorStore:i,annotationId:e,endpoint:h,annotations:l.current,dispatch:u.current})},[i,e,l,u]),(0,f.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,h);if(Ag.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){ao({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:a.dispatch});return}const y=Bi(s,e,h);if(y===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:Zr(y,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const x=Pg(p.key,n);if(x===null)return;p.preventDefault();const{anchor:b,point:C}=jm({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:x,bounds:he(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:Zr(b,C,n)})}}),[e,s,t,n,o,i,a])},ao=({editorStore:e,annotationId:t,endpoint:n,annotations:o,dispatch:a})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=Bi(o,t,n);l===null||Ii(l,s.placement.anchor)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Gi(n,s.placement.anchor)}))},Pg=(e,t)=>{const n=ee(oo,t.width),o=ee(oo,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Lg=e=>{const t=We(),n=Mg(t),o=Rg(e.panelRect,t),a=Og(t);if(n===null||o===null)return null;const i=a.dragged===null?o:Kn(o,a.dragged,e.panelRect);return(0,r.jsx)(Ig,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Ig=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Tg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=kg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[o&&(0,r.jsx)(gg,{arrow:e,arrowBox:Am(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&Li.map(m=>(0,r.jsx)(Eg,{endpoint:m,point:Tm(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},Eg=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:vg,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Mg=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},Rg=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Og=e=>c.useEditorState((0,se.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),_g=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),Ng="q7gcrz0",Dg="q7gcrz1",Fg="q7gcrz2";var Bg=["absoluteDifference","relativeDifference","proportion"],io=["absoluteDifference","relativeDifference"],Gg=["relativeDifference","proportion"],zg={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},Hg=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,f.useMemo)(()=>{const a=(0,d.areEndpointsComparable)(e.start,e.end);return Bg.filter(i=>a||!io.includes(i)||i===e.label).map(i=>({kind:i,key:zg[i],preview:(0,d.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!io.includes(i),suspect:Gg.includes(i)&&e.start.measurementValue===0}))},[e,o])},so=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],Vg=({arrow:e,color:t,labelBox:n,panelRect:o,frameWidth:a,frameHeight:i,frameElement:s})=>{const l=c.useI18n(),{commands:u}=c.useGraphContext(),h=c.useSceneSelector(A=>A.spec.styles.overrides),p=c.useSceneSelector(A=>(0,d.readStyleCoord)(A.spec)),m=Rt(),g=Hg(e),v=(0,d.resolveDifferenceArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),x=(0,f.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),b=(0,f.useMemo)(()=>({...x,part:"label"}),[x]),C=g.find(A=>A.kind===e.label),y=g.some(A=>A.pickable&&A.kind!==e.label),P=so.find(A=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[A.id].arrow.strokeWidth===v.strokeWidth),w=(A,j)=>{u.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:A}),j)},k=A=>({...(0,d.findStyleRule)(h,{select:x},p)?.declarations,...A}),T=A=>({...(0,d.findStyleRule)(h,{select:b},p)?.declarations,...A}),L=A=>{w(A),m.close()},M=()=>{u.dispatch(new d.RemoveAnnotationCommand({id:e.id})),s.focus({preventScroll:!0})},E=A=>u.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:k({stroke:A})}}),{transient:!0}),B=()=>w({start:e.end.anchor,end:e.start.anchor}),N=A=>()=>L({label:A}),R=A=>()=>{const j=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[A];u.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:k(j.arrow),label:T(j.label)})),m.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:o,frameWidth:a,frameHeight:i,label:l("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)($g,{option:C}),disabled:!y,...m.bind("labelKind"),children:g.map(A=>(0,r.jsxs)(V.MenuItem,{selected:A.kind===e.label,disabled:!A.pickable,onClick:N(A.kind),children:[(0,r.jsx)("span",{children:l(A.key)}),(A.suspect||!A.pickable)&&(0,r.jsx)("span",{"aria-label":l(A.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:Fg,children:A.preview})]},A.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:l("graph.annotations.differenceArrowToolbar.color"),onChange:E,...m.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:P===void 0?"":l(P.key),...m.bind("size"),children:so.map(A=>(0,r.jsx)(V.MenuItem,{selected:A.id===P?.id,onClick:R(A.id),children:l(A.key)},A.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:l("graph.annotations.differenceArrowToolbar.swap"),onClick:B,children:(0,r.jsx)(_g,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:l("graph.annotations.differenceArrowToolbar.remove"),onClick:M,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},$g=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Dg,children:t(e.key)}),(0,r.jsxs)("span",{className:Ng,children:["(",e.preview,")"]})]})},zi="var(--ydgo3h0)";var Wg="ydgo3h1",Ug="ydgo3h2",qg="ydgo3h3",Kg="ydgo3h4",Xg=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=Yg({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=o.query((0,d.toPanelCursor)(h,n));if(p===null)return null;const m=a.find(v=>v.id===p.layerId);if(m===void 0)return null;const g=(0,d.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,d.readObservationIndex)(p),coordSystem:i,align:u});return g===null||(0,d.areAnchorsEqual)(g.anchor,l)||(0,d.areSameStackEndpoints)(m,g.anchor,l)?null:g},Yg=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Hi=e=>e==="start"?"end":"start",Vi=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,d.areAnchorsEqual)(o,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},Zg=class extends Ke{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:u,coordSystem:h}=n(),p=Xg({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:u,coordSystem:h,resolver:a,fixedAnchor:i[Hi(t)].anchor,align:i[t].anchor.align});return p===null?null:{kind:"difference-arrow-endpoint-drag",annotationId:i.id,endpoint:t,point:p}}commit({point:e,endpoint:t}){const{dispatch:n,readInputs:o}=this.params;Vi({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},Jg=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,se.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=c.useLatestRef(o),p=(0,f.useRef)(null);return(0,f.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,f.useCallback)(m=>({onPointerDown:g=>{if(g.button===0&&p.current===null){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{return}g.currentTarget.focus({preventScroll:!0}),g.preventDefault(),p.current=new Zg({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>u.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>h.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[u,h,l,s,i,a])},Qg=[" ","Enter"],ev=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,se.useShallow)(u=>({layers:u.layers,coordSystem:u.coordSystem,mainAxis:(0,d.readMainAxis)(u.coordSystem)}))),l=e.id;return(0,f.useEffect)(()=>()=>{const u=o.getState();c.readStanding(u,"difference-arrow-endpoint-drag")?.annotationId===l&&u.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,f.useCallback)(u=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=o.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,u);if(Qg.includes(h.key)){if(h.preventDefault(),h.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:e[u]});p.releaseInteraction("difference-arrow-endpoint-drag"),Vi({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=tv(h.key,s);if(g===null)return;h.preventDefault();const v=nv({arrow:e,endpoint:u,from:m.point.anchor,move:g,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:v})}}),[e,o,t,n,a,i,s])},tv=(e,t)=>{const n=e==="ArrowUp"||e==="ArrowDown";return!n&&!(e==="ArrowLeft"||e==="ArrowRight")?null:{axis:t==="x"===n?"cross":"main",step:e==="ArrowDown"||e==="ArrowRight"?1:-1}},nv=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const u=s.createLayerMeasurement(l);if(u===null)return null;const{align:h}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Hi(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,m)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:u})})?.point??null},rv=e=>{const t=We(),n=c.useDifferenceArrowGeometries(),o=(0,f.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:Wg,children:[t!==null&&(0,r.jsx)(ov,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(iv,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},ov=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,f.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(av,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,dragging:a.dragging,...n})},av=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,panelRect:i,frameRect:s,frameElement:l,dragging:u})=>{const h=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,ve.assignInlineVars)({[zi]:h}),children:[!u&&(0,r.jsx)(Vg,{arrow:e,color:t,labelBox:o,panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),(0,r.jsx)("div",{"aria-hidden":"true",className:Kg,"data-testid":"difference-arrow-selection-label",style:{left:i.x+a.x-2,top:i.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},iv=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,f.useRef)(n),u=e.committedArrow.id;(0,f.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===u&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,u]);const h=Jg({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=ev({arrow:e.committedArrow}),m=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,ve.assignInlineVars)({[zi]:m}),children:[(0,r.jsx)(lo,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(lo,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},lo=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Ug,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":o||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:a?0:-1,...i,...a?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:qg})}),sv="s8eewu0",co="s8eewu1",lv=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(h=>c.readStanding(h,"arrow-draw")),o=c.useEditorState(h=>c.readStanding(h,"box-draw")),a=n?.start??o?.start??null,[i,s]=(0,f.useState)(null);if((0,f.useEffect)(()=>{if(n===null&&o===null)return;const h=(g,v)=>{const x=e.getBoundingClientRect();s({x:uo(g-x.left,0,x.width),y:uo(v-x.top,0,x.height)})},p=n?.pointer??o?.pointer;p!==void 0&&h(p.x,p.y);const m=g=>{h(g.clientX,g.clientY)};return document.addEventListener("pointermove",m,!0),document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointermove",m,!0),document.removeEventListener("pointerdown",m,!0),s(null)}},[n,o,e]),a===null||i===null)return null;const l=t.x+a.x*t.width,u=t.y+a.y*t.height;return(0,r.jsx)("svg",{className:sv,children:o===null?(0,r.jsx)("line",{className:co,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:co,fill:"none",x:Math.min(l,i.x),y:Math.min(u,i.y),width:Math.abs(i.x-l),height:Math.abs(i.y-u)})})},uo=(e,t,n)=>Math.min(Math.max(e,t),n),cv=({panelRect:e})=>{const t=c.useEditorState(i=>c.readStanding(i,"shape-resize-drag")),n=c.useResolvedAnnotations(e).shapes,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(i=>i.id===t.annotationId);return a===void 0?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ShapeAnnotation,{shape:{...a,region:t.region},style:o.annotation.shape(a.id).resolve(),panel:e})})},dv="var(--o49ib40)",uv={sm:"o49ib41",md:"o49ib42"},hv={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},$i=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:hv[n],role:"button",style:{left:e.x,top:e.y,...(0,ve.assignInlineVars)({[dv]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:uv[o]})})},mn=[{width:0,key:"graph.annotations.shapeToolbar.border.none"},{width:2,key:"graph.annotations.shapeToolbar.border.thin"},{width:8,key:"graph.annotations.shapeToolbar.border.medium"},{width:16,key:"graph.annotations.shapeToolbar.border.thick"}],pv=e=>[...mn].reverse().find(t=>t.width<=e)??mn[0],mv=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(w=>w.spec.styles.overrides),h=c.useSceneSelector(w=>(0,d.readStyleCoord)(w.spec)),p=Rt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=pv(m.strokeWidth),v=(0,f.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(w,k)=>{const T=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...T,...w}}}),k)},b=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},C=w=>x({fill:w},{transient:!0}),y=w=>x({fillAlpha:w},{transient:!0}),P=w=>()=>{x({strokeWidth:w}),p.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:C,opacity:m.fillAlpha,onOpacityChange:y,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Ni,{size:"sm",title:""}),...p.bind("border"),children:mn.map(w=>(0,r.jsx)(V.MenuItem,{selected:w.width===g?.width,onClick:P(w.width),children:s(w.key)},w.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:b,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},gn=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,u=e+t,h=Math.min(a,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),u-h),x=(0,pe.clamp)(e+o,g,v);return{start:x,extent:u-x}}const p=Math.max(Math.min(s,u),e+h),m=Math.max(l,u);return{start:e,extent:(0,pe.clamp)(u+o,p,m)-e}},gv=["top-left","top-right","bottom-right","bottom-left"];var Wi=({width:e,height:t})=>({x:ee(16,e),y:ee(16,t)}),vv=(e,t)=>({x:Ki(t)?e.x:e.x+e.width,y:Xi(t)?e.y:e.y+e.height}),Ui=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=gn({start:e.x,extent:e.width,moveStartEdge:Ki(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=gn({start:e.y,extent:e.height,moveStartEdge:Xi(t),delta:n.y,minExtent:o.y,...a===void 0?{}:{bounds:{min:a.minY,max:a.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},qi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Ki=e=>e==="top-left"||e==="bottom-left",Xi=e=>e==="top-left"||e==="top-right",Yi=e=>{const t=c.useLatestRef(e),n=(0,f.useRef)(null);return(0,f.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,f.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},wt=(e,t)=>{const n=e.shapes.find(o=>o.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},xv=class extends Ke{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=wt(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:Ui({region:u,corner:n,delta:Xn(o,e,s),minSize:Wi(s),bounds:he(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=wt(o().annotations,t);a===null||qi(a,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},fv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Yi((s,l)=>new xv({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},bv=[" ","Enter"],Zi=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,f.useEffect)(()=>()=>ho(t,n.current),[t,n]),(0,f.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(bv.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){ho(t,n.current);return}const u=n.current.claim(o);if(u===null)return;i.claimInteraction(u);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},ho=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},po=4,yv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return Zi({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=wt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=Sv(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:Ui({region:s.region,corner:l,delta:h,minSize:Wi(t),bounds:he(t,n)})}},commit:({region:s})=>{const l=wt(i,e);l===null||qi(l,s)||o.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},Sv=(e,t)=>{const n=ee(po,t.width),o=ee(po,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Cv={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},wv=e=>{const t=We(),n=Tv(t),o=Av(t);if(n===null)return null;const a=o.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return a===null?null:(0,r.jsx)(jv,{shape:n,region:a,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},jv=({shape:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=fv({annotationId:e.id,panelRect:a,frameElement:s}),h=yv({annotationId:e.id,panelRect:a,frameElement:s}),{rect:p}=c.measureShapeRegion(t,c.useStyleReaderTree().annotation.shape(e.id).resolve().strokeWidth,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(mv,{shape:e,shapeBox:p,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&gv.map(m=>{const g=vv(p,m);return(0,r.jsx)($i,{point:{x:a.x+g.x,y:a.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:Cv[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},Tv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},Av=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),kv=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var Ji=[{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:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),Pv=e=>Ji.find(t=>t.id===(e??"modern"))??null;var Qi=[{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"}],Lv=e=>Qi.find(t=>t.size===(e??15))??null,Iv=e=>`${e}px`,Ev=[{alignment:"left",Icon:di},{alignment:"center",Icon:li},{alignment:"right",Icon:ci}],Mv=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(_=>_.spec.styles.overrides),h=c.useSceneSelector(_=>(0,d.readStyleCoord)(_.spec)),p=c.useEditorStore(),m=Rt(),g=Ci(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),x=Uh(e.content),b=c.useEditorState(_=>_.caret?.editor??null),C=(0,Ce.useEditorState)({editor:b,selector:()=>pi(b)}),y=(0,Ce.useEditorState)({editor:b,selector:()=>mi(b)}),P=Pv(x.font??y),w=Lv(x.fontSize??C),k=c.useTextAnnotationTextColor(v),T=x.color??k,L=(0,f.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),M=(_,H)=>{const W=(0,d.findStyleRule)(u,{select:L},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:L,declarations:{...W,..._}}}),H)},E=(_,H)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:_}),H)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,N=(_,H)=>{const W=B(),U=p.getState().caret?.editor??null;if(U!==null&&!Fe(W)){U.chain().focus().setMark(He,_).run();return}E({content:qh(W,_)},H)},R=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},A=_=>M(Rv(_),{transient:!0}),j=_=>M({fillAlpha:_},{transient:!0}),S=v.fill!==gt,O=_=>N({color:_===d.AUTO_COLOR?void 0:_},{transient:!0}),z=_=>()=>{Fe(B())||te({font:_}),N({font:_}),m.close()},X=_=>()=>{Fe(B())||te({fontSize:_}),N({fontSize:_}),m.close()},te=_=>{const H=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:H,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:_.fontSize??C,pickedFont:_.font??y});W>e.width&&E({width:W})},K=_=>{const H=p.getState().caret?.editor??null;if(H===null||Fe(B())){E({content:Kh(B(),_)});return}const W=H.state.storedMarks;H.chain().focus().setTextAlign(_).command(({tr:U})=>(U.setStoredMarks(W),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,d.toPaintColor)(v.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:A,opacity:S?v.fillAlpha:void 0,onOpacityChange:S?j:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:S?(0,d.toPaintColor)(v.fill):Uu,opacity:S?v.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:x.color??d.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:O,...m.bind("color"),children:(0,r.jsx)(kv,{size:"sm",textColor:T,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:P?.fontFamily},children:"Aa"}),...m.bind("font"),children:Ji.map(_=>(0,r.jsx)(V.MenuItem,{selected:_.id===P?.id,onClick:z(_.id),children:(0,r.jsx)("span",{style:{fontFamily:_.fontFamily},children:s(_.key)})},_.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:Qi.map(_=>(0,r.jsx)(V.MenuItem,{selected:_.size===w?.size,onClick:X(_.size),children:(0,r.jsx)("span",{style:{fontSize:Iv(_.size)},children:s(_.key)})},_.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(Ov,{current:x.alignment??"center",onPick:K}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:R,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},Rv=e=>e==="transparent"?{fill:gt}:{fill:e,fillAlpha:Zu(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},Ov=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:Ev.map(a=>(0,r.jsx)(V.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:o(a.alignment),children:(0,r.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},_v=["left","right"];var es=({width:e})=>ee(60,e),Nv=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),ts=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,bounds:l})=>{if(a===0)return{at:e,width:t,shift:0};const u=(0,d.alignUnitFractions)(n).x,h=Dv(e.offset,s),p=gn({start:e.x+h-u*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...l===void 0?{}:{bounds:{min:l.minX,max:l.maxX}}}),m=p.start+u*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},ns=(e,t)=>e.at.x===t.at.x&&e.width===t.width,Dv=(e,t)=>e?.x===void 0?0:e.unit==="px"?ee(e.x,t):e.x,jt=(e,t)=>{const n=e.textAnnotations.find(o=>o.id===t);return n===void 0||n.at.anchorType!=="panel"?null:{at:n.at,width:n.width,align:n.align}},Fv=class extends Ke{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=jt(i,t);if(u===null)return null;const h=Xn(o,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...ts({...u,edge:n,delta:h,minWidth:es(s),panelWidth:s.width,bounds:he(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=jt(o().annotations,t);a===null||ns(a,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},Bv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Yi((s,l)=>new Fv({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Gv=4,zv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(l=>l.spec.annotations),s=(l,u)=>{const h=jt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...ts({...h,edge:l,delta:u,minWidth:es(t),panelWidth:t.width,bounds:he(t,n)})}};return Zi({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=Hv(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=jt(i,e);u===null||ns(u,l)||o.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},Hv=(e,t)=>{const n=ee(Gv,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},Vv=e=>{const t=We(),n=Wv(t),o=Uv(t),a=c.useEditorState(s=>s.caret?.annotationId===t),i=qv(e.panelRect,t,o.resized);return n===null||i===null?null:(0,r.jsx)($v,{annotation:n,textBox:i,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:n.at.anchorType==="panel",hasCaret:a,...e})},$v=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=Bv({annotationId:e.id,panelRect:s,frameElement:u}),m=zv({annotationId:e.id,panelRect:s,frameElement:u});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(Mv,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),a&&!o&&!i&&_v.map(g=>{const v=Nv(t,g);return(0,r.jsx)($i,{point:{x:s.x+v.x,y:s.y+v.y},label:h(`graph.annotations.textToolbar.resize.${g}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":g},dragHandlers:p(g),keyboardHandlers:m(g)},g)})]})},Wv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},Uv=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),qv=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,f.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:Ei(o,t,n,s)?.rect??null},Jn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],Kv=(e,t,n)=>c.readStampedEditTargetInStack(Jn(e,t),n),Xv="_1rpuha50";var mo=["pointerdown","mousedown","pointerup","mouseup","click"],rs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,Yv=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>Qv(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=o&&!t&&(e||n),s=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(!i)return;const l=a.getState();l.setHoverState(d.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,a]),(0,f.useEffect)(()=>{const l=s.current;if(l===null)return;const u=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=Zv(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(Jv(h)))};for(const h of mo)l.addEventListener(h,u);return()=>{for(const h of mo)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:Xv,"data-menu-shield":"","data-testid":"menu-shield"}):null},Zv=(e,t)=>Jn(e,t).find(n=>!rs(n))??null,Jv=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),Qv=e=>e==="arrow-draw"||e==="box-draw",e1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',t1=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,f.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Le(i.target,e,n)||vt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(e1)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(u=>u===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},n1=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,f.useEffect)(()=>{let a=null;const i=u=>{if(Ee(u.target))return;const{caret:h}=o.getState(),p=h===null?null:Kv(u.clientX,u.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=u=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Le(u.target,e,n)||p())},l=u=>{t.getState().selection.length!==0&&Le(u.target,e,n)&&u.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Le(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{a!==null&&cancelAnimationFrame(a),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[o,t,e,n])},r1=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],o=n?.items[e.part.itemIndex];if(n===void 0||o===void 0)return null;const a=o1(n,o.layerId,t.layers);return a===null?null:(0,d.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:s1(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},o1=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=a1(o,a);if(i!==null)return i}return null},a1=(e,t)=>{for(const n of e){const o=(0,d.readVariableName)(n.mapping[t]);if(o!==null&&i1(n,o))return{layer:n,variable:o}}return null},i1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",s1=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,d.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},l1=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,d.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(a),u=i?.intersects!==!1,h=(0,d.readBroadestObservationsScope)(s),p=u||!(0,d.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:o});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:u,target:g}}return null},c1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,d.findLayerById)(t,e.layerId);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},vn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const x=go(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:x.stamped,observations:null}),hover:null,elements:x.elements}}const l=a!==null&&n===a,u=l&&i?d1(a):null,h=u===null?null:u1(e,u,t),p=h===null?null:l1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=go(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?h:null,elements:g.elements}},d1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},go=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const u=e||o?Jn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=c.readStampedEditTargetInStack(u,i);return h===null?{stamped:null,elements:u}:{stamped:(h.kind==="annotation"?o:a&&l(h.target))?h:null,elements:u}},u1=(e,t,n)=>{const o=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},h1=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:u}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||u?.intersects!==!0)return null;const h=o.find(g=>g.id===l.layerId);if(h===void 0||$e(h,l.observation)||!p1(h.spatialKind))return null;const p=(0,d.readObservationIndex)(l),m=(0,d.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:a});return m===null||!i(m)?null:{target:m,observationIndex:p}},p1=e=>{switch(e){case"noop":return!1;case"points":return!0;case"buckets":case"filledBuckets":case"spannedBuckets":case"rects":case"cells":case"renderHitTest":return!0;default:return e}},vo="data-annotation-id",m1='[data-testid="pinnedNumber"], [data-testid="comment"]',xo=(e,t,n)=>{if(e.target instanceof Element){const o=fo(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=fo(o,t);if(a!==null)return a}return null},g1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(o=>o.id===t)??e.annotations.comments.find(o=>o.id===t);return n===void 0?null:v1(e,n.at.anchor.layerId,n.at.observationIndex)},fo=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(m1);if(n===null||!t.contains(n))return null;const o=e.closest(`[${vo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(vo);return a===null||a.length===0?null:a},v1=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},x1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},f1=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!yo(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(yo(t,e)){const{primary:l,intersection:u}=o.query((0,d.toPanelCursor)(i,t),{tolerance:x1,viewport:{width:t.width,height:t.height}}),h=l===null?void 0:a.find(m=>m.id===l.layerId),p=l!==null&&h!==void 0&&$e(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=Mi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:bo(i.x/t.width,s.minX,s.maxX),y:bo(i.y/t.height,s.minY,s.maxY)}},bo=(e,t,n)=>Math.min(Math.max(e,t),n),yo=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,b1=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:o})=>{switch(e?.kind){case"annotation":return e.target.id===o?{kind:"keep-caret"}:{kind:"select-annotation",target:e.target};case"axis":case"legend":case"grid":return{kind:"select-guide",target:e.target};case"observations":return y1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},y1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},S1=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,C1=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:u}=c.useGraphContext(),{engine:h}=c.useHoverContext(),p=c.useEditorStore(),m=c.useSceneSelector((0,se.useShallow)(M=>({spec:M.spec.annotations,layers:M.layers,coordSystem:M.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),x=c.usePaintedObservationBoxes(t),b=c.useGraphMode(),{selectGraphOnPress:C}=c.MODE_RULES[b],y=c.useLatestRef(C),P=c.useLatestRef(b===c.GRAPH_MODES.annotate),w=c.useLatestRef(b===c.GRAPH_MODES.annotate),k=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:x}),T=c.useLatestRef(o),L=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>L.current?.finish(!1),[]),(0,f.useEffect)(()=>s.subscribe(({selection:M})=>{const E=p.getState().pressedObservation,[B,...N]=M,R=B!==void 0&&N.length===0&&E!==null&&(0,d.areEditTargetsEqual)(B,E.selectedFor);E!==null&&!R&&p.getState().setPressedObservation(null)}),[p,s]),(0,f.useEffect)(()=>{const M=j=>vn({target:j.target,clientX:j.clientX,clientY:j.clientY},n()).targetAtPoint,E=j=>{if(!(j.target instanceof Element))return!1;const S=j.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return S!==null&&e.contains(S)&&c.readStampedEditTargetInStack([j.target],e)===null},B=(j,S)=>{if(L.current!==null||!c.canMoveAnnotationOnCanvas(k.current.spec,S.id))return;try{e.setPointerCapture(j.pointerId)}catch{return}j.preventDefault();const O=new Sg({handle:e,pointerId:j.pointerId,annotationId:S.id,press:{x:j.clientX,y:j.clientY},readInputs:()=>k.current,editorStore:p,engine:h,anchorResolver:u,dispatch:a.dispatch,onSettled:()=>{L.current=null}});L.current=O,O.start()},N=(j,S)=>{const O=s.getState(),{layers:z,config:X,coordSystem:te}=l.getState().scene,K=S.kind==="select-observations"&&S.observationIndex!==null?c.readPressedObservation(S.observationIndex,z,S.target,X.parsingLocale):null;if(p.getState().setPressedObservation(K),P.current&&(S.kind==="select-observations"||S.kind==="select-band")){const _=(0,d.findLayerById)(z,S.target.layerId);if(_!==void 0&&cm(_.geom,te.type)){const H=e.getBoundingClientRect(),W=Vn(e,H.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(S.target),x:(j.clientX-H.left)/W,y:(j.clientY-H.top)/W})}else p.getState().setAnnotatePress(null)}switch(S.kind){case"select-annotation":O.setSelection([S.target]),B(j,S.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":O.setSelection([S.target]);return;case"clear":O.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(S)}`})}},R=j=>{if(j.button!==0)return;if(rs(j.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Jt(j.target))return;const S=p.getState().caret?.annotationId??null,O=j.target instanceof Element?j.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ee(j.target)&&O!==S&&Wn(p,l.getState().scene.annotations,a.dispatch,$n(i));const z=p.getState().standingInteraction,X=$=>{p.getState().releaseInteraction($),p.getState().setPlotMenu(null),s.getState().clearSelection()},te=he(k.current.panelRect,k.current.frameElement),K=$=>{const Z=e.getBoundingClientRect();return $.x<Z.left||$.x>Z.right||$.y<Z.top||$.y>Z.bottom};if(z?.kind==="arrow-draw"){const $=n(),Z=$.captureRect?.getBoundingClientRect()??null,ae={x:j.clientX,y:j.clientY};if(K(ae)){X("arrow-draw");return}const je=c.readArrowEnd({client:ae,capture:Z,bounds:te,engine:$.engine,layers:$.scene.layers,start:z.start});if(je===null)return;a.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(z.heads),start:{anchorType:"panel",x:z.start.x,y:z.start.y},end:je}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(z?.kind==="box-draw"){const $=n().captureRect?.getBoundingClientRect()??null,Z={x:j.clientX,y:j.clientY};if(K(Z)){X("box-draw");return}const ae=c.readDrawnPanelPoint(Z,$,te);if(ae===null||$===null||c.isTinySpan(z.start,ae,$))return;a.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(z.start,ae)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),E(j)||c.isOnLiveGeomMark(j.target,e))return;const _=n(),H=vn({target:j.target,clientX:j.clientX,clientY:j.clientY},_);if(w.current){const $=xo(j,e,H.elements),Z=$===null?null:g1(l.getState().scene,$);if(Z?.observationIndex!==void 0){p.getState().setCaret(null),N(j,{kind:"select-observations",target:Z,observationIndex:Z.observationIndex});return}}const W=j.target instanceof Node&&e.contains(j.target),U=b1(H.targetAtPoint,{canSelectGraph:y.current&&!Ee(j.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(U.kind==="keep-caret")return;const ce=U.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some($=>$.id===U.target.id);if((U.kind==="clear"||ce)&&P.current){const $=n();if(j.target===$.captureRect){const Z=h1({client:{x:j.clientX,y:j.clientY},capture:$.captureRect?.getBoundingClientRect()??null,engine:$.engine,layers:$.scene.layers,parsingLocale:$.scene.config.parsingLocale,hasMenu:$.hasOverlayMenu});if(Z!==null){p.getState().setCaret(null),N(j,{kind:"select-observations",target:Z.target,observationIndex:Z.observationIndex});return}}}const de=_.scene.coordSystem.type==="polar"&&U.kind==="select-observations";if(W&&(U.kind==="clear"||de)&&w.current&&xo(j,e,H.elements)===null&&!w1(j.target,H.elements)){const $=f1({client:{x:j.clientX,y:j.clientY},capture:_.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:_.engine,layers:_.scene.layers});if($!==null){p.getState().setCaret(null),N(j,{kind:"clear"}),p.getState().setPlotMenu($);return}}p.getState().setCaret(null),N(j,U)},A=j=>{if(Jt(j.target)||E(j)||c.isOnLiveGeomMark(j.target,e))return;const S=M(j),{layers:O,guides:z,config:X}=l.getState().scene,{hasOverlayMenu:te}=n(),K=s.getState(),_=p.getState();switch(S?.kind){case"observations":{const{observations:H}=S,W=c1(H,O,X.parsingLocale);if(W===null||!te(W))return;const{observationIndex:U}=H;_.setPressedObservation({observationIndex:U,predicate:W.predicate,selectedFor:W}),K.setSelection([W]);return}case"axis":case"legend":{const H=r1(S,{layers:O,legends:z.legends.drawn,formattedAxes:T.current,parsingLocale:X.parsingLocale});if(H===null||!te(H))return;K.setSelection([H]);return}case"annotation":{const{target:H}=S;if(!k.current.spec.textAnnotations.some(W=>W.id===H.id))return;K.setSelection([H]),_.setCaret(H.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",R),document.addEventListener("dblclick",A),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("dblclick",A)}},[e,p,s,l,a,i,k,T,y,P,w,n,h,u])},w1=(e,t)=>Ee(e)||So(e)||t.some(So),So=e=>e instanceof Element&&e.closest(S1)!==null,j1=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:u}=c.useGraphAnimation(),h=Me(),p=i&&!u;return(0,f.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,o,s,a,p,n,l,t])},T1={kind:"idle"},A1=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=xp();return(0,f.useMemo)(()=>e!==null?e:t===null?T1:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},k1=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,P1=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),u=c.useLatestRef(n);(0,f.useEffect)(()=>{const h=v=>{if(o.getState().selection.length>0)return;const x=u.current,b=l.current,C={x:v.clientX-b.x,y:v.clientY-b.y},y=k1(C,x)?i.query((0,d.toPanelCursor)(C,x)):d.RESTING_HOVER_STATE;a.getState().setHoverState(y)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{Jt(v.target)||p&&o.getState().selection.length===0&&h(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[o,s,a,i,l,u])},L1=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,f.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,f.useEffect)(()=>{let s=null,l=null,u=!1;const h=P=>{if(!i)return;const w=a.getState();w.suspendsHover||P===null&&w.hover.primary===null||w.setHoverState(P??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const P=n.getState();if(lt(P.standingInteraction))return;if(u&&(u=!1,l={...l,target:I1(l)}),c.isOnLiveGeomMark(l.target,e)){P.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:k}=vn(l,t());P.setEditTargetUnderPointer(w),h(k)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(u=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},x=P=>{l={target:P.target,clientX:P.clientX,clientY:P.clientY},u=!1,m()},b=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},C=n.subscribe((P,w)=>{lt(w.standingInteraction)&&!lt(P.standingInteraction)&&g()}),y=o.subscribe((P,w)=>{P.scene!==w.scene&&(lt(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",x),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),C(),y(),e.removeEventListener("pointermove",x),e.removeEventListener("pointerleave",b),v()}},[e,n,o,a,i,t])},I1=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,lt=e=>{if(e===null)return!1;switch(e.kind){case"move-drag":case"shape-resize-drag":case"difference-arrow-endpoint-drag":case"arrow-endpoint-drag":case"text-resize-drag":return!0;case"arrow-draw":case"box-draw":case"chrome-popup":return!1}},E1=(e,t,n,o,a)=>{const i=A1(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=j1(e);L1(e,h),C1(e,n,h,a),P1(i,t,n),n1(e),E0(e),t1(e,o);const p=l&&u;(0,f.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,f.useEffect)(()=>{if(!l||!u)return;const m=s.getState();m.setHoverState(d.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,u])},M1=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,commands:s,store:l,history:u}=c.useGraphContext(),h=c.useEditorStore(),p=(0,f.useRef)(()=>{});(0,f.useEffect)(()=>{p.current=()=>{Wn(h,l.getState().scene.annotations,s.dispatch,$n(u))}},[s,h,u,l]);const m=a?.width??0,g=a?.height??0,v=(0,f.useRef)({width:m,height:g});(0,f.useEffect)(()=>{const y=v.current;v.current={width:m,height:g},!(y.width===m&&y.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const x=c.useEditorState(y=>y.caret?.annotationId??null),b=c.useGraphMode(),C=(0,f.useRef)(b);return(0,f.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,f.useEffect)(()=>()=>{p.current();const y=h.getState();y.setCaret(null),y.setPressedObservation(null),y.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,f.useEffect)(()=>{if(C.current===b)return;C.current=b,p.current();const y=h.getState();y.setCaret(null),y.setEditTargetUnderPointer(null),y.setPlotMenu(null),i.getState().clearSelection()},[b,h,i]),a===null?null:(0,r.jsxs)(el,{children:[x!==null&&(0,r.jsx)(R1,{annotationId:x,panelRect:t}),(0,r.jsx)(O1,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},R1=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,f.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},O1=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,f.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,f.useState)(null);return E1(e,a,n,i,o),(0,r.jsx)(_1,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},_1=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=kt(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Bp,{frameElement:e,frameSize:(0,f.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(wm,{frameRect:t}),(0,r.jsx)(v0,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:a,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rv,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(wv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Lg,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Vv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Mm,{panelRect:o}),(0,r.jsx)(lv,{frameElement:e,panelRect:o}),(0,r.jsx)(cv,{panelRect:o}),(0,r.jsx)(Wm,{panelRect:o}),(0,r.jsx)(Em,{panelRect:o}),(0,r.jsx)(zm,{panelRect:o})]}),(0,r.jsx)(Sm,{frameElement:e}),s&&(0,r.jsx)(K0,{frameElement:e,panelRect:o}),(0,r.jsx)(Yv,{})]})})]})},N1={},D1=({slots:e,palettePresets:t=N1,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,f.useMemo)(()=>({EditorSurface:M1,...e}),[e]);return(0,r.jsx)(Nn,{...a,children:(0,r.jsx)(yu,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(Jc,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:m0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},F1="_12lhx9e0",os=({children:e})=>(0,r.jsx)("div",{className:F1,children:e}),B1="_139ohwv0",ne=({children:e})=>(0,r.jsx)("div",{className:B1,children:e}),as=(0,f.createContext)(null),G1=as.Provider,is=()=>{const e=(0,f.useContext)(as);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},z1="_1jlczkt0",ss="data-graphy-editor-panel",H1={List:ne,Grid:os};function V1(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var $1=()=>()=>{},W1=e=>{const t=(0,f.useSyncExternalStore)(e?.subscribe??$1,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},U1=e=>{const t=(0,f.useContext)(c.GraphContext),n=c.useChartI18nProps(W1(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(q1,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(Nn,{...n,children:a})},Qn={Root:U1,Controls:H1},q1=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[u,h]=(0,f.useState)(()=>o?[o]:[]),p=(0,f.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(Pt.Provider,{value:i,children:(0,r.jsx)(la,{controls:n,children:(0,r.jsx)(G1,{value:p,children:(0,r.jsx)(De.Accordion.Root,{[ss]:"",className:(0,me.default)(z1,a,{[s]:!V1(a)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},K1="_2m7wuq0",X1=()=>(0,r.jsx)(Es.Separator,{className:K1}),Y1=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),er="_40zvwv0",tr="_40zvwv1",Z1="_40zvwv2",ls="_40zvwv3",J1="_40zvwv4 _40zvwv3";var Q1="_40zvwv6";var ex="_40zvwv8",Y=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(nx,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(tx,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:er,children:[(0,r.jsxs)("div",{className:tr,children:[(0,r.jsx)("span",{className:ls,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),o!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:o})]}),(0,r.jsx)("div",{children:i})]}),tx=({title:e,accessory:t,children:n})=>{const o=(0,f.useId)(),a=(0,f.useId)();return(0,r.jsx)("div",{className:er,children:(0,r.jsxs)("div",{className:tr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:J1,children:e}),(0,r.jsx)("span",{className:Q1,children:(0,r.jsx)(zo,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},nx=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(De.Accordion.Item,{value:e,className:er,onOpenChange:o,children:[(0,r.jsxs)(De.Accordion.Header,{className:tr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(De.Accordion.Trigger,{className:Z1,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:ls,children:e}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:n}),(0,r.jsx)("span",{className:ex,children:(0,r.jsx)(Y1,{size:"sm"})})]}),(0,r.jsx)(De.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},cs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=is(),{Switch:u}=F(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(Y,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:o,ariaLabel:e}),children:i})},rx={horizontal:["bottom","top"],vertical:["left","right"]},ox={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},ax={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},ht=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{NumberField:l,Switch:u,TextField:h,ToggleGroup:p}=F();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const m=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,g=i.scales[e],v=g?.spec,x=v?.scaleType==="continuous"?v:void 0;if(m==="circular"||m==="radial"&&x===void 0)return null;const b=v?.scaleType==="continuous"||v?.scaleType==="datetime",C=x!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),y=x?.transform==="log",P=x?.domainMax??null,w=ix(x),k=(D,ie)=>D.map(Ye=>({value:Ye,label:ie(Ye)})),T=i.guides.axes.find(D=>D.scaledAesthetic===e);if(T===void 0)return null;const L=T.position,M=i.guides.axes.filter(D=>D.scaledAesthetic===e),E=M.some(D=>D.visible),B=M.some(D=>D.visible||D.showGrid),N=e==="ySecondary"?i.config.axes.ySecondary?.label??T.label??"":i.config.axes[e].label??T.label??"",R=rx[L==="bottom"||L==="top"?"horizontal":"vertical"],A=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,j=A===null?void 0:(0,d.findLayerById)(i.spec.layers,A),S=i.guides.legends.drawn.some(D=>!D.inHeadlineRow&&R.some(ie=>ie===D.position)),O=R.map(D=>({value:D,label:s(ox[D])})),z=k(["auto","edges"],D=>s(D==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),X=k(["linear","log"],D=>s(D==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),te=k(["auto","zero","custom"],D=>s(D==="zero"?"editor.axesPanel.startFrom.zero":D==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),K=k(["auto","custom"],D=>s(D==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),_=k(["single","double"],D=>s(D==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),H=D=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:Xt(D,i.config.axes.y.visible)}));return}a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:D,keepSecondaryAxis:!0}))},W=D=>{a.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:D}),{transient:!0})},U=D=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:Xt(D,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:D,keepSecondaryAxis:!0}))},ce=D=>{const ie=D==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:Xt(ie,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:ie,keepSecondaryAxis:!0}))},de=D=>{a.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:D==="log"?"log":"linear"}))},$=D=>{a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,...D}),{transient:!0})},Z=D=>{D!==null&&$({domainMin:D})},ae=D=>{D!==null&&$({domainMax:D})},je=D=>{const ie=D==="auto"?null:D==="zero"?0:Co(g?.domain,"start");a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:ie}))},G=D=>{const ie=D==="custom"?Co(g?.domain,"end"):null;a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:ie}))},oe=D=>{j!==void 0&&a.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:j.id,yScaleType:D==="double"?"secondary":"primary"}))},ye=D=>{if(e==="ySecondary")return;const ie=R.find(Ye=>Ye===D);ie&&a.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:ie}))};return(0,r.jsx)(Y,{title:t??s(ax[e]),layout:n,preview:o,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:T.visible,onChange:H})}),j!==void 0&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(p,{value:j.yScaleType==="secondary"?"double":"single",options:_,onChange:oe})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[T.visible&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(h,{value:N,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:W,onCommit:a.commands.commit})}),E&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:T.showTicks,onChange:U})})]}),b&&B&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(p,{value:T.tickMode,options:z,onChange:ce})}),e!=="ySecondary"&&x&&m==="linear"&&T.visible&&!S&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(p,{value:T.position,options:O,onChange:ye})}),x&&!C&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(p,{value:y?"log":"linear",options:X,onChange:de})}),x&&!y&&(0,r.jsxs)(r.Fragment,{children:[!C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(p,{value:w,options:te,onChange:je})}),w!=="auto"&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:x.domainMin??null,onChange:Z,onCommit:a.commands.commit})})]}),(0,r.jsx)(I,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(p,{value:P===null?"auto":"custom",options:K,onChange:G})}),P!==null&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:P,onChange:ae,onCommit:a.commands.commit})})]})]})})},Xt=(e,t)=>e===t?void 0:e,ix=e=>{const t=e?.domainMin??null;return t===null?"auto":t===0?"zero":"custom"},Co=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return typeof n=="number"?n:0},nr=({value:e,onChange:t})=>{const n=q(),o=c.useI18n(),{TextField:a}=F(),i=e!==null&&typeof e!="string",s=l=>t(l===""?null:l);return(0,r.jsx)(I,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},ds=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(nr,{value:l.caption,onChange:h})]})})},wo=/^[a-z][a-z\d+.-]*:/i,sx={},us=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=h=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(lx,{source:l.source??sx})]})})},lx=({source:e})=>{const t=q(),n=c.useI18n(),{TextField:o}=F(),a=u=>{const h=(u.label??"")!==""||(u.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:h?u:null}),{transient:!0})},i=()=>{const u=e.url??"";u!==""&&!wo.test(u)&&a({...e,url:`https://${u}`}),t.commands.commit()},s=u=>a({...e,url:u}),l=u=>a({...e,label:u});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:wo.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},hs=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(nr,{value:l.subtitle,onChange:h})]})})},Xe=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,f.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,f.useMemo)(()=>e===null?null:n.readers(e),[e,n])},rr=(e,t,n)=>{const o=Xe(e);return(0,f.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,d.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},xn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],cx=xn.length/2,dx={select:{target:"graph"}},ps=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=F(),l=Xe(a);if(!a||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=xn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=xn.find(b=>`${b}`===g);if(v===void 0)return;const x=(0,d.findStyleRule)(a.spec.styles.overrides,dx,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,textScale:v}}}))};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:cx,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},ms=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(nr,{value:l.title,onChange:h})]})})},ux=({children:e,...t})=>(0,r.jsx)(Qn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ms,{}),(0,r.jsx)(hs,{}),(0,r.jsx)(ds,{}),(0,r.jsx)(us,{}),(0,r.jsx)(ps,{})]})}),hx=({children:e,...t})=>(0,r.jsx)(Qn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ht,{axis:"x"}),(0,r.jsx)(ht,{axis:"y"}),(0,r.jsx)(ht,{axis:"ySecondary"})]})}),Ot=e=>`${e}px`,gs=e=>`${Math.round(e*100)}%`,px=e=>`${e}°`,mx=24,gx={select:{target:"graph"}},jo=["dim","desaturate"],vx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=F(),u=Xe(a);if(!a||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(a.spec),m=jo.map(x=>({value:x,label:i(x==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=x=>{const b=(0,d.findStyleRule)(a.spec.styles.overrides,gx,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...b,cornerRadius:x}}}),{transient:!0})},v=x=>{const b=jo.find(C=>C===x);b&&o.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(Y,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:mx,step:1,formatValue:Ot,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},xx={none:0,md:3.5,full:6.5},fx=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:xx[e],stroke:"currentColor",strokeWidth:1.5})}),bx=.05,To=["none","md","full"],vs={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},yx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=F(),u=a?(0,d.findLayerByGeom)(a.spec.layers,"bar"):void 0,h=rr(a,u?.id??null,"bar");if(!a||!u||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=b=>{o.commands.dispatch(new d.SetBarWidthCommand({layerId:u.id,width:b}),{transient:!0})},m=h?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,g=(b,C)=>{const y=To.find(k=>k===C);if(!y)return;const[P,w]=vs[b];o.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[P]:y,[w]:y}}))},v=To.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(fx,{cornerRadius:b})})),x=(0,d.resolveBarBandFraction)(u.params,a.coordSystem.type);return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:x,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:bx,formatValue:gs,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:Ao(m,"tip"),options:v,onChange:b=>g("tip",b)})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:Ao(m,"base"),options:v,onChange:b=>g("base",b)})})]})})},Ao=(e,t)=>{const[n,o]=vs[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},_t=({children:e})=>{const t=(0,f.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},Nt="qdaoth0",Sx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M12.0591 7.11C11.5767 7.11 11.1857 6.71899 11.1857 6.23664C11.1857 5.7543 11.5767 5.36328 12.0591 5.36328H24.8684C25.3507 5.36328 25.7417 5.7543 25.7417 6.23664V19.0459C25.7417 19.5283 25.3507 19.9193 24.8684 19.9193C24.386 19.9193 23.995 19.5283 23.995 19.0459V8.34512L6.8542 25.4859C6.51313 25.827 5.96015 25.827 5.61908 25.4859C5.27801 25.1448 5.27801 24.5919 5.61908 24.2508L22.7599 7.11H12.0591Z"})]}),Cx=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(_t,{children:[(0,r.jsx)("path",{className:Nt,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,r.jsx)("path",{fill:"currentColor",d:"M24.25 9C24.25 8.30964 23.6904 7.75 23 7.75H9C8.30964 7.75 7.75 8.30964 7.75 9V23C7.75 23.6904 8.30964 24.25 9 24.25H23C23.6904 24.25 24.25 23.6904 24.25 23V9ZM25.75 23C25.75 24.5188 24.5188 25.75 23 25.75H9C7.48122 25.75 6.25 24.5188 6.25 23V9C6.25 7.48122 7.48122 6.25 9 6.25H23C24.5188 6.25 25.75 7.48122 25.75 9V23Z"})]})}),wx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,r.jsx)("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M25.25 22C25.25 20.7574 24.2426 19.75 23 19.75C21.7574 19.75 20.75 20.7574 20.75 22C20.75 23.2426 21.7574 24.25 23 24.25C24.2426 24.25 25.25 23.2426 25.25 22ZM23 18.25C25.0711 18.25 26.75 19.9289 26.75 22C26.75 24.0711 25.0711 25.75 23 25.75C20.9289 25.75 19.25 24.0711 19.25 22C19.25 19.9289 20.9289 18.25 23 18.25ZM11.25 9C11.25 7.75736 10.2426 6.75 9 6.75C7.75736 6.75 6.75 7.75736 6.75 9C6.75 10.2426 7.75736 11.25 9 11.25C10.2426 11.25 11.25 10.2426 11.25 9ZM9.75 12.675C11.4617 12.3275 12.75 10.8142 12.75 9C12.75 6.92893 11.0711 5.25 9 5.25C6.92893 5.25 5.25 6.92893 5.25 9C5.25 10.8142 6.53832 12.3275 8.25 12.675L8.25 24C8.25 24.4142 8.58579 24.75 9 24.75L16 24.75C16.4142 24.75 16.75 24.4142 16.75 24L16.75 7.75L22.25 7.75L22.25 14.1893L21.0303 12.9697C20.7374 12.6768 20.2626 12.6768 19.9697 12.9697C19.6768 13.2626 19.6768 13.7374 19.9697 14.0303L22.4697 16.5303C22.7626 16.8232 23.2374 16.8232 23.5303 16.5303L26.0303 14.0303C26.3232 13.7374 26.3232 13.2626 26.0303 12.9697C25.7374 12.6768 25.2626 12.6768 24.9697 12.9697L23.75 14.1893L23.75 7C23.75 6.58579 23.4142 6.25 23 6.25L16 6.25C15.5858 6.25 15.25 6.58579 15.25 7L15.25 23.25L9.75 23.25L9.75 12.675Z"})]}),jx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M8.41371 5H20.7271C21.1595 5 21.5325 5 21.8398 5.02507C22.1641 5.05157 22.4867 5.11007 22.7971 5.26822C23.2601 5.50416 23.6366 5.88064 23.8726 6.3437C24.0307 6.65409 24.0892 6.97666 24.1157 7.30097C24.1408 7.60823 24.1408 7.98127 24.1408 8.41369V9.10155C24.1408 9.55465 23.7735 9.92195 23.3205 9.92195C22.8674 9.92195 22.5001 9.55465 22.5001 9.10155V8.44533C22.5001 7.97237 22.4995 7.66699 22.4805 7.43457C22.4623 7.21172 22.4314 7.12909 22.4107 7.08853C22.3321 6.93418 22.2066 6.80869 22.0522 6.73004C22.0117 6.70938 21.9291 6.67847 21.7062 6.66026C21.4738 6.64127 21.1684 6.64063 20.6954 6.64063H15.3907V24.6877H20.0392C20.4922 24.6877 20.8595 25.0549 20.8595 25.508C20.8595 25.961 20.4922 26.3283 20.0392 26.3283H9.10159C8.64854 26.3283 8.28127 25.961 8.28127 25.508C8.28127 25.0549 8.64854 24.6877 9.10159 24.6877H13.7501V6.64063H8.44533C7.97238 6.64063 7.66699 6.64127 7.43457 6.66026C7.21172 6.67847 7.1291 6.70938 7.08854 6.73004C6.93418 6.80869 6.80869 6.93418 6.73004 7.08853C6.70938 7.12909 6.67847 7.21172 6.66026 7.43457C6.64127 7.66699 6.64063 7.97237 6.64063 8.44533V9.10155C6.64063 9.55465 6.27337 9.92195 5.82032 9.92195C5.36727 9.92195 5 9.55465 5 9.10155V8.41371C5 7.98128 5 7.60823 5.02508 7.30097C5.05157 6.97666 5.11007 6.65409 5.26823 6.3437C5.50417 5.88064 5.88064 5.50416 6.3437 5.26822C6.65409 5.11007 6.97666 5.05157 7.30097 5.02507C7.60824 5 7.98129 5 8.41371 5Z"})]}),Tx={x:.5,y:.5},Ax=.2,kx={x:.375,y:.25,width:.25,height:.5},Px={zOrder:"background"},Lx={x:.4,y:.6},Ix={x:.6,y:.4},Ex="relativeDifference",Mx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=F();if(!a)return null;const l=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Rx(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Tx},width:Ax}}))},u=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...Lx},end:{anchorType:"panel",...Ix}}}))},h=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Px,region:{anchorType:"panel",...kx}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:Ex}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(Y,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(os,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(jx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Sx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Cx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(wx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Rx=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Ox=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=F();if(!a)return null;const l=(0,d.readGraphType)(a.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const u=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=d.COMBO_TYPES.find(g=>g===p);m&&o.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:u,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},_x=.1,Nx=20,Dx=({title:e,preview:t})=>{const n=q(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=F();if(!o||o.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(o.spec.layers),u=e??a("editor.annotationsPanel.goalSection.title"),h=(0,d.readConstantValue)(l?.mapping.y),p=typeof h=="number"?h:null,m=x=>{const b=new d.ToggleGoalLineCommand({showGoalLine:x,value:Fx(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(b)},g=x=>{if(l===void 0)return;const b=new d.SetRuleLabelCommand({layerId:l.id,label:x===""?null:x});n.commands.dispatch(b,{transient:!0})},v=x=>{if(l===void 0||x===null)return;const b=new d.SetRuleValueCommand({layerId:l.id,value:x});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(cs,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(I,{label:a("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:a("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},Fx=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),o=n-Math.min(...t),a=o>0?o:Math.abs(n);if(a===0)return 0;const i=Math.min(Nx,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*_x).toFixed(i))},ko=["auto","inside","outside"],Bx=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:u}=F();if(!i)return null;const h=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:x}=h.dataLabels,b=ua(h,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const C=T=>{const L=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});a.commands.dispatch(L)},y=T=>{const L=ko.find(M=>M===T);L!==void 0&&a.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:L}))},P=T=>{const L=new d.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});a.commands.dispatch(L)},w=T=>{const L=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});a.commands.dispatch(L)},k=T=>{const L=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});a.commands.dispatch(L)};return(0,r.jsx)(Y,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:C})}),b.supportsPosition&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:x,options:ko.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:y})}),b.supportsPercentages&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:P})}),b.supportsStackTotals&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:k})})]})})},Gx=3,zx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=F(),l=(0,f.useMemo)(()=>Ge.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!ma(v,a?.spec)})),[i,a]);if(!a)return null;const u=(0,d.readGraphType)(a.spec),h=xt(u),p=m=>{const g=Ge.find(v=>v.name===m);g&&o.commands.dispatch(new d.SetGraphTypeCommand(ga(g.summary,u)))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(h===null?void 0:i(`editor.graphTypes.${h.name}`)),children:(0,r.jsx)(s,{value:h?.name??"",options:l,columns:Gx,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Hx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=F(),h=Xe(a),p=a!==null&&h!==null?ka(a,h):null;if(p===null)return null;const m=p.axes.filter(y=>y.supportsGrid);if(m.length===0)return null;const g=p.axes.some(y=>y.showGrid),v=yt.map(y=>({value:y,label:i(`editor.graphPanel.gridSection.lineStyles.${y}`)})),x=y=>P=>{o.commands.dispatch(new d.SetGridVisibilityCommand({axis:y,visible:P}))},b=y=>{const P=yt.find(w=>w===y);P!==void 0&&o.commands.dispatch(Pa(P))},C=y=>{o.commands.dispatch(La(y),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[m.map(y=>(0,r.jsx)(I,{label:i(Vx(y)),children:(0,r.jsx)(l,{checked:y.showGrid,onChange:x(y.scaledAesthetic)})},y.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:b})}),(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Ot,onChange:C,onCommit:o.commands.commit})})]})]})})},Vx=e=>e.geometry==="radial"?"editor.graphPanel.gridSection.rings":e.geometry==="circular"?"editor.graphPanel.gridSection.spokes":e.scaledAesthetic==="x"?"editor.graphPanel.gridSection.verticalGridLines":"editor.graphPanel.gridSection.horizontalGridLines",$x="total",xs=["total","average","current"],Wx=["total"],Po=["previous","first"],Lo=["auto","small","medium","large"],Ux=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=F();if(!a)return null;const u=a.config.headline,h=u.show!=="none",p=a.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(N=>N.summary.grandTotal!==void 0);if(m&&!v)return null;const x=m?Wx:xs,b=a.guides.headline,C=b?.kind==="perGroup"&&b.items.some(N=>N.comparison!==null),y=x.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.metrics.${N}`)})),P=Po.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.comparison.${N}`)})),w=Lo.map(N=>({value:N,label:i(N==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${N}`)})),k=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=N=>{o.commands.dispatch(new d.SetHeadlineShowCommand({show:N?$x:"none"}))},L=N=>{const R=x.find(A=>A===N);R&&o.commands.dispatch(new d.SetHeadlineShowCommand({show:R}))},M=N=>{const R=Po.find(A=>A===N);R&&o.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:R}))},E=N=>{const R=Lo.find(A=>A===N);R&&o.commands.dispatch(new d.SetHeadlineSizeCommand({size:R}))},B=N=>{o.commands.dispatch(new d.SetHeadlinePositionCommand({position:N==="center"?"center":"above"}))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??qx(i,u.show),children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:h,onChange:T})}),h&&(0,r.jsxs)(r.Fragment,{children:[y.length>1&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:y,onChange:L})}),C&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:P,onChange:M})}),(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:w,onChange:E})}),g&&(0,r.jsx)(I,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:k,onChange:B})})]})]})})},qx=(e,t)=>{const n=xs.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Yt=["top","bottom","left","right","none"],Io=["auto","start","center","end"],Kx={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Eo=["auto","pill","direct"],Xx=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=F(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??Yt,m=i.guides.legends.drawn[0],g=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",x=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(v||!x))return null;const b=m?.position??"none",C=h==="auto"?b:h,y=Yt.filter(j=>j===C||p.includes(j)).map(j=>({value:j,label:s(`editor.graphPanel.legendSection.${j}`)})),P=j=>{const S=Yt.find(O=>O===j);S&&a.commands.dispatch(new d.SetLegendPositionCommand({position:S}))},w=j=>{const S=Io.find(O=>O===j);S&&a.commands.dispatch(new d.SetLegendAlignCommand({align:S}))},k=j=>{const S=Eo.find(O=>O===j);S&&a.commands.dispatch(new d.SetLegendDisplayCommand({display:S}))},T=m?.position==="left"||m?.position==="right"?"column":"row",L=T==="row"?"ltr":u,M=j=>s(j==="start"||j==="end"?`editor.graphPanel.legendSection.${Kx[T][j]}`:`editor.graphPanel.legendSection.align.${j}`),E=Io.map(j=>({value:j,label:M(j)})),B=Eo.map(j=>({value:j,label:s(`editor.graphPanel.legendSection.display.${j}`)})),N=t??s("editor.graphPanel.legendSection.title"),R=y.find(j=>j.value===C)?.label,A=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(Y,{title:N,layout:n,preview:o??R,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:C,options:y,onChange:P})}),A&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Sn.DirectionProvider,{direction:L,children:(0,r.jsx)("div",{dir:L,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:E,onChange:w})})})}),g&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:k})})]})})},Yx=1,Zx=20,Jx=.5,fs=({layerId:e})=>{const t=q(),n=c.useHandleScene(t),{Slider:o}=F(),a=rr(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(u=>(a?.get("size",u)??0)>0)??void 0,s=a?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=u=>{const h=new d.SetPointSizeCommand({layerId:e,size:u});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(o,{value:s,min:Yx,max:Zx,step:Jx,formatValue:Ot,onChange:l,onCommit:t.commands.commit})},bs=({layerId:e})=>{const t=q(),n=c.useHandleScene(t),o=rr(n,e,"point");return n?(0,r.jsx)(Pn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},Qx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=F(),p=Xe(a),m=(0,d.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?kn(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(T=>({value:T,label:ha(i,T)})),x=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],b=T=>{o.commands.dispatch(new d.ToggleLinePointsCommand({layerId:g.layerId,showPoints:T}))},C=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,showFill:T,drawnFillAlpha:g.drawnFillAlpha}))},y=T=>{o.commands.dispatch(new d.SetLineCurveCommand({layerId:g.layerId,curve:T?"smooth":"linear"}))},P=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T==="custom"?g.strokeWidth:null}))},w=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T}),{transient:!0})},k=T=>{const L=en.find(M=>M===T);L&&o.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:L}))};return(0,r.jsx)(Y,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(I,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(fs,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(bs,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:C})}),g.smooth!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:y})}),(0,r.jsx)(I,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:x,onChange:P})}),g.widthMode==="custom"&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Ot,onChange:w,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(I,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:k})})]})})},fn="\0none",ef=["x","y","color","size","label"],tf={x:"editor.graphPanel.mappingSection.x",y:"editor.graphPanel.mappingSection.y",color:"editor.graphPanel.mappingSection.color",size:"editor.graphPanel.mappingSection.size",label:"editor.graphPanel.mappingSection.label"},nf=({title:e,layout:t="collapsible"})=>{const n=q(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=F(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,u=(0,f.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,ef).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:a(tf[h]),value:g??(m?null:fn),options:rf(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===fn?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(Y,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(ne,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(I,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},rf=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:fn,label:n}],...o.map(a=>({value:a,label:a}))]},of="k",af=2,sf=0,lf=5,bn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],cf=["auto","none"],df=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=F();if(!a)return null;const{abbreviation:u,decimals:h}=a.config.numberFormat,p=uf(u)!==void 0,m=h!=="auto",g=w=>w.map(k=>({value:k,label:i(`editor.graphPanel.numberFormat.options.${k}`)})),v=bn.map(({value:w,labelKey:k})=>({value:w,label:i(`common.abbreviations.${k}`)})),x=w=>{o.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const k=cf.find(T=>T===w);x(k??of)},C=w=>{const k=bn.find(T=>T.value===w);k&&x(k.value)},y=w=>{o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w==="custom"?af:"auto"}))},P=w=>{w!==null&&o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":u,options:g(["auto","none","custom"]),onChange:b})}),p&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:C})}),(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:y})}),m&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:sf,max:lf,onChange:P,onCommit:o.commands.commit})})]})})},uf=e=>bn.find(t=>t.value===e),hf=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(q()),a=c.useI18n();if(!o)return null;const i=pf(o.spec.layers);return i?(0,r.jsx)(Y,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(fs,{layerId:i.id})}),(0,r.jsx)(bs,{layerId:i.id})]})}):null},pf=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},mf=.9,gf=360,vf=.05,xf=15,ff=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=F();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:u}=a.spec.coords.params,h=m=>{o.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{o.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:mf,step:vf,formatValue:gs,onChange:h,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:gf-1,step:xf,formatValue:px,onChange:p,onCommit:o.commands.commit})})]})})},bf=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),Mo=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),Ro=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],yf="linear",Sf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=F(),{options:u,findValue:h}=It(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(a.spec.layers),m=(0,d.findAverageLineLayer)(a.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:yf,v=Cf(m),x=Ro.map(k=>({value:k,label:i(`editor.annotationsPanel.trendType.options.${k}`)})),b=(k,T={})=>{const L=p??m,M=new d.SetStatLineCommand({line:k,...T,...L!==void 0&&{layerId:L.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(M)},C=k=>b(k?"trend":"none",{method:g}),y=k=>b(k?"average":"none",{group:v??h(u[0]?.value??"")}),P=k=>{const T=Ro.find(L=>L===k);T!==void 0&&b("trend",{method:T})},w=k=>{const T=k===null?void 0:h(k);T!==void 0&&b("average",{group:T})};return(0,r.jsx)(Y,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Mo,{size:"lg"}),children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Mo,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:C})}),p!==void 0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:x,onChange:P,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(bf,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:y})}),m!==void 0&&u.length>0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:u,onChange:w,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},Cf=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=vx;exports.AxesPanel=hx;exports.AxisEditMenu=Tn;exports.AxisSection=ht;exports.BarEditMenu=An;exports.BarSection=yx;exports.Button=$o;exports.CalloutsSection=Mx;exports.CaptionSection=ds;exports.ChartEditMenu=In;exports.ColorRow=ge;exports.ColorSwatches=Ko;exports.ComboSection=Ox;exports.ControlRegistryProvider=la;exports.ControlTooltip=we;exports.CustomColor=Yo;exports.EditableGraphRenderer=D1;exports.EditorIntlProvider=Nn;exports.EditorPanel=Qn;exports.ElementsPanel=ux;exports.FileInput=Zo;exports.GoalSection=Dx;exports.GraphOptionsSection=Bx;exports.GraphTypeSection=zx;exports.GridEditMenu=En;exports.GridSection=Hx;exports.HeadlineSection=Ux;exports.LegendEditMenu=Ia;exports.LegendSection=Xx;exports.LineEditMenu=St;exports.LineSection=Qx;exports.MappingSection=nf;exports.NumberField=ea;exports.NumberFormatSection=df;exports.PANEL_ROOT_ATTRIBUTE=ss;exports.PaletteRow=ja;exports.PointEditMenu=On;exports.PointSection=hf;exports.PolarSection=ff;exports.RadioGrid=ta;exports.Row=I;exports.Section=Y;exports.Select=ra;exports.Separator=X1;exports.Slider=oa;exports.SourceSection=us;exports.SubtitleSection=hs;exports.Switch=aa;exports.TextField=ia;exports.TextSizeSection=ps;exports.TitleSection=ms;exports.ToggleGroup=jn;exports.ToggledSection=cs;exports.TrendsAndAveragesSection=Sf;exports.useAnnotateAnchor=Bo;exports.useControls=F;exports.usePanelExpansion=is;exports.usePanelGraph=q;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-YZK8ZBRh.cjs");let d=require("@graphysdk/viz-engine"),x=require("react"),r=require("react/jsx-runtime"),Ss=require("motion/react"),se=require("zustand/react/shallow"),pe=require("lodash-es"),ve=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let Re=require("@floating-ui/react-dom"),yn=require("react-dom"),le=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),or=require("react-colorful"),ar=require("@base-ui/react/number-field"),_o=require("@base-ui/react/radio"),No=require("@base-ui/react/radio-group"),ue=require("@base-ui/react/select"),Oe=require("@base-ui/react/slider"),ir=require("@base-ui/react/switch"),Cs=require("@base-ui/react/input"),Sn=require("@base-ui/react/direction-provider"),Do=require("@tiptap/core"),ws=require("@tiptap/extension-bold"),pt=require("@tiptap/extension-document"),js=require("@tiptap/extension-hard-break"),Ts=require("@tiptap/extension-heading"),As=require("@tiptap/extension-italic"),ks=require("@tiptap/extension-link"),Ps=require("@tiptap/extension-text"),Ls=require("@tiptap/extension-text-align"),mt=require("@tiptap/extension-text-style"),Is=require("@tiptap/extension-underline"),Tt=require("@tiptap/extensions"),Fo=require("@tiptap/extension-paragraph"),Ce=require("@tiptap/react"),xe=require("@base-ui/react/toolbar"),re=require("@base-ui/react/menu"),Es=require("@base-ui/react/toggle"),De=require("@base-ui/react/accordion"),Ms=require("@base-ui/react/separator");var Bo=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,d.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),a=o===void 0?void 0:n.data.getAt(o);if(a==null)return null;const i=(0,d.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,at:i}},Go=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,x.useMemo)(()=>Bo(e,t),[e,t])},Rs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Os=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),_s=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ns=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ds=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Fs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ve=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),zo=(0,x.createContext)(null),Ho=({labelId:e,controlId:t,children:n})=>{const o=(0,x.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(zo.Provider,{value:o,children:n})},be=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,x.useContext)(zo),i=(0,x.useId)(),[s]=(0,x.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),u=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...u!==void 0&&{"aria-labelledby":u}}},fe="_18ja6qr0",Cn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,x.useMemo)(()=>(0,ve.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Vo="srewh00",Bs="srewh01",Gs={pointer:null,focus:null,last:"pointer"},$o=(0,x.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),Zt=({className:e,children:t})=>{const[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(!1),[s,l]=(0,x.useState)(Gs),u=(0,x.useCallback)((f,y)=>{i(!1),l(S=>({...S,[y]:f,last:y}))},[]),h=(0,x.useCallback)((f,y)=>{l(S=>S[y]===f?{...S,[y]:null}:S)},[]),p=(0,x.useCallback)(()=>i(!0),[]),m=zs(s),g=(0,x.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:m,reach:u,release:h,dismiss:p}),[n,a,m,u,h,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)($o.Provider,{value:g,children:t})})},we=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,children:i})=>{const{hovered:s,dismissed:l,reachedTooltipId:u,reach:h,release:p,dismiss:m}=(0,x.useContext)($o),g=(0,x.useId)(),[v,f]=(0,x.useState)(!1),y=s?!l&&(u===g||t&&u===null):v;(0,x.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const S=(C,k)=>{k.reason==="escape-key"&&(m(),k.allowPropagation()),f(C)};return(0,r.jsxs)(le.Tooltip.Root,{open:y,onOpenChange:S,disableHoverablePopup:!0,children:[(0,r.jsx)(le.Tooltip.Trigger,{render:i,delay:o,...a?{"aria-label":e}:{},onPointerEnter:C=>C.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(le.Tooltip.Positioner,{side:n,sideOffset:6,className:Bs,children:(0,r.jsx)(le.Tooltip.Popup,{className:Vo,children:e})})})})]})},zs=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Hs="woi4bh0",Vs="woi4bh1";var $s={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Wo=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:u,onPointerEnter:h,onPointerLeave:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=be({id:v,ariaLabel:m,ariaLabelledBy:g}),y=o==="tile",S=(0,r.jsxs)("button",{type:"button",className:$s[o],disabled:i,"aria-expanded":a,onClick:n,onPointerEnter:h,onPointerLeave:p,...f,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:y?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Ve,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(we,{label:u,side:s,delay:l,nameTrigger:!1,children:S}):o==="icon"&&m!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(we,{label:m,side:s,delay:l,children:S}):S},sr={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%))",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)"},Ws="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))",Us="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Uo="_14ty2ng0",lr="_14ty2ng1",qs="_14ty2ng2",Ks="_14ty2ng3",qo="_14ty2ng4",Xs="_14ty2ng5",Ys="_14ty2ng6",gt="transparent",Ko=e=>e==="transparent"?{background:Ws,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:Us,border:`1px solid ${sr.border}`}:{background:e,border:`1px solid ${sr.border}`},Xo=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:u,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),f=be({id:p,ariaLabel:m,ariaLabelledBy:g},!1),y=a!==void 0||i,S=C=>{const k=C==="transparent"?v("graph.colorDropdown.transparent"):C,w=s?.[C],A=(0,r.jsx)("button",{type:"button","aria-label":w??k,className:Ks,"data-active":wn(C,n),disabled:h,onMouseDown:j=>j.preventDefault(),onClick:()=>o(C),children:(0,r.jsx)("span",{className:qo,style:Ko(C)})},C);return w===void 0?A:(0,r.jsx)(we,{label:w,side:l,delay:u,children:A},C)};return(0,r.jsxs)("div",{className:Uo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:qs,...f,children:[t.map(S),y&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},wn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),Zs="data-graphy-chart-chrome",Js="data-graphy-chart-menu",Qs={[Js]:""},At=e=>({[Zs]:e}),Be=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,vt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Jt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Le=(e,t,n)=>e instanceof Node&&(t.contains(e)||Be(e,n)),el="cml7ha0",Yo=(0,x.createContext)(null),tl=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,x.useState)(c.resolvePortalContainer),[o,a]=(0,x.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,yn.createPortal)((0,r.jsx)("div",{ref:a,className:el,...At(t)}),n),(0,r.jsx)(Yo.Provider,{value:o,children:e})]})},kt=()=>(0,x.useContext)(Yo),nl="_178jeit0",rl="_178jeit1 _14ty2ng3",ol="_178jeit2 _14ty2ng4",al="_178jeit3",il="_178jeit4",sl="_178jeit5",ll="_178jeit6",cl="_178jeit7",dl={side:"flip",align:"shift",fallbackAxisSide:"end"},Zo=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=kt(),[l,u]=(0,x.useState)(!1),h=g=>{u(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:h,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:rl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:ol})}):(0,r.jsxs)("div",{className:Uo,children:[(0,r.jsx)("div",{className:lr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:al,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:qo,style:Ko(p)}),(0,r.jsx)("span",{className:il,children:m})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:dl,collisionPadding:12,disableAnchorTracking:a==="chip",className:nl,children:(0,r.jsxs)(Q.Popover.Popup,{className:sl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:lr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(or.HexColorPicker,{color:m,onChange:t,className:ll}),(0,r.jsx)(or.HexColorInput,{color:m,onChange:t,prefixed:!0,className:cl,onMouseDown:g=>g.stopPropagation()})]})})})})]})},cr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),ul="a1l6m80 woi4bh6 woi4bh5",hl="a1l6m81 _14ty2ng3",pl="a1l6m82",Jo=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,x.useId)(),l=a??s,u=i==="chip",h=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":u?e:void 0,className:pl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(we,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:hl,children:[(0,r.jsx)(cr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:ul,children:[(0,r.jsx)("span",{className:Hs,children:(0,r.jsx)(cr,{})}),(0,r.jsx)("span",{className:Vs,children:e}),h]})},Pt=(0,x.createContext)(null),q=()=>{const e=(0,x.useContext)(Pt);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},Qo=({children:e,onKeyDown:t,...n})=>{const o=(0,x.useContext)(Pt),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?o.undo():o.redo())};return(0,r.jsx)("div",{onKeyDown:a,...n,children:e})},ea="keyboard",Lt=e=>{const t=(0,x.useRef)(!1),n=(0,x.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},ml="eh8dvc0",gl="eh8dvc1 uz3g760",vl="eh8dvc2 uz3g761";var ta=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:u,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=be({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:y,gestureHandlers:S}=Lt(n);return(0,r.jsx)(ar.NumberField.Root,{className:ml,value:e,onValueChange:C=>t(C),onValueCommitted:(C,k)=>{y(k.reason===ea)},min:o,max:a,step:i,disabled:h,children:(0,r.jsxs)(Qo,{className:gl,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(ar.NumberField.Input,{className:vl,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},fl="_1b7s5f0",Te={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},xl="_1b7s5f7";var bl=6,na=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=be({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",y=i==="chip",{commitAfterChange:S,gestureHandlers:C}=Lt(o);return(0,r.jsx)(No.RadioGroup,{className:(0,me.default)(fl,yl(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",y&&"_1b7s5fd"),value:t,onValueChange:k=>{n(k),S()},...C,disabled:s,...p,children:e.map(k=>{const w=(0,r.jsxs)(_o.Radio.Root,{value:k.value,disabled:k.disabled,className:(0,me.default)(xl,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",y&&"_1b7s5fe"),style:{gridRow:k.gridRow,gridColumn:k.gridColumn},"aria-label":m?void 0:k.label,children:[k.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:k.label})]},k.value);if(!g&&!v&&!y)return w;const A=(v||y)&&k.value===t;return(0,r.jsx)(we,{label:k.label,checked:A,children:w},k.value)})})},yl=e=>{switch(Math.min(Math.max(Math.round(e),1),bl)){case 1:return Te[1];case 2:return Te[2];case 3:return Te[3];case 4:return Te[4];case 5:return Te[5];default:return Te[6]}},ra=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),Sl="_1g5x15w0 uz3g760",Cl="_1g5x15w1",wl="_1g5x15w2",dr="_1g5x15w3",jl="_1g5x15w4",Tl="_1g5x15w5",Al="_1g5x15w6",kl="_1g5x15w7";var oa=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=be({id:u,ariaLabel:s,ariaLabelledBy:l}),p=kt();return(0,r.jsxs)(ue.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(ue.Select.Trigger,{className:Sl,"data-error":i===!0,...h,children:[(0,r.jsx)(ue.Select.Value,{className:Cl,children:m=>Pl(e,m,o)}),(0,r.jsx)(ue.Select.Icon,{className:dr,children:(0,r.jsx)(Ve,{size:"sm"})})]}),(0,r.jsx)(ue.Select.Portal,{container:p??c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ue.Select.Positioner,{className:jl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(ue.Select.Popup,{className:Tl,children:e.map(m=>(0,r.jsxs)(ue.Select.Item,{value:m.value,disabled:m.disabled,className:Al,children:[m.icon,(0,r.jsxs)("span",{className:kl,children:[(0,r.jsx)(ue.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(ue.Select.ItemIndicator,{className:dr,children:(0,r.jsx)(ra,{size:"sm"})})]},m.value))})})})})]})},Pl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:wl,children:n}):Ll(e,t),Ll=(e,t)=>e.find(n=>n.value===t)?.label??t,Il="vod76w0",El="vod76w1",Ml="vod76w2",Rl="vod76w3",Ol="vod76w4",_l="vod76w5";var aa=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:u=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=be({ariaLabel:p,ariaLabelledBy:m},!1),v=Nl(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:y}=Lt(n);return(0,r.jsxs)("div",{className:Il,children:[(0,r.jsx)(Oe.Slider.Root,{className:El,value:e,onValueChange:S=>t(S),onValueCommitted:(S,C)=>{f(C.reason===ea)},min:o,max:a,step:i,disabled:h,children:(0,r.jsx)(Oe.Slider.Control,{className:Ml,children:(0,r.jsxs)(Oe.Slider.Track,{className:Rl,children:[(0,r.jsx)(Oe.Slider.Indicator,{className:Ol}),(0,r.jsx)(Oe.Slider.Thumb,{className:_l,...y,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Nl=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Dl="_1hyrlw60",Fl="_1hyrlw61",ia=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=be({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(ir.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:Dl,...s,children:(0,r.jsx)(ir.Switch.Thumb,{className:Fl})})},Bl="uz3g761",Gl="tpcnun0 uz3g760",sa=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=be({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Qo,{className:Gl,"data-error":i===!0,children:(0,r.jsx)(Cs.Input,{className:Bl,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},zl="cnu9yl0",Hl="cnu9yl1";var jn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=be({id:h,ariaLabel:l,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=Lt(o);return(0,r.jsx)(No.RadioGroup,{className:zl,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const y=Vl(f,m),S=(0,r.jsxs)(_o.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,me.default)(Hl,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":y,children:[f.icon,la(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return y===void 0?S:(0,r.jsx)(we,{label:y,checked:f.value===t,children:S},f.value)})})},la=(e,t)=>e.icon===void 0||t,Vl=(e,t)=>{if(!la(e,t))return e.label},$l={ToggleGroup:jn,Switch:ia,Slider:aa,RadioGrid:na,Button:Wo,TextField:sa,NumberField:ta,Select:oa,ColorSwatches:Xo,CustomColor:Zo,FileInput:Jo},Qt=(0,x.createContext)($l),ca=({controls:e,children:t})=>{const n=(0,x.useContext)(Qt),o=(0,x.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.FileInput]);return(0,r.jsx)(Qt.Provider,{value:o,children:t})},F=()=>(0,x.useContext)(Qt),ur={stack:"pr583x0",grid:"pr583x1"},hr="pr583x2",Wl={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},L=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,x.useId)(),i=(0,x.useId)();return e===void 0?(0,r.jsx)(Zt,{className:ur[t],children:(0,r.jsx)("div",{className:hr,children:o})}):(0,r.jsxs)(Zt,{className:ur[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:Wl[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:hr,children:(0,r.jsx)(Ho,{labelId:a,controlId:i,children:o})})]})},Tn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Ul,{graph:t,axis:e.axis})};Tn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var Ul=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=F(),l=n?.guides.axes.find(E=>E.scaledAesthetic===t);if((0,x.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const u=!l.visible,h=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(E=>E.position==="left"||E.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,y=f?.scaleType==="continuous"?f:void 0,S=y!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),C=y?.transform==="log"?"log":"linear",k=S&&y.transform!=="log",w=y?.domainMin??null,A=y!==void 0&&(l.position==="left"||l.position==="right")&&y.transform!=="log",j=y?.domainMax??null,P=n.config.axes[t]?.label??l.label??"",M=E=>{const B=t==="ySecondary"?{axis:t,label:E}:{axis:t,label:E};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:P,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:M,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(L,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!h,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Fs,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Ds,{})}],onChange:E=>{const B=E==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(L,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:u,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(Rs,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(Os,{})}],onChange:E=>{if(E!=="left"&&E!=="right")return;const B=t==="y"?E:E==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),S&&(0,r.jsx)(L,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:C,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(_s,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Ns,{})}],onChange:E=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:E==="log"?"log":"linear"}))}})}),k&&(0,r.jsx)(L,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:w,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:E}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,r.jsx)(L,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:j,placeholder:o("editor.axesPanel.endAt.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:E}),{transient:!0})},onCommit:e.commands.commit})})]})},ql={narrow:3,regular:6,wide:11},Kl=({barWidth:e,...t})=>{const n=ql[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},Xl=6,ge=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=ua(e,i,n);(0,x.useEffect)(()=>()=>t.commit(),[t]);const l=(0,x.useMemo)(()=>(0,d.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const u=(p,m)=>{const g=s[0]?.part;t.dispatch(new d.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(da,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},da=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=F();return(0,r.jsx)(L,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Yl(t.slice(0,Xl),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ge.hasRows=(e,{scene:t,findGeom:n})=>ua(e,t,n)!==null;var ua=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,o)},Yl=(e,t)=>t===null||e.some(n=>wn(n,t))?e:[...e,t],Dt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],An=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=F(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,u=g=>{const v=Dt.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=Dt.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(Kl,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Dt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:e}),s!==null&&!l?(0,r.jsx)(L,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:h,onChange:u})}):null]})};An.hasRows=ge.hasRows;var Zl={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},Jl=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Zl[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Ql={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},ec=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Ql[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),pr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ha=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||tc(e))return pr;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&n.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},tc=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},pa=(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}};var en=["gap","zero","connect"],kn=(e,t,n)=>{const o=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(o.geom,o.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,u=(0,d.combineKindStyleDeclarations)(l,i,s),h=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof u?.strokeWidth=="number"?u.strokeWidth:null,m=nc(o,e.spec.layers),g=a?[]:oc(o),v=g.length>1,f=o.geom==="line"&&!a,y=f?ic(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&rc(e,t,m.id),pointLayerId:m?.id??null,showFill:f?y>0:null,drawnFillAlpha:y,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??ac(e,t,o)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},nc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),rc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},oc=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},ac=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},ic=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},sc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),lc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),ma=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),cc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.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"})]}),dc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),uc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.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,r.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"})]})}),hc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.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,r.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"})]})}),pc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),mc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),gc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),vc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),fc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),xc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),bc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),yc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),Sc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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"})]}),Cc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),wc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.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"})}),jc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.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,r.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"})]})}),Tc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Ac=.55,kc=.15,Ge=[{name:"column",icon:pc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:gc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:mc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:dc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:hc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:uc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:ma,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:cc,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:vc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Tc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:bc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:fc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Ac}},{name:"radialBar",icon:Cc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:kc}},{name:"rose",icon:wc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:jc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:yc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Sc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:xc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Pc=.05,ga=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,ft=e=>e===null?null:Ge.find(t=>Lc(t.summary,e))??null,va=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&fa(t)?{...e,position:"identity"}:e.coordType!=="polar"||!xt(e.innerRadius)||t.coordType!=="polar"||!xt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},fa=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Lc=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&fa(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&xt(e.innerRadius)===xt(t.innerRadius)},xt=e=>e>=Pc;var Ic="_1a90obs1",Ec=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:sc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:lc},{summary:{coordType:"cartesian",comboType:"lines"},icon:ma}],Mc=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Rc=4,Oc={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},_c={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Nc=()=>{const e=c.useSceneSelector(P=>P.spec),t=c.useSceneSelector(({layers:P})=>P.some(M=>(0,d.hasMultipleGroups)(M.data,M.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=F(),[s,l]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!s)return;const P=({target:M,detail:E})=>{E>0&&Fc(M)&&u.current?.contains(M)&&l(!1)};return document.addEventListener("click",P),()=>document.removeEventListener("click",P)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=Bc(h),m=bt(h),g=ft(h),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),y=(p===void 0?g:gr(p,m))?.icon,S=p!==void 0&&p.arrangements.length>1,C=S&&(t||p.name==="combo"),k=()=>l(!s),w=({summary:P})=>{n.dispatch(new d.SetGraphTypeCommand(va(P,h)),{transient:!0})},A=P=>{const M=mr.find(E=>E.name===P);M!==void 0&&w(gr(M,S?m:null))},j=mr.map(({name:P,arrangements:[M]})=>({value:P,label:o(`editor.graphTypes.${P}`),icon:(0,r.jsx)(M.icon,{size:"md"}),disabled:!ga(M.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:o("editor.overlayMenu.chartType"),children:y===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:k}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(y,{size:"sm"}),ariaLabel:f,expanded:s,onClick:k})}),s&&(0,r.jsx)(L,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:j,value:p?.name??"",onChange:A,onCommit:n.commit,columns:Rc,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),C&&(0,r.jsx)(Dc,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},xa=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?ft(e)===ft(t):e.coordType===t.coordType&&e.geom===t.geom,ba=Mc.flatMap(([e,t])=>{const n=Ge.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ge,...Ec].filter(o=>o!==n&&xa(n.summary,o.summary))]}]}),mr=ba.filter(({name:e})=>e!=="combo"),Dc=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=F(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=bt(u);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),l=u=>{const h=e.arrangements.find(({summary:p})=>bt(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(L,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Ic,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},Fc=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,bt=e=>(0,d.isComboGraphType)(e)?_c[e.comboType]:Oc[e.position],gr=(e,t)=>e.arrangements.find(({summary:n})=>bt(n)===t)??e.arrangements[0],Bc=e=>ba.find(({arrangements:[t]})=>xa(t.summary,e)),Gc=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:u,buildRange:h})=>{if(u===null)return null;const p=(m,g)=>{const v=h(m);v!==null&&(a(m),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(da,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},ya=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),Sa=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),zc={small:2,medium:3.8,large:5.6},Hc=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:zc[e],fill:"currentColor"})});var Vc=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},$c="_1yjsaqt0",Wc="_1yjsaqt1",Uc="_1yjsaqt2",qc="_1yjsaqt3";var Ax=512*1024,Kc=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const n=new FileReader;n.onerror=()=>t({rejection:"undecodable"}),n.onload=()=>{const o=n.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},n.readAsDataURL(e)}),vr=["solid","dashed","dotted"],Ft=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Bt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],Xc=["circle","square","diamond","triangle","cross","star"],Ca=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=Ft.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(L,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:Ft.find(i=>i.widthPx===e)?.name??"",options:Ft.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(Sa,{lineWidth:s})})),onChange:a})})},wa=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=vr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(L,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:vr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(ya,{lineStyle:i})})),onChange:a})})},Pn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=F(),[i,s]=(0,x.useState)(null),l=(0,x.useContext)(Pt),u=c.useGlyphRegistry(),h=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):h("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:j,definition:P})=>[j,P])):u;if(p===void 0||p.length===0)return null;const g=j=>typeof j=="string"&&p.includes(j),v=j=>g(j)||(0,d.isImageSymbol)(j)||!(0,d.isGeometricSymbol)(j)&&m.has(j),f=j=>!(0,d.isGeometricSymbol)(j)||Xc.some(P=>P===j),y=[...m.keys()].filter(j=>!(0,d.isGeometricSymbol)(j)&&!g(j)),S=[...p.filter(f),...y],C=e===null?"":Ze(e),k=e===null||S.some(j=>Ze(j)===C)||!v(e)?S:[...S,e],w=j=>(0,d.isGeometricSymbol)(j)?o(`editor.graphPanel.pointSymbol.symbols.${j}`):(0,d.isImageSymbol)(j)?o("editor.graphPanel.pointSymbol.custom"):j,A=j=>{s(null);const P=k.find(M=>Ze(M)===j);P!==void 0&&n(P)};return(0,r.jsx)(L,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:$c,children:[(0,r.jsxs)("div",{className:Wc,children:[(0,r.jsx)(a,{itemLayout:"chip",value:C,options:k.map(j=>({value:Ze(j),label:w(j),icon:(0,r.jsx)(Zc,{symbol:j,glyphs:m})})),onChange:A}),(0,r.jsxs)("span",{className:Xs,children:[(0,r.jsx)("span",{className:Ys,"aria-hidden":"true"}),(0,r.jsx)(Yc,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:j=>{s(null),n(j)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},Ln=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=F(),a=i=>{const s=Bt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(L,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:Bt.find(i=>i.sizePx===e)?.name??"",options:Bt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(Hc,{pointSize:i})})),onChange:a})})},Yc=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=F(),a=i=>{Kc(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},Zc=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(Vc,{symbol:e});const n=Jc(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:qc,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:Uc,src:n,alt:""});const o=18/2;return(0,r.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},Ze=e=>typeof e=="string"?e:e.image,Jc=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},ja=(0,x.createContext)({}),Qc=ja.Provider,ed=()=>(0,x.useContext)(ja),td="_1qh3fon0",tn="theme",nd=3,Je=14,fr=9,Ta=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=ed(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=F();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),u=[{value:tn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(xr,{colors:i})},...l.map(([p,m])=>({value:nn(p),label:p,icon:(0,r.jsx)(xr,{colors:m})}))],h=p=>{const m=l.find(([v])=>nn(v)===p);if(p!==tn&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(L,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:u,value:rd(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},nn=e=>`preset:${e}`,rd=(e,t)=>{if(e===null)return tn;const n=t.find(([,o])=>(0,pe.isEqual)(o,e));return n===void 0?"":nn(n[0])},xr=({colors:e})=>{const t=e.slice(0,nd),n=Je/2,o=Je+(t.length-1)*fr;return(0,r.jsx)("svg",{width:o,height:Je,viewBox:`0 0 ${o} ${Je}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:td,cx:n+i*fr,cy:n,r:n-.5,fill:a},i)).reverse()})},br=["smooth","linear"],yr=["auto","inside","outside"],In=()=>{const e=c.useSceneSelector(b=>b),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=F(),l=Aa(e.layers,e.coordSystem.type,n),u=b=>l.filter(({support:R})=>b(R)).map(({layer:R})=>R),h=od(e,t),p=h.filter(b=>b.smooth!==null),m=h.filter(b=>b.missingValues!==null&&b.missingValueOptions.length>1),g=en.filter(b=>m.some(R=>R.missingValueOptions.includes(b))),v=ld(p),f=cd(m),y=b=>{o.dispatch(new d.SequenceCommand({commands:h.map(R=>new d.ToggleLinePointsCommand({layerId:R.layerId,showPoints:b}))}))},S=b=>{const R=br.find(z=>z===b);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:p.map(z=>new d.SetLineCurveCommand({layerId:z.layerId,curve:R}))}))},C=u(b=>b.supportsPosition),k=Qe(C.map(b=>b.dataLabels.position))??"",w=b=>{const R=yr.find(z=>z===b);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:C.map(z=>new d.SetDataLabelsCommand({layerId:z.id,position:R}))}))},A=b=>{const R=en.find(X=>X===b);if(R===void 0)return;const z=m.filter(X=>X.missingValueOptions.includes(R)).map(X=>new d.SetLineMissingValuesCommand({layerId:X.layerId,missingValues:R}));z.length!==0&&o.dispatch(new d.SequenceCommand({commands:z}))},j=h.filter(b=>b.showFill!==null),P=h.filter(b=>b.showPoints),M=ad(e,t,h),E=j.some(b=>id(e,b)),B=b=>{b.length>0&&o.dispatch(new d.SequenceCommand({commands:b}))},N=b=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,strokeWidth:b})))},O=b=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,lineStyle:b})))},I=b=>{B(j.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,showFill:b,drawnFillAlpha:R.drawnFillAlpha})))},T=b=>{B(P.flatMap(({pointLayerId:R})=>R===null?[]:[new d.SetPointSizeCommand({layerId:R,size:b})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Nc,{}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(b=>b.supportsDataLabels),isOn:b=>b.showDataLabels,buildCommand:(b,R)=>new d.ToggleDataLabelsCommand({layerId:b,showDataLabels:R})}),C.length>0&&(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:k,options:yr.map(b=>({value:b,label:a(`editor.graphPanel.graphOptions.labelPositions.${b}`)})),onChange:w})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(b=>b.supportsPercentages),isOn:b=>b.format==="percentage",buildCommand:(b,R)=>new d.SetDataLabelsFormatCommand({layerId:b,format:R?"percentage":"absolute"})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(b=>b.supportsStackTotals),isOn:b=>b.showStackTotals,buildCommand:(b,R)=>new d.ToggleStackTotalsCommand({layerId:b,showStackTotals:R})}),(0,r.jsx)(et,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(b=>b.supportsCategoryLabels),isOn:b=>b.showCategoryLabels,buildCommand:(b,R)=>new d.ToggleCategoryLabelsCommand({layerId:b,showCategoryLabels:R})}),(0,r.jsx)(L,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:b}))})}),(0,r.jsx)(L,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:b}))})}),(0,r.jsx)(L,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:b}))})}),p.length>0&&(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:br.map(b=>({value:b,label:a(`editor.graphPanel.graphOptions.curves.${b}`),icon:(0,r.jsx)(Jl,{curve:b})})),onChange:S})}),g.length>1&&(0,r.jsx)(L,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(b=>({value:b,label:pa(a,b),icon:(0,r.jsx)(ec,{missingValues:b})})),onChange:A})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ca,{widthPx:Qe(M.map(b=>b.strokeWidth)),onChange:N}),(0,r.jsx)(wa,{lineStyle:Qe(M.map(b=>b.lineStyle)),onChange:O})]}),j.length>0&&(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:E,onChange:I})}),h.length>0&&(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:P.length>0,onChange:y})}),P.length>0&&(0,r.jsx)(Ln,{sizePx:Qe(sd(e,t,P)),onChange:T}),(0,r.jsx)(Ta,{}),(0,r.jsx)(Gc,{})]})};In.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||Aa(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,d.isLayerSpecOf)(o,"line","area"));var Aa=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:ha(o,t,n)})),od=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=kn(e,t,o.id);a!==null&&n.push(a)}return n},ad=(e,t,n)=>n.flatMap(o=>{const a=(0,d.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),id=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),o=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,d.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},sd=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,d.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),Qe=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},ld=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",cd=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},et=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=F();if(t.length===0)return null;const s=l=>{a.dispatch(new d.SequenceCommand({commands:t.map(u=>o(u.id,l))}))};return(0,r.jsx)(L,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},dd=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,d.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,d.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},tt=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},ud=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Sr(Cr(s.layers,e)?.[t]?.[n],a),u=l!==void 0?l:Sr(Cr(s.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},hd=e=>typeof e=="object"&&("style"in e||"annotate"in e),Sr=(e,t)=>e==null?e:hd(e)?e[t]:t==="style"?e:void 0,Cr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,yt=["solid","dashed","dotted"];var ka=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Pa=(e,t)=>{const n=e.guides.axes.filter(ka);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},pd=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const n=t.axes.find(o=>o.scaledAesthetic===e);return n===void 0||!n.showGrid},La=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),Ia=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Gt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],En=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=Pa(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=F();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,u=n.gridLine[l]().resolve(),h=(0,d.toDashPreset)(u.dashArray),p=pd(e.axis,o),m=yt.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(ya,{lineStyle:S})})),g=Gt.map(({name:S,widthPx:C})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(Sa,{lineWidth:C})})),v=Gt.find(({widthPx:S})=>S===u.strokeWidth)?.name??"",f=S=>{const C=yt.find(k=>k===S);C!==void 0&&i.dispatch(La(C,e.axis))},y=S=>{const C=Gt.find(({name:k})=>k===S);C!==void 0&&i.dispatch(Ia(C.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:f,disabled:p})}),(0,r.jsx)(L,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:y,disabled:p})})]})};En.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(ka);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var wr=[{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}],md={start:"Start",center:"Center",end:"End"},Ea=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=F(),a=e===void 0,i=a?"":zt(e),s=wr.map(u=>{const h=zt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${vd(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:gd(e,u)}}),l=u=>{const h=wr.find(p=>zt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(L,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Sn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},zt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${md[t]}`,gd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",vd=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ma=(e,t,n,o)=>{const a=Oa(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},Ra=(e,t,n,o)=>{const a=Oa(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},Oa=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),St=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(fd,{graph:t,target:e})};St.hasRows=(e,{scene:t})=>e.scope==="group"&&_a(t,e.layerId)!==null;var fd=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=F(),s=n===null?null:_a(n,t.layerId),l=n===null||s===null?null:kn(n,o,s.id);if(n===null||s===null||l===null)return null;const u=Sd(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:yd(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:xd(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??bd(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:Ma(n,o,l.pointLayerId,u),y=l.pointLayerId===null?null:Ra(n,o,l.pointLayerId,u),S=f!==null&&f>0,C=E=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:E,...h}))},k=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:E,drawnFillAlpha:l.drawnFillAlpha,...h}))},w=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:E,...h}))},A=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:E,...h}))},j=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:E,...h}))},P=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:E,...h}))},M=(0,d.readObservationsColorRoute)(n.spec,t)?.some(E=>E.geomKind==="line"||E.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:t}),(0,r.jsx)(Ca,{widthPx:v,onChange:w}),M&&(0,r.jsx)(wa,{lineStyle:Cd(n,o,t),onChange:P}),l.showFill!==null&&(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:k})}),(0,r.jsx)(L,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:C})}),S&&(0,r.jsx)(Ln,{sizePx:f,onChange:A}),S&&(0,r.jsx)(Pn,{symbol:y,coordType:n.coordSystem.type,onChange:j})]})},xd=(e,t,n,o)=>{const a=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},bd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},yd=(e,t,n)=>{const o=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},Sd=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Cd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,d.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},_a=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(o,"line","area")?o:null},Na=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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"})]}),wd="_1aafi1g0",jd="_1aafi1g1",jr=({children:e})=>(0,r.jsxs)("span",{className:wd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:jd})]}),Ht=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.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"})}),Tr=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.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"})]}),Da=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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"})]}),Fa=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.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,r.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,r.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,r.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,r.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"})]}),Td=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Ba=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ga=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Ad=()=>[{scope:"group",labelKey:"pieSlice"}];function kd(e,t){if(e.type==="polar"&&!Pd(t))return Ad();switch(t.geom){case"bar":return Td(t);case"line":case"area":return Ba(t);case"point":return Ga(t);default:return[]}}var Pd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Ld=(e,t,n,o)=>{const a=[],i=Id(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Ed(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},za=(e,t)=>{const n=t.find(o=>Mn(e.predicate,o.predicate));return n===void 0?e.scope:n.id},Id=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(a===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=Ha(t,a);return s===null||!_d(e,a,s)?null:{variable:a,value:s,label:Va(e,a,s,n,o)}},Ed=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.x);if(a===null||a===d.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 s=Md(e,t);if(s===null)return null;const l=Rd(e,a,s),u=l.findIndex(m=>ze(m)===ze(i));if(u<0||u>=l.length-1)return null;const h={variable:a,oneOf:l.slice(u)},p=s.length===0?h:{and:[h,...s]};return{label:Va(e,a,i,n,o),predicate:p}},Md=(e,t)=>{const n=[];for(const o of(0,d.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Rd=(e,t,n)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!Od(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],u=typeof l=="number"?l:a,h=ze(s),p=o.get(h);(p===void 0||u<p.position)&&o.set(h,{value:s,position:u})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Od=(e,t)=>t.every(n=>ze(e[n.variable]??null)===ze(n.eq)),_d=(e,t,n)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=Ha(a,t);if(i!==null&&i>n)return!0}return!1},Ha=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Va=(e,t,n,o,a)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},ze=e=>e instanceof Date?String(e.getTime()):String(e),Mn=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Ar(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Ar(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Mn(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&ke(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&kr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&ke(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&ke(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&ke(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&ke(e.gte,t.gte):"range"in e&&"range"in t&&kr(e.range,t.range),Ar=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Mn(n,a)}),kr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&ke(n,a)}),ke=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Nd=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,x.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},Dd={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Fd=e=>(0,d.isObservationAttachmentKind)(e.kind)&&Dd[e.kind],It=(e,t)=>(0,x.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),u=s.value instanceof Date?s.value.getTime():s.value;return{value:u,option:{value:String(u),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),$a=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=on(e,t,n,o);return{observation:i(zd(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Wa(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},rn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=Wa(e,t,n,a);switch(s){case"observation":{const h=l.length===0?null:on(e,t,n,o),p=Bd(h,u,i);return{whole:p,value:p}}case"xValue":return Pr((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=on(e,t,n,o)??i("editor.overlayMenu.all");return Pr(Gd(e,l),h,i)}default:return s}},Bd=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Pr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),Gd=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},zd=(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,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Wa=(e,t,n,o)=>{const a=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},on=(e,t,n,o)=>{const a=(0,d.getGroupVariables)(t.data,t.mapping);return a.length===0?Hd(t,n)??Vd(e,t):a.map(i=>$d(n[i]??null,o)).join(", ")},Hd=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Vd=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},$d=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},Wd="vez73g0",an="vez73g1",Ud="vez73g2",qd="vez73g3",Kd="vez73g4";var Xd="vez73g6",Yd="vez73g7",Zd="vez73g8",Jd="vez73g9",Qd="vez73ga",Ua=[Ud,Xd,Kd,qd],eu=Ua.map(e=>`.${e}`).join(", "),tu=Ua.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),qa=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${an}, ${eu}`),a=t.closest(`.${an}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(o).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=n.querySelector(tu);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Se={side:"top",delay:200},Ka={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Da},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Na},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Fa}},Xa=new Set(["barSeries","lineSeries","scatterSeries"]),nu=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Rn=e=>{const t=({target:n})=>{const o=Go(n);return o===null?null:(0,r.jsx)(ou,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>Bo(n,o)!==null,t},ct=Rn((e,t)=>kd(t,e)),Lr=Rn(Ba),ru=Rn(Ga),ou=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,at:a}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:u}=c.useGraphCommands(),{selectionStore:h,findGeom:p}=c.useGraphContext(),m=(0,x.useRef)(null),g=(0,x.useRef)(u);g.current=u;const{Button:v}=F(),f=c.useSceneSelector(G=>G),y=f.spec.annotations,S=f.config.parsingLocale,C=f.config.numberFormat,k=c.useFormattingLocale(),w={scene:f,layer:n,observation:o,groupOptions:It(f,k),locale:k,t:i},A=rn(w,"xValue").value,j=rn(w,"group").value,P=$a(w).observation,M=(0,x.useMemo)(()=>(0,d.createObservationAnchorParser)(n,S),[n,S]),E=(0,d.findObservationAttachment)(y,a,M,(0,x.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:f.layers,coordSystem:f.coordSystem,findGeom:p,readAnchor:M}),[f.layers,f.coordSystem,p,M])),B=E!==null&&Fd(E)?E:null,N=m.current,O=B!==null&&N?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,I=O?.kind==="comment"?O.annotation.content:null,T=I===null?"":xu(I)??void 0,[b,R]=(0,x.useState)(()=>vu(B?.kind)),z=Nd(n,o),X=f.coordSystem,te=t(n,X),K=te.length===0?[]:Ld(n,o,k,C),_=(N?.choiceId===void 0?z:z.filter(G=>za(G,K)!==N.choiceId)).at(-1),H=(0,x.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:X}),[n,a,X]),W=hu({layer:n,observation:o,highlights:z,highlightOptions:te,reaches:K,previewedChoiceId:m.current?.choiceId,scopeLabel:G=>mu(i,G,A,j,P),scopeDescription:G=>gu(i,G,Ir(i,n,te),A,j,te.some(oe=>Xa.has(oe.labelKey))),atLeastLabel:G=>i("graph.annotations.highlights.atLeast",{value:G}),atLeastDescription:G=>i("graph.annotations.highlights.atLeastDescription",{noun:Ir(i,n,te),value:G}),onwardLabel:G=>i("graph.annotations.highlights.onward",{label:G}),onwardDescription:G=>i("graph.annotations.highlights.onwardDescription",{label:G})}),U=()=>{m.current!==null&&(m.current=null,g.current())};(0,x.useEffect)(()=>()=>U(),[]);const ce=(G,oe,ye)=>{m.current?.key!==G&&(U(),m.current={key:G,choiceId:ye},l(oe)||(m.current=null))},de=G=>{U(),s(G),h.getState().clearSelection()},$=(G,oe)=>{if(m.current?.key===G){m.current=null,g.current(),s(oe),h.getState().clearSelection();return}de(oe)},Z=(G,oe,ye)=>({onPointerEnter:()=>ce(G,oe,ye),onPointerLeave:U,onClick:()=>$(G,oe)}),ae=G=>{U(),R(oe=>oe===G?null:G)},je=G=>{if(H===null)return;U();const oe=(0,d.areAnchorsEqual)(H.start,a)?H.end:H.start,ye=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:a,end:oe,label:G}});s(ye),h.getState().setSelection([{kind:"annotation",id:ye.params.annotation.id}])};return(0,r.jsxs)("div",{className:Wd,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:G=>{if(O!==null&&fu(G)){de(new d.RemoveAnnotationCommand({id:O.annotation.id}));return}qa(G)},children:[(0,r.jsxs)("div",{className:an,children:[W!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Tr,{}),expanded:b==="highlight",onClick:()=>ae("highlight")}),_!==void 0&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(jr,{children:(0,r.jsx)(Tr,{})}),onClick:()=>de(new d.RemoveHighlightCommand({id:_.id}))}),O!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i(Ka[O.kind].phrase),icon:(0,r.jsx)(jr,{children:au(O.kind)}),onClick:()=>de(new d.RemoveAnnotationCommand({id:O.annotation.id}))}),O===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Da,{}),onClick:()=>de(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Na,{}),expanded:b==="comment",onClick:()=>ae("comment")})]}),H!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Ht,{}),expanded:b==="difference",onClick:()=>ae("difference")}),O===null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Fa,{}),expanded:b==="sticker",onClick:()=>ae("sticker")})]}),b==="comment"&&T!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(iu,{at:a,onRun:de,annotationId:O?.kind==="comment"?O.annotation.id:void 0,initialText:T})}),b==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(su,{at:a,showPreview:ce,dropPreview:U,keepPreview:$,annotationId:O?.kind==="sticker"?O.annotation.id:void 0})}),b==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ht,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>je("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ht,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>je("absoluteDifference")})]}),b==="highlight"&&W!==null&&(0,r.jsx)("div",{className:"vez73g3",children:W.available.map(G=>(0,r.jsx)(v,{label:G.label,tooltip:G.description===G.label?void 0:G.description,...Se,...Z(lu(G.id),du(G,n.id),G.id)},G.id))})]})},au=e=>{const t=Ka[e].Icon;return(0,r.jsx)(t,{})},iu=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=F(),[l,u]=(0,x.useState)(o),h=(0,x.useRef)(null),p=l.trim();(0,x.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=bu(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:Yd,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:Zd,children:(0,r.jsx)(s,{value:l,onChange:u,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},su=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>(0,r.jsx)(r.Fragment,{children:Object.entries(c.STICKER_ASSETS).map(([i,s])=>{const l=uu(e,i,a);return(0,r.jsx)("button",{type:"button",className:Qd,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>o(l.key,l.command),children:(0,r.jsx)("img",{className:Jd,src:s.src,alt:""})},i)})}),lu=e=>`highlight:${e}`,cu=e=>`sticker:${e}`,du=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),uu=(e,t,n)=>n===void 0?{key:cu(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},hu=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:u,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,d.buildObservationPredicate)(e,t),v=new Set(n.flatMap(w=>{const A=za(w,a);return A===i?[]:[A]})),f=g===null?[]:o.filter(w=>!v.has(w.scope)).map(w=>{const A=s(w.labelKey);return{id:w.scope,label:A,description:l(w.labelKey),icon:w.labelKey,predicate:g,scope:w.scope}}),y=a.flatMap(w=>v.has(w.id)?[]:[pu(w,u,h,p,m)]),[S,...C]=f,k=S===void 0?y:[S,...y,...C];return k.length===0?null:{available:k}},pu=(e,t,n,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(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}},mu=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(nu.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Xa.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Ir=(e,t,n)=>{if(t.geom==="point"&&(0,d.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},gu=(e,t,n,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:n});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,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:n});default:return t}},vu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,fu=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)},xu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Er(t)||Mr(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Er(n)||Mr(n)?null:n.text},Er=e=>e.marks!==void 0&&e.marks.length>0,Mr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,bu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),On=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(yu,{graph:t,target:e})};On.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ge.hasRows(e,t);var yu=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(a,"point"))return(0,r.jsx)(ge,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(u=>u.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{target:t}),!l&&(0,r.jsx)(Ln,{sizePx:Ma(n,o,a.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:a.id,size:u,...s}))}}),(0,r.jsx)(Pn,{symbol:Ra(n,o,a.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:a.id,symbol:u,...s}))}})]})},Ya={geoms:{point:{style:On,annotate:ru},line:{style:St,annotate:Lr},area:{style:St,annotate:Lr},bar:{style:An,annotate:ct},rule:{style:null,annotate:ct},tile:{style:ge,annotate:ct}},legend:Ea,axis:Tn,grid:En,graph:In},_n=(0,x.createContext)([Ya]),Su=({editMenus:e,children:t})=>{const n=(0,x.useMemo)(()=>[e??{},Ya],[e]);return(0,r.jsx)(_n.Provider,{value:n,children:t})},Cu=e=>{const t=(0,x.useContext)(_n),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=Za(c.useGraphMode());return(0,x.useMemo)(()=>e===null?null:Ja(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},wu=()=>{const e=(0,x.useContext)(_n),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=Za(c.useGraphMode());return(0,x.useCallback)(i=>Ja(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},Za=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",Ja=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=dd(e.layerId,n.scene),i=a===null?null:ud(a,t,o,o==="annotate"?ct:ge);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=tt(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=tt(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=tt(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=tt(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},ju={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},Tu={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Au={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون الشكل",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"السماكة",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"بداية السهم",endArrowhead:"نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",box:"إضافة مربع",arrowOneWay:"اتجاه واحد",arrowTwoWay:"اتجاهان",arrowLine:"خط"},textMenu:{title:"تعليق",placeholder:"قل ما حدث…",addButton:"إضافة"},highlights:{menuTitle:"تمييز",labels:{bar:"شريط",barGroup:"مجموعة",barStack:"مكدس",barSeries:"سلسلة",line:"خط",linePoint:"نقطة",lineSeries:"سلسلة",scatterPoint:"نقطة",scatterSeries:"سلسلة",pieSlice:"شريحة",pointOrBar:"نقطة / شريط",lineOrSeries:"خط / سلسلة"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`تمييز كل ${e} عند ${t} أو أكثر`,onward:({label:e})=>`${e} فصاعداً`,onwardDescription:({label:e})=>`تمييز ${e} وكل ما بعده`,justThis:({noun:e})=>`تمييز هذه ${e} فقط`,justValue:({label:e})=>`تمييز ${e} فقط`,everyNamed:({name:e,noun:t})=>`تمييز كل ${e} ${t}`,everyIn:({noun:e,name:t})=>`تمييز كل ${e} في ${t}`,wholeGroup:"تمييز المجموعة كلها",wholeStack:"تمييز المكدس كله",wholeSeries:"تمييز السلسلة كلها",nouns:{bubble:"فقاعة"}},stickerMenu:{title:"إضافة ملصق"},delete:"حذف",arrow:{thickness:{label:"السمك",thin:"رفيع",medium:"متوسط",thick:"سميك"},arrowhead:{startPoint:"نقطة البداية",endPoint:"نقطة النهاية",lineArrow:"سهم الخط",none:"بدون"},lineStyle:{label:"نمط الخط",solid:"صلب",dotted:"منقط"},stickerEffect:"تأثير الملصق",toolbarAriaLabel:"شريط أدوات السهم الحر",editorAriaLabel:"محرر السهم"},differenceArrow:{type:{proportion:"النسبة",difference:({absoluteDifference:e})=>`الفرق (${e})`,increase:({absoluteDifference:e})=>`الزيادة (${e})`,decrease:({absoluteDifference:e})=>`النقصان (${e})`,percentageChange:({percentageChange:e})=>`تغيير النسبة المئوية (${e})`,percentIncrease:({percentageChange:e})=>`زيادة النسبة المئوية (${e})`,percentDecrease:({percentageChange:e})=>`نقصان النسبة المئوية (${e})`},size:{label:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},flipArrow:"عكس السهم",color:"اللون",toolbarAriaLabel:"شريط أدوات سهم الفرق",editorAriaLabel:"محرر سهم الفرق"},shape:{color:"اللون",border:{label:"الحدود",none:"بدون",thin:({value:e})=>`رفيع (${e})`,medium:({value:e})=>`متوسط (${e})`,thick:({value:e})=>`سميك (${e})`}}}},ku={common:ju,editor:Tu,graph:Au},Pu={save:"Save",cancel:"Cancel",confirm:"Confirm",delete:"Delete",confirmDelete:e=>`Are you sure you want to delete ${e.item}?`,abbreviations:{thousands:"k",millions:"m",billions:"b"}},Lu={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Iu={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Shape colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start of the arrow",endArrowhead:"End of the arrow",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",box:"Add box",arrowOneWay:"One way",arrowTwoWay:"Two way",arrowLine:"Line"},textMenu:{title:"Annotate",placeholder:"Say what happened…",addButton:"Add"},highlights:{menuTitle:"Highlight",labels:{bar:"bar",barGroup:"group",barStack:"stack",barSeries:"series",line:"line",linePoint:"point",lineSeries:"series",scatterPoint:"point",scatterSeries:"series",pieSlice:"slice",pointOrBar:"point / bar",lineOrSeries:"line / series"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Highlight every ${e} at ${t} or more`,onward:({label:e})=>`${e} onward`,onwardDescription:({label:e})=>`Highlight ${e} and everything after`,justThis:({noun:e})=>`Highlight just this ${e}`,justValue:({label:e})=>`Highlight just ${e}`,everyNamed:({name:e,noun:t})=>`Highlight every ${e} ${t}`,everyIn:({noun:e,name:t})=>`Highlight every ${e} in ${t}`,wholeGroup:"Highlight the whole group",wholeStack:"Highlight the whole stack",wholeSeries:"Highlight the whole series",nouns:{bubble:"bubble"}},stickerMenu:{title:"Add sticker"},delete:"Delete",arrow:{thickness:{label:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},arrowhead:{startPoint:"Start point",endPoint:"End point",lineArrow:"Line arrow",none:"None"},lineStyle:{label:"Line style",solid:"Solid",dotted:"Dotted"},stickerEffect:"Sticker effect",toolbarAriaLabel:"Free-form arrow toolbar",editorAriaLabel:"Arrow editor"},differenceArrow:{type:{proportion:"Proportion",difference:({absoluteDifference:e})=>`Difference (${e})`,increase:({absoluteDifference:e})=>`Increase (${e})`,decrease:({absoluteDifference:e})=>`Decrease (${e})`,percentageChange:({percentageChange:e})=>`Percentage change (${e})`,percentIncrease:({percentageChange:e})=>`Percent increase (${e})`,percentDecrease:({percentageChange:e})=>`Percent decrease (${e})`},size:{label:"Size",small:"Small",medium:"Medium",large:"Large"},flipArrow:"Flip arrow",color:"Color",toolbarAriaLabel:"Difference arrow toolbar",editorAriaLabel:"Difference arrow editor"},shape:{color:"Color",border:{label:"Border",none:"None",thin:({value:e})=>`Thin (${e})`,medium:({value:e})=>`Medium (${e})`,thick:({value:e})=>`Thick (${e})`}}}},Eu={common:Pu,editor:Lu,graph:Iu},Mu={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Ru={editor:Mu},Ou={save:"Guardar",cancel:"Cancelar",confirm:"Confirmar",delete:"Eliminar",confirmDelete:e=>`Tem a certeza que deseja eliminar ${e.item}?`,abbreviations:{thousands:"mil",millions:"M",billions:"MM"}},_u={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Nu={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor da forma",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Início da seta",endArrowhead:"Fim da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",box:"Adicionar caixa",arrowOneWay:"Um sentido",arrowTwoWay:"Dois sentidos",arrowLine:"Linha"},textMenu:{title:"Anotar",placeholder:"Diga o que aconteceu…",addButton:"Adicionar"},highlights:{menuTitle:"Realçar",labels:{bar:"Barra",barGroup:"Grupo",barStack:"Pilha",barSeries:"Série",line:"Linha",linePoint:"Ponto",lineSeries:"Série",scatterPoint:"Ponto",scatterSeries:"Série",pieSlice:"Fatia",pointOrBar:"Ponto / barra",lineOrSeries:"Linha / série"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Realçar cada ${e} em ${t} ou mais`,onward:({label:e})=>`${e} em diante`,onwardDescription:({label:e})=>`Realçar ${e} e tudo a seguir`,justThis:({noun:e})=>`Realçar apenas esta ${e}`,justValue:({label:e})=>`Realçar apenas ${e}`,everyNamed:({name:e,noun:t})=>`Realçar cada ${e} ${t}`,everyIn:({noun:e,name:t})=>`Realçar cada ${e} em ${t}`,wholeGroup:"Realçar o grupo inteiro",wholeStack:"Realçar a pilha inteira",wholeSeries:"Realçar a série inteira",nouns:{bubble:"bolha"}},stickerMenu:{title:"Adicionar autocolante"},delete:"Eliminar",arrow:{thickness:{label:"Espessura",thin:"Fina",medium:"Média",thick:"Grossa"},arrowhead:{startPoint:"Ponto inicial",endPoint:"Ponto final",lineArrow:"Seta de linha",none:"Nenhuma"},lineStyle:{label:"Estilo de linha",solid:"Sólida",dotted:"Pontilhada"},stickerEffect:"Efeito de autocolante",toolbarAriaLabel:"Barra de ferramentas de seta livre",editorAriaLabel:"Editor de seta"},differenceArrow:{type:{proportion:"Proporção",difference:({absoluteDifference:e})=>`Diferença (${e})`,increase:({absoluteDifference:e})=>`Aumento (${e})`,decrease:({absoluteDifference:e})=>`Diminuição (${e})`,percentageChange:({percentageChange:e})=>`Variação percentual (${e})`,percentIncrease:({percentageChange:e})=>`Aumento percentual (${e})`,percentDecrease:({percentageChange:e})=>`Diminuição percentual (${e})`},size:{label:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},flipArrow:"Inverter seta",color:"Cor",toolbarAriaLabel:"Barra de ferramentas de seta de diferença",editorAriaLabel:"Editor de seta de diferença"},shape:{color:"Cor",border:{label:"Contorno",none:"Nenhum",thin:({value:e})=>`Fino (${e})`,medium:({value:e})=>`Médio (${e})`,thick:({value:e})=>`Grosso (${e})`}}}},Du={common:Ou,editor:_u,graph:Nu},Fu={"en-GB":Eu,"en-US":Ru,ar:ku,"pt-PT":Du},Bu=[Fu,c.dictionaries],Nn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:Bu,...t,children:(0,r.jsx)(Gu,{children:e})}),Gu=({children:e})=>(0,r.jsx)(Sn.DirectionProvider,{direction:c.useTextDirection(),children:e}),zu="data-variant",Qa=Fo.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[zu]:e.variant}:{}}}}}),Hu=Do.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:t}=e.state;if(!t.empty)return!1;const{$from:n}=t;return n.depth!==1||n.parentOffset!==0?!1:n.index(0)===1}}}}),Dn=()=>[Ps.Text,Tt.UndoRedo,Ts.Heading.configure({levels:[1,2,3]}),ws.Bold,As.Italic,Is.Underline,Ls.TextAlign.configure({types:["heading","paragraph"]}),ks.Link.configure({openOnClick:!1,autolink:!0}),mt.TextStyle,mt.Color,js.HardBreak],Vu=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[Wu({showTitle:n,showSubtitle:o}),Qa,...Dn(),mt.FontFamily,Hu.configure({showTitle:n}),Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:i})=>{if(n&&a===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return o&&a===s?t:""}})],$u=({placeholder:e})=>[pt.Document,Qa,...Dn(),mt.FontFamily,Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],Wu=({showTitle:e,showSubtitle:t})=>e&&t?pt.Document.extend({content:"block{2,}"}):pt.Document,ei=()=>{const e=c.useI18n();return(0,x.useMemo)(()=>({...Object.fromEntries(ni.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ti=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,x.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const o=e.map(n);typeof o=="string"&&t.add(o)}return[...t]},[e])},Uu=e=>e!=="canvasDefault"&&e!=="canvasInverse",ni=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(Uu).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Fn=ni.map(e=>e.color);var qu="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))",Ku="d0bl00";var Xu="d0bl03",Yu="d0bl04",Zu=.01,Ju=e=>Fn.some(t=>t.toLowerCase()===e.toLowerCase()),Qu=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:u,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=c.useI18n(),{ColorSwatches:g,Slider:v}=F(),f=ei(),y=ti(),S=[...p?[d.AUTO_COLOR]:[],...h?[gt]:[],...Fn],C={...f,[gt]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},k=M=>{t(M),o(!1)},w=y.length>0,A=w?y:S,j=e!==null&&!Rr(S,e)&&!Rr(y,e)?[...A,e]:A,P=(0,r.jsx)(eh,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:Ku,onMouseDown:M=>M.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Xu,children:(0,r.jsxs)(Q.Popover.Popup,{className:Yu,onMouseDown:M=>M.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?S:j,names:C,value:e,onChange:k,trailing:w?void 0:P}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:j,names:C,value:e,onChange:k,trailing:P}),l!==void 0&&u!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(v,{value:l,onChange:u,min:0,max:1,step:Zu,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},eh=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=F(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===d.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},Rr=(e,t)=>e.some(n=>wn(n,t)),th="l9kff0",nh="l9kff1",rh="l9kff2",oh="xn24px0",ah="xn24px1",ih="xn24px2",sh=({children:e,popupAttributes:t})=>(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:oh,children:(0,r.jsx)(re.Menu.Popup,{className:ah,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),lh=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(re.Menu.Item,{className:ih,"data-selected":t,disabled:n,onClick:o,children:e}),ch=({className:e,...t})=>(0,r.jsx)(le.Tooltip.Provider,{children:(0,r.jsx)(xe.Toolbar.Root,{...t,className:(0,me.default)(th,e)})}),dh=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Group,{...t,className:(0,me.default)(nh,e)}),uh=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Separator,{...t,className:(0,me.default)(rh,e)}),hh=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,yn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},J={Portal:hh,Root:ch,Group:dh,Separator:uh,Button:xe.Toolbar.Button,ColorPicker:Qu,MenuPopup:sh,MenuItem:lh},ph="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",mh=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,gh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",vh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",sn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:mh},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:ph},{id:"technical",label:"Technical",preview:"00",fontFamily:gh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:vh}],fh=e=>e?sn.find(t=>t.fontFamily===e)??null:null,ri="_70l3rt0",oi="_70l3rt1",ai="_70l3rt3",ii="_70l3rt4",si="_70l3rt5",xh=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=fh(t)??sn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(re.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:ri,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:oi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ai,children:(0,r.jsx)(re.Menu.Popup,{className:ii,onMouseDown:l=>l.preventDefault(),children:sn.map(l=>(0,r.jsx)(re.Menu.Item,{className:si,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},li={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},Or=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},li,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],bh=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Or.find(s=>s.id===t)??li;return(0,r.jsxs)(re.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:ri,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:oi,children:a(i.translationKey)}),(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(re.Menu.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(re.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ai,children:(0,r.jsx)(re.Menu.Popup,{className:ii,onMouseDown:s=>s.preventDefault(),children:Or.map(s=>(0,r.jsx)(re.Menu.Item,{className:si,"data-selected":s.id===i.id,onClick:()=>yh(e,s.id),children:(0,r.jsx)(Sh,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},yh=(e,t)=>{switch(t){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()}},Sh=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),Ch=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),wh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),jh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),Th=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&_r(n[i-1]);)i-=1;let s=o;for(;s<n.length&&_r(n[s]);)s+=1;return{from:a+i,to:a+s}},_r=e=>e!==void 0&&/\S/.test(e),Ah="fop13s0",kh="fop13s1",Ph="fop13s2",Lh="fop13s3",Nr="fop13s4",Ih=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,x.useState)(""),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{o&&l(t??"")},[o,t]);const h=()=>{Eh(e,s),a(!1)},p=()=>{l(""),a(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),h())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Ah,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(Ch,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:kh,children:(0,r.jsxs)(Q.Popover.Popup,{className:Ph,initialFocus:u,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:u,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:Lh,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Nr,onClick:p,children:(0,r.jsx)(wh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Nr,onClick:h,children:(0,r.jsx)(ra,{})})]})})})})]})},Eh=(e,t)=>{const n=t.trim(),{selection:o}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!o.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const a=Th(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},ci=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),di=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),ui=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),Mh="_1d66w570",Rh="_1d66w571",Ie=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(le.Tooltip.Root,{children:[(0,r.jsx)(le.Tooltip.Trigger,{render:(0,r.jsx)(Es.Toggle,{render:(0,r.jsx)(xe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:Mh,onMouseDown:a,children:o}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:fe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(le.Tooltip.Positioner,{sideOffset:6,className:Rh,children:(0,r.jsx)(le.Tooltip.Popup,{className:Vo,children:e})})})})]})},Oh=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(ui,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(ci,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(di,{})})]})},_h="_1u34vl40",Nh=({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:Dh(e),textAlign:Fh(e)}),Dh=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",Fh=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",Bh=8,Gh=8,zh=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:u,floatingStyles:h}=(0,Re.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Re.offset)(Bh),(0,Re.flip)(),(0,Re.shift)({padding:Gh})],whileElementsMounted:Re.autoUpdate}),p=(0,x.useRef)(null),m=(0,Ce.useEditorState)({editor:e,selector:Nh}),g=(0,x.useCallback)(v=>{p.current=v,u.setFloating(v)},[u]);return(0,x.useEffect)(()=>{e&&u.setReference(e.view.dom)},[e,u]),(0,x.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:y})=>{const{relatedTarget:S,currentTarget:C}=y,k=S instanceof Node&&p.current?.contains(S),w=S instanceof Node&&C instanceof Node&&C.contains(S);!k&&!w&&o(!1)};return e.on("focus",v),e.on("blur",f),()=>{e.off("focus",v),e.off("blur",f)}},[e]),!e||!n&&!s?null:(0,r.jsx)(J.Portal,{children:(0,r.jsxs)(J.Root,{ref:g,className:_h,style:h,children:[(0,r.jsxs)(J.Group,{children:[(0,r.jsx)(J.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(xh,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(bh,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(J.Separator,{}),(0,r.jsxs)(J.Group,{children:[(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.bold"),active:m?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.italic"),active:m?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(Ie,{label:t("graph.toolbar.formatting.underline"),active:m?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(Oh,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(J.Separator,{}),(0,r.jsx)(J.Group,{children:(0,r.jsx)(Ih,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},Hh="_1uy50v30",hi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:Hh,children:[(0,r.jsx)(zh,{editor:e}),(0,r.jsx)(Ce.EditorContent,{editor:e,"aria-label":t})]}),Vh=200,Bn=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=Vh})=>{const i=(0,x.useRef)(Dr(e)),s=(0,x.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,o?.(h)},a),u=(0,Ce.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Vt(s.current,p))return l.cancel();l.run(p)}});return(0,x.useEffect)(()=>{u?.setEditable(n)},[u,n]),(0,x.useEffect)(()=>{if(!u)return;const h=Dr(e);Vt(s.current,h)||(s.current=h,!Vt(u.getJSON(),h)&&(l.cancel(),$h(u,h)))},[u,e,l]),(0,x.useEffect)(()=>()=>l.flush(),[l]),u},Dr=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,$h=(e,t)=>{const{from:n,to:o}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,a),to:Math.min(o,a)})},Vt=(e,t)=>JSON.stringify(Ct(e))===JSON.stringify(Ct(t)),Ct=e=>Array.isArray(e)?e.map(Ct):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ct(n)]).filter(([,t])=>!Wh(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),Wh=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Uh=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=Bn({content:e,extensions:(0,x.useMemo)(()=>$u({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=jh(a)?null:a;n(new d.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(hi,{editor:o,ariaLabel:"Chart caption"})})};var He="textStyle",pi=new Set(["paragraph","heading"]),mi=e=>bi(vi(e)?.fontSize)??null,gi=e=>fi(vi(e))??null,qh=e=>{const t=xi(e),n=Zh(e);return{color:nt(t.map(o=>Jh($t(o)?.color))),font:nt(t.map(o=>fi($t(o)))),fontSize:nt(t.map(o=>bi($t(o)?.fontSize))),alignment:nt(n.map(o=>Qh(o.attrs?.textAlign)))}},Kh=(e,t)=>Gn(e,n=>n.type==="text"?Yh(n,t):n),Fe=e=>xi(e).length>0,Xh=(e,t)=>Gn(e,n=>pi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),vi=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===He)?.attrs},Gn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>Gn(n,t))}),Yh=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===He),a={type:He,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},$t=e=>e.marks?.find(t=>t.type===He)?.attrs,fi=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),xi=e=>zn(e,t=>t.type==="text"),Zh=e=>zn(e,t=>pi.has(t.type??"")),zn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>zn(n,t))],nt=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},Jh=e=>typeof e=="string"&&e.length>0?e:void 0,bi=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Qh=e=>e==="left"||e==="center"||e==="right"?e:void 0,e0=e=>[pt.Document,Fo.Paragraph,...Dn(),n0,Tt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],t0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,x.useMemo)(()=>e0(t("graph.annotations.text.placeholder")),[t]),i=Bn({content:e.content,extensions:a,editable:!0,onUpdate:u=>{n(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:u}}))}});(0,x.useEffect)(()=>{const{setCaretEditor:u}=o.getState();return u(i),()=>u(null)},[i,o]),(0,x.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>mi(u)}),l=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>gi(u)});return(0,r.jsx)(Ce.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},Fr=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},n0=Do.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Fr(e.fontFamily)},font:{default:null,renderHTML:e=>Fr(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),r0=3,o0=({title:e,showTitle:t,subtitle:n,showSubtitle:o})=>{const a=[];return t&&a.push({type:"heading",attrs:{level:r0},content:i0(e)}),o&&a.push(...s0(n)),{type:"doc",content:a}},a0=e=>{const[t,...n]=e.content??[];return{title:l0(t?.content??[]),subtitle:c0(n)}},Hn=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Hn)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),i0=e=>e===null?[]:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e.type==="doc"&&e.content?e.content.flatMap(t=>t.content??[]):e.type==="text"||e.type==="hardBreak"?[e]:e.content??[],s0=e=>e===null?[{type:"paragraph"}]:typeof e=="string"?e===""?[{type:"paragraph"}]:[{type:"paragraph",content:[{type:"text",text:e}]}]:e.type==="doc"&&e.content?e.content.length===0?[{type:"paragraph"}]:e.content.map(Br):[Br(e)],Br=e=>e.type==="paragraph"?e:{type:"paragraph",content:e.content??[e]},l0=e=>{if(e.length===0)return null;const[t]=e;return t&&e.length===1&&t.type==="text"&&(!t.marks||t.marks.length===0)?t.text??null:{type:"paragraph",content:e.map(Hn)}},c0=e=>{const t=e.filter(o=>(o.content??[]).length>0);if(t.length===0)return null;const[n]=t;if(n&&t.length===1&&n.type==="paragraph"){const o=n.content??[],[a]=o;if(a&&o.length===1&&a.type==="text"&&(!a.marks||a.marks.length===0))return a.text??null}return{type:"doc",content:t.map(Hn)}},d0="uwf6lt0",u0={fontFamily:"var(--uwf6lt1)",fontSize:"var(--uwf6lt2)",fontWeight:"var(--uwf6lt3)",fontStyle:"var(--uwf6lt4)",letterSpacing:"var(--uwf6lt5)",lineHeight:"var(--uwf6lt6)",textColor:"var(--uwf6lt7)",textTransform:"var(--uwf6lt8)",textDecoration:"var(--uwf6lt9)",textShadow:"var(--uwf6lta)",textOutline:"var(--uwf6ltb)"},h0={fontFamily:"var(--uwf6ltc)",fontSize:"var(--uwf6ltd)",fontWeight:"var(--uwf6lte)",fontStyle:"var(--uwf6ltf)",letterSpacing:"var(--uwf6ltg)",lineHeight:"var(--uwf6lth)",textColor:"var(--uwf6lti)",textTransform:"var(--uwf6ltj)",textDecoration:"var(--uwf6ltk)",textShadow:"var(--uwf6ltl)",textOutline:"var(--uwf6ltm)"},p0=({title:e,showTitle:t,showSubtitle:n,subtitle:o,headingStyle:a,subtitleStyle:i})=>{const{dispatch:s}=c.useGraphCommands(),l=(0,x.useMemo)(()=>Vu({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),u=Bn({content:(0,x.useMemo)(()=>o0({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:l,editable:!0,onUpdate:h=>{const p=a0(h);t&&s(new d.SetContentTitleCommand({title:p.title})),n&&s(new d.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:d0,"data-testid":"title-editor",style:{...c.assignTextStyleVars(u0,a),...c.assignTextStyleVars(h0,i)},children:(0,r.jsx)(hi,{editor:u,ariaLabel:"Chart title and subtitle"})})},yi={Title:p0,Caption:Uh,TextAnnotation:t0},m0={Title:null,Caption:null,TextAnnotation:yi.TextAnnotation},g0=e=>c.MODE_RULES[e].editTextInline?yi:m0,v0="_10igzta0",f0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,yn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:v0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),x0="kwvn4c0",b0="kwvn4c1",Vn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Si=e=>Vn(e,e.getBoundingClientRect().width),ln=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},y0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=Vn(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),S0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!w0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Gr(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return Gr(s,o.width,t.width)},C0=()=>{const[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{t(!0)},[]),e},w0=e=>c.SIDE_KEYS.some(t=>t===e),Gr=(e,t,n)=>n===0?0:e*t/n,j0={x:8,y:8},T0={side:"flip",align:"shift",fallbackAxisSide:"end"},Ci=({frameElement:e,boundary:t,spans:n,clearance:o=j0,onEscape:a,children:i})=>{const s=kt(),l=C0(),[u,h]=(0,x.useState)(null),p=(0,x.useRef)(null),m=(0,x.useCallback)(A=>{p.current=A,h(A)},[]),g=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>()=>{u?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[u,e]);const{x:v,y:f,width:y,height:S}=t,C=(0,x.useMemo)(()=>({box:{x:v,y:f,width:y,height:S},spans:n}),[v,f,y,S,n]),k=(0,x.useMemo)(()=>y0(e,C.box),[e,C]),w=(A,j)=>{A||(j.cancel(),j.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:w,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:fe,children:(0,r.jsx)(Cn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:g,anchor:k,side:"right",align:"start",sideOffset:({side:A})=>A==="top"||A==="bottom"?o.y:o.x,alignOffset:({side:A,anchor:j})=>S0({side:A,boundary:C.box,spans:C.spans,anchor:j,rightToLeft:A0(g.current)}),collisionAvoidance:T0,sticky:!0,className:x0,...Qs,children:(0,r.jsx)(Q.Popover.Popup,{ref:m,className:b0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},A0=e=>e!==null&&getComputedStyle(e).direction==="rtl",k0=2,wi=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:u,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),v=h===null?m.fontSize:h*g,f=c.resolveRichTextFontFamily(p)??m.fontFamily,y=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+k0)/s;return Math.max(l,Math.min(y,P0(a,(0,d.alignUnitFractions)(i).x)))}},P0=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,o)},ji=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new d.SetLegendPositionCommand({position:"none"}),show:new d.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new d.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new d.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new d.SetGridVisibilityCommand({axis:a,visible:!1}),show:new d.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Me=()=>{const e=wu(),{store:t}=c.useGraphContext();return(0,x.useCallback)(n=>e(n)||ji(n,t.getState().scene)!==null,[e,t])},$n=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Wn=(e,t,n,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 l=t.textAnnotations.find(u=>u.id===a.annotationId);if(l===void 0||Fe(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(new d.RemoveAnnotationCommand({id:a.annotationId}))},$e=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,L0=(e,t,n)=>{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(...I0(i,e,t,n))}return o},zr=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},I0=(e,t,n,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||$e(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const u=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(u===null)continue;const h=E0(s,t.coordSystem,u);a.push({x:u.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:h.x,y:h.y}})}return a.sort((i,s)=>i.x-s.x),a},E0=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[d.POSITION_VARIABLES.x],a=e[d.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},We=()=>{const e=c.useGraphSelection();return cn(e)},cn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},M0=e=>{const{selectionStore:t,commands:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:u,overlayRef:h}=c.useHoverContext(),p=Me(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(P=>P.spec.annotations.textAnnotations)),v=(0,x.useRef)(null),f=(0,x.useRef)(null),y=(0,x.useRef)(!0),S=(0,x.useRef)(new WeakSet),{showAnnotations:C,showMenuTriggerOnHover:k}=c.MODE_RULES[c.useGraphMode()],w=(0,x.useCallback)(P=>{const{selection:M}=t.getState(),E=C?cn(M):null;E!==null&&(P.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:E})),e.focus({preventScroll:!0}))},[e,n,t,C]),A=(0,x.useCallback)(P=>{if(Be(P.target,o))return;const M=C?cn(t.getState().selection):null;M!==null&&g.current.some(E=>E.id===M)&&(P.preventDefault(),m.getState().setCaret(M))},[m,t,g,o,C]),j=(0,x.useCallback)(P=>{const M=m.getState(),E=M.standingInteraction?.kind;if(E!==void 0){E!=="chrome-popup"&&E!=="arrow-draw"&&E!=="box-draw"&&M.releaseInteraction(E);return}if(M.caret!==null){Wn(m,i.getState().scene.annotations,n.dispatch,$n(a)),M.setCaret(null),e.focus({preventScroll:!0});return}return Be(P.target,o)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,o,i,n,a]);(0,x.useEffect)(()=>{const P=I=>{if(!Le(I.target,e,o)||vt(I.target))return;const T=Ee(I.target),b=m.getState(),R=b.caret!==null&&!Be(I.target,o);if(T&&!R)return;const z=()=>k&&I.target===e&&!T&&!I.metaKey&&!I.ctrlKey&&!I.altKey&&!I.shiftKey&&b.standingInteraction===null&&t.getState().selection.length===0,X=()=>{if(!z())return;const K=L0(i.getState().scene,s,p);if(K.length===0)return;const _=l.getState().hover.primary,H=I.key==="ArrowRight"||I.key==="ArrowDown"?1:-1,W=v.current===null?zr(K,_):zr(K,v.current.primary),U=K[W<0?H>0?0:K.length-1:Math.min(K.length-1,Math.max(0,W+H))];if(U!==void 0){if(f.current===null){const ce=Pe(_);ce!==null&&!dt(ce,Pe(U.primary))&&(f.current=ce)}v.current=U,I.preventDefault(),M(U)}},te=()=>{if(!z())return;const K=v.current;K!==null&&(v.current=null,f.current=null,I.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([K.target]))};switch(I.key){case"Escape":return j(I);case"Enter":return T||(A(I),m.getState().caret!==null)?void 0:te();case"Delete":case"Backspace":return T?void 0:w(I);case"n":case"N":if(I.metaKey||I.ctrlKey||I.altKey||T||!k||I.target!==e||b.standingInteraction!==null)return;I.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return X();default:return}},M=I=>{const T=O0(u,I,i.getState().scene.coordSystem,F0(u,h.current));S.current.add(T),l.getState().setHoverState(T)},E=l.subscribe(I=>{const T=v.current;if(T===null||S.current.has(I.hover))return;const b=I.hover.primary;if(b===null){if(y.current){M(T);return}v.current=null,f.current=null;return}const R=Pe(b);if(dt(R,Pe(T.primary))){f.current=R;return}if(dt(R,f.current)){M(T);return}v.current=null,f.current=null}),B=h.current,N=()=>{y.current=!0},O=I=>{y.current=!1,!(v.current===null||R0(I,B,l))&&(v.current=null,f.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",N),B?.addEventListener("pointerleave",O),document.addEventListener("keydown",P),()=>{E(),B?.removeEventListener("pointerenter",N),B?.removeEventListener("pointerleave",O),document.removeEventListener("keydown",P)}},[e,w,A,j,o,m,k,t,i,s,p,l,u,h])},Ee=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),R0=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,d.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},Pe=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},O0=(e,t,n,o)=>{const a=_0(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(dt(Pe(i.primary),Pe(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}},_0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return N0(e.x,e.y,n);case"cartesian":return D0(e);default:return t}},N0=(e,t,n)=>{const o=(0,d.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},D0=e=>{const{observation:t,x:n,y:o}=e,a=rt(t,d.POSITION_VARIABLES.xMin),i=rt(t,d.POSITION_VARIABLES.xMax),s=rt(t,d.POSITION_VARIABLES.yMin),l=rt(t,d.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(u=>u>=0&&u<=1)?{x:(a+i)/2,y:(s+l)/2}:null},F0=(e,t)=>{const n=t?.getBoundingClientRect();return n===void 0||n.width<=0||n.height<=0?1:(e.setViewport({width:n.width,height:n.height}),n.width/n.height)},rt=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},dt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var B0="_1vbfegu3",Ue={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},G0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Ue})}),z0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Ue})}),H0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Ue})}),V0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...Ue})}),$0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...Ue})}),Un={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},W0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Un})}),U0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Un})}),q0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Un})}),Ae={side:"top",delay:200},Hr=.2,K0={type:"doc",content:[{type:"paragraph"}]},Vr={paddingInline:12,paddingBlock:10},X0=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(Y0,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},Y0=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:u}=c.useGraphContext(),{Button:h,ColorSwatches:p}=F(),m=ei(),g=ti(),v=wi(),[f,y]=(0,x.useState)({kind:"choose"}),S=c.useEditorState(I=>I.standingInteraction?.kind==="box-draw"),C=c.useEditorState(I=>I.standingInteraction?.kind==="arrow-draw"),k=!S&&!C,w=()=>{_e(a),a.getState().setPlotMenu(null)};(0,x.useEffect)(()=>()=>_e(a),[a]),(0,x.useEffect)(()=>{if(!S&&!C)return;const I=T=>{if(T.key!=="Escape"||!Le(T.target,e,s)||vt(T.target))return;const b=Ee(T.target),R=a.getState().caret!==null&&!Be(T.target,s);if(b&&!R)return;const z=a.getState().standingInteraction?.kind;z!=="arrow-draw"&&z!=="box-draw"||(T.preventDefault(),a.getState().releaseInteraction(z))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[s,S,C,a,e]);const A={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},j={top:{from:A.x,to:A.x+A.width},bottom:{from:A.x,to:A.x+A.width},left:{from:A.y,to:A.y+A.height},right:{from:A.y,to:A.y+A.height}},P=I=>{_e(a),y(T=>T.kind===I?{kind:"choose"}:{kind:I})},M=I=>(...T)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:I,start:n,...$r(T[0])})},E=(...I)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}_e(a),y({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...$r(I[0])})},B=()=>{const I=a.getState().standingInteraction?.kind;if((I==="arrow-draw"||I==="box-draw")&&!vt(document.activeElement)){a.getState().releaseInteraction(I);return}w()},N=I=>{_e(a);const T=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:K0,at:{anchorType:"panel",x:n.x,y:n.y},width:Hr}}),b=T.params.annotation.id,R=v({annotationId:b,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Hr,paddingInline:I===null?void 0:Vr.paddingInline}),z=new d.AddAnnotationCommand({kind:"text",annotation:{...T.params.annotation,width:R}});I===null?i.dispatch(z):i.dispatch(new d.SequenceCommand({commands:[z,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:b},declarations:{fill:I,...Vr}}})]})),u.getState().setSelection([{kind:"annotation",id:b}]),a.getState().setCaret(b,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},O=I=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:I}})),w()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:B0,style:{left:A.x,top:A.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),k&&(0,r.jsx)(Ci,{frameElement:e,boundary:A,spans:j,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:qa,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(G0,{}),onClick:()=>N(null)}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(z0,{}),expanded:f.kind==="sticky",onClick:()=>P("sticky")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(H0,{}),expanded:f.kind==="arrow",onClick:()=>P("arrow")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(V0,{}),expanded:S,onClick:E}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)($0,{}),expanded:f.kind==="sticker",onClick:()=>P("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:Fn,names:m,value:null,onChange:N,...Ae}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:N})]}),f.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([I,T])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":I,onClick:()=>O(I),children:(0,r.jsx)("img",{className:"vez73g9",src:T.src,alt:""})},I))}),f.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowOneWay"),onClick:M("end"),children:(0,r.jsx)(W0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:M("both"),children:(0,r.jsx)(U0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:M("none"),children:(0,r.jsx)(q0,{})})]})]})})]})},_e=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},$r=e=>{if(typeof e!="object"||e===null)return{};if("detail"in e&&e.detail===0)return{};if(!("clientX"in e)||!("clientY"in e))return{};const{clientX:t,clientY:n}=e;return typeof t!="number"||typeof n!="number"?{}:{pointer:{x:t,y:n}}},qe=e=>e.offset+e.strokeWidth,Wr="http://www.w3.org/2000/svg",Ur=new WeakMap,Z0=(e,t)=>{const n=J0(e);n.setAttribute("d",t);const{x:o,y:a,width:i,height:s}=n.getBBox();return{x:o,y:a,width:i,height:s}},J0=e=>{const t=Ur.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Wr,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const o=e.createElementNS(Wr,"path");return n.append(o),e.body.append(n),Ur.set(e,o),o},Q0=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=qe(o);switch(e.kind){case"observations":return Wt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>ep(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Wt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(op(s),a(s.axis)/2)),i);case"graph":return Wt([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},ep=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=np(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>tp(l,s))},tp=(e,t)=>{const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return a<=n||i<=o?[]:[{x:n,y:o,width:a-n,height:i-o}]},np=(e,t)=>e.kind==="boxes"?e.boxes:rp(e.shapes,t),rp=(e,t)=>{const n=[],o=new Map;for(const a of e){if(a.kind==="dots"){n.push(...a.centers.map(l=>c.growRect({...l,width:0,height:0},a.size/2)));continue}if(a.pathData==="")continue;const i=a.kind==="stroke"?a.width/2:0;if(!a.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(a.pathData),i));continue}const s=o.get(i)??[];s.push(a.pathData),o.set(i,s)}for(const[a,i]of o)n.push(c.growRect(t(i.join("")),a));return n},op=e=>{switch(e.kind){case"line":return{x:Math.min(e.from.x,e.to.x),y:Math.min(e.from.y,e.to.y),width:Math.abs(e.to.x-e.from.x),height:Math.abs(e.to.y-e.from.y)};case"ring":return{x:e.center.x-e.radius,y:e.center.y-e.radius,width:e.radius*2,height:e.radius*2}}},Wt=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var ap=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const o=e.vertex===null?e.parts:[...e.parts,e.vertex],a=o.reduce((s,l)=>Math.max(s,l.rows.length),0),i=a===1&&e.vertex===null;return a===0||i||a>1e3?null:o.flatMap(s=>ip(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},ip=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),sp=.5,lp={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},cp=(e,t,n)=>e===null||!dp(e)?{top:dn(t),right:un(t),bottom:dn(t),left:un(t)}:{top:ot(e,t,"top",n),right:ot(e,t,"right",n),bottom:ot(e,t,"bottom",n),left:ot(e,t,"left",n)},ot=(e,t,n,o)=>{const a=lp[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let u=-1/0;for(const f of e)u=Math.max(u,a(f));const h=u-Math.max(o,sp);let p=1/0,m=-1/0;for(const f of e)a(f)<h||(p=Math.min(p,s(f)),m=Math.max(m,l(f)));const g=i?un(t):dn(t),v={from:(0,pe.clamp)(p-o,g.from,g.to),to:(0,pe.clamp)(m+o,g.from,g.to)};return v.from<v.to?v:g},dp=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},dn=e=>({from:e.x,to:e.x+e.width}),un=e=>({from:e.y,to:e.y+e.height}),up=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,x.useRef)(new Map),u=e?.target??null,h=e?.outline??null;(0,x.useLayoutEffect)(()=>{if(u===null||h===null)return;const m=l.current,g=new Map,f=Q0(h,{panelRect:n,look:o,readGridLineWidth:C=>c.readGridLineStyle(i,C).strokeWidth,measurePathBox:C=>{const k=m.get(C)??Z0(t.ownerDocument,C);return g.set(C,k),k},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const y=cp(ap(h,{coordSystem:s,panelRect:n}),f,qe(o)),S=Si(t);a.getState().setSelectedOutline({target:u,frame:f,frameSpans:y,frameScale:S})},[a,i,s,u,h,t,n,o]);const p=e!==null;(0,x.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},qn="var(--_1qfw3e00)",hp="_1qfw3e01",pp="_1qfw3e02",qr=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(mp,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),mp=({pathData:e,source:t,...n})=>{const o=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(Ss.motion.path,{d:o,...n})},gp="var(--dppmab0)",vp="data-edit-outline-stroke",Ti=e=>({[vp]:"",style:(0,ve.assignInlineVars)({[gp]:`${e}px`})}),fp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=Ai(),l=c.useHoverState(u=>e?u.hover.primary:null);return(0,x.useMemo)(()=>{if(l===null)return null;const u=t.find(p=>p.id===l.layerId);if(u===void 0||$e(u,l.observation))return null;const h=(0,d.buildObservationsTarget)({layer:u,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:o});return h===null||!s(h)?null:ki({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},xp=()=>bp("pin"),bp=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=Ai(),[u]=c.useGraphSelection(),h=u?.kind==="observations"&&u.scope==="observation"?u:null;return(0,x.useMemo)(()=>{if(!t||h===null||!l(h))return null;const p=n.find(v=>v.id===h.layerId);if(p===void 0)return null;const[m]=(0,d.resolveObservationsTarget)({layer:p,target:h,parsingLocale:a}),g=m===void 0?void 0:p.data.getAt(m);return g==null||$e(p,g)?null:ki({layer:p,observation:g,target:h,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,a,o,i,s,e])},Ai=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,se.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),o=c.useGeomReaderTree(),a=Me();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},ki=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},yp=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,x.useMemo)(()=>e===null?null:Sp(e,t,n),[e,t,n])},Pi=(e,t,n)=>{const o=(0,d.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,d.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,d.findCompanionLayers)(o,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},Sp=(e,t,n)=>{switch(e.kind){case"observations":{const o=Pi(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Cp=()=>{const e=fp(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,o=c.useEditorState(l=>l.standingInteraction),a=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,se.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,x.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:Pi(e.target,i,s),[t,e,n,o,a,i,s])};var Kr=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},wp=(e,t)=>{const n=Math.max(e.width,8),o=Math.max(e.height,8),a=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-o/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+o/2);return{x:a,y:i,width:Math.max(0,s-a),height:Math.max(0,l-i)}},jp=[],Tp=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),o=c.useEditorState(g=>g.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,d.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,d.readRowScopeKey)(i,a.target.scope,a.observationIndex),u=(0,x.useMemo)(()=>i===void 0||s===null||l===null?null:Ap(t,i,s,l),[t,i,s,l]),h=(0,x.useMemo)(()=>u!==null&&e!==null&&Kr(u,e),[u,e]),p=Me(),m=a!==null&&i!==void 0&&kp(a,i,n,p)?a.observationIndex:null;return(0,x.useMemo)(()=>{switch(o?.kind){case"observations":{const g=u?.parts[0];if(u===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return h?v===null?null:{...u,parts:jp,vertex:v}:{...u,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,d.readEditTargetKey)(o.target),target:o.target};return e!==null&&Kr(g,e)?null:g}default:return null}},[o,u,h,m,e])},Ap=(e,t,n,o)=>{const a=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},kp=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},Pp=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(Lp(t))],s=l=>{const u=l.getBoundingClientRect();return{x:u.left-a.left,y:u.top-a.top,width:u.width,height:u.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?Ut(l):Ut([(0,d.getBoundingRect)(l)])}case"legend":return Ut([...Ip(i.filter(l=>!Ep(l)))].flatMap(([l,u])=>o[l]==="direct"?u.map(s):[(0,d.getBoundingRect)(u.map(s))]));case"grid":return i.flatMap(l=>{const u=c.readStampedEditTargetInStack([l],e);if(u?.kind!=="grid"||u.target.axis==="both")return[];const{axis:h}=u.target;return t.axis==="both"||h===t.axis?[Mp(l,s(l),h)]:[]})}},Lp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Ip=e=>{const t=new Map;for(const n of e){const o=c.readLegendItemAddress(n);o!==null&&t.set(o.legendIndex,[...t.get(o.legendIndex)??[],n])}return t},Ep=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,Ut=e=>e.map(t=>({kind:"box",rect:t})),Mp=(e,{x:t,y:n,width:o,height:a},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+o/2,y:n+a/2},radius:o/2}:o<1||a<1?o<a?{kind:"line",axis:i,from:{x:t+o/2,y:n},to:{x:t+o/2,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a/2},to:{x:t+o,y:n+a/2}}:Rp(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+o,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a},to:{x:t+o,y:n}},Rp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Op=[],_p=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(y=>y.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),u=Dp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Np(t,n),p=(0,x.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,x.useMemo)(()=>m?.map(y=>Xr(y,p,a))??Op,[m,p,a]),f=(0,x.useMemo)(()=>g===null?null:Xr(g,p,!1),[g,p]);return(0,x.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:u};case"graph":return{kind:"graph",frameSize:h}}},[e,v,f,u,h])},Np=(e,t)=>{const[n,o]=(0,x.useState)(()=>ln(e,t));return(0,x.useLayoutEffect)(()=>{o(a=>{const i=ln(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},Xr=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},u=a(e.geom,n.type);return u?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(h=>wp(h,o))}:{kind:"declared",layer:e,rows:t,shapes:u.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:u.symbols})}},Dp=(e,{frameElement:t,frameSize:n})=>{const o=c.useSceneSelector(p=>p.coordSystem.type),a=c.useSceneSelector((0,se.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=c.useSceneSelector(p=>e===null?null:p),[s,l]=(0,x.useState)([]),u=c.useLatestRef(e),h=(0,x.useRef)(!1);return(0,x.useLayoutEffect)(()=>{const p=u.current;if(p===null)return;const m=()=>{const g=Pp({frameElement:t,target:p,coordType:o,legendDisplays:a}),v=Si(t);l(g.map(f=>Fp(f,1/v)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,u,o,a,i,n.width,n.height]),s},Fp=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:o,width:a,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:o*t,width:a*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Bp=["x","y"],Gp=(0,x.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=yp(),s=Tp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Cp(),m=l||u||h,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(qt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:hp,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(qt,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(qt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),qt=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const u=(0,x.useId)(),h=`${u}-shapes`,p=`${u}-hole`,m=_p(t,{frameElement:s,frameSize:a,panelRect:i});return up(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:h,className:pp,children:(0,r.jsx)(Up,{outline:m,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${h}`,style:zp(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:Hp(o)}),(0,r.jsx)("use",{href:`#${h}`,style:Vp(o)})]}),t.kind==="observations"&&(0,r.jsx)(Jp,{target:t,look:o,panelRect:i})]}):null},zp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,ve.assignInlineVars)({[qn]:`${2*e}px`})}),Hp=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,ve.assignInlineVars)({[qn]:`${2*qe(e)}px`})}),Vp=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,ve.assignInlineVars)({[qn]:`${2*qe(e)}px`})}},$p=({dashArray:e,strokeWidth:t})=>{if((0,d.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},Li=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},Wp=(e,t,n)=>{const o=n.offset+qe(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Up=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=$p(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(Yr,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(Yr,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(Xp,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:Wp(e.frameSize,o,t)})}},Yr=(0,x.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(Kp,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(qp,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),qp=({shapes:e,layer:t,dashPeriod:n})=>e.map((o,a)=>{const i=o.kind==="dots"||o.key===void 0?String(a):`${o.kind}:${o.key}`;switch(o.kind){case"region":return o.pathData===""?null:(0,r.jsx)(qr,{pathData:o.pathData,fillRule:o.fillRule,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return o.pathData===""?null:(0,r.jsx)(qr,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...Ti(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:Li(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),Kp=({boxes:e,borderRadius:t})=>{const n=e.map(o=>c.buildRoundedRectPath(o,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Xp=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Bp.map(s=>{const l=Ti(c.readGridLineStyle(a,s).strokeWidth),u=t.map(p=>Yp(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(x.Fragment,{children:[u!==""&&(0,r.jsx)("path",{d:u,...l}),h.map((p,m)=>(0,r.jsx)("path",{d:Zp(p),pathLength:Li(p.radius,o),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Yp=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Zp=({center:e,radius:t})=>{const n=`${e.x},${e.y-t}`;return`M${n}A${t},${t} 0 0 1 ${`${e.x},${e.y+t}`}A${t},${t} 0 0 1 ${n}`},Jp=({target:e,look:t,panelRect:n})=>{const o=c.useSceneSelector(s=>s.coordSystem),a=e.parts[0];if(e.scope!=="xValue"||a===void 0||a.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Qp(a);return i===null?null:(0,r.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,r.jsx)("line",{...c.readCrosshairLine(o,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Qp=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,d.getXBand)(o),i=o===null?null:(0,d.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},em=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),tm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),nm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),rm={observation:em,xValue:tm,group:nm},om=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=It(a,o),s=c.useEditorState(S=>S.pressedObservation),l=Me(),u=(0,x.useMemo)(()=>am({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(u===null)return null;const{layer:h,levels:p,names:m}=u,{observationIndex:g,selectedFor:v}=u.pressed,f=p.map(S=>{const C=rm[S];return{value:S,label:m[S],icon:(0,r.jsx)(C,{})}}),y=S=>{const C=p.find(A=>A===S),{parsingLocale:k}=a.config,w=C===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:C,parsingLocale:k});w!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(jn,{value:v.scope,options:f,onChange:y,ariaLabel:n("editor.overlayMenu.selection")})},am=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:u}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,d.readReachableLevels)({layer:l,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(v=>{const f=(0,d.buildObservationsTarget)({layer:l,observationIndex:h,scope:v,parsingLocale:m});return f!==null&&i(f)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:$a({scene:e,layer:l,observation:u,groupOptions:n,locale:o,t:a})}},im=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),sm=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),lm="_11vjgg60",cm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,x.useState)(null),s=ji(e,o);if(s===null)return null;const{hidden:l,hide:u,show:h}=s,p=()=>{if(l){n.dispatch(a??h);return}i(h),n.dispatch(u)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?sm:im;return(0,r.jsx)(we,{label:m,children:(0,r.jsx)("button",{type:"button",className:lm,onClick:p,children:(0,r.jsx)(g,{title:""})})})},dm=(e,t)=>t==="polar"||e==="bar",um=(e,t)=>e===null||e.key!==t?null:{boundary:{x:e.x,y:e.y,width:0,height:0},spans:{top:{from:e.x,to:e.x},right:{from:e.y,to:e.y},bottom:{from:e.x,to:e.x},left:{from:e.y,to:e.y}}},hm="_1j45ehx0",pm="_1j45ehx1",mm="_1j45ehx2",gm="_1j45ehx3",vm=(e,t)=>{switch(e.kind){case"observations":return fm(e.scope,t);case"legend":case"axis":case"grid":return xm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},fm=(e,t)=>{switch(e){case"observation":return t("editor.overlayMenu.observation");case"group":return t("editor.overlayMenu.group");case"xValue":return t("editor.overlayMenu.band");default:return e}},xm=(e,t)=>{switch(e){case"axis":return t("editor.overlayMenu.axis");case"legend":return t("editor.overlayMenu.legend");case"grid":return t("editor.overlayMenu.gridLines");default:return e}},bm=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=It(o,n),i=(0,x.useMemo)(()=>Sm({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(ym,{title:i})},ym=({title:e})=>{const t=(0,x.useRef)(null),n=(0,x.useRef)(null),[o,a]=(0,x.useState)(!1),i=(0,x.useCallback)(()=>{const u=t.current,h=n.current;u===null||h===null||a(h.offsetWidth>u.clientWidth)},[]);(0,x.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,x.useCallback)(u=>{t.current=u,s(u)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:mm,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:gm,"aria-hidden":!0,children:e.whole})]})},Sm=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=vm(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[u]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),h=u===void 0?null:l.data.getAt(u);return h===null?s:rn({scene:t,layer:l,observation:h,groupOptions:n,locale:o,t:a},e.scope)},Cm=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=wm(c.useEditorState(p=>p.selectedOutline)),o=c.useEditorState(p=>p.annotatePress),a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=Cu(n?.target??null),s=Me(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,x.useMemo)(()=>a&&l!==null?um(o,l):null,[a,o,l]);if(n===null||l===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(Ci,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(Zt,{className:hm,children:[(0,r.jsxs)("div",{className:pm,children:[(0,r.jsx)(bm,{target:n.target}),(0,r.jsx)(cm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(om,{})]}),(0,r.jsx)(x.Fragment,{children:i},l)]})},wm=e=>{const t=c.useGraphSelection(),[n,o]=(0,x.useState)(e),a=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},jm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,x.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:u}=n;return{frame:s,client:{x:o+s.x*u,y:a+s.y*u,width:s.width*u,height:s.height*u},frameSpans:l,clientSpans:{top:at(l.top,o,u),right:at(l.right,a,u),bottom:at(l.bottom,o,u),left:at(l.left,a,u)}}},[n,o,a]);return(0,x.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,x.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},at=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Ii=["start","end"],Tm=({anchor:e,point:t,delta:n,bounds:o=d.PANEL_FRACTION_BOUNDS})=>{const a={x:Jr(t.x,n.x,o.minX,o.maxX),y:Jr(t.y,n.y,o.minY,o.maxY)};return{anchor:{...e,x:e.x+a.x,y:e.y+a.y},point:{x:t.x+a.x,y:t.y+a.y}}},Kn=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},Zr=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),Ei=(e,t)=>(0,pe.isEqual)(e,t),Am=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},km=(e,t,n)=>{const o=(0,d.projectAnchorToPanel)(e,n),a=(0,d.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},Jr=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,pe.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Et=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Mi=(e,t,n,o)=>{const a=e.textAnnotations.find(i=>i.id===t);return a===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(a,n),o)},Pm="var(--_1am0al60)";var Lm="_1am0al61",Im="_1am0al62",ee=(e,t)=>t>0?e/t:0,Ri=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?d.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)},Oi=(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)}),he=(e,t)=>{const n=t.getBoundingClientRect(),o=ln(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return Ri(e,a)},Xn=(e,t,n)=>({x:ee(t.x-e.x,n.width),y:ee(t.y-e.y,n.height)}),Em=e=>e.x!==0||e.y!==0,_i=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Mm=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=We(),i=c.useEditorState(y=>c.readStanding(y,"move-drag")),s=c.useEditorState(y=>c.readStanding(y,"shape-resize-drag")),l=c.useEditorState(y=>c.readStanding(y,"arrow-endpoint-drag")),u=c.useEditorState(y=>c.readStanding(y,"text-resize-drag")),h=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},m=Qr(t,a,p),g=Qr(t,h===a?null:h,p),v=y=>{if(s?.annotationId===y.id){const S=t.shapes.find(C=>C.id===y.id);return S===void 0?y.geometry:c.measureShapeRegion(s.region,o.annotation.shape(S.id).get("strokeWidth"),p.panel)}if(l?.annotationId===y.id){const S=t.arrows.find(C=>C.id===y.id);return S===void 0?y.geometry:c.measureArrowEnds(Kn(S,l,p.panel),p.panel)}return u?.annotationId===y.id?Mi(t,y.id,u,p)??y.geometry:y.geometry},f=y=>{if(i?.annotationId!==y)return e;const S=_i(i.translation,e);return{x:e.x+S.x,y:e.y+S.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(eo,{annotationId:g.id,geometry:v(g),state:"hovered",origin:f(g.id)}),m!==null&&(0,r.jsx)(eo,{annotationId:m.id,geometry:v(m),state:"selected",origin:f(m.id)})]})},Qr=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},eo=({annotationId:e,geometry:t,state:n,origin:o})=>{const a=c.useStyleReaderTree();if(t===null)return null;const i=a.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,ve.assignInlineVars)({[Pm]:Et(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(to,{point:t.start,origin:o}),(0,r.jsx)(to,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Lm,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:o.x+t.rect.x-2,top:o.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},to=({point:e,origin:t})=>(0,r.jsx)("span",{className:Im,style:{left:t.x+e.x,top:t.y+e.y}}),Yn="c44vv80",Rm=({panelRect:e})=>{const t=c.useEditorState(a=>c.readStanding(a,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=_i(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x+o.x,top:e.y+o.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:Nm(n,t.annotationId,e)})},Om=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Ne=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},_m={text:(e,t,n)=>Ne(e.textAnnotations,t,o=>(0,r.jsx)(Om,{annotation:o,panelSize:n})),shape:(e,t,n)=>Ne(e.shapes,t,o=>(0,r.jsx)(Fm,{shape:o,panelSize:n})),image:(e,t,n)=>Ne(e.images,t,o=>(0,r.jsx)(Gm,{image:o,panelSize:n})),arrow:(e,t,n)=>Ne(e.arrows,t,o=>(0,r.jsx)(Dm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Ne(e.stickers,t,o=>(0,r.jsx)(Bm,{sticker:o,panelSize:n}))},Nm=(e,t,n)=>{for(const o of Object.values(_m)){const a=o(e,t,n);if(a!==null)return a}return null},Dm=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Fm=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Bm=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Gm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),zm="_1lp7ph20",Hm=({panelRect:e})=>{const t=c.useEditorState(n=>c.readStanding(n,"move-drag")?.placement??c.readStanding(n,"arrow-endpoint-drag")?.placement??null);return t===null?null:(0,r.jsx)(Vm,{placement:t,panelRect:e})},Vm=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),u=e.type==="snapped"?e.point:null,h=e.type==="snapped"?$m(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:zm,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(u!==null&&p.x===u.x&&p.y===u.y)return null;const f=o.alpha*(g?1:Math.max(0,1-m/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...Kt(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":Wm(e),children:[h!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:h.x,y:h.y,width:h.width,height:h.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,d.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...Kt(s)})]}),e.type==="offset"&&(0,r.jsxs)("g",{"data-testid":"snap-tether",children:[(0,r.jsx)("line",{x1:e.targetPoint.x,y1:e.targetPoint.y,x2:e.point.x,y2:e.point.y,...Kt(l)}),(0,r.jsx)("circle",{cx:e.targetPoint.x,cy:e.targetPoint.y,r:l.size/2,fill:(0,d.toPaintColor)(l.fill),fillOpacity:l.alpha,stroke:"none"})]})]})},Kt=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),$m=e=>e.target.type==="observation"?e.target.box:e.target.rect,Wm=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Um=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(o,a.id),s=(0,d.computeArrow)({arrow:Kn(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},qm=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),Ni=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),Km=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),Di=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Mt=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),Xm="var(--pvjfpx0)",Ym="var(--pvjfpx1)",Zm="pvjfpx2",Jm="pvjfpx3",Qm="pvjfpx4",eg="pvjfpx6 pvjfpx5",tg="pvjfpx7 pvjfpx6 pvjfpx5",ng="pvjfpx8 pvjfpx5",it=8,rg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o})=>{const a=t.y+e.y,i=a+e.height,s=a-8-44,l=i+8,u=o-it-44,h=(0,pe.clamp)(l<=u?l:s,it,u),p=it;return{top:h,left:p,available:Math.max(0,n-it*2),centre:t.x+e.x+e.width/2-p}},og=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,label:a,testId:i,children:s})=>{const{chartId:l}=c.useGraphContext(),u=rg({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o});return(0,r.jsx)("div",{className:Zm,style:{top:u.top,left:u.left,width:u.available},children:(0,r.jsx)(J.Root,{"aria-label":a,className:Jm,"data-testid":i,...At(l),style:(0,ve.assignInlineVars)({[Xm]:`${u.centre}px`,[Ym]:`${u.available}px`}),children:s})})},ag=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(re.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsxs)(re.Menu.Trigger,{render:(0,r.jsx)(J.Button,{}),"aria-label":e,className:ng,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(Ve,{size:"sm"})]}),(0,r.jsx)(J.MenuPopup,{popupAttributes:At(s),children:i})]})},ig=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(J.ColorPicker,{...e,popupAttributes:At(t)})},sg=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Qm,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),lg=({label:e,onClick:t,children:n})=>(0,r.jsx)(J.Button,{"aria-label":e,className:eg,onClick:t,children:n}),cg=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(J.Button,{"aria-label":e,"aria-pressed":t,className:tg,onClick:n,children:o}),V={Root:og,Dropdown:ag,MenuItem:J.MenuItem,ColorPicker:ig,Swatch:sg,IconButton:lg,ToggleButton:cg,Button:J.Button,Separator:J.Separator},dg={kind:"chrome-popup"},Rt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>e.commit(),[e]),(0,x.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(dg),()=>s("chrome-popup")},[t,n]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?o(i):a()}),close:a}},ug=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),hg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),pg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),mg=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],no=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Ni},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],ro=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:pg},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:ug},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:hg}],gg=(e,t)=>e.find(n=>n.value===t)??e[0];var vg=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(O=>O.spec.styles.overrides),h=c.useSceneSelector(O=>(0,d.readStyleCoord)(O.spec)),p=Rt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=gg(ro,(0,d.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",f=(0,x.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),y=(0,x.useMemo)(()=>({...f,part:"outline"}),[f]),S=(O,I)=>{const T=(0,d.findStyleRule)(u,{select:f},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...T,...O}}}),I)},C=O=>{const I=(0,d.findStyleRule)(u,{select:y},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:y,declarations:{...I,...O}}}))},k=O=>{S(O),p.close()},w=O=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:O})),p.close()},A=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},j=O=>S({stroke:O},{transient:!0}),P=O=>k({strokeWidth:O}),M=O=>w({startArrowheadStyle:O}),E=O=>k({dashArray:d.DASH_PRESETS.arrow[O]}),B=O=>w({endArrowheadStyle:O}),N=()=>C(v?{strokeWidth:0,shadow:"none"}:d.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:j,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:m.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Di,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(st,{options:mg,current:m.strokeWidth,onPick:P})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(qm,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(st,{options:no,current:e.startArrowheadStyle,onPick:M})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:g?.Icon!==void 0&&(0,r.jsx)(g.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(st,{options:ro,current:(0,d.toDashPreset)(m.dashArray),onPick:E})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Ni,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(st,{options:no,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:N,children:(0,r.jsx)(Km,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:A,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},st=({options:e,current:t,onPick:n})=>{const o=c.useI18n(),a=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)(V.MenuItem,{selected:i.value===t,onClick:a(i.value),children:[(0,r.jsx)("span",{children:o(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},fg="_1me29t10";var xg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ke=class{constructor(e){this.params=e,this.listeners=new AbortController,this.pendingEvent=null,this.scheduledFrame=null,this.hasMoved=!1,this.hasPublished=!1,this.confirmedDrag=!1,this.releasePoint=null,this.handleMove=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.hasMoved=!0,this.scheduledFrame===null&&(this.scheduledFrame=requestAnimationFrame(this.runFrame)))},this.handleUp=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.releasePoint={x:t.clientX,y:t.clientY},this.finish(!0))},this.handleLost=t=>{t.pointerId===this.params.pointerId&&this.finish(!1)},this.runFrame=()=>{this.scheduledFrame=null;const t=this.pendingEvent;if(this.pendingEvent=null,t===null)return;const n=this.params.editorStore.getState();if(this.hasPublished&&this.readOwn(n)===null)return;const o={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,o))return;this.confirmedDrag=!0;const a=this.resolvePreview(o,{altKey:t.altKey});a!==null&&(n.claimInteraction(a),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return xg(e,t)}settle(e){this.pendingEvent=null;const t=this.params.editorStore.getState(),n=this.readOwn(t);n!==null&&t.releaseInteraction(this.kind),e&&n!==null&&this.commit(n),e&&!this.confirmedDrag&&this.params.onClick!==void 0&&(document.activeElement===this.params.handle&&this.params.handle.blur(),this.params.onClick(this.releasePoint??this.params.press))}cancelFrame(){this.scheduledFrame!==null&&(cancelAnimationFrame(this.scheduledFrame),this.scheduledFrame=null)}},hn=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,a),l=e.offset??s,u=(l?.x??0)*(l?.unit==="px"?1:o.width),h=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-u,y:i.y-h}}},Zn=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Fi=["center",...Zn],bg=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Fi.filter(a=>a!==t)].map(a=>({align:a,point:(0,d.readRectPoint)(o,a)}))},Bi=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image")continue;const l=(0,d.readAnnotationBox)(s,n,o);l!==null&&a.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return a},yg=(e,t,n,o)=>{const a=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:ee(e.point.x-a.x,o.width),y:ee(e.point.y-a.y,o.height)}},Sg=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,pe.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Cg=class extends Ke{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:u}=i,h=he(l,u),p=(0,d.clampAnnotationTranslation)(s,Xn(o,e,l),h);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s,frameElement:l}=a(),u=(0,d.findAnnotation)(i,n);if(u!==null){if(t!==void 0&&u.kind==="text"){const h=Sg(pn(t,i,n,s),u.annotation);h!==null&&o(new d.UpdateAnnotationCommand({kind:"text",id:n,patch:h}));return}if(t!==void 0&&u.kind==="sticker"){const{anchor:h}=pn(t,i,n,s);if((0,pe.isEqual)(h,u.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}Em(e)&&o(new d.MoveAnnotationCommand({id:n,translation:e,bounds:he(s,l)}))}}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,u=s.stickers.find(g=>g.id===a);if(u===void 0)return null;const h=(0,d.projectAnchorToPanel)(u.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:h.x+p.x,y:h.y+p.y}}],h,hn(e.at,null,u.at,l),n,o,{targetAligns:Zn,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:ee(m.point.x-h.x,l.width),y:ee(m.point.y-h.y,l.height)},placement:m}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:u}=o,h=s.textAnnotations.find(f=>f.id===a);if(h===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:h},l,u);if(p===null)return null;const m=(0,d.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(bg(m,e.align,g),(0,d.readRectPoint)(m,e.align),hn(e.at,e.align,h.at,l),n,o,{targetAligns:Fi});return v===null?null:{kind:"move-drag",annotationId:a,translation:yg(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:u,editorStore:h}=this.params,{spec:p,scene:m,panelRect:g,frameElement:v,layers:f,coordSystem:y,measuredBoxes:S,readObservationBox:C}=a,k=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),w=Oi(he(g,v),{x:ee(t.x,g.width),y:ee(t.y,g.height)}),A=this.readOwn(h.getState())?.placement;return(0,d.resolvePointPlacement)({sourcePoints:e,current:o.altKey?null:n,panelRect:g,bounds:w,engine:l,layers:f,coordSystem:y,resolver:u,readObservationBox:C,annotationTargets:o.altKey?[]:Bi(m,k,g,S),snapDistance:8,releaseDistance:12,revealDistance:160,previous:A?.type==="snapped"?A.target:null,detachDistance:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!o.altKey,annotation:!o.altKey,free:!0}})}},pn=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,ee(a.x,o.width))),l=Math.max(0,Math.min(1,ee(a.y,o.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*o.width,y:l*o.height},nearby:[]}},ut=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,Gi=(e,t,n)=>{const o=ut(e,t,n);return o?.anchorType==="panel"?o:null},zi=(e,t)=>e==="start"?{start:t}:{end:t},wg=(e,t,{scene:n,panelRect:o,measuredBoxes:a,readObservationBox:i})=>{const s=(0,d.projectAnchorToPanel)(t,o),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,d.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,d.readAnnotationBox)(m,o,a);return g===null?l:(0,d.projectBoxToPanel)(g,o)}const{observationIndex:u}=t,{layerId:h}=e;if(u===void 0||h===void 0)return l;const p=i({layerId:h,observationIndex:u});return p===null?l:(0,d.projectBoxToPanel)(p,o)},jg=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},Tg=class extends Ke{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:u}=this.params,h=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:f,coordSystem:y,measuredBoxes:S,readObservationBox:C}=h,k=ut(p,n,o);if(k===null)return null;const w={x:e.x-a.x,y:e.y-a.y},A=(0,d.projectAnchorToPanel)(m[o],v),j=Oi(he(v,h.frameElement),{x:ee(A.x,v.width),y:ee(A.y,v.height)}),P=o==="start"?"end":"start",M=ut(p,n,P),E=M===null?void 0:wg(M,m[P],{scene:g,panelRect:v,measuredBoxes:S,readObservationBox:C}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),N=this.readOwn(u.getState())?.placement,O=b=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:A.x+w.x,y:A.y+w.y}}],current:t.altKey?null:hn(k,null,m[o],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:j,engine:s,layers:f,coordSystem:y,resolver:l,readObservationBox:C,annotationTargets:t.altKey?[]:Bi(g,B,v,S),snapDistance:8,releaseDistance:12,revealDistance:160,previous:N?.type==="snapped"?N.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:Zn,areaAlign:b,annotationAreaAlign:b,areaSnapDistance:16,facing:E,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),I=O("auto"),T=I?.type==="snapped"&&I.landing==="area"&&jg(I.anchor,M)?O(void 0):I;return T===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:T}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=ut(i,n,e);if(l===null)return;const u=pn(t,i,n,s).anchor;Ei(l,u)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:zi(e,u)}))}},Ag=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useSceneSelector((0,se.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),h=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...u,arrow:t,scene:h,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:m}),v=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,x.useCallback)(f=>({onPointerDown:y=>{if(y.button===0&&v.current===null){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{return}y.currentTarget.focus({preventScroll:!0}),y.preventDefault(),v.current=new Tg({handle:y.currentTarget,pointerId:y.pointerId,annotationId:e,endpoint:f,press:{x:y.clientX,y:y.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,a])},kg=[" ","Enter"],oo=4,Pg=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(h=>h.spec.annotations),l=c.useLatestRef(s),u=c.useLatestRef(a.dispatch);return(0,x.useEffect)(()=>()=>{for(const h of Ii)ao({editorStore:i,annotationId:e,endpoint:h,annotations:l.current,dispatch:u.current})},[i,e,l,u]),(0,x.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,h);if(kg.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){ao({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:a.dispatch});return}const C=Gi(s,e,h);if(C===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:Zr(C,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Lg(p.key,n);if(f===null)return;p.preventDefault();const{anchor:y,point:S}=Tm({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:f,bounds:he(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:Zr(y,S,n)})}}),[e,s,t,n,o,i,a])},ao=({editorStore:e,annotationId:t,endpoint:n,annotations:o,dispatch:a})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=Gi(o,t,n);l===null||Ei(l,s.placement.anchor)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:zi(n,s.placement.anchor)}))},Lg=(e,t)=>{const n=ee(oo,t.width),o=ee(oo,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Ig=e=>{const t=We(),n=Rg(t),o=Og(e.panelRect,t),a=_g(t);if(n===null||o===null)return null;const i=a.dragged===null?o:Kn(o,a.dragged,e.panelRect);return(0,r.jsx)(Eg,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Eg=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Ag({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Pg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[o&&(0,r.jsx)(vg,{arrow:e,arrowBox:km(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&Ii.map(m=>(0,r.jsx)(Mg,{endpoint:m,point:Am(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},Mg=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:fg,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Rg=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},Og=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},_g=e=>c.useEditorState((0,se.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),Ng=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),io={small:2,medium:3,large:5},Dg=(e,t)=>{const n=Object.keys(io),o=n.find(a=>{const i=io[a];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&Fg(e.label,d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},Fg=(e,t,n)=>!(t.fontSize!==void 0&&e.fontSize!==t.fontSize*n||t.fontWeight!==void 0&&e.fontWeight!==t.fontWeight||t.paddingInline!==void 0&&e.paddingInline!==t.paddingInline||t.paddingBlock!==void 0&&e.paddingBlock!==t.paddingBlock||t.strokeWidth!==void 0&&e.strokeWidth!==t.strokeWidth),Bg="q7gcrz0",Gg="q7gcrz1",zg="q7gcrz2";var Hg=["absoluteDifference","relativeDifference","proportion"],so=["absoluteDifference","relativeDifference"],Vg=["relativeDifference","proportion"],$g={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},Wg=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,x.useMemo)(()=>{const a=(0,d.areEndpointsComparable)(e.start,e.end);return Hg.filter(i=>a||!so.includes(i)||i===e.label).map(i=>({kind:i,key:$g[i],preview:(0,d.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!so.includes(i),suspect:Vg.includes(i)&&e.start.measurementValue===0}))},[e,o])},lo=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],Ug=({arrow:e,color:t,labelBox:n,panelRect:o,frameWidth:a,frameHeight:i,frameElement:s})=>{const l=c.useI18n(),{commands:u}=c.useGraphContext(),h=c.useSceneSelector(b=>b.spec.styles.overrides),p=c.useSceneSelector(b=>(0,d.readStyleCoord)(b.spec)),m=Rt(),g=Wg(e),v=c.useStyleReaderTree(),f=(0,d.resolveDifferenceArrowAnnotationStyle)(v,e.id),y=v.graph().get("textScale"),S=(0,x.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),C=(0,x.useMemo)(()=>({...S,part:"label"}),[S]),k=g.find(b=>b.kind===e.label),w=g.some(b=>b.pickable&&b.kind!==e.label),A=lo.find(b=>b.id===Dg(f,y)),j=(b,R)=>{u.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:b}),R)},P=b=>({...(0,d.findStyleRule)(h,{select:S},p)?.declarations,...b}),M=b=>({...(0,d.findStyleRule)(h,{select:C},p)?.declarations,...b}),E=b=>{j(b),m.close()},B=()=>{u.dispatch(new d.RemoveAnnotationCommand({id:e.id})),s.focus({preventScroll:!0})},N=b=>u.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:S,declarations:P({stroke:b})}}),{transient:!0}),O=()=>j({start:e.end.anchor,end:e.start.anchor}),I=b=>()=>E({label:b}),T=b=>()=>{const R=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[b];u.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:P(R.arrow),label:M(R.label)})),m.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:o,frameWidth:a,frameHeight:i,label:l("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(qg,{option:k}),disabled:!w,...m.bind("labelKind"),children:g.map(b=>(0,r.jsxs)(V.MenuItem,{selected:b.kind===e.label,disabled:!b.pickable,onClick:I(b.kind),children:[(0,r.jsx)("span",{children:l(b.key)}),(b.suspect||!b.pickable)&&(0,r.jsx)("span",{"aria-label":l(b.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:zg,children:b.preview})]},b.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:l("graph.annotations.differenceArrowToolbar.color"),onChange:N,...m.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:A===void 0?"":l(A.key),...m.bind("size"),children:lo.map(b=>(0,r.jsx)(V.MenuItem,{selected:b.id===A?.id,onClick:T(b.id),children:l(b.key)},b.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:l("graph.annotations.differenceArrowToolbar.swap"),onClick:O,children:(0,r.jsx)(Ng,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:l("graph.annotations.differenceArrowToolbar.remove"),onClick:B,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},qg=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Gg,children:t(e.key)}),(0,r.jsxs)("span",{className:Bg,children:["(",e.preview,")"]})]})},Hi="var(--ydgo3h0)";var Kg="ydgo3h1",Xg="ydgo3h2",Yg="ydgo3h3",Zg="ydgo3h4",Jg=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=Qg({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=o.query((0,d.toPanelCursor)(h,n));if(p===null)return null;const m=a.find(v=>v.id===p.layerId);if(m===void 0)return null;const g=(0,d.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,d.readObservationIndex)(p),coordSystem:i,align:u});return g===null||(0,d.areAnchorsEqual)(g.anchor,l)||(0,d.areSameStackEndpoints)(m,g.anchor,l)?null:g},Qg=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Vi=e=>e==="start"?"end":"start",$i=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,d.areAnchorsEqual)(o,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},ev=class extends Ke{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:u,coordSystem:h}=n(),p=Jg({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:u,coordSystem:h,resolver:a,fixedAnchor:i[Vi(t)].anchor,align:i[t].anchor.align});return p===null?null:{kind:"difference-arrow-endpoint-drag",annotationId:i.id,endpoint:t,point:p}}commit({point:e,endpoint:t}){const{dispatch:n,readInputs:o}=this.params;$i({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},tv=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,se.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=c.useLatestRef(o),p=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,x.useCallback)(m=>({onPointerDown:g=>{if(g.button===0&&p.current===null){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{return}g.currentTarget.focus({preventScroll:!0}),g.preventDefault(),p.current=new ev({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>u.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>h.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[u,h,l,s,i,a])},nv=[" ","Enter"],rv=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,se.useShallow)(u=>({layers:u.layers,coordSystem:u.coordSystem,mainAxis:(0,d.readMainAxis)(u.coordSystem)}))),l=e.id;return(0,x.useEffect)(()=>()=>{const u=o.getState();c.readStanding(u,"difference-arrow-endpoint-drag")?.annotationId===l&&u.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,x.useCallback)(u=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=o.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,u);if(nv.includes(h.key)){if(h.preventDefault(),h.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:e[u]});p.releaseInteraction("difference-arrow-endpoint-drag"),$i({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=ov(h.key,s);if(g===null)return;h.preventDefault();const v=av({arrow:e,endpoint:u,from:m.point.anchor,move:g,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:v})}}),[e,o,t,n,a,i,s])},ov=(e,t)=>{const n=e==="ArrowUp"||e==="ArrowDown";return!n&&!(e==="ArrowLeft"||e==="ArrowRight")?null:{axis:t==="x"===n?"cross":"main",step:e==="ArrowDown"||e==="ArrowRight"?1:-1}},av=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const u=s.createLayerMeasurement(l);if(u===null)return null;const{align:h}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Vi(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,m)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:u})})?.point??null},iv=e=>{const t=We(),n=c.useDifferenceArrowGeometries(),o=(0,x.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:Kg,children:[t!==null&&(0,r.jsx)(sv,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(cv,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},sv=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,x.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(lv,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,dragging:a.dragging,...n})},lv=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,panelRect:i,frameRect:s,frameElement:l,dragging:u})=>{const h=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,ve.assignInlineVars)({[Hi]:h}),children:[!u&&(0,r.jsx)(Ug,{arrow:e,color:t,labelBox:o,panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),(0,r.jsx)("div",{"aria-hidden":"true",className:Zg,"data-testid":"difference-arrow-selection-label",style:{left:i.x+a.x-2,top:i.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},cv=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,x.useRef)(n),u=e.committedArrow.id;(0,x.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===u&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,u]);const h=tv({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=rv({arrow:e.committedArrow}),m=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,ve.assignInlineVars)({[Hi]:m}),children:[(0,r.jsx)(co,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(co,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},co=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Xg,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":o||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:a?0:-1,...i,...a?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:Yg})}),dv="s8eewu0",uo="s8eewu1",uv=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(h=>c.readStanding(h,"arrow-draw")),o=c.useEditorState(h=>c.readStanding(h,"box-draw")),a=n?.start??o?.start??null,[i,s]=(0,x.useState)(null);if((0,x.useEffect)(()=>{if(n===null&&o===null)return;const h=(g,v)=>{const f=e.getBoundingClientRect();s({x:ho(g-f.left,0,f.width),y:ho(v-f.top,0,f.height)})},p=n?.pointer??o?.pointer;p!==void 0&&h(p.x,p.y);const m=g=>{h(g.clientX,g.clientY)};return document.addEventListener("pointermove",m,!0),document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointermove",m,!0),document.removeEventListener("pointerdown",m,!0),s(null)}},[n,o,e]),a===null||i===null)return null;const l=t.x+a.x*t.width,u=t.y+a.y*t.height;return(0,r.jsx)("svg",{className:dv,children:o===null?(0,r.jsx)("line",{className:uo,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:uo,fill:"none",x:Math.min(l,i.x),y:Math.min(u,i.y),width:Math.abs(i.x-l),height:Math.abs(i.y-u)})})},ho=(e,t,n)=>Math.min(Math.max(e,t),n),hv=({panelRect:e})=>{const t=c.useEditorState(i=>c.readStanding(i,"shape-resize-drag")),n=c.useResolvedAnnotations(e).shapes,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(i=>i.id===t.annotationId);return a===void 0?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Yn,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ShapeAnnotation,{shape:{...a,region:t.region},style:o.annotation.shape(a.id).resolve(),panel:e})})},pv="var(--o49ib40)",mv={sm:"o49ib41",md:"o49ib42"},gv={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Wi=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Et(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:gv[n],role:"button",style:{left:e.x,top:e.y,...(0,ve.assignInlineVars)({[pv]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:mv[o]})})},mn=[{width:0,key:"graph.annotations.shapeToolbar.border.none"},{width:2,key:"graph.annotations.shapeToolbar.border.thin"},{width:8,key:"graph.annotations.shapeToolbar.border.medium"},{width:16,key:"graph.annotations.shapeToolbar.border.thick"}],vv=e=>[...mn].reverse().find(t=>t.width<=e)??mn[0],fv=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(w=>w.spec.styles.overrides),h=c.useSceneSelector(w=>(0,d.readStyleCoord)(w.spec)),p=Rt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=vv(m.strokeWidth),v=(0,x.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),f=(w,A)=>{const j=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...j,...w}}}),A)},y=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},S=w=>f({fill:w},{transient:!0}),C=w=>f({fillAlpha:w},{transient:!0}),k=w=>()=>{f({strokeWidth:w}),p.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:S,opacity:m.fillAlpha,onOpacityChange:C,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Di,{size:"sm",title:""}),...p.bind("border"),children:mn.map(w=>(0,r.jsx)(V.MenuItem,{selected:w.width===g?.width,onClick:k(w.width),children:s(w.key)},w.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:y,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},gn=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,u=e+t,h=Math.min(a,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),u-h),f=(0,pe.clamp)(e+o,g,v);return{start:f,extent:u-f}}const p=Math.max(Math.min(s,u),e+h),m=Math.max(l,u);return{start:e,extent:(0,pe.clamp)(u+o,p,m)-e}},xv=["top-left","top-right","bottom-right","bottom-left"];var Ui=({width:e,height:t})=>({x:ee(16,e),y:ee(16,t)}),bv=(e,t)=>({x:Xi(t)?e.x:e.x+e.width,y:Yi(t)?e.y:e.y+e.height}),qi=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=gn({start:e.x,extent:e.width,moveStartEdge:Xi(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=gn({start:e.y,extent:e.height,moveStartEdge:Yi(t),delta:n.y,minExtent:o.y,...a===void 0?{}:{bounds:{min:a.minY,max:a.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},Ki=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Xi=e=>e==="top-left"||e==="bottom-left",Yi=e=>e==="top-left"||e==="top-right",Zi=e=>{const t=c.useLatestRef(e),n=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,x.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},wt=(e,t)=>{const n=e.shapes.find(o=>o.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},yv=class extends Ke{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=wt(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:qi({region:u,corner:n,delta:Xn(o,e,s),minSize:Ui(s),bounds:he(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=wt(o().annotations,t);a===null||Ki(a,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Sv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Zi((s,l)=>new yv({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Cv=[" ","Enter"],Ji=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,x.useEffect)(()=>()=>po(t,n.current),[t,n]),(0,x.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(Cv.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){po(t,n.current);return}const u=n.current.claim(o);if(u===null)return;i.claimInteraction(u);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},po=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},mo=4,wv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return Ji({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=wt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=jv(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:qi({region:s.region,corner:l,delta:h,minSize:Ui(t),bounds:he(t,n)})}},commit:({region:s})=>{const l=wt(i,e);l===null||Ki(l,s)||o.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},jv=(e,t)=>{const n=ee(mo,t.width),o=ee(mo,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Tv={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},Av=e=>{const t=We(),n=Pv(t),o=Lv(t);if(n===null)return null;const a=o.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return a===null?null:(0,r.jsx)(kv,{shape:n,region:a,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},kv=({shape:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=Sv({annotationId:e.id,panelRect:a,frameElement:s}),h=wv({annotationId:e.id,panelRect:a,frameElement:s}),{rect:p}=c.measureShapeRegion(t,c.useStyleReaderTree().annotation.shape(e.id).resolve().strokeWidth,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(fv,{shape:e,shapeBox:p,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&xv.map(m=>{const g=bv(p,m);return(0,r.jsx)(Wi,{point:{x:a.x+g.x,y:a.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:Tv[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},Pv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},Lv=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),Iv=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var Qi=[{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:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),Ev=e=>Qi.find(t=>t.id===(e??"modern"))??null;var es=[{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"}],Mv=e=>es.find(t=>t.size===(e??15))??null,Rv=e=>`${e}px`,Ov=[{alignment:"left",Icon:ui},{alignment:"center",Icon:ci},{alignment:"right",Icon:di}],_v=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(_=>_.spec.styles.overrides),h=c.useSceneSelector(_=>(0,d.readStyleCoord)(_.spec)),p=c.useEditorStore(),m=Rt(),g=wi(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),f=qh(e.content),y=c.useEditorState(_=>_.caret?.editor??null),S=(0,Ce.useEditorState)({editor:y,selector:()=>mi(y)}),C=(0,Ce.useEditorState)({editor:y,selector:()=>gi(y)}),k=Ev(f.font??C),w=Mv(f.fontSize??S),A=c.useTextAnnotationTextColor(v),j=f.color??A,P=(0,x.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),M=(_,H)=>{const W=(0,d.findStyleRule)(u,{select:P},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:P,declarations:{...W,..._}}}),H)},E=(_,H)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:_}),H)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,N=(_,H)=>{const W=B(),U=p.getState().caret?.editor??null;if(U!==null&&!Fe(W)){U.chain().focus().setMark(He,_).run();return}E({content:Kh(W,_)},H)},O=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},I=_=>M(Nv(_),{transient:!0}),T=_=>M({fillAlpha:_},{transient:!0}),b=v.fill!==gt,R=_=>N({color:_===d.AUTO_COLOR?void 0:_},{transient:!0}),z=_=>()=>{Fe(B())||te({font:_}),N({font:_}),m.close()},X=_=>()=>{Fe(B())||te({fontSize:_}),N({fontSize:_}),m.close()},te=_=>{const H=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:H,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:_.fontSize??S,pickedFont:_.font??C});W>e.width&&E({width:W})},K=_=>{const H=p.getState().caret?.editor??null;if(H===null||Fe(B())){E({content:Xh(B(),_)});return}const W=H.state.storedMarks;H.chain().focus().setTextAlign(_).command(({tr:U})=>(U.setStoredMarks(W),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,d.toPaintColor)(v.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:I,opacity:b?v.fillAlpha:void 0,onOpacityChange:b?T:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:b?(0,d.toPaintColor)(v.fill):qu,opacity:b?v.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:f.color??d.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:R,...m.bind("color"),children:(0,r.jsx)(Iv,{size:"sm",textColor:j,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:k?.fontFamily},children:"Aa"}),...m.bind("font"),children:Qi.map(_=>(0,r.jsx)(V.MenuItem,{selected:_.id===k?.id,onClick:z(_.id),children:(0,r.jsx)("span",{style:{fontFamily:_.fontFamily},children:s(_.key)})},_.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:es.map(_=>(0,r.jsx)(V.MenuItem,{selected:_.size===w?.size,onClick:X(_.size),children:(0,r.jsx)("span",{style:{fontSize:Rv(_.size)},children:s(_.key)})},_.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(Dv,{current:f.alignment??"center",onPick:K}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:O,children:(0,r.jsx)(Mt,{size:"sm",title:""})})]})},Nv=e=>e==="transparent"?{fill:gt}:{fill:e,fillAlpha:Ju(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},Dv=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:Ov.map(a=>(0,r.jsx)(V.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:o(a.alignment),children:(0,r.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},Fv=["left","right"];var ts=({width:e})=>ee(60,e),Bv=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),ns=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,bounds:l})=>{if(a===0)return{at:e,width:t,shift:0};const u=(0,d.alignUnitFractions)(n).x,h=Gv(e.offset,s),p=gn({start:e.x+h-u*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...l===void 0?{}:{bounds:{min:l.minX,max:l.maxX}}}),m=p.start+u*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},rs=(e,t)=>e.at.x===t.at.x&&e.width===t.width,Gv=(e,t)=>e?.x===void 0?0:e.unit==="px"?ee(e.x,t):e.x,jt=(e,t)=>{const n=e.textAnnotations.find(o=>o.id===t);return n===void 0||n.at.anchorType!=="panel"?null:{at:n.at,width:n.width,align:n.align}},zv=class extends Ke{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=jt(i,t);if(u===null)return null;const h=Xn(o,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...ns({...u,edge:n,delta:h,minWidth:ts(s),panelWidth:s.width,bounds:he(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=jt(o().annotations,t);a===null||rs(a,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},Hv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Zi((s,l)=>new zv({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Vv=4,$v=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(l=>l.spec.annotations),s=(l,u)=>{const h=jt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...ns({...h,edge:l,delta:u,minWidth:ts(t),panelWidth:t.width,bounds:he(t,n)})}};return Ji({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=Wv(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=jt(i,e);u===null||rs(u,l)||o.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},Wv=(e,t)=>{const n=ee(Vv,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},Uv=e=>{const t=We(),n=Kv(t),o=Xv(t),a=c.useEditorState(s=>s.caret?.annotationId===t),i=Yv(e.panelRect,t,o.resized);return n===null||i===null?null:(0,r.jsx)(qv,{annotation:n,textBox:i,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:n.at.anchorType==="panel",hasCaret:a,...e})},qv=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=Hv({annotationId:e.id,panelRect:s,frameElement:u}),m=$v({annotationId:e.id,panelRect:s,frameElement:u});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(_v,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),a&&!o&&!i&&Fv.map(g=>{const v=Bv(t,g);return(0,r.jsx)(Wi,{point:{x:s.x+v.x,y:s.y+v.y},label:h(`graph.annotations.textToolbar.resize.${g}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":g},dragHandlers:p(g),keyboardHandlers:m(g)},g)})]})},Kv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},Xv=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),Yv=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,x.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:Mi(o,t,n,s)?.rect??null},Jn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],Zv=(e,t,n)=>c.readStampedEditTargetInStack(Jn(e,t),n),Jv="_1rpuha50";var go=["pointerdown","mousedown","pointerup","mouseup","click"],os=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,Qv=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>n1(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=o&&!t&&(e||n),s=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!i)return;const l=a.getState();l.setHoverState(d.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,a]),(0,x.useEffect)(()=>{const l=s.current;if(l===null)return;const u=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=e1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(t1(h)))};for(const h of go)l.addEventListener(h,u);return()=>{for(const h of go)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:Jv,"data-menu-shield":"","data-testid":"menu-shield"}):null},e1=(e,t)=>Jn(e,t).find(n=>!os(n))??null,t1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),n1=e=>e==="arrow-draw"||e==="box-draw",r1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',o1=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,x.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Le(i.target,e,n)||vt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(r1)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(u=>u===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},a1=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,x.useEffect)(()=>{let a=null;const i=u=>{if(Ee(u.target))return;const{caret:h}=o.getState(),p=h===null?null:Zv(u.clientX,u.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=u=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Le(u.target,e,n)||p())},l=u=>{t.getState().selection.length!==0&&Le(u.target,e,n)&&u.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Le(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{a!==null&&cancelAnimationFrame(a),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[o,t,e,n])},i1=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],o=n?.items[e.part.itemIndex];if(n===void 0||o===void 0)return null;const a=s1(n,o.layerId,t.layers);return a===null?null:(0,d.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:d1(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},s1=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=l1(o,a);if(i!==null)return i}return null},l1=(e,t)=>{for(const n of e){const o=(0,d.readVariableName)(n.mapping[t]);if(o!==null&&c1(n,o))return{layer:n,variable:o}}return null},c1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",d1=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,d.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},u1=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,d.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(a),u=i?.intersects!==!1,h=(0,d.readBroadestObservationsScope)(s),p=u||!(0,d.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:o});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:u,target:g}}return null},h1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,d.findLayerById)(t,e.layerId);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},vn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=vo(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,u=l&&i?p1(a):null,h=u===null?null:m1(e,u,t),p=h===null?null:u1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=vo(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?h:null,elements:g.elements}},p1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},vo=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const u=e||o?Jn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=c.readStampedEditTargetInStack(u,i);return h===null?{stamped:null,elements:u}:{stamped:(h.kind==="annotation"?o:a&&l(h.target))?h:null,elements:u}},m1=(e,t,n)=>{const o=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},g1=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:u}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||u?.intersects!==!0)return null;const h=o.find(g=>g.id===l.layerId);if(h===void 0||$e(h,l.observation)||!v1(h.spatialKind))return null;const p=(0,d.readObservationIndex)(l),m=(0,d.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:a});return m===null||!i(m)?null:{target:m,observationIndex:p}},v1=e=>{switch(e){case"noop":return!1;case"points":return!0;case"buckets":case"filledBuckets":case"spannedBuckets":case"rects":case"cells":case"renderHitTest":return!0;default:return e}},fo="data-annotation-id",f1='[data-testid="pinnedNumber"], [data-testid="comment"]',xo=(e,t,n)=>{if(e.target instanceof Element){const o=bo(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=bo(o,t);if(a!==null)return a}return null},x1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(o=>o.id===t)??e.annotations.comments.find(o=>o.id===t);return n===void 0?null:b1(e,n.at.anchor.layerId,n.at.observationIndex)},bo=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(f1);if(n===null||!t.contains(n))return null;const o=e.closest(`[${fo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(fo);return a===null||a.length===0?null:a},b1=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},y1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},S1=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!So(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(So(t,e)){const{primary:l,intersection:u}=o.query((0,d.toPanelCursor)(i,t),{tolerance:y1,viewport:{width:t.width,height:t.height}}),h=l===null?void 0:a.find(m=>m.id===l.layerId),p=l!==null&&h!==void 0&&$e(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=Ri({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:yo(i.x/t.width,s.minX,s.maxX),y:yo(i.y/t.height,s.minY,s.maxY)}},yo=(e,t,n)=>Math.min(Math.max(e,t),n),So=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,C1=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:o})=>{switch(e?.kind){case"annotation":return e.target.id===o?{kind:"keep-caret"}:{kind:"select-annotation",target:e.target};case"axis":case"legend":case"grid":return{kind:"select-guide",target:e.target};case"observations":return w1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},w1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},j1=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,T1=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:u}=c.useGraphContext(),{engine:h}=c.useHoverContext(),p=c.useEditorStore(),m=c.useSceneSelector((0,se.useShallow)(M=>({spec:M.spec.annotations,layers:M.layers,coordSystem:M.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),f=c.usePaintedObservationBoxes(t),y=c.useGraphMode(),{selectGraphOnPress:S}=c.MODE_RULES[y],C=c.useLatestRef(S),k=c.useLatestRef(y===c.GRAPH_MODES.annotate),w=c.useLatestRef(y===c.GRAPH_MODES.annotate),A=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:f}),j=c.useLatestRef(o),P=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>P.current?.finish(!1),[]),(0,x.useEffect)(()=>s.subscribe(({selection:M})=>{const E=p.getState().pressedObservation,[B,...N]=M,O=B!==void 0&&N.length===0&&E!==null&&(0,d.areEditTargetsEqual)(B,E.selectedFor);E!==null&&!O&&p.getState().setPressedObservation(null)}),[p,s]),(0,x.useEffect)(()=>{const M=T=>vn({target:T.target,clientX:T.clientX,clientY:T.clientY},n()).targetAtPoint,E=T=>{if(!(T.target instanceof Element))return!1;const b=T.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return b!==null&&e.contains(b)&&c.readStampedEditTargetInStack([T.target],e)===null},B=(T,b)=>{if(P.current!==null||!c.canMoveAnnotationOnCanvas(A.current.spec,b.id))return;try{e.setPointerCapture(T.pointerId)}catch{return}T.preventDefault();const R=new Cg({handle:e,pointerId:T.pointerId,annotationId:b.id,press:{x:T.clientX,y:T.clientY},readInputs:()=>A.current,editorStore:p,engine:h,anchorResolver:u,dispatch:a.dispatch,onSettled:()=>{P.current=null}});P.current=R,R.start()},N=(T,b)=>{const R=s.getState(),{layers:z,config:X,coordSystem:te}=l.getState().scene,K=b.kind==="select-observations"&&b.observationIndex!==null?c.readPressedObservation(b.observationIndex,z,b.target,X.parsingLocale):null;if(p.getState().setPressedObservation(K),k.current&&(b.kind==="select-observations"||b.kind==="select-band")){const _=(0,d.findLayerById)(z,b.target.layerId);if(_!==void 0&&dm(_.geom,te.type)){const H=e.getBoundingClientRect(),W=Vn(e,H.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(b.target),x:(T.clientX-H.left)/W,y:(T.clientY-H.top)/W})}else p.getState().setAnnotatePress(null)}switch(b.kind){case"select-annotation":R.setSelection([b.target]),B(T,b.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([b.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(b)}`})}},O=T=>{if(T.button!==0)return;if(os(T.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Jt(T.target))return;const b=p.getState().caret?.annotationId??null,R=T.target instanceof Element?T.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ee(T.target)&&R!==b&&Wn(p,l.getState().scene.annotations,a.dispatch,$n(i));const z=p.getState().standingInteraction,X=$=>{p.getState().releaseInteraction($),p.getState().setPlotMenu(null),s.getState().clearSelection()},te=he(A.current.panelRect,A.current.frameElement),K=$=>{const Z=e.getBoundingClientRect();return $.x<Z.left||$.x>Z.right||$.y<Z.top||$.y>Z.bottom};if(z?.kind==="arrow-draw"){const $=n(),Z=$.captureRect?.getBoundingClientRect()??null,ae={x:T.clientX,y:T.clientY};if(K(ae)){X("arrow-draw");return}const je=c.readArrowEnd({client:ae,capture:Z,bounds:te,engine:$.engine,layers:$.scene.layers,start:z.start});if(je===null)return;a.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(z.heads),start:{anchorType:"panel",x:z.start.x,y:z.start.y},end:je}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(z?.kind==="box-draw"){const $=n().captureRect?.getBoundingClientRect()??null,Z={x:T.clientX,y:T.clientY};if(K(Z)){X("box-draw");return}const ae=c.readDrawnPanelPoint(Z,$,te);if(ae===null||$===null||c.isTinySpan(z.start,ae,$))return;a.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(z.start,ae)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),E(T)||c.isOnLiveGeomMark(T.target,e))return;const _=n(),H=vn({target:T.target,clientX:T.clientX,clientY:T.clientY},_);if(w.current){const $=xo(T,e,H.elements),Z=$===null?null:x1(l.getState().scene,$);if(Z?.observationIndex!==void 0){p.getState().setCaret(null),N(T,{kind:"select-observations",target:Z,observationIndex:Z.observationIndex});return}}const W=T.target instanceof Node&&e.contains(T.target),U=C1(H.targetAtPoint,{canSelectGraph:C.current&&!Ee(T.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(U.kind==="keep-caret")return;const ce=U.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some($=>$.id===U.target.id);if((U.kind==="clear"||ce)&&k.current){const $=n();if(T.target===$.captureRect){const Z=g1({client:{x:T.clientX,y:T.clientY},capture:$.captureRect?.getBoundingClientRect()??null,engine:$.engine,layers:$.scene.layers,parsingLocale:$.scene.config.parsingLocale,hasMenu:$.hasOverlayMenu});if(Z!==null){p.getState().setCaret(null),N(T,{kind:"select-observations",target:Z.target,observationIndex:Z.observationIndex});return}}}const de=_.scene.coordSystem.type==="polar"&&U.kind==="select-observations";if(W&&(U.kind==="clear"||de)&&w.current&&xo(T,e,H.elements)===null&&!A1(T.target,H.elements)){const $=S1({client:{x:T.clientX,y:T.clientY},capture:_.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:_.engine,layers:_.scene.layers});if($!==null){p.getState().setCaret(null),N(T,{kind:"clear"}),p.getState().setPlotMenu($);return}}p.getState().setCaret(null),N(T,U)},I=T=>{if(Jt(T.target)||E(T)||c.isOnLiveGeomMark(T.target,e))return;const b=M(T),{layers:R,guides:z,config:X}=l.getState().scene,{hasOverlayMenu:te}=n(),K=s.getState(),_=p.getState();switch(b?.kind){case"observations":{const{observations:H}=b,W=h1(H,R,X.parsingLocale);if(W===null||!te(W))return;const{observationIndex:U}=H;_.setPressedObservation({observationIndex:U,predicate:W.predicate,selectedFor:W}),K.setSelection([W]);return}case"axis":case"legend":{const H=i1(b,{layers:R,legends:z.legends.drawn,formattedAxes:j.current,parsingLocale:X.parsingLocale});if(H===null||!te(H))return;K.setSelection([H]);return}case"annotation":{const{target:H}=b;if(!A.current.spec.textAnnotations.some(W=>W.id===H.id))return;K.setSelection([H]),_.setCaret(H.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",O),document.addEventListener("dblclick",I),()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("dblclick",I)}},[e,p,s,l,a,i,A,j,C,k,w,n,h,u])},A1=(e,t)=>Ee(e)||Co(e)||t.some(Co),Co=e=>e instanceof Element&&e.closest(j1)!==null,k1=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:u}=c.useGraphAnimation(),h=Me(),p=i&&!u;return(0,x.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,o,s,a,p,n,l,t])},P1={kind:"idle"},L1=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=xp();return(0,x.useMemo)(()=>e!==null?e:t===null?P1:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},I1=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,E1=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),u=c.useLatestRef(n);(0,x.useEffect)(()=>{const h=v=>{if(o.getState().selection.length>0)return;const f=u.current,y=l.current,S={x:v.clientX-y.x,y:v.clientY-y.y},C=I1(S,f)?i.query((0,d.toPanelCursor)(S,f)):d.RESTING_HOVER_STATE;a.getState().setHoverState(C)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{Jt(v.target)||p&&o.getState().selection.length===0&&h(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[o,s,a,i,l,u])},M1=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,x.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,x.useEffect)(()=>{let s=null,l=null,u=!1;const h=k=>{if(!i)return;const w=a.getState();w.suspendsHover||k===null&&w.hover.primary===null||w.setHoverState(k??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const k=n.getState();if(lt(k.standingInteraction))return;if(u&&(u=!1,l={...l,target:R1(l)}),c.isOnLiveGeomMark(l.target,e)){k.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:A}=vn(l,t());k.setEditTargetUnderPointer(w),h(A)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(u=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},f=k=>{l={target:k.target,clientX:k.clientX,clientY:k.clientY},u=!1,m()},y=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((k,w)=>{lt(w.standingInteraction)&&!lt(k.standingInteraction)&&g()}),C=o.subscribe((k,w)=>{k.scene!==w.scene&&(lt(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",y),()=>{s!==null&&cancelAnimationFrame(s),S(),C(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",y),v()}},[e,n,o,a,i,t])},R1=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,lt=e=>{if(e===null)return!1;switch(e.kind){case"move-drag":case"shape-resize-drag":case"difference-arrow-endpoint-drag":case"arrow-endpoint-drag":case"text-resize-drag":return!0;case"arrow-draw":case"box-draw":case"chrome-popup":return!1}},O1=(e,t,n,o,a)=>{const i=L1(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=k1(e);M1(e,h),T1(e,n,h,a),E1(i,t,n),a1(e),M0(e),o1(e,o);const p=l&&u;(0,x.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,x.useEffect)(()=>{if(!l||!u)return;const m=s.getState();m.setHoverState(d.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,u])},_1=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,commands:s,store:l,history:u}=c.useGraphContext(),h=c.useEditorStore(),p=(0,x.useRef)(()=>{});(0,x.useEffect)(()=>{p.current=()=>{Wn(h,l.getState().scene.annotations,s.dispatch,$n(u))}},[s,h,u,l]);const m=a?.width??0,g=a?.height??0,v=(0,x.useRef)({width:m,height:g});(0,x.useEffect)(()=>{const C=v.current;v.current={width:m,height:g},!(C.width===m&&C.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const f=c.useEditorState(C=>C.caret?.annotationId??null),y=c.useGraphMode(),S=(0,x.useRef)(y);return(0,x.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,x.useEffect)(()=>()=>{p.current();const C=h.getState();C.setCaret(null),C.setPressedObservation(null),C.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,x.useEffect)(()=>{if(S.current===y)return;S.current=y,p.current();const C=h.getState();C.setCaret(null),C.setEditTargetUnderPointer(null),C.setPlotMenu(null),i.getState().clearSelection()},[y,h,i]),a===null?null:(0,r.jsxs)(tl,{children:[f!==null&&(0,r.jsx)(N1,{annotationId:f,panelRect:t}),(0,r.jsx)(D1,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},N1=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,x.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},D1=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,x.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,x.useState)(null);return O1(e,a,n,i,o),(0,r.jsx)(F1,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},F1=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=kt(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Gp,{frameElement:e,frameSize:(0,x.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(jm,{frameRect:t}),(0,r.jsx)(f0,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:a,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iv,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(Av,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Ig,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Uv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Rm,{panelRect:o}),(0,r.jsx)(uv,{frameElement:e,panelRect:o}),(0,r.jsx)(hv,{panelRect:o}),(0,r.jsx)(Um,{panelRect:o}),(0,r.jsx)(Mm,{panelRect:o}),(0,r.jsx)(Hm,{panelRect:o})]}),(0,r.jsx)(Cm,{frameElement:e}),s&&(0,r.jsx)(X0,{frameElement:e,panelRect:o}),(0,r.jsx)(Qv,{})]})})]})},B1={},G1=({slots:e,palettePresets:t=B1,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,x.useMemo)(()=>({EditorSurface:_1,...e}),[e]);return(0,r.jsx)(Nn,{...a,children:(0,r.jsx)(Su,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(Qc,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:g0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},z1="_12lhx9e0",as=({children:e})=>(0,r.jsx)("div",{className:z1,children:e}),H1="_139ohwv0",ne=({children:e})=>(0,r.jsx)("div",{className:H1,children:e}),is=(0,x.createContext)(null),V1=is.Provider,ss=()=>{const e=(0,x.useContext)(is);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},$1="_1jlczkt0",ls="data-graphy-editor-panel",W1={List:ne,Grid:as};function U1(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var q1=()=>()=>{},K1=e=>{const t=(0,x.useSyncExternalStore)(e?.subscribe??q1,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},X1=e=>{const t=(0,x.useContext)(c.GraphContext),n=c.useChartI18nProps(K1(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(Y1,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(Nn,{...n,children:a})},Qn={Root:X1,Controls:W1},Y1=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[u,h]=(0,x.useState)(()=>o?[o]:[]),p=(0,x.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(Pt.Provider,{value:i,children:(0,r.jsx)(ca,{controls:n,children:(0,r.jsx)(V1,{value:p,children:(0,r.jsx)(De.Accordion.Root,{[ls]:"",className:(0,me.default)($1,a,{[s]:!U1(a)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},Z1="_2m7wuq0",J1=()=>(0,r.jsx)(Ms.Separator,{className:Z1}),Q1=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),er="_40zvwv0",tr="_40zvwv1",ef="_40zvwv2",cs="_40zvwv3",tf="_40zvwv4 _40zvwv3";var nf="_40zvwv6";var rf="_40zvwv8",Y=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(af,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(of,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:er,children:[(0,r.jsxs)("div",{className:tr,children:[(0,r.jsx)("span",{className:cs,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),o!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:o})]}),(0,r.jsx)("div",{children:i})]}),of=({title:e,accessory:t,children:n})=>{const o=(0,x.useId)(),a=(0,x.useId)();return(0,r.jsx)("div",{className:er,children:(0,r.jsxs)("div",{className:tr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:tf,children:e}),(0,r.jsx)("span",{className:nf,children:(0,r.jsx)(Ho,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},af=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(De.Accordion.Item,{value:e,className:er,onOpenChange:o,children:[(0,r.jsxs)(De.Accordion.Header,{className:tr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(De.Accordion.Trigger,{className:ef,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:cs,children:e}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:n}),(0,r.jsx)("span",{className:rf,children:(0,r.jsx)(Q1,{size:"sm"})})]}),(0,r.jsx)(De.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},ds=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=ss(),{Switch:u}=F(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(Y,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:o,ariaLabel:e}),children:i})},sf={horizontal:["bottom","top"],vertical:["left","right"]},lf={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},cf={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},ht=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{NumberField:l,Switch:u,TextField:h,ToggleGroup:p}=F();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const m=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,g=i.scales[e],v=g?.spec,f=v?.scaleType==="continuous"?v:void 0;if(m==="circular"||m==="radial"&&f===void 0)return null;const y=v?.scaleType==="continuous"||v?.scaleType==="datetime",S=f!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),C=f?.transform==="log",k=f?.domainMax??null,w=df(f),A=(D,ie)=>D.map(Ye=>({value:Ye,label:ie(Ye)})),j=i.guides.axes.find(D=>D.scaledAesthetic===e);if(j===void 0)return null;const P=j.position,M=i.guides.axes.filter(D=>D.scaledAesthetic===e),E=M.some(D=>D.visible),B=M.some(D=>D.visible||D.showGrid),N=e==="ySecondary"?i.config.axes.ySecondary?.label??j.label??"":i.config.axes[e].label??j.label??"",O=sf[P==="bottom"||P==="top"?"horizontal":"vertical"],I=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,T=I===null?void 0:(0,d.findLayerById)(i.spec.layers,I),b=i.guides.legends.drawn.some(D=>!D.inHeadlineRow&&O.some(ie=>ie===D.position)),R=O.map(D=>({value:D,label:s(lf[D])})),z=A(["auto","edges"],D=>s(D==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),X=A(["linear","log"],D=>s(D==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),te=A(["auto","zero","custom"],D=>s(D==="zero"?"editor.axesPanel.startFrom.zero":D==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),K=A(["auto","custom"],D=>s(D==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),_=A(["single","double"],D=>s(D==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),H=D=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:Xt(D,i.config.axes.y.visible)}));return}a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:D,keepSecondaryAxis:!0}))},W=D=>{a.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:D}),{transient:!0})},U=D=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:Xt(D,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:D,keepSecondaryAxis:!0}))},ce=D=>{const ie=D==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:Xt(ie,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:ie,keepSecondaryAxis:!0}))},de=D=>{a.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:D==="log"?"log":"linear"}))},$=D=>{a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,...D}),{transient:!0})},Z=D=>{D!==null&&$({domainMin:D})},ae=D=>{D!==null&&$({domainMax:D})},je=D=>{const ie=D==="auto"?null:D==="zero"?0:wo(g?.domain,"start");a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:ie}))},G=D=>{const ie=D==="custom"?wo(g?.domain,"end"):null;a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:ie}))},oe=D=>{T!==void 0&&a.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:T.id,yScaleType:D==="double"?"secondary":"primary"}))},ye=D=>{if(e==="ySecondary")return;const ie=O.find(Ye=>Ye===D);ie&&a.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:ie}))};return(0,r.jsx)(Y,{title:t??s(cf[e]),layout:n,preview:o,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:j.visible,onChange:H})}),T!==void 0&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(p,{value:T.yScaleType==="secondary"?"double":"single",options:_,onChange:oe})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[j.visible&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(h,{value:N,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:W,onCommit:a.commands.commit})}),E&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:j.showTicks,onChange:U})})]}),y&&B&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(p,{value:j.tickMode,options:z,onChange:ce})}),e!=="ySecondary"&&f&&m==="linear"&&j.visible&&!b&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(p,{value:j.position,options:R,onChange:ye})}),f&&!S&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(p,{value:C?"log":"linear",options:X,onChange:de})}),f&&!C&&(0,r.jsxs)(r.Fragment,{children:[!S&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(p,{value:w,options:te,onChange:je})}),w!=="auto"&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:f.domainMin??null,onChange:Z,onCommit:a.commands.commit})})]}),(0,r.jsx)(L,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(p,{value:k===null?"auto":"custom",options:K,onChange:G})}),k!==null&&(0,r.jsx)(L,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:k,onChange:ae,onCommit:a.commands.commit})})]})]})})},Xt=(e,t)=>e===t?void 0:e,df=e=>{const t=e?.domainMin??null;return t===null?"auto":t===0?"zero":"custom"},wo=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return typeof n=="number"?n:0},nr=({value:e,onChange:t})=>{const n=q(),o=c.useI18n(),{TextField:a}=F(),i=e!==null&&typeof e!="string",s=l=>t(l===""?null:l);return(0,r.jsx)(L,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},us=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(nr,{value:l.caption,onChange:h})]})})},jo=/^[a-z][a-z\d+.-]*:/i,uf={},hs=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=h=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(hf,{source:l.source??uf})]})})},hf=({source:e})=>{const t=q(),n=c.useI18n(),{TextField:o}=F(),a=u=>{const h=(u.label??"")!==""||(u.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:h?u:null}),{transient:!0})},i=()=>{const u=e.url??"";u!==""&&!jo.test(u)&&a({...e,url:`https://${u}`}),t.commands.commit()},s=u=>a({...e,url:u}),l=u=>a({...e,label:u});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:jo.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(L,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},ps=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(nr,{value:l.subtitle,onChange:h})]})})},Xe=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,x.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,x.useMemo)(()=>e===null?null:n.readers(e),[e,n])},rr=(e,t,n)=>{const o=Xe(e);return(0,x.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,d.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},fn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],pf=fn.length/2,mf={select:{target:"graph"}},ms=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=F(),l=Xe(a);if(!a||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=fn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=fn.find(y=>`${y}`===g);if(v===void 0)return;const f=(0,d.findStyleRule)(a.spec.styles.overrides,mf,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:pf,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},gs=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=F();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(nr,{value:l.title,onChange:h})]})})},gf=({children:e,...t})=>(0,r.jsx)(Qn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gs,{}),(0,r.jsx)(ps,{}),(0,r.jsx)(us,{}),(0,r.jsx)(hs,{}),(0,r.jsx)(ms,{})]})}),vf=({children:e,...t})=>(0,r.jsx)(Qn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ht,{axis:"x"}),(0,r.jsx)(ht,{axis:"y"}),(0,r.jsx)(ht,{axis:"ySecondary"})]})}),Ot=e=>`${e}px`,vs=e=>`${Math.round(e*100)}%`,ff=e=>`${e}°`,xf=24,bf={select:{target:"graph"}},To=["dim","desaturate"],yf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=F(),u=Xe(a);if(!a||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(a.spec),m=To.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const y=(0,d.findStyleRule)(a.spec.styles.overrides,bf,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...y,cornerRadius:f}}}),{transient:!0})},v=f=>{const y=To.find(S=>S===f);y&&o.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:y}))};return(0,r.jsx)(Y,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:xf,step:1,formatValue:Ot,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(L,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},Sf={none:0,md:3.5,full:6.5},Cf=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:Sf[e],stroke:"currentColor",strokeWidth:1.5})}),wf=.05,Ao=["none","md","full"],fs={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},jf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=F(),u=a?(0,d.findLayerByGeom)(a.spec.layers,"bar"):void 0,h=rr(a,u?.id??null,"bar");if(!a||!u||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=y=>{o.commands.dispatch(new d.SetBarWidthCommand({layerId:u.id,width:y}),{transient:!0})},m=h?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,g=(y,S)=>{const C=Ao.find(A=>A===S);if(!C)return;const[k,w]=fs[y];o.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[k]:C,[w]:C}}))},v=Ao.map(y=>({value:y,label:i(`editor.graphPanel.barSection.radiusOptions.${y}`),icon:(0,r.jsx)(Cf,{cornerRadius:y})})),f=(0,d.resolveBarBandFraction)(u.params,a.coordSystem.type);return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:wf,formatValue:vs,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(L,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:ko(m,"tip"),options:v,onChange:y=>g("tip",y)})}),(0,r.jsx)(L,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:ko(m,"base"),options:v,onChange:y=>g("base",y)})})]})})},ko=(e,t)=>{const[n,o]=fs[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},_t=({children:e})=>{const t=(0,x.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},Nt="qdaoth0",Tf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M12.0591 7.11C11.5767 7.11 11.1857 6.71899 11.1857 6.23664C11.1857 5.7543 11.5767 5.36328 12.0591 5.36328H24.8684C25.3507 5.36328 25.7417 5.7543 25.7417 6.23664V19.0459C25.7417 19.5283 25.3507 19.9193 24.8684 19.9193C24.386 19.9193 23.995 19.5283 23.995 19.0459V8.34512L6.8542 25.4859C6.51313 25.827 5.96015 25.827 5.61908 25.4859C5.27801 25.1448 5.27801 24.5919 5.61908 24.2508L22.7599 7.11H12.0591Z"})]}),Af=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(_t,{children:[(0,r.jsx)("path",{className:Nt,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,r.jsx)("path",{fill:"currentColor",d:"M24.25 9C24.25 8.30964 23.6904 7.75 23 7.75H9C8.30964 7.75 7.75 8.30964 7.75 9V23C7.75 23.6904 8.30964 24.25 9 24.25H23C23.6904 24.25 24.25 23.6904 24.25 23V9ZM25.75 23C25.75 24.5188 24.5188 25.75 23 25.75H9C7.48122 25.75 6.25 24.5188 6.25 23V9C6.25 7.48122 7.48122 6.25 9 6.25H23C24.5188 6.25 25.75 7.48122 25.75 9V23Z"})]})}),kf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,r.jsx)("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M25.25 22C25.25 20.7574 24.2426 19.75 23 19.75C21.7574 19.75 20.75 20.7574 20.75 22C20.75 23.2426 21.7574 24.25 23 24.25C24.2426 24.25 25.25 23.2426 25.25 22ZM23 18.25C25.0711 18.25 26.75 19.9289 26.75 22C26.75 24.0711 25.0711 25.75 23 25.75C20.9289 25.75 19.25 24.0711 19.25 22C19.25 19.9289 20.9289 18.25 23 18.25ZM11.25 9C11.25 7.75736 10.2426 6.75 9 6.75C7.75736 6.75 6.75 7.75736 6.75 9C6.75 10.2426 7.75736 11.25 9 11.25C10.2426 11.25 11.25 10.2426 11.25 9ZM9.75 12.675C11.4617 12.3275 12.75 10.8142 12.75 9C12.75 6.92893 11.0711 5.25 9 5.25C6.92893 5.25 5.25 6.92893 5.25 9C5.25 10.8142 6.53832 12.3275 8.25 12.675L8.25 24C8.25 24.4142 8.58579 24.75 9 24.75L16 24.75C16.4142 24.75 16.75 24.4142 16.75 24L16.75 7.75L22.25 7.75L22.25 14.1893L21.0303 12.9697C20.7374 12.6768 20.2626 12.6768 19.9697 12.9697C19.6768 13.2626 19.6768 13.7374 19.9697 14.0303L22.4697 16.5303C22.7626 16.8232 23.2374 16.8232 23.5303 16.5303L26.0303 14.0303C26.3232 13.7374 26.3232 13.2626 26.0303 12.9697C25.7374 12.6768 25.2626 12.6768 24.9697 12.9697L23.75 14.1893L23.75 7C23.75 6.58579 23.4142 6.25 23 6.25L16 6.25C15.5858 6.25 15.25 6.58579 15.25 7L15.25 23.25L9.75 23.25L9.75 12.675Z"})]}),Pf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(_t,{children:(0,r.jsx)("path",{className:Nt,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M8.41371 5H20.7271C21.1595 5 21.5325 5 21.8398 5.02507C22.1641 5.05157 22.4867 5.11007 22.7971 5.26822C23.2601 5.50416 23.6366 5.88064 23.8726 6.3437C24.0307 6.65409 24.0892 6.97666 24.1157 7.30097C24.1408 7.60823 24.1408 7.98127 24.1408 8.41369V9.10155C24.1408 9.55465 23.7735 9.92195 23.3205 9.92195C22.8674 9.92195 22.5001 9.55465 22.5001 9.10155V8.44533C22.5001 7.97237 22.4995 7.66699 22.4805 7.43457C22.4623 7.21172 22.4314 7.12909 22.4107 7.08853C22.3321 6.93418 22.2066 6.80869 22.0522 6.73004C22.0117 6.70938 21.9291 6.67847 21.7062 6.66026C21.4738 6.64127 21.1684 6.64063 20.6954 6.64063H15.3907V24.6877H20.0392C20.4922 24.6877 20.8595 25.0549 20.8595 25.508C20.8595 25.961 20.4922 26.3283 20.0392 26.3283H9.10159C8.64854 26.3283 8.28127 25.961 8.28127 25.508C8.28127 25.0549 8.64854 24.6877 9.10159 24.6877H13.7501V6.64063H8.44533C7.97238 6.64063 7.66699 6.64127 7.43457 6.66026C7.21172 6.67847 7.1291 6.70938 7.08854 6.73004C6.93418 6.80869 6.80869 6.93418 6.73004 7.08853C6.70938 7.12909 6.67847 7.21172 6.66026 7.43457C6.64127 7.66699 6.64063 7.97237 6.64063 8.44533V9.10155C6.64063 9.55465 6.27337 9.92195 5.82032 9.92195C5.36727 9.92195 5 9.55465 5 9.10155V8.41371C5 7.98128 5 7.60823 5.02508 7.30097C5.05157 6.97666 5.11007 6.65409 5.26823 6.3437C5.50417 5.88064 5.88064 5.50416 6.3437 5.26822C6.65409 5.11007 6.97666 5.05157 7.30097 5.02507C7.60824 5 7.98129 5 8.41371 5Z"})]}),Lf={x:.5,y:.5},If=.2,Ef={x:.375,y:.25,width:.25,height:.5},Mf={zOrder:"background"},Rf={x:.4,y:.6},Of={x:.6,y:.4},_f="relativeDifference",Nf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=F();if(!a)return null;const l=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Df(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Lf},width:If}}))},u=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...Rf},end:{anchorType:"panel",...Of}}}))},h=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Mf,region:{anchorType:"panel",...Ef}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:_f}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(Y,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(as,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Pf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Tf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Af,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(kf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Df=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Ff=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=F();if(!a)return null;const l=(0,d.readGraphType)(a.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const u=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=d.COMBO_TYPES.find(g=>g===p);m&&o.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:u,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Bf=.1,Gf=20,zf=({title:e,preview:t})=>{const n=q(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=F();if(!o||o.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(o.spec.layers),u=e??a("editor.annotationsPanel.goalSection.title"),h=(0,d.readConstantValue)(l?.mapping.y),p=typeof h=="number"?h:null,m=f=>{const y=new d.ToggleGoalLineCommand({showGoalLine:f,value:Hf(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(y)},g=f=>{if(l===void 0)return;const y=new d.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(y,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const y=new d.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(y,{transient:!0})};return(0,r.jsx)(ds,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(L,{label:a("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:a("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},Hf=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),o=n-Math.min(...t),a=o>0?o:Math.abs(n);if(a===0)return 0;const i=Math.min(Gf,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*Bf).toFixed(i))},Po=["auto","inside","outside"],Vf=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:u}=F();if(!i)return null;const h=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:f}=h.dataLabels,y=ha(h,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!y.supportsDataLabels)return null;const S=j=>{const P=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:j});a.commands.dispatch(P)},C=j=>{const P=Po.find(M=>M===j);P!==void 0&&a.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:P}))},k=j=>{const P=new d.SetDataLabelsFormatCommand({layerId:h.id,format:j?"percentage":"absolute"});a.commands.dispatch(P)},w=j=>{const P=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:j});a.commands.dispatch(P)},A=j=>{const P=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:j});a.commands.dispatch(P)};return(0,r.jsx)(Y,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),y.supportsPosition&&(0,r.jsx)(L,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:f,options:Po.map(j=>({value:j,label:s(`editor.graphPanel.graphOptions.labelPositions.${j}`)})),onChange:C})}),y.supportsPercentages&&(0,r.jsx)(L,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:k})}),y.supportsStackTotals&&(0,r.jsx)(L,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:w})}),y.supportsCategoryLabels&&(0,r.jsx)(L,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:A})})]})})},$f=3,Wf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=F(),l=(0,x.useMemo)(()=>Ge.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!ga(v,a?.spec)})),[i,a]);if(!a)return null;const u=(0,d.readGraphType)(a.spec),h=ft(u),p=m=>{const g=Ge.find(v=>v.name===m);g&&o.commands.dispatch(new d.SetGraphTypeCommand(va(g.summary,u)))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(h===null?void 0:i(`editor.graphTypes.${h.name}`)),children:(0,r.jsx)(s,{value:h?.name??"",options:l,columns:$f,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Uf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=F(),h=Xe(a),p=a!==null&&h!==null?Pa(a,h):null;if(p===null)return null;const m=p.axes.filter(C=>C.supportsGrid);if(m.length===0)return null;const g=p.axes.some(C=>C.showGrid),v=yt.map(C=>({value:C,label:i(`editor.graphPanel.gridSection.lineStyles.${C}`)})),f=C=>k=>{o.commands.dispatch(new d.SetGridVisibilityCommand({axis:C,visible:k}))},y=C=>{const k=yt.find(w=>w===C);k!==void 0&&o.commands.dispatch(La(k))},S=C=>{o.commands.dispatch(Ia(C),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[m.map(C=>(0,r.jsx)(L,{label:i(qf(C)),children:(0,r.jsx)(l,{checked:C.showGrid,onChange:f(C.scaledAesthetic)})},C.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:y})}),(0,r.jsx)(L,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Ot,onChange:S,onCommit:o.commands.commit})})]})]})})},qf=e=>e.geometry==="radial"?"editor.graphPanel.gridSection.rings":e.geometry==="circular"?"editor.graphPanel.gridSection.spokes":e.scaledAesthetic==="x"?"editor.graphPanel.gridSection.verticalGridLines":"editor.graphPanel.gridSection.horizontalGridLines",Kf="total",xs=["total","average","current"],Xf=["total"],Lo=["previous","first"],Io=["auto","small","medium","large"],Yf=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=F();if(!a)return null;const u=a.config.headline,h=u.show!=="none",p=a.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(N=>N.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?Xf:xs,y=a.guides.headline,S=y?.kind==="perGroup"&&y.items.some(N=>N.comparison!==null),C=f.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.metrics.${N}`)})),k=Lo.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.comparison.${N}`)})),w=Io.map(N=>({value:N,label:i(N==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${N}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],j=N=>{o.commands.dispatch(new d.SetHeadlineShowCommand({show:N?Kf:"none"}))},P=N=>{const O=f.find(I=>I===N);O&&o.commands.dispatch(new d.SetHeadlineShowCommand({show:O}))},M=N=>{const O=Lo.find(I=>I===N);O&&o.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:O}))},E=N=>{const O=Io.find(I=>I===N);O&&o.commands.dispatch(new d.SetHeadlineSizeCommand({size:O}))},B=N=>{o.commands.dispatch(new d.SetHeadlinePositionCommand({position:N==="center"?"center":"above"}))};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??Zf(i,u.show),children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:h,onChange:j})}),h&&(0,r.jsxs)(r.Fragment,{children:[C.length>1&&(0,r.jsx)(L,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:C,onChange:P})}),S&&(0,r.jsx)(L,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:k,onChange:M})}),(0,r.jsx)(L,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:w,onChange:E})}),g&&(0,r.jsx)(L,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:A,onChange:B})})]})]})})},Zf=(e,t)=>{const n=xs.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Yt=["top","bottom","left","right","none"],Eo=["auto","start","center","end"],Jf={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Mo=["auto","pill","direct"],Qf=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=q(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=F(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??Yt,m=i.guides.legends.drawn[0],g=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(v||!f))return null;const y=m?.position??"none",S=h==="auto"?y:h,C=Yt.filter(T=>T===S||p.includes(T)).map(T=>({value:T,label:s(`editor.graphPanel.legendSection.${T}`)})),k=T=>{const b=Yt.find(R=>R===T);b&&a.commands.dispatch(new d.SetLegendPositionCommand({position:b}))},w=T=>{const b=Eo.find(R=>R===T);b&&a.commands.dispatch(new d.SetLegendAlignCommand({align:b}))},A=T=>{const b=Mo.find(R=>R===T);b&&a.commands.dispatch(new d.SetLegendDisplayCommand({display:b}))},j=m?.position==="left"||m?.position==="right"?"column":"row",P=j==="row"?"ltr":u,M=T=>s(T==="start"||T==="end"?`editor.graphPanel.legendSection.${Jf[j][T]}`:`editor.graphPanel.legendSection.align.${T}`),E=Eo.map(T=>({value:T,label:M(T)})),B=Mo.map(T=>({value:T,label:s(`editor.graphPanel.legendSection.display.${T}`)})),N=t??s("editor.graphPanel.legendSection.title"),O=C.find(T=>T.value===S)?.label,I=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(Y,{title:N,layout:n,preview:o??O,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:C,onChange:k})}),I&&(0,r.jsx)(L,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Sn.DirectionProvider,{direction:P,children:(0,r.jsx)("div",{dir:P,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:E,onChange:w})})})}),g&&(0,r.jsx)(L,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},ex=1,tx=20,nx=.5,bs=({layerId:e})=>{const t=q(),n=c.useHandleScene(t),{Slider:o}=F(),a=rr(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(u=>(a?.get("size",u)??0)>0)??void 0,s=a?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=u=>{const h=new d.SetPointSizeCommand({layerId:e,size:u});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(o,{value:s,min:ex,max:tx,step:nx,formatValue:Ot,onChange:l,onCommit:t.commands.commit})},ys=({layerId:e})=>{const t=q(),n=c.useHandleScene(t),o=rr(n,e,"point");return n?(0,r.jsx)(Pn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},rx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=F(),p=Xe(a),m=(0,d.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?kn(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(j=>({value:j,label:pa(i,j)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],y=j=>{o.commands.dispatch(new d.ToggleLinePointsCommand({layerId:g.layerId,showPoints:j}))},S=j=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,showFill:j,drawnFillAlpha:g.drawnFillAlpha}))},C=j=>{o.commands.dispatch(new d.SetLineCurveCommand({layerId:g.layerId,curve:j?"smooth":"linear"}))},k=j=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j==="custom"?g.strokeWidth:null}))},w=j=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j}),{transient:!0})},A=j=>{const P=en.find(M=>M===j);P&&o.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:P}))};return(0,r.jsx)(Y,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:y})}),g.pointLayerId&&(0,r.jsx)(L,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(bs,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(ys,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(L,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:S})}),g.smooth!==null&&(0,r.jsx)(L,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:C})}),(0,r.jsx)(L,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:f,onChange:k})}),g.widthMode==="custom"&&(0,r.jsx)(L,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Ot,onChange:w,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(L,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:A})})]})})},xn="\0none",ox=["x","y","color","size","label"],ax={x:"editor.graphPanel.mappingSection.x",y:"editor.graphPanel.mappingSection.y",color:"editor.graphPanel.mappingSection.color",size:"editor.graphPanel.mappingSection.size",label:"editor.graphPanel.mappingSection.label"},ix=({title:e,layout:t="collapsible"})=>{const n=q(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=F(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,u=(0,x.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,ox).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:a(ax[h]),value:g??(m?null:xn),options:sx(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===xn?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(Y,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(ne,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(L,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},sx=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:xn,label:n}],...o.map(a=>({value:a,label:a}))]},lx="k",cx=2,dx=0,ux=5,bn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],hx=["auto","none"],px=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=F();if(!a)return null;const{abbreviation:u,decimals:h}=a.config.numberFormat,p=mx(u)!==void 0,m=h!=="auto",g=w=>w.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),v=bn.map(({value:w,labelKey:A})=>({value:w,label:i(`common.abbreviations.${A}`)})),f=w=>{o.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:w}))},y=w=>{const A=hx.find(j=>j===w);f(A??lx)},S=w=>{const A=bn.find(j=>j.value===w);A&&f(A.value)},C=w=>{o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w==="custom"?cx:"auto"}))},k=w=>{w!==null&&o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":u,options:g(["auto","none","custom"]),onChange:y})}),p&&(0,r.jsx)(L,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:S})}),(0,r.jsx)(L,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:C})}),m&&(0,r.jsx)(L,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:dx,max:ux,onChange:k,onCommit:o.commands.commit})})]})})},mx=e=>bn.find(t=>t.value===e),gx=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(q()),a=c.useI18n();if(!o)return null;const i=vx(o.spec.layers);return i?(0,r.jsx)(Y,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(bs,{layerId:i.id})}),(0,r.jsx)(ys,{layerId:i.id})]})}):null},vx=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},fx=.9,xx=360,bx=.05,yx=15,Sx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=F();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:u}=a.spec.coords.params,h=m=>{o.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{o.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(Y,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:fx,step:bx,formatValue:vs,onChange:h,onCommit:o.commands.commit})}),(0,r.jsx)(L,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:xx-1,step:yx,formatValue:ff,onChange:p,onCommit:o.commands.commit})})]})})},Cx=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),Ro=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),Oo=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],wx="linear",jx=({title:e,layout:t="collapsible",preview:n})=>{const o=q(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=F(),{options:u,findValue:h}=It(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(a.spec.layers),m=(0,d.findAverageLineLayer)(a.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:wx,v=Tx(m),f=Oo.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),y=(A,j={})=>{const P=p??m,M=new d.SetStatLineCommand({line:A,...j,...P!==void 0&&{layerId:P.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(M)},S=A=>y(A?"trend":"none",{method:g}),C=A=>y(A?"average":"none",{group:v??h(u[0]?.value??"")}),k=A=>{const j=Oo.find(P=>P===A);j!==void 0&&y("trend",{method:j})},w=A=>{const j=A===null?void 0:h(A);j!==void 0&&y("average",{group:j})};return(0,r.jsx)(Y,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Ro,{size:"lg"}),children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(L,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Ro,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(L,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:f,onChange:k,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(L,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(Cx,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:C})}),m!==void 0&&u.length>0&&(0,r.jsx)(L,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:u,onChange:w,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},Tx=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=yf;exports.AxesPanel=vf;exports.AxisEditMenu=Tn;exports.AxisSection=ht;exports.BarEditMenu=An;exports.BarSection=jf;exports.Button=Wo;exports.CalloutsSection=Nf;exports.CaptionSection=us;exports.ChartEditMenu=In;exports.ColorRow=ge;exports.ColorSwatches=Xo;exports.ComboSection=Ff;exports.ControlRegistryProvider=ca;exports.ControlTooltip=we;exports.CustomColor=Zo;exports.EditableGraphRenderer=G1;exports.EditorIntlProvider=Nn;exports.EditorPanel=Qn;exports.ElementsPanel=gf;exports.FileInput=Jo;exports.GoalSection=zf;exports.GraphOptionsSection=Vf;exports.GraphTypeSection=Wf;exports.GridEditMenu=En;exports.GridSection=Uf;exports.HeadlineSection=Yf;exports.LegendEditMenu=Ea;exports.LegendSection=Qf;exports.LineEditMenu=St;exports.LineSection=rx;exports.MappingSection=ix;exports.NumberField=ta;exports.NumberFormatSection=px;exports.PANEL_ROOT_ATTRIBUTE=ls;exports.PaletteRow=Ta;exports.PointEditMenu=On;exports.PointSection=gx;exports.PolarSection=Sx;exports.RadioGrid=na;exports.Row=L;exports.Section=Y;exports.Select=oa;exports.Separator=J1;exports.Slider=aa;exports.SourceSection=hs;exports.SubtitleSection=ps;exports.Switch=ia;exports.TextField=sa;exports.TextSizeSection=ms;exports.TitleSection=gs;exports.ToggleGroup=jn;exports.ToggledSection=ds;exports.TrendsAndAveragesSection=jx;exports.useAnnotateAnchor=Go;exports.useControls=F;exports.usePanelExpansion=ss;exports.usePanelGraph=q;