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AAU,IAAI;IAClB,IAAI,eAAe,MAAM,OAAO,CAAC,UAAU,SAAS;QAAC;KAAO;IAE5D,KAAK,IAAI,eAAe,aAAc;QACpC,IAAI,eAAe,YAAY,KAAK,CAAC,gBAAgB,CAAC;QACtD,IAAI,kBAAkB,YAAY,KAAK,CAAC,mBAAmB,CAAC;QAE5D,YAAY,KAAK,CAAC,WAAW,CAAC,UAAU,OAAO;QAE/C,QAAQ,OAAO,CAAC;YACd,IAAI,cACF,YAAY,KAAK,CAAC,WAAW,CAAC,UAAU,cAAc;iBAEtD,YAAY,KAAK,CAAC,cAAc,CAAC;QAErC;IACF;IAEA,OAAO;QACL,KAAK,IAAI,WAAW,QAClB;IAEJ;AACF","sources":["packages/react-aria/src/utils/domHelpers.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {EventMapType} from '@react-types/shared';\n\nexport const getOwnerDocument = (target?: EventTarget | null): Document => {\n  if (isWindow(target)) return target.document;\n\n  if (isDocument(target)) return target;\n\n  // @ts-expect-error Ensure safe access in SSR environments.\n  return target?.ownerDocument ?? (typeof document !== 'undefined' ? document : undefined);\n};\n\nexport const getOwnerWindow = (target?: EventTarget | null): Window & typeof globalThis => {\n  let ownerDocument = getOwnerDocument(target);\n\n  // @ts-expect-error Ensure safe access in SSR environments.\n  return ownerDocument?.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n};\n\n/**\n * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType\n * property.\n */\nexport function isNode(value: unknown): value is Node {\n  return (\n    value !== null &&\n    typeof value === 'object' &&\n    'nodeType' in value &&\n    typeof value.nodeType === 'number'\n  );\n}\n\n/**\n * Type guard that checks if a value is a Window. Uses window self reference checks to\n * distinguish Window from other values.\n */\nfunction isWindow(value: unknown): value is Window & typeof globalThis {\n  return typeof value === 'object' && value != null && 'window' in value && value.window === value;\n}\n\n/**\n * Type guard that checks if a value is a Document. Uses nodeType and host property checks to\n * distinguish Document from other values.\n */\nexport function isDocument(value: unknown): value is Document {\n  return isNode(value) && value.nodeType === 9;\n}\n\n/**\n * Type guard that checks if a value is a ShadowRoot. Uses nodeType and host property checks to\n * distinguish ShadowRoot from other values.\n */\nexport function isShadowRoot(value: unknown): value is ShadowRoot {\n  // 11 = DOCUMENT_FRAGMENT_NODE\n  return isNode(value) && value.nodeType === 11 && 'host' in value;\n}\n\n/**\n * Attaches an event listener on target(s) and returns a cleanup function.\n */\nexport function addEvent<T extends EventTarget, K extends keyof EventMapType<Exclude<T, null>>>(\n  target: T | EventTarget[] | null,\n  event: Extract<K, string> | (string & {}),\n  listener?: (this: T, ev: EventMapType<Exclude<T, null>>[K]) => any,\n  options?: boolean | AddEventListenerOptions\n): () => void {\n  if (listener == null || target == null) {\n    return () => {};\n  }\n\n  let eventTargets = Array.isArray(target) ? target : [target];\n\n  for (let eventTarget of eventTargets) {\n    eventTarget.addEventListener(event, listener as EventListener, options);\n  }\n\n  return () => {\n    for (let eventTarget of eventTargets) {\n      eventTarget.removeEventListener(event, listener as EventListener, options);\n    }\n  };\n}\n\n/**\n * Sets a CSS property on an element and returns a cleanup function.\n */\nexport function setStyle(\n  target: HTMLElement | HTMLElement[] | null,\n  property: string,\n  value: string,\n  priority?: string\n): () => void {\n  if (target == null) {\n    return () => {};\n  }\n\n  let restore = new Array<Function>();\n  let styleTargets = Array.isArray(target) ? target : [target];\n\n  for (let styleTarget of styleTargets) {\n    let initialValue = styleTarget.style.getPropertyValue(property);\n    let initialPriority = styleTarget.style.getPropertyPriority(property);\n\n    styleTarget.style.setProperty(property, value, priority);\n\n    restore.unshift(() => {\n      if (initialValue) {\n        styleTarget.style.setProperty(property, initialValue, initialPriority);\n      } else {\n        styleTarget.style.removeProperty(property);\n      }\n    });\n  }\n\n  return () => {\n    for (let cleanup of restore) {\n      cleanup();\n    }\n  };\n}\n"],"names":[],"version":3,"file":"domHelpers.cjs.map"}