{"version":3,"file":"index.mjs","names":["React","getElementByPropGiven","_myRef","myRef","ref","xStr2absRelative","str","sp","absLen","percentLen","p","p1","p2","dist","getShortestLine","minDist","d","closestPair","sPoints","ePoints","ep","getElemPos","elem","pos","getSvgPos","svgRef","xarrowElemX","xarrowElemY","xarrowStyle","xarrowStyleLeft","xarrowStyleTop","getTotalLength","SAME_POINT_EPSILON","polylinePath","points","i","q","move","radius","prev","corner","next","dPrev","dNext","r","last","cAnchorEdge","cPaths","cSvgElems","arrowShapes","cArrowShapes","_typeof","o","toPrimitive","t","e","toPropertyKey","_defineProperty","ownKeys","_objectSpread2","parseLabels","parsedLabel","label","labels","key","_labels$key","parseAnchor","anchorChoice2","anchor","anchorChoice","an","autosAncs","anchorObj","anchorName","anchorChoiceCustom","parseDashness","dashStroke","dashNone","animDashSpeed","dashness","_dashness$nonStrokeLe","props","parseEdgeShape","shape","svgEdge","\"arrow1\"","parseGridBreak","resGridBreak","gridBreak","withUpdate","updateRef","propVal","noParse","userProp","noParseWithUpdatePos","updatePos","parseNumWithUpdatePos","parsePropsFuncs","propsRefs","propsDeps","propName","parseGivenProps","name","_parsePropsFuncs$name","propsRef","defaultProps","createInitialParsedProps","initialValVars","samePosition","a","b","useXarrowProps","setPropsRefs","useState","shouldUpdatePosition","useRef","\"shouldUpdatePosition\"","curProps","userProps","_parsePropsFuncs$prop","valVars","setValVars","useLayoutEffect","startPos","endPos","XelemContext","XarrowContext","updateRefCount","XarrowProvider","setRender","updateXarrow","useEffect","instanceCount","children","XelemProvider","Xwrapper","getAnchorsDefaultOffsets","width","height","calcAnchors","anchors","anchorPos","x","y","bzFunction","p3","p4","buzzierMinSols","bz","A","B","C","getPosition","xProps","path","mainRef","headOrient","tailOrient","startPoints","startAnchor","endPoints","endAnchor","startAnchorPosition","chosenStart","endAnchorPosition","chosenEnd","startPoint","endPoint","mainDivPos","cx0","cy0","dx","dy","absDx","absDy","xSign","ySign","headOffset","tailOffset","headShape","tailShape","fHeadSize","headSize","strokeWidth","fTailSize","tailSize","xHeadOffset","yHeadOffset","xTailOffset","yTailOffset","_headOffset","_tailOffset","cu","curveness","_calc","excRight","excLeft","excUp","excDown","_extendSVGcanvas","x1","x2","y1","y2","headAngel","showHead","tailAngel","showTail","arrowHeadOffset","arrowTailOffset","cpx1","cpy1","cpx2","cpy2","curvesPossibilities","middleAxis","axisOf","position","selectedCurviness","_cpx1Offset","_cpy1Offset","_cpx2Offset","_cpy2Offset","xSol1","xSol2","ySol1","ySol2","cw","ch","bzx","bzy","labelStartPos","labelMiddlePos","labelEndPos","arrowPath","gridRadius","lineRef","Xarrow","animateDrawing","drawAnimEnded","setDrawAnimEnded","forceRerender","st","setSt","xOffsetHead","yOffsetHead","xOffsetTail","yOffsetTail","dashoffset","animDirection","dashArray","animation","animRepeatCount","animStartValue","animEndValue","prevSt","cleanMonitorDOMchanges","handleDrawAmimEnd","_headOpacityAnimRef$c","_lineDashAnimRef$curr","headOpacityAnimRef","lineDashAnimRef","lineDrawAnimRef","showXarrow","divContainerProps","divContainerStyle","_debug","SVGcanvasStyle","SVGcanvasProps","lineColor","passProps","arrowBodyProps","tailColor","arrowTailProps","headRef","headColor","arrowHeadProps","noop","useXarrow","reRender","useContext"],"sources":["../src/Xarrow/utils/index.ts","../src/constants.tsx","../src/Xarrow/useXarrowProps.ts","../src/Xwrapper.tsx","../src/Xarrow/anchors.ts","../src/Xarrow/utils/buzzier.js","../src/Xarrow/utils/GetPosition.tsx","../src/Xarrow/Xarrow.tsx","../src/useXarrow.tsx"],"sourcesContent":["import { refType } from '../../types';\nimport { parsedAnchorType } from '../../privateTypes';\nimport React from 'react';\n\nexport type point = { x: number; y: number };\n\nexport const getElementByPropGiven = (ref: refType): Element | null => {\n  let myRef;\n  if (typeof ref === 'string') {\n    // myRef = document.getElementById(ref);\n    myRef = document.getElementById(ref);\n  } else myRef = ref?.current;\n  return myRef ?? null;\n};\n\n// receives string representing a d path and factoring only the numbers\nexport const factorDpathStr = (d: string, factor: number) => {\n  let l = d.split(/(\\d+(?:\\.\\d+)?)/);\n  l = l.map((s) => {\n    if (Number(s)) return (Number(s) * factor).toString();\n    else return s;\n  });\n  return l.join('');\n};\n\n// return relative,abs\nexport const xStr2absRelative = (str: string): { abs: number; relative: number } | undefined => {\n  if (typeof str !== 'string') return { abs: 0, relative: 0.5 };\n  const sp = str.split('%');\n  let absLen = 0,\n    percentLen = 0;\n  if (sp.length == 1) {\n    const p = parseFloat(sp[0]);\n    if (!isNaN(p)) {\n      absLen = p;\n      return { abs: absLen, relative: 0 };\n    }\n  } else if (sp.length == 2) {\n    const [p1, p2] = [parseFloat(sp[0]), parseFloat(sp[1])];\n    if (!isNaN(p1)) percentLen = p1 / 100;\n    if (!isNaN(p2)) absLen = p2;\n    if (!isNaN(p1) || !isNaN(p2)) return { abs: absLen, relative: percentLen };\n  }\n};\n\nconst dist = (p1: point, p2: point) => {\n  //length of line\n  return Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2);\n};\n\ntype t1 = { x: number; y: number; anchor: parsedAnchorType };\n\nexport const getShortestLine = (sPoints: t1[], ePoints: t1[]) => {\n  // closes tPair Of Points which feet to the specified anchors\n  let minDist = Infinity,\n    d = Infinity;\n  // Seeded with the first pair rather than left unassigned: callers destructure\n  // the result, and both lists always hold at least one anchor.\n  let closestPair = { chosenStart: sPoints[0], chosenEnd: ePoints[0] };\n  sPoints.forEach((sp) => {\n    ePoints.forEach((ep) => {\n      d = dist(sp, ep);\n      if (d < minDist) {\n        minDist = d;\n        closestPair = { chosenStart: sp, chosenEnd: ep };\n      }\n    });\n  });\n  return closestPair;\n};\n\nexport const getElemPos = (elem: Element | null) => {\n  if (!elem) return { x: 0, y: 0, right: 0, bottom: 0 };\n  const pos = elem.getBoundingClientRect();\n  return {\n    x: pos.left,\n    y: pos.top,\n    right: pos.right,\n    bottom: pos.bottom,\n  };\n};\n\nexport const getSvgPos = (svgRef: React.MutableRefObject<SVGSVGElement | null>) => {\n  if (!svgRef.current) return { x: 0, y: 0 };\n  const { left: xarrowElemX, top: xarrowElemY } = svgRef.current.getBoundingClientRect();\n  const xarrowStyle = getComputedStyle(svgRef.current);\n  const xarrowStyleLeft = Number(xarrowStyle.left.slice(0, -2));\n  const xarrowStyleTop = Number(xarrowStyle.top.slice(0, -2));\n  return {\n    x: xarrowElemX - xarrowStyleLeft,\n    y: xarrowElemY - xarrowStyleTop,\n  };\n};\n\n/**\n * SVGGeometryElement.getTotalLength is not implemented by every DOM\n * implementation - jsdom and server-side rendering both provide the element\n * without the method. Falling back to 0 keeps the draw animation inert instead\n * of throwing during render.\n */\nexport const getTotalLength = (elem: SVGPathElement | null): number => {\n  if (!elem || typeof elem.getTotalLength !== 'function') return 0;\n  return elem.getTotalLength();\n};\n\nconst SAME_POINT_EPSILON = 1e-6;\n\n/**\n * Builds an SVG path through `points`, rounding every interior corner with a\n * quadratic whose control point is the corner itself.\n *\n * Deliberately vector based rather than special cased per corner orientation.\n * The grid control points are axis aligned only by arithmetic coincidence - the\n * head offset applied to cpx1 and cpx2 cancels out the shift applied to x2 - so\n * comparing coordinates for equality would rest on two independently computed\n * floats matching exactly, and would break outright for anyone using the\n * _cpx1Offset escape hatches.\n */\nexport const polylinePath = (points: point[], radius: number): string => {\n  // Collapse repeated points first. The hv and vh grid paths put the second\n  // control point on top of the end point, and gridBreak \"0%\" puts the first on\n  // top of the start; left in place they become zero length segments and the\n  // corner math divides by zero.\n  const p = points.filter(\n    (q, i) =>\n      i === 0 ||\n      Math.abs(q.x - points[i - 1].x) > SAME_POINT_EPSILON ||\n      Math.abs(q.y - points[i - 1].y) > SAME_POINT_EPSILON,\n  );\n  if (p.length === 0) return '';\n  const move = `M ${p[0].x} ${p[0].y}`;\n  if (!(radius > 0) || p.length < 3)\n    return (\n      move +\n      p\n        .slice(1)\n        .map((q) => ` L ${q.x} ${q.y}`)\n        .join('')\n    );\n\n  let d = move;\n  for (let i = 1; i < p.length - 1; i++) {\n    const [prev, corner, next] = [p[i - 1], p[i], p[i + 1]];\n    const dPrev = Math.sqrt((corner.x - prev.x) ** 2 + (corner.y - prev.y) ** 2);\n    const dNext = Math.sqrt((next.x - corner.x) ** 2 + (next.y - corner.y) ** 2);\n    // Half of the shorter neighbour, so that two corners sharing a segment can\n    // never overshoot into each other and fold the path back on itself.\n    const r = Math.min(radius, dPrev / 2, dNext / 2);\n    if (!(r > 0)) {\n      d += ` L ${corner.x} ${corner.y}`;\n      continue;\n    }\n    d += ` L ${corner.x + ((prev.x - corner.x) / dPrev) * r} ${corner.y + ((prev.y - corner.y) / dPrev) * r}`;\n    d += ` Q ${corner.x} ${corner.y} ${corner.x + ((next.x - corner.x) / dNext) * r} ${\n      corner.y + ((next.y - corner.y) / dNext) * r\n    }`;\n  }\n  const last = p[p.length - 1];\n  return `${d} L ${last.x} ${last.y}`;\n};\n","// constants used for typescript and proptypes definitions\nimport React from 'react';\n\nexport const cAnchorEdge = ['middle', 'left', 'right', 'top', 'bottom', 'auto'] as const;\nexport const cPaths = ['smooth', 'grid', 'straight'] as const;\nexport const cSvgElems = ['circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect'] as const;\n\n//default arrows svgs\nexport const arrowShapes = {\n  arrow1: { svgElem: <path d=\"M 0 0 L 1 0.5 L 0 1 L 0.25 0.5 z\" />, offsetForward: 0.25 },\n  heart: {\n    svgElem: (\n      <path d=\"M 0,0.25 A 0.125,0.125 0,0,1 0.5,0.25 A 0.125,0.125 0,0,1 1,0.25 Q 1,0.625 0.5,1 Q 0,0.625 0,0.25 z\" />\n    ),\n    offsetForward: 0.1,\n  },\n  circle: {\n    svgElem: <circle r={0.5} cx={0.5} cy={0.5} />,\n    offsetForward: 0,\n  },\n} as const;\n\nexport const cArrowShapes = Object.keys(arrowShapes) as Array<keyof typeof arrowShapes>;\n","import React, { useLayoutEffect, useRef, useState } from 'react';\nimport {\n  anchorCustomPositionType,\n  anchorType,\n  labelsType,\n  pathType,\n  svgCustomEdgeType,\n  svgEdgeShapeType,\n  svgElemPropsType,\n  xarrowPropsType,\n} from '../types';\nimport { getElementByPropGiven, getElemPos, xStr2absRelative } from './utils';\nimport { arrowShapes, cAnchorEdge, cArrowShapes } from '../constants';\nimport {\n  anchorEdgeType,\n  dimensionType,\n  parsedAnchorType,\n  parsedEdgeShapeType,\n  parsedLabelsType,\n} from '../privateTypes';\n\nconst parseLabels = (label: xarrowPropsType['labels']): parsedLabelsType => {\n  const parsedLabel: parsedLabelsType = { start: null, middle: null, end: null };\n  if (label) {\n    // isValidElement is not a narrowing guard for this union, so the else\n    // branch still looks like it could hold a JSX element without the cast.\n    if (typeof label === 'string' || React.isValidElement(label)) parsedLabel.middle = label;\n    else {\n      const labels = label as labelsType;\n      // Left as for..in rather than Object.keys: for..in also walks the\n      // prototype chain, and swapping it would quietly stop honouring a labels\n      // object that inherits its keys.\n      for (const key in labels) {\n        parsedLabel[key as keyof labelsType] = labels[key as keyof labelsType] ?? null;\n      }\n    }\n  }\n  return parsedLabel;\n};\n\nconst parseAnchor = (anchor: anchorType) => {\n  // convert to array\n  const anchorChoice = Array.isArray(anchor) ? anchor : [anchor];\n\n  //convert to array of objects\n  let anchorChoice2 = anchorChoice.map((anchorChoice) => {\n    if (typeof anchorChoice === 'string') {\n      return { position: anchorChoice };\n    } else return anchorChoice;\n  });\n\n  //remove any invalid anchor names\n  anchorChoice2 = anchorChoice2.filter((an) => cAnchorEdge.includes(an.position));\n  if (anchorChoice2.length == 0) anchorChoice2 = [{ position: 'auto' }];\n\n  //replace any 'auto' with ['left','right','bottom','top']\n  const autosAncs = anchorChoice2.filter((an) => an.position === 'auto');\n  if (autosAncs.length > 0) {\n    anchorChoice2 = anchorChoice2.filter((an) => an.position !== 'auto');\n    anchorChoice2.push(\n      ...autosAncs.flatMap((anchorObj) => {\n        return (['left', 'right', 'top', 'bottom'] as anchorEdgeType[]).map((anchorName) => {\n          return { ...anchorObj, position: anchorName };\n        });\n      }),\n    );\n  }\n\n  // default values\n  const anchorChoice3 = anchorChoice2.map((anchorChoice) => {\n    if (typeof anchorChoice === 'object') {\n      let anchorChoiceCustom = anchorChoice as anchorCustomPositionType;\n      if (!anchorChoiceCustom.position) anchorChoiceCustom.position = 'auto';\n      if (!anchorChoiceCustom.offset) anchorChoiceCustom.offset = { x: 0, y: 0 };\n      if (!anchorChoiceCustom.offset.y) anchorChoiceCustom.offset.y = 0;\n      if (!anchorChoiceCustom.offset.x) anchorChoiceCustom.offset.x = 0;\n      anchorChoiceCustom = anchorChoiceCustom as Required<anchorCustomPositionType>;\n      return anchorChoiceCustom;\n    } else return anchorChoice;\n  }) as Required<anchorCustomPositionType>[];\n\n  return anchorChoice3 as parsedAnchorType[];\n};\n\nconst parseDashness = (dashness: xarrowPropsType['dashness'], props: { strokeWidth: number }) => {\n  let dashStroke = 0,\n    dashNone = 0,\n    animDashSpeed: number | null = null;\n  const animDirection = 1;\n  if (typeof dashness === 'object') {\n    dashStroke = dashness.strokeLen || props.strokeWidth * 2;\n    // nonStrokeLen is optional, and used to be passed straight through when\n    // strokeLen was given, rendering a stroke-dasharray of \"<n> undefined\".\n    // Only that fallback is new: `??` keeps an explicit 0, and the outer\n    // condition is left as it was so that no other input changes meaning.\n    dashNone = dashness.strokeLen ? (dashness.nonStrokeLen ?? props.strokeWidth) : props.strokeWidth;\n    // `animation: true` means the documented default of 1s. It used to fall\n    // through as a boolean and only worked because `1 / true` is 1.\n    animDashSpeed = dashness.animation === true ? 1 : dashness.animation || null;\n  } else if (typeof dashness === 'boolean' && dashness) {\n    dashStroke = props.strokeWidth * 2;\n    dashNone = props.strokeWidth;\n    animDashSpeed = null;\n  }\n  return { strokeLen: dashStroke, nonStrokeLen: dashNone, animation: animDashSpeed, animDirection } as {\n    strokeLen: number;\n    nonStrokeLen: number;\n    animation: number;\n  };\n};\n\nconst parseEdgeShape = (svgEdge: svgEdgeShapeType | svgCustomEdgeType): parsedEdgeShapeType => {\n  let shape: Partial<svgCustomEdgeType> | undefined;\n  if (typeof svgEdge == 'string') {\n    if (svgEdge in arrowShapes) shape = arrowShapes[svgEdge as svgEdgeShapeType];\n    else {\n      console.warn(\n        `'${svgEdge}' is not supported arrow shape. the supported arrow shapes is one of ${cArrowShapes}.\n           reverting to default shape.`,\n      );\n      shape = arrowShapes['arrow1'];\n    }\n  } else shape = svgEdge;\n\n  // Returns a new object rather than filling in the one it was handed. For a\n  // shape name that object is the shared arrowShapes constant, and for a custom\n  // shape it is the caller's own, so the old in-place defaulting wrote into\n  // whichever of the two it happened to get.\n  //\n  // Both fields keep the `=== undefined` test the in-place version used, rather\n  // than `??`, so that an explicitly passed null still means what it used to.\n  // Only the svgElem fallback value changes: it was the bare string 'path',\n  // which React renders as the literal text \"path\" rather than an element.\n  return {\n    svgElem: shape?.svgElem === undefined ? arrowShapes.arrow1.svgElem : shape.svgElem,\n    offsetForward: shape?.offsetForward === undefined ? 0.25 : shape.offsetForward,\n  };\n};\n\nconst parseGridBreak = (gridBreak: string): { relative: number; abs: number } => {\n  let resGridBreak = xStr2absRelative(gridBreak);\n  if (!resGridBreak) resGridBreak = { relative: 0.5, abs: 0 };\n  return resGridBreak;\n};\n\n/**\n * should be wrapped with any changed prop that is affecting the points path positioning\n * @param propVal\n * @param updateRef\n */\nconst withUpdate = <T>(propVal: T, updateRef?: updatePosRef): T => {\n  if (updateRef) updateRef.current = true;\n  return propVal;\n};\n\nconst noParse = <T>(userProp: T): T => userProp;\nconst noParseWithUpdatePos = <T>(userProp: T, _: unknown, updatePos?: updatePosRef): T =>\n  withUpdate(userProp, updatePos);\nconst parseNumWithUpdatePos = (userProp: unknown, _: unknown, updatePos?: updatePosRef): number =>\n  withUpdate(Number(userProp), updatePos);\nconst parseNum = (userProp: unknown): number => Number(userProp);\n\ntype updatePosRef = React.MutableRefObject<boolean>;\n\n// Still `any` in and out. Making this generic over the prop name is what ties\n// xarrowPropsType[K] to parsedXarrowProps[K], and it is a large enough change\n// to want its own pass.\ntype ParsePropFunc = (userProp: any, prevProp?: any, updatePos?: updatePosRef) => any;\n\nconst parsePropsFuncs: Required<{ [key in keyof xarrowPropsType]: ParsePropFunc }> = {\n  start: (userProp) => getElementByPropGiven(userProp),\n  end: (userProp) => getElementByPropGiven(userProp),\n  startAnchor: (userProp, _, updatePos) => withUpdate(parseAnchor(userProp), updatePos),\n  endAnchor: (userProp, _, updatePos) => withUpdate(parseAnchor(userProp), updatePos),\n  labels: (userProp) => parseLabels(userProp),\n  color: noParse,\n  lineColor: (userProp, propsRefs) => userProp || propsRefs.color,\n  headColor: (userProp, propsRefs) => userProp || propsRefs.color,\n  tailColor: (userProp, propsRefs) => userProp || propsRefs.color,\n  strokeWidth: parseNumWithUpdatePos,\n  showHead: noParseWithUpdatePos,\n  headSize: parseNumWithUpdatePos,\n  showTail: noParseWithUpdatePos,\n  tailSize: parseNumWithUpdatePos,\n  path: noParseWithUpdatePos,\n  curveness: parseNumWithUpdatePos,\n  gridBreak: (userProp, _, updatePos) => withUpdate(parseGridBreak(userProp), updatePos),\n  // Resolved against strokeWidth in getPosition rather than here, so that this\n  // parser does not depend on strokeWidth having been parsed first.\n  gridRadius: noParseWithUpdatePos,\n  dashness: (userProp, propsRefs) => parseDashness(userProp, propsRefs),\n  headShape: (userProp) => parseEdgeShape(userProp),\n  tailShape: (userProp) => parseEdgeShape(userProp),\n  showXarrow: noParse,\n  animateDrawing: noParse,\n  zIndex: parseNum,\n  passProps: noParse,\n  arrowBodyProps: noParseWithUpdatePos,\n  arrowHeadProps: noParseWithUpdatePos,\n  arrowTailProps: noParseWithUpdatePos,\n  SVGcanvasProps: noParseWithUpdatePos,\n  divContainerProps: noParseWithUpdatePos,\n  divContainerStyle: noParseWithUpdatePos,\n  SVGcanvasStyle: noParseWithUpdatePos,\n  _extendSVGcanvas: noParseWithUpdatePos,\n  _debug: noParseWithUpdatePos,\n  _cpx1Offset: noParseWithUpdatePos,\n  _cpy1Offset: noParseWithUpdatePos,\n  _cpx2Offset: noParseWithUpdatePos,\n  _cpy2Offset: noParseWithUpdatePos,\n};\n\ntype propName = keyof xarrowPropsType;\n\n//build dependencies\nconst propsDeps = {} as Record<propName, propName[]>;\n//each prop depends on himself\nfor (const propName of Object.keys(parsePropsFuncs) as propName[]) {\n  propsDeps[propName] = [propName];\n}\n// 'lineColor', 'headColor', 'tailColor' props also depends on 'color' prop\nfor (const propName of ['lineColor', 'headColor', 'tailColor'] as const) {\n  propsDeps[propName].push('color');\n}\n\n// Only ever called with the defaults table, which carries nulls where a prop\n// has no default.\nconst parseGivenProps = (props: defaultPropsType, propsRef: parsedXarrowProps) => {\n  for (const name of Object.keys(props) as propName[]) {\n    // Correlating the parser's return type with propsRef[name] needs the\n    // generic ParsePropFunc above; until then this write is unchecked.\n    (propsRef as Record<string, unknown>)[name] = parsePropsFuncs?.[name]?.(props[name], propsRef);\n  }\n  return propsRef;\n};\n\n/**\n * Every prop's default. null means \"no default\": start and end are required of\n * the user, and labels are absent until given. Declaring this as\n * Required<xarrowPropsType> claimed those three were always present.\n */\ntype defaultPropsType = { [K in keyof Required<xarrowPropsType>]: Required<xarrowPropsType>[K] | null };\n\nconst defaultProps: defaultPropsType = {\n  start: null,\n  end: null,\n  startAnchor: 'auto',\n  endAnchor: 'auto',\n  labels: null,\n  color: 'CornflowerBlue',\n  lineColor: null,\n  headColor: null,\n  tailColor: null,\n  strokeWidth: 4,\n  showHead: true,\n  headSize: 6,\n  showTail: false,\n  tailSize: 6,\n  path: 'smooth',\n  curveness: 0.8,\n  gridBreak: '50%',\n  gridRadius: false,\n  dashness: false,\n  headShape: 'arrow1',\n  tailShape: 'arrow1',\n  showXarrow: true,\n  animateDrawing: false,\n  zIndex: 0,\n  passProps: {},\n  arrowBodyProps: {},\n  arrowHeadProps: {},\n  arrowTailProps: {},\n  SVGcanvasProps: {},\n  divContainerProps: {},\n  divContainerStyle: {},\n  SVGcanvasStyle: {},\n  _extendSVGcanvas: 0,\n  _debug: false,\n  _cpx1Offset: 0,\n  _cpy1Offset: 0,\n  _cpx2Offset: 0,\n  _cpy2Offset: 0,\n} as const;\n\ntype parsedXarrowProps = {\n  shouldUpdatePosition: React.MutableRefObject<boolean>;\n  start: Element | null;\n  end: Element | null;\n  startAnchor: parsedAnchorType[];\n  endAnchor: parsedAnchorType[];\n  labels: parsedLabelsType;\n  color: string;\n  lineColor: string;\n  headColor: string;\n  tailColor: string;\n  strokeWidth: number;\n  showHead: boolean;\n  headSize: number;\n  showTail: boolean;\n  tailSize: number;\n  path: pathType;\n  showXarrow: boolean;\n  curveness: number;\n  gridBreak: { relative: number; abs: number };\n  gridRadius: boolean | number;\n  dashness: {\n    strokeLen: number;\n    nonStrokeLen: number;\n    animation: number;\n  };\n  headShape: parsedEdgeShapeType;\n  tailShape: parsedEdgeShapeType;\n  animateDrawing: number;\n  zIndex: number;\n  passProps: svgElemPropsType;\n  SVGcanvasProps: React.SVGAttributes<SVGSVGElement>;\n  arrowBodyProps: React.SVGProps<SVGPathElement>;\n  arrowHeadProps: svgElemPropsType;\n  arrowTailProps: svgElemPropsType;\n  divContainerProps: React.HTMLProps<HTMLDivElement>;\n  SVGcanvasStyle: React.CSSProperties;\n  divContainerStyle: React.CSSProperties;\n  _extendSVGcanvas: number;\n  _debug: boolean;\n  _cpx1Offset: number;\n  _cpy1Offset: number;\n  _cpx2Offset: number;\n  _cpy2Offset: number;\n};\n\n/**\n * A fresh object for every hook instance.\n *\n * This used to be a single module-level object, parsed once and then handed to\n * every `useState` call. The hook writes each prop it resolves straight into\n * that object - including the resolved `start`/`end` elements - so the first\n * arrow to mount left its own elements and its own prop values inside the\n * defaults that every arrow mounted afterwards rendered its first frame with.\n * An arrow with default props would paint one frame using the previous arrow's\n * stroke, color and elements before its own effects corrected it.\n */\nconst createInitialParsedProps = (): parsedXarrowProps => parseGivenProps(defaultProps, {} as parsedXarrowProps);\n\nconst initialValVars = {\n  startPos: { x: 0, y: 0, right: 0, bottom: 0 } as dimensionType,\n  endPos: { x: 0, y: 0, right: 0, bottom: 0 } as dimensionType,\n};\n\n// The only values ever compared here are element positions, which getElemPos\n// always returns as four numbers, including on its null-element branch. A\n// general deep-equality helper (this used to be lodash isEqual) is more than\n// this needs, and would also have to be careful around the refs and React\n// elements that appear elsewhere in the props.\nconst samePosition = (a: dimensionType | undefined, b: dimensionType | undefined) => {\n  if (a === b) return true;\n  if (!a || !b) return false;\n  return a.x === b.x && a.y === b.y && a.right === b.right && a.bottom === b.bottom;\n};\n\n/**\n * smart hook that provides parsed props to Xarrow and will trigger rerender whenever given prop is changed.\n */\nconst useXarrowProps = (\n  userProps: xarrowPropsType,\n  refs: { headRef: React.MutableRefObject<any>; tailRef: React.MutableRefObject<any> },\n) => {\n  // lazy initializer - one parsed-props object per arrow, never shared\n  const [propsRefs, setPropsRefs] = useState(createInitialParsedProps);\n  const shouldUpdatePosition = useRef(false);\n  propsRefs['shouldUpdatePosition'] = shouldUpdatePosition;\n  const curProps = { ...defaultProps, ...userProps };\n\n  // react states the number of hooks per render must stay constant,\n  // this is ok we are using these hooks in a loop, because the number of props in defaultProps is constant,\n  // so the number of hook we will fire each render will always be the same.\n\n  // update the value of the ref that represents the corresponding prop\n  // for example: if given 'start' prop would change call getElementByPropGiven(props.start) and save value into propsRefs.start.current\n  // why to save refs to props parsed values? some of the props require relatively expensive computations(like 'start' and 'startAnchor').\n  // this will always run in the same order and THAT'S WAY ITS LEGAL\n  for (const propName of Object.keys(defaultProps) as propName[]) {\n    useLayoutEffect(\n      () => {\n        // Same unchecked write as parseGivenProps - see the note there.\n        (propsRefs as Record<string, unknown>)[propName] = parsePropsFuncs?.[propName]?.(\n          curProps[propName],\n          propsRefs,\n          shouldUpdatePosition,\n        );\n        // console.log('prop update:', propName, 'with value', propsRefs[propName]);\n        setPropsRefs({ ...propsRefs });\n      },\n      propsDeps[propName].map((name) => userProps[name]),\n    );\n  }\n\n  // rerender whenever position of start element or end element changes.\n  //\n  // The measurement deliberately happens in a layout effect rather than in the\n  // render body. React commits DOM mutations after render and before layout\n  // effects, so anything measured during render describes the *previous*\n  // frame's layout: an element that moved in this very commit gets measured at\n  // its old position, and because the comparison is then stale-against-stale no\n  // correcting render is ever scheduled. Reading here instead sees the layout\n  // that was just committed, and the resulting extra render happens before\n  // paint, so the arrow never lags a frame behind the elements it connects.\n  //\n  // The elements are re-resolved here too, so an element remounted under the\n  // same id or ref is picked up again instead of leaving the arrow measuring a\n  // detached node - which the DOM reports as all zeros, dragging the arrow to\n  // the viewport origin.\n  const [valVars, setValVars] = useState(initialValVars);\n  useLayoutEffect(() => {\n    // no DOM to measure - nothing here can be meaningful, and getElementByPropGiven would throw\n    if (typeof document === 'undefined') return;\n\n    // resolved on every commit rather than only when the cached node looks stale:\n    // an id or ref can move to another element while the old one stays mounted,\n    // and a connected old node gives no sign it is no longer the endpoint. Each\n    // lookup is one getElementById or one ref.current read.\n    propsRefs.start = getElementByPropGiven(curProps.start);\n    propsRefs.end = getElementByPropGiven(curProps.end);\n\n    const startPos = getElemPos(propsRefs.start);\n    const endPos = getElemPos(propsRefs.end);\n    // guarded so this effect cannot schedule a render that would run it again forever\n    if (samePosition(startPos, valVars.startPos) && samePosition(endPos, valVars.endPos)) return;\n\n    valVars.startPos = startPos;\n    valVars.endPos = endPos;\n    shouldUpdatePosition.current = true;\n    setValVars({ ...valVars });\n  });\n\n  useLayoutEffect(() => {\n    // console.log('svg shape changed!');\n    shouldUpdatePosition.current = true;\n    setValVars({ ...valVars });\n  }, [propsRefs.headShape.svgElem, propsRefs.tailShape.svgElem]);\n\n  return [propsRefs, valVars] as const;\n};\n\nexport type useXarrowPropsResType = ReturnType<typeof useXarrowProps>;\nexport default useXarrowProps;\n","import React, { FC, useEffect, useRef, useState } from 'react';\n\ntype updateXarrowFunc = () => void;\n\n// The default really is null - a component outside any Xwrapper reads it - so\n// the type says so rather than casting the null away.\nexport const XelemContext = React.createContext<updateXarrowFunc | null>(null);\nexport const XarrowContext = React.createContext<updateXarrowFunc | null>(null);\n\nconst updateRef: Record<number, updateXarrowFunc> = {};\nlet updateRefCount = 0;\n\n// React 18 dropped the implicit `children` prop from FC, so it is declared explicitly here.\ntype ProviderProps = {\n  instanceCount: React.MutableRefObject<number>;\n  children?: React.ReactNode;\n};\n\nconst XarrowProvider: FC<ProviderProps> = ({ children, instanceCount }) => {\n  const [, setRender] = useState({});\n  const updateXarrow = () => setRender({});\n  useEffect(() => {\n    instanceCount.current = updateRefCount; // so this instance would know what is id\n    updateRef[instanceCount.current] = updateXarrow;\n  }, []);\n  // log('XarrowProvider', updateRefCount);\n  return <XarrowContext.Provider value={updateXarrow}>{children}</XarrowContext.Provider>;\n};\n\nconst XelemProvider: FC<ProviderProps> = ({ children, instanceCount }) => {\n  return <XelemContext.Provider value={updateRef[instanceCount.current]}>{children}</XelemContext.Provider>;\n};\n\nconst Xwrapper: FC<{ children?: React.ReactNode }> = ({ children }) => {\n  const instanceCount = useRef(updateRefCount);\n  const [, setRender] = useState({});\n  useEffect(() => {\n    updateRefCount++;\n    setRender({});\n    return () => {\n      delete updateRef[instanceCount.current];\n    };\n  }, []);\n\n  return (\n    <XelemProvider instanceCount={instanceCount}>\n      <XarrowProvider instanceCount={instanceCount}>{children}</XarrowProvider>\n    </XelemProvider>\n  );\n};\n\nexport default Xwrapper;\n","import { dimensionType, parsedAnchorType } from '../privateTypes';\n\nconst getAnchorsDefaultOffsets = (width: number, height: number) => {\n  return {\n    middle: { x: width * 0.5, y: height * 0.5 },\n    left: { x: 0, y: height * 0.5 },\n    right: { x: width, y: height * 0.5 },\n    top: { x: width * 0.5, y: 0 },\n    bottom: { x: width * 0.5, y: height },\n  };\n};\n\nexport const calcAnchors = (anchors: parsedAnchorType[], anchorPos: dimensionType) => {\n  // now prepare this list of anchors to object expected by the `getShortestLine` function\n  return anchors.map((anchor) => {\n    const defsOffsets = getAnchorsDefaultOffsets(anchorPos.right - anchorPos.x, anchorPos.bottom - anchorPos.y);\n    const { x, y } = defsOffsets[anchor.position];\n    return {\n      x: anchorPos.x + x + anchor.offset.x,\n      y: anchorPos.y + y + anchor.offset.y,\n      anchor: anchor,\n    };\n  });\n};\n","// Buzier curve calculations\n\n/**\n * returns buzzier curve function with 2 controls points\n * bzCurve with 2 control points function(4 points total):  bz = (1−t)^3*p1 + 3(1−t)^2*t*p2 +3(1−t)*t^2*p3 + t^3*p4\n */\nexport const bzFunction = (p1, p2, p3, p4) => (t) =>\n  (1 - t) ** 3 * p1 + 3 * (1 - t) ** 2 * t * p2 + 3 * (1 - t) * t ** 2 * p3 + t ** 3 * p4;\n\n/**\n * returns 2 solutions from extram points for buzzier curve with 2 controls points\n */\nexport const buzzierMinSols = (p1, p2, p3, p4) => {\n  const bz = bzFunction(p1, p2, p3, p4);\n  // dt(bz) = -3 p1 (1 - t)^2 + 3 p2 (1 - t)^2 - 6 p2 (1 - t) t + 6 p3 (1 - t) t - 3 p3 t^2 + 3 p4 t^2\n  // when p1=(x1,y1),p2=(cpx1,cpy1),p3=(cpx2,cpy2),p4=(x2,y2)\n  // then extrema points is when dt(bz) = 0\n  // solutions =>  t = ((-6 p1 + 12 p2 - 6 p3) ± sqrt((6 p1 - 12 p2 + 6 p3)^2 - 4 (3 p2 - 3 p1) (-3 p1 + 9 p2 - 9 p3 + 3 p4)))/(2 (-3 p1 + 9 p2 - 9 p3 + 3 p4))  when (p1 + 3 p3!=3 p2 + p4)\n  // if we mark A=(-6 p1 + 12 p2 - 6 p3) and B=(6 p1 - 12 p2 + 6 p3)^2 - 4 (3 p2 - 3 p1) (-3 p1 + 9 p2 - 9 p3 + 3 p4)) and C =(2 (-3 p1 + 9 p2 - 9 p3 + 3 p4) then\n  // tSol = A ± sqrt(B)\n  // then solution we want is: bz(tSol)\n  const A = -6 * p1 + 12 * p2 - 6 * p3;\n  const B = (-6 * p1 + 12 * p2 - 6 * p3) ** 2 - 4 * (3 * p2 - 3 * p1) * (-3 * p1 + 9 * p2 - 9 * p3 + 3 * p4);\n  const C = 2 * (-3 * p1 + 9 * p2 - 9 * p3 + 3 * p4);\n\n  const sol1 = bz((A + Math.sqrt(B)) / C);\n  const sol2 = bz((A - Math.sqrt(B)) / C);\n  return [sol1, sol2];\n};\n","import { useXarrowPropsResType } from '../useXarrowProps';\nimport React from 'react';\nimport { calcAnchors } from '../anchors';\nimport { getShortestLine, getSvgPos, getTotalLength, polylinePath } from './index';\nimport { cPaths } from '../../constants';\nimport { buzzierMinSols, bzFunction } from './buzzier';\nimport { anchorNamedType } from '../../types';\n\n// which axis the line leaves an anchor on: horizontal or vertical\ntype curveAxis = 'h' | 'v';\ntype curveKey = `${curveAxis}${curveAxis}`;\n\n/**\n * The Main logic of path calculation for the arrow.\n * calculate new path, adjusting canvas, and set state based on given properties.\n * */\nexport const getPosition = (xProps: useXarrowPropsResType, mainRef: React.MutableRefObject<any>) => {\n  const [propsRefs, valVars] = xProps;\n  const {\n    startAnchor,\n    endAnchor,\n    strokeWidth,\n    showHead,\n    headSize,\n    showTail,\n    tailSize,\n    curveness,\n    gridBreak,\n    gridRadius,\n    headShape,\n    tailShape,\n    _extendSVGcanvas,\n    _cpx1Offset,\n    _cpy1Offset,\n    _cpx2Offset,\n    _cpy2Offset,\n  } = propsRefs;\n  // normalized below - an unknown path falls back to 'smooth', and 'straight' is\n  // expressed as 'smooth' with zero curveness\n  let path = propsRefs.path;\n  const { startPos, endPos } = valVars;\n  const { svgRef, lineRef } = mainRef.current;\n\n  let headOrient: number = 0;\n  let tailOrient: number = 0;\n\n  // convert startAnchor and endAnchor to list of objects represents allowed anchors.\n  const startPoints = calcAnchors(startAnchor, startPos);\n  const endPoints = calcAnchors(endAnchor, endPos);\n\n  // choose the smallest path for 2 points from these possibilities.\n  const { chosenStart, chosenEnd } = getShortestLine(startPoints, endPoints);\n\n  const startAnchorPosition = chosenStart.anchor.position;\n  let endAnchorPosition = chosenEnd.anchor.position;\n  const startPoint = { x: chosenStart.x, y: chosenStart.y },\n    endPoint = { x: chosenEnd.x, y: chosenEnd.y };\n\n  const mainDivPos = getSvgPos(svgRef);\n  let cx0 = Math.min(startPoint.x, endPoint.x) - mainDivPos.x;\n  let cy0 = Math.min(startPoint.y, endPoint.y) - mainDivPos.y;\n  const dx = endPoint.x - startPoint.x;\n  const dy = endPoint.y - startPoint.y;\n  const absDx = Math.abs(endPoint.x - startPoint.x);\n  const absDy = Math.abs(endPoint.y - startPoint.y);\n  const xSign = dx > 0 ? 1 : -1;\n  const ySign = dy > 0 ? 1 : -1;\n  const [headOffset, tailOffset] = [headShape.offsetForward, tailShape.offsetForward];\n  const fHeadSize = headSize * strokeWidth; //factored head size\n  const fTailSize = tailSize * strokeWidth; //factored head size\n\n  // const { current: _headBox } = headBox;\n  let xHeadOffset = 0;\n  let yHeadOffset = 0;\n  let xTailOffset = 0;\n  let yTailOffset = 0;\n\n  const _headOffset = fHeadSize * headOffset;\n  const _tailOffset = fTailSize * tailOffset;\n\n  let cu = Number(curveness);\n  if (!cPaths.includes(path)) path = 'smooth';\n  if (path === 'straight') {\n    cu = 0;\n    path = 'smooth';\n  }\n\n  const biggerSide = headSize > tailSize ? headSize : tailSize;\n  const _calc = strokeWidth + (strokeWidth * biggerSide) / 2;\n  let excRight = _calc;\n  let excLeft = _calc;\n  let excUp = _calc;\n  let excDown = _calc;\n  excLeft += Number(_extendSVGcanvas);\n  excRight += Number(_extendSVGcanvas);\n  excUp += Number(_extendSVGcanvas);\n  excDown += Number(_extendSVGcanvas);\n\n  ////////////////////////////////////\n  // arrow point to point calculations\n  let x1 = 0,\n    x2 = absDx,\n    y1 = 0,\n    y2 = absDy;\n  if (dx < 0) [x1, x2] = [x2, x1];\n  if (dy < 0) [y1, y2] = [y2, y1];\n\n  ////////////////////////////////////\n  // arrow curviness and arrowhead placement calculations\n\n  if (cu === 0) {\n    // in case of straight path\n    // atan2 rather than atan(absDy / absDx): identical for every other input,\n    // but 0/0 makes the division NaN and poisons every coordinate downstream.\n    // Both deltas are zero whenever start and end sit at the same point, which\n    // includes the very common case of elements not yet measured on first\n    // render. atan2(0, 0) is 0, so a zero-length arrow renders flat instead.\n    let headAngel = Math.atan2(absDy, absDx);\n\n    if (showHead) {\n      x2 -= fHeadSize * (1 - headOffset) * xSign * Math.cos(headAngel);\n      y2 -= fHeadSize * (1 - headOffset) * ySign * Math.sin(headAngel);\n\n      headAngel *= ySign;\n      if (xSign < 0) headAngel = (Math.PI - headAngel * xSign) * xSign;\n      xHeadOffset = Math.cos(headAngel) * _headOffset - (Math.sin(headAngel) * fHeadSize) / 2;\n      yHeadOffset = (Math.cos(headAngel) * fHeadSize) / 2 + Math.sin(headAngel) * _headOffset;\n      headOrient = (headAngel * 180) / Math.PI;\n    }\n\n    let tailAngel = Math.atan2(absDy, absDx);\n    if (showTail) {\n      x1 += fTailSize * (1 - tailOffset) * xSign * Math.cos(tailAngel);\n      y1 += fTailSize * (1 - tailOffset) * ySign * Math.sin(tailAngel);\n      tailAngel *= -ySign;\n      if (xSign > 0) tailAngel = (Math.PI - tailAngel * xSign) * xSign;\n      xTailOffset = Math.cos(tailAngel) * _tailOffset - (Math.sin(tailAngel) * fTailSize) / 2;\n      yTailOffset = (Math.cos(tailAngel) * fTailSize) / 2 + Math.sin(tailAngel) * _tailOffset;\n      tailOrient = (tailAngel * 180) / Math.PI;\n    }\n  } else {\n    // in case of smooth path\n    if (endAnchorPosition === 'middle') {\n      // in case a middle anchor is chosen for endAnchor choose from which side to attach to the middle of the element\n      if (absDx > absDy) {\n        endAnchorPosition = xSign ? 'left' : 'right';\n      } else {\n        endAnchorPosition = ySign ? 'top' : 'bottom';\n      }\n    }\n    if (showHead) {\n      if (['left', 'right'].includes(endAnchorPosition)) {\n        xHeadOffset += _headOffset * xSign;\n        x2 -= fHeadSize * (1 - headOffset) * xSign; //same!\n        yHeadOffset += (fHeadSize * xSign) / 2;\n        if (endAnchorPosition === 'left') {\n          headOrient = 0;\n          if (xSign < 0) headOrient += 180;\n        } else {\n          headOrient = 180;\n          if (xSign > 0) headOrient += 180;\n        }\n      } else if (['top', 'bottom'].includes(endAnchorPosition)) {\n        xHeadOffset += (fHeadSize * -ySign) / 2;\n        yHeadOffset += _headOffset * ySign;\n        y2 -= fHeadSize * ySign - yHeadOffset;\n        if (endAnchorPosition === 'top') {\n          headOrient = 270;\n          if (ySign > 0) headOrient += 180;\n        } else {\n          headOrient = 90;\n          if (ySign < 0) headOrient += 180;\n        }\n      }\n    }\n  }\n\n  if (showTail && cu !== 0) {\n    if (['left', 'right'].includes(startAnchorPosition)) {\n      xTailOffset += _tailOffset * -xSign;\n      x1 += fTailSize * xSign + xTailOffset;\n      yTailOffset += -(fTailSize * xSign) / 2;\n      if (startAnchorPosition === 'left') {\n        tailOrient = 180;\n        if (xSign < 0) tailOrient += 180;\n      } else {\n        tailOrient = 0;\n        if (xSign > 0) tailOrient += 180;\n      }\n    } else if (['top', 'bottom'].includes(startAnchorPosition)) {\n      yTailOffset += _tailOffset * -ySign;\n      y1 += fTailSize * ySign + yTailOffset;\n      xTailOffset += (fTailSize * ySign) / 2;\n      if (startAnchorPosition === 'top') {\n        tailOrient = 90;\n        if (ySign > 0) tailOrient += 180;\n      } else {\n        tailOrient = 270;\n        if (ySign < 0) tailOrient += 180;\n      }\n    }\n  }\n\n  const arrowHeadOffset = { x: xHeadOffset, y: yHeadOffset };\n  const arrowTailOffset = { x: xTailOffset, y: yTailOffset };\n\n  let cpx1 = x1,\n    cpy1 = y1,\n    cpx2 = x2,\n    cpy2 = y2;\n\n  let curvesPossibilities = {} as Record<curveKey, () => void>;\n  if (path === 'smooth')\n    curvesPossibilities = {\n      hh: () => {\n        //horizontal - from right to left or the opposite\n        cpx1 += absDx * cu * xSign;\n        cpx2 -= absDx * cu * xSign;\n      },\n      vv: () => {\n        //vertical - from top to bottom or opposite\n        cpy1 += absDy * cu * ySign;\n        cpy2 -= absDy * cu * ySign;\n      },\n      hv: () => {\n        // start horizontally then vertically\n        // from v side to h side\n        cpx1 += absDx * cu * xSign;\n        cpy2 -= absDy * cu * ySign;\n      },\n      vh: () => {\n        // start vertically then horizontally\n        // from h side to v side\n        cpy1 += absDy * cu * ySign;\n        cpx2 -= absDx * cu * xSign;\n      },\n    };\n  else if (path === 'grid') {\n    curvesPossibilities = {\n      hh: () => {\n        cpx1 += (absDx * gridBreak.relative + gridBreak.abs) * xSign;\n        cpx2 -= (absDx * (1 - gridBreak.relative) - gridBreak.abs) * xSign;\n        if (showHead) {\n          cpx1 -= ((fHeadSize * (1 - headOffset)) / 2) * xSign;\n          cpx2 += ((fHeadSize * (1 - headOffset)) / 2) * xSign;\n        }\n        if (showTail) {\n          cpx1 -= ((fTailSize * (1 - tailOffset)) / 2) * xSign;\n          cpx2 += ((fTailSize * (1 - tailOffset)) / 2) * xSign;\n        }\n      },\n      vv: () => {\n        cpy1 += (absDy * gridBreak.relative + gridBreak.abs) * ySign;\n        cpy2 -= (absDy * (1 - gridBreak.relative) - gridBreak.abs) * ySign;\n        if (showHead) {\n          cpy1 -= ((fHeadSize * (1 - headOffset)) / 2) * ySign;\n          cpy2 += ((fHeadSize * (1 - headOffset)) / 2) * ySign;\n        }\n        if (showTail) {\n          cpy1 -= ((fTailSize * (1 - tailOffset)) / 2) * ySign;\n          cpy2 += ((fTailSize * (1 - tailOffset)) / 2) * ySign;\n        }\n      },\n      hv: () => {\n        cpx1 = x2;\n      },\n      vh: () => {\n        cpy1 = y2;\n      },\n    };\n  }\n  // smart select best curve for the current anchors. Built per anchor rather\n  // than by concatenating and regex-replacing a bare string, so that the key\n  // is a union the lookup below can be checked against: an anchor position\n  // that matched none of the branches used to append nothing and index\n  // curvesPossibilities with a one-character key that does not exist.\n  const middleAxis: curveAxis = absDx > absDy ? 'h' : 'v';\n  const axisOf = (position: anchorNamedType): curveAxis => {\n    if (position === 'left' || position === 'right') return 'h';\n    if (position === 'top' || position === 'bottom') return 'v';\n    return middleAxis;\n  };\n  const selectedCurviness: curveKey = `${axisOf(startAnchorPosition)}${axisOf(endAnchorPosition)}`;\n  curvesPossibilities[selectedCurviness]();\n\n  cpx1 += _cpx1Offset;\n  cpy1 += _cpy1Offset;\n  cpx2 += _cpx2Offset;\n  cpy2 += _cpy2Offset;\n\n  ////////////////////////////////////\n  // canvas smart size adjustments\n  const [xSol1, xSol2] = buzzierMinSols(x1, cpx1, cpx2, x2);\n  const [ySol1, ySol2] = buzzierMinSols(y1, cpy1, cpy2, y2);\n  if (xSol1 < 0) excLeft += -xSol1;\n  if (xSol2 > absDx) excRight += xSol2 - absDx;\n  if (ySol1 < 0) excUp += -ySol1;\n  if (ySol2 > absDy) excDown += ySol2 - absDy;\n\n  if (path === 'grid') {\n    excLeft += _calc;\n    excRight += _calc;\n    excUp += _calc;\n    excDown += _calc;\n  }\n\n  x1 += excLeft;\n  x2 += excLeft;\n  y1 += excUp;\n  y2 += excUp;\n  cpx1 += excLeft;\n  cpx2 += excLeft;\n  cpy1 += excUp;\n  cpy2 += excUp;\n\n  const cw = absDx + excLeft + excRight,\n    ch = absDy + excUp + excDown;\n  cx0 -= excLeft;\n  cy0 -= excUp;\n\n  //labels\n  const bzx = bzFunction(x1, cpx1, cpx2, x2);\n  const bzy = bzFunction(y1, cpy1, cpy2, y2);\n  const labelStartPos = { x: bzx(0.01), y: bzy(0.01) };\n  const labelMiddlePos = { x: bzx(0.5), y: bzy(0.5) };\n  const labelEndPos = { x: bzx(0.99), y: bzy(0.99) };\n\n  // 'straight' and any unknown path are normalized to 'smooth' above, so one of\n  // the branches below always assigns. The initializer keeps the type a plain\n  // string rather than string | undefined.\n  let arrowPath = '';\n  if (path === 'grid') {\n    const radius = gridRadius === true ? strokeWidth * 2 : Math.max(0, Number(gridRadius) || 0);\n    arrowPath = polylinePath(\n      [\n        { x: x1, y: y1 },\n        { x: cpx1, y: cpy1 },\n        { x: cpx2, y: cpy2 },\n        { x: x2, y: y2 },\n      ],\n      radius,\n    );\n  } else if (path === 'smooth') arrowPath = `M ${x1} ${y1} C ${cpx1} ${cpy1}, ${cpx2} ${cpy2}, ${x2} ${y2}`;\n  return {\n    cx0,\n    cy0,\n    x1,\n    x2,\n    y1,\n    y2,\n    cw,\n    ch,\n    cpx1,\n    cpy1,\n    cpx2,\n    cpy2,\n    dx,\n    dy,\n    absDx,\n    absDy,\n    headOrient,\n    tailOrient,\n    labelStartPos,\n    labelMiddlePos,\n    labelEndPos,\n    excLeft,\n    excRight,\n    excUp,\n    excDown,\n    headOffset: _headOffset,\n    arrowHeadOffset,\n    arrowTailOffset,\n    startPoints,\n    endPoints,\n    mainDivPos,\n    xSign,\n    ySign,\n    lineLength: getTotalLength(lineRef.current),\n    fHeadSize,\n    fTailSize,\n    arrowPath,\n  };\n};\n","import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { xarrowPropsType } from '../types';\nimport useXarrowProps from './useXarrowProps';\nimport { XarrowContext } from '../Xwrapper';\nimport { getPosition } from './utils/GetPosition';\nimport { getTotalLength } from './utils';\n\nconst log = console.log;\n\nconst Xarrow: React.FC<xarrowPropsType> = (props: xarrowPropsType) => {\n  // log('xarrow update');\n\n  const mainRef = useRef({\n    svgRef: useRef<SVGSVGElement>(null),\n    lineRef: useRef<SVGPathElement>(null),\n    headRef: useRef<SVGElement>(null),\n    tailRef: useRef<SVGElement>(null),\n    lineDrawAnimRef: useRef<SVGElement>(null),\n    lineDashAnimRef: useRef<SVGElement>(null),\n    headOpacityAnimRef: useRef<SVGElement>(null),\n  });\n  const { svgRef, lineRef, headRef, tailRef, lineDrawAnimRef, lineDashAnimRef, headOpacityAnimRef } = mainRef.current;\n  useContext(XarrowContext);\n  const xProps = useXarrowProps(props, mainRef.current);\n  const [propsRefs] = xProps;\n\n  const {\n    labels,\n    lineColor,\n    headColor,\n    tailColor,\n    strokeWidth,\n    showHead,\n    showTail,\n    dashness,\n    headShape,\n    tailShape,\n    showXarrow,\n    zIndex,\n    passProps,\n    arrowBodyProps,\n    arrowHeadProps,\n    arrowTailProps,\n    SVGcanvasProps,\n    divContainerProps,\n    divContainerStyle,\n    SVGcanvasStyle,\n    _debug,\n    shouldUpdatePosition,\n  } = propsRefs;\n\n  // read straight off props rather than the parsed refs - this one is reassigned below\n  let animateDrawing = props.animateDrawing as number;\n  const [drawAnimEnded, setDrawAnimEnded] = useState(!animateDrawing);\n\n  const [, setRender] = useState({});\n  const forceRerender = () => setRender({});\n\n  // Typed from what getPosition returns rather than inferred from the literal\n  // below, which would make the two empty arrays never[].\n  const [st, setSt] = useState<ReturnType<typeof getPosition>>({\n    //initial state\n    cx0: 0, //x start position of the canvas\n    cy0: 0, //y start position of the canvas\n    cw: 0, // the canvas width\n    ch: 0, // the canvas height\n    x1: 0, //the x starting point of the line inside the canvas\n    y1: 0, //the y starting point of the line inside the canvas\n    x2: 0, //the x ending point of the line inside the canvas\n    y2: 0, //the y ending point of the line inside the canvas\n    dx: 0, // the x difference between 'start' anchor to 'end' anchor\n    dy: 0, // the y difference between 'start' anchor to 'end' anchor\n    absDx: 0, // the x length(positive) difference\n    absDy: 0, // the y length(positive) difference\n    cpx1: 0, // control points - control the curviness of the line\n    cpy1: 0,\n    cpx2: 0,\n    cpy2: 0,\n    headOrient: 0, // determines to what side the arrowhead will point\n    tailOrient: 0, // determines to what side the arrow tail will point\n    arrowHeadOffset: { x: 0, y: 0 },\n    arrowTailOffset: { x: 0, y: 0 },\n    headOffset: 0,\n    excRight: 0, //expand canvas to the right\n    excLeft: 0, //expand canvas to the left\n    excUp: 0, //expand canvas upwards\n    excDown: 0, // expand canvas downward\n    startPoints: [],\n    endPoints: [],\n    mainDivPos: { x: 0, y: 0 },\n    xSign: 1,\n    ySign: 1,\n    lineLength: 0,\n    fHeadSize: 1,\n    fTailSize: 1,\n    arrowPath: ``,\n    labelStartPos: { x: 0, y: 0 },\n    labelMiddlePos: { x: 0, y: 0 },\n    labelEndPos: { x: 0, y: 0 },\n  });\n\n  /**\n   * The Main logic of path calculation for the arrow.\n   * calculate new path, adjusting canvas, and set state based on given properties.\n   * */\n  useLayoutEffect(() => {\n    if (shouldUpdatePosition.current) {\n      // log('xarrow getPosition');\n      const pos = getPosition(xProps, mainRef);\n      // log('pos', pos);\n      setSt(pos);\n      shouldUpdatePosition.current = false;\n    }\n  });\n\n  // log('st', st);\n\n  const xOffsetHead = st.x2 - st.arrowHeadOffset.x;\n  const yOffsetHead = st.y2 - st.arrowHeadOffset.y;\n  const xOffsetTail = st.x1 - st.arrowTailOffset.x;\n  const yOffsetTail = st.y1 - st.arrowTailOffset.y;\n\n  const dashoffset = dashness.strokeLen + dashness.nonStrokeLen;\n  let animDirection = 1;\n  if (dashness.animation < 0) {\n    dashness.animation *= -1;\n    animDirection = -1;\n  }\n  let dashArray,\n    animation,\n    animRepeatCount,\n    animStartValue,\n    animEndValue = 0;\n\n  if (animateDrawing && drawAnimEnded == false) {\n    if (typeof animateDrawing === 'boolean') animateDrawing = 1;\n    animation = animateDrawing + 's';\n    dashArray = st.lineLength;\n    animStartValue = st.lineLength;\n    animRepeatCount = 1;\n    if (animateDrawing < 0) {\n      [animStartValue, animEndValue] = [animEndValue, animStartValue];\n      animation = animateDrawing * -1 + 's';\n    }\n  } else {\n    dashArray = `${dashness.strokeLen} ${dashness.nonStrokeLen}`;\n    animation = `${1 / dashness.animation}s`;\n    animStartValue = dashoffset * animDirection;\n    animRepeatCount = 'indefinite';\n    animEndValue = 0;\n  }\n\n  // handle draw animation\n  useLayoutEffect(() => {\n    if (lineRef.current) setSt((prevSt) => ({ ...prevSt, lineLength: getTotalLength(lineRef.current) }));\n  }, [lineRef.current]);\n\n  // set all props on first render\n  useEffect(() => {\n    const monitorDOMchanges = () => {\n      window.addEventListener('resize', forceRerender);\n\n      const handleDrawAmimEnd = () => {\n        setDrawAnimEnded(true);\n        // @ts-ignore\n        headOpacityAnimRef.current?.beginElement();\n        // @ts-ignore\n        lineDashAnimRef.current?.beginElement();\n      };\n      // Deliberately does not depend on the arrowhead. This listener is what\n      // ends the draw phase, and gating it on headRef left `drawAnimEnded`\n      // false forever whenever showHead was false, so the arrow stayed stuck\n      // mid-draw. The head is hidden through the rendered `opacity` attribute\n      // instead, which React can actually reconcile.\n      if (lineDrawAnimRef.current) {\n        lineDrawAnimRef.current.addEventListener('endEvent', handleDrawAmimEnd);\n      }\n      return () => {\n        window.removeEventListener('resize', forceRerender);\n        if (lineDrawAnimRef.current) {\n          lineDrawAnimRef.current.removeEventListener('endEvent', handleDrawAmimEnd);\n        }\n      };\n    };\n\n    const cleanMonitorDOMchanges = monitorDOMchanges();\n    return () => {\n      setDrawAnimEnded(false);\n      cleanMonitorDOMchanges();\n    };\n  }, [showXarrow]);\n\n  //todo: could make some advanced generic typescript inferring. for example get type from headShape.elem:T and\n  // tailShape.elem:K force the type for passProps,arrowHeadProps,arrowTailProps property. for now `as any` is used to\n  // avoid typescript conflicts\n  // so todo- fix all the `passProps as any` assertions\n\n  return (\n    <div {...divContainerProps} style={{ position: 'absolute', zIndex, ...divContainerStyle }}>\n      {showXarrow ? (\n        <>\n          <svg\n            ref={svgRef}\n            width={st.cw}\n            height={st.ch}\n            style={{\n              position: 'absolute',\n              left: st.cx0,\n              top: st.cy0,\n              pointerEvents: 'none',\n              border: _debug ? '1px dashed yellow' : undefined,\n              ...SVGcanvasStyle,\n            }}\n            overflow=\"auto\"\n            {...SVGcanvasProps}>\n            {/* body of the arrow */}\n            <path\n              ref={lineRef}\n              d={st.arrowPath}\n              stroke={lineColor}\n              strokeDasharray={dashArray}\n              // strokeDasharray={'0 0'}\n              strokeWidth={strokeWidth}\n              fill=\"transparent\"\n              pointerEvents=\"visibleStroke\"\n              {...(passProps as any)}\n              {...arrowBodyProps}>\n              <>\n                {drawAnimEnded || !animateDrawing ? (\n                  <>\n                    {/* moving dashed line animation */}\n                    {dashness.animation ? (\n                      <animate\n                        ref={lineDashAnimRef}\n                        attributeName=\"stroke-dashoffset\"\n                        values={`${dashoffset * animDirection};0`}\n                        dur={`${1 / dashness.animation}s`}\n                        repeatCount=\"indefinite\"\n                      />\n                    ) : null}\n                  </>\n                ) : (\n                  <>\n                    {/* the creation of the line animation */}\n                    {animateDrawing ? (\n                      <animate\n                        ref={lineDrawAnimRef}\n                        id={`svgEndAnimate`}\n                        attributeName=\"stroke-dashoffset\"\n                        values={`${animStartValue};${animEndValue}`}\n                        dur={animation}\n                        repeatCount={animRepeatCount}\n                      />\n                    ) : null}\n                  </>\n                )}\n              </>\n            </path>\n            {/* arrow tail */}\n            {showTail ? (\n              <g\n                fill={tailColor}\n                pointerEvents=\"auto\"\n                transform={`translate(${xOffsetTail},${yOffsetTail}) rotate(${st.tailOrient}) scale(${st.fTailSize})`}\n                {...(passProps as any)}\n                {...arrowTailProps}>\n                {tailShape.svgElem}\n              </g>\n            ) : null}\n\n            {/* head of the arrow */}\n            {showHead ? (\n              <g\n                ref={headRef as any}\n                // d={normalArrowShape}\n                fill={headColor}\n                pointerEvents=\"auto\"\n                transform={`translate(${xOffsetHead},${yOffsetHead}) rotate(${st.headOrient}) scale(${st.fHeadSize})`}\n                opacity={animateDrawing && !drawAnimEnded ? 0 : 1}\n                {...(passProps as any)}\n                {...arrowHeadProps}>\n                {/* No repeatCount: SMIL rejects 0 and logs \"Unexpected value 0\n                    parsing repeatCount attribute\", and the default of a single\n                    run is what this fade-in wants anyway. */}\n                <animate\n                  ref={headOpacityAnimRef}\n                  dur={'0.4'}\n                  attributeName=\"opacity\"\n                  from=\"0\"\n                  to=\"1\"\n                  begin={`indefinite`}\n                  fill=\"freeze\"\n                />\n\n                {headShape.svgElem}\n              </g>\n            ) : null}\n            {/* debug elements */}\n            {_debug ? (\n              <>\n                {/* control points circles */}\n                <circle r=\"5\" cx={st.cpx1} cy={st.cpy1} fill=\"green\" />\n                <circle r=\"5\" cx={st.cpx2} cy={st.cpy2} fill=\"blue\" />\n                {/* start to end rectangle wrapper */}\n                <rect\n                  x={st.excLeft}\n                  y={st.excUp}\n                  width={st.absDx}\n                  height={st.absDy}\n                  fill=\"none\"\n                  stroke=\"pink\"\n                  strokeWidth=\"2px\"\n                />\n              </>\n            ) : null}\n          </svg>\n\n          {labels.start ? (\n            <div\n              style={{\n                transform: st.dx < 0 ? 'translate(-100% , -50%)' : 'translate(-0% , -50%)',\n                width: 'max-content',\n                position: 'absolute',\n                left: st.cx0 + st.labelStartPos.x,\n                top: st.cy0 + st.labelStartPos.y - strokeWidth - 5,\n              }}>\n              {labels.start}\n            </div>\n          ) : null}\n          {labels.middle ? (\n            <div\n              style={{\n                display: 'table',\n                width: 'max-content',\n                transform: 'translate(-50% , -50%)',\n                position: 'absolute',\n                left: st.cx0 + st.labelMiddlePos.x,\n                top: st.cy0 + st.labelMiddlePos.y,\n              }}>\n              {labels.middle}\n            </div>\n          ) : null}\n          {labels.end ? (\n            <div\n              style={{\n                transform: st.dx > 0 ? 'translate(-100% , -50%)' : 'translate(-0% , -50%)',\n                width: 'max-content',\n                position: 'absolute',\n                left: st.cx0 + st.labelEndPos.x,\n                top: st.cy0 + st.labelEndPos.y + strokeWidth + 5,\n              }}>\n              {labels.end}\n            </div>\n          ) : null}\n          {_debug ? (\n            <>\n              {/* possible anchor connections */}\n              {[...st.startPoints, ...st.endPoints].map((p, i) => {\n                return (\n                  <div\n                    key={i}\n                    style={{\n                      background: 'gray',\n                      opacity: 0.5,\n                      borderRadius: '50%',\n                      transform: 'translate(-50%, -50%)',\n                      height: 5,\n                      width: 5,\n                      position: 'absolute',\n                      left: p.x - st.mainDivPos.x,\n                      top: p.y - st.mainDivPos.y,\n                    }}\n                  />\n                );\n              })}\n            </>\n          ) : null}\n        </>\n      ) : null}\n    </div>\n  );\n};\n\nexport default Xarrow;\n","import React, { useContext, useLayoutEffect, useState } from 'react';\nimport { XelemContext } from './Xwrapper';\n\nconst noop = () => {};\n\nconst useXarrow = () => {\n  const [, setRender] = useState({});\n  const reRender = () => setRender({});\n\n  let updateXarrow = useContext(XelemContext);\n  if (!updateXarrow) updateXarrow = noop;\n  // throw new Error(\n  //   \"'Xwrapper' is required around element using 'useXarrow' hook! wrap your xarrows and connected elements with Xwrapper! \"\n  // );\n\n  useLayoutEffect(() => {\n    updateXarrow();\n  });\n  return reRender;\n};\n\nexport default useXarrow;\n"],"mappings":";;AAMA,IAAaC,KAAyB,MAAiC;;CACrE,IAAIE;CAKJ,OAJA,AAGOA,IAHH,OA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