1import { a1 as onCleanup, _ as mergeProps, aa as splitProps, i as createComponent, D as Dynamic, q as createSignal, m as createMemo, af as untrack, l as createEffect, Z as memo } from "./tr-UliDDw9Z.js"; 2import { a as access$1 } from "./U42ECMND-CpGP6a5I.js"; 3const isNonNullable = (i) => i != null; 4const filterNonNullable = (arr) => arr.filter(isNonNullable); 5function chain(callbacks) { 6 return (...args) => { 7 for (const callback of callbacks) callback && callback(...args); 8 }; 9} 10const access = (v) => typeof v === "function" && !v.length ? v() : v; 11const asArray = (value) => Array.isArray(value) ? value : value ? [value] : []; 12function accessWith(valueOrFn, ...args) { 13 return typeof valueOrFn === "function" ? valueOrFn(...args) : valueOrFn; 14} 15const tryOnCleanup = onCleanup; 16function handleDiffArray(current, prev, handleAdded, handleRemoved) { 17 const currLength = current.length; 18 const prevLength = prev.length; 19 let i = 0; 20 if (!prevLength) { 21 for (; i < currLength; i++) handleAdded(current[i]); 22 return; 23 } 24 if (!currLength) { 25 for (; i < prevLength; i++) handleRemoved(prev[i]); 26 return; 27 } 28 for (; i < prevLength; i++) { 29 if (prev[i] !== current[i]) break; 30 } 31 let prevEl; 32 let currEl; 33 prev = prev.slice(i); 34 current = current.slice(i); 35 for (prevEl of prev) { 36 if (!current.includes(prevEl)) handleRemoved(prevEl); 37 } 38 for (currEl of current) { 39 if (!prev.includes(currEl)) handleAdded(currEl); 40 } 41} 42const extractCSSregex = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g; 43function stringStyleToObject(style) { 44 const object = {}; 45 let match; 46 while (match = extractCSSregex.exec(style)) { 47 object[match[1]] = match[2]; 48 } 49 return object; 50} 51function combineStyle(a, b) { 52 if (typeof a === "string") { 53 if (typeof b === "string") return `${a};${b}`; 54 a = stringStyleToObject(a); 55 } else if (typeof b === "string") { 56 b = stringStyleToObject(b); 57 } 58 return { 59 ...a, 60 ...b 61 }; 62} 63function mergeRefs(...refs) { 64 return chain(refs); 65} 66function addItemToArray(array, item, index = -1) { 67 if (!(index in array)) { 68 return [...array, item]; 69 } 70 return [...array.slice(0, index), item, ...array.slice(index)]; 71} 72function removeItemFromArray(array, item) { 73 const updatedArray = [...array]; 74 const index = updatedArray.indexOf(item); 75 if (index !== -1) { 76 updatedArray.splice(index, 1); 77 } 78 return updatedArray; 79} 80function isNumber(value) { 81 return typeof value === "number"; 82} 83function isString(value) { 84 return Object.prototype.toString.call(value) === "[object String]"; 85} 86function isFunction(value) { 87 return typeof value === "function"; 88} 89function createGenerateId(baseId) { 90 return (suffix) => `${baseId()}-${suffix}`; 91} 92function contains(parent, child) { 93 if (!parent) { 94 return false; 95 } 96 return parent === child || parent.contains(child); 97} 98function getActiveElement(node, activeDescendant = false) { 99 const { 100 activeElement 101 } = getDocument(node); 102 if (!activeElement?.nodeName) { 103 return null; 104 } 105 if (isFrame(activeElement) && activeElement.contentDocument) { 106 return getActiveElement(activeElement.contentDocument.body, activeDescendant); 107 } 108 if (activeDescendant) { 109 const id = activeElement.getAttribute("aria-activedescendant"); 110 if (id) { 111 const element = getDocument(activeElement).getElementById(id); 112 if (element) { 113 return element; 114 } 115 } 116 } 117 return activeElement; 118} 119function getDocument(node) { 120 return node ? node.ownerDocument || node : document; 121} 122function isFrame(element) { 123 return element.tagName === "IFRAME"; 124} 125var EventKey = /* @__PURE__ */ ((EventKey2) => { 126 EventKey2["Escape"] = "Escape"; 127 EventKey2["Enter"] = "Enter"; 128 EventKey2["Tab"] = "Tab"; 129 EventKey2["Space"] = " "; 130 EventKey2["ArrowDown"] = "ArrowDown"; 131 EventKey2["ArrowLeft"] = "ArrowLeft"; 132 EventKey2["ArrowRight"] = "ArrowRight"; 133 EventKey2["ArrowUp"] = "ArrowUp"; 134 EventKey2["End"] = "End"; 135 EventKey2["Home"] = "Home"; 136 EventKey2["PageDown"] = "PageDown"; 137 EventKey2["PageUp"] = "PageUp"; 138 return EventKey2; 139})(EventKey || {}); 140function testUserAgent(re) { 141 if (typeof window === "undefined" || window.navigator == null) { 142 return false;
143 } 144 return ( 145 // @ts-ignore 146 window.navigator.userAgentData?.brands.some((brand) => re.test(brand.brand)) || re.test(window.navigator.userAgent) 147 ); 148} 149function testPlatform(re) { 150 return typeof window !== "undefined" && window.navigator != null ? re.test( 151 // @ts-ignore 152 window.navigator.userAgentData?.platform || window.navigator.platform 153 ) : false; 154} 155function isMac() { 156 return testPlatform(/^Mac/i); 157} 158function isIPhone() { 159 return testPlatform(/^iPhone/i); 160} 161function isIPad() { 162 return testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support. 163 isMac() && navigator.maxTouchPoints > 1; 164} 165function isIOS() { 166 return isIPhone() || isIPad(); 167} 168function isAppleDevice() { 169 return isMac() || isIOS(); 170} 171function isWebKit() { 172 return testUserAgent(/AppleWebKit/i) && !isChrome(); 173} 174function isChrome() { 175 return testUserAgent(/Chrome/i); 176} 177function callHandler(event, handler) { 178 if (handler) { 179 if (isFunction(handler)) { 180 handler(event); 181 } else { 182 handler[0](handler[1], event); 183 } 184 } 185 return event?.defaultPrevented; 186} 187function composeEventHandlers(handlers) { 188 return (event) => { 189 for (const handler of handlers) { 190 callHandler(event, handler); 191 } 192 }; 193} 194function isCtrlKey(e) { 195 if (isMac()) { 196 return e.metaKey && !e.ctrlKey; 197 } 198 return e.ctrlKey && !e.metaKey; 199} 200function focusWithoutScrolling(element) { 201 if (!element) { 202 return; 203 } 204 if (supportsPreventScroll()) { 205 element.focus({ 206 preventScroll: true 207 }); 208 } else { 209 const scrollableElements = getScrollableElements(element); 210 element.focus(); 211 restoreScrollPosition(scrollableElements); 212 } 213} 214var supportsPreventScrollCached = null; 215function supportsPreventScroll() { 216 if (supportsPreventScrollCached == null) { 217 supportsPreventScrollCached = false; 218 try { 219 const focusElem = document.createElement("div"); 220 focusElem.focus({ 221 get preventScroll() { 222 supportsPreventScrollCached = true; 223 return true; 224 } 225 }); 226 } catch (e) { 227 } 228 } 229 return supportsPreventScrollCached; 230} 231function getScrollableElements(element) { 232 let parent = element.parentNode; 233 const scrollableElements = []; 234 const rootScrollingElement = document.scrollingElement || document.documentElement; 235 while (parent instanceof HTMLElement && parent !== rootScrollingElement) { 236 if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) { 237 scrollableElements.push({ 238 element: parent, 239 scrollTop: parent.scrollTop, 240 scrollLeft: parent.scrollLeft 241 }); 242 } 243 parent = parent.parentNode; 244 } 245 if (rootScrollingElement instanceof HTMLElement) { 246 scrollableElements.push({ 247 element: rootScrollingElement, 248 scrollTop: rootScrollingElement.scrollTop, 249 scrollLeft: rootScrollingElement.scrollLeft 250 }); 251 } 252 return scrollableElements; 253} 254function restoreScrollPosition(scrollableElements) { 255 for (const { 256 element, 257 scrollTop, 258 scrollLeft 259 } of scrollableElements) { 260 element.scrollTop = scrollTop; 261 element.scrollLeft = scrollLeft; 262 } 263} 264var focusableElements = ["input:not([type='hidden']):not([disabled])", "select:not([disabled])", "textarea:not([disabled])", "button:not([disabled])", "a[href]", "area[href]", "[tabindex]", "iframe", "object", "embed", "audio[controls]", "video[controls]", "[contenteditable]:not([contenteditable='false'])"]; 265var tabbableElements = [...focusableElements, '[tabindex]:not([tabindex="-1"]):not([disabled])']; 266var FOCUSABLE_ELEMENT_SELECTOR = `${focusableElements.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`; 267var TABBABLE_ELEMENT_SELECTOR = tabbableElements.join(':not([hidden]):not([tabindex="-1"]),'); 268function getAllTabbableIn(container, includeContainer) { 269 const elements = Array.from(container.querySelectorAll(FOCUSABLE_ELEMENT_SELECTOR)); 270 const tabbableElements2 = elements.filter(isTabbable); 271 if (includeContainer && isTabbable(container)) { 272 tabbableElements2.unshift(container); 273 } 274 tabbableElements2.forEach((element, i) => { 275 if (isFrame(element) && element.contentDocument) { 276 const frameBody = element.contentDocument.body; 277 const allFrameTabbable = getAllTabbableIn(frameBody, false); 278 tabbableElements2.splice(i, 1, ...allFrameTabbable); 279 } 280 }); 281 return tabbableElements2; 282} 283function isTabbable(element) { 284 return isFocusable(element) && !hasNegativeTabIndex(element); 285} 286function isFocusable(element) { 287 return element.matches(FOCUSABLE_ELEMENT_SELECTOR) && isElementVisible(element); 288} 289function hasNegativeTabIndex(element) { 290 const tabIndex = Number.parseInt(element.getAttribute("tabindex") || "0", 10); 291 return tabIndex < 0; 292} 293function isElementVisible(element, childElement) { 294 return element.nodeName !== "#comment" && isStyleVisible(element) && isAttributeVisible(element, childElement) && (!element.parentElement || isElementVisible(element.parentElement, element)); 295} 296function isStyleVisible(element) { 297 if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) { 298 return false;
299 } 300 const { 301 display, 302 visibility 303 } = element.style; 304 let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse"; 305 if (isVisible) { 306 if (!element.ownerDocument.defaultView) { 307 return isVisible; 308 } 309 const { 310 getComputedStyle: getComputedStyle2 311 } = element.ownerDocument.defaultView; 312 const { 313 display: computedDisplay, 314 visibility: computedVisibility 315 } = getComputedStyle2(element); 316 isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse"; 317 } 318 return isVisible; 319} 320function isAttributeVisible(element, childElement) { 321 return !element.hasAttribute("hidden") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : true); 322} 323function getFocusableTreeWalker(root, opts, scope) { 324 const selector = opts?.tabbable ? TABBABLE_ELEMENT_SELECTOR : FOCUSABLE_ELEMENT_SELECTOR; 325 const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { 326 acceptNode(node) { 327 if (opts?.from?.contains(node)) { 328 return NodeFilter.FILTER_REJECT; 329 } 330 if (node.matches(selector) && isElementVisible(node) && true && (!opts?.accept || opts.accept(node))) { 331 return NodeFilter.FILTER_ACCEPT; 332 } 333 return NodeFilter.FILTER_SKIP; 334 } 335 }); 336 if (opts?.from) { 337 walker.currentNode = opts.from; 338 } 339 return walker; 340} 341function noop() { 342 return; 343} 344function mergeDefaultProps(defaultProps, props) { 345 return mergeProps(defaultProps, props); 346} 347var transitionsByElement = /* @__PURE__ */ new Map(); 348var transitionCallbacks = /* @__PURE__ */ new Set(); 349function setupGlobalEvents() { 350 if (typeof window === "undefined") { 351 return; 352 } 353 const onTransitionStart = (e) => { 354 if (!e.target) { 355 return; 356 } 357 let transitions = transitionsByElement.get(e.target); 358 if (!transitions) { 359 transitions = /* @__PURE__ */ new Set(); 360 transitionsByElement.set(e.target, transitions); 361 e.target.addEventListener("transitioncancel", onTransitionEnd); 362 } 363 transitions.add(e.propertyName); 364 }; 365 const onTransitionEnd = (e) => { 366 if (!e.target) { 367 return; 368 } 369 const properties = transitionsByElement.get(e.target); 370 if (!properties) { 371 return; 372 } 373 properties.delete(e.propertyName); 374 if (properties.size === 0) { 375 e.target.removeEventListener("transitioncancel", onTransitionEnd); 376 transitionsByElement.delete(e.target); 377 } 378 if (transitionsByElement.size === 0) { 379 for (const cb of transitionCallbacks) { 380 cb(); 381 } 382 transitionCallbacks.clear(); 383 } 384 }; 385 document.body.addEventListener("transitionrun", onTransitionStart); 386 document.body.addEventListener("transitionend", onTransitionEnd); 387} 388if (typeof document !== "undefined") { 389 if (document.readyState !== "loading") { 390 setupGlobalEvents(); 391 } else { 392 document.addEventListener("DOMContentLoaded", setupGlobalEvents); 393 } 394} 395function scrollIntoView(scrollView, element) { 396 const offsetX = relativeOffset(scrollView, element, "left"); 397 const offsetY = relativeOffset(scrollView, element, "top"); 398 const width = element.offsetWidth; 399 const height = element.offsetHeight; 400 let x = scrollView.scrollLeft; 401 let y = scrollView.scrollTop; 402 const maxX = x + scrollView.offsetWidth; 403 const maxY = y + scrollView.offsetHeight; 404 if (offsetX <= x) { 405 x = offsetX; 406 } else if (offsetX + width > maxX) { 407 x += offsetX + width - maxX; 408 } 409 if (offsetY <= y) { 410 y = offsetY; 411 } else if (offsetY + height > maxY) { 412 y += offsetY + height - maxY; 413 } 414 scrollView.scrollLeft = x; 415 scrollView.scrollTop = y; 416} 417function relativeOffset(ancestor, child, axis) { 418 const prop = axis === "left" ? "offsetLeft" : "offsetTop"; 419 let sum = 0; 420 while (child.offsetParent) { 421 sum += child[prop]; 422 if (child.offsetParent === ancestor) { 423 break; 424 } 425 if (child.offsetParent.contains(ancestor)) { 426 sum -= ancestor[prop]; 427 break; 428 } 429 child = child.offsetParent; 430 } 431 return sum; 432} 433var visuallyHiddenStyles = { 434 border: "0", 435 clip: "rect(0 0 0 0)", 436 "clip-path": "inset(50%)", 437 height: "1px", 438 margin: "0 -1px -1px 0", 439 overflow: "hidden", 440 padding: "0", 441 position: "absolute", 442 width: "1px", 443 "white-space": "nowrap" 444}; 445function Polymorphic(props) { 446 const [local, others] = splitProps(props, ["as"]); 447 if (!local.as) { 448 throw new Error("[kobalte]: Polymorphic is missing the required `as` prop."); 449 } 450 return ( 451 // @ts-ignore: Props are valid but not worth calculating 452 createComponent(Dynamic, mergeProps(others, { 453 get component() { 454 return local.as; 455 } 456 })) 457 ); 458} 459function createControllableSignal(props) { 460 const [_value, _setValue] = createSignal(props.defaultValue?.()); 461 const isControlled = createMemo(() => props.value?.() !== void 0); 462 const value = createMemo(() => isControlled() ? props.value?.() : _value()); 463 const setValue = (next) => { 464 untrack(() => { 465 const nextValue = accessWith(next, value()); 466 if (!Object.is(nextValue, value())) { 467 if (!isControlled()) {
468 _setValue(nextValue); 469 } 470 props.onChange?.(nextValue); 471 } 472 return nextValue; 473 }); 474 }; 475 return [value, setValue]; 476} 477function createControllableBooleanSignal(props) { 478 const [_value, setValue] = createControllableSignal(props); 479 const value = () => _value() ?? false; 480 return [value, setValue]; 481} 482function createControllableArraySignal(props) { 483 const [_value, setValue] = createControllableSignal(props); 484 const value = () => _value() ?? []; 485 return [value, setValue]; 486} 487function createDisclosureState(props = {}) { 488 const [isOpen, setIsOpen] = createControllableBooleanSignal({ 489 value: () => access(props.open), 490 defaultValue: () => !!access(props.defaultOpen), 491 onChange: (value) => props.onOpenChange?.(value) 492 }); 493 const open = () => { 494 setIsOpen(true); 495 }; 496 const close = () => { 497 setIsOpen(false); 498 }; 499 const toggle = () => { 500 isOpen() ? close() : open(); 501 }; 502 return { 503 isOpen, 504 setIsOpen, 505 open, 506 close, 507 toggle 508 }; 509} 510function createTagName(ref, fallback) { 511 const [tagName, setTagName] = createSignal(stringOrUndefined(fallback?.())); 512 createEffect(() => { 513 setTagName(ref()?.tagName.toLowerCase() || stringOrUndefined(fallback?.())); 514 }); 515 return tagName; 516} 517function stringOrUndefined(value) { 518 return isString(value) ? value : void 0; 519} 520var __defProp = Object.defineProperty; 521var __export = (target, all) => { 522 for (var name in all) __defProp(target, name, { 523 get: all[name], 524 enumerable: true 525 }); 526}; 527var button_exports = {}; 528__export(button_exports, { 529 Button: () => Button, 530 Root: () => ButtonRoot 531}); 532var BUTTON_INPUT_TYPES = ["button", "color", "file", "image", "reset", "submit"]; 533function isButton(element) { 534 const tagName = element.tagName.toLowerCase(); 535 if (tagName === "button") { 536 return true; 537 } 538 if (tagName === "input" && element.type) { 539 return BUTTON_INPUT_TYPES.indexOf(element.type) !== -1; 540 } 541 return false; 542} 543function ButtonRoot(props) { 544 let ref; 545 const mergedProps = mergeDefaultProps({ 546 type: "button" 547 }, props); 548 const [local, others] = splitProps(mergedProps, ["ref", "type", "disabled"]); 549 const tagName = createTagName(() => ref, () => "button"); 550 const isNativeButton = createMemo(() => { 551 const elementTagName = tagName(); 552 if (elementTagName == null) { 553 return false; 554 } 555 return isButton({ 556 tagName: elementTagName, 557 type: local.type 558 }); 559 }); 560 const isNativeInput = createMemo(() => { 561 return tagName() === "input"; 562 }); 563 const isNativeLink = createMemo(() => { 564 return tagName() === "a" && ref?.getAttribute("href") != null; 565 }); 566 return createComponent(Polymorphic, mergeProps({ 567 as: "button", 568 ref(r$) { 569 var _ref$ = mergeRefs((el) => ref = el, local.ref); 570 typeof _ref$ === "function" && _ref$(r$); 571 }, 572 get type() { 573 return memo(() => !!(isNativeButton() || isNativeInput()))() ? local.type : void 0; 574 }, 575 get role() { 576 return !isNativeButton() && !isNativeLink() ? "button" : void 0; 577 }, 578 get tabIndex() { 579 return !isNativeButton() && !isNativeLink() && !local.disabled ? 0 : void 0; 580 }, 581 get disabled() { 582 return memo(() => !!(isNativeButton() || isNativeInput()))() ? local.disabled : void 0; 583 }, 584 get ["aria-disabled"]() { 585 return !isNativeButton() && !isNativeInput() && local.disabled ? true : void 0; 586 }, 587 get ["data-disabled"]() { 588 return local.disabled ? "" : void 0; 589 } 590 }, others)); 591} 592var Button = ButtonRoot; 593function createRegisterId(setter) { 594 return (id) => { 595 setter(id); 596 return () => setter(void 0); 597 }; 598} 599var createPresence = (props) => { 600 const refStyles = createMemo(() => { 601 const element = access$1(props.element); 602 if (!element) return; 603 return getComputedStyle(element); 604 }); 605 const getAnimationName = () => { 606 return refStyles()?.animationName ?? "none"; 607 }; 608 const [presentState, setPresentState] = createSignal(access$1(props.show) ? "present" : "hidden"); 609 let animationName = "none"; 610 createEffect((prevShow) => { 611 const show = access$1(props.show); 612 untrack(() => { 613 if (prevShow === show) return show; 614 const prevAnimationName = animationName; 615 const currentAnimationName = getAnimationName(); 616 if (show) { 617 setPresentState("present"); 618 } else if (currentAnimationName === "none" || refStyles()?.display === "none") { 619 setPresentState("hidden"); 620 } else { 621 const isAnimating = prevAnimationName !== currentAnimationName; 622 if (prevShow === true && isAnimating) { 623 setPresentState("hiding"); 624 } else { 625 setPresentState("hidden"); 626 } 627 } 628 }); 629 return show; 630 });
631 createEffect(() => { 632 const element = access$1(props.element); 633 if (!element) return; 634 const handleAnimationStart = (event) => { 635 if (event.target === element) { 636 animationName = getAnimationName(); 637 } 638 }; 639 const handleAnimationEnd = (event) => { 640 const currentAnimationName = getAnimationName(); 641 const isCurrentAnimation = currentAnimationName.includes(event.animationName); 642 if (event.target === element && isCurrentAnimation && presentState() === "hiding") { 643 setPresentState("hidden"); 644 } 645 }; 646 element.addEventListener("animationstart", handleAnimationStart); 647 element.addEventListener("animationcancel", handleAnimationEnd); 648 element.addEventListener("animationend", handleAnimationEnd); 649 onCleanup(() => { 650 element.removeEventListener("animationstart", handleAnimationStart); 651 element.removeEventListener("animationcancel", handleAnimationEnd); 652 element.removeEventListener("animationend", handleAnimationEnd); 653 }); 654 }); 655 return { 656 present: () => presentState() === "present" || presentState() === "hiding", 657 state: presentState, 658 setState: setPresentState 659 }; 660}; 661var presence_default = createPresence; 662var src_default = presence_default; 663export { 664 mergeDefaultProps as A, 665 ButtonRoot as B, 666 mergeRefs as C, 667 noop as D, 668 EventKey as E, 669 removeItemFromArray as F, 670 scrollIntoView as G, 671 src_default as H, 672 tryOnCleanup as I, 673 visuallyHiddenStyles as J, 674 Polymorphic as P, 675 __export as _, 676 access as a, 677 addItemToArray as b, 678 asArray as c, 679 callHandler as d, 680 combineStyle as e, 681 composeEventHandlers as f, 682 contains as g, 683 createControllableArraySignal as h, 684 createControllableSignal as i, 685 createDisclosureState as j, 686 createGenerateId as k, 687 createRegisterId as l, 688 filterNonNullable as m, 689 focusWithoutScrolling as n, 690 getActiveElement as o, 691 getAllTabbableIn as p, 692 getDocument as q, 693 getFocusableTreeWalker as r, 694 handleDiffArray as s, 695 isAppleDevice as t, 696 isCtrlKey as u, 697 isFocusable as v, 698 isMac as w, 699 isNumber as x, 700 isString as y, 701 isWebKit as z 702};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.