chunk-LPWNO2ZS.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565
  1. import {
  2. closestElementCrossShadowBoundary,
  3. getElementDir
  4. } from "./chunk-2TTT3V5O.js";
  5. import {
  6. Build
  7. } from "./chunk-IOZKU7B2.js";
  8. // node_modules/@esri/calcite-components/dist/components/debounce.js
  9. var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
  10. var freeSelf = typeof self == "object" && self && self.Object === Object && self;
  11. var root = freeGlobal || freeSelf || Function("return this")();
  12. var Symbol = root.Symbol;
  13. var objectProto$1 = Object.prototype;
  14. var hasOwnProperty = objectProto$1.hasOwnProperty;
  15. var nativeObjectToString$1 = objectProto$1.toString;
  16. var symToStringTag$1 = Symbol ? Symbol.toStringTag : void 0;
  17. function getRawTag(value) {
  18. var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
  19. try {
  20. value[symToStringTag$1] = void 0;
  21. var unmasked = true;
  22. } catch (e) {
  23. }
  24. var result = nativeObjectToString$1.call(value);
  25. if (unmasked) {
  26. if (isOwn) {
  27. value[symToStringTag$1] = tag;
  28. } else {
  29. delete value[symToStringTag$1];
  30. }
  31. }
  32. return result;
  33. }
  34. var objectProto = Object.prototype;
  35. var nativeObjectToString = objectProto.toString;
  36. function objectToString(value) {
  37. return nativeObjectToString.call(value);
  38. }
  39. var nullTag = "[object Null]";
  40. var undefinedTag = "[object Undefined]";
  41. var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
  42. function baseGetTag(value) {
  43. if (value == null) {
  44. return value === void 0 ? undefinedTag : nullTag;
  45. }
  46. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  47. }
  48. function isObjectLike(value) {
  49. return value != null && typeof value == "object";
  50. }
  51. var symbolTag = "[object Symbol]";
  52. function isSymbol(value) {
  53. return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
  54. }
  55. var reWhitespace = /\s/;
  56. function trimmedEndIndex(string) {
  57. var index = string.length;
  58. while (index-- && reWhitespace.test(string.charAt(index))) {
  59. }
  60. return index;
  61. }
  62. var reTrimStart = /^\s+/;
  63. function baseTrim(string) {
  64. return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
  65. }
  66. function isObject(value) {
  67. var type = typeof value;
  68. return value != null && (type == "object" || type == "function");
  69. }
  70. var NAN = 0 / 0;
  71. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  72. var reIsBinary = /^0b[01]+$/i;
  73. var reIsOctal = /^0o[0-7]+$/i;
  74. var freeParseInt = parseInt;
  75. function toNumber(value) {
  76. if (typeof value == "number") {
  77. return value;
  78. }
  79. if (isSymbol(value)) {
  80. return NAN;
  81. }
  82. if (isObject(value)) {
  83. var other = typeof value.valueOf == "function" ? value.valueOf() : value;
  84. value = isObject(other) ? other + "" : other;
  85. }
  86. if (typeof value != "string") {
  87. return value === 0 ? value : +value;
  88. }
  89. value = baseTrim(value);
  90. var isBinary = reIsBinary.test(value);
  91. return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
  92. }
  93. var now = function() {
  94. return root.Date.now();
  95. };
  96. var FUNC_ERROR_TEXT = "Expected a function";
  97. var nativeMax = Math.max;
  98. var nativeMin = Math.min;
  99. function debounce(func, wait, options) {
  100. var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
  101. if (typeof func != "function") {
  102. throw new TypeError(FUNC_ERROR_TEXT);
  103. }
  104. wait = toNumber(wait) || 0;
  105. if (isObject(options)) {
  106. leading = !!options.leading;
  107. maxing = "maxWait" in options;
  108. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  109. trailing = "trailing" in options ? !!options.trailing : trailing;
  110. }
  111. function invokeFunc(time) {
  112. var args = lastArgs, thisArg = lastThis;
  113. lastArgs = lastThis = void 0;
  114. lastInvokeTime = time;
  115. result = func.apply(thisArg, args);
  116. return result;
  117. }
  118. function leadingEdge(time) {
  119. lastInvokeTime = time;
  120. timerId = setTimeout(timerExpired, wait);
  121. return leading ? invokeFunc(time) : result;
  122. }
  123. function remainingWait(time) {
  124. var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
  125. return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
  126. }
  127. function shouldInvoke(time) {
  128. var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
  129. return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
  130. }
  131. function timerExpired() {
  132. var time = now();
  133. if (shouldInvoke(time)) {
  134. return trailingEdge(time);
  135. }
  136. timerId = setTimeout(timerExpired, remainingWait(time));
  137. }
  138. function trailingEdge(time) {
  139. timerId = void 0;
  140. if (trailing && lastArgs) {
  141. return invokeFunc(time);
  142. }
  143. lastArgs = lastThis = void 0;
  144. return result;
  145. }
  146. function cancel() {
  147. if (timerId !== void 0) {
  148. clearTimeout(timerId);
  149. }
  150. lastInvokeTime = 0;
  151. lastArgs = lastCallTime = lastThis = timerId = void 0;
  152. }
  153. function flush() {
  154. return timerId === void 0 ? result : trailingEdge(now());
  155. }
  156. function debounced() {
  157. var time = now(), isInvoking = shouldInvoke(time);
  158. lastArgs = arguments;
  159. lastThis = this;
  160. lastCallTime = time;
  161. if (isInvoking) {
  162. if (timerId === void 0) {
  163. return leadingEdge(lastCallTime);
  164. }
  165. if (maxing) {
  166. clearTimeout(timerId);
  167. timerId = setTimeout(timerExpired, wait);
  168. return invokeFunc(lastCallTime);
  169. }
  170. }
  171. if (timerId === void 0) {
  172. timerId = setTimeout(timerExpired, wait);
  173. }
  174. return result;
  175. }
  176. debounced.cancel = cancel;
  177. debounced.flush = flush;
  178. return debounced;
  179. }
  180. // node_modules/@esri/calcite-components/dist/components/floating-ui.js
  181. function getSide(placement) {
  182. return placement.split("-")[0];
  183. }
  184. function getAlignment(placement) {
  185. return placement.split("-")[1];
  186. }
  187. function getMainAxisFromPlacement(placement) {
  188. return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
  189. }
  190. function getLengthFromAxis(axis) {
  191. return axis === "y" ? "height" : "width";
  192. }
  193. function computeCoordsFromPlacement(_ref, placement, rtl) {
  194. let {
  195. reference,
  196. floating
  197. } = _ref;
  198. const commonX = reference.x + reference.width / 2 - floating.width / 2;
  199. const commonY = reference.y + reference.height / 2 - floating.height / 2;
  200. const mainAxis = getMainAxisFromPlacement(placement);
  201. const length = getLengthFromAxis(mainAxis);
  202. const commonAlign = reference[length] / 2 - floating[length] / 2;
  203. const side = getSide(placement);
  204. const isVertical = mainAxis === "x";
  205. let coords;
  206. switch (side) {
  207. case "top":
  208. coords = {
  209. x: commonX,
  210. y: reference.y - floating.height
  211. };
  212. break;
  213. case "bottom":
  214. coords = {
  215. x: commonX,
  216. y: reference.y + reference.height
  217. };
  218. break;
  219. case "right":
  220. coords = {
  221. x: reference.x + reference.width,
  222. y: commonY
  223. };
  224. break;
  225. case "left":
  226. coords = {
  227. x: reference.x - floating.width,
  228. y: commonY
  229. };
  230. break;
  231. default:
  232. coords = {
  233. x: reference.x,
  234. y: reference.y
  235. };
  236. }
  237. switch (getAlignment(placement)) {
  238. case "start":
  239. coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
  240. break;
  241. case "end":
  242. coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
  243. break;
  244. }
  245. return coords;
  246. }
  247. var computePosition$1 = async (reference, floating, config2) => {
  248. const {
  249. placement = "bottom",
  250. strategy = "absolute",
  251. middleware = [],
  252. platform: platform2
  253. } = config2;
  254. const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
  255. let rects = await platform2.getElementRects({
  256. reference,
  257. floating,
  258. strategy
  259. });
  260. let {
  261. x,
  262. y
  263. } = computeCoordsFromPlacement(rects, placement, rtl);
  264. let statefulPlacement = placement;
  265. let middlewareData = {};
  266. let resetCount = 0;
  267. for (let i = 0; i < middleware.length; i++) {
  268. const {
  269. name,
  270. fn
  271. } = middleware[i];
  272. const {
  273. x: nextX,
  274. y: nextY,
  275. data,
  276. reset
  277. } = await fn({
  278. x,
  279. y,
  280. initialPlacement: placement,
  281. placement: statefulPlacement,
  282. strategy,
  283. middlewareData,
  284. rects,
  285. platform: platform2,
  286. elements: {
  287. reference,
  288. floating
  289. }
  290. });
  291. x = nextX != null ? nextX : x;
  292. y = nextY != null ? nextY : y;
  293. middlewareData = {
  294. ...middlewareData,
  295. [name]: {
  296. ...middlewareData[name],
  297. ...data
  298. }
  299. };
  300. if (reset && resetCount <= 50) {
  301. resetCount++;
  302. if (typeof reset === "object") {
  303. if (reset.placement) {
  304. statefulPlacement = reset.placement;
  305. }
  306. if (reset.rects) {
  307. rects = reset.rects === true ? await platform2.getElementRects({
  308. reference,
  309. floating,
  310. strategy
  311. }) : reset.rects;
  312. }
  313. ({
  314. x,
  315. y
  316. } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
  317. }
  318. i = -1;
  319. continue;
  320. }
  321. }
  322. return {
  323. x,
  324. y,
  325. placement: statefulPlacement,
  326. strategy,
  327. middlewareData
  328. };
  329. };
  330. function expandPaddingObject(padding) {
  331. return {
  332. top: 0,
  333. right: 0,
  334. bottom: 0,
  335. left: 0,
  336. ...padding
  337. };
  338. }
  339. function getSideObjectFromPadding(padding) {
  340. return typeof padding !== "number" ? expandPaddingObject(padding) : {
  341. top: padding,
  342. right: padding,
  343. bottom: padding,
  344. left: padding
  345. };
  346. }
  347. function rectToClientRect(rect) {
  348. return {
  349. ...rect,
  350. top: rect.y,
  351. left: rect.x,
  352. right: rect.x + rect.width,
  353. bottom: rect.y + rect.height
  354. };
  355. }
  356. async function detectOverflow(middlewareArguments, options) {
  357. var _await$platform$isEle;
  358. if (options === void 0) {
  359. options = {};
  360. }
  361. const {
  362. x,
  363. y,
  364. platform: platform2,
  365. rects,
  366. elements,
  367. strategy
  368. } = middlewareArguments;
  369. const {
  370. boundary = "clippingAncestors",
  371. rootBoundary = "viewport",
  372. elementContext = "floating",
  373. altBoundary = false,
  374. padding = 0
  375. } = options;
  376. const paddingObject = getSideObjectFromPadding(padding);
  377. const altContext = elementContext === "floating" ? "reference" : "floating";
  378. const element = elements[altBoundary ? altContext : elementContext];
  379. const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
  380. element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
  381. boundary,
  382. rootBoundary,
  383. strategy
  384. }));
  385. const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
  386. rect: elementContext === "floating" ? {
  387. ...rects.floating,
  388. x,
  389. y
  390. } : rects.reference,
  391. offsetParent: await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating)),
  392. strategy
  393. }) : rects[elementContext]);
  394. return {
  395. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  396. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  397. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  398. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  399. };
  400. }
  401. var min$1 = Math.min;
  402. var max$1 = Math.max;
  403. function within(min$1$1, value, max$1$1) {
  404. return max$1(min$1$1, min$1(value, max$1$1));
  405. }
  406. var arrow = (options) => ({
  407. name: "arrow",
  408. options,
  409. async fn(middlewareArguments) {
  410. const {
  411. element,
  412. padding = 0
  413. } = options != null ? options : {};
  414. const {
  415. x,
  416. y,
  417. placement,
  418. rects,
  419. platform: platform2
  420. } = middlewareArguments;
  421. if (element == null) {
  422. return {};
  423. }
  424. const paddingObject = getSideObjectFromPadding(padding);
  425. const coords = {
  426. x,
  427. y
  428. };
  429. const axis = getMainAxisFromPlacement(placement);
  430. const alignment = getAlignment(placement);
  431. const length = getLengthFromAxis(axis);
  432. const arrowDimensions = await platform2.getDimensions(element);
  433. const minProp = axis === "y" ? "top" : "left";
  434. const maxProp = axis === "y" ? "bottom" : "right";
  435. const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
  436. const startDiff = coords[axis] - rects.reference[axis];
  437. const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
  438. let clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  439. if (clientSize === 0) {
  440. clientSize = rects.floating[length];
  441. }
  442. const centerToReference = endDiff / 2 - startDiff / 2;
  443. const min2 = paddingObject[minProp];
  444. const max2 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
  445. const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
  446. const offset2 = within(min2, center, max2);
  447. const alignmentPadding = alignment === "start" ? paddingObject[minProp] : paddingObject[maxProp];
  448. const shouldAddOffset = alignmentPadding > 0 && center !== offset2 && rects.reference[length] <= rects.floating[length];
  449. const alignmentOffset = shouldAddOffset ? center < min2 ? min2 - center : max2 - center : 0;
  450. return {
  451. [axis]: coords[axis] - alignmentOffset,
  452. data: {
  453. [axis]: offset2,
  454. centerOffset: center - offset2
  455. }
  456. };
  457. }
  458. });
  459. var hash$1 = {
  460. left: "right",
  461. right: "left",
  462. bottom: "top",
  463. top: "bottom"
  464. };
  465. function getOppositePlacement(placement) {
  466. return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
  467. }
  468. function getAlignmentSides(placement, rects, rtl) {
  469. if (rtl === void 0) {
  470. rtl = false;
  471. }
  472. const alignment = getAlignment(placement);
  473. const mainAxis = getMainAxisFromPlacement(placement);
  474. const length = getLengthFromAxis(mainAxis);
  475. let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
  476. if (rects.reference[length] > rects.floating[length]) {
  477. mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
  478. }
  479. return {
  480. main: mainAlignmentSide,
  481. cross: getOppositePlacement(mainAlignmentSide)
  482. };
  483. }
  484. var hash = {
  485. start: "end",
  486. end: "start"
  487. };
  488. function getOppositeAlignmentPlacement(placement) {
  489. return placement.replace(/start|end/g, (matched) => hash[matched]);
  490. }
  491. var sides = ["top", "right", "bottom", "left"];
  492. var allPlacements = sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
  493. function getPlacementList(alignment, autoAlignment, allowedPlacements) {
  494. const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
  495. return allowedPlacementsSortedByAlignment.filter((placement) => {
  496. if (alignment) {
  497. return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
  498. }
  499. return true;
  500. });
  501. }
  502. var autoPlacement = function(options) {
  503. if (options === void 0) {
  504. options = {};
  505. }
  506. return {
  507. name: "autoPlacement",
  508. options,
  509. async fn(middlewareArguments) {
  510. var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
  511. const {
  512. x,
  513. y,
  514. rects,
  515. middlewareData,
  516. placement,
  517. platform: platform2,
  518. elements
  519. } = middlewareArguments;
  520. const {
  521. alignment = null,
  522. allowedPlacements = allPlacements,
  523. autoAlignment = true,
  524. ...detectOverflowOptions
  525. } = options;
  526. const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
  527. const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
  528. const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
  529. const currentPlacement = placements[currentIndex];
  530. if (currentPlacement == null) {
  531. return {};
  532. }
  533. const {
  534. main,
  535. cross
  536. } = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
  537. if (placement !== currentPlacement) {
  538. return {
  539. x,
  540. y,
  541. reset: {
  542. placement: placements[0]
  543. }
  544. };
  545. }
  546. const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
  547. const allOverflows = [...(_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : [], {
  548. placement: currentPlacement,
  549. overflows: currentOverflows
  550. }];
  551. const nextPlacement = placements[currentIndex + 1];
  552. if (nextPlacement) {
  553. return {
  554. data: {
  555. index: currentIndex + 1,
  556. overflows: allOverflows
  557. },
  558. reset: {
  559. placement: nextPlacement
  560. }
  561. };
  562. }
  563. const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
  564. const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find((_ref) => {
  565. let {
  566. overflows
  567. } = _ref;
  568. return overflows.every((overflow2) => overflow2 <= 0);
  569. })) == null ? void 0 : _placementsSortedByLe.placement;
  570. const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
  571. if (resetPlacement !== placement) {
  572. return {
  573. data: {
  574. index: currentIndex + 1,
  575. overflows: allOverflows
  576. },
  577. reset: {
  578. placement: resetPlacement
  579. }
  580. };
  581. }
  582. return {};
  583. }
  584. };
  585. };
  586. function getExpandedPlacements(placement) {
  587. const oppositePlacement = getOppositePlacement(placement);
  588. return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
  589. }
  590. var flip = function(options) {
  591. if (options === void 0) {
  592. options = {};
  593. }
  594. return {
  595. name: "flip",
  596. options,
  597. async fn(middlewareArguments) {
  598. var _middlewareData$flip;
  599. const {
  600. placement,
  601. middlewareData,
  602. rects,
  603. initialPlacement,
  604. platform: platform2,
  605. elements
  606. } = middlewareArguments;
  607. const {
  608. mainAxis: checkMainAxis = true,
  609. crossAxis: checkCrossAxis = true,
  610. fallbackPlacements: specifiedFallbackPlacements,
  611. fallbackStrategy = "bestFit",
  612. flipAlignment = true,
  613. ...detectOverflowOptions
  614. } = options;
  615. const side = getSide(placement);
  616. const isBasePlacement = side === initialPlacement;
  617. const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
  618. const placements = [initialPlacement, ...fallbackPlacements];
  619. const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
  620. const overflows = [];
  621. let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
  622. if (checkMainAxis) {
  623. overflows.push(overflow[side]);
  624. }
  625. if (checkCrossAxis) {
  626. const {
  627. main,
  628. cross
  629. } = getAlignmentSides(placement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
  630. overflows.push(overflow[main], overflow[cross]);
  631. }
  632. overflowsData = [...overflowsData, {
  633. placement,
  634. overflows
  635. }];
  636. if (!overflows.every((side2) => side2 <= 0)) {
  637. var _middlewareData$flip$, _middlewareData$flip2;
  638. const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
  639. const nextPlacement = placements[nextIndex];
  640. if (nextPlacement) {
  641. return {
  642. data: {
  643. index: nextIndex,
  644. overflows: overflowsData
  645. },
  646. reset: {
  647. placement: nextPlacement
  648. }
  649. };
  650. }
  651. let resetPlacement = "bottom";
  652. switch (fallbackStrategy) {
  653. case "bestFit": {
  654. var _overflowsData$map$so;
  655. const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
  656. if (placement2) {
  657. resetPlacement = placement2;
  658. }
  659. break;
  660. }
  661. case "initialPlacement":
  662. resetPlacement = initialPlacement;
  663. break;
  664. }
  665. if (placement !== resetPlacement) {
  666. return {
  667. reset: {
  668. placement: resetPlacement
  669. }
  670. };
  671. }
  672. }
  673. return {};
  674. }
  675. };
  676. };
  677. function getSideOffsets(overflow, rect) {
  678. return {
  679. top: overflow.top - rect.height,
  680. right: overflow.right - rect.width,
  681. bottom: overflow.bottom - rect.height,
  682. left: overflow.left - rect.width
  683. };
  684. }
  685. function isAnySideFullyClipped(overflow) {
  686. return sides.some((side) => overflow[side] >= 0);
  687. }
  688. var hide = function(_temp) {
  689. let {
  690. strategy = "referenceHidden",
  691. ...detectOverflowOptions
  692. } = _temp === void 0 ? {} : _temp;
  693. return {
  694. name: "hide",
  695. async fn(middlewareArguments) {
  696. const {
  697. rects
  698. } = middlewareArguments;
  699. switch (strategy) {
  700. case "referenceHidden": {
  701. const overflow = await detectOverflow(middlewareArguments, {
  702. ...detectOverflowOptions,
  703. elementContext: "reference"
  704. });
  705. const offsets = getSideOffsets(overflow, rects.reference);
  706. return {
  707. data: {
  708. referenceHiddenOffsets: offsets,
  709. referenceHidden: isAnySideFullyClipped(offsets)
  710. }
  711. };
  712. }
  713. case "escaped": {
  714. const overflow = await detectOverflow(middlewareArguments, {
  715. ...detectOverflowOptions,
  716. altBoundary: true
  717. });
  718. const offsets = getSideOffsets(overflow, rects.floating);
  719. return {
  720. data: {
  721. escapedOffsets: offsets,
  722. escaped: isAnySideFullyClipped(offsets)
  723. }
  724. };
  725. }
  726. default: {
  727. return {};
  728. }
  729. }
  730. }
  731. };
  732. };
  733. async function convertValueToCoords(middlewareArguments, value) {
  734. const {
  735. placement,
  736. platform: platform2,
  737. elements
  738. } = middlewareArguments;
  739. const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
  740. const side = getSide(placement);
  741. const alignment = getAlignment(placement);
  742. const isVertical = getMainAxisFromPlacement(placement) === "x";
  743. const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
  744. const crossAxisMulti = rtl && isVertical ? -1 : 1;
  745. const rawValue = typeof value === "function" ? value(middlewareArguments) : value;
  746. let {
  747. mainAxis,
  748. crossAxis,
  749. alignmentAxis
  750. } = typeof rawValue === "number" ? {
  751. mainAxis: rawValue,
  752. crossAxis: 0,
  753. alignmentAxis: null
  754. } : {
  755. mainAxis: 0,
  756. crossAxis: 0,
  757. alignmentAxis: null,
  758. ...rawValue
  759. };
  760. if (alignment && typeof alignmentAxis === "number") {
  761. crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
  762. }
  763. return isVertical ? {
  764. x: crossAxis * crossAxisMulti,
  765. y: mainAxis * mainAxisMulti
  766. } : {
  767. x: mainAxis * mainAxisMulti,
  768. y: crossAxis * crossAxisMulti
  769. };
  770. }
  771. var offset = function(value) {
  772. if (value === void 0) {
  773. value = 0;
  774. }
  775. return {
  776. name: "offset",
  777. options: value,
  778. async fn(middlewareArguments) {
  779. const {
  780. x,
  781. y
  782. } = middlewareArguments;
  783. const diffCoords = await convertValueToCoords(middlewareArguments, value);
  784. return {
  785. x: x + diffCoords.x,
  786. y: y + diffCoords.y,
  787. data: diffCoords
  788. };
  789. }
  790. };
  791. };
  792. function getCrossAxis(axis) {
  793. return axis === "x" ? "y" : "x";
  794. }
  795. var shift = function(options) {
  796. if (options === void 0) {
  797. options = {};
  798. }
  799. return {
  800. name: "shift",
  801. options,
  802. async fn(middlewareArguments) {
  803. const {
  804. x,
  805. y,
  806. placement
  807. } = middlewareArguments;
  808. const {
  809. mainAxis: checkMainAxis = true,
  810. crossAxis: checkCrossAxis = false,
  811. limiter = {
  812. fn: (_ref) => {
  813. let {
  814. x: x2,
  815. y: y2
  816. } = _ref;
  817. return {
  818. x: x2,
  819. y: y2
  820. };
  821. }
  822. },
  823. ...detectOverflowOptions
  824. } = options;
  825. const coords = {
  826. x,
  827. y
  828. };
  829. const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
  830. const mainAxis = getMainAxisFromPlacement(getSide(placement));
  831. const crossAxis = getCrossAxis(mainAxis);
  832. let mainAxisCoord = coords[mainAxis];
  833. let crossAxisCoord = coords[crossAxis];
  834. if (checkMainAxis) {
  835. const minSide = mainAxis === "y" ? "top" : "left";
  836. const maxSide = mainAxis === "y" ? "bottom" : "right";
  837. const min2 = mainAxisCoord + overflow[minSide];
  838. const max2 = mainAxisCoord - overflow[maxSide];
  839. mainAxisCoord = within(min2, mainAxisCoord, max2);
  840. }
  841. if (checkCrossAxis) {
  842. const minSide = crossAxis === "y" ? "top" : "left";
  843. const maxSide = crossAxis === "y" ? "bottom" : "right";
  844. const min2 = crossAxisCoord + overflow[minSide];
  845. const max2 = crossAxisCoord - overflow[maxSide];
  846. crossAxisCoord = within(min2, crossAxisCoord, max2);
  847. }
  848. const limitedCoords = limiter.fn({
  849. ...middlewareArguments,
  850. [mainAxis]: mainAxisCoord,
  851. [crossAxis]: crossAxisCoord
  852. });
  853. return {
  854. ...limitedCoords,
  855. data: {
  856. x: limitedCoords.x - x,
  857. y: limitedCoords.y - y
  858. }
  859. };
  860. }
  861. };
  862. };
  863. function isWindow(value) {
  864. return value && value.document && value.location && value.alert && value.setInterval;
  865. }
  866. function getWindow(node) {
  867. if (node == null) {
  868. return window;
  869. }
  870. if (!isWindow(node)) {
  871. const ownerDocument = node.ownerDocument;
  872. return ownerDocument ? ownerDocument.defaultView || window : window;
  873. }
  874. return node;
  875. }
  876. function getComputedStyle(element) {
  877. return getWindow(element).getComputedStyle(element);
  878. }
  879. function getNodeName(node) {
  880. return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
  881. }
  882. function getUAString() {
  883. const uaData = navigator.userAgentData;
  884. if (uaData != null && uaData.brands) {
  885. return uaData.brands.map((item) => item.brand + "/" + item.version).join(" ");
  886. }
  887. return navigator.userAgent;
  888. }
  889. function isHTMLElement(value) {
  890. return value instanceof getWindow(value).HTMLElement;
  891. }
  892. function isElement(value) {
  893. return value instanceof getWindow(value).Element;
  894. }
  895. function isNode(value) {
  896. return value instanceof getWindow(value).Node;
  897. }
  898. function isShadowRoot(node) {
  899. if (typeof ShadowRoot === "undefined") {
  900. return false;
  901. }
  902. const OwnElement = getWindow(node).ShadowRoot;
  903. return node instanceof OwnElement || node instanceof ShadowRoot;
  904. }
  905. function isOverflowElement(element) {
  906. const {
  907. overflow,
  908. overflowX,
  909. overflowY,
  910. display
  911. } = getComputedStyle(element);
  912. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
  913. }
  914. function isTableElement(element) {
  915. return ["table", "td", "th"].includes(getNodeName(element));
  916. }
  917. function isContainingBlock(element) {
  918. const isFirefox = /firefox/i.test(getUAString());
  919. const css = getComputedStyle(element);
  920. return css.transform !== "none" || css.perspective !== "none" || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective"].some((value) => css.willChange.includes(value)) || ["paint", "layout", "strict", "content"].some(
  921. (value) => {
  922. const contain = css.contain;
  923. return contain != null ? contain.includes(value) : false;
  924. }
  925. );
  926. }
  927. function isLayoutViewport() {
  928. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  929. }
  930. function isLastTraversableNode(node) {
  931. return ["html", "body", "#document"].includes(getNodeName(node));
  932. }
  933. var min = Math.min;
  934. var max = Math.max;
  935. var round = Math.round;
  936. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  937. var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
  938. if (includeScale === void 0) {
  939. includeScale = false;
  940. }
  941. if (isFixedStrategy === void 0) {
  942. isFixedStrategy = false;
  943. }
  944. const clientRect = element.getBoundingClientRect();
  945. let scaleX = 1;
  946. let scaleY = 1;
  947. if (includeScale && isHTMLElement(element)) {
  948. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  949. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  950. }
  951. const win = isElement(element) ? getWindow(element) : window;
  952. const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  953. const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
  954. const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
  955. const width = clientRect.width / scaleX;
  956. const height = clientRect.height / scaleY;
  957. return {
  958. width,
  959. height,
  960. top: y,
  961. right: x + width,
  962. bottom: y + height,
  963. left: x,
  964. x,
  965. y
  966. };
  967. }
  968. function getDocumentElement(node) {
  969. return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
  970. }
  971. function getNodeScroll(element) {
  972. if (isElement(element)) {
  973. return {
  974. scrollLeft: element.scrollLeft,
  975. scrollTop: element.scrollTop
  976. };
  977. }
  978. return {
  979. scrollLeft: element.pageXOffset,
  980. scrollTop: element.pageYOffset
  981. };
  982. }
  983. function getWindowScrollBarX(element) {
  984. return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
  985. }
  986. function isScaled(element) {
  987. const rect = getBoundingClientRect(element);
  988. return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
  989. }
  990. function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
  991. const isOffsetParentAnElement = isHTMLElement(offsetParent);
  992. const documentElement = getDocumentElement(offsetParent);
  993. const rect = getBoundingClientRect(
  994. element,
  995. isOffsetParentAnElement && isScaled(offsetParent),
  996. strategy === "fixed"
  997. );
  998. let scroll = {
  999. scrollLeft: 0,
  1000. scrollTop: 0
  1001. };
  1002. const offsets = {
  1003. x: 0,
  1004. y: 0
  1005. };
  1006. if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
  1007. if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
  1008. scroll = getNodeScroll(offsetParent);
  1009. }
  1010. if (isHTMLElement(offsetParent)) {
  1011. const offsetRect = getBoundingClientRect(offsetParent, true);
  1012. offsets.x = offsetRect.x + offsetParent.clientLeft;
  1013. offsets.y = offsetRect.y + offsetParent.clientTop;
  1014. } else if (documentElement) {
  1015. offsets.x = getWindowScrollBarX(documentElement);
  1016. }
  1017. }
  1018. return {
  1019. x: rect.left + scroll.scrollLeft - offsets.x,
  1020. y: rect.top + scroll.scrollTop - offsets.y,
  1021. width: rect.width,
  1022. height: rect.height
  1023. };
  1024. }
  1025. function getParentNode(node) {
  1026. if (getNodeName(node) === "html") {
  1027. return node;
  1028. }
  1029. return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
  1030. }
  1031. function getTrueOffsetParent(element) {
  1032. if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
  1033. return null;
  1034. }
  1035. return element.offsetParent;
  1036. }
  1037. function getContainingBlock(element) {
  1038. let currentNode = getParentNode(element);
  1039. if (isShadowRoot(currentNode)) {
  1040. currentNode = currentNode.host;
  1041. }
  1042. while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
  1043. if (isContainingBlock(currentNode)) {
  1044. return currentNode;
  1045. } else {
  1046. const parent = currentNode.parentNode;
  1047. currentNode = isShadowRoot(parent) ? parent.host : parent;
  1048. }
  1049. }
  1050. return null;
  1051. }
  1052. function getOffsetParent(element) {
  1053. const window2 = getWindow(element);
  1054. let offsetParent = getTrueOffsetParent(element);
  1055. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
  1056. offsetParent = getTrueOffsetParent(offsetParent);
  1057. }
  1058. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
  1059. return window2;
  1060. }
  1061. return offsetParent || getContainingBlock(element) || window2;
  1062. }
  1063. function getDimensions(element) {
  1064. if (isHTMLElement(element)) {
  1065. return {
  1066. width: element.offsetWidth,
  1067. height: element.offsetHeight
  1068. };
  1069. }
  1070. const rect = getBoundingClientRect(element);
  1071. return {
  1072. width: rect.width,
  1073. height: rect.height
  1074. };
  1075. }
  1076. function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
  1077. let {
  1078. rect,
  1079. offsetParent,
  1080. strategy
  1081. } = _ref;
  1082. const isOffsetParentAnElement = isHTMLElement(offsetParent);
  1083. const documentElement = getDocumentElement(offsetParent);
  1084. if (offsetParent === documentElement) {
  1085. return rect;
  1086. }
  1087. let scroll = {
  1088. scrollLeft: 0,
  1089. scrollTop: 0
  1090. };
  1091. const offsets = {
  1092. x: 0,
  1093. y: 0
  1094. };
  1095. if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
  1096. if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
  1097. scroll = getNodeScroll(offsetParent);
  1098. }
  1099. if (isHTMLElement(offsetParent)) {
  1100. const offsetRect = getBoundingClientRect(offsetParent, true);
  1101. offsets.x = offsetRect.x + offsetParent.clientLeft;
  1102. offsets.y = offsetRect.y + offsetParent.clientTop;
  1103. }
  1104. }
  1105. return {
  1106. ...rect,
  1107. x: rect.x - scroll.scrollLeft + offsets.x,
  1108. y: rect.y - scroll.scrollTop + offsets.y
  1109. };
  1110. }
  1111. function getViewportRect(element, strategy) {
  1112. const win = getWindow(element);
  1113. const html = getDocumentElement(element);
  1114. const visualViewport = win.visualViewport;
  1115. let width = html.clientWidth;
  1116. let height = html.clientHeight;
  1117. let x = 0;
  1118. let y = 0;
  1119. if (visualViewport) {
  1120. width = visualViewport.width;
  1121. height = visualViewport.height;
  1122. const layoutViewport = isLayoutViewport();
  1123. if (layoutViewport || !layoutViewport && strategy === "fixed") {
  1124. x = visualViewport.offsetLeft;
  1125. y = visualViewport.offsetTop;
  1126. }
  1127. }
  1128. return {
  1129. width,
  1130. height,
  1131. x,
  1132. y
  1133. };
  1134. }
  1135. function getDocumentRect(element) {
  1136. var _element$ownerDocumen;
  1137. const html = getDocumentElement(element);
  1138. const scroll = getNodeScroll(element);
  1139. const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  1140. const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  1141. const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  1142. let x = -scroll.scrollLeft + getWindowScrollBarX(element);
  1143. const y = -scroll.scrollTop;
  1144. if (getComputedStyle(body || html).direction === "rtl") {
  1145. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  1146. }
  1147. return {
  1148. width,
  1149. height,
  1150. x,
  1151. y
  1152. };
  1153. }
  1154. function getNearestOverflowAncestor(node) {
  1155. const parentNode = getParentNode(node);
  1156. if (isLastTraversableNode(parentNode)) {
  1157. return node.ownerDocument.body;
  1158. }
  1159. if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
  1160. return parentNode;
  1161. }
  1162. return getNearestOverflowAncestor(parentNode);
  1163. }
  1164. function getOverflowAncestors(node, list) {
  1165. var _node$ownerDocument;
  1166. if (list === void 0) {
  1167. list = [];
  1168. }
  1169. const scrollableAncestor = getNearestOverflowAncestor(node);
  1170. const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
  1171. const win = getWindow(scrollableAncestor);
  1172. const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
  1173. const updatedList = list.concat(target);
  1174. return isBody ? updatedList : updatedList.concat(getOverflowAncestors(target));
  1175. }
  1176. function contains(parent, child) {
  1177. const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
  1178. if (parent.contains(child)) {
  1179. return true;
  1180. } else if (rootNode && isShadowRoot(rootNode)) {
  1181. let next = child;
  1182. do {
  1183. if (next && parent === next) {
  1184. return true;
  1185. }
  1186. next = next.parentNode || next.host;
  1187. } while (next);
  1188. }
  1189. return false;
  1190. }
  1191. function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
  1192. let currentNode = element;
  1193. while (currentNode && !isLastTraversableNode(currentNode) && !clippingAncestors.includes(currentNode)) {
  1194. if (isElement(currentNode) && ["absolute", "fixed"].includes(getComputedStyle(currentNode).position)) {
  1195. break;
  1196. }
  1197. const parentNode = getParentNode(currentNode);
  1198. currentNode = isShadowRoot(parentNode) ? parentNode.host : parentNode;
  1199. }
  1200. return currentNode;
  1201. }
  1202. function getInnerBoundingClientRect(element, strategy) {
  1203. const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
  1204. const top = clientRect.top + element.clientTop;
  1205. const left = clientRect.left + element.clientLeft;
  1206. return {
  1207. top,
  1208. left,
  1209. x: left,
  1210. y: top,
  1211. right: left + element.clientWidth,
  1212. bottom: top + element.clientHeight,
  1213. width: element.clientWidth,
  1214. height: element.clientHeight
  1215. };
  1216. }
  1217. function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
  1218. if (clippingParent === "viewport") {
  1219. return rectToClientRect(getViewportRect(element, strategy));
  1220. }
  1221. if (isElement(clippingParent)) {
  1222. return getInnerBoundingClientRect(clippingParent, strategy);
  1223. }
  1224. return rectToClientRect(getDocumentRect(getDocumentElement(element)));
  1225. }
  1226. function getClippingAncestors(element) {
  1227. const clippingAncestors = getOverflowAncestors(element);
  1228. const nearestEscapableParent = getNearestParentCapableOfEscapingClipping(element, clippingAncestors);
  1229. let clipperElement = null;
  1230. if (nearestEscapableParent && isHTMLElement(nearestEscapableParent)) {
  1231. const offsetParent = getOffsetParent(nearestEscapableParent);
  1232. if (isOverflowElement(nearestEscapableParent)) {
  1233. clipperElement = nearestEscapableParent;
  1234. } else if (isHTMLElement(offsetParent)) {
  1235. clipperElement = offsetParent;
  1236. }
  1237. }
  1238. if (!isElement(clipperElement)) {
  1239. return [];
  1240. }
  1241. return clippingAncestors.filter((clippingAncestors2) => clipperElement && isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName(clippingAncestors2) !== "body");
  1242. }
  1243. function getClippingRect(_ref) {
  1244. let {
  1245. element,
  1246. boundary,
  1247. rootBoundary,
  1248. strategy
  1249. } = _ref;
  1250. const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
  1251. const clippingAncestors = [...mainClippingAncestors, rootBoundary];
  1252. const firstClippingAncestor = clippingAncestors[0];
  1253. const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
  1254. const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
  1255. accRect.top = max(rect.top, accRect.top);
  1256. accRect.right = min(rect.right, accRect.right);
  1257. accRect.bottom = min(rect.bottom, accRect.bottom);
  1258. accRect.left = max(rect.left, accRect.left);
  1259. return accRect;
  1260. }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
  1261. return {
  1262. width: clippingRect.right - clippingRect.left,
  1263. height: clippingRect.bottom - clippingRect.top,
  1264. x: clippingRect.left,
  1265. y: clippingRect.top
  1266. };
  1267. }
  1268. var platform = {
  1269. getClippingRect,
  1270. convertOffsetParentRelativeRectToViewportRelativeRect,
  1271. isElement,
  1272. getDimensions,
  1273. getOffsetParent,
  1274. getDocumentElement,
  1275. getElementRects: (_ref) => {
  1276. let {
  1277. reference,
  1278. floating,
  1279. strategy
  1280. } = _ref;
  1281. return {
  1282. reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
  1283. floating: {
  1284. ...getDimensions(floating),
  1285. x: 0,
  1286. y: 0
  1287. }
  1288. };
  1289. },
  1290. getClientRects: (element) => Array.from(element.getClientRects()),
  1291. isRTL: (element) => getComputedStyle(element).direction === "rtl"
  1292. };
  1293. function autoUpdate(reference, floating, update, options) {
  1294. if (options === void 0) {
  1295. options = {};
  1296. }
  1297. const {
  1298. ancestorScroll: _ancestorScroll = true,
  1299. ancestorResize = true,
  1300. elementResize = true,
  1301. animationFrame = false
  1302. } = options;
  1303. const ancestorScroll = _ancestorScroll && !animationFrame;
  1304. const ancestors = ancestorScroll || ancestorResize ? [...isElement(reference) ? getOverflowAncestors(reference) : [], ...getOverflowAncestors(floating)] : [];
  1305. ancestors.forEach((ancestor) => {
  1306. ancestorScroll && ancestor.addEventListener("scroll", update, {
  1307. passive: true
  1308. });
  1309. ancestorResize && ancestor.addEventListener("resize", update);
  1310. });
  1311. let observer = null;
  1312. if (elementResize) {
  1313. let initialUpdate = true;
  1314. observer = new ResizeObserver(() => {
  1315. if (!initialUpdate) {
  1316. update();
  1317. }
  1318. initialUpdate = false;
  1319. });
  1320. isElement(reference) && !animationFrame && observer.observe(reference);
  1321. observer.observe(floating);
  1322. }
  1323. let frameId;
  1324. let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
  1325. if (animationFrame) {
  1326. frameLoop();
  1327. }
  1328. function frameLoop() {
  1329. const nextRefRect = getBoundingClientRect(reference);
  1330. if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
  1331. update();
  1332. }
  1333. prevRefRect = nextRefRect;
  1334. frameId = requestAnimationFrame(frameLoop);
  1335. }
  1336. update();
  1337. return () => {
  1338. var _observer;
  1339. ancestors.forEach((ancestor) => {
  1340. ancestorScroll && ancestor.removeEventListener("scroll", update);
  1341. ancestorResize && ancestor.removeEventListener("resize", update);
  1342. });
  1343. (_observer = observer) == null ? void 0 : _observer.disconnect();
  1344. observer = null;
  1345. if (animationFrame) {
  1346. cancelAnimationFrame(frameId);
  1347. }
  1348. };
  1349. }
  1350. var computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
  1351. platform,
  1352. ...options
  1353. });
  1354. var configOverrides = globalThis["calciteComponentsConfig"];
  1355. var config = {
  1356. floatingUINonChromiumPositioningFix: true,
  1357. ...configOverrides
  1358. };
  1359. var floatingUIBrowserCheck = patchFloatingUiForNonChromiumBrowsers();
  1360. async function patchFloatingUiForNonChromiumBrowsers() {
  1361. function getUAString2() {
  1362. const uaData = navigator.userAgentData;
  1363. if (uaData === null || uaData === void 0 ? void 0 : uaData.brands) {
  1364. return uaData.brands.map((item) => `${item.brand}/${item.version}`).join(" ");
  1365. }
  1366. return navigator.userAgent;
  1367. }
  1368. if (Build.isBrowser && config.floatingUINonChromiumPositioningFix && /firefox|safari/i.test(getUAString2())) {
  1369. const { getClippingRect: getClippingRect2, getElementRects, getOffsetParent: getOffsetParent2 } = await import("./nonChromiumPlatformUtils-WEX4VIW3.js");
  1370. platform.getClippingRect = getClippingRect2;
  1371. platform.getOffsetParent = getOffsetParent2;
  1372. platform.getElementRects = getElementRects;
  1373. }
  1374. }
  1375. var placementDataAttribute = "data-placement";
  1376. var repositionDebounceTimeout = 100;
  1377. var effectivePlacements = [
  1378. "top",
  1379. "bottom",
  1380. "right",
  1381. "left",
  1382. "top-start",
  1383. "top-end",
  1384. "bottom-start",
  1385. "bottom-end",
  1386. "right-start",
  1387. "right-end",
  1388. "left-start",
  1389. "left-end"
  1390. ];
  1391. var FloatingCSS = {
  1392. animation: "calcite-floating-ui-anim",
  1393. animationActive: "calcite-floating-ui-anim--active"
  1394. };
  1395. function getMiddleware({ placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, arrowEl, type }) {
  1396. const defaultMiddleware = [shift(), hide()];
  1397. if (type === "menu") {
  1398. return [
  1399. ...defaultMiddleware,
  1400. flip({
  1401. fallbackPlacements: flipPlacements || ["top-start", "top", "top-end", "bottom-start", "bottom", "bottom-end"]
  1402. })
  1403. ];
  1404. }
  1405. if (type === "popover" || type === "tooltip") {
  1406. const middleware = [
  1407. ...defaultMiddleware,
  1408. offset({
  1409. mainAxis: typeof offsetDistance === "number" ? offsetDistance : 0,
  1410. crossAxis: typeof offsetSkidding === "number" ? offsetSkidding : 0
  1411. })
  1412. ];
  1413. if (placement === "auto" || placement === "auto-start" || placement === "auto-end") {
  1414. middleware.push(autoPlacement({ alignment: placement === "auto-start" ? "start" : placement === "auto-end" ? "end" : null }));
  1415. } else if (!disableFlip) {
  1416. middleware.push(flip(flipPlacements ? { fallbackPlacements: flipPlacements } : {}));
  1417. }
  1418. if (arrowEl) {
  1419. middleware.push(arrow({
  1420. element: arrowEl
  1421. }));
  1422. }
  1423. return middleware;
  1424. }
  1425. return [];
  1426. }
  1427. function filterComputedPlacements(placements, el) {
  1428. const filteredPlacements = placements.filter((placement) => effectivePlacements.includes(placement));
  1429. if (filteredPlacements.length !== placements.length) {
  1430. console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${effectivePlacements.map((placement) => `"${placement}"`).join(", ").trim()}`, { el });
  1431. }
  1432. return filteredPlacements;
  1433. }
  1434. function getEffectivePlacement(floatingEl, placement) {
  1435. const placements = ["left", "right"];
  1436. if (getElementDir(floatingEl) === "rtl") {
  1437. placements.reverse();
  1438. }
  1439. return placement.replace(/-leading/gi, "-start").replace(/-trailing/gi, "-end").replace(/leading/gi, placements[0]).replace(/trailing/gi, placements[1]);
  1440. }
  1441. async function reposition(component, options, delayed = false) {
  1442. if (!component.open) {
  1443. return;
  1444. }
  1445. return delayed ? debouncedReposition(options) : positionFloatingUI(options);
  1446. }
  1447. var debouncedReposition = debounce(positionFloatingUI, repositionDebounceTimeout, {
  1448. leading: true,
  1449. maxWait: repositionDebounceTimeout
  1450. });
  1451. async function positionFloatingUI({ referenceEl, floatingEl, overlayPositioning = "absolute", placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, includeArrow = false, arrowEl, type }) {
  1452. var _a;
  1453. if (!referenceEl || !floatingEl || includeArrow && !arrowEl) {
  1454. return null;
  1455. }
  1456. await floatingUIBrowserCheck;
  1457. const { x, y, placement: effectivePlacement, strategy: position, middlewareData } = await computePosition(referenceEl, floatingEl, {
  1458. strategy: overlayPositioning,
  1459. placement: placement === "auto" || placement === "auto-start" || placement === "auto-end" ? void 0 : getEffectivePlacement(floatingEl, placement),
  1460. middleware: getMiddleware({
  1461. placement,
  1462. disableFlip,
  1463. flipPlacements,
  1464. offsetDistance,
  1465. offsetSkidding,
  1466. arrowEl,
  1467. type
  1468. })
  1469. });
  1470. if (middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.arrow) {
  1471. const { x: arrowX, y: arrowY } = middlewareData.arrow;
  1472. Object.assign(arrowEl.style, {
  1473. left: arrowX != null ? `${arrowX}px` : "",
  1474. top: arrowY != null ? `${arrowY}px` : ""
  1475. });
  1476. }
  1477. const referenceHidden = (_a = middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.hide) === null || _a === void 0 ? void 0 : _a.referenceHidden;
  1478. const visibility = referenceHidden ? "hidden" : null;
  1479. const pointerEvents = visibility ? "none" : null;
  1480. floatingEl.setAttribute(placementDataAttribute, effectivePlacement);
  1481. const transform = `translate(${Math.round(x)}px,${Math.round(y)}px)`;
  1482. Object.assign(floatingEl.style, {
  1483. visibility,
  1484. pointerEvents,
  1485. position,
  1486. top: "0",
  1487. left: "0",
  1488. transform
  1489. });
  1490. }
  1491. var cleanupMap = /* @__PURE__ */ new WeakMap();
  1492. function connectFloatingUI(component, referenceEl, floatingEl) {
  1493. if (!floatingEl || !referenceEl) {
  1494. return;
  1495. }
  1496. disconnectFloatingUI(component, referenceEl, floatingEl);
  1497. const position = component.overlayPositioning;
  1498. floatingEl.style.position = position;
  1499. if (position === "absolute") {
  1500. moveOffScreen(floatingEl);
  1501. }
  1502. const runAutoUpdate = Build.isBrowser ? autoUpdate : (_refEl, _floatingEl, updateCallback) => {
  1503. updateCallback();
  1504. return () => {
  1505. };
  1506. };
  1507. cleanupMap.set(component, runAutoUpdate(referenceEl, floatingEl, () => component.reposition()));
  1508. }
  1509. function disconnectFloatingUI(component, referenceEl, floatingEl) {
  1510. if (!floatingEl || !referenceEl) {
  1511. return;
  1512. }
  1513. getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
  1514. const cleanup = cleanupMap.get(component);
  1515. if (cleanup) {
  1516. cleanup();
  1517. }
  1518. cleanupMap.delete(component);
  1519. }
  1520. var visiblePointerSize = 4;
  1521. var defaultOffsetDistance = Math.ceil(Math.hypot(visiblePointerSize, visiblePointerSize));
  1522. function updateAfterClose(floatingEl) {
  1523. if (!floatingEl || floatingEl.style.position !== "absolute") {
  1524. return;
  1525. }
  1526. getTransitionTarget(floatingEl).addEventListener("transitionend", handleTransitionElTransitionEnd);
  1527. }
  1528. function getTransitionTarget(floatingEl) {
  1529. return floatingEl.shadowRoot || floatingEl;
  1530. }
  1531. function handleTransitionElTransitionEnd(event) {
  1532. const floatingTransitionEl = event.target;
  1533. if (event.propertyName === "opacity" && floatingTransitionEl.classList.contains(FloatingCSS.animation)) {
  1534. const floatingEl = getFloatingElFromTransitionTarget(floatingTransitionEl);
  1535. moveOffScreen(floatingEl);
  1536. getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
  1537. }
  1538. }
  1539. function moveOffScreen(floatingEl) {
  1540. floatingEl.style.transform = "";
  1541. floatingEl.style.top = "-99999px";
  1542. floatingEl.style.left = "-99999px";
  1543. }
  1544. function getFloatingElFromTransitionTarget(floatingTransitionEl) {
  1545. return closestElementCrossShadowBoundary(floatingTransitionEl, `[${placementDataAttribute}]`);
  1546. }
  1547. export {
  1548. rectToClientRect,
  1549. FloatingCSS,
  1550. filterComputedPlacements,
  1551. reposition,
  1552. connectFloatingUI,
  1553. disconnectFloatingUI,
  1554. defaultOffsetDistance,
  1555. updateAfterClose
  1556. };
  1557. /*!
  1558. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  1559. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  1560. * v1.0.0-beta.97
  1561. */
  1562. //# sourceMappingURL=chunk-LPWNO2ZS.js.map