{"version":3,"file":"clientUtils-0cdb4ef3.js","sources":["../../src/components/composables/clientUtils.ts"],"sourcesContent":["import { debounce } from \"lodash-es\";\nimport { onBeforeUnmount, onMounted, ref } from \"vue\";\n\n/**\n * Provides reactive values for client height and width properties\n */\nexport const useClientSize = () => {\n const clientWidth = ref(document.documentElement.clientWidth);\n const clientHeight = ref(document.documentElement.clientHeight);\n\n const handleResizeEvent = () => {\n clientWidth.value = document.documentElement.clientWidth;\n clientHeight.value = document.documentElement.clientHeight;\n };\n\n const handleResizeEventDebounced = debounce(handleResizeEvent, 300);\n\n onMounted(() => {\n window.addEventListener(\"resize\", handleResizeEventDebounced);\n });\n\n onBeforeUnmount(() => {\n window.removeEventListener(\"resize\", handleResizeEventDebounced);\n });\n\n return {\n clientWidth,\n clientHeight,\n };\n};\n\n/**\n * Allows toggling and current state of fullscreen mode\n */\nexport const useFullscreen = () => {\n const isFullscreen = ref(false);\n const prefixes = [\"\", \"ms\", \"webkit\"];\n\n const documentElementFullscreenExtended =\n document.documentElement as HTMLElement & {\n mozRequestFullScreen: () => Promise;\n webkitRequestFullscreen: () => Promise;\n msRequestFullscreen: () => Promise;\n };\n\n const documentFullscreenExtended = document as Document & {\n webkitExitFullscreen: () => Promise;\n mozCancelFullScreen: () => Promise;\n msExitFullscreen: () => Promise;\n\n webkitFullscreenElement: Element | null;\n mozFullScreenElement: Element | null;\n msFullscreenElement: Element | null;\n };\n\n const isFullscreenSupported = () => {\n if (!documentElementFullscreenExtended || !documentFullscreenExtended) {\n return false;\n }\n // Supported by most modern browsers\n return !!(\n documentElementFullscreenExtended.requestFullscreen ||\n documentElementFullscreenExtended.webkitRequestFullscreen ||\n documentElementFullscreenExtended.msRequestFullscreen\n );\n };\n\n const toggleFullscreen = () => {\n if (!isFullscreenSupported()) {\n return;\n }\n\n if (isFullscreen.value) {\n closeFullscreen();\n } else {\n openFullscreen();\n }\n };\n\n const openFullscreen = () => {\n try {\n if (documentElementFullscreenExtended.requestFullscreen) {\n documentElementFullscreenExtended.requestFullscreen();\n } else if (documentElementFullscreenExtended.webkitRequestFullscreen) {\n /* Safari */\n documentElementFullscreenExtended.webkitRequestFullscreen();\n } else if (documentElementFullscreenExtended.msRequestFullscreen) {\n /* IE11 */\n documentElementFullscreenExtended.msRequestFullscreen();\n }\n } catch (_) {\n // Ignore fullscreen errors\n }\n };\n\n const closeFullscreen = () => {\n try {\n if (documentFullscreenExtended.exitFullscreen) {\n documentFullscreenExtended.exitFullscreen();\n } else if (documentFullscreenExtended.webkitExitFullscreen) {\n /* Safari */\n documentFullscreenExtended.webkitExitFullscreen();\n } else if (documentFullscreenExtended.msExitFullscreen) {\n /* IE11 */\n documentFullscreenExtended.msExitFullscreen();\n }\n } catch (_) {\n // Ignore fullscreen errors\n }\n };\n\n const handleFullscreenChange = () => {\n isFullscreen.value = !!(\n documentFullscreenExtended.fullscreenElement ||\n documentFullscreenExtended.webkitFullscreenElement ||\n documentFullscreenExtended.mozFullScreenElement ||\n documentFullscreenExtended.msFullscreenElement\n );\n };\n\n onMounted(() => {\n handleFullscreenChange();\n for (const prefix of prefixes) {\n document.addEventListener(\n `${prefix}fullscreenchange`,\n handleFullscreenChange\n );\n }\n });\n\n onBeforeUnmount(() => {\n for (const prefix of prefixes) {\n document.removeEventListener(\n `${prefix}fullscreenchange`,\n handleFullscreenChange\n );\n }\n });\n\n return {\n isFullscreen,\n toggleFullscreen,\n isFullscreenSupported,\n closeFullscreen,\n openFullscreen,\n };\n};\n"],"names":["ref"],"mappings":"yNAMO,MAAM,cAAgB,WAAM,CACjC,MAAM,YAAcA,MAAI,SAAS,gBAAgB,WAAW,EACtD,aAAeA,MAAI,SAAS,gBAAgB,YAAY,EAOxD,2BAA6B,SALT,WAAM,CAClB,YAAA,MAAQ,SAAS,gBAAgB,YAChC,aAAA,MAAQ,SAAS,gBAAgB,YAAA,EAFtB,qBAKqC,GAAG,EAElE,iBAAU,IAAM,CACP,OAAA,iBAAiB,SAAU,0BAA0B,CAAA,CAC7D,EA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