{"version":3,"file":"getKeyboardHeight.mjs","names":[],"sources":["../../../src/utils/getKeyboardHeight/getKeyboardHeight.ts"],"sourcesContent":["import { isServer } from '../isServer/index.ts';\n\n/**\n * @description\n * `getKeyboardHeight` is a utility function that returns the current on-screen keyboard height in pixels.\n *\n * This function uses the Visual Viewport API to calculate the keyboard height.\n * It assumes a modern environment where Visual Viewport is supported\n * (Safari / WKWebView 14+, Chrome / Android WebView 80+).\n *\n * The keyboard height is computed as:\n *   `window.innerHeight - visualViewport.height - visualViewport.offsetTop`\n *\n * The subtraction of `offsetTop` is required to correctly handle iOS behavior\n * where the visual viewport may shift vertically when the keyboard appears.\n *\n * @returns {number} The keyboard height in pixels. Returns 0 if the keyboard is not visible.\n *\n * @example\n * const height = getKeyboardHeight();\n *\n * if (height > 0) {\n *   footer.style.paddingBottom = `${height}px`;\n * }\n */\nexport function getKeyboardHeight(): number {\n  if (isServer()) {\n    return 0;\n  }\n\n  const visualViewport = window.visualViewport;\n  if (visualViewport == null) {\n    // Defensive guard; not expected to run in supported environments\n    return 0;\n  }\n  const height = window.innerHeight - visualViewport.height - visualViewport.offsetTop;\n  return Math.max(0, height);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,oBAA4B;CAC1C,IAAI,SAAS,GACX,OAAO;CAGT,MAAM,iBAAiB,OAAO;CAC9B,IAAI,kBAAkB,MAEpB,OAAO;CAET,MAAM,SAAS,OAAO,cAAc,eAAe,SAAS,eAAe;CAC3E,OAAO,KAAK,IAAI,GAAG,MAAM;AAC3B"}