@graphysdk/react-renderer 1.9.0-beta.1795015443496 → 1.9.0-beta.1795022135575
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 +1 -1
- package/dist/editable.mjs +519 -503
- package/dist/{history-chords-B52rWY-3.cjs → history-chords-Brh9GUjC.cjs} +1 -1
- package/dist/{history-chords-BN_SvCJO.js → history-chords-eAw9OJIk.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/dist/editable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-B52rWY-3.cjs");let d=require("@graphysdk/viz-engine"),x=require("react"),r=require("react/jsx-runtime"),Es=require("motion/react"),se=require("zustand/react/shallow"),de=require("lodash-es"),fe=require("@vanilla-extract/dynamic"),ge=require("clsx");ge=c.__toESM(ge,1);let _e=require("@floating-ui/react-dom"),Pn=require("react-dom"),ce=require("@base-ui/react/tooltip"),te=require("@base-ui/react/popover"),dr=require("react-colorful"),vt=require("@base-ui/react/number-field"),Ho=require("@base-ui/react/radio"),Vo=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),Ne=require("@base-ui/react/slider"),ur=require("@base-ui/react/switch"),Ms=require("@base-ui/react/input"),Ln=require("@base-ui/react/direction-provider"),$o=require("@tiptap/core"),Rs=require("@tiptap/extension-bold"),ft=require("@tiptap/extension-document"),Os=require("@tiptap/extension-hard-break"),_s=require("@tiptap/extension-heading"),Ns=require("@tiptap/extension-italic"),Ds=require("@tiptap/extension-link"),Fs=require("@tiptap/extension-text"),Bs=require("@tiptap/extension-text-align"),xt=require("@tiptap/extension-text-style"),Gs=require("@tiptap/extension-underline"),It=require("@tiptap/extensions"),Wo=require("@tiptap/extension-paragraph"),we=require("@tiptap/react"),Se=require("@base-ui/react/toolbar"),ae=require("@base-ui/react/menu"),zs=require("@base-ui/react/toggle"),Ge=require("@base-ui/react/accordion"),Hs=require("@base-ui/react/separator");var Uo=(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}},qo=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,x.useMemo)(()=>Uo(e,t),[e,t])},Vs=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"})}),$s=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"})}),Ws=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"})}),Us=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"})}),qs=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"})}),Ks=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"})}),Ue=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"})})}),Ko=(0,x.createContext)(null),Xo=({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)(Ko.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,x.useContext)(Ko),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}}},xe="_18ja6qr0",In=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,x.useMemo)(()=>(0,fe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Yo="srewh00",Xs="srewh01",Ys={pointer:null,focus:null,last:"pointer"},Zo=(0,x.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),an=({className:e,children:t})=>{const[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(!1),[s,l]=(0,x.useState)(Ys),u=(0,x.useCallback)((f,b)=>{i(!1),l(C=>({...C,[b]:f,last:b}))},[]),h=(0,x.useCallback)((f,b)=>{l(C=>C[b]===f?{...C,[b]:null}:C)},[]),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)(Zo.Provider,{value:g,children:t})})},ye=({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)(Zo),g=(0,x.useId)(),[v,f]=(0,x.useState)(!1),b=s?!l&&(u===g||t&&u===null):v;(0,x.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const C=(y,k)=>{k.reason==="escape-key"&&(m(),k.allowPropagation()),f(y)};return(0,r.jsxs)(ce.Tooltip.Root,{open:b,onOpenChange:C,disableHoverablePopup:!0,children:[(0,r.jsx)(ce.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)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{side:n,sideOffset:6,className:Xs,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Yo,children:e})})})})]})},Zs=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Js="woi4bh0",Qs="woi4bh1";var el={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Jo=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:u,pressed:h,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const b=ue({id:f,ariaLabel:g,ariaLabelledBy:v}),C=o==="tile",y=(0,r.jsxs)("button",{type:"button",className:el[o],disabled:i,"aria-expanded":a,"aria-pressed":h,onClick:n,onPointerEnter:p,onPointerLeave:m,...b,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,ge.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:C?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Ue,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(ye,{label:u,side:s,delay:l,nameTrigger:!1,children:y}):o==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ye,{label:g,side:s,delay:l,children:y}):y},hr={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)"},tl="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))",nl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Qo="_14ty2ng0",pr="_14ty2ng1",rl="_14ty2ng2",ol="_14ty2ng3",ea="_14ty2ng4",al="_14ty2ng5",il="_14ty2ng6",bt="transparent",ta=e=>e==="transparent"?{background:tl,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:nl,border:`1px solid ${hr.border}`}:{background:e,border:`1px solid ${hr.border}`},na=({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=ue({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=a!==void 0||i,C=y=>{const k=y==="transparent"?v("graph.colorDropdown.transparent"):y,w=s?.[y],A=(0,r.jsx)("button",{type:"button","aria-label":w??k,className:ol,"data-active":En(y,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>o(y),children:(0,r.jsx)("span",{className:ea,style:ta(y)})},y);return w===void 0?A:(0,r.jsx)(ye,{label:w,side:l,delay:u,children:A},y)};return(0,r.jsxs)("div",{className:Qo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:rl,...f,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")]})]})]})},En=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),sl="data-graphy-chart-chrome",ll="data-graphy-chart-menu",cl={[ll]:""},Et=e=>({[sl]:e}),He=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,yt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,sn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Le=(e,t,n)=>e instanceof Node&&(t.contains(e)||He(e,n)),dl="cml7ha0",ra=(0,x.createContext)(null),ul=({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,Pn.createPortal)((0,r.jsx)("div",{ref:a,className:dl,...Et(t)}),n),(0,r.jsx)(ra.Provider,{value:o,children:e})]})},Mt=()=>(0,x.useContext)(ra),hl="_178jeit0",pl="_178jeit1 _14ty2ng3",ml="_178jeit2 _14ty2ng4",gl="_178jeit3",vl="_178jeit4",fl="_178jeit5",xl="_178jeit6",bl="_178jeit7",yl={side:"flip",align:"shift",fallbackAxisSide:"end"},oa=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=Mt(),[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)(te.Popover.Root,{open:l,onOpenChange:h,children:[a==="chip"?(0,r.jsx)(te.Popover.Trigger,{className:pl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:ml})}):(0,r.jsxs)("div",{className:Qo,children:[(0,r.jsx)("div",{className:pr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(te.Popover.Trigger,{className:gl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:ea,style:ta(p)}),(0,r.jsx)("span",{className:vl,children:m})]})]}),(0,r.jsx)(te.Popover.Portal,{container:s??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:yl,collisionPadding:12,disableAnchorTracking:a==="chip",className:hl,children:(0,r.jsxs)(te.Popover.Popup,{className:fl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:pr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(dr.HexColorPicker,{color:m,onChange:t,className:xl}),(0,r.jsx)(dr.HexColorInput,{color:m,onChange:t,prefixed:!0,className:bl,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Rt=(0,x.createContext)(null),K=()=>{const e=(0,x.useContext)(Rt);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},Ot=({children:e,onKeyDown:t,...n})=>{const o=(0,x.useContext)(Rt),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})},Sl="_6fidqf0 uz3g760",Cl="_6fidqf1 uz3g761",aa=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),u=h=>{const p=jl(h.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Ot,{className:Sl,children:(0,r.jsx)("input",{type:"date",className:Cl,value:wl(e),onChange:u,onBlur:n,disabled:o,...l})})},wl=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},jl=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},mr=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"})]})}),Tl="a1l6m80 woi4bh6 woi4bh5",Al="a1l6m81 _14ty2ng3",kl="a1l6m82",ia=({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:kl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(ye,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:Al,children:[(0,r.jsx)(mr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:Tl,children:[(0,r.jsx)("span",{className:Js,children:(0,r.jsx)(mr,{})}),(0,r.jsx)("span",{className:Qs,children:e}),h]})},sa="keyboard",_t=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()}}}},Pl="eh8dvc0",Ll="eh8dvc1 uz3g760",Il="eh8dvc2 uz3g761";var la=({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=ue({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:C}=_t(n);return(0,r.jsx)(vt.NumberField.Root,{className:Pl,value:e,onValueChange:y=>t(y),onValueCommitted:(y,k)=>{b(k.reason===sa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsxs)(Ot,{className:Ll,"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)(vt.NumberField.Input,{className:Il,placeholder:s,...C,"aria-invalid":p===!0?!0:void 0,...f}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},El="_1b7s5f0",Te={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Ml="_1b7s5f7";var Rl=6,ca=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",b=i==="chip",{commitAfterChange:C,gestureHandlers:y}=_t(o);return(0,r.jsx)(Vo.RadioGroup,{className:(0,ge.default)(El,Ol(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:k=>{n(k),C()},...y,disabled:s,...p,children:e.map(k=>{const w=(0,r.jsxs)(Ho.Radio.Root,{value:k.value,disabled:k.disabled,className:(0,ge.default)(Ml,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",b&&"_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&&!b)return w;const A=(v||b)&&k.value===t;return(0,r.jsx)(ye,{label:k.label,checked:A,children:w},k.value)})})},Ol=e=>{switch(Math.min(Math.max(Math.round(e),1),Rl)){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]}},da=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"})})}),_l="_1g5x15w0 uz3g760",Nl="_1g5x15w1",Dl="_1g5x15w2",gr="_1g5x15w3",Fl="_1g5x15w4",Bl="_1g5x15w5",Gl="_1g5x15w6",zl="_1g5x15w7";var ua=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l}),p=Mt();return(0,r.jsxs)(pe.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)(pe.Select.Trigger,{className:_l,"data-error":i===!0,...h,children:[(0,r.jsx)(pe.Select.Value,{className:Nl,children:m=>Hl(e,m,o)}),(0,r.jsx)(pe.Select.Icon,{className:gr,children:(0,r.jsx)(Ue,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:Fl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:Bl,children:e.map(m=>(0,r.jsxs)(pe.Select.Item,{value:m.value,disabled:m.disabled,className:Gl,children:[m.icon,(0,r.jsxs)("span",{className:zl,children:[(0,r.jsx)(pe.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:gr,children:(0,r.jsx)(da,{size:"sm"})})]},m.value))})})})})]})},Hl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Dl,children:n}):Vl(e,t),Vl=(e,t)=>e.find(n=>n.value===t)?.label??t,$l="vod76w0",Wl="vod76w1",Ul="vod76w2",ql="vod76w3",Kl="vod76w4",Xl="vod76w5";var ha=({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=ue({ariaLabel:p,ariaLabelledBy:m},!1),v=Yl(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:b}=_t(n);return(0,r.jsxs)("div",{className:$l,children:[(0,r.jsx)(Ne.Slider.Root,{className:Wl,value:e,onValueChange:C=>t(C),onValueCommitted:(C,y)=>{f(y.reason===sa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsx)(Ne.Slider.Control,{className:Ul,children:(0,r.jsxs)(Ne.Slider.Track,{className:ql,children:[(0,r.jsx)(Ne.Slider.Indicator,{className:Kl}),(0,r.jsx)(Ne.Slider.Thumb,{className:Xl,...b,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Yl=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Zl=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 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),Jl="cnu9yl0",Ql="_1n6f4bd0 cnu9yl1",ec="_1n6f4bd1",tc="_1n6f4bd2",nc="_1n6f4bd3 uz3g761";var rc=1e-9,pa=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:u,ariaLabelledBy:h,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=oc(e),b=ue({id:p,ariaLabel:u,ariaLabelledBy:h}),C=c.useI18n(),y=i??C("editor.accessibility.decrease"),k=s??C("editor.accessibility.increase"),[w,A]=(0,x.useState)(t),[T,I]=(0,x.useState)(t);t!==T&&(I(t),A(t));const E=t===null?void 0:f(t),L=t===null?void 0:v(t),B=P=>{P!==void 0&&(A(P),n(P))},F=P=>{const j=P===null?null:Math.min(Math.max(P,m),g);if(j!==null&&j!==t){n(j);return}A(t)},O=P=>{P.blur(),P.focus()};return(0,r.jsxs)("div",{className:Jl,children:[(0,r.jsx)(vr,{label:y,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||E===void 0,onPress:()=>B(E)}),(0,r.jsx)(vt.NumberField.Root,{className:ec,value:w,onValueChange:A,onValueCommitted:F,min:m,max:g,disabled:l,readOnly:!a,children:(0,r.jsxs)(Ot,{className:tc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(vt.NumberField.Input,{className:nc,onKeyDown:P=>{const j=P.currentTarget;if(P.key==="Enter"){O(j);return}if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventBaseUIHandler(),P.preventDefault(),P.repeat))return;const S=w??t;S!==null&&(O(j),B(P.key==="ArrowUp"?v(S):f(S)))},...b}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(vr,{label:k,icon:(0,r.jsx)(Zl,{}),disabled:l===!0||L===void 0,onPress:()=>B(L)})]})},vr=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ye,{label:e,children:(0,r.jsx)("button",{type:"button",className:Ql,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),oc=e=>{if(e.stops!==void 0){const{stops:l}=e,u=l[0],h=l.at(-1);if(u===void 0||h===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:u,max:h,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:o}=e;if(!(t>0))return{min:n,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(fr(t),fr(n)),i=l=>Math.min(Math.max(Number(l.toFixed(a)),n),o),s=(l,u)=>{const h=(l-n)/t,p=Math.round(h);return Math.abs(h-p)<rc?p:u(h)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},fr=e=>String(e).split(".")[1]?.length??0,ac="_1hyrlw60",ic="_1hyrlw61",ma=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(ur.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:ac,...s,children:(0,r.jsx)(ur.Switch.Thumb,{className:ic})})},sc="uz3g761",lc="tpcnun0 uz3g760",ga=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Ot,{className:lc,"data-error":i===!0,children:(0,r.jsx)(Ms.Input,{className:sc,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},cc="cnu9yl0",dc="cnu9yl1";var Mn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=_t(o);return(0,r.jsx)(Vo.RadioGroup,{className:cc,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const b=uc(f,m),C=(0,r.jsxs)(Ho.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,ge.default)(dc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[f.icon,va(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return b===void 0?C:(0,r.jsx)(ye,{label:b,checked:f.value===t,children:C},f.value)})})},va=(e,t)=>e.icon===void 0||t,uc=(e,t)=>{if(!va(e,t))return e.label},hc={ToggleGroup:Mn,Switch:ma,Slider:ha,RadioGrid:ca,Button:Jo,TextField:ga,NumberField:la,Stepper:pa,Select:ua,ColorSwatches:na,CustomColor:oa,DateField:aa,FileInput:ia},ln=(0,x.createContext)(hc),fa=({controls:e,children:t})=>{const n=(0,x.useContext)(ln),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,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,r.jsx)(ln.Provider,{value:o,children:t})},H=()=>(0,x.useContext)(ln),xr={stack:"pr583x0",grid:"pr583x1"},br="pr583x2",pc={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},M=({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)(an,{className:xr[t],children:(0,r.jsx)("div",{className:br,children:o})}):(0,r.jsxs)(an,{className:xr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:pc[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:br,children:(0,r.jsx)(Xo,{labelId:a,controlId:i,children:o})})]})},Rn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(mc,{graph:t,axis:e.axis})};Rn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var mc=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=H(),l=n?.guides.axes.find(L=>L.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(L=>L.position==="left"||L.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,b=f?.scaleType==="continuous"?f:void 0,C=b!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),y=b?.transform==="log"?"log":"linear",k=C&&b.transform!=="log",w=b?.domainMin??null,A=b!==void 0&&(l.position==="left"||l.position==="right")&&b.transform!=="log",T=b?.domainMax??null,I=n.config.axes[t]?.label??l.label??"",E=L=>{const B=t==="ySecondary"?{axis:t,label:L}:{axis:t,label:L};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:I,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:E,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(M,{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)(Ks,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(qs,{})}],onChange:L=>{const B=L==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(M,{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)(Vs,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)($s,{})}],onChange:L=>{if(L!=="left"&&L!=="right")return;const B=t==="y"?L:L==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),C&&(0,r.jsx)(M,{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)(Ws,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Us,{})}],onChange:L=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:L==="log"?"log":"linear"}))}})}),k&&(0,r.jsx)(M,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:w,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:L}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,r.jsx)(M,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:L}),{transient:!0})},onCommit:e.commands.commit})})]})},gc={narrow:3,regular:6,wide:11},vc=({barWidth:e,...t})=>{const n=gc[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"})})},fc=6,ve=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=ba(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)(xa,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},xa=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=H();return(0,r.jsx)(M,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:xc(t.slice(0,fc),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ve.hasRows=(e,{scene:t,findGeom:n})=>ba(e,t,n)!==null;var ba=(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)},xc=(e,t)=>t===null||e.some(n=>En(n,t))?e:[...e,t],Wt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],On=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=H(),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=Wt.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=Wt.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(vc,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Wt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:e}),s!==null&&!l?(0,r.jsx)(M,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:h,onChange:u})}):null]})};On.hasRows=ve.hasRows;var bc={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},yc=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:bc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Sc={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Cc=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Sc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),yr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ya=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||wc(e))return yr;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}},wc=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},Sa=(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 cn=["gap","zero","connect"],_n=(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=jc(o,e.spec.layers),g=a?[]:Ac(o),v=g.length>1,f=o.geom==="line"&&!a,b=f?Pc(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&Tc(e,t,m.id),pointLayerId:m?.id??null,showFill:f?b>0:null,drawnFillAlpha:b,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??kc(e,t,o)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},jc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),Tc=(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},Ac=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},kc=(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")},Pc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Lc=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"})]}),Ic=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"})]})]}),Ca=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"})]})]})}),Ec=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"})]}),Mc=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"})]})}),Rc=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"})]})}),Oc=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"})]})}),_c=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"})]}),Nc=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"})]}),Dc=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"})]}),Fc=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"})]})]}),Bc=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"})]})}),Gc=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"})]})}),zc=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"})]}),Hc=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"})]})}),Vc=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"})]}),$c=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"})}),Uc=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"})]})}),qc=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"})]})}),Kc=.55,Xc=.15,Ve=[{name:"column",icon:_c,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Dc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Nc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Mc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Oc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Rc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Ca,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:Ec,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Fc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:qc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:zc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Bc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Kc}},{name:"radialBar",icon:$c,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Xc}},{name:"rose",icon:Wc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:Uc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Hc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Vc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Gc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Yc=.05,wa=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,St=e=>e===null?null:Ve.find(t=>Zc(t.summary,e))??null,ja=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&Ta(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Ct(e.innerRadius)||t.coordType!=="polar"||!Ct(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},Ta=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Zc=(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"&&Ta(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Ct(e.innerRadius)===Ct(t.innerRadius)},Ct=e=>e>=Yc;var Jc="_1a90obs1",Qc=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Lc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Ic},{summary:{coordType:"cartesian",comboType:"lines"},icon:Ca}],ed=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],td=4,nd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},rd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},od=()=>{const e=c.useSceneSelector(I=>I.spec),t=c.useSceneSelector(({layers:I})=>I.some(E=>(0,d.hasMultipleGroups)(E.data,E.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=H(),[s,l]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!s)return;const I=({target:E,detail:L})=>{L>0&&id(E)&&u.current?.contains(E)&&l(!1)};return document.addEventListener("click",I),()=>document.removeEventListener("click",I)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=sd(h),m=wt(h),g=St(h),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),b=(p===void 0?g:Cr(p,m))?.icon,C=p!==void 0&&p.arrangements.length>1,y=C&&(t||p.name==="combo"),k=()=>l(!s),w=({summary:I})=>{n.dispatch(new d.SetGraphTypeCommand(ja(I,h)),{transient:!0})},A=I=>{const E=Sr.find(L=>L.name===I);E!==void 0&&w(Cr(E,C?m:null))},T=Sr.map(({name:I,arrangements:[E]})=>({value:I,label:o(`editor.graphTypes.${I}`),icon:(0,r.jsx)(E.icon,{size:"md"}),disabled:!wa(E.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:o("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:k}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:f,expanded:s,onClick:k})}),s&&(0,r.jsx)(M,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:A,onCommit:n.commit,columns:td,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),y&&(0,r.jsx)(ad,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},Aa=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?St(e)===St(t):e.coordType===t.coordType&&e.geom===t.geom,ka=ed.flatMap(([e,t])=>{const n=Ve.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ve,...Qc].filter(o=>o!==n&&Aa(n.summary,o.summary))]}]}),Sr=ka.filter(({name:e})=>e!=="combo"),ad=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=H(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=wt(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})=>wt(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(M,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Jc,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},id=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,wt=e=>(0,d.isComboGraphType)(e)?rd[e.comboType]:nd[e.position],Cr=(e,t)=>e.arrangements.find(({summary:n})=>wt(n)===t)??e.arrangements[0],sd=e=>ka.find(({arrangements:[t]})=>Aa(t.summary,e)),ld=()=>{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)(xa,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},Pa=({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})]})]}),La=({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})}),cd={small:2,medium:3.8,large:5.6},dd=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:cd[e],fill:"currentColor"})});var ud=({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})`})})},hd="_1yjsaqt0",pd="_1yjsaqt1",md="_1yjsaqt2",gd="_1yjsaqt3";var Ux=512*1024,vd=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)}),wr=["solid","dashed","dotted"],Ut=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],qt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],fd=["circle","square","diamond","triangle","cross","star"],Ia=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=Ut.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:Ut.find(i=>i.widthPx===e)?.name??"",options:Ut.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(La,{lineWidth:s})})),onChange:a})})},Ea=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=wr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(M,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:wr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Pa,{lineStyle:i})})),onChange:a})})},Nn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=H(),[i,s]=(0,x.useState)(null),l=(0,x.useContext)(Rt),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:I})=>[T,I])):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),f=T=>!(0,d.isGeometricSymbol)(T)||fd.some(I=>I===T),b=[...m.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!g(T)),C=[...p.filter(f),...b],y=e===null?"":tt(e),k=e===null||C.some(T=>tt(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,A=T=>{s(null);const I=k.find(E=>tt(E)===T);I!==void 0&&n(I)};return(0,r.jsx)(M,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:hd,children:[(0,r.jsxs)("div",{className:pd,children:[(0,r.jsx)(a,{itemLayout:"chip",value:y,options:k.map(T=>({value:tt(T),label:w(T),icon:(0,r.jsx)(bd,{symbol:T,glyphs:m})})),onChange:A}),(0,r.jsxs)("span",{className:al,children:[(0,r.jsx)("span",{className:il,"aria-hidden":"true"}),(0,r.jsx)(xd,{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}`)})]})})},Dn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=qt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:qt.find(i=>i.sizePx===e)?.name??"",options:qt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(dd,{pointSize:i})})),onChange:a})})},xd=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=H(),a=i=>{vd(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})},bd=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(ud,{symbol:e});const n=yd(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:gd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:md,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"})})},tt=e=>typeof e=="string"?e:e.image,yd=(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},Ma=(0,x.createContext)({}),Sd=Ma.Provider,Cd=()=>(0,x.useContext)(Ma),wd="_1qh3fon0",dn="theme",jd=3,nt=14,jr=9,Ra=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=Cd(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=H();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:dn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Tr,{colors:i})},...l.map(([p,m])=>({value:un(p),label:p,icon:(0,r.jsx)(Tr,{colors:m})}))],h=p=>{const m=l.find(([v])=>un(v)===p);if(p!==dn&&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)(M,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:u,value:Td(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},un=e=>`preset:${e}`,Td=(e,t)=>{if(e===null)return dn;const n=t.find(([,o])=>(0,de.isEqual)(o,e));return n===void 0?"":un(n[0])},Tr=({colors:e})=>{const t=e.slice(0,jd),n=nt/2,o=nt+(t.length-1)*jr;return(0,r.jsx)("svg",{width:o,height:nt,viewBox:`0 0 ${o} ${nt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:wd,cx:n+i*jr,cy:n,r:n-.5,fill:a},i)).reverse()})},Ar=["smooth","linear"],kr=["auto","inside","outside"],Fn=()=>{const e=c.useSceneSelector(S=>S),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=H(),l=Oa(e.layers,e.coordSystem.type,n),u=S=>l.filter(({support:R})=>S(R)).map(({layer:R})=>R),h=Ad(e,t),p=h.filter(S=>S.smooth!==null),m=h.filter(S=>S.missingValues!==null&&S.missingValueOptions.length>1),g=cn.filter(S=>m.some(R=>R.missingValueOptions.includes(S))),v=Id(p),f=Ed(m),b=S=>{o.dispatch(new d.SequenceCommand({commands:h.map(R=>new d.ToggleLinePointsCommand({layerId:R.layerId,showPoints:S}))}))},C=S=>{const R=Ar.find(G=>G===S);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:p.map(G=>new d.SetLineCurveCommand({layerId:G.layerId,curve:R}))}))},y=u(S=>S.supportsPosition),k=rt(y.map(S=>S.dataLabels.position))??"",w=S=>{const R=kr.find(G=>G===S);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:y.map(G=>new d.SetDataLabelsCommand({layerId:G.id,position:R}))}))},A=S=>{const R=cn.find(N=>N===S);if(R===void 0)return;const G=m.filter(N=>N.missingValueOptions.includes(R)).map(N=>new d.SetLineMissingValuesCommand({layerId:N.layerId,missingValues:R}));G.length!==0&&o.dispatch(new d.SequenceCommand({commands:G}))},T=h.filter(S=>S.showFill!==null),I=h.filter(S=>S.showPoints),E=kd(e,t,h),L=T.some(S=>Pd(e,S)),B=S=>{S.length>0&&o.dispatch(new d.SequenceCommand({commands:S}))},F=S=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,strokeWidth:S})))},O=S=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,lineStyle:S})))},P=S=>{B(T.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,showFill:S,drawnFillAlpha:R.drawnFillAlpha})))},j=S=>{B(I.flatMap(({pointLayerId:R})=>R===null?[]:[new d.SetPointSizeCommand({layerId:R,size:S})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(od,{}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(S=>S.supportsDataLabels),isOn:S=>S.showDataLabels,buildCommand:(S,R)=>new d.ToggleDataLabelsCommand({layerId:S,showDataLabels:R})}),y.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:k,options:kr.map(S=>({value:S,label:a(`editor.graphPanel.graphOptions.labelPositions.${S}`)})),onChange:w})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(S=>S.supportsPercentages),isOn:S=>S.format==="percentage",buildCommand:(S,R)=>new d.SetDataLabelsFormatCommand({layerId:S,format:R?"percentage":"absolute"})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(S=>S.supportsStackTotals),isOn:S=>S.showStackTotals,buildCommand:(S,R)=>new d.ToggleStackTotalsCommand({layerId:S,showStackTotals:R})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(S=>S.supportsCategoryLabels),isOn:S=>S.showCategoryLabels,buildCommand:(S,R)=>new d.ToggleCategoryLabelsCommand({layerId:S,showCategoryLabels:R})}),(0,r.jsx)(M,{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)(M,{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)(M,{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)(M,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Ar.map(S=>({value:S,label:a(`editor.graphPanel.graphOptions.curves.${S}`),icon:(0,r.jsx)(yc,{curve:S})})),onChange:C})}),g.length>1&&(0,r.jsx)(M,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(S=>({value:S,label:Sa(a,S),icon:(0,r.jsx)(Cc,{missingValues:S})})),onChange:A})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ia,{widthPx:rt(E.map(S=>S.strokeWidth)),onChange:F}),(0,r.jsx)(Ea,{lineStyle:rt(E.map(S=>S.lineStyle)),onChange:O})]}),T.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:L,onChange:P})}),h.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:I.length>0,onChange:b})}),I.length>0&&(0,r.jsx)(Dn,{sizePx:rt(Ld(e,t,I)),onChange:j}),(0,r.jsx)(Ra,{}),(0,r.jsx)(ld,{})]})};Fn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||Oa(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 Oa=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:ya(o,t,n)})),Ad=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=_n(e,t,o.id);a!==null&&n.push(a)}return n},kd=(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))}))}),Pd=(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)},Ld=(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)}),rt=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},Id=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",Ed=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},ot=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=H();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)(M,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Md=(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}},at=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},Rd=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Pr(Lr(s.layers,e)?.[t]?.[n],a),u=l!==void 0?l:Pr(Lr(s.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},Od=e=>typeof e=="object"&&("style"in e||"annotate"in e),Pr=(e,t)=>e==null?e:Od(e)?e[t]:t==="style"?e:void 0,Lr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,jt=["solid","dashed","dotted"];var _a=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Na=(e,t)=>{const n=e.guides.axes.filter(_a);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}},_d=(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},Da=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),Fa=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Kt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Bn=({target:e})=>{const t=c.useSceneSelector(C=>C),n=c.useStyleReaderTree(),o=Na(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=H();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=_d(e.axis,o),m=jt.map(C=>({value:C,label:a(`editor.graphPanel.gridSection.lineStyles.${C}`),icon:(0,r.jsx)(Pa,{lineStyle:C})})),g=Kt.map(({name:C,widthPx:y})=>({value:C,label:a(`editor.graphPanel.gridSection.lineWidths.${C}`),icon:(0,r.jsx)(La,{lineWidth:y})})),v=Kt.find(({widthPx:C})=>C===u.strokeWidth)?.name??"",f=C=>{const y=jt.find(k=>k===C);y!==void 0&&i.dispatch(Da(y,e.axis))},b=C=>{const y=Kt.find(({name:k})=>k===C);y!==void 0&&i.dispatch(Fa(y.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:f,disabled:p})}),(0,r.jsx)(M,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:b,disabled:p})})]})};Bn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(_a);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var Ir=[{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}],Nd={start:"Start",center:"Center",end:"End"},Ba=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=H(),a=e===void 0,i=a?"":Xt(e),s=Ir.map(u=>{const h=Xt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Fd(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:Dd(e,u)}}),l=u=>{const h=Ir.find(p=>Xt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(M,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Ln.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})})})})},Xt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Nd[t]}`,Dd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Fd=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ga=(e,t,n,o)=>{const a=Ha(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},za=(e,t,n,o)=>{const a=Ha(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"},Ha=(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)),Tt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Bd,{graph:t,target:e})};Tt.hasRows=(e,{scene:t})=>e.scope==="group"&&Va(t,e.layerId)!==null;var Bd=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=H(),s=n===null?null:Va(n,t.layerId),l=n===null||s===null?null:_n(n,o,s.id);if(n===null||s===null||l===null)return null;const u=Vd(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:Hd(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:Gd(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??zd(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:Ga(n,o,l.pointLayerId,u),b=l.pointLayerId===null?null:za(n,o,l.pointLayerId,u),C=f!==null&&f>0,y=L=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:L,...h}))},k=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:L,drawnFillAlpha:l.drawnFillAlpha,...h}))},w=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:L,...h}))},A=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:L,...h}))},T=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:L,...h}))},I=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:L,...h}))},E=(0,d.readObservationsColorRoute)(n.spec,t)?.some(L=>L.geomKind==="line"||L.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),(0,r.jsx)(Ia,{widthPx:v,onChange:w}),E&&(0,r.jsx)(Ea,{lineStyle:$d(n,o,t),onChange:I}),l.showFill!==null&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:k})}),(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:C,onChange:y})}),C&&(0,r.jsx)(Dn,{sizePx:f,onChange:A}),C&&(0,r.jsx)(Nn,{symbol:b,coordType:n.coordSystem.type,onChange:T})]})},Gd=(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},zd=(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},Hd=(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},Vd=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,$d=(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))},Va=(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"})]}),Wd="_1aafi1g0",Ud="_1aafi1g1",Er=({children:e})=>(0,r.jsxs)("span",{className:Wd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:Ud})]}),Yt=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"})}),Mr=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"})]}),Wa=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"})]}),Ua=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"})]}),qd=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},qa=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ka=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Kd=()=>[{scope:"group",labelKey:"pieSlice"}];function Xd(e,t){if(e.type==="polar"&&!Yd(t))return Kd();switch(t.geom){case"bar":return qd(t);case"line":case"area":return qa(t);case"point":return Ka(t);default:return[]}}var Yd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Zd=(e,t,n,o)=>{const a=[],i=Jd(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Qd(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},Xa=(e,t,n)=>{const o=t.find(a=>At(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&At(e.predicate,n)?"observation":null},Jd=(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=Ya(t,a);return s===null||!ru(e,a,s)?null:{variable:a,value:s,label:Za(e,a,s,n,o)}},Qd=(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=eu(e,t);if(s===null)return null;const l=tu(e,a,s),u=l.findIndex(m=>$e(m)===$e(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:Za(e,a,i,n,o),predicate:p}},eu=(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},tu=(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||!nu(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=$e(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)},nu=(e,t)=>t.every(n=>$e(e[n.variable]??null)===$e(n.eq)),ru=(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=Ya(a,t);if(i!==null&&i>n)return!0}return!1},Ya=(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},Za=(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)},$e=e=>e instanceof Date?String(e.getTime()):String(e),At=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Rr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Rr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&At(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&&Or(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&&Or(e.range,t.range),Rr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&At(n,a)}),Or=(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,ou=(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])},au={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},iu=e=>(0,d.isObservationAttachmentKind)(e.kind)&&au[e.kind],Nt=(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]),Ja=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=pn(e,t,n,o);return{observation:i(cu(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Qa(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},hn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=Qa(e,t,n,a);switch(s){case"observation":{const h=l.length===0?null:pn(e,t,n,o),p=su(h,u,i);return{whole:p,value:p}}case"xValue":return _r((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=pn(e,t,n,o)??i("editor.overlayMenu.all");return _r(lu(e,l),h,i)}default:return s}},su=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),_r=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),lu=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},cu=(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"}},Qa=(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)},pn=(e,t,n,o)=>{const a=(0,d.getGroupVariables)(t.data,t.mapping);return a.length===0?du(t,n)??uu(e,t):a.map(i=>hu(n[i]??null,o)).join(", ")},du=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},uu=(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},hu=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},pu="vez73g0",mn="vez73g1",mu="vez73g2",gu="vez73g3",vu="vez73g4";var fu="vez73g6",xu="vez73g7",bu="vez73g8",yu="vez73g9",Su="vez73ga",ei=[mu,fu,vu,gu],Cu=ei.map(e=>`.${e}`).join(", "),wu=ei.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),ti=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${mn}, ${Cu}`),a=t.closest(`.${mn}`)!==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(wu);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Ce={side:"top",delay:200},ni={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Wa},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:$a},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Ua}},ri=new Set(["barSeries","lineSeries","scatterSeries"]),ju=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Gn=e=>{const t=({target:n})=>{const o=qo(n);return o===null?null:(0,r.jsx)(Au,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>Uo(n,o)!==null,t},ht=Gn((e,t)=>Xd(t,e)),Nr=Gn(qa),Tu=Gn(Ka),Au=({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}=H(),f=c.useSceneSelector(z=>z),b=f.spec.annotations,C=f.config.parsingLocale,y=f.config.numberFormat,k=c.useFormattingLocale(),w={scene:f,layer:n,observation:o,groupOptions:Nt(f,k),locale:k,t:i},A=hn(w,"xValue").value,T=hn(w,"group").value,I=Ja(w).observation,E=(0,x.useMemo)(()=>(0,d.createObservationAnchorParser)(n,C),[n,C]),L=(0,d.findObservationAttachment)(b,a,E,(0,x.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:f.layers,coordSystem:f.coordSystem,findGeom:p,readAnchor:E}),[f.layers,f.coordSystem,p,E])),B=L!==null&&iu(L)?L:null,F=m.current,O=B!==null&&F?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,P=O?.kind==="comment"?O.annotation.content:null,j=P===null?"":Gu(P)??void 0,[S,R]=(0,x.useState)(()=>Fu(B?.kind)),G=ou(n,o),N=f.coordSystem,Y=t(n,N),Z=Y.length===0?[]:Zd(n,o,k,y),D=m.current?.heldHighlight,$=D===void 0?G:[...G,D],W=(0,x.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:N}),[n,a,N]),X=Ou({layer:n,observation:o,highlights:$,highlightOptions:Y,reaches:Z,previewedChoiceId:m.current?.choiceId,scopeLabel:z=>Nu(i,z,A,T,I),scopeDescription:z=>Du(i,z,Dr(i,n,Y),A,T,Y.some(J=>ri.has(J.labelKey))),atLeastLabel:z=>i("graph.annotations.highlights.atLeast",{value:z}),atLeastDescription:z=>i("graph.annotations.highlights.atLeastDescription",{noun:Dr(i,n,Y),value:z}),onwardLabel:z=>i("graph.annotations.highlights.onward",{label:z}),onwardDescription:z=>i("graph.annotations.highlights.onwardDescription",{label:z})}),be=(0,d.buildObservationPredicate)(n,o),Re=new Set(X?.available.map(z=>z.id)??[]),U=G.filter(z=>{const J=Xa(z,Z,be);return J===null||!Re.has(J)}).at(-1),q=()=>{m.current!==null&&(m.current=null,g.current())};(0,x.useEffect)(()=>()=>q(),[]);const le=(z,J,he,_)=>{m.current?.key!==z&&(q(),m.current={key:z,choiceId:he,heldHighlight:_},l(J)||(m.current=null))},ie=z=>{q(),s(z),h.getState().clearSelection()},Oe=(z,J)=>{if(m.current?.key===z){m.current=null,g.current(),s(J),h.getState().clearSelection();return}ie(J)},$t=(z,J,he,_)=>({onPointerEnter:()=>le(z,J,he,_),onPointerLeave:q,onClick:()=>Oe(z,J)}),je=z=>{q(),R(J=>J===z?null:z)},Qe=z=>{if(W===null)return;q();const J=(0,d.areAnchorsEqual)(W.start,a)?W.end:W.start,he=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:a,end:J,label:z}});s(he),h.getState().setSelection([{kind:"annotation",id:he.params.annotation.id}])};return(0,r.jsxs)("div",{className:pu,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:z=>{if(O!==null&&Bu(z)){ie(new d.RemoveAnnotationCommand({id:O.annotation.id}));return}ti(z)},children:[(0,r.jsxs)("div",{className:mn,children:[X!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Mr,{}),expanded:S==="highlight",onClick:()=>je("highlight")}),U!==void 0&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Er,{children:(0,r.jsx)(Mr,{})}),onClick:()=>ie(new d.RemoveHighlightCommand({id:U.id}))}),O!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i(ni[O.kind].phrase),icon:(0,r.jsx)(Er,{children:ku(O.kind)}),onClick:()=>ie(new d.RemoveAnnotationCommand({id:O.annotation.id}))}),O===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Wa,{}),onClick:()=>ie(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)($a,{}),expanded:S==="comment",onClick:()=>je("comment")})]}),W!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Yt,{}),expanded:S==="difference",onClick:()=>je("difference")}),O===null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Ua,{}),expanded:S==="sticker",onClick:()=>je("sticker")})]}),S==="comment"&&j!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(Pu,{at:a,onRun:ie,annotationId:O?.kind==="comment"?O.annotation.id:void 0,initialText:j})}),S==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Lu,{at:a,showPreview:le,dropPreview:q,keepPreview:Oe,annotationId:O?.kind==="sticker"?O.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)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Qe("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Qe("absoluteDifference")})]}),S==="highlight"&&X!==null&&(0,r.jsx)("div",{className:"vez73g3",children:X.available.map(z=>{const J=z.appliedHighlightId,he=J===void 0?Mu(z,n.id):new d.RemoveHighlightCommand({id:J}),_=J===void 0?void 0:$.find(re=>re.id===J);return(0,r.jsx)(v,{label:z.label,pressed:J!==void 0,tooltip:z.description===z.label?void 0:z.description,...Ce,...$t(Iu(z.id),he,J===void 0?z.id:void 0,_)},z.id)})})]})},ku=e=>{const t=ni[e].Icon;return(0,r.jsx)(t,{})},Pu=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=H(),[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=zu(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:xu,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:bu,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})]})},Lu=({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=Ru(e,i,a);return(0,r.jsx)("button",{type:"button",className:Su,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>o(l.key,l.command),children:(0,r.jsx)("img",{className:yu,src:s.src,alt:""})},i)})}),Iu=e=>`highlight:${e}`,Eu=e=>`sticker:${e}`,Mu=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Ru=(e,t,n)=>n===void 0?{key:Eu(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}})},Ou=({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 Map;for(const w of n){const A=Xa(w,a,g);A===null||A===i||v.set(A,w.id)}const f=g===null?[]:o.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,appliedHighlightId:v.get(w.scope)}}),b=a.map(w=>({..._u(w,u,h,p,m),appliedHighlightId:v.get(w.id)})),[C,...y]=f,k=C===void 0?b:[C,...b,...y];return k.length===0?null:{available:k}},_u=(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}},Nu=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(ju.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!ri.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Dr=(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}`)},Du=(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}},Fu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Bu=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)},Gu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Fr(t)||Br(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Fr(n)||Br(n)?null:n.text},Fr=e=>e.marks!==void 0&&e.marks.length>0,Br=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,zu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),zn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Hu,{graph:t,target:e})};zn.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ve.hasRows(e,t);var Hu=({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)(ve,{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)(ve,{target:t}),!l&&(0,r.jsx)(Dn,{sizePx:Ga(n,o,a.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:a.id,size:u,...s}))}}),(0,r.jsx)(Nn,{symbol:za(n,o,a.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:a.id,symbol:u,...s}))}})]})},oi={geoms:{point:{style:zn,annotate:Tu},line:{style:Tt,annotate:Nr},area:{style:Tt,annotate:Nr},bar:{style:On,annotate:ht},rule:{style:null,annotate:ht},tile:{style:ve,annotate:ht}},legend:Ba,axis:Rn,grid:Bn,graph:Fn},Hn=(0,x.createContext)([oi]),Vu=({editMenus:e,children:t})=>{const n=(0,x.useMemo)(()=>[e??{},oi],[e]);return(0,r.jsx)(Hn.Provider,{value:n,children:t})},$u=e=>{const t=(0,x.useContext)(Hn),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=ai(c.useGraphMode());return(0,x.useMemo)(()=>e===null?null:ii(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Wu=()=>{const e=(0,x.useContext)(Hn),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=ai(c.useGraphMode());return(0,x.useCallback)(i=>ii(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},ai=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",ii=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=Md(e.layerId,n.scene),i=a===null?null:Rd(a,t,o,o==="annotate"?ht:ve);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=at(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=at(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=at(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=at(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Uu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},qu={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}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Ku={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})`}}}},Xu={common:Uu,editor:qu,graph:Ku},Yu={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"}},Zu={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`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Ju={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})`}}}},Qu={common:Yu,editor:Zu,graph:Ju},eh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},th={editor:eh},nh={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"}},rh={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}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},oh={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})`}}}},ah={common:nh,editor:rh,graph:oh},ih={"en-GB":Qu,"en-US":th,ar:Xu,"pt-PT":ah},sh=[ih,c.dictionaries],Vn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:sh,...t,children:(0,r.jsx)(lh,{children:e})}),lh=({children:e})=>(0,r.jsx)(Ln.DirectionProvider,{direction:c.useTextDirection(),children:e}),ch="data-variant",si=Wo.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[ch]:e.variant}:{}}}}}),dh=$o.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}}}}),$n=()=>[Fs.Text,It.UndoRedo,_s.Heading.configure({levels:[1,2,3]}),Rs.Bold,Ns.Italic,Gs.Underline,Bs.TextAlign.configure({types:["heading","paragraph"]}),Ds.Link.configure({openOnClick:!1,autolink:!0}),xt.TextStyle,xt.Color,Os.HardBreak],uh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[ph({showTitle:n,showSubtitle:o}),si,...$n(),xt.FontFamily,dh.configure({showTitle:n}),It.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:""}})],hh=({placeholder:e})=>[ft.Document,si,...$n(),xt.FontFamily,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],ph=({showTitle:e,showSubtitle:t})=>e&&t?ft.Document.extend({content:"block{2,}"}):ft.Document,li=()=>{const e=c.useI18n();return(0,x.useMemo)(()=>({...Object.fromEntries(di.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ci=()=>{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])},mh=e=>e!=="canvasDefault"&&e!=="canvasInverse",di=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(mh).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Wn=di.map(e=>e.color);var gh="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))",vh="d0bl00";var fh="d0bl03",xh="d0bl04",bh=.01,yh=e=>Wn.some(t=>t.toLowerCase()===e.toLowerCase()),Sh=({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}=H(),f=li(),b=ci(),C=[...p?[d.AUTO_COLOR]:[],...h?[bt]:[],...Wn],y={...f,[bt]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},k=E=>{t(E),o(!1)},w=b.length>0,A=w?b:C,T=e!==null&&!Gr(C,e)&&!Gr(b,e)?[...A,e]:A,I=(0,r.jsx)(Ch,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(te.Popover.Root,{open:n,onOpenChange:o,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:vh,onMouseDown:E=>E.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"start",className:fh,children:(0,r.jsxs)(te.Popover.Popup,{className:xh,onMouseDown:E=>E.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?C:T,names:y,value:e,onChange:k,trailing:w?void 0:I}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:y,value:e,onChange:k,trailing:I}),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:bh,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},Ch=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=H(),{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})},Gr=(e,t)=>e.some(n=>En(n,t)),wh="l9kff0",jh="l9kff1",Th="l9kff2",Ah="xn24px0",kh="xn24px1",Ph="xn24px2",Lh=({children:e,popupAttributes:t})=>(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Ah,children:(0,r.jsx)(ae.Menu.Popup,{className:kh,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),Ih=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ae.Menu.Item,{className:Ph,"data-selected":t,disabled:n,onClick:o,children:e}),Eh=({className:e,...t})=>(0,r.jsx)(ce.Tooltip.Provider,{children:(0,r.jsx)(Se.Toolbar.Root,{...t,className:(0,ge.default)(wh,e)})}),Mh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Group,{...t,className:(0,ge.default)(jh,e)}),Rh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Separator,{...t,className:(0,ge.default)(Th,e)}),Oh=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Pn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},ee={Portal:Oh,Root:Eh,Group:Mh,Separator:Rh,Button:Se.Toolbar.Button,ColorPicker:Sh,MenuPopup:Lh,MenuItem:Ih},_h="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Nh=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Dh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Fh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",gn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Nh},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:_h},{id:"technical",label:"Technical",preview:"00",fontFamily:Dh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Fh}],Bh=e=>e?gn.find(t=>t.fontFamily===e)??null:null,ui="_70l3rt0",hi="_70l3rt1",pi="_70l3rt3",mi="_70l3rt4",gi="_70l3rt5",Gh=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Bh(t)??gn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:ui,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:hi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:pi,children:(0,r.jsx)(ae.Menu.Popup,{className:mi,onMouseDown:l=>l.preventDefault(),children:gn.map(l=>(0,r.jsx)(ae.Menu.Item,{className:gi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},vi={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},zr=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},vi,{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}],zh=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=zr.find(s=>s.id===t)??vi;return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:ui,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:hi,children:a(i.translationKey)}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:pi,children:(0,r.jsx)(ae.Menu.Popup,{className:mi,onMouseDown:s=>s.preventDefault(),children:zr.map(s=>(0,r.jsx)(ae.Menu.Item,{className:gi,"data-selected":s.id===i.id,onClick:()=>Hh(e,s.id),children:(0,r.jsx)(Vh,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},Hh=(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()}},Vh=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),$h=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"})]})}),Uh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),qh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&Hr(n[i-1]);)i-=1;let s=o;for(;s<n.length&&Hr(n[s]);)s+=1;return{from:a+i,to:a+s}},Hr=e=>e!==void 0&&/\S/.test(e),Kh="fop13s0",Xh="fop13s1",Yh="fop13s2",Zh="fop13s3",Vr="fop13s4",Jh=({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=()=>{Qh(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)(te.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Kh,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)($h,{})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"end",className:Xh,children:(0,r.jsxs)(te.Popover.Popup,{className:Yh,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:Zh,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Vr,onClick:p,children:(0,r.jsx)(Wh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Vr,onClick:h,children:(0,r.jsx)(da,{})})]})})})})]})},Qh=(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=qh(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},fi=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"})]})}),xi=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"})]})}),bi=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"})]})}),e0="_1d66w570",t0="_1d66w571",Ie=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(ce.Tooltip.Root,{children:[(0,r.jsx)(ce.Tooltip.Trigger,{render:(0,r.jsx)(zs.Toggle,{render:(0,r.jsx)(Se.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:e0,onMouseDown:a,children:o}),(0,r.jsx)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{sideOffset:6,className:t0,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Yo,children:e})})})})]})},n0=({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)(bi,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(fi,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(xi,{})})]})},r0="_1u34vl40",o0=({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:a0(e),textAlign:i0(e)}),a0=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",i0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",s0=8,l0=8,c0=({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,_e.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,_e.offset)(s0),(0,_e.flip)(),(0,_e.shift)({padding:l0})],whileElementsMounted:_e.autoUpdate}),p=(0,x.useRef)(null),m=(0,we.useEditorState)({editor:e,selector:o0}),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:b})=>{const{relatedTarget:C,currentTarget:y}=b,k=C instanceof Node&&p.current?.contains(C),w=C instanceof Node&&y instanceof Node&&y.contains(C);!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)(ee.Portal,{children:(0,r.jsxs)(ee.Root,{ref:g,className:r0,style:h,children:[(0,r.jsxs)(ee.Group,{children:[(0,r.jsx)(ee.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(Gh,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(zh,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsxs)(ee.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)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(n0,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(Jh,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},d0="_1uy50v30",yi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:d0,children:[(0,r.jsx)(c0,{editor:e}),(0,r.jsx)(we.EditorContent,{editor:e,"aria-label":t})]}),u0=200,Un=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=u0})=>{const i=(0,x.useRef)($r(e)),s=(0,x.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,o?.(h)},a),u=(0,we.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Zt(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=$r(e);Zt(s.current,h)||(s.current=h,!Zt(u.getJSON(),h)&&(l.cancel(),h0(u,h)))},[u,e,l]),(0,x.useEffect)(()=>()=>l.flush(),[l]),u},$r=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,h0=(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)})},Zt=(e,t)=>JSON.stringify(kt(e))===JSON.stringify(kt(t)),kt=e=>Array.isArray(e)?e.map(kt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,kt(n)]).filter(([,t])=>!p0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),p0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,m0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=Un({content:e,extensions:(0,x.useMemo)(()=>hh({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=Uh(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)(yi,{editor:o,ariaLabel:"Chart caption"})})};var We="textStyle",Si=new Set(["paragraph","heading"]),Ci=e=>ki(ji(e)?.fontSize)??null,wi=e=>Ti(ji(e))??null,g0=e=>{const t=Ai(e),n=b0(e);return{color:it(t.map(o=>y0(Jt(o)?.color))),font:it(t.map(o=>Ti(Jt(o)))),fontSize:it(t.map(o=>ki(Jt(o)?.fontSize))),alignment:it(n.map(o=>S0(o.attrs?.textAlign)))}},v0=(e,t)=>qn(e,n=>n.type==="text"?x0(n,t):n),ze=e=>Ai(e).length>0,f0=(e,t)=>qn(e,n=>Si.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),ji=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===We)?.attrs},qn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>qn(n,t))}),x0=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===We),a={type:We,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},Jt=e=>e.marks?.find(t=>t.type===We)?.attrs,Ti=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),Ai=e=>Kn(e,t=>t.type==="text"),b0=e=>Kn(e,t=>Si.has(t.type??"")),Kn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Kn(n,t))],it=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},y0=e=>typeof e=="string"&&e.length>0?e:void 0,ki=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,S0=e=>e==="left"||e==="center"||e==="right"?e:void 0,C0=e=>[ft.Document,Wo.Paragraph,...$n(),j0,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],w0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,x.useMemo)(()=>C0(t("graph.annotations.text.placeholder")),[t]),i=Un({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,we.useEditorState)({editor:i,selector:({editor:u})=>Ci(u)}),l=(0,we.useEditorState)({editor:i,selector:({editor:u})=>wi(u)});return(0,r.jsx)(we.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"})},Wr=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},j0=$o.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Wr(e.fontFamily)},font:{default:null,renderHTML:e=>Wr(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})`}:{}}}}]}}),T0=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,x.useMemo)(()=>uh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(yi,{editor:Un({content:(0,x.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new d.SetContentTitleCommand({title:l.title})),n&&a(new d.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},Pi={Title:T0,Caption:m0,TextAnnotation:w0},A0={Title:null,Caption:null,TextAnnotation:Pi.TextAnnotation},k0=e=>c.MODE_RULES[e].editTextInline?Pi:A0,P0="_10igzta0",L0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Pn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:P0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),I0="kwvn4c0",E0="kwvn4c1",Xn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Li=e=>Xn(e,e.getBoundingClientRect().width),vn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},M0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=Xn(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),R0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!_0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Ur(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return Ur(s,o.width,t.width)},O0=()=>{const[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{t(!0)},[]),e},_0=e=>c.SIDE_KEYS.some(t=>t===e),Ur=(e,t,n)=>n===0?0:e*t/n,N0={x:8,y:8},D0={side:"flip",align:"shift",fallbackAxisSide:"end"},Ii=({frameElement:e,boundary:t,spans:n,clearance:o=N0,onEscape:a,children:i})=>{const s=Mt(),l=O0(),[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:b,height:C}=t,y=(0,x.useMemo)(()=>({box:{x:v,y:f,width:b,height:C},spans:n}),[v,f,b,C,n]),k=(0,x.useMemo)(()=>M0(e,y.box),[e,y]),w=(A,T)=>{A||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(te.Popover.Root,{open:l,modal:!1,onOpenChange:w,children:(0,r.jsx)(te.Popover.Portal,{container:s,className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(te.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:T})=>R0({side:A,boundary:y.box,spans:y.spans,anchor:T,rightToLeft:F0(g.current)}),collisionAvoidance:D0,sticky:!0,className:I0,...cl,children:(0,r.jsx)(te.Popover.Popup,{ref:m,className:E0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},F0=e=>e!==null&&getComputedStyle(e).direction==="rtl",B0=2,Ei=()=>{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,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+B0)/s;return Math.max(l,Math.min(b,G0(a,(0,d.alignUnitFractions)(i).x)))}},G0=(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)},Mi=(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)||Mi(n,t.getState().scene)!==null,[e,t])},Yn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Zn=(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||ze(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(new d.RemoveAnnotationCommand({id:a.annotationId}))},qe=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,z0=(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(...H0(i,e,t,n))}return o},qr=(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)},H0=(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||qe(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=V0(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},V0=(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}},Ke=()=>{const e=c.useGraphSelection();return fn(e)},fn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},$0=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(I=>I.spec.annotations.textAnnotations)),v=(0,x.useRef)(null),f=(0,x.useRef)(null),b=(0,x.useRef)(!0),C=(0,x.useRef)(new WeakSet),{showAnnotations:y,showMenuTriggerOnHover:k}=c.MODE_RULES[c.useGraphMode()],w=(0,x.useCallback)(I=>{const{selection:E}=t.getState(),L=y?fn(E):null;L!==null&&(I.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:L})),e.focus({preventScroll:!0}))},[e,n,t,y]),A=(0,x.useCallback)(I=>{if(He(I.target,o))return;const E=y?fn(t.getState().selection):null;E!==null&&g.current.some(L=>L.id===E)&&(I.preventDefault(),m.getState().setCaret(E))},[m,t,g,o,y]),T=(0,x.useCallback)(I=>{const E=m.getState(),L=E.standingInteraction?.kind;if(L!==void 0){L!=="chrome-popup"&&L!=="arrow-draw"&&L!=="box-draw"&&E.releaseInteraction(L);return}if(E.caret!==null){Zn(m,i.getState().scene.annotations,n.dispatch,Yn(a)),E.setCaret(null),e.focus({preventScroll:!0});return}return He(I.target,o)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,o,i,n,a]);(0,x.useEffect)(()=>{const I=P=>{if(!Le(P.target,e,o)||yt(P.target))return;const j=Ee(P.target),S=m.getState(),R=S.caret!==null&&!He(P.target,o);if(j&&!R)return;const G=()=>k&&P.target===e&&!j&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&S.standingInteraction===null&&t.getState().selection.length===0,N=()=>{if(!G())return;const Z=z0(i.getState().scene,s,p);if(Z.length===0)return;const D=l.getState().hover.primary,$=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,W=v.current===null?qr(Z,D):qr(Z,v.current.primary),X=Z[W<0?$>0?0:Z.length-1:Math.min(Z.length-1,Math.max(0,W+$))];if(X!==void 0){if(f.current===null){const be=Pe(D);be!==null&&!pt(be,Pe(X.primary))&&(f.current=be)}v.current=X,P.preventDefault(),E(X)}},Y=()=>{if(!G())return;const Z=v.current;Z!==null&&(v.current=null,f.current=null,P.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([Z.target]))};switch(P.key){case"Escape":return T(P);case"Enter":return j||(A(P),m.getState().caret!==null)?void 0:Y();case"Delete":case"Backspace":return j?void 0:w(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||j||!k||P.target!==e||S.standingInteraction!==null)return;P.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return N();default:return}},E=P=>{const j=U0(u,P,i.getState().scene.coordSystem,Y0(u,h.current));C.current.add(j),l.getState().setHoverState(j)},L=l.subscribe(P=>{const j=v.current;if(j===null||C.current.has(P.hover))return;const S=P.hover.primary;if(S===null){if(b.current){E(j);return}v.current=null,f.current=null;return}const R=Pe(S);if(pt(R,Pe(j.primary))){f.current=R;return}if(pt(R,f.current)){E(j);return}v.current=null,f.current=null}),B=h.current,F=()=>{b.current=!0},O=P=>{b.current=!1,!(v.current===null||W0(P,B,l))&&(v.current=null,f.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",F),B?.addEventListener("pointerleave",O),document.addEventListener("keydown",I),()=>{L(),B?.removeEventListener("pointerenter",F),B?.removeEventListener("pointerleave",O),document.removeEventListener("keydown",I)}},[e,w,A,T,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),W0=(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)},U0=(e,t,n,o)=>{const a=q0(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(pt(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}},q0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return K0(e.x,e.y,n);case"cartesian":return X0(e);default:return t}},K0=(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}},X0=e=>{const{observation:t,x:n,y:o}=e,a=st(t,d.POSITION_VARIABLES.xMin),i=st(t,d.POSITION_VARIABLES.xMax),s=st(t,d.POSITION_VARIABLES.yMin),l=st(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},Y0=(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)},st=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},pt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Z0="_1vbfegu3",Xe={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},J0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Xe})}),Q0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Xe})}),ep=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Xe})}),tp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...Xe})}),np=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",...Xe})}),Jn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},rp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Jn})}),op=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",...Jn})}),ap=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Jn})}),Ae={side:"top",delay:200},Kr=.2,ip={type:"doc",content:[{type:"paragraph"}]},Xr={paddingInline:12,paddingBlock:10},sp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(lp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},lp=({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}=H(),m=li(),g=ci(),v=Ei(),[f,b]=(0,x.useState)({kind:"choose"}),C=c.useEditorState(P=>P.standingInteraction?.kind==="box-draw"),y=c.useEditorState(P=>P.standingInteraction?.kind==="arrow-draw"),k=!C&&!y,w=()=>{De(a),a.getState().setPlotMenu(null)};(0,x.useEffect)(()=>()=>De(a),[a]),(0,x.useEffect)(()=>{if(!C&&!y)return;const P=j=>{if(j.key!=="Escape"||!Le(j.target,e,s)||yt(j.target))return;const S=Ee(j.target),R=a.getState().caret!==null&&!He(j.target,s);if(S&&!R)return;const G=a.getState().standingInteraction?.kind;G!=="arrow-draw"&&G!=="box-draw"||(j.preventDefault(),a.getState().releaseInteraction(G))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s,C,y,a,e]);const A={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={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}},I=P=>{De(a),b(j=>j.kind===P?{kind:"choose"}:{kind:P})},E=P=>(...j)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:P,start:n,...Yr(j[0])})},L=(...P)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}De(a),b({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...Yr(P[0])})},B=()=>{const P=a.getState().standingInteraction?.kind;if((P==="arrow-draw"||P==="box-draw")&&!yt(document.activeElement)){a.getState().releaseInteraction(P);return}w()},F=P=>{De(a);const j=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:ip,at:{anchorType:"panel",x:n.x,y:n.y},width:Kr}}),S=j.params.annotation.id,R=v({annotationId:S,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Kr,paddingInline:P===null?void 0:Xr.paddingInline}),G=new d.AddAnnotationCommand({kind:"text",annotation:{...j.params.annotation,width:R}});P===null?i.dispatch(G):i.dispatch(new d.SequenceCommand({commands:[G,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:S},declarations:{fill:P,...Xr}}})]})),u.getState().setSelection([{kind:"annotation",id:S}]),a.getState().setCaret(S,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},O=P=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:P}})),w()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Z0,style:{left:A.x,top:A.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),k&&(0,r.jsx)(Ii,{frameElement:e,boundary:A,spans:T,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:ti,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)(J0,{}),onClick:()=>F(null)}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(Q0,{}),expanded:f.kind==="sticky",onClick:()=>I("sticky")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(ep,{}),expanded:f.kind==="arrow",onClick:()=>I("arrow")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(tp,{}),expanded:C,onClick:L}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(np,{}),expanded:f.kind==="sticker",onClick:()=>I("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:Wn,names:m,value:null,onChange:F,...Ae}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:F})]}),f.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([P,j])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":P,onClick:()=>O(P),children:(0,r.jsx)("img",{className:"vez73g9",src:j.src,alt:""})},P))}),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:E("end"),children:(0,r.jsx)(rp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:E("both"),children:(0,r.jsx)(op,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:E("none"),children:(0,r.jsx)(ap,{})})]})]})})]})},De=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Yr=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}}},Ye=e=>e.offset+e.strokeWidth,Zr="http://www.w3.org/2000/svg",Jr=new WeakMap,cp=(e,t)=>{const n=dp(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}},dp=e=>{const t=Jr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Zr,"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(Zr,"path");return n.append(o),e.body.append(n),Jr.set(e,o),o},up=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=Ye(o);switch(e.kind){case"observations":return Qt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>hp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Qt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(vp(s),a(s.axis)/2)),i);case"graph":return Qt([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},hp=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=mp(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>pp(l,s))},pp=(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}]},mp=(e,t)=>e.kind==="boxes"?e.boxes:gp(e.shapes,t),gp=(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},vp=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}}},Qt=(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 fp=(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=>xp(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},xp=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),bp=.5,yp={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},Sp=(e,t,n)=>e===null||!Cp(e)?{top:xn(t),right:bn(t),bottom:xn(t),left:bn(t)}:{top:lt(e,t,"top",n),right:lt(e,t,"right",n),bottom:lt(e,t,"bottom",n),left:lt(e,t,"left",n)},lt=(e,t,n,o)=>{const a=yp[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,bp);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?bn(t):xn(t),v={from:(0,de.clamp)(p-o,g.from,g.to),to:(0,de.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))},xn=e=>({from:e.x,to:e.x+e.width}),bn=e=>({from:e.y,to:e.y+e.height}),wp=(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=up(h,{panelRect:n,look:o,readGridLineWidth:y=>c.readGridLineStyle(i,y).strokeWidth,measurePathBox:y=>{const k=m.get(y)??cp(t.ownerDocument,y);return g.set(y,k),k},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const b=Sp(fp(h,{coordSystem:s,panelRect:n}),f,Ye(o)),C=Li(t);a.getState().setSelectedOutline({target:u,frame:f,frameSpans:b,frameScale:C})},[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)",jp="_1qfw3e01",Tp="_1qfw3e02",Qr=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(Ap,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),Ap=({pathData:e,source:t,...n})=>{const o=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(Es.motion.path,{d:o,...n})},kp="var(--dppmab0)",Pp="data-edit-outline-stroke",Ri=e=>({[Pp]:"",style:(0,fe.assignInlineVars)({[kp]:`${e}px`})}),Lp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=Oi(),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||qe(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:_i({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},Ip=()=>Ep("pin"),Ep=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=Oi(),[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||qe(p,g)?null:_i({layer:p,observation:g,target:h,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,a,o,i,s,e])},Oi=()=>{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}},_i=({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}},Mp=()=>{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:Rp(e,t,n),[e,t,n])},Ni=(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}},Rp=(e,t,n)=>{switch(e.kind){case"observations":{const o=Ni(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}},Op=()=>{const e=Lp(),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:Ni(e.target,i,s),[t,e,n,o,a,i,s])};var eo=(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"},_p=(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)}},Np=[],Dp=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:Fp(t,i,s,l),[t,i,s,l]),h=(0,x.useMemo)(()=>u!==null&&e!==null&&eo(u,e),[u,e]),p=Me(),m=a!==null&&i!==void 0&&Bp(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:Np,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&&eo(g,e)?null:g}default:return null}},[o,u,h,m,e])},Fp=(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}},Bp=({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)},Gp=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(zp(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?en(l):en([(0,d.getBoundingRect)(l)])}case"legend":return en([...Hp(i.filter(l=>!Vp(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?[$p(l,s(l),h)]:[]})}},zp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Hp=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},Vp=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,en=e=>e.map(t=>({kind:"box",rect:t})),$p=(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}}:Wp(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}},Wp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Up=[],qp=(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=Xp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Kp(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(b=>to(b,p,a))??Up,[m,p,a]),f=(0,x.useMemo)(()=>g===null?null:to(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])},Kp=(e,t)=>{const[n,o]=(0,x.useState)(()=>vn(e,t));return(0,x.useLayoutEffect)(()=>{o(a=>{const i=vn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},to=({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=>_p(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})}},Xp=(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=Gp({frameElement:t,target:p,coordType:o,legendDisplays:a}),v=Li(t);l(g.map(f=>Yp(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},Yp=(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}}},Zp=["x","y"],Jp=(0,x.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=Mp(),s=Dp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Op(),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)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:jp,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(tn,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),tn=({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=qp(t,{frameElement:s,frameSize:a,panelRect:i});return wp(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:Tp,children:(0,r.jsx)(om,{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:Qp(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:em(o)}),(0,r.jsx)("use",{href:`#${h}`,style:tm(o)})]}),t.kind==="observations"&&(0,r.jsx)(dm,{target:t,look:o,panelRect:i})]}):null},Qp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,fe.assignInlineVars)({[Qn]:`${2*e}px`})}),em=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,fe.assignInlineVars)({[Qn]:`${2*Ye(e)}px`})}),tm=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,fe.assignInlineVars)({[Qn]:`${2*Ye(e)}px`})}},nm=({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},Di=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},rm=(e,t,n)=>{const o=n.offset+Ye(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},om=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=nm(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)(no,{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)(no,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(sm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:rm(e.frameSize,o,t)})}},no=(0,x.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(im,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(am,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),am=({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,...Ri(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:Di(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),im=({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"})},sm=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Zp.map(s=>{const l=Ri(c.readGridLineStyle(a,s).strokeWidth),u=t.map(p=>lm(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:cm(p),pathLength:Di(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})},lm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",cm=({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}`},dm=({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=um(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"})})},um=({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},hm=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"})]}),pm=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"})]}),mm=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"})]}),gm={observation:hm,xValue:pm,group:mm},vm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(C=>C),i=Nt(a,o),s=c.useEditorState(C=>C.pressedObservation),l=Me(),u=(0,x.useMemo)(()=>fm({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(C=>{const y=gm[C];return{value:C,label:m[C],icon:(0,r.jsx)(y,{})}}),b=C=>{const y=p.find(A=>A===C),{parsingLocale:k}=a.config,w=y===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:y,parsingLocale:k});w!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(Mn,{value:v.scope,options:f,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},fm=({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:Ja({scene:e,layer:l,observation:u,groupOptions:n,locale:o,t:a})}},xm=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"})]})}),bm=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"})]})}),ym="_11vjgg60",Sm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,x.useState)(null),s=Mi(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?bm:xm;return(0,r.jsx)(ye,{label:m,children:(0,r.jsx)("button",{type:"button",className:ym,onClick:p,children:(0,r.jsx)(g,{title:""})})})},Cm=(e,t)=>t==="polar"||e==="bar",wm=(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}}},jm="_1j45ehx0",Tm="_1j45ehx1",Am="_1j45ehx2",km="_1j45ehx3",Pm=(e,t)=>{switch(e.kind){case"observations":return Lm(e.scope,t);case"legend":case"axis":case"grid":return Im(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},Lm=(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}},Im=(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}},Em=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Nt(o,n),i=(0,x.useMemo)(()=>Rm({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(Mm,{title:i})},Mm=({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)(te.Popover.Title,{ref:l,className:Am,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:km,"aria-hidden":!0,children:e.whole})]})},Rm=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=Pm(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:hn({scene:t,layer:l,observation:h,groupOptions:n,locale:o,t:a},e.scope)},Om=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=_m(c.useEditorState(p=>p.selectedOutline)),o=c.useEditorState(p=>p.annotatePress),a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=$u(n?.target??null),s=Me(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,x.useMemo)(()=>a&&l!==null?wm(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)(Ii,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(an,{className:jm,children:[(0,r.jsxs)("div",{className:Tm,children:[(0,r.jsx)(Em,{target:n.target}),(0,r.jsx)(Sm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(vm,{})]}),(0,r.jsx)(x.Fragment,{children:i},l)]})},_m=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},Nm=({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:ct(l.top,o,u),right:ct(l.right,a,u),bottom:ct(l.bottom,o,u),left:ct(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},ct=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Fi=["start","end"],Dm=({anchor:e,point:t,delta:n,bounds:o=d.PANEL_FRACTION_BOUNDS})=>{const a={x:oo(t.x,n.x,o.minX,o.maxX),y:oo(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}}},er=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},ro=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),Bi=(e,t)=>(0,de.isEqual)(e,t),Fm=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Bm=(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)}},oo=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,de.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Dt=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Gi=(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)},Gm="var(--_1am0al60)";var zm="_1am0al61",Hm="_1am0al62",ne=(e,t)=>t>0?e/t:0,zi=(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)},Hi=(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)}),me=(e,t)=>{const n=t.getBoundingClientRect(),o=vn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return zi(e,a)},tr=(e,t,n)=>({x:ne(t.x-e.x,n.width),y:ne(t.y-e.y,n.height)}),Vm=e=>e.x!==0||e.y!==0,Vi=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),$m=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=Ke(),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=ao(t,a,p),g=ao(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(er(C,l,p.panel),p.panel)}return u?.annotationId===b.id?Gi(t,b.id,u,p)??b.geometry:b.geometry},f=b=>{if(i?.annotationId!==b)return e;const C=Vi(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)(io,{annotationId:g.id,geometry:v(g),state:"hovered",origin:f(g.id)}),m!==null&&(0,r.jsx)(io,{annotationId:m.id,geometry:v(m),state:"selected",origin:f(m.id)})]})},ao=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},io=({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,fe.assignInlineVars)({[Gm]:Dt(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)(so,{point:t.start,origin:o}),(0,r.jsx)(so,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:zm,"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}})},so=({point:e,origin:t})=>(0,r.jsx)("span",{className:Hm,style:{left:t.x+e.x,top:t.y+e.y}}),nr="c44vv80",Wm=({panelRect:e})=>{const t=c.useEditorState(a=>c.readStanding(a,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=Vi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:nr,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:Km(n,t.annotationId,e)})},Um=({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})},Fe=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},qm={text:(e,t,n)=>Fe(e.textAnnotations,t,o=>(0,r.jsx)(Um,{annotation:o,panelSize:n})),shape:(e,t,n)=>Fe(e.shapes,t,o=>(0,r.jsx)(Ym,{shape:o,panelSize:n})),image:(e,t,n)=>Fe(e.images,t,o=>(0,r.jsx)(Jm,{image:o,panelSize:n})),arrow:(e,t,n)=>Fe(e.arrows,t,o=>(0,r.jsx)(Xm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Fe(e.stickers,t,o=>(0,r.jsx)(Zm,{sticker:o,panelSize:n}))},Km=(e,t,n)=>{for(const o of Object.values(qm)){const a=o(e,t,n);if(a!==null)return a}return null},Xm=({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})},Ym=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Zm=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Jm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),Qm="_1lp7ph20",eg=({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)(tg,{placement:t,panelRect:e})},tg=({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"?ng(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:Qm,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",...nn(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":rg(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",...nn(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,...nn(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"})]})]})},nn=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),ng=e=>e.target.type==="observation"?e.target.box:e.target.rect,rg=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,og=({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:er(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:nr,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})})},ag=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"})]})}),ig=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"})]})}),Wi=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"})]})}),Ft=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"})]})}),sg="var(--pvjfpx0)",lg="var(--pvjfpx1)",cg="pvjfpx2",dg="pvjfpx3",ug="pvjfpx4",hg="pvjfpx6 pvjfpx5",pg="pvjfpx7 pvjfpx6 pvjfpx5",mg="pvjfpx8 pvjfpx5",Be=8,gg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],estimatedPillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,u=s-8-44,h=l+8,p=o-Be-44,m=Be,g=Math.max(0,n-Be*2),v=t.x+e.x+e.width/2-m,f=y=>y>=Be&&y<=p,b=(0,de.clamp)(h<=p?h:u,Be,p);if(a.length===0||i===void 0)return{top:b,left:m,available:g,centre:v};const C=y=>!vg(y,m,g,v,i,a);return f(h)&&C(h)?{top:h,left:m,available:g,centre:v}:f(u)&&C(u)?{top:u,left:m,available:g,centre:v}:{top:b,left:m,available:g,centre:v}},vg=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,de.clamp)(o-s/2,0,Math.max(0,n-s)),u=l+s,h=e+44;return i.some(p=>l<p.x+p.width&&u>p.x&&e<p.y+p.height&&h>p.y)},fg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:u})=>{const{chartId:h}=c.useGraphContext(),p=gg({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i});return(0,r.jsx)("div",{className:cg,style:{top:p.top,left:p.left,width:p.available},children:(0,r.jsx)(ee.Root,{"aria-label":s,className:dg,"data-testid":l,...Et(h),style:(0,fe.assignInlineVars)({[sg]:`${p.centre}px`,[lg]:`${p.available}px`}),children:u})})},xg=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ae.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ee.Button,{}),"aria-label":e,className:mg,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ee.MenuPopup,{popupAttributes:Et(s),children:i})]})},bg=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ee.ColorPicker,{...e,popupAttributes:Et(t)})},yg=({color:e,opacity:t})=>(0,r.jsx)("span",{className:ug,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),Sg=({label:e,onClick:t,children:n})=>(0,r.jsx)(ee.Button,{"aria-label":e,className:hg,onClick:t,children:n}),Cg=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(ee.Button,{"aria-label":e,"aria-pressed":t,className:pg,onClick:n,children:o}),V={Root:fg,Dropdown:xg,MenuItem:ee.MenuItem,ColorPicker:bg,Swatch:yg,IconButton:Sg,ToggleButton:Cg,Button:ee.Button,Separator:ee.Separator},wg={kind:"chrome-popup"},Bt=()=>{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(wg),()=>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}},jg=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"})]})}),Tg=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"})]})}),Ag=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),kg=[{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"}],lo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:$i},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],co=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Ag},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:jg},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Tg}],Pg=(e,t)=>e.find(n=>n.value===t)??e[0];var Lg=({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=Bt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=Pg(co,(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]),b=(0,x.useMemo)(()=>({...f,part:"outline"}),[f]),C=(O,P)=>{const j=(0,d.findStyleRule)(u,{select:f},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...j,...O}}}),P)},y=O=>{const P=(0,d.findStyleRule)(u,{select:b},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...P,...O}}}))},k=O=>{C(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})},T=O=>C({stroke:O},{transient:!0}),I=O=>k({strokeWidth:O}),E=O=>w({startArrowheadStyle:O}),L=O=>k({dashArray:d.DASH_PRESETS.arrow[O]}),B=O=>w({endArrowheadStyle:O}),F=()=>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)(Wi,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(dt,{options:kg,current:m.strokeWidth,onPick:I})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(ag,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(dt,{options:lo,current:e.startArrowheadStyle,onPick:E})}),(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)(dt,{options:co,current:(0,d.toDashPreset)(m.dashArray),onPick:L})}),(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)(dt,{options:lo,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:F,children:(0,r.jsx)(ig,{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)(Ft,{size:"sm",title:""})})]})},dt=({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)))})},Ig="_1me29t10";var Eg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ze=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 Eg(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)}},yn=(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}}},rr=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Ui=["center",...rr],Mg=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Ui.filter(a=>a!==t)].map(a=>({align:a,point:(0,d.readRectPoint)(o,a)}))},qi=(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},Rg=(e,t,n,o)=>{const a=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:ne(e.point.x-a.x,o.width),y:ne(e.point.y-a.y,o.height)}},Og=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,de.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},_g=class extends Ze{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=me(l,u),p=(0,d.clampAnnotationTranslation)(s,tr(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=Og(Sn(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}=Sn(t,i,n,s);if((0,de.isEqual)(h,u.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}Vm(e)&&o(new d.MoveAnnotationCommand({id:n,translation:e,bounds:me(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,yn(e.at,null,u.at,l),n,o,{targetAligns:rr,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:ne(m.point.x-h.x,l.width),y:ne(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(Mg(m,e.align,g),(0,d.readRectPoint)(m,e.align),yn(e.at,e.align,h.at,l),n,o,{targetAligns:Ui});return v===null?null:{kind:"move-drag",annotationId:a,translation:Rg(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:b,measuredBoxes:C,readObservationBox:y}=a,k=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),w=Hi(me(g,v),{x:ne(t.x,g.width),y:ne(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:b,resolver:u,readObservationBox:y,annotationTargets:o.altKey?[]:qi(m,k,g,C),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}})}},Sn=(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,ne(a.x,o.width))),l=Math.max(0,Math.min(1,ne(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:[]}},mt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,Ki=(e,t,n)=>{const o=mt(e,t,n);return o?.anchorType==="panel"?o:null},Xi=(e,t)=>e==="start"?{start:t}:{end:t},Ng=(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)},Dg=(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},Fg=class extends Ze{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:b,measuredBoxes:C,readObservationBox:y}=h,k=mt(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),T=Hi(me(v,h.frameElement),{x:ne(A.x,v.width),y:ne(A.y,v.height)}),I=o==="start"?"end":"start",E=mt(p,n,I),L=E===null?void 0:Ng(E,m[I],{scene:g,panelRect:v,measuredBoxes:C,readObservationBox:y}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),F=this.readOwn(u.getState())?.placement,O=S=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:A.x+w.x,y:A.y+w.y}}],current:t.altKey?null:yn(k,null,m[o],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:b,resolver:l,readObservationBox:y,annotationTargets:t.altKey?[]:qi(g,B,v,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:F?.type==="snapped"?F.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:rr,areaAlign:S,annotationAreaAlign:S,areaSnapDistance:16,facing:L,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),P=O("auto"),j=P?.type==="snapped"&&P.landing==="area"&&Dg(P.anchor,E)?O(void 0):P;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=mt(i,n,e);if(l===null)return;const u=Sn(t,i,n,s).anchor;Bi(l,u)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Xi(e,u)}))}},Bg=({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: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 Fg({handle:b.currentTarget,pointerId:b.pointerId,annotationId:e,endpoint:f,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])},Gg=[" ","Enter"],uo=4,zg=({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 Fi)ho({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(Gg.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){ho({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:a.dispatch});return}const y=Ki(s,e,h);if(y===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:ro(y,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Hg(p.key,n);if(f===null)return;p.preventDefault();const{anchor:b,point:C}=Dm({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:f,bounds:me(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:ro(b,C,n)})}}),[e,s,t,n,o,i,a])},ho=({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=Ki(o,t,n);l===null||Bi(l,s.placement.anchor)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Xi(n,s.placement.anchor)}))},Hg=(e,t)=>{const n=ne(uo,t.width),o=ne(uo,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}},Vg=e=>{const t=Ke(),n=Ug(t),o=qg(e.panelRect,t),a=Kg(t);if(n===null||o===null)return null;const i=a.dragged===null?o:er(o,a.dragged,e.panelRect);return(0,r.jsx)($g,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},$g=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Bg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=zg({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)(Lg,{arrow:e,arrowBox:Bm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&Fi.map(m=>(0,r.jsx)(Wg,{endpoint:m,point:Fm(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},Wg=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:Ig,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Ug=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},qg=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Kg=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}})),Xg=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"})]})}),Yi="var(--ydgo3h0)";var Yg="ydgo3h1",Zg="ydgo3h2",Jg="ydgo3h3",Qg="ydgo3h4",po={small:2,medium:3,large:5},ev=(e,t)=>{const n=Object.keys(po),o=n.find(a=>{const i=po[a];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&tv(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)},tv=(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),nv="q7gcrz0",rv="q7gcrz1",ov="q7gcrz2";var av=4,iv=6,sv=c.iconSizeMap.sm,lv=3,cv=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*av,u=[n,o].filter(p=>p.length>0).length,h=a.length===0?0:1;return s(n)+s(o)+s(a)+l(u)+l(h)+dv()},dv=()=>36+34*lv+iv*4+sv*2,uv=["absoluteDifference","relativeDifference","proportion"],mo=["absoluteDifference","relativeDifference"],hv=["relativeDifference","proportion"],pv={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},mv=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 uv.filter(i=>a||!mo.includes(i)||i===e.label).map(i=>({kind:i,key:pv[i],preview:(0,d.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!mo.includes(i),suspect:hv.includes(i)&&e.start.measurementValue===0}))},[e,o])},go=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],gv=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:u})=>{const h=c.useI18n(),p=c.useTextMeasurer(),{commands:m}=c.useGraphContext(),g=c.useSceneSelector(N=>N.spec.styles.overrides),v=c.useSceneSelector(N=>(0,d.readStyleCoord)(N.spec)),f=Bt(),b=mv(e),C=c.useStyleReaderTree(),y=(0,d.resolveDifferenceArrowAnnotationStyle)(C,e.id),k=C.graph().get("textScale"),w=(0,x.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),A=(0,x.useMemo)(()=>({...w,part:"label"}),[w]),T=b.find(N=>N.kind===e.label),I=b.some(N=>N.pickable&&N.kind!==e.label),E=go.find(N=>N.id===ev(y,k)),L=(N,Y)=>{m.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:N}),Y)},B=N=>({...(0,d.findStyleRule)(g,{select:w},v)?.declarations,...N}),F=N=>({...(0,d.findStyleRule)(g,{select:A},v)?.declarations,...N}),O=N=>{L(N),f.close()},P=()=>{m.dispatch(new d.RemoveAnnotationCommand({id:e.id})),u.focus({preventScroll:!0})},j=N=>m.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:w,declarations:B({stroke:N})}}),{transient:!0}),S=()=>L({start:e.end.anchor,end:e.start.anchor}),R=N=>()=>O({label:N}),G=N=>()=>{const Y=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[N];m.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(Y.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(F(Y.label))})),f.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[vo(i,o),vo(i,a)],estimatedPillWidthPx:cv({textMeasurer:p,textScale:k,labelKindName:T===void 0?"":h(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:E===void 0?"":h(E.key)}),label:h("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(vv,{option:T}),disabled:!I,...f.bind("labelKind"),children:b.map(N=>(0,r.jsxs)(V.MenuItem,{selected:N.kind===e.label,disabled:!N.pickable,onClick:R(N.kind),children:[(0,r.jsx)("span",{children:h(N.key)}),(N.suspect||!N.pickable)&&(0,r.jsx)("span",{"aria-label":h(N.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:ov,children:N.preview})]},N.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:h("graph.annotations.differenceArrowToolbar.color"),onChange:j,...f.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:E===void 0?"":h(E.key),...f.bind("size"),children:go.map(N=>(0,r.jsx)(V.MenuItem,{selected:N.id===E?.id,onClick:G(N.id),children:h(N.key)},N.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.swap"),onClick:S,children:(0,r.jsx)(Xg,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.remove"),onClick:P,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},vv=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:rv,children:t(e.key)}),(0,r.jsxs)("span",{className:nv,children:["(",e.preview,")"]})]})},vo=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),fv=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=xv({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},xv=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Zi=e=>e==="start"?"end":"start",Ji=({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}}))},bv=class extends Ze{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=fv({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:u,coordSystem:h,resolver:a,fixedAnchor:i[Zi(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;Ji({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},yv=({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 bv({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])},Sv=[" ","Enter"],Cv=({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(Sv.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"),Ji({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=wv(h.key,s);if(g===null)return;h.preventDefault();const v=jv({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])},wv=(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}},jv=({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[Zi(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},Tv=e=>{const t=Ke(),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:Yg,children:[t!==null&&(0,r.jsx)(Av,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(Pv,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},Av=({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)(kv,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},kv=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:u,frameElement:h,dragging:p})=>{const m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,fe.assignInlineVars)({[Yi]:m}),children:[!p&&(0,r.jsx)(gv,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:u.width,frameHeight:u.height,frameElement:h}),(0,r.jsx)("div",{"aria-hidden":"true",className:Qg,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},Pv=({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=yv({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=Cv({arrow:e.committedArrow}),m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,fe.assignInlineVars)({[Yi]:m}),children:[(0,r.jsx)(fo,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(fo,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},fo=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Zg,"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:Jg})}),Lv="s8eewu0",xo="s8eewu1",Iv=({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:bo(g-f.left,0,f.width),y:bo(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:Lv,children:o===null?(0,r.jsx)("line",{className:xo,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:xo,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)})})},bo=(e,t,n)=>Math.min(Math.max(e,t),n),Ev=({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:nr,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})})},Mv="var(--o49ib40)",Rv={sm:"o49ib41",md:"o49ib42"},Ov={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Qi=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:Ov[n],role:"button",style:{left:e.x,top:e.y,...(0,fe.assignInlineVars)({[Mv]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Rv[o]})})},Cn=[{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"}],_v=e=>[...Cn].reverse().find(t=>t.width<=e)??Cn[0],Nv=({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=Bt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=_v(m.strokeWidth),v=(0,x.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),f=(w,A)=>{const T=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...T,...w}}}),A)},b=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},C=w=>f({fill:w},{transient:!0}),y=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: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)(Wi,{size:"sm",title:""}),...p.bind("border"),children:Cn.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:b,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},wn=({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,de.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,de.clamp)(u+o,p,m)-e}},Dv=["top-left","top-right","bottom-right","bottom-left"];var es=({width:e,height:t})=>({x:ne(16,e),y:ne(16,t)}),Fv=(e,t)=>({x:rs(t)?e.x:e.x+e.width,y:os(t)?e.y:e.y+e.height}),ts=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=wn({start:e.x,extent:e.width,moveStartEdge:rs(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=wn({start:e.y,extent:e.height,moveStartEdge:os(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}},ns=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,rs=e=>e==="top-left"||e==="bottom-left",os=e=>e==="top-left"||e==="top-right",as=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])},Pt=(e,t)=>{const n=e.shapes.find(o=>o.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Bv=class extends Ze{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=Pt(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:ts({region:u,corner:n,delta:tr(o,e,s),minSize:es(s),bounds:me(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=Pt(o().annotations,t);a===null||ns(a,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Gv=({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 as((s,l)=>new Bv({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},zv=[" ","Enter"],is=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,x.useEffect)(()=>()=>yo(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(zv.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){yo(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])},yo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},So=4,Hv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return is({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=Pt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=Vv(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:ts({region:s.region,corner:l,delta:h,minSize:es(t),bounds:me(t,n)})}},commit:({region:s})=>{const l=Pt(i,e);l===null||ns(l,s)||o.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},Vv=(e,t)=>{const n=ne(So,t.width),o=ne(So,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}},$v={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},Wv=e=>{const t=Ke(),n=qv(t),o=Kv(t);if(n===null)return null;const a=o.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return a===null?null:(0,r.jsx)(Uv,{shape:n,region:a,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},Uv=({shape:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=Gv({annotationId:e.id,panelRect:a,frameElement:s}),h=Hv({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)(Nv,{shape:e,shapeBox:p,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&Dv.map(m=>{const g=Fv(p,m);return(0,r.jsx)(Qi,{point:{x:a.x+g.x,y:a.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:$v[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},qv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},Kv=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})),Xv=({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 ss=[{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})),Yv=e=>ss.find(t=>t.id===(e??"modern"))??null;var ls=[{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"}],Zv=e=>ls.find(t=>t.size===(e??15))??null,Jv=e=>`${e}px`,Qv=[{alignment:"left",Icon:bi},{alignment:"center",Icon:fi},{alignment:"right",Icon:xi}],e1=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(D=>D.spec.styles.overrides),h=c.useSceneSelector(D=>(0,d.readStyleCoord)(D.spec)),p=c.useEditorStore(),m=Bt(),g=Ei(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),f=g0(e.content),b=c.useEditorState(D=>D.caret?.editor??null),C=(0,we.useEditorState)({editor:b,selector:()=>Ci(b)}),y=(0,we.useEditorState)({editor:b,selector:()=>wi(b)}),k=Yv(f.font??y),w=Zv(f.fontSize??C),A=c.useTextAnnotationTextColor(v),T=f.color??A,I=(0,x.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),E=(D,$)=>{const W=(0,d.findStyleRule)(u,{select:I},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:I,declarations:{...W,...D}}}),$)},L=(D,$)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:D}),$)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,F=(D,$)=>{const W=B(),X=p.getState().caret?.editor??null;if(X!==null&&!ze(W)){X.chain().focus().setMark(We,D).run();return}L({content:v0(W,D)},$)},O=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=D=>E(t1(D),{transient:!0}),j=D=>E({fillAlpha:D},{transient:!0}),S=v.fill!==bt,R=D=>F({color:D===d.AUTO_COLOR?void 0:D},{transient:!0}),G=D=>()=>{ze(B())||Y({font:D}),F({font:D}),m.close()},N=D=>()=>{ze(B())||Y({fontSize:D}),F({fontSize:D}),m.close()},Y=D=>{const $=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:$,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:D.fontSize??C,pickedFont:D.font??y});W>e.width&&L({width:W})},Z=D=>{const $=p.getState().caret?.editor??null;if($===null||ze(B())){L({content:f0(B(),D)});return}const W=$.state.storedMarks;$.chain().focus().setTextAlign(D).command(({tr:X})=>(X.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:P,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):gh,opacity:S?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)(Xv,{size:"sm",textColor:T,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:ss.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.id===k?.id,onClick:G(D.id),children:(0,r.jsx)("span",{style:{fontFamily:D.fontFamily},children:s(D.key)})},D.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:ls.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.size===w?.size,onClick:N(D.size),children:(0,r.jsx)("span",{style:{fontSize:Jv(D.size)},children:s(D.key)})},D.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(n1,{current:f.alignment??"center",onPick:Z}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:O,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},t1=e=>e==="transparent"?{fill:bt}:{fill:e,fillAlpha:yh(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},n1=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:Qv.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))})},r1=["left","right"];var cs=({width:e})=>ne(60,e),o1=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),ds=({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=a1(e.offset,s),p=wn({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}},us=(e,t)=>e.at.x===t.at.x&&e.width===t.width,a1=(e,t)=>e?.x===void 0?0:e.unit==="px"?ne(e.x,t):e.x,Lt=(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}},i1=class extends Ze{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=Lt(i,t);if(u===null)return null;const h=tr(o,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...ds({...u,edge:n,delta:h,minWidth:cs(s),panelWidth:s.width,bounds:me(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=Lt(o().annotations,t);a===null||us(a,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},s1=({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 as((s,l)=>new i1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},l1=4,c1=({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=Lt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...ds({...h,edge:l,delta:u,minWidth:cs(t),panelWidth:t.width,bounds:me(t,n)})}};return is({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=d1(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=Lt(i,e);u===null||us(u,l)||o.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},d1=(e,t)=>{const n=ne(l1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},u1=e=>{const t=Ke(),n=p1(t),o=m1(t),a=c.useEditorState(s=>s.caret?.annotationId===t),i=g1(e.panelRect,t,o.resized);return n===null||i===null?null:(0,r.jsx)(h1,{annotation:n,textBox:i,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:n.at.anchorType==="panel",hasCaret:a,...e})},h1=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=s1({annotationId:e.id,panelRect:s,frameElement:u}),m=c1({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)(e1,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),a&&!o&&!i&&r1.map(g=>{const v=o1(t,g);return(0,r.jsx)(Qi,{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)})]})},p1=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},m1=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})),g1=(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:Gi(o,t,n,s)?.rect??null},or=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],v1=(e,t,n)=>c.readStampedEditTargetInStack(or(e,t),n),f1="_1rpuha50";var Co=["pointerdown","mousedown","pointerup","mouseup","click"],hs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,x1=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>S1(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=b1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(y1(h)))};for(const h of Co)l.addEventListener(h,u);return()=>{for(const h of Co)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:f1,"data-menu-shield":"","data-testid":"menu-shield"}):null},b1=(e,t)=>or(e,t).find(n=>!hs(n))??null,y1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),S1=e=>e==="arrow-draw"||e==="box-draw",C1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',w1=(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)||yt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(C1)];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])},j1=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:v1(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])},T1=(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=A1(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:L1(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},A1=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=k1(o,a);if(i!==null)return i}return null},k1=(e,t)=>{for(const n of e){const o=(0,d.readVariableName)(n.mapping[t]);if(o!==null&&P1(n,o))return{layer:n,variable:o}}return null},P1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",L1=(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},I1=({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},E1=(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})},jn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=wo(!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?M1(a):null,h=u===null?null:R1(e,u,t),p=h===null?null:I1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=wo(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}},M1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},wo=(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?or(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}},R1=(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})},O1=({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||qe(h,l.observation)||!_1(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}},_1=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}},jo="data-annotation-id",N1='[data-testid="pinnedNumber"], [data-testid="comment"]',To=(e,t,n)=>{if(e.target instanceof Element){const o=Ao(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=Ao(o,t);if(a!==null)return a}return null},D1=(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:F1(e,n.at.anchor.layerId,n.at.observationIndex)},Ao=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(N1);if(n===null||!t.contains(n))return null;const o=e.closest(`[${jo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(jo);return a===null||a.length===0?null:a},F1=(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})},B1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},G1=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!Po(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Po(t,e)){const{primary:l,intersection:u}=o.query((0,d.toPanelCursor)(i,t),{tolerance:B1,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&&qe(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=zi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:ko(i.x/t.width,s.minX,s.maxX),y:ko(i.y/t.height,s.minY,s.maxY)}},ko=(e,t,n)=>Math.min(Math.max(e,t),n),Po=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,z1=(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 H1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},H1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},V1=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,$1=(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)(E=>({spec:E.spec.annotations,layers:E.layers,coordSystem:E.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),f=c.usePaintedObservationBoxes(t),b=c.useGraphMode(),{selectGraphOnPress:C}=c.MODE_RULES[b],y=c.useLatestRef(C),k=c.useLatestRef(b===c.GRAPH_MODES.annotate),w=c.useLatestRef(b===c.GRAPH_MODES.annotate),A=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:f}),T=c.useLatestRef(o),I=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>I.current?.finish(!1),[]),(0,x.useEffect)(()=>s.subscribe(({selection:E})=>{const L=p.getState().pressedObservation,[B,...F]=E,O=B!==void 0&&F.length===0&&L!==null&&(0,d.areEditTargetsEqual)(B,L.selectedFor);L!==null&&!O&&p.getState().setPressedObservation(null)}),[p,s]),(0,x.useEffect)(()=>{const E=j=>jn({target:j.target,clientX:j.clientX,clientY:j.clientY},n()).targetAtPoint,L=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(I.current!==null||!c.canMoveAnnotationOnCanvas(A.current.spec,S.id))return;try{e.setPointerCapture(j.pointerId)}catch{return}j.preventDefault();const R=new _g({handle:e,pointerId:j.pointerId,annotationId:S.id,press:{x:j.clientX,y:j.clientY},readInputs:()=>A.current,editorStore:p,engine:h,anchorResolver:u,dispatch:a.dispatch,onSettled:()=>{I.current=null}});I.current=R,R.start()},F=(j,S)=>{const R=s.getState(),{layers:G,config:N,coordSystem:Y}=l.getState().scene,Z=S.kind==="select-observations"&&S.observationIndex!==null?c.readPressedObservation(S.observationIndex,G,S.target,N.parsingLocale):null;if(p.getState().setPressedObservation(Z),k.current&&(S.kind==="select-observations"||S.kind==="select-band")){const D=(0,d.findLayerById)(G,S.target.layerId);if(D!==void 0&&Cm(D.geom,Y.type)){const $=e.getBoundingClientRect(),W=Xn(e,$.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(S.target),x:(j.clientX-$.left)/W,y:(j.clientY-$.top)/W})}else p.getState().setAnnotatePress(null)}switch(S.kind){case"select-annotation":R.setSelection([S.target]),B(j,S.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([S.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(S)}`})}},O=j=>{if(j.button!==0)return;if(hs(j.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(sn(j.target))return;const S=p.getState().caret?.annotationId??null,R=j.target instanceof Element?j.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ee(j.target)&&R!==S&&Zn(p,l.getState().scene.annotations,a.dispatch,Yn(i));const G=p.getState().standingInteraction,N=U=>{p.getState().releaseInteraction(U),p.getState().setPlotMenu(null),s.getState().clearSelection()},Y=me(A.current.panelRect,A.current.frameElement),Z=U=>{const q=e.getBoundingClientRect();return U.x<q.left||U.x>q.right||U.y<q.top||U.y>q.bottom};if(G?.kind==="arrow-draw"){const U=n(),q=U.captureRect?.getBoundingClientRect()??null,le={x:j.clientX,y:j.clientY};if(Z(le)){N("arrow-draw");return}const ie=c.readArrowEnd({client:le,capture:q,bounds:Y,engine:U.engine,layers:U.scene.layers,start:G.start});if(ie===null)return;a.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(G.heads),start:{anchorType:"panel",x:G.start.x,y:G.start.y},end:ie}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(G?.kind==="box-draw"){const U=n().captureRect?.getBoundingClientRect()??null,q={x:j.clientX,y:j.clientY};if(Z(q)){N("box-draw");return}const le=c.readDrawnPanelPoint(q,U,Y);if(le===null||U===null||c.isTinySpan(G.start,le,U))return;a.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(G.start,le)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),L(j)||c.isOnLiveGeomMark(j.target,e))return;const D=n(),$=jn({target:j.target,clientX:j.clientX,clientY:j.clientY},D);if(w.current){const U=To(j,e,$.elements),q=U===null?null:D1(l.getState().scene,U);if(q?.observationIndex!==void 0){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q,observationIndex:q.observationIndex});return}}const W=j.target instanceof Node&&e.contains(j.target),X=z1($.targetAtPoint,{canSelectGraph:y.current&&!Ee(j.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const be=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(U=>U.id===X.target.id);if((X.kind==="clear"||be)&&k.current){const U=n();if(j.target===U.captureRect){const q=O1({client:{x:j.clientX,y:j.clientY},capture:U.captureRect?.getBoundingClientRect()??null,engine:U.engine,layers:U.scene.layers,parsingLocale:U.scene.config.parsingLocale,hasMenu:U.hasOverlayMenu});if(q!==null){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q.target,observationIndex:q.observationIndex});return}}}const Re=D.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(W&&(X.kind==="clear"||Re)&&w.current&&To(j,e,$.elements)===null&&!W1(j.target,$.elements)){const U=G1({client:{x:j.clientX,y:j.clientY},capture:D.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:D.engine,layers:D.scene.layers});if(U!==null){p.getState().setCaret(null),F(j,{kind:"clear"}),p.getState().setPlotMenu(U);return}}p.getState().setCaret(null),F(j,X)},P=j=>{if(sn(j.target)||L(j)||c.isOnLiveGeomMark(j.target,e))return;const S=E(j),{layers:R,guides:G,config:N}=l.getState().scene,{hasOverlayMenu:Y}=n(),Z=s.getState(),D=p.getState();switch(S?.kind){case"observations":{const{observations:$}=S,W=E1($,R,N.parsingLocale);if(W===null||!Y(W))return;const{observationIndex:X}=$;D.setPressedObservation({observationIndex:X,predicate:W.predicate,selectedFor:W}),Z.setSelection([W]);return}case"axis":case"legend":{const $=T1(S,{layers:R,legends:G.legends.drawn,formattedAxes:T.current,parsingLocale:N.parsingLocale});if($===null||!Y($))return;Z.setSelection([$]);return}case"annotation":{const{target:$}=S;if(!A.current.spec.textAnnotations.some(W=>W.id===$.id))return;Z.setSelection([$]),D.setCaret($.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",O),document.addEventListener("dblclick",P),()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("dblclick",P)}},[e,p,s,l,a,i,A,T,y,k,w,n,h,u])},W1=(e,t)=>Ee(e)||Lo(e)||t.some(Lo),Lo=e=>e instanceof Element&&e.closest(V1)!==null,U1=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])},q1={kind:"idle"},K1=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Ip();return(0,x.useMemo)(()=>e!==null?e:t===null?q1:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},X1=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Y1=(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,b=l.current,C={x:v.clientX-b.x,y:v.clientY-b.y},y=X1(C,f)?i.query((0,d.toPanelCursor)(C,f)):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=>{sn(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])},Z1=(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(ut(k.standingInteraction))return;if(u&&(u=!1,l={...l,target:J1(l)}),c.isOnLiveGeomMark(l.target,e)){k.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:A}=jn(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()},b=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},C=n.subscribe((k,w)=>{ut(w.standingInteraction)&&!ut(k.standingInteraction)&&g()}),y=o.subscribe((k,w)=>{k.scene!==w.scene&&(ut(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),C(),y(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",b),v()}},[e,n,o,a,i,t])},J1=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ut=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}},Q1=(e,t,n,o,a)=>{const i=K1(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=U1(e);Z1(e,h),$1(e,n,h,a),Y1(i,t,n),j1(e),$0(e),w1(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])},ef=({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=()=>{Zn(h,l.getState().scene.annotations,s.dispatch,Yn(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 y=v.current;v.current={width:m,height:g},!(y.width===m&&y.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const f=c.useEditorState(y=>y.caret?.annotationId??null),b=c.useGraphMode(),C=(0,x.useRef)(b);return(0,x.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,x.useEffect)(()=>()=>{p.current();const y=h.getState();y.setCaret(null),y.setPressedObservation(null),y.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,x.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)(ul,{children:[f!==null&&(0,r.jsx)(tf,{annotationId:f,panelRect:t}),(0,r.jsx)(nf,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},tf=({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},nf=({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 Q1(e,a,n,i,o),(0,r.jsx)(rf,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},rf=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=Mt(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Jp,{frameElement:e,frameSize:(0,x.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(Nm,{frameRect:t}),(0,r.jsx)(L0,{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)(Tv,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(Wv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Vg,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(u1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Wm,{panelRect:o}),(0,r.jsx)(Iv,{frameElement:e,panelRect:o}),(0,r.jsx)(Ev,{panelRect:o}),(0,r.jsx)(og,{panelRect:o}),(0,r.jsx)($m,{panelRect:o}),(0,r.jsx)(eg,{panelRect:o})]}),(0,r.jsx)(Om,{frameElement:e}),s&&(0,r.jsx)(sp,{frameElement:e,panelRect:o}),(0,r.jsx)(x1,{})]})})]})},of={},af=({slots:e,palettePresets:t=of,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,x.useMemo)(()=>({EditorSurface:ef,...e}),[e]);return(0,r.jsx)(Vn,{...a,children:(0,r.jsx)(Vu,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(Sd,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:k0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},sf="_12lhx9e0",ps=({children:e})=>(0,r.jsx)("div",{className:sf,children:e}),lf="_139ohwv0",oe=({children:e})=>(0,r.jsx)("div",{className:lf,children:e}),ms=(0,x.createContext)(null),cf=ms.Provider,gs=()=>{const e=(0,x.useContext)(ms);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},df="_1jlczkt0",vs="data-graphy-editor-panel",uf={List:oe,Grid:ps};function hf(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var pf=()=>()=>{},mf=e=>{const t=(0,x.useSyncExternalStore)(e?.subscribe??pf,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},gf=e=>{const t=(0,x.useContext)(c.GraphContext),n=c.useChartI18nProps(mf(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(vf,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(Vn,{...n,children:a})},ar={Root:gf,Controls:uf},vf=({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)(Rt.Provider,{value:i,children:(0,r.jsx)(fa,{controls:n,children:(0,r.jsx)(cf,{value:p,children:(0,r.jsx)(Ge.Accordion.Root,{[vs]:"",className:(0,ge.default)(df,a,{[s]:!hf(a)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},ff="_2m7wuq0",xf=()=>(0,r.jsx)(Hs.Separator,{className:ff}),bf=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"})})}),ir="_40zvwv0",sr="_40zvwv1",yf="_40zvwv2",fs="_40zvwv3",Sf="_40zvwv4 _40zvwv3";var Cf="_40zvwv6";var wf="_40zvwv8",Q=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(Tf,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(jf,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:ir,children:[(0,r.jsxs)("div",{className:sr,children:[(0,r.jsx)("span",{className:fs,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})]}),jf=({title:e,accessory:t,children:n})=>{const o=(0,x.useId)(),a=(0,x.useId)();return(0,r.jsx)("div",{className:ir,children:(0,r.jsxs)("div",{className:sr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:Sf,children:e}),(0,r.jsx)("span",{className:Cf,children:(0,r.jsx)(Xo,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Tf=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ge.Accordion.Item,{value:e,className:ir,onOpenChange:o,children:[(0,r.jsxs)(Ge.Accordion.Header,{className:sr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ge.Accordion.Trigger,{className:yf,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:fs,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:wf,children:(0,r.jsx)(bf,{size:"sm"})})]}),(0,r.jsx)(Ge.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},xs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=gs(),{Switch:u}=H(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(Q,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:o,ariaLabel:e}),children:i})},Af={horizontal:["bottom","top"],vertical:["left","right"]},kf={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},Pf={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},gt=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:u,Switch:h,TextField:p,ToggleGroup:m}=H();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const g=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,v=i.scales[e],f=v?.spec,b=f?.scaleType==="continuous"?f:void 0,C=f?.scaleType==="datetime",y=f?.scaleType==="continuous"||C?f:void 0;if(g==="circular"||g==="radial"&&b===void 0)return null;const k=f?.scaleType==="continuous"||f?.scaleType==="datetime",w=b!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),A=b?.transform==="log",T=y?.domainMax??null,I=Lf(y),E=(_,re)=>_.map(et=>({value:et,label:re(et)})),L=i.guides.axes.find(_=>_.scaledAesthetic===e);if(L===void 0)return null;const B=L.position,F=i.guides.axes.filter(_=>_.scaledAesthetic===e),O=F.some(_=>_.visible),P=F.some(_=>_.visible||_.showGrid),j=e==="ySecondary"?i.config.axes.ySecondary?.label??L.label??"":i.config.axes[e].label??L.label??"",S=Af[B==="bottom"||B==="top"?"horizontal":"vertical"],R=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,G=R===null?void 0:(0,d.findLayerById)(i.spec.layers,R),N=i.guides.legends.drawn.some(_=>!_.inHeadlineRow&&S.some(re=>re===_.position)),Y=S.map(_=>({value:_,label:s(kf[_])})),Z=E(["auto","edges"],_=>s(_==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),D=E(["linear","log"],_=>s(_==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),$=E(C?["auto","custom"]:["auto","zero","custom"],_=>s(_==="zero"?"editor.axesPanel.startFrom.zero":_==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),W=E(["auto","custom"],_=>s(_==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),X=E(["single","double"],_=>s(_==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),be=_=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.visible)}));return}a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},Re=_=>{a.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:_}),{transient:!0})},U=_=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},q=_=>{const re=_==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:rn(re,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:re,keepSecondaryAxis:!0}))},le=_=>{a.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:_==="log"?"log":"linear"}))},ie=_=>{a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,..._}),{transient:!0})},Oe=_=>{_!==null&&ie({domainMin:_})},$t=_=>{_!==null&&ie({domainMax:_})},je=_=>{const re=bs(_);re!==null&&ie({domainMax:re})},Qe=_=>{if(_==="auto"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(_==="zero"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const re=Io(v?.domain,"start");re!==null&&a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:re}))},z=_=>{if(_!=="custom"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const re=Io(v?.domain,"end");re!==null&&a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:re}))},J=_=>{G!==void 0&&a.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:G.id,yScaleType:_==="double"?"secondary":"primary"}))},he=_=>{if(e==="ySecondary")return;const re=S.find(et=>et===_);re&&a.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:re}))};return(0,r.jsx)(Q,{title:t??s(Pf[e]),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(h,{checked:L.visible,onChange:be})}),G!==void 0&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(m,{value:G.yScaleType==="secondary"?"double":"single",options:X,onChange:J})}),g==="linear"&&(0,r.jsxs)(r.Fragment,{children:[L.visible&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:j,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:Re,onCommit:a.commands.commit})}),O&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(h,{checked:L.showTicks,onChange:U})})]}),k&&P&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(m,{value:L.tickMode,options:Z,onChange:q})}),e!=="ySecondary"&&b&&g==="linear"&&L.visible&&!N&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(m,{value:L.position,options:Y,onChange:he})}),b&&!w&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(m,{value:A?"log":"linear",options:D,onChange:le})}),y&&!A&&(0,r.jsxs)(r.Fragment,{children:[!w&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(m,{value:I,options:$,onChange:Qe})}),I!=="auto"&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:C?(0,r.jsx)(l,{value:Gt(y.domainMin??null),onChange:Oe,onCommit:a.commands.commit}):(0,r.jsx)(u,{value:y.domainMin??null,onChange:Oe,onCommit:a.commands.commit})})]}),(0,r.jsx)(M,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(m,{value:T===null?"auto":"custom",options:W,onChange:z})}),T!==null&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:C?(0,r.jsx)(l,{value:If(T),onChange:je,onCommit:a.commands.commit}):(0,r.jsx)(u,{value:T,onChange:$t,onCommit:a.commands.commit})})]})]})})},rn=(e,t)=>e===t?void 0:e,Lf=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Io=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?Gt(n.getTime()):bs(n.getTime()):typeof n=="number"?n:null},Gt=e=>{if(e===null||!Number.isFinite(e))return null;const t=new Date(e).toISOString().slice(0,10),n=Date.parse(`${t}T00:00:00.000Z`);return Number.isNaN(n)?null:n},bs=e=>{const t=Gt(e);return t===null?null:t+864e5},If=e=>e===null||!Number.isFinite(e)?null:Gt(e-1),lr=({value:e,onChange:t})=>{const n=K(),o=c.useI18n(),{TextField:a}=H(),i=e!==null&&typeof e!="string"?ys(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",u=h=>{if(h==="")return t(null);t(i?i.write(h):h)};return(0,r.jsx)(M,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:u,onCommit:n.commands.commit,disabled:s})})},ys=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?ys(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},Ss=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(lr,{value:l.caption,onChange:h})]})})},Eo=/^[a-z][a-z\d+.-]*:/i,Ef={},Cs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(Mf,{source:l.source??Ef})]})})},Mf=({source:e})=>{const t=K(),n=c.useI18n(),{TextField:o}=H(),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!==""&&!Eo.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)(M,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:Eo.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(M,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},ws=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(lr,{value:l.subtitle,onChange:h})]})})},Je=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])},cr=(e,t,n)=>{const o=Je(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])},Tn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Rf=Tn.length/2,Of={select:{target:"graph"}},js=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=H(),l=Je(a);if(!a||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Tn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=Tn.find(b=>`${b}`===g);if(v===void 0)return;const f=(0,d.findStyleRule)(a.spec.styles.overrides,Of,(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)(Q,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:Rf,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},Ts=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(lr,{value:l.title,onChange:h})]})})},_f=({children:e,...t})=>(0,r.jsx)(ar.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ts,{}),(0,r.jsx)(ws,{}),(0,r.jsx)(Ss,{}),(0,r.jsx)(Cs,{}),(0,r.jsx)(js,{})]})}),Nf=({children:e,...t})=>(0,r.jsx)(ar.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{axis:"x"}),(0,r.jsx)(gt,{axis:"y"}),(0,r.jsx)(gt,{axis:"ySecondary"})]})}),zt=e=>`${e}px`,As=e=>`${Math.round(e*100)}%`,Df=e=>`${e}°`,Ff=24,Bf={select:{target:"graph"}},Mo=["dim","desaturate"],Gf=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=Je(a);if(!a||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(a.spec),m=Mo.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const b=(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:{...b,cornerRadius:f}}}),{transient:!0})},v=f=>{const b=Mo.find(C=>C===f);b&&o.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(Q,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Ff,step:1,formatValue:zt,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},zf={none:0,md:3.5,full:6.5},Hf=({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:zf[e],stroke:"currentColor",strokeWidth:1.5})}),Vf=.05,Ro=["none","md","full"],ks={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},$f=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=a?(0,d.findLayerByGeom)(a.spec.layers,"bar"):void 0,h=cr(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=Ro.find(A=>A===C);if(!y)return;const[k,w]=ks[b];o.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[k]:y,[w]:y}}))},v=Ro.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(Hf,{cornerRadius:b})})),f=(0,d.resolveBarBandFraction)(u.params,a.coordSystem.type);return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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:Vf,formatValue:As,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:Oo(m,"tip"),options:v,onChange:b=>g("tip",b)})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:Oo(m,"base"),options:v,onChange:b=>g("base",b)})})]})})},Oo=(e,t)=>{const[n,o]=ks[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},Ht=({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"})]})})]})},Vt="qdaoth0",Wf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Uf=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Ht,{children:[(0,r.jsx)("path",{className:Vt,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"})]})}),qf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Kf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Xf={x:.5,y:.5},Yf=.2,Zf={x:.375,y:.25,width:.25,height:.5},Jf={zOrder:"background"},Qf={x:.4,y:.6},ex={x:.6,y:.4},tx="relativeDifference",nx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=H();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",...Xf},width:Yf}}))},u=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...Qf},end:{anchorType:"panel",...ex}}}))},h=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Jf,region:{anchorType:"panel",...Zf}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:tx}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(Q,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ps,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Kf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Wf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Uf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(qf,{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=K(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=H();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)(Q,{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")})})},ax=.1,ix=20,sx=({title:e,preview:t})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=H();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 b=new d.ToggleGoalLineCommand({showGoalLine:f,value:lx(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(b)},g=f=>{if(l===void 0)return;const b=new d.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(b,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const b=new d.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(xs,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{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")})})]})})},lx=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(ix,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*ax).toFixed(i))},_o=["auto","inside","outside"],cx=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:u}=H();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,b=ya(h,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const C=T=>{const I=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});a.commands.dispatch(I)},y=T=>{const I=_o.find(E=>E===T);I!==void 0&&a.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:I}))},k=T=>{const I=new d.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});a.commands.dispatch(I)},w=T=>{const I=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});a.commands.dispatch(I)},A=T=>{const I=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});a.commands.dispatch(I)};return(0,r.jsx)(Q,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:C})}),b.supportsPosition&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:f,options:_o.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:y})}),b.supportsPercentages&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:k})}),b.supportsStackTotals&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:A})})]})})},dx=3,ux=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=H(),l=(0,x.useMemo)(()=>Ve.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!wa(v,a?.spec)})),[i,a]);if(!a)return null;const u=(0,d.readGraphType)(a.spec),h=St(u),p=m=>{const g=Ve.find(v=>v.name===m);g&&o.commands.dispatch(new d.SetGraphTypeCommand(ja(g.summary,u)))};return(0,r.jsx)(Q,{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:dx,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},hx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=H(),h=Je(a),p=a!==null&&h!==null?Na(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=jt.map(y=>({value:y,label:i(`editor.graphPanel.gridSection.lineStyles.${y}`)})),f=y=>k=>{o.commands.dispatch(new d.SetGridVisibilityCommand({axis:y,visible:k}))},b=y=>{const k=jt.find(w=>w===y);k!==void 0&&o.commands.dispatch(Da(k))},C=y=>{o.commands.dispatch(Fa(y),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[m.map(y=>(0,r.jsx)(M,{label:i(px(y)),children:(0,r.jsx)(l,{checked:y.showGrid,onChange:f(y.scaledAesthetic)})},y.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:b})}),(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:zt,onChange:C,onCommit:o.commands.commit})})]})]})})},px=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",mx="total",Ps=["total","average","current"],gx=["total"],No=["previous","first"],Do=["auto","small","medium","large"],vx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=H();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(F=>F.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?gx:Ps,b=a.guides.headline,C=b?.kind==="perGroup"&&b.items.some(F=>F.comparison!==null),y=f.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.metrics.${F}`)})),k=No.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.comparison.${F}`)})),w=Do.map(F=>({value:F,label:i(F==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${F}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=F=>{o.commands.dispatch(new d.SetHeadlineShowCommand({show:F?mx:"none"}))},I=F=>{const O=f.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineShowCommand({show:O}))},E=F=>{const O=No.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:O}))},L=F=>{const O=Do.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineSizeCommand({size:O}))},B=F=>{o.commands.dispatch(new d.SetHeadlinePositionCommand({position:F==="center"?"center":"above"}))};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??fx(i,u.show),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:y,onChange:I})}),C&&(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:k,onChange:E})}),(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:w,onChange:L})}),g&&(0,r.jsx)(M,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:A,onChange:B})})]})]})})},fx=(e,t)=>{const n=Ps.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var on=["top","bottom","left","right","none"],Fo=["auto","start","center","end"],xx={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Bo=["auto","pill","direct"],bx=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=H(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??on,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 b=m?.position??"none",C=h==="auto"?b:h,y=on.filter(j=>j===C||p.includes(j)).map(j=>({value:j,label:s(`editor.graphPanel.legendSection.${j}`)})),k=j=>{const S=on.find(R=>R===j);S&&a.commands.dispatch(new d.SetLegendPositionCommand({position:S}))},w=j=>{const S=Fo.find(R=>R===j);S&&a.commands.dispatch(new d.SetLegendAlignCommand({align:S}))},A=j=>{const S=Bo.find(R=>R===j);S&&a.commands.dispatch(new d.SetLegendDisplayCommand({display:S}))},T=m?.position==="left"||m?.position==="right"?"column":"row",I=T==="row"?"ltr":u,E=j=>s(j==="start"||j==="end"?`editor.graphPanel.legendSection.${xx[T][j]}`:`editor.graphPanel.legendSection.align.${j}`),L=Fo.map(j=>({value:j,label:E(j)})),B=Bo.map(j=>({value:j,label:s(`editor.graphPanel.legendSection.display.${j}`)})),F=t??s("editor.graphPanel.legendSection.title"),O=y.find(j=>j.value===C)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(Q,{title:F,layout:n,preview:o??O,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:C,options:y,onChange:k})}),P&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Ln.DirectionProvider,{direction:I,children:(0,r.jsx)("div",{dir:I,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:L,onChange:w})})})}),g&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},yx=1,Sx=20,Cx=.5,Ls=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),{Slider:o}=H(),a=cr(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:Sx,step:Cx,formatValue:zt,onChange:l,onCommit:t.commands.commit})},Is=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),o=cr(n,e,"point");return n?(0,r.jsx)(Nn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},wx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=H(),p=Je(a),m=(0,d.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?_n(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(T=>({value:T,label:Sa(i,T)})),f=[{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"}))},k=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})},A=T=>{const I=cn.find(E=>E===T);I&&o.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:I}))};return(0,r.jsx)(Q,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(M,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(Ls,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(Is,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:C})}),g.smooth!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:y})}),(0,r.jsx)(M,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:f,onChange:k})}),g.widthMode==="custom"&&(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:zt,onChange:w,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(M,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:A})})]})})},An="\0none",jx=["x","y","color","size","label"],Tx={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"},Ax=({title:e,layout:t="collapsible"})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=H(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,u=(0,x.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,jx).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:a(Tx[h]),value:g??(m?null:An),options:kx(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===An?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(Q,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(oe,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(M,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},kx=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:An,label:n}],...o.map(a=>({value:a,label:a}))]},Px="k",Lx=2,Ix=0,Ex=5,kn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Mx=["auto","none"],Rx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=H();if(!a)return null;const{abbreviation:u,decimals:h}=a.config.numberFormat,p=Ox(u)!==void 0,m=h!=="auto",g=w=>w.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),v=kn.map(({value:w,labelKey:A})=>({value:w,label:i(`common.abbreviations.${A}`)})),f=w=>{o.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const A=Mx.find(T=>T===w);f(A??Px)},C=w=>{const A=kn.find(T=>T.value===w);A&&f(A.value)},y=w=>{o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w==="custom"?Lx:"auto"}))},k=w=>{w!==null&&o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:C})}),(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:Ix,max:Ex,onChange:k,onCommit:o.commands.commit})})]})})},Ox=e=>kn.find(t=>t.value===e),_x=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(K()),a=c.useI18n();if(!o)return null;const i=Nx(o.spec.layers);return i?(0,r.jsx)(Q,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(Ls,{layerId:i.id})}),(0,r.jsx)(Is,{layerId:i.id})]})}):null},Nx=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},Dx=.9,Fx=360,Bx=.05,Gx=15,zx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=H();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)(Q,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:Dx,step:Bx,formatValue:As,onChange:h,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:Fx-1,step:Gx,formatValue:Df,onChange:p,onCommit:o.commands.commit})})]})})},Hx=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"})]}),Go=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"})]}),zo=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],Vx="linear",$x=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=H(),{options:u,findValue:h}=Nt(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:Vx,v=Wx(m),f=zo.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),b=(A,T={})=>{const I=p??m,E=new d.SetStatLineCommand({line:A,...T,...I!==void 0&&{layerId:I.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(E)},C=A=>b(A?"trend":"none",{method:g}),y=A=>b(A?"average":"none",{group:v??h(u[0]?.value??"")}),k=A=>{const T=zo.find(I=>I===A);T!==void 0&&b("trend",{method:T})},w=A=>{const T=A===null?void 0:h(A);T!==void 0&&b("average",{group:T})};return(0,r.jsx)(Q,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Go,{size:"lg"}),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Go,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:C})}),p!==void 0&&(0,r.jsx)(M,{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)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(Hx,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:y})}),m!==void 0&&u.length>0&&(0,r.jsx)(M,{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")})})]})})},Wx=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Gf;exports.AxesPanel=Nf;exports.AxisEditMenu=Rn;exports.AxisSection=gt;exports.BarEditMenu=On;exports.BarSection=$f;exports.Button=Jo;exports.CalloutsSection=nx;exports.CaptionSection=Ss;exports.ChartEditMenu=Fn;exports.ColorRow=ve;exports.ColorSwatches=na;exports.ComboSection=ox;exports.ControlRegistryProvider=fa;exports.ControlTooltip=ye;exports.CustomColor=oa;exports.DateField=aa;exports.EditableGraphRenderer=af;exports.EditorIntlProvider=Vn;exports.EditorPanel=ar;exports.ElementsPanel=_f;exports.FileInput=ia;exports.GoalSection=sx;exports.GraphOptionsSection=cx;exports.GraphTypeSection=ux;exports.GridEditMenu=Bn;exports.GridSection=hx;exports.HeadlineSection=vx;exports.LegendEditMenu=Ba;exports.LegendSection=bx;exports.LineEditMenu=Tt;exports.LineSection=wx;exports.MappingSection=Ax;exports.NumberField=la;exports.NumberFormatSection=Rx;exports.PANEL_ROOT_ATTRIBUTE=vs;exports.PaletteRow=Ra;exports.PointEditMenu=zn;exports.PointSection=_x;exports.PolarSection=zx;exports.RadioGrid=ca;exports.Row=M;exports.Section=Q;exports.Select=ua;exports.Separator=xf;exports.Slider=ha;exports.SourceSection=Cs;exports.Stepper=pa;exports.SubtitleSection=ws;exports.Switch=ma;exports.TextField=ga;exports.TextSizeSection=js;exports.TitleSection=Ts;exports.ToggleGroup=Mn;exports.ToggledSection=xs;exports.TrendsAndAveragesSection=$x;exports.useAnnotateAnchor=qo;exports.useControls=H;exports.usePanelExpansion=gs;exports.usePanelGraph=K;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-Brh9GUjC.cjs");let d=require("@graphysdk/viz-engine"),x=require("react"),r=require("react/jsx-runtime"),Es=require("motion/react"),se=require("zustand/react/shallow"),de=require("lodash-es"),fe=require("@vanilla-extract/dynamic"),ge=require("clsx");ge=c.__toESM(ge,1);let Ne=require("@floating-ui/react-dom"),Pn=require("react-dom"),ce=require("@base-ui/react/tooltip"),te=require("@base-ui/react/popover"),dr=require("react-colorful"),vt=require("@base-ui/react/number-field"),Ho=require("@base-ui/react/radio"),Vo=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),De=require("@base-ui/react/slider"),ur=require("@base-ui/react/switch"),Ms=require("@base-ui/react/input"),Ln=require("@base-ui/react/direction-provider"),$o=require("@tiptap/core"),Rs=require("@tiptap/extension-bold"),ft=require("@tiptap/extension-document"),Os=require("@tiptap/extension-hard-break"),_s=require("@tiptap/extension-heading"),Ns=require("@tiptap/extension-italic"),Ds=require("@tiptap/extension-link"),Fs=require("@tiptap/extension-text"),Bs=require("@tiptap/extension-text-align"),xt=require("@tiptap/extension-text-style"),Gs=require("@tiptap/extension-underline"),It=require("@tiptap/extensions"),Wo=require("@tiptap/extension-paragraph"),we=require("@tiptap/react"),Se=require("@base-ui/react/toolbar"),ae=require("@base-ui/react/menu"),zs=require("@base-ui/react/toggle"),Ge=require("@base-ui/react/accordion"),Hs=require("@base-ui/react/separator");var Uo=(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}},qo=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,x.useMemo)(()=>Uo(e,t),[e,t])},Vs=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"})}),$s=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"})}),Ws=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"})}),Us=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"})}),qs=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"})}),Ks=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"})}),Ue=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"})})}),Ko=(0,x.createContext)(null),Xo=({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)(Ko.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,x.useContext)(Ko),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}}},xe="_18ja6qr0",In=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,x.useMemo)(()=>(0,fe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Yo="srewh00",Xs="srewh01",Ys={pointer:null,focus:null,last:"pointer"},Zo=(0,x.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),an=({className:e,children:t})=>{const[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(!1),[s,l]=(0,x.useState)(Ys),u=(0,x.useCallback)((f,b)=>{i(!1),l(S=>({...S,[b]:f,last:b}))},[]),h=(0,x.useCallback)((f,b)=>{l(S=>S[b]===f?{...S,[b]: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)(Zo.Provider,{value:g,children:t})})},ye=({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)(Zo),g=(0,x.useId)(),[v,f]=(0,x.useState)(!1),b=s?!l&&(u===g||t&&u===null):v;(0,x.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const S=(y,k)=>{k.reason==="escape-key"&&(m(),k.allowPropagation()),f(y)};return(0,r.jsxs)(ce.Tooltip.Root,{open:b,onOpenChange:S,disableHoverablePopup:!0,children:[(0,r.jsx)(ce.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)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{side:n,sideOffset:6,className:Xs,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Yo,children:e})})})})]})},Zs=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Js="woi4bh0",Qs="woi4bh1";var el={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Jo=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:u,pressed:h,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const b=ue({id:f,ariaLabel:g,ariaLabelledBy:v}),S=o==="tile",y=(0,r.jsxs)("button",{type:"button",className:el[o],disabled:i,"aria-expanded":a,"aria-pressed":h,onClick:n,onPointerEnter:p,onPointerLeave:m,...b,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,ge.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:S?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Ue,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(ye,{label:u,side:s,delay:l,nameTrigger:!1,children:y}):o==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ye,{label:g,side:s,delay:l,children:y}):y},hr={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)"},tl="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))",nl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Qo="_14ty2ng0",pr="_14ty2ng1",rl="_14ty2ng2",ol="_14ty2ng3",ea="_14ty2ng4",al="_14ty2ng5",il="_14ty2ng6",bt="transparent",ta=e=>e==="transparent"?{background:tl,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:nl,border:`1px solid ${hr.border}`}:{background:e,border:`1px solid ${hr.border}`},na=({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=ue({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=a!==void 0||i,S=y=>{const k=y==="transparent"?v("graph.colorDropdown.transparent"):y,w=s?.[y],A=(0,r.jsx)("button",{type:"button","aria-label":w??k,className:ol,"data-active":En(y,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>o(y),children:(0,r.jsx)("span",{className:ea,style:ta(y)})},y);return w===void 0?A:(0,r.jsx)(ye,{label:w,side:l,delay:u,children:A},y)};return(0,r.jsxs)("div",{className:Qo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:rl,...f,children:[t.map(S),b&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},En=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),sl="data-graphy-chart-chrome",ll="data-graphy-chart-menu",cl={[ll]:""},Et=e=>({[sl]:e}),He=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,yt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,sn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Ie=(e,t,n)=>e instanceof Node&&(t.contains(e)||He(e,n)),dl="cml7ha0",ra=(0,x.createContext)(null),ul=({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,Pn.createPortal)((0,r.jsx)("div",{ref:a,className:dl,...Et(t)}),n),(0,r.jsx)(ra.Provider,{value:o,children:e})]})},Mt=()=>(0,x.useContext)(ra),hl="_178jeit0",pl="_178jeit1 _14ty2ng3",ml="_178jeit2 _14ty2ng4",gl="_178jeit3",vl="_178jeit4",fl="_178jeit5",xl="_178jeit6",bl="_178jeit7",yl={side:"flip",align:"shift",fallbackAxisSide:"end"},oa=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=Mt(),[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)(te.Popover.Root,{open:l,onOpenChange:h,children:[a==="chip"?(0,r.jsx)(te.Popover.Trigger,{className:pl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:ml})}):(0,r.jsxs)("div",{className:Qo,children:[(0,r.jsx)("div",{className:pr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(te.Popover.Trigger,{className:gl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:ea,style:ta(p)}),(0,r.jsx)("span",{className:vl,children:m})]})]}),(0,r.jsx)(te.Popover.Portal,{container:s??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:yl,collisionPadding:12,disableAnchorTracking:a==="chip",className:hl,children:(0,r.jsxs)(te.Popover.Popup,{className:fl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:pr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(dr.HexColorPicker,{color:m,onChange:t,className:xl}),(0,r.jsx)(dr.HexColorInput,{color:m,onChange:t,prefixed:!0,className:bl,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Rt=(0,x.createContext)(null),K=()=>{const e=(0,x.useContext)(Rt);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},Ot=({children:e,onKeyDown:t,...n})=>{const o=(0,x.useContext)(Rt),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})},Sl="_6fidqf0 uz3g760",Cl="_6fidqf1 uz3g761",aa=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),u=h=>{const p=jl(h.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Ot,{className:Sl,children:(0,r.jsx)("input",{type:"date",className:Cl,value:wl(e),onChange:u,onBlur:n,disabled:o,...l})})},wl=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},jl=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},mr=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"})]})}),Tl="a1l6m80 woi4bh6 woi4bh5",Al="a1l6m81 _14ty2ng3",kl="a1l6m82",ia=({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:kl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(ye,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:Al,children:[(0,r.jsx)(mr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:Tl,children:[(0,r.jsx)("span",{className:Js,children:(0,r.jsx)(mr,{})}),(0,r.jsx)("span",{className:Qs,children:e}),h]})},sa="keyboard",_t=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()}}}},Pl="eh8dvc0",Ll="eh8dvc1 uz3g760",Il="eh8dvc2 uz3g761";var la=({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=ue({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:S}=_t(n);return(0,r.jsx)(vt.NumberField.Root,{className:Pl,value:e,onValueChange:y=>t(y),onValueCommitted:(y,k)=>{b(k.reason===sa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsxs)(Ot,{className:Ll,"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)(vt.NumberField.Input,{className:Il,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},El="_1b7s5f0",Te={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Ml="_1b7s5f7";var Rl=6,ca=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",b=i==="chip",{commitAfterChange:S,gestureHandlers:y}=_t(o);return(0,r.jsx)(Vo.RadioGroup,{className:(0,ge.default)(El,Ol(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:k=>{n(k),S()},...y,disabled:s,...p,children:e.map(k=>{const w=(0,r.jsxs)(Ho.Radio.Root,{value:k.value,disabled:k.disabled,className:(0,ge.default)(Ml,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",b&&"_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&&!b)return w;const A=(v||b)&&k.value===t;return(0,r.jsx)(ye,{label:k.label,checked:A,children:w},k.value)})})},Ol=e=>{switch(Math.min(Math.max(Math.round(e),1),Rl)){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]}},da=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"})})}),_l="_1g5x15w0 uz3g760",Nl="_1g5x15w1",Dl="_1g5x15w2",gr="_1g5x15w3",Fl="_1g5x15w4",Bl="_1g5x15w5",Gl="_1g5x15w6",zl="_1g5x15w7";var ua=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l}),p=Mt();return(0,r.jsxs)(pe.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)(pe.Select.Trigger,{className:_l,"data-error":i===!0,...h,children:[(0,r.jsx)(pe.Select.Value,{className:Nl,children:m=>Hl(e,m,o)}),(0,r.jsx)(pe.Select.Icon,{className:gr,children:(0,r.jsx)(Ue,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:Fl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:Bl,children:e.map(m=>(0,r.jsxs)(pe.Select.Item,{value:m.value,disabled:m.disabled,className:Gl,children:[m.icon,(0,r.jsxs)("span",{className:zl,children:[(0,r.jsx)(pe.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:gr,children:(0,r.jsx)(da,{size:"sm"})})]},m.value))})})})})]})},Hl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Dl,children:n}):Vl(e,t),Vl=(e,t)=>e.find(n=>n.value===t)?.label??t,$l="vod76w0",Wl="vod76w1",Ul="vod76w2",ql="vod76w3",Kl="vod76w4",Xl="vod76w5";var ha=({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=ue({ariaLabel:p,ariaLabelledBy:m},!1),v=Yl(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:b}=_t(n);return(0,r.jsxs)("div",{className:$l,children:[(0,r.jsx)(De.Slider.Root,{className:Wl,value:e,onValueChange:S=>t(S),onValueCommitted:(S,y)=>{f(y.reason===sa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsx)(De.Slider.Control,{className:Ul,children:(0,r.jsxs)(De.Slider.Track,{className:ql,children:[(0,r.jsx)(De.Slider.Indicator,{className:Kl}),(0,r.jsx)(De.Slider.Thumb,{className:Xl,...b,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Yl=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Zl=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 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),Jl="cnu9yl0",Ql="_1n6f4bd0 cnu9yl1",ec="_1n6f4bd1",tc="_1n6f4bd2",nc="_1n6f4bd3 uz3g761";var rc=1e-9,pa=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:u,ariaLabelledBy:h,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=oc(e),b=ue({id:p,ariaLabel:u,ariaLabelledBy:h}),S=c.useI18n(),y=i??S("editor.accessibility.decrease"),k=s??S("editor.accessibility.increase"),[w,A]=(0,x.useState)(t),[T,I]=(0,x.useState)(t);t!==T&&(I(t),A(t));const E=t===null?void 0:f(t),L=t===null?void 0:v(t),B=P=>{P!==void 0&&(A(P),n(P))},F=P=>{const j=P===null?null:Math.min(Math.max(P,m),g);if(j!==null&&j!==t){n(j);return}A(t)},O=P=>{P.blur(),P.focus()};return(0,r.jsxs)("div",{className:Jl,children:[(0,r.jsx)(vr,{label:y,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||E===void 0,onPress:()=>B(E)}),(0,r.jsx)(vt.NumberField.Root,{className:ec,value:w,onValueChange:A,onValueCommitted:F,min:m,max:g,disabled:l,readOnly:!a,children:(0,r.jsxs)(Ot,{className:tc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(vt.NumberField.Input,{className:nc,onKeyDown:P=>{const j=P.currentTarget;if(P.key==="Enter"){O(j);return}if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventBaseUIHandler(),P.preventDefault(),P.repeat))return;const C=w??t;C!==null&&(O(j),B(P.key==="ArrowUp"?v(C):f(C)))},...b}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(vr,{label:k,icon:(0,r.jsx)(Zl,{}),disabled:l===!0||L===void 0,onPress:()=>B(L)})]})},vr=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ye,{label:e,children:(0,r.jsx)("button",{type:"button",className:Ql,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),oc=e=>{if(e.stops!==void 0){const{stops:l}=e,u=l[0],h=l.at(-1);if(u===void 0||h===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:u,max:h,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:o}=e;if(!(t>0))return{min:n,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(fr(t),fr(n)),i=l=>Math.min(Math.max(Number(l.toFixed(a)),n),o),s=(l,u)=>{const h=(l-n)/t,p=Math.round(h);return Math.abs(h-p)<rc?p:u(h)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},fr=e=>String(e).split(".")[1]?.length??0,ac="_1hyrlw60",ic="_1hyrlw61",ma=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(ur.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:ac,...s,children:(0,r.jsx)(ur.Switch.Thumb,{className:ic})})},sc="uz3g761",lc="tpcnun0 uz3g760",ga=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Ot,{className:lc,"data-error":i===!0,children:(0,r.jsx)(Ms.Input,{className:sc,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},cc="cnu9yl0",dc="cnu9yl1";var Mn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=_t(o);return(0,r.jsx)(Vo.RadioGroup,{className:cc,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const b=uc(f,m),S=(0,r.jsxs)(Ho.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,ge.default)(dc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[f.icon,va(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return b===void 0?S:(0,r.jsx)(ye,{label:b,checked:f.value===t,children:S},f.value)})})},va=(e,t)=>e.icon===void 0||t,uc=(e,t)=>{if(!va(e,t))return e.label},hc={ToggleGroup:Mn,Switch:ma,Slider:ha,RadioGrid:ca,Button:Jo,TextField:ga,NumberField:la,Stepper:pa,Select:ua,ColorSwatches:na,CustomColor:oa,DateField:aa,FileInput:ia},ln=(0,x.createContext)(hc),fa=({controls:e,children:t})=>{const n=(0,x.useContext)(ln),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,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,r.jsx)(ln.Provider,{value:o,children:t})},H=()=>(0,x.useContext)(ln),xr={stack:"pr583x0",grid:"pr583x1"},br="pr583x2",pc={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},M=({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)(an,{className:xr[t],children:(0,r.jsx)("div",{className:br,children:o})}):(0,r.jsxs)(an,{className:xr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:pc[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:br,children:(0,r.jsx)(Xo,{labelId:a,controlId:i,children:o})})]})},Rn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(mc,{graph:t,axis:e.axis})};Rn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var mc=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=H(),l=n?.guides.axes.find(L=>L.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(L=>L.position==="left"||L.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,b=f?.scaleType==="continuous"?f:void 0,S=b!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),y=b?.transform==="log"?"log":"linear",k=S&&b.transform!=="log",w=b?.domainMin??null,A=b!==void 0&&(l.position==="left"||l.position==="right")&&b.transform!=="log",T=b?.domainMax??null,I=n.config.axes[t]?.label??l.label??"",E=L=>{const B=t==="ySecondary"?{axis:t,label:L}:{axis:t,label:L};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:I,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:E,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(M,{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)(Ks,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(qs,{})}],onChange:L=>{const B=L==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(M,{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)(Vs,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)($s,{})}],onChange:L=>{if(L!=="left"&&L!=="right")return;const B=t==="y"?L:L==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),S&&(0,r.jsx)(M,{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)(Ws,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Us,{})}],onChange:L=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:L==="log"?"log":"linear"}))}})}),k&&(0,r.jsx)(M,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:w,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:L}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,r.jsx)(M,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:L}),{transient:!0})},onCommit:e.commands.commit})})]})},gc={narrow:3,regular:6,wide:11},vc=({barWidth:e,...t})=>{const n=gc[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"})})},fc=6,ve=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=ba(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)(xa,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},xa=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=H();return(0,r.jsx)(M,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:xc(t.slice(0,fc),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ve.hasRows=(e,{scene:t,findGeom:n})=>ba(e,t,n)!==null;var ba=(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)},xc=(e,t)=>t===null||e.some(n=>En(n,t))?e:[...e,t],Wt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],On=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=H(),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=Wt.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=Wt.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(vc,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Wt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:e}),s!==null&&!l?(0,r.jsx)(M,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:h,onChange:u})}):null]})};On.hasRows=ve.hasRows;var bc={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},yc=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:bc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Sc={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Cc=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Sc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),yr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ya=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||wc(e))return yr;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}},wc=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},Sa=(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 cn=["gap","zero","connect"],_n=(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=jc(o,e.spec.layers),g=a?[]:Ac(o),v=g.length>1,f=o.geom==="line"&&!a,b=f?Pc(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&Tc(e,t,m.id),pointLayerId:m?.id??null,showFill:f?b>0:null,drawnFillAlpha:b,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??kc(e,t,o)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},jc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),Tc=(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},Ac=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},kc=(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")},Pc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Lc=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"})]}),Ic=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"})]})]}),Ca=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"})]})]})}),Ec=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"})]}),Mc=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"})]})}),Rc=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"})]})}),Oc=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"})]})}),_c=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"})]}),Nc=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"})]}),Dc=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"})]}),Fc=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"})]})]}),Bc=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"})]})}),Gc=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"})]})}),zc=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"})]}),Hc=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"})]})}),Vc=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"})]}),$c=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"})}),Uc=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"})]})}),qc=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"})]})}),Kc=.55,Xc=.15,Ve=[{name:"column",icon:_c,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Dc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Nc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Mc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Oc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Rc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Ca,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:Ec,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Fc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:qc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:zc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Bc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Kc}},{name:"radialBar",icon:$c,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Xc}},{name:"rose",icon:Wc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:Uc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Hc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Vc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Gc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Yc=.05,wa=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,St=e=>e===null?null:Ve.find(t=>Zc(t.summary,e))??null,ja=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&Ta(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Ct(e.innerRadius)||t.coordType!=="polar"||!Ct(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},Ta=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Zc=(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"&&Ta(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Ct(e.innerRadius)===Ct(t.innerRadius)},Ct=e=>e>=Yc;var Jc="_1a90obs1",Qc=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Lc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Ic},{summary:{coordType:"cartesian",comboType:"lines"},icon:Ca}],ed=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],td=4,nd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},rd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},od=()=>{const e=c.useSceneSelector(I=>I.spec),t=c.useSceneSelector(({layers:I})=>I.some(E=>(0,d.hasMultipleGroups)(E.data,E.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=H(),[s,l]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!s)return;const I=({target:E,detail:L})=>{L>0&&id(E)&&u.current?.contains(E)&&l(!1)};return document.addEventListener("click",I),()=>document.removeEventListener("click",I)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=sd(h),m=wt(h),g=St(h),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),b=(p===void 0?g:Cr(p,m))?.icon,S=p!==void 0&&p.arrangements.length>1,y=S&&(t||p.name==="combo"),k=()=>l(!s),w=({summary:I})=>{n.dispatch(new d.SetGraphTypeCommand(ja(I,h)),{transient:!0})},A=I=>{const E=Sr.find(L=>L.name===I);E!==void 0&&w(Cr(E,S?m:null))},T=Sr.map(({name:I,arrangements:[E]})=>({value:I,label:o(`editor.graphTypes.${I}`),icon:(0,r.jsx)(E.icon,{size:"md"}),disabled:!wa(E.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:o("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:k}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:f,expanded:s,onClick:k})}),s&&(0,r.jsx)(M,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:A,onCommit:n.commit,columns:td,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),y&&(0,r.jsx)(ad,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},Aa=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?St(e)===St(t):e.coordType===t.coordType&&e.geom===t.geom,ka=ed.flatMap(([e,t])=>{const n=Ve.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ve,...Qc].filter(o=>o!==n&&Aa(n.summary,o.summary))]}]}),Sr=ka.filter(({name:e})=>e!=="combo"),ad=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=H(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=wt(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})=>wt(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(M,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Jc,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},id=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,wt=e=>(0,d.isComboGraphType)(e)?rd[e.comboType]:nd[e.position],Cr=(e,t)=>e.arrangements.find(({summary:n})=>wt(n)===t)??e.arrangements[0],sd=e=>ka.find(({arrangements:[t]})=>Aa(t.summary,e)),ld=()=>{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)(xa,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},Pa=({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})]})]}),La=({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})}),cd={small:2,medium:3.8,large:5.6},dd=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:cd[e],fill:"currentColor"})});var ud=({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})`})})},hd="_1yjsaqt0",pd="_1yjsaqt1",md="_1yjsaqt2",gd="_1yjsaqt3";var Ux=512*1024,vd=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)}),wr=["solid","dashed","dotted"],Ut=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],qt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],fd=["circle","square","diamond","triangle","cross","star"],Ia=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=Ut.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:Ut.find(i=>i.widthPx===e)?.name??"",options:Ut.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(La,{lineWidth:s})})),onChange:a})})},Ea=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=wr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(M,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:wr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Pa,{lineStyle:i})})),onChange:a})})},Nn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=H(),[i,s]=(0,x.useState)(null),l=(0,x.useContext)(Rt),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:I})=>[T,I])):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),f=T=>!(0,d.isGeometricSymbol)(T)||fd.some(I=>I===T),b=[...m.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!g(T)),S=[...p.filter(f),...b],y=e===null?"":tt(e),k=e===null||S.some(T=>tt(T)===y)||!v(e)?S:[...S,e],w=T=>(0,d.isGeometricSymbol)(T)?o(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,d.isImageSymbol)(T)?o("editor.graphPanel.pointSymbol.custom"):T,A=T=>{s(null);const I=k.find(E=>tt(E)===T);I!==void 0&&n(I)};return(0,r.jsx)(M,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:hd,children:[(0,r.jsxs)("div",{className:pd,children:[(0,r.jsx)(a,{itemLayout:"chip",value:y,options:k.map(T=>({value:tt(T),label:w(T),icon:(0,r.jsx)(bd,{symbol:T,glyphs:m})})),onChange:A}),(0,r.jsxs)("span",{className:al,children:[(0,r.jsx)("span",{className:il,"aria-hidden":"true"}),(0,r.jsx)(xd,{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}`)})]})})},Dn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=H(),a=i=>{const s=qt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:qt.find(i=>i.sizePx===e)?.name??"",options:qt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(dd,{pointSize:i})})),onChange:a})})},xd=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=H(),a=i=>{vd(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})},bd=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(ud,{symbol:e});const n=yd(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:gd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:md,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"})})},tt=e=>typeof e=="string"?e:e.image,yd=(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},Ma=(0,x.createContext)({}),Sd=Ma.Provider,Cd=()=>(0,x.useContext)(Ma),wd="_1qh3fon0",dn="theme",jd=3,nt=14,jr=9,Ra=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=Cd(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=H();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:dn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Tr,{colors:i})},...l.map(([p,m])=>({value:un(p),label:p,icon:(0,r.jsx)(Tr,{colors:m})}))],h=p=>{const m=l.find(([v])=>un(v)===p);if(p!==dn&&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)(M,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:u,value:Td(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},un=e=>`preset:${e}`,Td=(e,t)=>{if(e===null)return dn;const n=t.find(([,o])=>(0,de.isEqual)(o,e));return n===void 0?"":un(n[0])},Tr=({colors:e})=>{const t=e.slice(0,jd),n=nt/2,o=nt+(t.length-1)*jr;return(0,r.jsx)("svg",{width:o,height:nt,viewBox:`0 0 ${o} ${nt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:wd,cx:n+i*jr,cy:n,r:n-.5,fill:a},i)).reverse()})},Ar=["smooth","linear"],kr=["auto","inside","outside"],Fn=()=>{const e=c.useSceneSelector(C=>C),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=H(),l=Oa(e.layers,e.coordSystem.type,n),u=C=>l.filter(({support:R})=>C(R)).map(({layer:R})=>R),h=Ad(e,t),p=h.filter(C=>C.smooth!==null),m=h.filter(C=>C.missingValues!==null&&C.missingValueOptions.length>1),g=cn.filter(C=>m.some(R=>R.missingValueOptions.includes(C))),v=Id(p),f=Ed(m),b=C=>{o.dispatch(new d.SequenceCommand({commands:h.map(R=>new d.ToggleLinePointsCommand({layerId:R.layerId,showPoints:C}))}))},S=C=>{const R=Ar.find(G=>G===C);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:p.map(G=>new d.SetLineCurveCommand({layerId:G.layerId,curve:R}))}))},y=u(C=>C.supportsPosition),k=rt(y.map(C=>C.dataLabels.position))??"",w=C=>{const R=kr.find(G=>G===C);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:y.map(G=>new d.SetDataLabelsCommand({layerId:G.id,position:R}))}))},A=C=>{const R=cn.find(N=>N===C);if(R===void 0)return;const G=m.filter(N=>N.missingValueOptions.includes(R)).map(N=>new d.SetLineMissingValuesCommand({layerId:N.layerId,missingValues:R}));G.length!==0&&o.dispatch(new d.SequenceCommand({commands:G}))},T=h.filter(C=>C.showFill!==null),I=h.filter(C=>C.showPoints),E=kd(e,t,h),L=T.some(C=>Pd(e,C)),B=C=>{C.length>0&&o.dispatch(new d.SequenceCommand({commands:C}))},F=C=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,strokeWidth:C})))},O=C=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,lineStyle:C})))},P=C=>{B(T.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,showFill:C,drawnFillAlpha:R.drawnFillAlpha})))},j=C=>{B(I.flatMap(({pointLayerId:R})=>R===null?[]:[new d.SetPointSizeCommand({layerId:R,size:C})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(od,{}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(C=>C.supportsDataLabels),isOn:C=>C.showDataLabels,buildCommand:(C,R)=>new d.ToggleDataLabelsCommand({layerId:C,showDataLabels:R})}),y.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:k,options:kr.map(C=>({value:C,label:a(`editor.graphPanel.graphOptions.labelPositions.${C}`)})),onChange:w})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(C=>C.supportsPercentages),isOn:C=>C.format==="percentage",buildCommand:(C,R)=>new d.SetDataLabelsFormatCommand({layerId:C,format:R?"percentage":"absolute"})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(C=>C.supportsStackTotals),isOn:C=>C.showStackTotals,buildCommand:(C,R)=>new d.ToggleStackTotalsCommand({layerId:C,showStackTotals:R})}),(0,r.jsx)(ot,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(C=>C.supportsCategoryLabels),isOn:C=>C.showCategoryLabels,buildCommand:(C,R)=>new d.ToggleCategoryLabelsCommand({layerId:C,showCategoryLabels:R})}),(0,r.jsx)(M,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:C=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:C}))})}),(0,r.jsx)(M,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:C=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:C}))})}),(0,r.jsx)(M,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:C=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:C}))})}),p.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Ar.map(C=>({value:C,label:a(`editor.graphPanel.graphOptions.curves.${C}`),icon:(0,r.jsx)(yc,{curve:C})})),onChange:S})}),g.length>1&&(0,r.jsx)(M,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(C=>({value:C,label:Sa(a,C),icon:(0,r.jsx)(Cc,{missingValues:C})})),onChange:A})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ia,{widthPx:rt(E.map(C=>C.strokeWidth)),onChange:F}),(0,r.jsx)(Ea,{lineStyle:rt(E.map(C=>C.lineStyle)),onChange:O})]}),T.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:L,onChange:P})}),h.length>0&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:I.length>0,onChange:b})}),I.length>0&&(0,r.jsx)(Dn,{sizePx:rt(Ld(e,t,I)),onChange:j}),(0,r.jsx)(Ra,{}),(0,r.jsx)(ld,{})]})};Fn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||Oa(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 Oa=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:ya(o,t,n)})),Ad=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=_n(e,t,o.id);a!==null&&n.push(a)}return n},kd=(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))}))}),Pd=(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)},Ld=(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)}),rt=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},Id=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",Ed=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},ot=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=H();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)(M,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Md=(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}},at=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},Rd=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Pr(Lr(s.layers,e)?.[t]?.[n],a),u=l!==void 0?l:Pr(Lr(s.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},Od=e=>typeof e=="object"&&("style"in e||"annotate"in e),Pr=(e,t)=>e==null?e:Od(e)?e[t]:t==="style"?e:void 0,Lr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,jt=["solid","dashed","dotted"];var _a=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Na=(e,t)=>{const n=e.guides.axes.filter(_a);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}},_d=(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},Da=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),Fa=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Kt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Bn=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=Na(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=H();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=_d(e.axis,o),m=jt.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(Pa,{lineStyle:S})})),g=Kt.map(({name:S,widthPx:y})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(La,{lineWidth:y})})),v=Kt.find(({widthPx:S})=>S===u.strokeWidth)?.name??"",f=S=>{const y=jt.find(k=>k===S);y!==void 0&&i.dispatch(Da(y,e.axis))},b=S=>{const y=Kt.find(({name:k})=>k===S);y!==void 0&&i.dispatch(Fa(y.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:f,disabled:p})}),(0,r.jsx)(M,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:b,disabled:p})})]})};Bn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(_a);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var Ir=[{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}],Nd={start:"Start",center:"Center",end:"End"},Ba=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=H(),a=e===void 0,i=a?"":Xt(e),s=Ir.map(u=>{const h=Xt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Fd(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:Dd(e,u)}}),l=u=>{const h=Ir.find(p=>Xt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(M,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Ln.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})})})})},Xt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Nd[t]}`,Dd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Fd=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ga=(e,t,n,o)=>{const a=Ha(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},za=(e,t,n,o)=>{const a=Ha(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"},Ha=(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)),Tt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Bd,{graph:t,target:e})};Tt.hasRows=(e,{scene:t})=>e.scope==="group"&&Va(t,e.layerId)!==null;var Bd=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=H(),s=n===null?null:Va(n,t.layerId),l=n===null||s===null?null:_n(n,o,s.id);if(n===null||s===null||l===null)return null;const u=Vd(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:Hd(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:Gd(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??zd(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:Ga(n,o,l.pointLayerId,u),b=l.pointLayerId===null?null:za(n,o,l.pointLayerId,u),S=f!==null&&f>0,y=L=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:L,...h}))},k=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:L,drawnFillAlpha:l.drawnFillAlpha,...h}))},w=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:L,...h}))},A=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:L,...h}))},T=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:L,...h}))},I=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:L,...h}))},E=(0,d.readObservationsColorRoute)(n.spec,t)?.some(L=>L.geomKind==="line"||L.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),(0,r.jsx)(Ia,{widthPx:v,onChange:w}),E&&(0,r.jsx)(Ea,{lineStyle:$d(n,o,t),onChange:I}),l.showFill!==null&&(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:k})}),(0,r.jsx)(M,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:y})}),S&&(0,r.jsx)(Dn,{sizePx:f,onChange:A}),S&&(0,r.jsx)(Nn,{symbol:b,coordType:n.coordSystem.type,onChange:T})]})},Gd=(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},zd=(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},Hd=(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},Vd=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,$d=(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))},Va=(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"})]}),Wd="_1aafi1g0",Ud="_1aafi1g1",Er=({children:e})=>(0,r.jsxs)("span",{className:Wd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:Ud})]}),Yt=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"})}),Mr=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"})]}),Wa=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"})]}),Ua=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"})]}),qd=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},qa=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ka=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Kd=()=>[{scope:"group",labelKey:"pieSlice"}];function Xd(e,t){if(e.type==="polar"&&!Yd(t))return Kd();switch(t.geom){case"bar":return qd(t);case"line":case"area":return qa(t);case"point":return Ka(t);default:return[]}}var Yd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Zd=(e,t,n,o)=>{const a=[],i=Jd(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Qd(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},Xa=(e,t,n)=>{const o=t.find(a=>At(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&At(e.predicate,n)?"observation":null},Jd=(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=Ya(t,a);return s===null||!ru(e,a,s)?null:{variable:a,value:s,label:Za(e,a,s,n,o)}},Qd=(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=eu(e,t);if(s===null)return null;const l=tu(e,a,s),u=l.findIndex(m=>$e(m)===$e(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:Za(e,a,i,n,o),predicate:p}},eu=(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},tu=(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||!nu(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=$e(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)},nu=(e,t)=>t.every(n=>$e(e[n.variable]??null)===$e(n.eq)),ru=(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=Ya(a,t);if(i!==null&&i>n)return!0}return!1},Ya=(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},Za=(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)},$e=e=>e instanceof Date?String(e.getTime()):String(e),At=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Rr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Rr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&At(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Pe(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&Or(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Pe(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Pe(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Pe(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Pe(e.gte,t.gte):"range"in e&&"range"in t&&Or(e.range,t.range),Rr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&At(n,a)}),Or=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Pe(n,a)}),Pe=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,ou=(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])},au={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},iu=e=>(0,d.isObservationAttachmentKind)(e.kind)&&au[e.kind],Nt=(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]),Ja=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=pn(e,t,n,o);return{observation:i(cu(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Qa(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},hn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=Qa(e,t,n,a);switch(s){case"observation":{const h=l.length===0?null:pn(e,t,n,o),p=su(h,u,i);return{whole:p,value:p}}case"xValue":return _r((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=pn(e,t,n,o)??i("editor.overlayMenu.all");return _r(lu(e,l),h,i)}default:return s}},su=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),_r=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),lu=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},cu=(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"}},Qa=(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)},pn=(e,t,n,o)=>{const a=(0,d.getGroupVariables)(t.data,t.mapping);return a.length===0?du(t,n)??uu(e,t):a.map(i=>hu(n[i]??null,o)).join(", ")},du=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},uu=(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},hu=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},pu="vez73g0",mn="vez73g1",mu="vez73g2",gu="vez73g3",vu="vez73g4";var fu="vez73g6",xu="vez73g7",bu="vez73g8",yu="vez73g9",Su="vez73ga",ei=[mu,fu,vu,gu],Cu=ei.map(e=>`.${e}`).join(", "),wu=ei.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),ti=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${mn}, ${Cu}`),a=t.closest(`.${mn}`)!==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(wu);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Ce={side:"top",delay:200},ni={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Wa},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:$a},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Ua}},ri=new Set(["barSeries","lineSeries","scatterSeries"]),ju=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Gn=e=>{const t=({target:n})=>{const o=qo(n);return o===null?null:(0,r.jsx)(Au,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>Uo(n,o)!==null,t},ht=Gn((e,t)=>Xd(t,e)),Nr=Gn(qa),Tu=Gn(Ka),Au=({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}=H(),f=c.useSceneSelector(z=>z),b=f.spec.annotations,S=f.config.parsingLocale,y=f.config.numberFormat,k=c.useFormattingLocale(),w={scene:f,layer:n,observation:o,groupOptions:Nt(f,k),locale:k,t:i},A=hn(w,"xValue").value,T=hn(w,"group").value,I=Ja(w).observation,E=(0,x.useMemo)(()=>(0,d.createObservationAnchorParser)(n,S),[n,S]),L=(0,d.findObservationAttachment)(b,a,E,(0,x.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:f.layers,coordSystem:f.coordSystem,findGeom:p,readAnchor:E}),[f.layers,f.coordSystem,p,E])),B=L!==null&&iu(L)?L:null,F=m.current,O=B!==null&&F?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,P=O?.kind==="comment"?O.annotation.content:null,j=P===null?"":Gu(P)??void 0,[C,R]=(0,x.useState)(()=>Fu(B?.kind)),G=ou(n,o),N=f.coordSystem,Y=t(n,N),Z=Y.length===0?[]:Zd(n,o,k,y),D=m.current?.heldHighlight,$=D===void 0?G:[...G,D],W=(0,x.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:N}),[n,a,N]),X=Ou({layer:n,observation:o,highlights:$,highlightOptions:Y,reaches:Z,previewedChoiceId:m.current?.choiceId,scopeLabel:z=>Nu(i,z,A,T,I),scopeDescription:z=>Du(i,z,Dr(i,n,Y),A,T,Y.some(J=>ri.has(J.labelKey))),atLeastLabel:z=>i("graph.annotations.highlights.atLeast",{value:z}),atLeastDescription:z=>i("graph.annotations.highlights.atLeastDescription",{noun:Dr(i,n,Y),value:z}),onwardLabel:z=>i("graph.annotations.highlights.onward",{label:z}),onwardDescription:z=>i("graph.annotations.highlights.onwardDescription",{label:z})}),be=(0,d.buildObservationPredicate)(n,o),Oe=new Set(X?.available.map(z=>z.id)??[]),U=G.filter(z=>{const J=Xa(z,Z,be);return J===null||!Oe.has(J)}).at(-1),q=()=>{m.current!==null&&(m.current=null,g.current())};(0,x.useEffect)(()=>()=>q(),[]);const le=(z,J,he,_)=>{m.current?.key!==z&&(q(),m.current={key:z,choiceId:he,heldHighlight:_},l(J)||(m.current=null))},ie=z=>{q(),s(z),h.getState().clearSelection()},_e=(z,J)=>{if(m.current?.key===z){m.current=null,g.current(),s(J),h.getState().clearSelection();return}ie(J)},$t=(z,J,he,_)=>({onPointerEnter:()=>le(z,J,he,_),onPointerLeave:q,onClick:()=>_e(z,J)}),je=z=>{q(),R(J=>J===z?null:z)},Qe=z=>{if(W===null)return;q();const J=(0,d.areAnchorsEqual)(W.start,a)?W.end:W.start,he=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:a,end:J,label:z}});s(he),h.getState().setSelection([{kind:"annotation",id:he.params.annotation.id}])};return(0,r.jsxs)("div",{className:pu,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:z=>{if(O!==null&&Bu(z)){ie(new d.RemoveAnnotationCommand({id:O.annotation.id}));return}ti(z)},children:[(0,r.jsxs)("div",{className:mn,children:[X!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Mr,{}),expanded:C==="highlight",onClick:()=>je("highlight")}),U!==void 0&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Er,{children:(0,r.jsx)(Mr,{})}),onClick:()=>ie(new d.RemoveHighlightCommand({id:U.id}))}),O!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i(ni[O.kind].phrase),icon:(0,r.jsx)(Er,{children:ku(O.kind)}),onClick:()=>ie(new d.RemoveAnnotationCommand({id:O.annotation.id}))}),O===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Wa,{}),onClick:()=>ie(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)($a,{}),expanded:C==="comment",onClick:()=>je("comment")})]}),W!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Yt,{}),expanded:C==="difference",onClick:()=>je("difference")}),O===null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Ua,{}),expanded:C==="sticker",onClick:()=>je("sticker")})]}),C==="comment"&&j!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(Pu,{at:a,onRun:ie,annotationId:O?.kind==="comment"?O.annotation.id:void 0,initialText:j})}),C==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Lu,{at:a,showPreview:le,dropPreview:q,keepPreview:_e,annotationId:O?.kind==="sticker"?O.annotation.id:void 0})}),C==="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)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Qe("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Qe("absoluteDifference")})]}),C==="highlight"&&X!==null&&(0,r.jsx)("div",{className:"vez73g3",children:X.available.map(z=>{const J=z.appliedHighlightId,he=J===void 0?Mu(z,n.id):new d.RemoveHighlightCommand({id:J}),_=J===void 0?void 0:$.find(re=>re.id===J);return(0,r.jsx)(v,{label:z.label,pressed:J!==void 0,tooltip:z.description===z.label?void 0:z.description,...Ce,...$t(Iu(z.id),he,J===void 0?z.id:void 0,_)},z.id)})})]})},ku=e=>{const t=ni[e].Icon;return(0,r.jsx)(t,{})},Pu=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=H(),[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=zu(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:xu,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:bu,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})]})},Lu=({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=Ru(e,i,a);return(0,r.jsx)("button",{type:"button",className:Su,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>o(l.key,l.command),children:(0,r.jsx)("img",{className:yu,src:s.src,alt:""})},i)})}),Iu=e=>`highlight:${e}`,Eu=e=>`sticker:${e}`,Mu=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Ru=(e,t,n)=>n===void 0?{key:Eu(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}})},Ou=({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 Map;for(const w of n){const A=Xa(w,a,g);A===null||A===i||v.set(A,w.id)}const f=g===null?[]:o.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,appliedHighlightId:v.get(w.scope)}}),b=a.map(w=>({..._u(w,u,h,p,m),appliedHighlightId:v.get(w.id)})),[S,...y]=f,k=S===void 0?b:[S,...b,...y];return k.length===0?null:{available:k}},_u=(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}},Nu=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(ju.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!ri.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Dr=(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}`)},Du=(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}},Fu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Bu=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)},Gu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Fr(t)||Br(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Fr(n)||Br(n)?null:n.text},Fr=e=>e.marks!==void 0&&e.marks.length>0,Br=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,zu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),zn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Hu,{graph:t,target:e})};zn.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ve.hasRows(e,t);var Hu=({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)(ve,{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)(ve,{target:t}),!l&&(0,r.jsx)(Dn,{sizePx:Ga(n,o,a.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:a.id,size:u,...s}))}}),(0,r.jsx)(Nn,{symbol:za(n,o,a.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:a.id,symbol:u,...s}))}})]})},oi={geoms:{point:{style:zn,annotate:Tu},line:{style:Tt,annotate:Nr},area:{style:Tt,annotate:Nr},bar:{style:On,annotate:ht},rule:{style:null,annotate:ht},tile:{style:ve,annotate:ht}},legend:Ba,axis:Rn,grid:Bn,graph:Fn},Hn=(0,x.createContext)([oi]),Vu=({editMenus:e,children:t})=>{const n=(0,x.useMemo)(()=>[e??{},oi],[e]);return(0,r.jsx)(Hn.Provider,{value:n,children:t})},$u=e=>{const t=(0,x.useContext)(Hn),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=ai(c.useGraphMode());return(0,x.useMemo)(()=>e===null?null:ii(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Wu=()=>{const e=(0,x.useContext)(Hn),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=ai(c.useGraphMode());return(0,x.useCallback)(i=>ii(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},ai=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",ii=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=Md(e.layerId,n.scene),i=a===null?null:Rd(a,t,o,o==="annotate"?ht:ve);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=at(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=at(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=at(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=at(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Uu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},qu={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}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Ku={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})`}}}},Xu={common:Uu,editor:qu,graph:Ku},Yu={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"}},Zu={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`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Ju={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})`}}}},Qu={common:Yu,editor:Zu,graph:Ju},eh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},th={editor:eh},nh={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"}},rh={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}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},oh={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})`}}}},ah={common:nh,editor:rh,graph:oh},ih={"en-GB":Qu,"en-US":th,ar:Xu,"pt-PT":ah},sh=[ih,c.dictionaries],Vn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:sh,...t,children:(0,r.jsx)(lh,{children:e})}),lh=({children:e})=>(0,r.jsx)(Ln.DirectionProvider,{direction:c.useTextDirection(),children:e}),ch="data-variant",si=Wo.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[ch]:e.variant}:{}}}}}),dh=$o.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}}}}),$n=()=>[Fs.Text,It.UndoRedo,_s.Heading.configure({levels:[1,2,3]}),Rs.Bold,Ns.Italic,Gs.Underline,Bs.TextAlign.configure({types:["heading","paragraph"]}),Ds.Link.configure({openOnClick:!1,autolink:!0}),xt.TextStyle,xt.Color,Os.HardBreak],uh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[ph({showTitle:n,showSubtitle:o}),si,...$n(),xt.FontFamily,dh.configure({showTitle:n}),It.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:""}})],hh=({placeholder:e})=>[ft.Document,si,...$n(),xt.FontFamily,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],ph=({showTitle:e,showSubtitle:t})=>e&&t?ft.Document.extend({content:"block{2,}"}):ft.Document,li=()=>{const e=c.useI18n();return(0,x.useMemo)(()=>({...Object.fromEntries(di.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ci=()=>{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])},mh=e=>e!=="canvasDefault"&&e!=="canvasInverse",di=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(mh).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Wn=di.map(e=>e.color);var gh="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))",vh="d0bl00";var fh="d0bl03",xh="d0bl04",bh=.01,yh=e=>Wn.some(t=>t.toLowerCase()===e.toLowerCase()),Sh=({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}=H(),f=li(),b=ci(),S=[...p?[d.AUTO_COLOR]:[],...h?[bt]:[],...Wn],y={...f,[bt]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},k=E=>{t(E),o(!1)},w=b.length>0,A=w?b:S,T=e!==null&&!Gr(S,e)&&!Gr(b,e)?[...A,e]:A,I=(0,r.jsx)(Ch,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(te.Popover.Root,{open:n,onOpenChange:o,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:vh,onMouseDown:E=>E.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"start",className:fh,children:(0,r.jsxs)(te.Popover.Popup,{className:xh,onMouseDown:E=>E.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?S:T,names:y,value:e,onChange:k,trailing:w?void 0:I}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:y,value:e,onChange:k,trailing:I}),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:bh,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},Ch=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=H(),{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})},Gr=(e,t)=>e.some(n=>En(n,t)),wh="l9kff0",jh="l9kff1",Th="l9kff2",Ah="xn24px0",kh="xn24px1",Ph="xn24px2",Lh=({children:e,popupAttributes:t})=>(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Ah,children:(0,r.jsx)(ae.Menu.Popup,{className:kh,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),Ih=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ae.Menu.Item,{className:Ph,"data-selected":t,disabled:n,onClick:o,children:e}),Eh=({className:e,...t})=>(0,r.jsx)(ce.Tooltip.Provider,{children:(0,r.jsx)(Se.Toolbar.Root,{...t,className:(0,ge.default)(wh,e)})}),Mh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Group,{...t,className:(0,ge.default)(jh,e)}),Rh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Separator,{...t,className:(0,ge.default)(Th,e)}),Oh=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Pn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},ee={Portal:Oh,Root:Eh,Group:Mh,Separator:Rh,Button:Se.Toolbar.Button,ColorPicker:Sh,MenuPopup:Lh,MenuItem:Ih},_h="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Nh=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Dh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Fh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",gn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Nh},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:_h},{id:"technical",label:"Technical",preview:"00",fontFamily:Dh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Fh}],Bh=e=>e?gn.find(t=>t.fontFamily===e)??null:null,ui="_70l3rt0",hi="_70l3rt1",pi="_70l3rt3",mi="_70l3rt4",gi="_70l3rt5",Gh=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Bh(t)??gn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:ui,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:hi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:pi,children:(0,r.jsx)(ae.Menu.Popup,{className:mi,onMouseDown:l=>l.preventDefault(),children:gn.map(l=>(0,r.jsx)(ae.Menu.Item,{className:gi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},vi={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},zr=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},vi,{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}],zh=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=zr.find(s=>s.id===t)??vi;return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:ui,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:hi,children:a(i.translationKey)}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:pi,children:(0,r.jsx)(ae.Menu.Popup,{className:mi,onMouseDown:s=>s.preventDefault(),children:zr.map(s=>(0,r.jsx)(ae.Menu.Item,{className:gi,"data-selected":s.id===i.id,onClick:()=>Hh(e,s.id),children:(0,r.jsx)(Vh,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},Hh=(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()}},Vh=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),$h=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"})]})}),Uh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),qh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&Hr(n[i-1]);)i-=1;let s=o;for(;s<n.length&&Hr(n[s]);)s+=1;return{from:a+i,to:a+s}},Hr=e=>e!==void 0&&/\S/.test(e),Kh="fop13s0",Xh="fop13s1",Yh="fop13s2",Zh="fop13s3",Vr="fop13s4",Jh=({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=()=>{Qh(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)(te.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Kh,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)($h,{})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"end",className:Xh,children:(0,r.jsxs)(te.Popover.Popup,{className:Yh,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:Zh,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Vr,onClick:p,children:(0,r.jsx)(Wh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Vr,onClick:h,children:(0,r.jsx)(da,{})})]})})})})]})},Qh=(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=qh(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},fi=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"})]})}),xi=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"})]})}),bi=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"})]})}),e0="_1d66w570",t0="_1d66w571",Ee=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(ce.Tooltip.Root,{children:[(0,r.jsx)(ce.Tooltip.Trigger,{render:(0,r.jsx)(zs.Toggle,{render:(0,r.jsx)(Se.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:e0,onMouseDown:a,children:o}),(0,r.jsx)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{sideOffset:6,className:t0,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Yo,children:e})})})})]})},n0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ee,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(bi,{})}),(0,r.jsx)(Ee,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(fi,{})}),(0,r.jsx)(Ee,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(xi,{})})]})},r0="_1u34vl40",o0=({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:a0(e),textAlign:i0(e)}),a0=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",i0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",s0=8,l0=8,c0=({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,Ne.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Ne.offset)(s0),(0,Ne.flip)(),(0,Ne.shift)({padding:l0})],whileElementsMounted:Ne.autoUpdate}),p=(0,x.useRef)(null),m=(0,we.useEditorState)({editor:e,selector:o0}),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:b})=>{const{relatedTarget:S,currentTarget:y}=b,k=S instanceof Node&&p.current?.contains(S),w=S instanceof Node&&y instanceof Node&&y.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)(ee.Portal,{children:(0,r.jsxs)(ee.Root,{ref:g,className:r0,style:h,children:[(0,r.jsxs)(ee.Group,{children:[(0,r.jsx)(ee.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(Gh,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(zh,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsxs)(ee.Group,{children:[(0,r.jsx)(Ee,{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)(Ee,{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)(Ee,{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)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(n0,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(Jh,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},d0="_1uy50v30",yi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:d0,children:[(0,r.jsx)(c0,{editor:e}),(0,r.jsx)(we.EditorContent,{editor:e,"aria-label":t})]}),u0=200,Un=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=u0})=>{const i=(0,x.useRef)($r(e)),s=(0,x.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,o?.(h)},a),u=(0,we.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Zt(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=$r(e);Zt(s.current,h)||(s.current=h,!Zt(u.getJSON(),h)&&(l.cancel(),h0(u,h)))},[u,e,l]),(0,x.useEffect)(()=>()=>l.flush(),[l]),u},$r=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,h0=(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)})},Zt=(e,t)=>JSON.stringify(kt(e))===JSON.stringify(kt(t)),kt=e=>Array.isArray(e)?e.map(kt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,kt(n)]).filter(([,t])=>!p0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),p0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,m0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=Un({content:e,extensions:(0,x.useMemo)(()=>hh({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=Uh(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)(yi,{editor:o,ariaLabel:"Chart caption"})})};var We="textStyle",Si=new Set(["paragraph","heading"]),Ci=e=>ki(ji(e)?.fontSize)??null,wi=e=>Ti(ji(e))??null,g0=e=>{const t=Ai(e),n=b0(e);return{color:it(t.map(o=>y0(Jt(o)?.color))),font:it(t.map(o=>Ti(Jt(o)))),fontSize:it(t.map(o=>ki(Jt(o)?.fontSize))),alignment:it(n.map(o=>S0(o.attrs?.textAlign)))}},v0=(e,t)=>qn(e,n=>n.type==="text"?x0(n,t):n),ze=e=>Ai(e).length>0,f0=(e,t)=>qn(e,n=>Si.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),ji=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===We)?.attrs},qn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>qn(n,t))}),x0=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===We),a={type:We,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},Jt=e=>e.marks?.find(t=>t.type===We)?.attrs,Ti=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),Ai=e=>Kn(e,t=>t.type==="text"),b0=e=>Kn(e,t=>Si.has(t.type??"")),Kn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Kn(n,t))],it=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},y0=e=>typeof e=="string"&&e.length>0?e:void 0,ki=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,S0=e=>e==="left"||e==="center"||e==="right"?e:void 0,C0=e=>[ft.Document,Wo.Paragraph,...$n(),j0,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],w0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,x.useMemo)(()=>C0(t("graph.annotations.text.placeholder")),[t]),i=Un({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,we.useEditorState)({editor:i,selector:({editor:u})=>Ci(u)}),l=(0,we.useEditorState)({editor:i,selector:({editor:u})=>wi(u)});return(0,r.jsx)(we.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"})},Wr=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},j0=$o.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Wr(e.fontFamily)},font:{default:null,renderHTML:e=>Wr(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})`}:{}}}}]}}),T0=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,x.useMemo)(()=>uh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(yi,{editor:Un({content:(0,x.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new d.SetContentTitleCommand({title:l.title})),n&&a(new d.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},Pi={Title:T0,Caption:m0,TextAnnotation:w0},A0={Title:null,Caption:null,TextAnnotation:Pi.TextAnnotation},k0=e=>c.MODE_RULES[e].editTextInline?Pi:A0,P0="_10igzta0",L0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Pn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:P0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),I0="kwvn4c0",E0="kwvn4c1",Xn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Li=e=>Xn(e,e.getBoundingClientRect().width),vn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},M0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=Xn(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),R0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!_0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Ur(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return Ur(s,o.width,t.width)},O0=()=>{const[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{t(!0)},[]),e},_0=e=>c.SIDE_KEYS.some(t=>t===e),Ur=(e,t,n)=>n===0?0:e*t/n,N0={x:8,y:8},D0={side:"flip",align:"shift",fallbackAxisSide:"end"},Ii=({frameElement:e,boundary:t,spans:n,clearance:o=N0,onEscape:a,children:i})=>{const s=Mt(),l=O0(),[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:b,height:S}=t,y=(0,x.useMemo)(()=>({box:{x:v,y:f,width:b,height:S},spans:n}),[v,f,b,S,n]),k=(0,x.useMemo)(()=>M0(e,y.box),[e,y]),w=(A,T)=>{A||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(te.Popover.Root,{open:l,modal:!1,onOpenChange:w,children:(0,r.jsx)(te.Popover.Portal,{container:s,className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(te.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:T})=>R0({side:A,boundary:y.box,spans:y.spans,anchor:T,rightToLeft:F0(g.current)}),collisionAvoidance:D0,sticky:!0,className:I0,...cl,children:(0,r.jsx)(te.Popover.Popup,{ref:m,className:E0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},F0=e=>e!==null&&getComputedStyle(e).direction==="rtl",B0=2,Ei=()=>{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,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+B0)/s;return Math.max(l,Math.min(b,G0(a,(0,d.alignUnitFractions)(i).x)))}},G0=(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)},Mi=(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}},Re=()=>{const e=Wu(),{store:t}=c.useGraphContext();return(0,x.useCallback)(n=>e(n)||Mi(n,t.getState().scene)!==null,[e,t])},Yn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Zn=(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||ze(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(new d.RemoveAnnotationCommand({id:a.annotationId}))},qe=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,z0=(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(...H0(i,e,t,n))}return o},qr=(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)},H0=(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||qe(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=V0(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},V0=(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}},Ke=()=>{const e=c.useGraphSelection();return fn(e)},fn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},$0=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=Re(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(I=>I.spec.annotations.textAnnotations)),v=(0,x.useRef)(null),f=(0,x.useRef)(null),b=(0,x.useRef)(!0),S=(0,x.useRef)(new WeakSet),{showAnnotations:y,showMenuTriggerOnHover:k}=c.MODE_RULES[c.useGraphMode()],w=(0,x.useCallback)(I=>{const{selection:E}=t.getState(),L=y?fn(E):null;L!==null&&(I.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:L})),e.focus({preventScroll:!0}))},[e,n,t,y]),A=(0,x.useCallback)(I=>{if(He(I.target,o))return;const E=y?fn(t.getState().selection):null;E!==null&&g.current.some(L=>L.id===E)&&(I.preventDefault(),m.getState().setCaret(E))},[m,t,g,o,y]),T=(0,x.useCallback)(I=>{const E=m.getState(),L=E.standingInteraction?.kind;if(L!==void 0){L!=="chrome-popup"&&L!=="arrow-draw"&&L!=="box-draw"&&E.releaseInteraction(L);return}if(E.caret!==null){Zn(m,i.getState().scene.annotations,n.dispatch,Yn(a)),E.setCaret(null),e.focus({preventScroll:!0});return}return He(I.target,o)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,o,i,n,a]);(0,x.useEffect)(()=>{const I=P=>{if(!Ie(P.target,e,o)||yt(P.target))return;const j=Me(P.target),C=m.getState(),R=C.caret!==null&&!He(P.target,o);if(j&&!R)return;const G=()=>k&&P.target===e&&!j&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&C.standingInteraction===null&&t.getState().selection.length===0,N=()=>{if(!G())return;const Z=z0(i.getState().scene,s,p);if(Z.length===0)return;const D=l.getState().hover.primary,$=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,W=v.current===null?qr(Z,D):qr(Z,v.current.primary),X=Z[W<0?$>0?0:Z.length-1:Math.min(Z.length-1,Math.max(0,W+$))];if(X!==void 0){if(f.current===null){const be=Le(D);be!==null&&!pt(be,Le(X.primary))&&(f.current=be)}v.current=X,P.preventDefault(),E(X)}},Y=()=>{if(!G())return;const Z=v.current;Z!==null&&(v.current=null,f.current=null,P.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([Z.target]))};switch(P.key){case"Escape":return T(P);case"Enter":return j||(A(P),m.getState().caret!==null)?void 0:Y();case"Delete":case"Backspace":return j?void 0:w(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||j||!k||P.target!==e||C.standingInteraction!==null)return;P.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return N();default:return}},E=P=>{const j=U0(u,P,i.getState().scene.coordSystem,Y0(u,h.current));S.current.add(j),l.getState().setHoverState(j)},L=l.subscribe(P=>{const j=v.current;if(j===null||S.current.has(P.hover))return;const C=P.hover.primary;if(C===null){if(b.current){E(j);return}v.current=null,f.current=null;return}const R=Le(C);if(pt(R,Le(j.primary))){f.current=R;return}if(pt(R,f.current)){E(j);return}v.current=null,f.current=null}),B=h.current,F=()=>{b.current=!0},O=P=>{b.current=!1,!(v.current===null||W0(P,B,l))&&(v.current=null,f.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",F),B?.addEventListener("pointerleave",O),document.addEventListener("keydown",I),()=>{L(),B?.removeEventListener("pointerenter",F),B?.removeEventListener("pointerleave",O),document.removeEventListener("keydown",I)}},[e,w,A,T,o,m,k,t,i,s,p,l,u,h])},Me=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),W0=(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},Le=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},U0=(e,t,n,o)=>{const a=q0(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(pt(Le(i.primary),Le(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}},q0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return K0(e.x,e.y,n);case"cartesian":return X0(e);default:return t}},K0=(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}},X0=e=>{const{observation:t,x:n,y:o}=e,a=st(t,d.POSITION_VARIABLES.xMin),i=st(t,d.POSITION_VARIABLES.xMax),s=st(t,d.POSITION_VARIABLES.yMin),l=st(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},Y0=(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)},st=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},pt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Z0="_1vbfegu3",Xe={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},J0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Xe})}),Q0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Xe})}),ep=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Xe})}),tp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...Xe})}),np=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",...Xe})}),Jn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},rp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Jn})}),op=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",...Jn})}),ap=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Jn})}),Ae={side:"top",delay:200},Kr=.2,ip={type:"doc",content:[{type:"paragraph"}]},Xr={paddingInline:12,paddingBlock:10},sp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(lp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},lp=({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}=H(),m=li(),g=ci(),v=Ei(),[f,b]=(0,x.useState)({kind:"choose"}),S=c.useEditorState(P=>P.standingInteraction?.kind==="box-draw"),y=c.useEditorState(P=>P.standingInteraction?.kind==="arrow-draw"),k=!S&&!y,w=()=>{Fe(a),a.getState().setPlotMenu(null)};(0,x.useEffect)(()=>()=>Fe(a),[a]),(0,x.useEffect)(()=>{if(!S&&!y)return;const P=j=>{if(j.key!=="Escape"||!Ie(j.target,e,s)||yt(j.target))return;const C=Me(j.target),R=a.getState().caret!==null&&!He(j.target,s);if(C&&!R)return;const G=a.getState().standingInteraction?.kind;G!=="arrow-draw"&&G!=="box-draw"||(j.preventDefault(),a.getState().releaseInteraction(G))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s,S,y,a,e]);const A={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={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}},I=P=>{Fe(a),b(j=>j.kind===P?{kind:"choose"}:{kind:P})},E=P=>(...j)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:P,start:n,...Yr(j[0])})},L=(...P)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Fe(a),b({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...Yr(P[0])})},B=()=>{const P=a.getState().standingInteraction?.kind;if((P==="arrow-draw"||P==="box-draw")&&!yt(document.activeElement)){a.getState().releaseInteraction(P);return}w()},F=P=>{Fe(a);const j=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:ip,at:{anchorType:"panel",x:n.x,y:n.y},width:Kr}}),C=j.params.annotation.id,R=v({annotationId:C,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Kr,paddingInline:P===null?void 0:Xr.paddingInline}),G=new d.AddAnnotationCommand({kind:"text",annotation:{...j.params.annotation,width:R}});P===null?i.dispatch(G):i.dispatch(new d.SequenceCommand({commands:[G,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:C},declarations:{fill:P,...Xr}}})]})),u.getState().setSelection([{kind:"annotation",id:C}]),a.getState().setCaret(C,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},O=P=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:P}})),w()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Z0,style:{left:A.x,top:A.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),k&&(0,r.jsx)(Ii,{frameElement:e,boundary:A,spans:T,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:ti,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)(J0,{}),onClick:()=>F(null)}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(Q0,{}),expanded:f.kind==="sticky",onClick:()=>I("sticky")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(ep,{}),expanded:f.kind==="arrow",onClick:()=>I("arrow")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(tp,{}),expanded:S,onClick:L}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(np,{}),expanded:f.kind==="sticker",onClick:()=>I("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:Wn,names:m,value:null,onChange:F,...Ae}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:F})]}),f.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([P,j])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":P,onClick:()=>O(P),children:(0,r.jsx)("img",{className:"vez73g9",src:j.src,alt:""})},P))}),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:E("end"),children:(0,r.jsx)(rp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:E("both"),children:(0,r.jsx)(op,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:E("none"),children:(0,r.jsx)(ap,{})})]})]})})]})},Fe=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Yr=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}}},Ye=e=>e.offset+e.strokeWidth,Zr="http://www.w3.org/2000/svg",Jr=new WeakMap,cp=(e,t)=>{const n=dp(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}},dp=e=>{const t=Jr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Zr,"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(Zr,"path");return n.append(o),e.body.append(n),Jr.set(e,o),o},up=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=Ye(o);switch(e.kind){case"observations":return Qt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>hp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Qt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(vp(s),a(s.axis)/2)),i);case"graph":return Qt([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},hp=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=mp(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>pp(l,s))},pp=(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}]},mp=(e,t)=>e.kind==="boxes"?e.boxes:gp(e.shapes,t),gp=(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},vp=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}}},Qt=(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 fp=(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=>xp(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},xp=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),bp=.5,yp={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},Sp=(e,t,n)=>e===null||!Cp(e)?{top:xn(t),right:bn(t),bottom:xn(t),left:bn(t)}:{top:lt(e,t,"top",n),right:lt(e,t,"right",n),bottom:lt(e,t,"bottom",n),left:lt(e,t,"left",n)},lt=(e,t,n,o)=>{const a=yp[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,bp);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?bn(t):xn(t),v={from:(0,de.clamp)(p-o,g.from,g.to),to:(0,de.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))},xn=e=>({from:e.x,to:e.x+e.width}),bn=e=>({from:e.y,to:e.y+e.height}),wp=(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=up(h,{panelRect:n,look:o,readGridLineWidth:y=>c.readGridLineStyle(i,y).strokeWidth,measurePathBox:y=>{const k=m.get(y)??cp(t.ownerDocument,y);return g.set(y,k),k},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const b=Sp(fp(h,{coordSystem:s,panelRect:n}),f,Ye(o)),S=Li(t);a.getState().setSelectedOutline({target:u,frame:f,frameSpans:b,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)",jp="_1qfw3e01",Tp="_1qfw3e02",Qr=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(Ap,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),Ap=({pathData:e,source:t,...n})=>{const o=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(Es.motion.path,{d:o,...n})},kp="var(--dppmab0)",Pp="data-edit-outline-stroke",Ri=e=>({[Pp]:"",style:(0,fe.assignInlineVars)({[kp]:`${e}px`})}),Lp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=Oi(),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||qe(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:_i({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},Ip=()=>Ep("pin"),Ep=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=Oi(),[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||qe(p,g)?null:_i({layer:p,observation:g,target:h,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,a,o,i,s,e])},Oi=()=>{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=Re();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},_i=({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}},Mp=()=>{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:Rp(e,t,n),[e,t,n])},Ni=(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}},Rp=(e,t,n)=>{switch(e.kind){case"observations":{const o=Ni(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}},Op=()=>{const e=Lp(),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:Ni(e.target,i,s),[t,e,n,o,a,i,s])};var eo=(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"},_p=(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)}},Np=[],Dp=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:Fp(t,i,s,l),[t,i,s,l]),h=(0,x.useMemo)(()=>u!==null&&e!==null&&eo(u,e),[u,e]),p=Re(),m=a!==null&&i!==void 0&&Bp(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:Np,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&&eo(g,e)?null:g}default:return null}},[o,u,h,m,e])},Fp=(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}},Bp=({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)},Gp=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(zp(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?en(l):en([(0,d.getBoundingRect)(l)])}case"legend":return en([...Hp(i.filter(l=>!Vp(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?[$p(l,s(l),h)]:[]})}},zp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Hp=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},Vp=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,en=e=>e.map(t=>({kind:"box",rect:t})),$p=(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}}:Wp(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}},Wp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Up=[],qp=(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=Xp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Kp(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(b=>to(b,p,a))??Up,[m,p,a]),f=(0,x.useMemo)(()=>g===null?null:to(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])},Kp=(e,t)=>{const[n,o]=(0,x.useState)(()=>vn(e,t));return(0,x.useLayoutEffect)(()=>{o(a=>{const i=vn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},to=({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=>_p(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})}},Xp=(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=Gp({frameElement:t,target:p,coordType:o,legendDisplays:a}),v=Li(t);l(g.map(f=>Yp(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},Yp=(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}}},Zp=["x","y"],Jp=(0,x.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=Mp(),s=Dp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Op(),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)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:jp,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(tn,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),tn=({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=qp(t,{frameElement:s,frameSize:a,panelRect:i});return wp(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:Tp,children:(0,r.jsx)(om,{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:Qp(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:em(o)}),(0,r.jsx)("use",{href:`#${h}`,style:tm(o)})]}),t.kind==="observations"&&(0,r.jsx)(dm,{target:t,look:o,panelRect:i})]}):null},Qp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,fe.assignInlineVars)({[Qn]:`${2*e}px`})}),em=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,fe.assignInlineVars)({[Qn]:`${2*Ye(e)}px`})}),tm=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,fe.assignInlineVars)({[Qn]:`${2*Ye(e)}px`})}},nm=({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},Di=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},rm=(e,t,n)=>{const o=n.offset+Ye(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},om=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=nm(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)(no,{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)(no,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(sm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:rm(e.frameSize,o,t)})}},no=(0,x.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(im,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(am,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),am=({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,...Ri(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:Di(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),im=({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"})},sm=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Zp.map(s=>{const l=Ri(c.readGridLineStyle(a,s).strokeWidth),u=t.map(p=>lm(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:cm(p),pathLength:Di(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})},lm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",cm=({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}`},dm=({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=um(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"})})},um=({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},hm=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"})]}),pm=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"})]}),mm=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"})]}),gm={observation:hm,xValue:pm,group:mm},vm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=Nt(a,o),s=c.useEditorState(S=>S.pressedObservation),l=Re(),u=(0,x.useMemo)(()=>fm({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 y=gm[S];return{value:S,label:m[S],icon:(0,r.jsx)(y,{})}}),b=S=>{const y=p.find(A=>A===S),{parsingLocale:k}=a.config,w=y===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:y,parsingLocale:k});w!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(Mn,{value:v.scope,options:f,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},fm=({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:Ja({scene:e,layer:l,observation:u,groupOptions:n,locale:o,t:a})}},xm=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"})]})}),bm=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"})]})}),ym="_11vjgg60",Sm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,x.useState)(null),s=Mi(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?bm:xm;return(0,r.jsx)(ye,{label:m,children:(0,r.jsx)("button",{type:"button",className:ym,onClick:p,children:(0,r.jsx)(g,{title:""})})})},Cm=(e,t)=>t==="polar"||e==="bar",wm=(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}}},jm="_1j45ehx0",Tm="_1j45ehx1",Am="_1j45ehx2",km="_1j45ehx3",Pm=(e,t)=>{switch(e.kind){case"observations":return Lm(e.scope,t);case"legend":case"axis":case"grid":return Im(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},Lm=(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}},Im=(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}},Em=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Nt(o,n),i=(0,x.useMemo)(()=>Rm({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(Mm,{title:i})},Mm=({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)(te.Popover.Title,{ref:l,className:Am,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:km,"aria-hidden":!0,children:e.whole})]})},Rm=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=Pm(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:hn({scene:t,layer:l,observation:h,groupOptions:n,locale:o,t:a},e.scope)},Om=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=_m(c.useEditorState(p=>p.selectedOutline)),o=c.useEditorState(p=>p.annotatePress),a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=$u(n?.target??null),s=Re(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,x.useMemo)(()=>a&&l!==null?wm(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)(Ii,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(an,{className:jm,children:[(0,r.jsxs)("div",{className:Tm,children:[(0,r.jsx)(Em,{target:n.target}),(0,r.jsx)(Sm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(vm,{})]}),(0,r.jsx)(x.Fragment,{children:i},l)]})},_m=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},Nm=({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:ct(l.top,o,u),right:ct(l.right,a,u),bottom:ct(l.bottom,o,u),left:ct(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},ct=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Fi=["start","end"],Dm=({anchor:e,point:t,delta:n,bounds:o=d.PANEL_FRACTION_BOUNDS})=>{const a={x:oo(t.x,n.x,o.minX,o.maxX),y:oo(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}}},er=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},ro=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),Bi=(e,t)=>(0,de.isEqual)(e,t),Fm=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Bm=(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)}},oo=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,de.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Dt=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Gi=(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)},Gm="var(--_1am0al60)";var zm="_1am0al61",Hm="_1am0al62",ne=(e,t)=>t>0?e/t:0,zi=(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)},Hi=(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)}),me=(e,t)=>{const n=t.getBoundingClientRect(),o=vn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return zi(e,a)},tr=(e,t,n)=>({x:ne(t.x-e.x,n.width),y:ne(t.y-e.y,n.height)}),Vm=e=>e.x!==0||e.y!==0,Vi=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),$m=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=Ke(),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=ao(t,a,p),g=ao(t,h===a?null:h,p),v=b=>{if(s?.annotationId===b.id){const S=t.shapes.find(y=>y.id===b.id);return S===void 0?b.geometry:c.measureShapeRegion(s.region,o.annotation.shape(S.id).get("strokeWidth"),p.panel)}if(l?.annotationId===b.id){const S=t.arrows.find(y=>y.id===b.id);return S===void 0?b.geometry:c.measureArrowEnds(er(S,l,p.panel),p.panel)}return u?.annotationId===b.id?Gi(t,b.id,u,p)??b.geometry:b.geometry},f=b=>{if(i?.annotationId!==b)return e;const S=Vi(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)(io,{annotationId:g.id,geometry:v(g),state:"hovered",origin:f(g.id)}),m!==null&&(0,r.jsx)(io,{annotationId:m.id,geometry:v(m),state:"selected",origin:f(m.id)})]})},ao=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},io=({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,fe.assignInlineVars)({[Gm]:Dt(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)(so,{point:t.start,origin:o}),(0,r.jsx)(so,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:zm,"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}})},so=({point:e,origin:t})=>(0,r.jsx)("span",{className:Hm,style:{left:t.x+e.x,top:t.y+e.y}}),nr="c44vv80",Wm=({panelRect:e})=>{const t=c.useEditorState(a=>c.readStanding(a,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=Vi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:nr,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:Km(n,t.annotationId,e)})},Um=({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})},Be=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},qm={text:(e,t,n)=>Be(e.textAnnotations,t,o=>(0,r.jsx)(Um,{annotation:o,panelSize:n})),shape:(e,t,n)=>Be(e.shapes,t,o=>(0,r.jsx)(Ym,{shape:o,panelSize:n})),image:(e,t,n)=>Be(e.images,t,o=>(0,r.jsx)(Jm,{image:o,panelSize:n})),arrow:(e,t,n)=>Be(e.arrows,t,o=>(0,r.jsx)(Xm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Be(e.stickers,t,o=>(0,r.jsx)(Zm,{sticker:o,panelSize:n}))},Km=(e,t,n)=>{for(const o of Object.values(qm)){const a=o(e,t,n);if(a!==null)return a}return null},Xm=({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})},Ym=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Zm=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Jm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),Qm="_1lp7ph20",eg=({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)(tg,{placement:t,panelRect:e})},tg=({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"?ng(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:Qm,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",...nn(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":rg(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",...nn(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,...nn(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"})]})]})},nn=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),ng=e=>e.target.type==="observation"?e.target.box:e.target.rect,rg=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,og=({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:er(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:nr,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})})},ag=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"})]})}),ig=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"})]})}),Wi=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"})]})}),Ft=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"})]})}),sg="var(--pvjfpx0)",lg="var(--pvjfpx1)",cg="pvjfpx2",dg="pvjfpx3",ug="pvjfpx4",hg="pvjfpx6 pvjfpx5",pg="pvjfpx7 pvjfpx6 pvjfpx5",mg="pvjfpx8 pvjfpx5",ke=8,gg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],pillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,u=s-8-44,h=l+8,p=o-ke-44,m=ke,g=Math.max(0,n-ke*2),v=t.x+e.x+e.width/2-m,f=w=>w>=ke&&w<=p,b=(0,de.clamp)(h<=p?h:u,ke,p);if(a.length===0||i===void 0)return{top:b,left:m,available:g,centre:v};const S=w=>!vg(w,m,g,v,i,a),y=Math.max(h,ke);if(f(y)&&S(y))return{top:y,left:m,available:g,centre:v};const k=Math.max(l,...a.map(w=>w.y+w.height))+8;return f(k)?{top:k,left:m,available:g,centre:v}:f(u)&&S(u)?{top:u,left:m,available:g,centre:v}:{top:b,left:m,available:g,centre:v}},vg=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,de.clamp)(o-s/2,0,Math.max(0,n-s)),u=l+s,h=e+44;return i.some(p=>l<p.x+p.width&&u>p.x&&e<p.y+p.height&&h>p.y)},fg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:u})=>{const{chartId:h}=c.useGraphContext(),[p,m]=(0,x.useState)(null),[g,v]=(0,x.useState)(null);(0,x.useLayoutEffect)(()=>{if(p===null)return;const b=()=>v(p.offsetWidth);b();const S=new ResizeObserver(b);return S.observe(p),()=>S.disconnect()},[p]);const f=gg({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,pillWidthPx:g??i});return(0,r.jsx)("div",{className:cg,style:{top:f.top,left:f.left,width:f.available},children:(0,r.jsx)(ee.Root,{ref:m,"aria-label":s,className:dg,"data-testid":l,...Et(h),style:(0,fe.assignInlineVars)({[sg]:`${f.centre}px`,[lg]:`${f.available}px`}),children:u})})},xg=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ae.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ee.Button,{}),"aria-label":e,className:mg,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ee.MenuPopup,{popupAttributes:Et(s),children:i})]})},bg=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ee.ColorPicker,{...e,popupAttributes:Et(t)})},yg=({color:e,opacity:t})=>(0,r.jsx)("span",{className:ug,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),Sg=({label:e,onClick:t,children:n})=>(0,r.jsx)(ee.Button,{"aria-label":e,className:hg,onClick:t,children:n}),Cg=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(ee.Button,{"aria-label":e,"aria-pressed":t,className:pg,onClick:n,children:o}),V={Root:fg,Dropdown:xg,MenuItem:ee.MenuItem,ColorPicker:bg,Swatch:yg,IconButton:Sg,ToggleButton:Cg,Button:ee.Button,Separator:ee.Separator},wg={kind:"chrome-popup"},Bt=()=>{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(wg),()=>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}},jg=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"})]})}),Tg=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"})]})}),Ag=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),kg=[{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"}],lo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:$i},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],co=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Ag},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:jg},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Tg}],Pg=(e,t)=>e.find(n=>n.value===t)??e[0];var Lg=({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=Bt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=Pg(co,(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]),b=(0,x.useMemo)(()=>({...f,part:"outline"}),[f]),S=(O,P)=>{const j=(0,d.findStyleRule)(u,{select:f},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...j,...O}}}),P)},y=O=>{const P=(0,d.findStyleRule)(u,{select:b},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...P,...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})},T=O=>S({stroke:O},{transient:!0}),I=O=>k({strokeWidth:O}),E=O=>w({startArrowheadStyle:O}),L=O=>k({dashArray:d.DASH_PRESETS.arrow[O]}),B=O=>w({endArrowheadStyle:O}),F=()=>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)(Wi,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(dt,{options:kg,current:m.strokeWidth,onPick:I})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(ag,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(dt,{options:lo,current:e.startArrowheadStyle,onPick:E})}),(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)(dt,{options:co,current:(0,d.toDashPreset)(m.dashArray),onPick:L})}),(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)(dt,{options:lo,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:F,children:(0,r.jsx)(ig,{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)(Ft,{size:"sm",title:""})})]})},dt=({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)))})},Ig="_1me29t10";var Eg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ze=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 Eg(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)}},yn=(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}}},rr=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Ui=["center",...rr],Mg=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Ui.filter(a=>a!==t)].map(a=>({align:a,point:(0,d.readRectPoint)(o,a)}))},qi=(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},Rg=(e,t,n,o)=>{const a=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:ne(e.point.x-a.x,o.width),y:ne(e.point.y-a.y,o.height)}},Og=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,de.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},_g=class extends Ze{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=me(l,u),p=(0,d.clampAnnotationTranslation)(s,tr(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=Og(Sn(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}=Sn(t,i,n,s);if((0,de.isEqual)(h,u.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}Vm(e)&&o(new d.MoveAnnotationCommand({id:n,translation:e,bounds:me(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,yn(e.at,null,u.at,l),n,o,{targetAligns:rr,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:ne(m.point.x-h.x,l.width),y:ne(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(Mg(m,e.align,g),(0,d.readRectPoint)(m,e.align),yn(e.at,e.align,h.at,l),n,o,{targetAligns:Ui});return v===null?null:{kind:"move-drag",annotationId:a,translation:Rg(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:b,measuredBoxes:S,readObservationBox:y}=a,k=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),w=Hi(me(g,v),{x:ne(t.x,g.width),y:ne(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:b,resolver:u,readObservationBox:y,annotationTargets:o.altKey?[]:qi(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}})}},Sn=(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,ne(a.x,o.width))),l=Math.max(0,Math.min(1,ne(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:[]}},mt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,Ki=(e,t,n)=>{const o=mt(e,t,n);return o?.anchorType==="panel"?o:null},Xi=(e,t)=>e==="start"?{start:t}:{end:t},Ng=(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)},Dg=(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},Fg=class extends Ze{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:b,measuredBoxes:S,readObservationBox:y}=h,k=mt(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),T=Hi(me(v,h.frameElement),{x:ne(A.x,v.width),y:ne(A.y,v.height)}),I=o==="start"?"end":"start",E=mt(p,n,I),L=E===null?void 0:Ng(E,m[I],{scene:g,panelRect:v,measuredBoxes:S,readObservationBox:y}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),F=this.readOwn(u.getState())?.placement,O=C=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:A.x+w.x,y:A.y+w.y}}],current:t.altKey?null:yn(k,null,m[o],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:b,resolver:l,readObservationBox:y,annotationTargets:t.altKey?[]:qi(g,B,v,S),snapDistance:8,releaseDistance:12,revealDistance:160,previous:F?.type==="snapped"?F.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:rr,areaAlign:C,annotationAreaAlign:C,areaSnapDistance:16,facing:L,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),P=O("auto"),j=P?.type==="snapped"&&P.landing==="area"&&Dg(P.anchor,E)?O(void 0):P;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=mt(i,n,e);if(l===null)return;const u=Sn(t,i,n,s).anchor;Bi(l,u)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Xi(e,u)}))}},Bg=({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: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 Fg({handle:b.currentTarget,pointerId:b.pointerId,annotationId:e,endpoint:f,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])},Gg=[" ","Enter"],uo=4,zg=({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 Fi)ho({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(Gg.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){ho({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:a.dispatch});return}const y=Ki(s,e,h);if(y===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:ro(y,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Hg(p.key,n);if(f===null)return;p.preventDefault();const{anchor:b,point:S}=Dm({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:f,bounds:me(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:ro(b,S,n)})}}),[e,s,t,n,o,i,a])},ho=({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=Ki(o,t,n);l===null||Bi(l,s.placement.anchor)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Xi(n,s.placement.anchor)}))},Hg=(e,t)=>{const n=ne(uo,t.width),o=ne(uo,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}},Vg=e=>{const t=Ke(),n=Ug(t),o=qg(e.panelRect,t),a=Kg(t);if(n===null||o===null)return null;const i=a.dragged===null?o:er(o,a.dragged,e.panelRect);return(0,r.jsx)($g,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},$g=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Bg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=zg({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)(Lg,{arrow:e,arrowBox:Bm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&Fi.map(m=>(0,r.jsx)(Wg,{endpoint:m,point:Fm(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},Wg=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:Ig,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Ug=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},qg=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Kg=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}})),Xg=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"})]})}),Yi="var(--ydgo3h0)";var Yg="ydgo3h1",Zg="ydgo3h2",Jg="ydgo3h3",Qg="ydgo3h4",po={small:2,medium:3,large:5},ev=(e,t)=>{const n=Object.keys(po),o=n.find(a=>{const i=po[a];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&tv(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)},tv=(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),nv="q7gcrz0",rv="q7gcrz1",ov="q7gcrz2";var av=4,iv=6,sv=c.iconSizeMap.sm,lv=3,cv=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*av,u=[n,o].filter(p=>p.length>0).length,h=a.length===0?0:1;return s(n)+s(o)+s(a)+l(u)+l(h)+dv()},dv=()=>36+34*lv+iv*4+sv*2,uv=["absoluteDifference","relativeDifference","proportion"],mo=["absoluteDifference","relativeDifference"],hv=["relativeDifference","proportion"],pv={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},mv=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 uv.filter(i=>a||!mo.includes(i)||i===e.label).map(i=>({kind:i,key:pv[i],preview:(0,d.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!mo.includes(i),suspect:hv.includes(i)&&e.start.measurementValue===0}))},[e,o])},go=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],gv=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:u})=>{const h=c.useI18n(),p=c.useTextMeasurer(),{commands:m}=c.useGraphContext(),g=c.useSceneSelector(N=>N.spec.styles.overrides),v=c.useSceneSelector(N=>(0,d.readStyleCoord)(N.spec)),f=Bt(),b=mv(e),S=c.useStyleReaderTree(),y=(0,d.resolveDifferenceArrowAnnotationStyle)(S,e.id),k=S.graph().get("textScale"),w=(0,x.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),A=(0,x.useMemo)(()=>({...w,part:"label"}),[w]),T=b.find(N=>N.kind===e.label),I=b.some(N=>N.pickable&&N.kind!==e.label),E=go.find(N=>N.id===ev(y,k)),L=(N,Y)=>{m.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:N}),Y)},B=N=>({...(0,d.findStyleRule)(g,{select:w},v)?.declarations,...N}),F=N=>({...(0,d.findStyleRule)(g,{select:A},v)?.declarations,...N}),O=N=>{L(N),f.close()},P=()=>{m.dispatch(new d.RemoveAnnotationCommand({id:e.id})),u.focus({preventScroll:!0})},j=N=>m.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:w,declarations:B({stroke:N})}}),{transient:!0}),C=()=>L({start:e.end.anchor,end:e.start.anchor}),R=N=>()=>O({label:N}),G=N=>()=>{const Y=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[N];m.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(Y.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(F(Y.label))})),f.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[vo(i,o),vo(i,a)],estimatedPillWidthPx:cv({textMeasurer:p,textScale:k,labelKindName:T===void 0?"":h(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:E===void 0?"":h(E.key)}),label:h("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(vv,{option:T}),disabled:!I,...f.bind("labelKind"),children:b.map(N=>(0,r.jsxs)(V.MenuItem,{selected:N.kind===e.label,disabled:!N.pickable,onClick:R(N.kind),children:[(0,r.jsx)("span",{children:h(N.key)}),(N.suspect||!N.pickable)&&(0,r.jsx)("span",{"aria-label":h(N.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:ov,children:N.preview})]},N.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:h("graph.annotations.differenceArrowToolbar.color"),onChange:j,...f.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:E===void 0?"":h(E.key),...f.bind("size"),children:go.map(N=>(0,r.jsx)(V.MenuItem,{selected:N.id===E?.id,onClick:G(N.id),children:h(N.key)},N.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.swap"),onClick:C,children:(0,r.jsx)(Xg,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.remove"),onClick:P,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},vv=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:rv,children:t(e.key)}),(0,r.jsxs)("span",{className:nv,children:["(",e.preview,")"]})]})},vo=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),fv=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=xv({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},xv=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Zi=e=>e==="start"?"end":"start",Ji=({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}}))},bv=class extends Ze{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=fv({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:u,coordSystem:h,resolver:a,fixedAnchor:i[Zi(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;Ji({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},yv=({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 bv({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])},Sv=[" ","Enter"],Cv=({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(Sv.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"),Ji({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=wv(h.key,s);if(g===null)return;h.preventDefault();const v=jv({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])},wv=(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}},jv=({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[Zi(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},Tv=e=>{const t=Ke(),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:Yg,children:[t!==null&&(0,r.jsx)(Av,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(Pv,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},Av=({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)(kv,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},kv=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:u,frameElement:h,dragging:p})=>{const m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,fe.assignInlineVars)({[Yi]:m}),children:[!p&&(0,r.jsx)(gv,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:u.width,frameHeight:u.height,frameElement:h}),(0,r.jsx)("div",{"aria-hidden":"true",className:Qg,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},Pv=({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=yv({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=Cv({arrow:e.committedArrow}),m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,fe.assignInlineVars)({[Yi]:m}),children:[(0,r.jsx)(fo,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(fo,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},fo=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Zg,"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:Jg})}),Lv="s8eewu0",xo="s8eewu1",Iv=({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:bo(g-f.left,0,f.width),y:bo(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:Lv,children:o===null?(0,r.jsx)("line",{className:xo,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:xo,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)})})},bo=(e,t,n)=>Math.min(Math.max(e,t),n),Ev=({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:nr,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})})},Mv="var(--o49ib40)",Rv={sm:"o49ib41",md:"o49ib42"},Ov={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Qi=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:Ov[n],role:"button",style:{left:e.x,top:e.y,...(0,fe.assignInlineVars)({[Mv]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Rv[o]})})},Cn=[{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"}],_v=e=>[...Cn].reverse().find(t=>t.width<=e)??Cn[0],Nv=({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=Bt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=_v(m.strokeWidth),v=(0,x.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),f=(w,A)=>{const T=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...T,...w}}}),A)},b=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},S=w=>f({fill:w},{transient:!0}),y=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: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)(Wi,{size:"sm",title:""}),...p.bind("border"),children:Cn.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:b,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},wn=({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,de.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,de.clamp)(u+o,p,m)-e}},Dv=["top-left","top-right","bottom-right","bottom-left"];var es=({width:e,height:t})=>({x:ne(16,e),y:ne(16,t)}),Fv=(e,t)=>({x:rs(t)?e.x:e.x+e.width,y:os(t)?e.y:e.y+e.height}),ts=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=wn({start:e.x,extent:e.width,moveStartEdge:rs(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=wn({start:e.y,extent:e.height,moveStartEdge:os(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}},ns=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,rs=e=>e==="top-left"||e==="bottom-left",os=e=>e==="top-left"||e==="top-right",as=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])},Pt=(e,t)=>{const n=e.shapes.find(o=>o.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Bv=class extends Ze{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=Pt(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:ts({region:u,corner:n,delta:tr(o,e,s),minSize:es(s),bounds:me(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=Pt(o().annotations,t);a===null||ns(a,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Gv=({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 as((s,l)=>new Bv({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},zv=[" ","Enter"],is=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,x.useEffect)(()=>()=>yo(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(zv.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){yo(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])},yo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},So=4,Hv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return is({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=Pt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=Vv(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:ts({region:s.region,corner:l,delta:h,minSize:es(t),bounds:me(t,n)})}},commit:({region:s})=>{const l=Pt(i,e);l===null||ns(l,s)||o.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},Vv=(e,t)=>{const n=ne(So,t.width),o=ne(So,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}},$v={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},Wv=e=>{const t=Ke(),n=qv(t),o=Kv(t);if(n===null)return null;const a=o.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return a===null?null:(0,r.jsx)(Uv,{shape:n,region:a,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},Uv=({shape:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=Gv({annotationId:e.id,panelRect:a,frameElement:s}),h=Hv({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)(Nv,{shape:e,shapeBox:p,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&Dv.map(m=>{const g=Fv(p,m);return(0,r.jsx)(Qi,{point:{x:a.x+g.x,y:a.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:$v[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},qv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},Kv=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})),Xv=({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 ss=[{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})),Yv=e=>ss.find(t=>t.id===(e??"modern"))??null;var ls=[{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"}],Zv=e=>ls.find(t=>t.size===(e??15))??null,Jv=e=>`${e}px`,Qv=[{alignment:"left",Icon:bi},{alignment:"center",Icon:fi},{alignment:"right",Icon:xi}],e1=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(D=>D.spec.styles.overrides),h=c.useSceneSelector(D=>(0,d.readStyleCoord)(D.spec)),p=c.useEditorStore(),m=Bt(),g=Ei(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),f=g0(e.content),b=c.useEditorState(D=>D.caret?.editor??null),S=(0,we.useEditorState)({editor:b,selector:()=>Ci(b)}),y=(0,we.useEditorState)({editor:b,selector:()=>wi(b)}),k=Yv(f.font??y),w=Zv(f.fontSize??S),A=c.useTextAnnotationTextColor(v),T=f.color??A,I=(0,x.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),E=(D,$)=>{const W=(0,d.findStyleRule)(u,{select:I},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:I,declarations:{...W,...D}}}),$)},L=(D,$)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:D}),$)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,F=(D,$)=>{const W=B(),X=p.getState().caret?.editor??null;if(X!==null&&!ze(W)){X.chain().focus().setMark(We,D).run();return}L({content:v0(W,D)},$)},O=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=D=>E(t1(D),{transient:!0}),j=D=>E({fillAlpha:D},{transient:!0}),C=v.fill!==bt,R=D=>F({color:D===d.AUTO_COLOR?void 0:D},{transient:!0}),G=D=>()=>{ze(B())||Y({font:D}),F({font:D}),m.close()},N=D=>()=>{ze(B())||Y({fontSize:D}),F({fontSize:D}),m.close()},Y=D=>{const $=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:$,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:D.fontSize??S,pickedFont:D.font??y});W>e.width&&L({width:W})},Z=D=>{const $=p.getState().caret?.editor??null;if($===null||ze(B())){L({content:f0(B(),D)});return}const W=$.state.storedMarks;$.chain().focus().setTextAlign(D).command(({tr:X})=>(X.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:P,opacity:C?v.fillAlpha:void 0,onOpacityChange:C?j:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:C?(0,d.toPaintColor)(v.fill):gh,opacity:C?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)(Xv,{size:"sm",textColor:T,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:ss.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.id===k?.id,onClick:G(D.id),children:(0,r.jsx)("span",{style:{fontFamily:D.fontFamily},children:s(D.key)})},D.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:ls.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.size===w?.size,onClick:N(D.size),children:(0,r.jsx)("span",{style:{fontSize:Jv(D.size)},children:s(D.key)})},D.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(n1,{current:f.alignment??"center",onPick:Z}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:O,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},t1=e=>e==="transparent"?{fill:bt}:{fill:e,fillAlpha:yh(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},n1=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:Qv.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))})},r1=["left","right"];var cs=({width:e})=>ne(60,e),o1=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),ds=({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=a1(e.offset,s),p=wn({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}},us=(e,t)=>e.at.x===t.at.x&&e.width===t.width,a1=(e,t)=>e?.x===void 0?0:e.unit==="px"?ne(e.x,t):e.x,Lt=(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}},i1=class extends Ze{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=Lt(i,t);if(u===null)return null;const h=tr(o,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...ds({...u,edge:n,delta:h,minWidth:cs(s),panelWidth:s.width,bounds:me(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=Lt(o().annotations,t);a===null||us(a,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},s1=({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 as((s,l)=>new i1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},l1=4,c1=({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=Lt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...ds({...h,edge:l,delta:u,minWidth:cs(t),panelWidth:t.width,bounds:me(t,n)})}};return is({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=d1(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=Lt(i,e);u===null||us(u,l)||o.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},d1=(e,t)=>{const n=ne(l1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},u1=e=>{const t=Ke(),n=p1(t),o=m1(t),a=c.useEditorState(s=>s.caret?.annotationId===t),i=g1(e.panelRect,t,o.resized);return n===null||i===null?null:(0,r.jsx)(h1,{annotation:n,textBox:i,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:n.at.anchorType==="panel",hasCaret:a,...e})},h1=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=s1({annotationId:e.id,panelRect:s,frameElement:u}),m=c1({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)(e1,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),a&&!o&&!i&&r1.map(g=>{const v=o1(t,g);return(0,r.jsx)(Qi,{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)})]})},p1=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},m1=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})),g1=(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:Gi(o,t,n,s)?.rect??null},or=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],v1=(e,t,n)=>c.readStampedEditTargetInStack(or(e,t),n),f1="_1rpuha50";var Co=["pointerdown","mousedown","pointerup","mouseup","click"],hs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,x1=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>S1(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=b1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(y1(h)))};for(const h of Co)l.addEventListener(h,u);return()=>{for(const h of Co)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:f1,"data-menu-shield":"","data-testid":"menu-shield"}):null},b1=(e,t)=>or(e,t).find(n=>!hs(n))??null,y1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),S1=e=>e==="arrow-draw"||e==="box-draw",C1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',w1=(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||!Ie(i.target,e,n)||yt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(C1)];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])},j1=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,x.useEffect)(()=>{let a=null;const i=u=>{if(Me(u.target))return;const{caret:h}=o.getState(),p=h===null?null:v1(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&&(Ie(u.target,e,n)||p())},l=u=>{t.getState().selection.length!==0&&Ie(u.target,e,n)&&u.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Ie(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])},T1=(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=A1(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:L1(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},A1=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=k1(o,a);if(i!==null)return i}return null},k1=(e,t)=>{for(const n of e){const o=(0,d.readVariableName)(n.mapping[t]);if(o!==null&&P1(n,o))return{layer:n,variable:o}}return null},P1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",L1=(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},I1=({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},E1=(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})},jn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=wo(!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?M1(a):null,h=u===null?null:R1(e,u,t),p=h===null?null:I1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=wo(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}},M1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},wo=(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?or(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}},R1=(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})},O1=({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||qe(h,l.observation)||!_1(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}},_1=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}},jo="data-annotation-id",N1='[data-testid="pinnedNumber"], [data-testid="comment"]',To=(e,t,n)=>{if(e.target instanceof Element){const o=Ao(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=Ao(o,t);if(a!==null)return a}return null},D1=(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:F1(e,n.at.anchor.layerId,n.at.observationIndex)},Ao=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(N1);if(n===null||!t.contains(n))return null;const o=e.closest(`[${jo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(jo);return a===null||a.length===0?null:a},F1=(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})},B1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},G1=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!Po(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Po(t,e)){const{primary:l,intersection:u}=o.query((0,d.toPanelCursor)(i,t),{tolerance:B1,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&&qe(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=zi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:ko(i.x/t.width,s.minX,s.maxX),y:ko(i.y/t.height,s.minY,s.maxY)}},ko=(e,t,n)=>Math.min(Math.max(e,t),n),Po=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,z1=(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 H1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},H1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},V1=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,$1=(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)(E=>({spec:E.spec.annotations,layers:E.layers,coordSystem:E.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),f=c.usePaintedObservationBoxes(t),b=c.useGraphMode(),{selectGraphOnPress:S}=c.MODE_RULES[b],y=c.useLatestRef(S),k=c.useLatestRef(b===c.GRAPH_MODES.annotate),w=c.useLatestRef(b===c.GRAPH_MODES.annotate),A=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:f}),T=c.useLatestRef(o),I=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>I.current?.finish(!1),[]),(0,x.useEffect)(()=>s.subscribe(({selection:E})=>{const L=p.getState().pressedObservation,[B,...F]=E,O=B!==void 0&&F.length===0&&L!==null&&(0,d.areEditTargetsEqual)(B,L.selectedFor);L!==null&&!O&&p.getState().setPressedObservation(null)}),[p,s]),(0,x.useEffect)(()=>{const E=j=>jn({target:j.target,clientX:j.clientX,clientY:j.clientY},n()).targetAtPoint,L=j=>{if(!(j.target instanceof Element))return!1;const C=j.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return C!==null&&e.contains(C)&&c.readStampedEditTargetInStack([j.target],e)===null},B=(j,C)=>{if(I.current!==null||!c.canMoveAnnotationOnCanvas(A.current.spec,C.id))return;try{e.setPointerCapture(j.pointerId)}catch{return}j.preventDefault();const R=new _g({handle:e,pointerId:j.pointerId,annotationId:C.id,press:{x:j.clientX,y:j.clientY},readInputs:()=>A.current,editorStore:p,engine:h,anchorResolver:u,dispatch:a.dispatch,onSettled:()=>{I.current=null}});I.current=R,R.start()},F=(j,C)=>{const R=s.getState(),{layers:G,config:N,coordSystem:Y}=l.getState().scene,Z=C.kind==="select-observations"&&C.observationIndex!==null?c.readPressedObservation(C.observationIndex,G,C.target,N.parsingLocale):null;if(p.getState().setPressedObservation(Z),k.current&&(C.kind==="select-observations"||C.kind==="select-band")){const D=(0,d.findLayerById)(G,C.target.layerId);if(D!==void 0&&Cm(D.geom,Y.type)){const $=e.getBoundingClientRect(),W=Xn(e,$.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(C.target),x:(j.clientX-$.left)/W,y:(j.clientY-$.top)/W})}else p.getState().setAnnotatePress(null)}switch(C.kind){case"select-annotation":R.setSelection([C.target]),B(j,C.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([C.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(C)}`})}},O=j=>{if(j.button!==0)return;if(hs(j.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(sn(j.target))return;const C=p.getState().caret?.annotationId??null,R=j.target instanceof Element?j.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Me(j.target)&&R!==C&&Zn(p,l.getState().scene.annotations,a.dispatch,Yn(i));const G=p.getState().standingInteraction,N=U=>{p.getState().releaseInteraction(U),p.getState().setPlotMenu(null),s.getState().clearSelection()},Y=me(A.current.panelRect,A.current.frameElement),Z=U=>{const q=e.getBoundingClientRect();return U.x<q.left||U.x>q.right||U.y<q.top||U.y>q.bottom};if(G?.kind==="arrow-draw"){const U=n(),q=U.captureRect?.getBoundingClientRect()??null,le={x:j.clientX,y:j.clientY};if(Z(le)){N("arrow-draw");return}const ie=c.readArrowEnd({client:le,capture:q,bounds:Y,engine:U.engine,layers:U.scene.layers,start:G.start});if(ie===null)return;a.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(G.heads),start:{anchorType:"panel",x:G.start.x,y:G.start.y},end:ie}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(G?.kind==="box-draw"){const U=n().captureRect?.getBoundingClientRect()??null,q={x:j.clientX,y:j.clientY};if(Z(q)){N("box-draw");return}const le=c.readDrawnPanelPoint(q,U,Y);if(le===null||U===null||c.isTinySpan(G.start,le,U))return;a.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(G.start,le)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),L(j)||c.isOnLiveGeomMark(j.target,e))return;const D=n(),$=jn({target:j.target,clientX:j.clientX,clientY:j.clientY},D);if(w.current){const U=To(j,e,$.elements),q=U===null?null:D1(l.getState().scene,U);if(q?.observationIndex!==void 0){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q,observationIndex:q.observationIndex});return}}const W=j.target instanceof Node&&e.contains(j.target),X=z1($.targetAtPoint,{canSelectGraph:y.current&&!Me(j.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const be=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(U=>U.id===X.target.id);if((X.kind==="clear"||be)&&k.current){const U=n();if(j.target===U.captureRect){const q=O1({client:{x:j.clientX,y:j.clientY},capture:U.captureRect?.getBoundingClientRect()??null,engine:U.engine,layers:U.scene.layers,parsingLocale:U.scene.config.parsingLocale,hasMenu:U.hasOverlayMenu});if(q!==null){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q.target,observationIndex:q.observationIndex});return}}}const Oe=D.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(W&&(X.kind==="clear"||Oe)&&w.current&&To(j,e,$.elements)===null&&!W1(j.target,$.elements)){const U=G1({client:{x:j.clientX,y:j.clientY},capture:D.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:D.engine,layers:D.scene.layers});if(U!==null){p.getState().setCaret(null),F(j,{kind:"clear"}),p.getState().setPlotMenu(U);return}}p.getState().setCaret(null),F(j,X)},P=j=>{if(sn(j.target)||L(j)||c.isOnLiveGeomMark(j.target,e))return;const C=E(j),{layers:R,guides:G,config:N}=l.getState().scene,{hasOverlayMenu:Y}=n(),Z=s.getState(),D=p.getState();switch(C?.kind){case"observations":{const{observations:$}=C,W=E1($,R,N.parsingLocale);if(W===null||!Y(W))return;const{observationIndex:X}=$;D.setPressedObservation({observationIndex:X,predicate:W.predicate,selectedFor:W}),Z.setSelection([W]);return}case"axis":case"legend":{const $=T1(C,{layers:R,legends:G.legends.drawn,formattedAxes:T.current,parsingLocale:N.parsingLocale});if($===null||!Y($))return;Z.setSelection([$]);return}case"annotation":{const{target:$}=C;if(!A.current.spec.textAnnotations.some(W=>W.id===$.id))return;Z.setSelection([$]),D.setCaret($.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",O),document.addEventListener("dblclick",P),()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("dblclick",P)}},[e,p,s,l,a,i,A,T,y,k,w,n,h,u])},W1=(e,t)=>Me(e)||Lo(e)||t.some(Lo),Lo=e=>e instanceof Element&&e.closest(V1)!==null,U1=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=Re(),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])},q1={kind:"idle"},K1=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Ip();return(0,x.useMemo)(()=>e!==null?e:t===null?q1:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},X1=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Y1=(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,b=l.current,S={x:v.clientX-b.x,y:v.clientY-b.y},y=X1(S,f)?i.query((0,d.toPanelCursor)(S,f)):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=>{sn(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])},Z1=(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(ut(k.standingInteraction))return;if(u&&(u=!1,l={...l,target:J1(l)}),c.isOnLiveGeomMark(l.target,e)){k.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:A}=jn(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()},b=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((k,w)=>{ut(w.standingInteraction)&&!ut(k.standingInteraction)&&g()}),y=o.subscribe((k,w)=>{k.scene!==w.scene&&(ut(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),S(),y(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",b),v()}},[e,n,o,a,i,t])},J1=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ut=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}},Q1=(e,t,n,o,a)=>{const i=K1(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=U1(e);Z1(e,h),$1(e,n,h,a),Y1(i,t,n),j1(e),$0(e),w1(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])},ef=({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=()=>{Zn(h,l.getState().scene.annotations,s.dispatch,Yn(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 y=v.current;v.current={width:m,height:g},!(y.width===m&&y.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const f=c.useEditorState(y=>y.caret?.annotationId??null),b=c.useGraphMode(),S=(0,x.useRef)(b);return(0,x.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,x.useEffect)(()=>()=>{p.current();const y=h.getState();y.setCaret(null),y.setPressedObservation(null),y.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,x.useEffect)(()=>{if(S.current===b)return;S.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)(ul,{children:[f!==null&&(0,r.jsx)(tf,{annotationId:f,panelRect:t}),(0,r.jsx)(nf,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},tf=({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},nf=({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 Q1(e,a,n,i,o),(0,r.jsx)(rf,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},rf=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=Mt(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Jp,{frameElement:e,frameSize:(0,x.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(Nm,{frameRect:t}),(0,r.jsx)(L0,{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)(Tv,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(Wv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Vg,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(u1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Wm,{panelRect:o}),(0,r.jsx)(Iv,{frameElement:e,panelRect:o}),(0,r.jsx)(Ev,{panelRect:o}),(0,r.jsx)(og,{panelRect:o}),(0,r.jsx)($m,{panelRect:o}),(0,r.jsx)(eg,{panelRect:o})]}),(0,r.jsx)(Om,{frameElement:e}),s&&(0,r.jsx)(sp,{frameElement:e,panelRect:o}),(0,r.jsx)(x1,{})]})})]})},of={},af=({slots:e,palettePresets:t=of,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,x.useMemo)(()=>({EditorSurface:ef,...e}),[e]);return(0,r.jsx)(Vn,{...a,children:(0,r.jsx)(Vu,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(Sd,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:k0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},sf="_12lhx9e0",ps=({children:e})=>(0,r.jsx)("div",{className:sf,children:e}),lf="_139ohwv0",oe=({children:e})=>(0,r.jsx)("div",{className:lf,children:e}),ms=(0,x.createContext)(null),cf=ms.Provider,gs=()=>{const e=(0,x.useContext)(ms);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},df="_1jlczkt0",vs="data-graphy-editor-panel",uf={List:oe,Grid:ps};function hf(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var pf=()=>()=>{},mf=e=>{const t=(0,x.useSyncExternalStore)(e?.subscribe??pf,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},gf=e=>{const t=(0,x.useContext)(c.GraphContext),n=c.useChartI18nProps(mf(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(vf,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(Vn,{...n,children:a})},ar={Root:gf,Controls:uf},vf=({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)(Rt.Provider,{value:i,children:(0,r.jsx)(fa,{controls:n,children:(0,r.jsx)(cf,{value:p,children:(0,r.jsx)(Ge.Accordion.Root,{[vs]:"",className:(0,ge.default)(df,a,{[s]:!hf(a)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},ff="_2m7wuq0",xf=()=>(0,r.jsx)(Hs.Separator,{className:ff}),bf=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"})})}),ir="_40zvwv0",sr="_40zvwv1",yf="_40zvwv2",fs="_40zvwv3",Sf="_40zvwv4 _40zvwv3";var Cf="_40zvwv6";var wf="_40zvwv8",Q=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(Tf,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(jf,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:ir,children:[(0,r.jsxs)("div",{className:sr,children:[(0,r.jsx)("span",{className:fs,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})]}),jf=({title:e,accessory:t,children:n})=>{const o=(0,x.useId)(),a=(0,x.useId)();return(0,r.jsx)("div",{className:ir,children:(0,r.jsxs)("div",{className:sr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:Sf,children:e}),(0,r.jsx)("span",{className:Cf,children:(0,r.jsx)(Xo,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Tf=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ge.Accordion.Item,{value:e,className:ir,onOpenChange:o,children:[(0,r.jsxs)(Ge.Accordion.Header,{className:sr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ge.Accordion.Trigger,{className:yf,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:fs,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:wf,children:(0,r.jsx)(bf,{size:"sm"})})]}),(0,r.jsx)(Ge.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},xs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=gs(),{Switch:u}=H(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(Q,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:o,ariaLabel:e}),children:i})},Af={horizontal:["bottom","top"],vertical:["left","right"]},kf={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},Pf={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},gt=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:u,Switch:h,TextField:p,ToggleGroup:m}=H();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const g=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,v=i.scales[e],f=v?.spec,b=f?.scaleType==="continuous"?f:void 0,S=f?.scaleType==="datetime",y=f?.scaleType==="continuous"||S?f:void 0;if(g==="circular"||g==="radial"&&b===void 0)return null;const k=f?.scaleType==="continuous"||f?.scaleType==="datetime",w=b!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),A=b?.transform==="log",T=y?.domainMax??null,I=Lf(y),E=(_,re)=>_.map(et=>({value:et,label:re(et)})),L=i.guides.axes.find(_=>_.scaledAesthetic===e);if(L===void 0)return null;const B=L.position,F=i.guides.axes.filter(_=>_.scaledAesthetic===e),O=F.some(_=>_.visible),P=F.some(_=>_.visible||_.showGrid),j=e==="ySecondary"?i.config.axes.ySecondary?.label??L.label??"":i.config.axes[e].label??L.label??"",C=Af[B==="bottom"||B==="top"?"horizontal":"vertical"],R=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,G=R===null?void 0:(0,d.findLayerById)(i.spec.layers,R),N=i.guides.legends.drawn.some(_=>!_.inHeadlineRow&&C.some(re=>re===_.position)),Y=C.map(_=>({value:_,label:s(kf[_])})),Z=E(["auto","edges"],_=>s(_==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),D=E(["linear","log"],_=>s(_==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),$=E(S?["auto","custom"]:["auto","zero","custom"],_=>s(_==="zero"?"editor.axesPanel.startFrom.zero":_==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),W=E(["auto","custom"],_=>s(_==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),X=E(["single","double"],_=>s(_==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),be=_=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.visible)}));return}a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},Oe=_=>{a.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:_}),{transient:!0})},U=_=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},q=_=>{const re=_==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:rn(re,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:re,keepSecondaryAxis:!0}))},le=_=>{a.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:_==="log"?"log":"linear"}))},ie=_=>{a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,..._}),{transient:!0})},_e=_=>{_!==null&&ie({domainMin:_})},$t=_=>{_!==null&&ie({domainMax:_})},je=_=>{const re=bs(_);re!==null&&ie({domainMax:re})},Qe=_=>{if(_==="auto"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(_==="zero"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const re=Io(v?.domain,"start");re!==null&&a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:re}))},z=_=>{if(_!=="custom"){a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const re=Io(v?.domain,"end");re!==null&&a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:re}))},J=_=>{G!==void 0&&a.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:G.id,yScaleType:_==="double"?"secondary":"primary"}))},he=_=>{if(e==="ySecondary")return;const re=C.find(et=>et===_);re&&a.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:re}))};return(0,r.jsx)(Q,{title:t??s(Pf[e]),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(h,{checked:L.visible,onChange:be})}),G!==void 0&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(m,{value:G.yScaleType==="secondary"?"double":"single",options:X,onChange:J})}),g==="linear"&&(0,r.jsxs)(r.Fragment,{children:[L.visible&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:j,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:Oe,onCommit:a.commands.commit})}),O&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(h,{checked:L.showTicks,onChange:U})})]}),k&&P&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(m,{value:L.tickMode,options:Z,onChange:q})}),e!=="ySecondary"&&b&&g==="linear"&&L.visible&&!N&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(m,{value:L.position,options:Y,onChange:he})}),b&&!w&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(m,{value:A?"log":"linear",options:D,onChange:le})}),y&&!A&&(0,r.jsxs)(r.Fragment,{children:[!w&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(m,{value:I,options:$,onChange:Qe})}),I!=="auto"&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:Gt(y.domainMin??null),onChange:_e,onCommit:a.commands.commit}):(0,r.jsx)(u,{value:y.domainMin??null,onChange:_e,onCommit:a.commands.commit})})]}),(0,r.jsx)(M,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(m,{value:T===null?"auto":"custom",options:W,onChange:z})}),T!==null&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:If(T),onChange:je,onCommit:a.commands.commit}):(0,r.jsx)(u,{value:T,onChange:$t,onCommit:a.commands.commit})})]})]})})},rn=(e,t)=>e===t?void 0:e,Lf=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Io=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?Gt(n.getTime()):bs(n.getTime()):typeof n=="number"?n:null},Gt=e=>{if(e===null||!Number.isFinite(e))return null;const t=new Date(e).toISOString().slice(0,10),n=Date.parse(`${t}T00:00:00.000Z`);return Number.isNaN(n)?null:n},bs=e=>{const t=Gt(e);return t===null?null:t+864e5},If=e=>e===null||!Number.isFinite(e)?null:Gt(e-1),lr=({value:e,onChange:t})=>{const n=K(),o=c.useI18n(),{TextField:a}=H(),i=e!==null&&typeof e!="string"?ys(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",u=h=>{if(h==="")return t(null);t(i?i.write(h):h)};return(0,r.jsx)(M,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:u,onCommit:n.commands.commit,disabled:s})})},ys=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?ys(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},Ss=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(lr,{value:l.caption,onChange:h})]})})},Eo=/^[a-z][a-z\d+.-]*:/i,Ef={},Cs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(Mf,{source:l.source??Ef})]})})},Mf=({source:e})=>{const t=K(),n=c.useI18n(),{TextField:o}=H(),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!==""&&!Eo.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)(M,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:Eo.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(M,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},ws=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(lr,{value:l.subtitle,onChange:h})]})})},Je=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])},cr=(e,t,n)=>{const o=Je(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])},Tn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Rf=Tn.length/2,Of={select:{target:"graph"}},js=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=H(),l=Je(a);if(!a||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Tn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=Tn.find(b=>`${b}`===g);if(v===void 0)return;const f=(0,d.findStyleRule)(a.spec.styles.overrides,Of,(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)(Q,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:Rf,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},Ts=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=H();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)(Q,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(lr,{value:l.title,onChange:h})]})})},_f=({children:e,...t})=>(0,r.jsx)(ar.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ts,{}),(0,r.jsx)(ws,{}),(0,r.jsx)(Ss,{}),(0,r.jsx)(Cs,{}),(0,r.jsx)(js,{})]})}),Nf=({children:e,...t})=>(0,r.jsx)(ar.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{axis:"x"}),(0,r.jsx)(gt,{axis:"y"}),(0,r.jsx)(gt,{axis:"ySecondary"})]})}),zt=e=>`${e}px`,As=e=>`${Math.round(e*100)}%`,Df=e=>`${e}°`,Ff=24,Bf={select:{target:"graph"}},Mo=["dim","desaturate"],Gf=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=Je(a);if(!a||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(a.spec),m=Mo.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const b=(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:{...b,cornerRadius:f}}}),{transient:!0})},v=f=>{const b=Mo.find(S=>S===f);b&&o.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(Q,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Ff,step:1,formatValue:zt,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},zf={none:0,md:3.5,full:6.5},Hf=({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:zf[e],stroke:"currentColor",strokeWidth:1.5})}),Vf=.05,Ro=["none","md","full"],ks={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},$f=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=a?(0,d.findLayerByGeom)(a.spec.layers,"bar"):void 0,h=cr(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,S)=>{const y=Ro.find(A=>A===S);if(!y)return;const[k,w]=ks[b];o.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[k]:y,[w]:y}}))},v=Ro.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(Hf,{cornerRadius:b})})),f=(0,d.resolveBarBandFraction)(u.params,a.coordSystem.type);return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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:Vf,formatValue:As,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:Oo(m,"tip"),options:v,onChange:b=>g("tip",b)})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:Oo(m,"base"),options:v,onChange:b=>g("base",b)})})]})})},Oo=(e,t)=>{const[n,o]=ks[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},Ht=({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"})]})})]})},Vt="qdaoth0",Wf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Uf=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Ht,{children:[(0,r.jsx)("path",{className:Vt,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"})]})}),qf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Kf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),Xf={x:.5,y:.5},Yf=.2,Zf={x:.375,y:.25,width:.25,height:.5},Jf={zOrder:"background"},Qf={x:.4,y:.6},ex={x:.6,y:.4},tx="relativeDifference",nx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=H();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",...Xf},width:Yf}}))},u=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...Qf},end:{anchorType:"panel",...ex}}}))},h=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Jf,region:{anchorType:"panel",...Zf}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:tx}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(Q,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ps,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Kf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Wf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Uf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(qf,{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=K(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=H();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)(Q,{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")})})},ax=.1,ix=20,sx=({title:e,preview:t})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=H();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 b=new d.ToggleGoalLineCommand({showGoalLine:f,value:lx(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(b)},g=f=>{if(l===void 0)return;const b=new d.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(b,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const b=new d.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(xs,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{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")})})]})})},lx=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(ix,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*ax).toFixed(i))},_o=["auto","inside","outside"],cx=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:u}=H();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,b=ya(h,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const S=T=>{const I=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});a.commands.dispatch(I)},y=T=>{const I=_o.find(E=>E===T);I!==void 0&&a.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:I}))},k=T=>{const I=new d.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});a.commands.dispatch(I)},w=T=>{const I=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});a.commands.dispatch(I)},A=T=>{const I=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});a.commands.dispatch(I)};return(0,r.jsx)(Q,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),b.supportsPosition&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:f,options:_o.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:y})}),b.supportsPercentages&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:k})}),b.supportsStackTotals&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:A})})]})})},dx=3,ux=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=H(),l=(0,x.useMemo)(()=>Ve.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!wa(v,a?.spec)})),[i,a]);if(!a)return null;const u=(0,d.readGraphType)(a.spec),h=St(u),p=m=>{const g=Ve.find(v=>v.name===m);g&&o.commands.dispatch(new d.SetGraphTypeCommand(ja(g.summary,u)))};return(0,r.jsx)(Q,{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:dx,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},hx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=H(),h=Je(a),p=a!==null&&h!==null?Na(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=jt.map(y=>({value:y,label:i(`editor.graphPanel.gridSection.lineStyles.${y}`)})),f=y=>k=>{o.commands.dispatch(new d.SetGridVisibilityCommand({axis:y,visible:k}))},b=y=>{const k=jt.find(w=>w===y);k!==void 0&&o.commands.dispatch(Da(k))},S=y=>{o.commands.dispatch(Fa(y),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[m.map(y=>(0,r.jsx)(M,{label:i(px(y)),children:(0,r.jsx)(l,{checked:y.showGrid,onChange:f(y.scaledAesthetic)})},y.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:b})}),(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:zt,onChange:S,onCommit:o.commands.commit})})]})]})})},px=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",mx="total",Ps=["total","average","current"],gx=["total"],No=["previous","first"],Do=["auto","small","medium","large"],vx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=H();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(F=>F.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?gx:Ps,b=a.guides.headline,S=b?.kind==="perGroup"&&b.items.some(F=>F.comparison!==null),y=f.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.metrics.${F}`)})),k=No.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.comparison.${F}`)})),w=Do.map(F=>({value:F,label:i(F==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${F}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=F=>{o.commands.dispatch(new d.SetHeadlineShowCommand({show:F?mx:"none"}))},I=F=>{const O=f.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineShowCommand({show:O}))},E=F=>{const O=No.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:O}))},L=F=>{const O=Do.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineSizeCommand({size:O}))},B=F=>{o.commands.dispatch(new d.SetHeadlinePositionCommand({position:F==="center"?"center":"above"}))};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??fx(i,u.show),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:y,onChange:I})}),S&&(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:k,onChange:E})}),(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:w,onChange:L})}),g&&(0,r.jsx)(M,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:A,onChange:B})})]})]})})},fx=(e,t)=>{const n=Ps.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var on=["top","bottom","left","right","none"],Fo=["auto","start","center","end"],xx={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Bo=["auto","pill","direct"],bx=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=H(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??on,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 b=m?.position??"none",S=h==="auto"?b:h,y=on.filter(j=>j===S||p.includes(j)).map(j=>({value:j,label:s(`editor.graphPanel.legendSection.${j}`)})),k=j=>{const C=on.find(R=>R===j);C&&a.commands.dispatch(new d.SetLegendPositionCommand({position:C}))},w=j=>{const C=Fo.find(R=>R===j);C&&a.commands.dispatch(new d.SetLegendAlignCommand({align:C}))},A=j=>{const C=Bo.find(R=>R===j);C&&a.commands.dispatch(new d.SetLegendDisplayCommand({display:C}))},T=m?.position==="left"||m?.position==="right"?"column":"row",I=T==="row"?"ltr":u,E=j=>s(j==="start"||j==="end"?`editor.graphPanel.legendSection.${xx[T][j]}`:`editor.graphPanel.legendSection.align.${j}`),L=Fo.map(j=>({value:j,label:E(j)})),B=Bo.map(j=>({value:j,label:s(`editor.graphPanel.legendSection.display.${j}`)})),F=t??s("editor.graphPanel.legendSection.title"),O=y.find(j=>j.value===S)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(Q,{title:F,layout:n,preview:o??O,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:y,onChange:k})}),P&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Ln.DirectionProvider,{direction:I,children:(0,r.jsx)("div",{dir:I,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:L,onChange:w})})})}),g&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},yx=1,Sx=20,Cx=.5,Ls=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),{Slider:o}=H(),a=cr(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:Sx,step:Cx,formatValue:zt,onChange:l,onCommit:t.commands.commit})},Is=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),o=cr(n,e,"point");return n?(0,r.jsx)(Nn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},wx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=H(),p=Je(a),m=(0,d.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?_n(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(T=>({value:T,label:Sa(i,T)})),f=[{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}))},S=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"}))},k=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})},A=T=>{const I=cn.find(E=>E===T);I&&o.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:I}))};return(0,r.jsx)(Q,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(M,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(Ls,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(Is,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:S})}),g.smooth!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:y})}),(0,r.jsx)(M,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:f,onChange:k})}),g.widthMode==="custom"&&(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:zt,onChange:w,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(M,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:A})})]})})},An="\0none",jx=["x","y","color","size","label"],Tx={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"},Ax=({title:e,layout:t="collapsible"})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=H(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,u=(0,x.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,jx).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:a(Tx[h]),value:g??(m?null:An),options:kx(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===An?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(Q,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(oe,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(M,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},kx=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:An,label:n}],...o.map(a=>({value:a,label:a}))]},Px="k",Lx=2,Ix=0,Ex=5,kn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Mx=["auto","none"],Rx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=H();if(!a)return null;const{abbreviation:u,decimals:h}=a.config.numberFormat,p=Ox(u)!==void 0,m=h!=="auto",g=w=>w.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),v=kn.map(({value:w,labelKey:A})=>({value:w,label:i(`common.abbreviations.${A}`)})),f=w=>{o.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const A=Mx.find(T=>T===w);f(A??Px)},S=w=>{const A=kn.find(T=>T.value===w);A&&f(A.value)},y=w=>{o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w==="custom"?Lx:"auto"}))},k=w=>{w!==null&&o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:S})}),(0,r.jsx)(M,{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)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:Ix,max:Ex,onChange:k,onCommit:o.commands.commit})})]})})},Ox=e=>kn.find(t=>t.value===e),_x=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(K()),a=c.useI18n();if(!o)return null;const i=Nx(o.spec.layers);return i?(0,r.jsx)(Q,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(Ls,{layerId:i.id})}),(0,r.jsx)(Is,{layerId:i.id})]})}):null},Nx=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},Dx=.9,Fx=360,Bx=.05,Gx=15,zx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=H();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)(Q,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:Dx,step:Bx,formatValue:As,onChange:h,onCommit:o.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:Fx-1,step:Gx,formatValue:Df,onChange:p,onCommit:o.commands.commit})})]})})},Hx=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"})]}),Go=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"})]}),zo=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],Vx="linear",$x=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=H(),{options:u,findValue:h}=Nt(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:Vx,v=Wx(m),f=zo.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),b=(A,T={})=>{const I=p??m,E=new d.SetStatLineCommand({line:A,...T,...I!==void 0&&{layerId:I.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(E)},S=A=>b(A?"trend":"none",{method:g}),y=A=>b(A?"average":"none",{group:v??h(u[0]?.value??"")}),k=A=>{const T=zo.find(I=>I===A);T!==void 0&&b("trend",{method:T})},w=A=>{const T=A===null?void 0:h(A);T!==void 0&&b("average",{group:T})};return(0,r.jsx)(Q,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Go,{size:"lg"}),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Go,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(M,{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)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(Hx,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:y})}),m!==void 0&&u.length>0&&(0,r.jsx)(M,{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")})})]})})},Wx=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Gf;exports.AxesPanel=Nf;exports.AxisEditMenu=Rn;exports.AxisSection=gt;exports.BarEditMenu=On;exports.BarSection=$f;exports.Button=Jo;exports.CalloutsSection=nx;exports.CaptionSection=Ss;exports.ChartEditMenu=Fn;exports.ColorRow=ve;exports.ColorSwatches=na;exports.ComboSection=ox;exports.ControlRegistryProvider=fa;exports.ControlTooltip=ye;exports.CustomColor=oa;exports.DateField=aa;exports.EditableGraphRenderer=af;exports.EditorIntlProvider=Vn;exports.EditorPanel=ar;exports.ElementsPanel=_f;exports.FileInput=ia;exports.GoalSection=sx;exports.GraphOptionsSection=cx;exports.GraphTypeSection=ux;exports.GridEditMenu=Bn;exports.GridSection=hx;exports.HeadlineSection=vx;exports.LegendEditMenu=Ba;exports.LegendSection=bx;exports.LineEditMenu=Tt;exports.LineSection=wx;exports.MappingSection=Ax;exports.NumberField=la;exports.NumberFormatSection=Rx;exports.PANEL_ROOT_ATTRIBUTE=vs;exports.PaletteRow=Ra;exports.PointEditMenu=zn;exports.PointSection=_x;exports.PolarSection=zx;exports.RadioGrid=ca;exports.Row=M;exports.Section=Q;exports.Select=ua;exports.Separator=xf;exports.Slider=ha;exports.SourceSection=Cs;exports.Stepper=pa;exports.SubtitleSection=ws;exports.Switch=ma;exports.TextField=ga;exports.TextSizeSection=js;exports.TitleSection=Ts;exports.ToggleGroup=Mn;exports.ToggledSection=xs;exports.TrendsAndAveragesSection=$x;exports.useAnnotateAnchor=qo;exports.useControls=H;exports.usePanelExpansion=gs;exports.usePanelGraph=K;
|