{"ast":null,"code":"import isSelectionValid from \"../../modules/isSelectionValid\";\nvar keyName = '__reactResponderId';\n\nfunction getEventPath(domEvent) {\n  if (domEvent.type === 'selectionchange') {\n    var target = window.getSelection().anchorNode;\n    return composedPathFallback(target);\n  } else {\n    var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);\n    return path;\n  }\n}\n\nfunction composedPathFallback(target) {\n  var path = [];\n\n  while (target != null && target !== document.body) {\n    path.push(target);\n    target = target.parentNode;\n  }\n\n  return path;\n}\n\nfunction getResponderId(node) {\n  if (node != null) {\n    return node[keyName];\n  }\n\n  return null;\n}\n\nexport function setResponderId(node, id) {\n  if (node != null) {\n    node[keyName] = id;\n  }\n}\nexport function getResponderPaths(domEvent) {\n  var idPath = [];\n  var nodePath = [];\n  var eventPath = getEventPath(domEvent);\n\n  for (var i = 0; i < eventPath.length; i++) {\n    var node = eventPath[i];\n    var id = getResponderId(node);\n\n    if (id != null) {\n      idPath.push(id);\n      nodePath.push(node);\n    }\n  }\n\n  return {\n    idPath: idPath,\n    nodePath: nodePath\n  };\n}\nexport function getLowestCommonAncestor(pathA, pathB) {\n  var pathALength = pathA.length;\n  var pathBLength = pathB.length;\n\n  if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {\n    return null;\n  }\n\n  var itemA = pathA[0];\n  var indexA = 0;\n  var itemB = pathB[0];\n  var indexB = 0;\n\n  if (pathALength - pathBLength > 0) {\n    indexA = pathALength - pathBLength;\n    itemA = pathA[indexA];\n    pathALength = pathBLength;\n  }\n\n  if (pathBLength - pathALength > 0) {\n    indexB = pathBLength - pathALength;\n    itemB = pathB[indexB];\n    pathBLength = pathALength;\n  }\n\n  var depth = pathALength;\n\n  while (depth--) {\n    if (itemA === itemB) {\n      return itemA;\n    }\n\n    itemA = pathA[indexA++];\n    itemB = pathB[indexB++];\n  }\n\n  return null;\n}\nexport function hasTargetTouches(target, touches) {\n  if (!touches || touches.length === 0) {\n    return false;\n  }\n\n  for (var i = 0; i < touches.length; i++) {\n    var node = touches[i].target;\n\n    if (node != null) {\n      if (target.contains(node)) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\nexport function hasValidSelection(domEvent) {\n  if (domEvent.type === 'selectionchange') {\n    return isSelectionValid();\n  }\n\n  return domEvent.type === 'select';\n}\nexport function isPrimaryPointerDown(domEvent) {\n  var altKey = domEvent.altKey,\n      button = domEvent.button,\n      buttons = domEvent.buttons,\n      ctrlKey = domEvent.ctrlKey,\n      type = domEvent.type;\n  var isTouch = type === 'touchstart' || type === 'touchmove';\n  var isPrimaryMouseDown = type === 'mousedown' && (button === 0 || buttons === 1);\n  var isPrimaryMouseMove = type === 'mousemove' && buttons === 1;\n  var noModifiers = altKey === false && ctrlKey === false;\n\n  if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {\n    return true;\n  }\n\n  return false;\n}","map":{"version":3,"sources":["/Users/nishan/Desktop/oss/responsive-breakpoints/example/node_modules/react-native-web/dist/modules/useResponderEvents/utils.js"],"names":["isSelectionValid","keyName","getEventPath","domEvent","type","target","window","getSelection","anchorNode","composedPathFallback","path","composedPath","document","body","push","parentNode","getResponderId","node","setResponderId","id","getResponderPaths","idPath","nodePath","eventPath","i","length","getLowestCommonAncestor","pathA","pathB","pathALength","pathBLength","itemA","indexA","itemB","indexB","depth","hasTargetTouches","touches","contains","hasValidSelection","isPrimaryPointerDown","altKey","button","buttons","ctrlKey","isTouch","isPrimaryMouseDown","isPrimaryMouseMove","noModifiers"],"mappings":"AAQA,OAAOA,gBAAP;AACA,IAAIC,OAAO,GAAG,oBAAd;;AAEA,SAASC,YAAT,CAAsBC,QAAtB,EAAgC;AAI9B,MAAIA,QAAQ,CAACC,IAAT,KAAkB,iBAAtB,EAAyC;AACvC,QAAIC,MAAM,GAAGC,MAAM,CAACC,YAAP,GAAsBC,UAAnC;AACA,WAAOC,oBAAoB,CAACJ,MAAD,CAA3B;AACD,GAHD,MAGO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ArD,CAAzB;AACA,MAAII,kBAAkB,GAAG3C,IAAI,KAAK,WAAT,IAAwBuC,OAAO,KAAK,CAA7D;AACA,MAAIK,WAAW,GAAGP,MAAM,KAAK,KAAX,IAAoBG,OAAO,KAAK,KAAlD;;AAEA,MAAIC,OAAO,IAAIC,kBAAkB,IAAIE,WAAjC,IAAgDD,kBAAkB,IAAIC,WAA1E,EAAuF;AACrF,WAAO,IAAP;AACD;;AAED,SAAO,KAAP;AACD","sourcesContent":["/**\n * Copyright (c) Nicolas Gallagher\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport isSelectionValid from '../../modules/isSelectionValid';\nvar keyName = '__reactResponderId';\n\nfunction getEventPath(domEvent) {\n  // The 'selectionchange' event always has the 'document' as the target.\n  // Use the anchor node as the initial target to reconstruct a path.\n  // (We actually only need the first \"responder\" node in practice.)\n  if (domEvent.type === 'selectionchange') {\n    var target = window.getSelection().anchorNode;\n    return composedPathFallback(target);\n  } else {\n    var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);\n    return path;\n  }\n}\n\nfunction composedPathFallback(target) {\n  var path = [];\n\n  while (target != null && target !== document.body) {\n    path.push(target);\n    target = target.parentNode;\n  }\n\n  return path;\n}\n/**\n * Retrieve the responderId from a host node\n */\n\n\nfunction getResponderId(node) {\n  if (node != null) {\n    return node[keyName];\n  }\n\n  return null;\n}\n/**\n * Store the responderId on a host node\n */\n\n\nexport function setResponderId(node, id) {\n  if (node != null) {\n    node[keyName] = id;\n  }\n}\n/**\n * Filter the event path to contain only the nodes attached to the responder system\n */\n\nexport function getResponderPaths(domEvent) {\n  var idPath = [];\n  var nodePath = [];\n  var eventPath = getEventPath(domEvent);\n\n  for (var i = 0; i < eventPath.length; i++) {\n    var node = eventPath[i];\n    var id = getResponderId(node);\n\n    if (id != null) {\n      idPath.push(id);\n      nodePath.push(node);\n    }\n  }\n\n  return {\n    idPath: idPath,\n    nodePath: nodePath\n  };\n}\n/**\n * Walk the paths and find the first common ancestor\n */\n\nexport function getLowestCommonAncestor(pathA, pathB) {\n  var pathALength = pathA.length;\n  var pathBLength = pathB.length;\n\n  if ( // If either path is empty\n  pathALength === 0 || pathBLength === 0 || // If the last elements aren't the same there can't be a common ancestor\n  // that is connected to the responder system\n  pathA[pathALength - 1] !== pathB[pathBLength - 1]) {\n    return null;\n  }\n\n  var itemA = pathA[0];\n  var indexA = 0;\n  var itemB = pathB[0];\n  var indexB = 0; // If A is deeper, skip indices that can't match.\n\n  if (pathALength - pathBLength > 0) {\n    indexA = pathALength - pathBLength;\n    itemA = pathA[indexA];\n    pathALength = pathBLength;\n  } // If B is deeper, skip indices that can't match\n\n\n  if (pathBLength - pathALength > 0) {\n    indexB = pathBLength - pathALength;\n    itemB = pathB[indexB];\n    pathBLength = pathALength;\n  } // Walk in lockstep until a match is found\n\n\n  var depth = pathALength;\n\n  while (depth--) {\n    if (itemA === itemB) {\n      return itemA;\n    }\n\n    itemA = pathA[indexA++];\n    itemB = pathB[indexB++];\n  }\n\n  return null;\n}\n/**\n * Determine whether any of the active touches are within the current responder.\n * This cannot rely on W3C `targetTouches`, as neither IE11 nor Safari implement it.\n */\n\nexport function hasTargetTouches(target, touches) {\n  if (!touches || touches.length === 0) {\n    return false;\n  }\n\n  for (var i = 0; i < touches.length; i++) {\n    var node = touches[i].target;\n\n    if (node != null) {\n      if (target.contains(node)) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n/**\n * Ignore 'selectionchange' events that don't correspond with a person's intent to\n * select text.\n */\n\nexport function hasValidSelection(domEvent) {\n  if (domEvent.type === 'selectionchange') {\n    return isSelectionValid();\n  }\n\n  return domEvent.type === 'select';\n}\n/**\n * Events are only valid if the primary button was used without specific modifier keys.\n */\n\nexport function isPrimaryPointerDown(domEvent) {\n  var altKey = domEvent.altKey,\n      button = domEvent.button,\n      buttons = domEvent.buttons,\n      ctrlKey = domEvent.ctrlKey,\n      type = domEvent.type;\n  var isTouch = type === 'touchstart' || type === 'touchmove';\n  var isPrimaryMouseDown = type === 'mousedown' && (button === 0 || buttons === 1);\n  var isPrimaryMouseMove = type === 'mousemove' && buttons === 1;\n  var noModifiers = altKey === false && ctrlKey === false;\n\n  if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {\n    return true;\n  }\n\n  return false;\n}"]},"metadata":{},"sourceType":"module"}