@microblink/camera-manager 7.1.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +1,76 @@
1
- (function(){"use strict";(r=>{window.__mbCameraManagerCssCode=r})("._dialogPositioner_worsp_1{position:fixed;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);display:grid;height:100vh;width:100%;padding:calc(var(--mb-size)*2rem)}@supports (height:100dvh){._dialogPositioner_worsp_1{height:100dvh}}._dialogBackdrop_worsp_5{position:absolute;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);width:100%;height:100%;--un-bg-opacity:1;background-color:rgb(var(--color-black-rgb-value) / var(--un-bg-opacity));--un-bg-opacity:.5;--un-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}._dialogContent_worsp_9{position:relative;max-height:calc(100dvh - 4rem);max-width:28rem;display:flex;flex-direction:column;place-self:center;border-radius:.5rem;--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity));padding-left:min(8%,3rem);padding-right:min(8%,3rem);padding-top:min(8%,1.5rem);padding-bottom:min(8%,1.5rem);--un-text-opacity:1;color:rgb(15 15 15 / var(--un-text-opacity));--un-shadow:var(--un-shadow-inset) 0 10px 15px -3px var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 4px 6px -4px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._dialogContent_worsp_9._large_worsp_13{padding-left:min(8%,4rem);padding-right:min(8%,4rem);padding-top:min(8%,3rem);padding-bottom:min(8%,3rem)}._dialogContent_worsp_9._compact_worsp_16{padding:min(8%,1.5rem)}@media (min-width: 640px){._dialogContent_worsp_9{max-width:36rem}}@media (min-width: 1024px){._dialogContent_worsp_9{max-width:28rem}}._dialogTitle_worsp_30{text-align:center;font-size:calc(var(--mb-size)*1.5rem);line-height:calc(var(--mb-size)*2rem);font-weight:700}._contentOut_worsp_34{overflow-y:auto}._closeButton_worsp_38{position:absolute;top:.625rem;right:.625rem;width:calc(var(--mb-size)*2rem);height:calc(var(--mb-size)*2rem);display:flex;align-items:center;justify-content:center;border-radius:9999px;border-style:none;background-color:transparent;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._closeButton_worsp_38:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-100-rgb-value) / var(--un-bg-opacity))}._closeButton_worsp_38:active{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity))}._closeButtonInner_worsp_44{display:flex;--un-translate-y:-2px;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));align-items:center;justify-content:center;font-size:calc(var(--mb-size)*1.875rem);line-height:calc(var(--mb-size)*2.25rem);--un-text-opacity:1;color:rgb(var(--color-black-rgb-value) / var(--un-text-opacity));font-weight:200;line-height:1}._primaryActionButton_worsp_49{height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;--un-bg-opacity:1;background-color:rgb(var(--color-primary) / var(--un-bg-opacity));padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*.25rem);padding-bottom:calc(var(--mb-size)*.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._primaryActionButton_worsp_49[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._primaryActionButton_worsp_49[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity))}._primaryActionButton_worsp_49:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-700-rgb-value) / var(--un-bg-opacity))}._primaryActionButton_worsp_49:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-800-rgb-value) / var(--un-bg-opacity))}._primaryActionButton_worsp_49:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity));outline-offset:4px;outline-style:solid}._secondaryActionButton_worsp_53{height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;background-color:transparent;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*.25rem);padding-bottom:calc(var(--mb-size)*.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-primary) / var(--un-text-opacity));--un-ring-width:1px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);--un-ring-opacity:1;--un-ring-color:rgb(var(--color-primary) / var(--un-ring-opacity)) ;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._secondaryActionButton_worsp_53[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._secondaryActionButton_worsp_53[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity))}._secondaryActionButton_worsp_53:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-25-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-accent-700-rgb-value) / var(--un-text-opacity));--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-700-rgb-value) / var(--un-ring-opacity)) }._secondaryActionButton_worsp_53:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-50-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-accent-800-rgb-value) / var(--un-text-opacity));--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-800-rgb-value) / var(--un-ring-opacity)) }._secondaryActionButton_worsp_53:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity));outline-offset:4px;outline-style:solid}._actions_worsp_57{display:flex;gap:calc(var(--mb-size)*1rem)}._actions_worsp_57 ._primaryActionButton_worsp_49,._actions_worsp_57 ._secondaryActionButton_worsp_53{width:50%}._alertTitle_worsp_64{font-size:calc(var(--mb-size)*1.125rem);line-height:calc(var(--mb-size)*1.75rem);--un-text-opacity:1;color:rgb(var(--color-gray-700-rgb-value) / var(--un-text-opacity));font-weight:400}._alertText_worsp_68{margin-top:calc(var(--mb-size)*1rem);margin-bottom:calc(var(--mb-size)*2rem);padding-left:calc(var(--mb-size)*.5rem);padding-right:calc(var(--mb-size)*.5rem);text-align:center;text-wrap:pretty;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));font-weight:300;line-height:1.5}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.left-0{left:calc(var(--mb-size)*0rem)}.right-0{right:calc(var(--mb-size)*0rem)}.right-4{right:calc(var(--mb-size)*1rem)}.top-\\[-1px\\]{top:-1px}.top-0{top:calc(var(--mb-size)*0rem)}.has-\\[\\[data-scope\\]\\]\\:z-2:has([data-scope]),.z-2{z-index:2}.z-1{z-index:1}.grid{display:grid}.auto-cols-auto{grid-auto-columns:auto}.grid-cols-\\[1fr_auto_1fr\\]{grid-template-columns:1fr auto 1fr}.block{display:block}.size-12{width:calc(var(--mb-size)*3rem);height:calc(var(--mb-size)*3rem)}.size-6{width:calc(var(--mb-size)*1.5rem);height:calc(var(--mb-size)*1.5rem)}.size-full{width:100%;height:100%}.h-\\[1px\\]{height:1px}.h-full{height:100%}.h-vh{height:100vh}.max-w-\\[100\\%\\]{max-width:100%}.min-h-\\[300px\\]{min-height:300px}.min-w-0{min-width:calc(var(--mb-size)*0rem)}.w-full{width:100%}.flex{display:flex}.shrink-0{flex-shrink:0}.flex-nowrap{flex-wrap:nowrap}.data-\\[state\\=open\\]\\:scale-y-\\[-1\\][data-state=open]{--un-scale-y:-1;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.select-none{-webkit-user-select:none;user-select:none}.resize{resize:both}.appearance-none{-webkit-appearance:none;appearance:none}.place-items-center{place-items:center}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.justify-self-center{justify-self:center}.gap-\\[1px\\]{gap:1px}.gap-2{gap:calc(var(--mb-size)*.5rem)}.gap-4{gap:calc(var(--mb-size)*1rem)}.overflow-hidden{overflow:hidden}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.rounded-4{border-radius:calc(var(--mb-size)*1rem)}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border-none{border-style:none}.bg-dark-100\\/50{background-color:#3c3c3c80}.bg-dark-500{--un-bg-opacity:1;background-color:rgb(31 31 31 / var(--un-bg-opacity))}.bg-white{--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity))}.data-\\[highlighted\\]\\:bg-gray-500\\/50[data-highlighted]{background-color:rgb(var(--color-gray-500-rgb-value) / .5)}.bg-opacity-50{--un-bg-opacity:.5}.p-2{padding:calc(var(--mb-size)*.5rem)}.px-4{padding-left:calc(var(--mb-size)*1rem);padding-right:calc(var(--mb-size)*1rem)}.py-2{padding-top:calc(var(--mb-size)*.5rem);padding-bottom:calc(var(--mb-size)*.5rem)}.py-3{padding-top:calc(var(--mb-size)*.75rem);padding-bottom:calc(var(--mb-size)*.75rem)}.py-4{padding-top:calc(var(--mb-size)*1rem);padding-bottom:calc(var(--mb-size)*1rem)}.pl-4{padding-left:calc(var(--mb-size)*1rem)}.pr-12{padding-right:calc(var(--mb-size)*3rem)}.text-align-center{text-align:center}.text-base{font-size:calc(var(--mb-size)*1rem);line-height:calc(var(--mb-size)*1.5rem)}.text-sm{font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem)}.color-white{--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity))}.font-500{font-weight:500}.disabled\\:opacity-50:disabled{opacity:.5}.shadow{--un-shadow:var(--un-shadow-inset) 0 1px 3px 0 var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 1px 2px -1px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.backdrop-blur{--un-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}.backdrop-blur-xl{--un-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}.drop-shadow-md{--un-drop-shadow:drop-shadow(0 4px 3px var(--un-drop-shadow-color, rgb(0 0 0 / .07))) drop-shadow(0 2px 2px var(--un-drop-shadow-color, rgb(0 0 0 / .06)));filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia)}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.lerp\\:px-3\\@xs\\,8\\@lg{padding-inline:clamp(calc(var(--mb-size)*.75rem),calc(var(--mb-size)*.75rem) + (100vw - 380px) * .031055900621118012,calc(var(--mb-size)*2rem))}@supports (height:100dvh){.supports-\\[\\(height\\:100dvh\\)\\]\\:h-dvh{height:100dvh}}")})();
2
- import { subscribeWithSelector as he } from "zustand/middleware";
3
- import { createStore as me } from "zustand/vanilla";
4
- import { createComponent as s, use as O, template as S, spread as D, mergeProps as K, insert as w, memo as ge, isServer as Be, delegateEvents as Ve, effect as H, className as V, Portal as fe, Dynamic as Ue, render as je } from "solid-js/web";
5
- import { createContext as be, onCleanup as ie, useContext as pe, onMount as Q, createSignal as z, Show as E, Index as qe, createRoot as He, getOwner as ve, splitProps as We, createEffect as Ge } from "solid-js";
6
- import { createWithSignal as we } from "solid-zustand";
7
- import { createStore as Xe } from "solid-js/store";
8
- import { EnvironmentProvider as Ke } from "@ark-ui/solid/environment";
9
- import { Dialog as $ } from "@ark-ui/solid/dialog";
10
- import { Select as A, createListCollection as Qe } from "@ark-ui/solid/select";
11
- import { Tooltip as G } from "@ark-ui/solid/tooltip";
12
- typeof HTMLVideoElement < "u" && !("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPlaybackQuality" in HTMLVideoElement.prototype && (HTMLVideoElement.prototype._rvfcpolyfillmap = {}, HTMLVideoElement.prototype.requestVideoFrameCallback = function(r) {
13
- const e = performance.now(), t = this.getVideoPlaybackQuality(), a = this.mozPresentedFrames || this.mozPaintedFrames || t.totalVideoFrames - t.droppedVideoFrames, n = (o, i) => {
14
- const l = this.getVideoPlaybackQuality(), c = this.mozPresentedFrames || this.mozPaintedFrames || l.totalVideoFrames - l.droppedVideoFrames;
15
- if (c > a) {
16
- const f = this.mozFrameDelay || l.totalFrameDelay - t.totalFrameDelay || 0, g = i - o;
17
- r(i, {
18
- presentationTime: i + f * 1e3,
19
- expectedDisplayTime: i + g,
20
- width: this.videoWidth,
21
- height: this.videoHeight,
22
- mediaTime: Math.max(0, this.currentTime || 0) + g / 1e3,
23
- presentedFrames: c,
24
- processingDuration: f
25
- }), delete this._rvfcpolyfillmap[e];
26
- } else
27
- this._rvfcpolyfillmap[e] = requestAnimationFrame((f) => n(i, f));
1
+ (function() {
2
+ "use strict";
3
+ ((cssCode) => {
4
+ window.__mbCameraManagerCssCode = cssCode;
5
+ })("._dialogPositioner_worsp_1 {\n position:fixed;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);display:grid;height:100vh;width:100%;padding:calc(var(--mb-size)*2rem);\n}@supports (height:100dvh){._dialogPositioner_worsp_1{height:100dvh;}}\n\n._dialogBackdrop_worsp_5 {\n position:absolute;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);width:100%;height:100%;--un-bg-opacity:1;background-color:rgb(var(--color-black-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-black-rgb-value) / <alpha-value>) */;--un-bg-opacity:0.5;--un-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);\n}\n\n._dialogContent_worsp_9 {\n position:relative;max-height:calc(100dvh - 4rem);max-width:28rem;display:flex;flex-direction:column;place-self:center;border-radius:0.5rem;--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;padding-left:min(8%,3rem);padding-right:min(8%,3rem);padding-top:min(8%,1.5rem);padding-bottom:min(8%,1.5rem);--un-text-opacity:1;color:rgb(15 15 15 / var(--un-text-opacity)) /* #0f0f0f */;--un-shadow:var(--un-shadow-inset) 0 10px 15px -3px var(--un-shadow-color, rgb(0 0 0 / 0.1)),var(--un-shadow-inset) 0 4px 6px -4px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);\n}\n._dialogContent_worsp_9._large_worsp_13 {\n padding-left:min(8%,4rem);padding-right:min(8%,4rem);padding-top:min(8%,3rem);padding-bottom:min(8%,3rem);\n}\n._dialogContent_worsp_9._compact_worsp_16 {\n padding:min(8%,1.5rem);\n}\n@media (min-width: 640px){\n ._dialogContent_worsp_9 {\n max-width:36rem;\n }\n}\n@media (min-width: 1024px){\n ._dialogContent_worsp_9 {\n max-width:28rem;\n }\n}\n\n._dialogTitle_worsp_30 {\n text-align:center;font-size:calc(var(--mb-size)*1.5rem);line-height:calc(var(--mb-size)*2rem);font-weight:700;\n}\n\n._contentOut_worsp_34 {\n overflow-y:auto;\n}\n\n._closeButton_worsp_38 {\n position:absolute;top:0.625rem;right:0.625rem;width:calc(var(--mb-size)*2rem);height:calc(var(--mb-size)*2rem);display:flex;align-items:center;justify-content:center;border-radius:9999px;border-style:none;background-color:transparent /* transparent */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._closeButton_worsp_38:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-100-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-100-rgb-value) / <alpha-value>) */;}._closeButton_worsp_38:active{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;}\n\n._closeButtonInner_worsp_44 {\n display:flex;--un-translate-y:-2px;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));align-items:center;justify-content:center;font-size:calc(var(--mb-size)*1.875rem);line-height:calc(var(--mb-size)*2.25rem);--un-text-opacity:1;color:rgb(var(--color-black-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-black-rgb-value) / <alpha-value>) */;font-weight:200;line-height:1;\n}\n\n._primaryActionButton_worsp_49 {\n height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;--un-bg-opacity:1;background-color:rgb(var(--color-primary) / var(--un-bg-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*0.25rem);padding-bottom:calc(var(--mb-size)*0.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._primaryActionButton_worsp_49[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}._primaryActionButton_worsp_49[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-700-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-800-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity)) /* rgb(var(--color-accent-400-rgb-value) / <alpha-value>) */;outline-offset:4px;outline-style:solid;}\n\n._secondaryActionButton_worsp_53 {\n height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;background-color:transparent /* transparent */;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*0.25rem);padding-bottom:calc(var(--mb-size)*0.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-primary) / var(--un-text-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;--un-ring-width:1px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);--un-ring-opacity:1;--un-ring-color:rgb(var(--color-primary) / var(--un-ring-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._secondaryActionButton_worsp_53[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}._secondaryActionButton_worsp_53[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-25-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-25-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-accent-700-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-700-rgb-value) / var(--un-ring-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-50-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-50-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-accent-800-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-800-rgb-value) / var(--un-ring-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity)) /* rgb(var(--color-accent-400-rgb-value) / <alpha-value>) */;outline-offset:4px;outline-style:solid;}\n\n._actions_worsp_57 {\n display:flex;gap:calc(var(--mb-size)*1rem);\n}\n._actions_worsp_57 ._primaryActionButton_worsp_49, ._actions_worsp_57 ._secondaryActionButton_worsp_53 {\n width:50%;\n}\n\n._alertTitle_worsp_64 {\n font-size:calc(var(--mb-size)*1.125rem);line-height:calc(var(--mb-size)*1.75rem);--un-text-opacity:1;color:rgb(var(--color-gray-700-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-700-rgb-value) / <alpha-value>) */;font-weight:400;\n}\n\n._alertText_worsp_68 {\n margin-top:calc(var(--mb-size)*1rem);margin-bottom:calc(var(--mb-size)*2rem);padding-left:calc(var(--mb-size)*0.5rem);padding-right:calc(var(--mb-size)*0.5rem);text-align:center;text-wrap:pretty;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;font-weight:300;line-height:1.5;\n} *,::before,::after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;}.pointer-events-none{pointer-events:none;}.absolute{position:absolute;}.fixed{position:fixed;}.relative{position:relative;}.left-0{left:calc(var(--mb-size)*0rem);}.right-0{right:calc(var(--mb-size)*0rem);}.right-4{right:calc(var(--mb-size)*1rem);}.top-\\[-1px\\]{top:-1px;}.top-0{top:calc(var(--mb-size)*0rem);}.z-1{z-index:1;}.has-\\[\\[data-scope\\]\\]\\:z-2:has([data-scope]),.z-2{z-index:2;}.grid{display:grid;}.auto-cols-auto{grid-auto-columns:auto;}.grid-cols-\\[1fr_auto_1fr\\]{grid-template-columns:1fr auto 1fr;}.block{display:block;}.size-12{width:calc(var(--mb-size)*3rem);height:calc(var(--mb-size)*3rem);}.size-6{width:calc(var(--mb-size)*1.5rem);height:calc(var(--mb-size)*1.5rem);}.size-full{width:100%;height:100%;}.h-\\[1px\\]{height:1px;}.h-full{height:100%;}.h-vh{height:100vh;}.max-w-\\[100\\%\\]{max-width:100%;}.min-h-\\[300px\\]{min-height:300px;}.min-w-0{min-width:calc(var(--mb-size)*0rem);}.w-full{width:100%;}.flex{display:flex;}.shrink-0{flex-shrink:0;}.flex-nowrap{flex-wrap:nowrap;}.data-\\[state\\=open\\]\\:scale-y-\\[-1\\][data-state=open]{--un-scale-y:-1;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}.transform{transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}.cursor-pointer{cursor:pointer;}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed;}.select-none{-webkit-user-select:none;user-select:none;}.resize{resize:both;}.appearance-none{-webkit-appearance:none;appearance:none;}.place-items-center{place-items:center;}.items-center{align-items:center;}.justify-between{justify-content:space-between;}.justify-self-start{justify-self:start;}.justify-self-end{justify-self:end;}.justify-self-center{justify-self:center;}.gap-\\[1px\\]{gap:1px;}.gap-2{gap:calc(var(--mb-size)*0.5rem);}.gap-4{gap:calc(var(--mb-size)*1rem);}.overflow-hidden{overflow:hidden;}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.whitespace-nowrap{white-space:nowrap;}.rounded-4{border-radius:calc(var(--mb-size)*1rem);}.rounded-full{border-radius:9999px;}.rounded-md{border-radius:0.375rem;}.border-none{border-style:none;}.bg-dark-100\\/50{background-color:rgb(60 60 60 / 0.5) /* #3c3c3c */;}.bg-dark-500{--un-bg-opacity:1;background-color:rgb(31 31 31 / var(--un-bg-opacity)) /* #1f1f1f */;}.data-\\[highlighted\\]\\:bg-gray-500\\/50[data-highlighted]{background-color:rgb(var(--color-gray-500-rgb-value) / 0.5) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}.bg-white{--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;}.bg-opacity-50{--un-bg-opacity:0.5;}.p-2{padding:calc(var(--mb-size)*0.5rem);}.px-4{padding-left:calc(var(--mb-size)*1rem);padding-right:calc(var(--mb-size)*1rem);}.py-2{padding-top:calc(var(--mb-size)*0.5rem);padding-bottom:calc(var(--mb-size)*0.5rem);}.py-3{padding-top:calc(var(--mb-size)*0.75rem);padding-bottom:calc(var(--mb-size)*0.75rem);}.py-4{padding-top:calc(var(--mb-size)*1rem);padding-bottom:calc(var(--mb-size)*1rem);}.pl-4{padding-left:calc(var(--mb-size)*1rem);}.pr-12{padding-right:calc(var(--mb-size)*3rem);}.text-align-center{text-align:center;}.text-base{font-size:calc(var(--mb-size)*1rem);line-height:calc(var(--mb-size)*1.5rem);}.text-sm{font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);}.color-white{--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;}.font-500{font-weight:500;}.disabled\\:opacity-50:disabled{opacity:0.5;}.shadow{--un-shadow:var(--un-shadow-inset) 0 1px 3px 0 var(--un-shadow-color, rgb(0 0 0 / 0.1)),var(--un-shadow-inset) 0 1px 2px -1px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}.backdrop-blur{--un-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);}.backdrop-blur-xl{--un-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);}.drop-shadow-md{--un-drop-shadow:drop-shadow(0 4px 3px var(--un-drop-shadow-color, rgb(0 0 0 / 0.07))) drop-shadow(0 2px 2px var(--un-drop-shadow-color, rgb(0 0 0 / 0.06)));filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}.duration-300{transition-duration:300ms;}.ease-in-out{transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);}@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} .\\?{animation:__un_qm 0.5s ease-in-out alternate infinite;}.lerp\\:px-3\\@xs\\,8\\@lg{padding-inline:clamp(calc(var(--mb-size)*0.75rem), calc(var(--mb-size)*0.75rem) + (100vw - 380px) * 0.031055900621118012, calc(var(--mb-size)*2rem));}@supports (height:100dvh){.supports-\\[\\(height\\:100dvh\\)\\]\\:h-dvh{height:100dvh;}}");
6
+ })();
7
+ import { subscribeWithSelector } from "zustand/middleware";
8
+ import { createStore } from "zustand/vanilla";
9
+ import { createComponent, use, template, spread, mergeProps, insert, memo, isServer, delegateEvents, effect, className, Portal, Dynamic, render } from "solid-js/web";
10
+ import { createContext, onCleanup, useContext, onMount, createSignal, Show, Index, createRoot, getOwner, splitProps, createEffect } from "solid-js";
11
+ import { createWithSignal } from "solid-zustand";
12
+ import { createStore as createStore$1 } from "solid-js/store";
13
+ import { EnvironmentProvider } from "@ark-ui/solid/environment";
14
+ import { Dialog } from "@ark-ui/solid/dialog";
15
+ import { Select, createListCollection } from "@ark-ui/solid/select";
16
+ import { Tooltip } from "@ark-ui/solid/tooltip";
17
+ if (typeof HTMLVideoElement !== "undefined" && !("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPlaybackQuality" in HTMLVideoElement.prototype) {
18
+ HTMLVideoElement.prototype._rvfcpolyfillmap = {};
19
+ HTMLVideoElement.prototype.requestVideoFrameCallback = function(callback) {
20
+ const handle = performance.now();
21
+ const quality = this.getVideoPlaybackQuality();
22
+ const baseline = this.mozPresentedFrames || this.mozPaintedFrames || quality.totalVideoFrames - quality.droppedVideoFrames;
23
+ const check = (old, now) => {
24
+ const newquality = this.getVideoPlaybackQuality();
25
+ const presentedFrames = this.mozPresentedFrames || this.mozPaintedFrames || newquality.totalVideoFrames - newquality.droppedVideoFrames;
26
+ if (presentedFrames > baseline) {
27
+ const processingDuration = this.mozFrameDelay || newquality.totalFrameDelay - quality.totalFrameDelay || 0;
28
+ const timediff = now - old;
29
+ callback(now, {
30
+ presentationTime: now + processingDuration * 1e3,
31
+ expectedDisplayTime: now + timediff,
32
+ width: this.videoWidth,
33
+ height: this.videoHeight,
34
+ mediaTime: Math.max(0, this.currentTime || 0) + timediff / 1e3,
35
+ presentedFrames,
36
+ processingDuration
37
+ });
38
+ delete this._rvfcpolyfillmap[handle];
39
+ } else {
40
+ this._rvfcpolyfillmap[handle] = requestAnimationFrame((newer) => check(now, newer));
41
+ }
42
+ };
43
+ this._rvfcpolyfillmap[handle] = requestAnimationFrame((newer) => check(handle, newer));
44
+ return handle;
28
45
  };
29
- return this._rvfcpolyfillmap[e] = requestAnimationFrame((o) => n(e, o)), e;
30
- }, HTMLVideoElement.prototype.cancelVideoFrameCallback = function(r) {
31
- cancelAnimationFrame(this._rvfcpolyfillmap[r]), delete this._rvfcpolyfillmap[r];
32
- });
33
- const ye = {
46
+ HTMLVideoElement.prototype.cancelVideoFrameCallback = function(handle) {
47
+ cancelAnimationFrame(this._rvfcpolyfillmap[handle]);
48
+ delete this._rvfcpolyfillmap[handle];
49
+ };
50
+ }
51
+ const initialState$1 = {
34
52
  cameras: [],
35
53
  facingFilter: void 0,
36
54
  videoElement: void 0,
37
55
  playbackState: "idle",
38
56
  selectedCamera: void 0,
39
- isSwappingCamera: !1,
40
- isQueryingCameras: !1,
41
- mirrorX: !1,
57
+ isSwappingCamera: false,
58
+ isQueryingCameras: false,
59
+ mirrorX: false,
42
60
  errorState: void 0
43
- }, d = me()(
61
+ };
62
+ const cameraManagerStore = createStore()(
44
63
  // this is important! Otherwise solid-zustand will start mutating the initial state
45
- he(() => structuredClone(ye))
46
- ), Ye = () => {
47
- console.debug("Stopping all cameras and resetting the `cameraManagerStore`."), d.getState().cameras.forEach((r) => {
48
- r.stopStream();
49
- }), d.setState(structuredClone(ye));
50
- }, Je = [
64
+ subscribeWithSelector(() => structuredClone(initialState$1))
65
+ );
66
+ const resetCameraManagerStore = () => {
67
+ console.debug("Stopping all cameras and resetting the `cameraManagerStore`.");
68
+ cameraManagerStore.getState().cameras.forEach((camera) => {
69
+ camera.stopStream();
70
+ });
71
+ cameraManagerStore.setState(structuredClone(initialState$1));
72
+ };
73
+ const backCameraKeywords = [
51
74
  // English
52
75
  "back",
53
76
  "rear",
@@ -118,7 +141,8 @@ const ye = {
118
141
  "बैक",
119
142
  // Latin American Spanish
120
143
  "posterior"
121
- ], Ze = [
144
+ ];
145
+ const frontCameraKeywords = [
122
146
  // English
123
147
  "front",
124
148
  // German
@@ -185,38 +209,66 @@ const ye = {
185
209
  "फ्रंट",
186
210
  // Latin American Spanish
187
211
  "frontal"
188
- ], Se = (r, e) => e.some((t) => r.toLowerCase().includes(t)), Ce = (r) => Se(r, Je), ke = (r) => Se(r, Ze);
189
- var et = /* @__PURE__ */ function() {
190
- function r(e, t) {
191
- for (var a = 0; a < t.length; a++) {
192
- var n = t[a];
193
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
212
+ ];
213
+ const containsKeyword = (string, keywords) => {
214
+ return keywords.some((keyword) => string.toLowerCase().includes(keyword));
215
+ };
216
+ const isBackCameraName = (string) => containsKeyword(string, backCameraKeywords);
217
+ const isFrontCameraName = (string) => containsKeyword(string, frontCameraKeywords);
218
+ var _createClass = /* @__PURE__ */ function() {
219
+ function defineProperties(target, props) {
220
+ for (var i = 0; i < props.length; i++) {
221
+ var descriptor = props[i];
222
+ descriptor.enumerable = descriptor.enumerable || false;
223
+ descriptor.configurable = true;
224
+ if ("value" in descriptor) descriptor.writable = true;
225
+ Object.defineProperty(target, descriptor.key, descriptor);
194
226
  }
195
227
  }
196
- return function(e, t, a) {
197
- return t && r(e.prototype, t), a && r(e, a), e;
228
+ return function(Constructor, protoProps, staticProps) {
229
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
230
+ if (staticProps) defineProperties(Constructor, staticProps);
231
+ return Constructor;
198
232
  };
199
- }(), tt = rt(["", ""], ["", ""]);
200
- function rt(r, e) {
201
- return Object.freeze(Object.defineProperties(r, { raw: { value: Object.freeze(e) } }));
233
+ }();
234
+ var _templateObject = _taggedTemplateLiteral(["", ""], ["", ""]);
235
+ function _taggedTemplateLiteral(strings, raw) {
236
+ return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } }));
202
237
  }
203
- function at(r, e) {
204
- if (!(r instanceof e))
238
+ function _classCallCheck(instance, Constructor) {
239
+ if (!(instance instanceof Constructor)) {
205
240
  throw new TypeError("Cannot call a class as a function");
241
+ }
206
242
  }
207
- var _ = function() {
208
- function r() {
209
- for (var e = this, t = arguments.length, a = Array(t), n = 0; n < t; n++)
210
- a[n] = arguments[n];
211
- return at(this, r), this.tag = function(o) {
212
- for (var i = arguments.length, l = Array(i > 1 ? i - 1 : 0), c = 1; c < i; c++)
213
- l[c - 1] = arguments[c];
214
- return typeof o == "function" ? e.interimTag.bind(e, o) : typeof o == "string" ? e.transformEndResult(o) : (o = o.map(e.transformString.bind(e)), e.transformEndResult(o.reduce(e.processSubstitutions.bind(e, l))));
215
- }, a.length > 0 && Array.isArray(a[0]) && (a = a[0]), this.transformers = a.map(function(o) {
216
- return typeof o == "function" ? o() : o;
217
- }), this.tag;
218
- }
219
- return et(r, [{
243
+ var TemplateTag = function() {
244
+ function TemplateTag2() {
245
+ var _this = this;
246
+ for (var _len = arguments.length, transformers = Array(_len), _key = 0; _key < _len; _key++) {
247
+ transformers[_key] = arguments[_key];
248
+ }
249
+ _classCallCheck(this, TemplateTag2);
250
+ this.tag = function(strings) {
251
+ for (var _len2 = arguments.length, expressions = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
252
+ expressions[_key2 - 1] = arguments[_key2];
253
+ }
254
+ if (typeof strings === "function") {
255
+ return _this.interimTag.bind(_this, strings);
256
+ }
257
+ if (typeof strings === "string") {
258
+ return _this.transformEndResult(strings);
259
+ }
260
+ strings = strings.map(_this.transformString.bind(_this));
261
+ return _this.transformEndResult(strings.reduce(_this.processSubstitutions.bind(_this, expressions)));
262
+ };
263
+ if (transformers.length > 0 && Array.isArray(transformers[0])) {
264
+ transformers = transformers[0];
265
+ }
266
+ this.transformers = transformers.map(function(transformer) {
267
+ return typeof transformer === "function" ? transformer() : transformer;
268
+ });
269
+ return this.tag;
270
+ }
271
+ _createClass(TemplateTag2, [{
220
272
  key: "interimTag",
221
273
  /**
222
274
  * An intermediary template tag that receives a template tag and passes the result of calling the template with the received
@@ -226,10 +278,11 @@ var _ = function() {
226
278
  * @param {...*} ...substitutions - `substitutions` is an array of all substitutions in the template
227
279
  * @return {*} - the final processed value
228
280
  */
229
- value: function(t, a) {
230
- for (var n = arguments.length, o = Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++)
231
- o[i - 2] = arguments[i];
232
- return this.tag(tt, t.apply(void 0, [a].concat(o)));
281
+ value: function interimTag(previousTag, template2) {
282
+ for (var _len3 = arguments.length, substitutions = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
283
+ substitutions[_key3 - 2] = arguments[_key3];
284
+ }
285
+ return this.tag(_templateObject, previousTag.apply(void 0, [template2].concat(substitutions)));
233
286
  }
234
287
  /**
235
288
  * Performs bulk processing on the tagged template, transforming each substitution and then
@@ -241,9 +294,9 @@ var _ = function() {
241
294
  */
242
295
  }, {
243
296
  key: "processSubstitutions",
244
- value: function(t, a, n) {
245
- var o = this.transformSubstitution(t.shift(), a);
246
- return "".concat(a, o, n);
297
+ value: function processSubstitutions(substitutions, resultSoFar, remainingPart) {
298
+ var substitution = this.transformSubstitution(substitutions.shift(), resultSoFar);
299
+ return "".concat(resultSoFar, substitution, remainingPart);
247
300
  }
248
301
  /**
249
302
  * Iterate through each transformer, applying the transformer's `onString` method to the template
@@ -253,11 +306,11 @@ var _ = function() {
253
306
  */
254
307
  }, {
255
308
  key: "transformString",
256
- value: function(t) {
257
- var a = function(o, i) {
258
- return i.onString ? i.onString(o) : o;
309
+ value: function transformString(str) {
310
+ var cb = function cb2(res, transform) {
311
+ return transform.onString ? transform.onString(res) : res;
259
312
  };
260
- return this.transformers.reduce(a, t);
313
+ return this.transformers.reduce(cb, str);
261
314
  }
262
315
  /**
263
316
  * When a substitution is encountered, iterates through each transformer and applies the transformer's
@@ -268,11 +321,11 @@ var _ = function() {
268
321
  */
269
322
  }, {
270
323
  key: "transformSubstitution",
271
- value: function(t, a) {
272
- var n = function(i, l) {
273
- return l.onSubstitution ? l.onSubstitution(i, a) : i;
324
+ value: function transformSubstitution(substitution, resultSoFar) {
325
+ var cb = function cb2(res, transform) {
326
+ return transform.onSubstitution ? transform.onSubstitution(res, resultSoFar) : res;
274
327
  };
275
- return this.transformers.reduce(n, t);
328
+ return this.transformers.reduce(cb, substitution);
276
329
  }
277
330
  /**
278
331
  * Iterates through each transformer, applying the transformer's `onEndResult` method to the
@@ -282,120 +335,161 @@ var _ = function() {
282
335
  */
283
336
  }, {
284
337
  key: "transformEndResult",
285
- value: function(t) {
286
- var a = function(o, i) {
287
- return i.onEndResult ? i.onEndResult(o) : o;
338
+ value: function transformEndResult(endResult) {
339
+ var cb = function cb2(res, transform) {
340
+ return transform.onEndResult ? transform.onEndResult(res) : res;
288
341
  };
289
- return this.transformers.reduce(a, t);
342
+ return this.transformers.reduce(cb, endResult);
290
343
  }
291
- }]), r;
292
- }(), T = function() {
293
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
344
+ }]);
345
+ return TemplateTag2;
346
+ }();
347
+ var trimResultTransformer = function trimResultTransformer2() {
348
+ var side = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
294
349
  return {
295
- onEndResult: function(a) {
296
- if (e === "")
297
- return a.trim();
298
- if (e = e.toLowerCase(), e === "start" || e === "left")
299
- return a.replace(/^\s*/, "");
300
- if (e === "end" || e === "right")
301
- return a.replace(/\s*$/, "");
302
- throw new Error("Side not supported: " + e);
350
+ onEndResult: function onEndResult(endResult) {
351
+ if (side === "") {
352
+ return endResult.trim();
353
+ }
354
+ side = side.toLowerCase();
355
+ if (side === "start" || side === "left") {
356
+ return endResult.replace(/^\s*/, "");
357
+ }
358
+ if (side === "end" || side === "right") {
359
+ return endResult.replace(/\s*$/, "");
360
+ }
361
+ throw new Error("Side not supported: " + side);
303
362
  }
304
363
  };
305
364
  };
306
- function nt(r) {
307
- if (Array.isArray(r)) {
308
- for (var e = 0, t = Array(r.length); e < r.length; e++)
309
- t[e] = r[e];
310
- return t;
311
- } else
312
- return Array.from(r);
365
+ function _toConsumableArray(arr) {
366
+ if (Array.isArray(arr)) {
367
+ for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
368
+ arr2[i] = arr[i];
369
+ }
370
+ return arr2;
371
+ } else {
372
+ return Array.from(arr);
373
+ }
313
374
  }
314
- var L = function() {
315
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "initial";
375
+ var stripIndentTransformer = function stripIndentTransformer2() {
376
+ var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "initial";
316
377
  return {
317
- onEndResult: function(a) {
318
- if (e === "initial") {
319
- var n = a.match(/^[^\S\n]*(?=\S)/gm), o = n && Math.min.apply(Math, nt(n.map(function(l) {
320
- return l.length;
378
+ onEndResult: function onEndResult(endResult) {
379
+ if (type === "initial") {
380
+ var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
381
+ var indent = match && Math.min.apply(Math, _toConsumableArray(match.map(function(el) {
382
+ return el.length;
321
383
  })));
322
- if (o) {
323
- var i = new RegExp("^.{" + o + "}", "gm");
324
- return a.replace(i, "");
384
+ if (indent) {
385
+ var regexp = new RegExp("^.{" + indent + "}", "gm");
386
+ return endResult.replace(regexp, "");
325
387
  }
326
- return a;
388
+ return endResult;
389
+ }
390
+ if (type === "all") {
391
+ return endResult.replace(/^[^\S\n]+/gm, "");
327
392
  }
328
- if (e === "all")
329
- return a.replace(/^[^\S\n]+/gm, "");
330
- throw new Error("Unknown type: " + e);
393
+ throw new Error("Unknown type: " + type);
331
394
  }
332
395
  };
333
- }, j = function(e, t) {
396
+ };
397
+ var replaceResultTransformer = function replaceResultTransformer2(replaceWhat, replaceWith) {
334
398
  return {
335
- onEndResult: function(n) {
336
- if (e == null || t == null)
399
+ onEndResult: function onEndResult(endResult) {
400
+ if (replaceWhat == null || replaceWith == null) {
337
401
  throw new Error("replaceResultTransformer requires at least 2 arguments.");
338
- return n.replace(e, t);
402
+ }
403
+ return endResult.replace(replaceWhat, replaceWith);
339
404
  }
340
405
  };
341
- }, B = function(e, t) {
406
+ };
407
+ var replaceSubstitutionTransformer = function replaceSubstitutionTransformer2(replaceWhat, replaceWith) {
342
408
  return {
343
- onSubstitution: function(n, o) {
344
- if (e == null || t == null)
409
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
410
+ if (replaceWhat == null || replaceWith == null) {
345
411
  throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");
346
- return n == null ? n : n.toString().replace(e, t);
412
+ }
413
+ if (substitution == null) {
414
+ return substitution;
415
+ } else {
416
+ return substitution.toString().replace(replaceWhat, replaceWith);
417
+ }
347
418
  }
348
419
  };
349
- }, ot = {
420
+ };
421
+ var defaults = {
350
422
  separator: "",
351
423
  conjunction: "",
352
- serial: !1
353
- }, I = function() {
354
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ot;
424
+ serial: false
425
+ };
426
+ var inlineArrayTransformer = function inlineArrayTransformer2() {
427
+ var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults;
355
428
  return {
356
- onSubstitution: function(a, n) {
357
- if (Array.isArray(a)) {
358
- var o = a.length, i = e.separator, l = e.conjunction, c = e.serial, f = n.match(/(\n?[^\S\n]+)$/);
359
- if (f ? a = a.join(i + f[1]) : a = a.join(i + " "), l && o > 1) {
360
- var g = a.lastIndexOf(i);
361
- a = a.slice(0, g) + (c ? i : "") + " " + l + a.slice(g + 1);
429
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
430
+ if (Array.isArray(substitution)) {
431
+ var arrayLength = substitution.length;
432
+ var separator = opts.separator;
433
+ var conjunction = opts.conjunction;
434
+ var serial = opts.serial;
435
+ var indent = resultSoFar.match(/(\n?[^\S\n]+)$/);
436
+ if (indent) {
437
+ substitution = substitution.join(separator + indent[1]);
438
+ } else {
439
+ substitution = substitution.join(separator + " ");
440
+ }
441
+ if (conjunction && arrayLength > 1) {
442
+ var separatorIndex = substitution.lastIndexOf(separator);
443
+ substitution = substitution.slice(0, separatorIndex) + (serial ? separator : "") + " " + conjunction + substitution.slice(separatorIndex + 1);
362
444
  }
363
445
  }
364
- return a;
446
+ return substitution;
365
447
  }
366
448
  };
367
- }, Ee = function(e) {
449
+ };
450
+ var splitStringTransformer = function splitStringTransformer2(splitBy) {
368
451
  return {
369
- onSubstitution: function(a, n) {
370
- return typeof a == "string" && a.includes(e) && (a = a.split(e)), a;
452
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
453
+ {
454
+ if (typeof substitution === "string" && substitution.includes(splitBy)) {
455
+ substitution = substitution.split(splitBy);
456
+ }
457
+ }
458
+ return substitution;
371
459
  }
372
460
  };
373
- }, le = function(e) {
374
- return e != null && !Number.isNaN(e) && typeof e != "boolean";
375
- }, it = function() {
461
+ };
462
+ var isValidValue = function isValidValue2(x) {
463
+ return x != null && !Number.isNaN(x) && typeof x !== "boolean";
464
+ };
465
+ var removeNonPrintingValuesTransformer = function removeNonPrintingValuesTransformer2() {
376
466
  return {
377
- onSubstitution: function(t) {
378
- return Array.isArray(t) ? t.filter(le) : le(t) ? t : "";
467
+ onSubstitution: function onSubstitution(substitution) {
468
+ if (Array.isArray(substitution)) {
469
+ return substitution.filter(isValidValue);
470
+ }
471
+ if (isValidValue(substitution)) {
472
+ return substitution;
473
+ }
474
+ return "";
379
475
  }
380
476
  };
381
477
  };
382
- new _(I({ separator: "," }), L, T);
383
- new _(I({ separator: ",", conjunction: "and" }), L, T);
384
- new _(I({ separator: ",", conjunction: "or" }), L, T);
385
- new _(Ee(`
386
- `), it, I, L, T);
387
- new _(Ee(`
388
- `), I, L, T, B(/&/g, "&amp;"), B(/</g, "&lt;"), B(/>/g, "&gt;"), B(/"/g, "&quot;"), B(/'/g, "&#x27;"), B(/`/g, "&#x60;"));
389
- new _(j(/(?:\n(?:\s*))+/g, " "), T);
390
- new _(j(/(?:\n\s*)/g, ""), T);
391
- new _(I({ separator: "," }), j(/(?:\s+)/g, " "), T);
392
- new _(I({ separator: ",", conjunction: "or" }), j(/(?:\s+)/g, " "), T);
393
- new _(I({ separator: ",", conjunction: "and" }), j(/(?:\s+)/g, " "), T);
394
- new _(I, L, T);
395
- new _(I, j(/(?:\s+)/g, " "), T);
396
- new _(L, T);
397
- var _e = new _(L("all"), T);
398
- const st = [
478
+ new TemplateTag(inlineArrayTransformer({ separator: "," }), stripIndentTransformer, trimResultTransformer);
479
+ new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "and" }), stripIndentTransformer, trimResultTransformer);
480
+ new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "or" }), stripIndentTransformer, trimResultTransformer);
481
+ new TemplateTag(splitStringTransformer("\n"), removeNonPrintingValuesTransformer, inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
482
+ new TemplateTag(splitStringTransformer("\n"), inlineArrayTransformer, stripIndentTransformer, trimResultTransformer, replaceSubstitutionTransformer(/&/g, "&amp;"), replaceSubstitutionTransformer(/</g, "&lt;"), replaceSubstitutionTransformer(/>/g, "&gt;"), replaceSubstitutionTransformer(/"/g, "&quot;"), replaceSubstitutionTransformer(/'/g, "&#x27;"), replaceSubstitutionTransformer(/`/g, "&#x60;"));
483
+ new TemplateTag(replaceResultTransformer(/(?:\n(?:\s*))+/g, " "), trimResultTransformer);
484
+ new TemplateTag(replaceResultTransformer(/(?:\n\s*)/g, ""), trimResultTransformer);
485
+ new TemplateTag(inlineArrayTransformer({ separator: "," }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
486
+ new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "or" }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
487
+ new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "and" }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
488
+ new TemplateTag(inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
489
+ new TemplateTag(inlineArrayTransformer, replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
490
+ new TemplateTag(stripIndentTransformer, trimResultTransformer);
491
+ var stripIndents = new TemplateTag(stripIndentTransformer("all"), trimResultTransformer);
492
+ const backDualWideCameraLocalizations = [
399
493
  "Cameră dublă cu obiectiv superangular spate",
400
494
  "מצלמה כפולה רחבה אחורית",
401
495
  "Артқы қос кең бұрышты камера",
@@ -433,145 +527,220 @@ const st = [
433
527
  "Cámara trasera dual con gran angular",
434
528
  "背面デュアル広角カメラ",
435
529
  "Stražnja dvostruka široka kamera"
436
- ], X = (r) => {
437
- if (r instanceof Error) return r;
530
+ ];
531
+ const asError = (thrown) => {
532
+ if (thrown instanceof Error) return thrown;
438
533
  try {
439
- return new Error(JSON.stringify(r));
534
+ return new Error(JSON.stringify(thrown));
440
535
  } catch {
441
- return new Error(String(r));
536
+ return new Error(String(thrown));
442
537
  }
443
538
  };
444
- class Te extends Error {
539
+ class CameraError extends Error {
445
540
  code;
446
- constructor(e, t, a) {
447
- super(e), this.code = t, this.cause = a;
541
+ constructor(message, code, cause) {
542
+ super(message);
543
+ this.code = code;
544
+ this.cause = cause;
448
545
  }
449
546
  }
450
- const lt = async () => {
547
+ const askForCameraPermission = async () => {
451
548
  try {
452
- const r = await navigator.mediaDevices.getUserMedia({
453
- video: !0
549
+ const mediaStream = await navigator.mediaDevices.getUserMedia({
550
+ video: true
454
551
  });
455
- xe(r);
456
- } catch (r) {
457
- throw console.log(r), new Te(
552
+ closeStreamTracks(mediaStream);
553
+ } catch (error) {
554
+ console.log(error);
555
+ const newError = new CameraError(
458
556
  "Camera permission not given",
459
557
  "PERMISSION_DENIED",
460
- X(r)
558
+ asError(error)
461
559
  );
560
+ throw newError;
462
561
  }
463
- }, ct = async () => {
464
- if (!isSecureContext)
465
- throw new Error(_e`
562
+ };
563
+ const obtainVideoInputDevices = async () => {
564
+ if (!isSecureContext) {
565
+ throw new Error(stripIndents`
466
566
  Cameras can only be used in a secure context:
467
567
  https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
468
568
  `);
469
- return await lt(), (await navigator.mediaDevices.enumerateDevices()).filter((t) => t.kind === "videoinput");
470
- }, xe = (r) => {
471
- const e = r.getTracks();
472
- for (const t of e)
473
- t.stop();
474
- }, ut = (r, e, t) => ({
475
- video: {
476
- deviceId: t ? { exact: t } : void 0,
477
- frameRate: 30,
478
- aspectRatio: {
479
- exact: P[r].width / P[r].height
480
- },
481
- width: {
482
- ideal: P[r].width
483
- },
484
- height: {
485
- ideal: P[r].height
569
+ }
570
+ await askForCameraPermission();
571
+ const allDevices = await navigator.mediaDevices.enumerateDevices();
572
+ const cameraDevices = allDevices.filter((device) => {
573
+ return device.kind === "videoinput";
574
+ });
575
+ return cameraDevices;
576
+ };
577
+ const closeStreamTracks = (stream) => {
578
+ const tracks = stream.getTracks();
579
+ for (const track of tracks) {
580
+ track.stop();
581
+ }
582
+ };
583
+ const createConstraints = (resolution, facing, id) => {
584
+ const constraints = {
585
+ video: {
586
+ deviceId: id ? { exact: id } : void 0,
587
+ frameRate: 30,
588
+ aspectRatio: {
589
+ exact: videoResolutions[resolution].width / videoResolutions[resolution].height
590
+ },
591
+ width: {
592
+ ideal: videoResolutions[resolution].width
593
+ },
594
+ height: {
595
+ ideal: videoResolutions[resolution].height
596
+ },
597
+ facingMode: facing
486
598
  },
487
- facingMode: e
488
- },
489
- audio: !1
490
- }), dt = async (r, e = "4k", t = "back") => {
491
- if (r.length === 0)
599
+ audio: false
600
+ };
601
+ return constraints;
602
+ };
603
+ function scoreCameraCapabilities(camera) {
604
+ let score = 0;
605
+ if (camera.torchSupported) score += 1;
606
+ if (camera.singleShotSupported) score += 1;
607
+ return score;
608
+ }
609
+ function filterCamerasByFacing(cameras, requestedFacing) {
610
+ return cameras.filter((camera) => {
611
+ if (requestedFacing === "back" || requestedFacing === void 0) {
612
+ return isBackCameraName(camera.name);
613
+ } else {
614
+ return isFrontCameraName(camera.name);
615
+ }
616
+ });
617
+ }
618
+ const findIdealCamera = async (cameras, resolution = "4k", requestedFacing = "back") => {
619
+ if (cameras.length === 0) {
492
620
  throw new Error("No cameras found");
493
- if (t === "back") {
494
- const o = r.find(
495
- (i) => st.includes(i.name)
621
+ }
622
+ if (cameras.length === 1) {
623
+ await cameras[0].startStream(resolution);
624
+ return cameras[0];
625
+ }
626
+ let cameraPool = filterCamerasByFacing(cameras, requestedFacing);
627
+ if (cameraPool.length === 1) {
628
+ await cameraPool[0].startStream(resolution);
629
+ return cameraPool[0];
630
+ }
631
+ if (cameraPool.length === 0) {
632
+ console.debug("No camera found with requested facing, using all cameras");
633
+ cameraPool = cameras;
634
+ }
635
+ if (requestedFacing === "back") {
636
+ const dualWideCamera = cameraPool.find(
637
+ (camera) => backDualWideCameraLocalizations.includes(camera.name)
496
638
  );
497
- if (o)
498
- return await o.startStream(e), o;
499
- }
500
- const a = r.filter((o) => t === "back" || t === void 0 ? Ce(o.name) : ke(o.name));
501
- if (a.length === 1 && a[0].facingMode === t)
502
- return await a[0].startStream(e), a[0];
503
- if (a.length > 0 && t === "front") {
504
- const o = a[a.length - 1];
505
- return await o.startStream(e), o;
506
- }
507
- a.length === 0 && (console.debug("No camera found with requested facing, using all cameras"), a.push(...r));
508
- const n = /* @__PURE__ */ new Map();
509
- r.forEach((o) => n.set(o, 0));
510
- for (let o = a.length - 1; o >= 0; o--) {
511
- const i = a[o];
512
- if (await i.startStream(e), !i.facingMode)
513
- return console.debug("No facing mode, returning last camera"), i;
514
- if (i.facingMode && i.facingMode !== t) {
515
- console.debug("Mismatched facing mode, moving on to the next camera"), i.stopStream();
516
- continue;
639
+ if (dualWideCamera) {
640
+ await dualWideCamera.startStream(resolution);
641
+ return dualWideCamera;
517
642
  }
518
- if (i.torchSupported && i.singleShotSupported)
519
- return console.debug("Camera supports torch and single shot, returning"), i;
520
- if (i.torchSupported && n.set(i, n.get(i) + 1), i.singleShotSupported && n.set(i, n.get(i) + 1), o === 0) {
521
- console.debug("Last camera in the pool, picking the best one");
522
- let l, c = -1 / 0;
523
- return n.forEach((f, g) => {
524
- f > c && (c = f, l = g);
525
- }), l;
643
+ }
644
+ if (requestedFacing === "front") {
645
+ const lastCamera = cameraPool[cameraPool.length - 1];
646
+ await lastCamera.startStream(resolution);
647
+ return lastCamera;
648
+ }
649
+ const cameraScores = /* @__PURE__ */ new Map();
650
+ let bestCamera;
651
+ let maxScore = -Infinity;
652
+ for (let i = cameraPool.length - 1; i >= 0; i--) {
653
+ const camera = cameraPool[i];
654
+ try {
655
+ await camera.startStream(resolution);
656
+ const score = scoreCameraCapabilities(camera);
657
+ cameraScores.set(camera, score);
658
+ if (score > maxScore) {
659
+ if (bestCamera && bestCamera !== camera) {
660
+ bestCamera.stopStream();
661
+ }
662
+ maxScore = score;
663
+ bestCamera = camera;
664
+ } else {
665
+ camera.stopStream();
666
+ }
667
+ if (score === 2) {
668
+ console.debug("Found camera with all capabilities, returning early");
669
+ return camera;
670
+ }
671
+ } catch (error) {
672
+ console.warn(`Failed to test camera ${camera.name}:`, error);
673
+ camera.stopStream();
526
674
  }
527
- i.stopStream();
528
675
  }
529
- throw new Error("No camera found, should not happen");
676
+ if (bestCamera) {
677
+ return bestCamera;
678
+ }
679
+ const firstCamera = cameraPool[0];
680
+ await firstCamera.startStream(resolution);
681
+ return firstCamera;
530
682
  };
531
- function ht(r) {
532
- const e = [];
533
- for (const t of r) {
534
- const a = new Me(t);
535
- a !== null && e.push(a);
683
+ function createCameras(cameras) {
684
+ const camerasWithStream = [];
685
+ for (const device of cameras) {
686
+ const camera = new Camera(device);
687
+ if (camera !== null) {
688
+ camerasWithStream.push(camera);
689
+ }
536
690
  }
537
- return e;
691
+ return camerasWithStream;
538
692
  }
539
- const P = {
693
+ const videoResolutions = {
540
694
  "720p": { width: 1280, height: 720 },
541
695
  "1080p": { width: 1920, height: 1080 },
542
696
  "4k": { width: 3840, height: 2160 }
543
697
  };
544
- function mt(r) {
545
- return Math.max(r.width, r.height);
698
+ function returnLongerSide(resolution) {
699
+ return Math.max(resolution.width, resolution.height);
546
700
  }
547
- function gt(r) {
548
- const e = {
549
- width: Math.max(r.width, r.height),
550
- height: Math.min(r.width, r.height)
701
+ function getNormalizedResolution(resolution) {
702
+ const normalized = {
703
+ width: Math.max(resolution.width, resolution.height),
704
+ height: Math.min(resolution.width, resolution.height)
551
705
  };
552
- return Math.abs(e.width / e.height - 16 / 9) > 1e-4 && console.warn(
553
- `Resolution ${JSON.stringify(
554
- r
555
- )} is not 16:9, may cause issues with some video players.`
556
- ), e;
706
+ const epsilon = 1e-4;
707
+ if (Math.abs(normalized.width / normalized.height - 16 / 9) > epsilon) {
708
+ console.warn(
709
+ `Resolution ${JSON.stringify(
710
+ resolution
711
+ )} is not 16:9, may cause issues with some video players.`
712
+ );
713
+ }
714
+ return normalized;
557
715
  }
558
- function ft(r) {
559
- const e = mt(r);
560
- return e > 1920 ? "4k" : e > 1280 ? "1080p" : "720p";
716
+ function matchClosestResolution(resolution) {
717
+ const actualWidth = returnLongerSide(resolution);
718
+ if (actualWidth > 1920) {
719
+ return "4k";
720
+ } else if (actualWidth > 1280) {
721
+ return "1080p";
722
+ } else {
723
+ return "720p";
724
+ }
561
725
  }
562
- function bt(r) {
563
- const e = gt(r), t = Object.entries(P).find(
564
- ([n, o]) => o.width === e.width && o.height === e.height
726
+ function findResolutionKey(videoTrackResolution) {
727
+ const normalizedResolution = getNormalizedResolution(videoTrackResolution);
728
+ const resolutionMatch = Object.entries(videoResolutions).find(
729
+ ([key, value]) => {
730
+ return value.width === normalizedResolution.width && value.height === normalizedResolution.height;
731
+ }
565
732
  );
566
- if (!t) {
567
- const n = ft(r);
568
- return console.warn(
569
- `No exact resolution match found for ${JSON.stringify(r)}, categorizing as ${n}`
570
- ), n;
733
+ if (!resolutionMatch) {
734
+ const closestMatch = matchClosestResolution(videoTrackResolution);
735
+ console.warn(
736
+ `No exact resolution match found for ${JSON.stringify(videoTrackResolution)}, categorizing as ${closestMatch}`
737
+ );
738
+ return closestMatch;
571
739
  }
572
- return t[0];
740
+ const resolutionKey = resolutionMatch[0];
741
+ return resolutionKey;
573
742
  }
574
- class Me {
743
+ class Camera {
575
744
  deviceInfo;
576
745
  /**
577
746
  * Stream capabilities as reported by the stream.
@@ -585,9 +754,9 @@ class Me {
585
754
  activeStream;
586
755
  name;
587
756
  facingMode;
588
- torchSupported = !1;
589
- torchEnabled = !1;
590
- singleShotSupported = !1;
757
+ torchSupported = false;
758
+ torchEnabled = false;
759
+ singleShotSupported = false;
591
760
  maxSupportedResolution;
592
761
  /**
593
762
  * Reference to the original instance before it was proxied.
@@ -604,100 +773,158 @@ class Me {
604
773
  *
605
774
  * @deprecated Not used. Reconsider using once Firefox and Chrome align on this.
606
775
  */
607
- #e;
608
- constructor(e) {
609
- if (e.kind !== "videoinput")
776
+ #deviceCapabilities;
777
+ constructor(deviceInfo) {
778
+ if (deviceInfo.kind !== "videoinput") {
610
779
  throw new Error("Device is not a video input device");
611
- this.deviceInfo = e, this.name = e.label, ke(e.label) && (this.facingMode = "front"), Ce(e.label) && (this.facingMode = "back");
612
- const t = this, a = new Proxy(this, {
613
- set(n, o, i, l) {
614
- const c = Reflect.get(n, o, l), f = {
615
- property: o,
616
- oldValue: c,
617
- value: i
780
+ }
781
+ this.deviceInfo = deviceInfo;
782
+ this.name = deviceInfo.label;
783
+ if (isFrontCameraName(deviceInfo.label)) {
784
+ this.facingMode = "front";
785
+ }
786
+ if (isBackCameraName(deviceInfo.label)) {
787
+ this.facingMode = "back";
788
+ }
789
+ const originalRef = this;
790
+ const proxy = new Proxy(this, {
791
+ set(target, property, value, receiver) {
792
+ const oldValue = Reflect.get(target, property, receiver);
793
+ const change = {
794
+ property,
795
+ oldValue,
796
+ value
618
797
  };
619
- return t.notify(f), Reflect.set(n, o, i, l);
798
+ originalRef.notify(change);
799
+ return Reflect.set(target, property, value, receiver);
620
800
  }
621
801
  });
622
- return this.notify = (n) => {
623
- this.notifyStateChange?.(a, n);
624
- }, a;
802
+ this.notify = (reason) => {
803
+ this.notifyStateChange?.(proxy, reason);
804
+ };
805
+ return proxy;
625
806
  }
626
- async startStream(e) {
627
- if (this.activeStream)
807
+ async startStream(resolution) {
808
+ if (this.activeStream) {
628
809
  return this.activeStream;
629
- this.maxSupportedResolution && (e = this.maxSupportedResolution);
630
- const t = await this.acquireStreamWithFallback(e);
631
- this.populateCapabilities(t), this.activeStream = t;
632
- const a = t.getVideoTracks()[0];
633
- return a.onended = (n) => {
634
- this.stopStream(), this.notify({
635
- event: n,
810
+ }
811
+ if (this.maxSupportedResolution) {
812
+ resolution = this.maxSupportedResolution;
813
+ }
814
+ const stream = await this.acquireStreamWithFallback(resolution);
815
+ this.populateCapabilities(stream);
816
+ this.activeStream = stream;
817
+ const videoTrack = stream.getVideoTracks()[0];
818
+ videoTrack.onended = (e) => {
819
+ this.stopStream();
820
+ this.notify({
821
+ event: e,
636
822
  payload: "TRACK_END"
637
823
  });
638
- }, t;
824
+ };
825
+ return stream;
639
826
  }
640
827
  /**
641
828
  * Acquires a camera stream with the specified resolution.
642
829
  * If acquisition fails, it tries a lower resolution as fallback.
643
830
  */
644
- async acquireStreamWithFallback(e) {
831
+ async acquireStreamWithFallback(resolution) {
645
832
  try {
646
- const t = ut(
647
- e,
833
+ const constraints = createConstraints(
834
+ resolution,
648
835
  this.facingMode,
649
836
  this.deviceInfo.deviceId
650
837
  );
651
- return await navigator.mediaDevices.getUserMedia(t);
652
- } catch (t) {
838
+ return await navigator.mediaDevices.getUserMedia(constraints);
839
+ } catch (error) {
653
840
  console.warn(
654
- `Can't get camera stream for ${this.name} at ${e}`,
655
- t
841
+ `Can't get camera stream for ${this.name} at ${resolution}`,
842
+ error
656
843
  );
657
- let a = Object.keys(P).indexOf(e);
658
- if (a === 0)
844
+ let currentResolutionIndex = Object.keys(videoResolutions).indexOf(resolution);
845
+ if (currentResolutionIndex === 0) {
659
846
  throw new Error("Failed to get camera stream");
660
- const n = Object.keys(P)[a - 1];
661
- return await this.acquireStreamWithFallback(n);
847
+ }
848
+ const fallbackResolution = Object.keys(videoResolutions)[currentResolutionIndex - 1];
849
+ return await this.acquireStreamWithFallback(fallbackResolution);
662
850
  }
663
851
  }
664
852
  /**
665
853
  * Populates the camera instance with capabilities from the stream.
666
854
  */
667
- populateCapabilities(e) {
668
- this.streamCapabilities = e.getVideoTracks()[0].getCapabilities();
669
- const a = e.getVideoTracks()[0].getSettings();
670
- if (!a.width || !a.height)
855
+ populateCapabilities(stream) {
856
+ this.streamCapabilities = stream.getVideoTracks()[0].getCapabilities();
857
+ const videoTrack = stream.getVideoTracks()[0];
858
+ const trackSettings = videoTrack.getSettings();
859
+ if (!trackSettings.width || !trackSettings.height) {
671
860
  throw new Error(
672
861
  "Video track resolution not available. Should not happen."
673
862
  );
674
- const n = {
675
- width: a.width,
676
- height: a.height
677
- }, o = bt(n);
678
- !this.maxSupportedResolution && o && (this.maxSupportedResolution = o), "torch" in this.streamCapabilities && (this.torchSupported = !0), "focusMode" in this.streamCapabilities && this.streamCapabilities.focusMode?.includes("single-shot") && (this.singleShotSupported = !0), this.facingMode === "front" && this.streamCapabilities.facingMode?.includes("environment") && (this.facingMode = "back", console.warn("Front camera selected, but facingMode is environment")), this.facingMode === "back" && this.streamCapabilities.facingMode?.includes("user") && (this.facingMode = "front", console.warn("Back camera selected, but facingMode is user")), this.facingMode || (this.streamCapabilities.facingMode?.includes("environment") && (this.facingMode = "back"), this.streamCapabilities.facingMode?.includes("user") && (this.facingMode = "front"));
863
+ }
864
+ const videoTrackResolution = {
865
+ width: trackSettings.width,
866
+ height: trackSettings.height
867
+ };
868
+ const resolutionKey = findResolutionKey(videoTrackResolution);
869
+ if (!this.maxSupportedResolution && resolutionKey) {
870
+ this.maxSupportedResolution = resolutionKey;
871
+ }
872
+ if ("torch" in this.streamCapabilities) {
873
+ this.torchSupported = true;
874
+ }
875
+ if ("focusMode" in this.streamCapabilities && this.streamCapabilities.focusMode?.includes("single-shot")) {
876
+ this.singleShotSupported = true;
877
+ }
878
+ if (this.facingMode === "front" && this.streamCapabilities.facingMode?.includes("environment")) {
879
+ this.facingMode = "back";
880
+ console.warn("Front camera selected, but facingMode is environment");
881
+ }
882
+ if (this.facingMode === "back" && this.streamCapabilities.facingMode?.includes("user")) {
883
+ this.facingMode = "front";
884
+ console.warn("Back camera selected, but facingMode is user");
885
+ }
886
+ if (!this.facingMode) {
887
+ if (this.streamCapabilities.facingMode?.includes("environment")) {
888
+ this.facingMode = "back";
889
+ }
890
+ if (this.streamCapabilities.facingMode?.includes("user")) {
891
+ this.facingMode = "front";
892
+ }
893
+ }
679
894
  }
680
895
  async toggleTorch() {
681
- const e = this.getVideoTrack();
682
- if (!e)
896
+ const videoTrack = this.getVideoTrack();
897
+ if (!videoTrack) {
683
898
  throw new Error("No active stream on Camera instance.");
684
- if (!this.torchSupported)
899
+ }
900
+ if (!this.torchSupported) {
685
901
  throw new Error("Torch not supported on this device.");
902
+ }
686
903
  try {
687
- await e.applyConstraints({
904
+ await videoTrack.applyConstraints({
688
905
  advanced: [
689
906
  {
690
907
  torch: !this.torchEnabled
691
908
  }
692
909
  ]
693
- }), this.torchEnabled = !this.torchEnabled;
694
- } catch (t) {
695
- throw console.error("Failed to toggle torch", t), this.torchEnabled = !1, this.torchSupported = !1, new Error("Failed to toggle torch", { cause: t });
910
+ });
911
+ this.torchEnabled = !this.torchEnabled;
912
+ } catch (error) {
913
+ console.error("Failed to toggle torch", error);
914
+ this.torchEnabled = false;
915
+ this.torchSupported = false;
916
+ throw new Error("Failed to toggle torch", { cause: error });
696
917
  }
697
918
  return this.torchEnabled;
698
919
  }
699
920
  stopStream() {
700
- this.activeStream && (console.debug(`Stopping active stream on ${this.name}`), xe(this.activeStream), this.activeStream = void 0, this.streamCapabilities = void 0, this.torchEnabled = !1);
921
+ if (this.activeStream) {
922
+ console.debug(`Stopping active stream on ${this.name}`);
923
+ closeStreamTracks(this.activeStream);
924
+ this.activeStream = void 0;
925
+ this.streamCapabilities = void 0;
926
+ this.torchEnabled = false;
927
+ }
701
928
  }
702
929
  getVideoTrack() {
703
930
  if (!this.activeStream) {
@@ -707,149 +934,241 @@ class Me {
707
934
  return this.activeStream.getVideoTracks()[0];
708
935
  }
709
936
  }
710
- const ce = Element.prototype.attachShadow;
711
- function se() {
712
- return typeof window.ShadyDOM < "u" && typeof ShadowRoot < "u";
937
+ const ORIGINAL_ATTACH_SHADOW = Element.prototype.attachShadow;
938
+ function isShady() {
939
+ return typeof window.ShadyDOM !== "undefined" && typeof ShadowRoot !== "undefined";
713
940
  }
714
- function pt() {
715
- return typeof ShadowRoot < "u";
941
+ function supportsShadowRoots() {
942
+ return typeof ShadowRoot !== "undefined";
716
943
  }
717
- function vt(r) {
718
- ce == null || se() || (Element.prototype.attachShadow = function(e) {
719
- const t = ce.call(this, e);
720
- return r(t), t;
721
- });
944
+ function patchElementPrototypeAttachShadow(callback) {
945
+ if (ORIGINAL_ATTACH_SHADOW == null || isShady())
946
+ return;
947
+ Element.prototype.attachShadow = function(shadowRootInitDict) {
948
+ const shadowRoot = ORIGINAL_ATTACH_SHADOW.call(this, shadowRootInitDict);
949
+ callback(shadowRoot);
950
+ return shadowRoot;
951
+ };
722
952
  }
723
- function wt(r, ...e) {
724
- const t = new Set(e);
725
- let a = !1;
726
- const n = () => {
727
- for (const o of t)
728
- r(o);
729
- t.clear();
953
+ function createPausableQueue(job, ...queueItems) {
954
+ const queue = new Set(queueItems);
955
+ let running = false;
956
+ const flush = () => {
957
+ for (const queuedNode of queue) {
958
+ job(queuedNode);
959
+ }
960
+ queue.clear();
730
961
  };
731
962
  return {
732
963
  isRunning() {
733
- return a;
964
+ return running;
734
965
  },
735
- schedule(o) {
736
- t.add(o), a && n();
966
+ schedule(node) {
967
+ queue.add(node);
968
+ if (running) {
969
+ flush();
970
+ }
737
971
  },
738
972
  stop() {
739
- a = !1;
973
+ running = false;
740
974
  },
741
975
  run() {
742
- a || (a = !0, n());
976
+ if (running)
977
+ return;
978
+ running = true;
979
+ flush();
743
980
  }
744
981
  };
745
982
  }
746
- const yt = {
747
- childList: !0,
748
- subtree: !0
749
- }, St = (r) => {
750
- typeof queueMicrotask < "u" ? queueMicrotask(r) : typeof Promise < "u" ? Promise.resolve().then(() => r()) : setTimeout(() => r(), 0);
983
+ const MUTATION_OBSERVER_INIT = {
984
+ childList: true,
985
+ subtree: true
986
+ };
987
+ const nextMicrotask = (func) => {
988
+ if (typeof queueMicrotask !== "undefined")
989
+ queueMicrotask(func);
990
+ else if (typeof Promise !== "undefined")
991
+ Promise.resolve().then(() => func());
992
+ else
993
+ setTimeout(() => func(), 0);
751
994
  };
752
- function ue(r) {
753
- if (typeof Symbol < "u" && r[Symbol.iterator] != null)
754
- return [...r];
755
- {
756
- const e = [];
757
- for (let t = 0; t < r.length; t++)
758
- e[t] = r[t];
759
- return e;
995
+ function nodeListToArray(nodeList) {
996
+ if (typeof Symbol !== "undefined" && nodeList[Symbol.iterator] != null) {
997
+ return [...nodeList];
998
+ } else {
999
+ const arr = [];
1000
+ for (let i = 0; i < nodeList.length; i++) {
1001
+ arr[i] = nodeList[i];
1002
+ }
1003
+ return arr;
760
1004
  }
761
1005
  }
762
- function Ct(r, e) {
763
- return se() ? new Set(ue(window.ShadyDOM.nativeMethods.querySelectorAll.call(document.documentElement, e))) : new Set("querySelectorAll" in r ? ue(r.querySelectorAll(e)) : []);
1006
+ function queryRoot(root, query) {
1007
+ if (isShady()) {
1008
+ return new Set(nodeListToArray(window.ShadyDOM.nativeMethods.querySelectorAll.call(document.documentElement, query)));
1009
+ }
1010
+ return new Set(!("querySelectorAll" in root) ? [] : nodeListToArray(root.querySelectorAll(query)));
764
1011
  }
765
- function kt(r, e) {
766
- return /* @__PURE__ */ new Set([...r ?? [], ...e ?? []]);
1012
+ function mergeNodes(a, b) {
1013
+ return /* @__PURE__ */ new Set([...a == null ? [] : a, ...b == null ? [] : b]);
767
1014
  }
768
- function Et(r) {
769
- return "activeElement" in r;
1015
+ function isDocumentOrShadowRoot(root) {
1016
+ return "activeElement" in root;
770
1017
  }
771
- function Re(r = document.documentElement) {
772
- if (Et(r) && Ae(r), se() && r instanceof ShadowRoot || !pt())
1018
+ function observeMissingRoots(root = document.documentElement) {
1019
+ if (isDocumentOrShadowRoot(root)) {
1020
+ observeRoot(root);
1021
+ }
1022
+ if (isShady() && root instanceof ShadowRoot)
1023
+ return;
1024
+ if (!supportsShadowRoots())
773
1025
  return;
774
- const e = r.childNodes, t = "shadowRoot" in r && r.shadowRoot != null ? [r.shadowRoot] : [];
775
- for (const a of [...e, ...t])
776
- Re(a);
1026
+ const childNodes = root.childNodes;
1027
+ const shadowRoot = "shadowRoot" in root && root.shadowRoot != null ? [root.shadowRoot] : [];
1028
+ for (const node of [...childNodes, ...shadowRoot]) {
1029
+ observeMissingRoots(node);
1030
+ }
777
1031
  }
778
- function _t(r) {
779
- return "isConnected" in Node.prototype ? r.isConnected : r.ownerDocument == null || !(r.ownerDocument.compareDocumentPosition(r) & r.DOCUMENT_POSITION_DISCONNECTED);
1032
+ function isConnected(node) {
1033
+ if ("isConnected" in Node.prototype)
1034
+ return node.isConnected;
1035
+ return node.ownerDocument == null || !(node.ownerDocument.compareDocumentPosition(node) & node.DOCUMENT_POSITION_DISCONNECTED);
780
1036
  }
781
- const W = /* @__PURE__ */ new Map();
782
- function Tt(r, e) {
783
- const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new WeakMap();
784
- let i = !1, l = !1, c = !1;
785
- const f = () => {
786
- l = !0;
787
- const v = [...t];
788
- v.length > 0 && e(v, r), t.clear(), i = !1, l = !1;
789
- }, g = () => {
790
- i || (i = !0, St(f));
791
- }, y = (v) => {
792
- t.add(v), l || g();
793
- }, u = () => {
794
- const v = [...t];
795
- return t.clear(), v;
796
- }, h = () => {
797
- a.clear();
798
- }, p = (v, x) => {
799
- let R = n.get(v);
800
- const F = Ct(v, x), M = R?.get(x), Pe = kt(F, M);
801
- C(Pe), R == null && (R = /* @__PURE__ */ new Map(), n.set(v, R)), R.set(x, F);
802
- }, C = (v) => {
803
- for (const x of v) {
804
- const R = o.get(x), F = _t(x);
805
- R !== F && (o.set(x, F), y({
806
- connected: F,
807
- target: x
808
- }));
1037
+ const CONNECTION_OBSERVER_INTERNALS_MAP = /* @__PURE__ */ new Map();
1038
+ function initializeConnectionObserver(observer, callback) {
1039
+ const queue = /* @__PURE__ */ new Set();
1040
+ const observedTargets = /* @__PURE__ */ new Set();
1041
+ const rootToQuerySelectorToMatchedNodesMap = /* @__PURE__ */ new Map();
1042
+ const nodeToLastConnectionValueMap = /* @__PURE__ */ new WeakMap();
1043
+ let scheduled = false;
1044
+ let flushing = false;
1045
+ let hasFoundMissingRoots = false;
1046
+ const flush = () => {
1047
+ flushing = true;
1048
+ const arr = [...queue];
1049
+ if (arr.length > 0) {
1050
+ callback(arr, observer);
809
1051
  }
810
- }, b = {
811
- observedTargets: a,
812
- queryRootAndHandleMutationChanges: p,
813
- handleMutationChange: C,
814
- addObservedTarget: (v) => {
815
- if (ae.run(), c || (c = !0, Re()), a.add(v), typeof v != "string")
816
- C([v]);
817
- else
818
- for (const x of re)
819
- p(x, v);
820
- },
821
- clearObservedTargets: h,
822
- clearQueue: u
1052
+ queue.clear();
1053
+ scheduled = false;
1054
+ flushing = false;
1055
+ };
1056
+ const scheduleFlush = () => {
1057
+ if (!scheduled) {
1058
+ scheduled = true;
1059
+ nextMicrotask(flush);
1060
+ }
1061
+ };
1062
+ const addToQueue = (entry) => {
1063
+ queue.add(entry);
1064
+ if (!flushing) {
1065
+ scheduleFlush();
1066
+ }
1067
+ };
1068
+ const clearQueue = () => {
1069
+ const items = [...queue];
1070
+ queue.clear();
1071
+ return items;
823
1072
  };
824
- W.set(r, b);
1073
+ const clearObservedTargets = () => {
1074
+ observedTargets.clear();
1075
+ };
1076
+ const queryRootAndHandleMutationChanges = (root, query) => {
1077
+ let oldQuerySelectorMap = rootToQuerySelectorToMatchedNodesMap.get(root);
1078
+ const currentNodes = queryRoot(root, query);
1079
+ const oldNodes = oldQuerySelectorMap == null ? void 0 : oldQuerySelectorMap.get(query);
1080
+ const mergedNodes = mergeNodes(currentNodes, oldNodes);
1081
+ handleMutationChange(mergedNodes);
1082
+ if (oldQuerySelectorMap == null) {
1083
+ oldQuerySelectorMap = /* @__PURE__ */ new Map();
1084
+ rootToQuerySelectorToMatchedNodesMap.set(root, oldQuerySelectorMap);
1085
+ }
1086
+ oldQuerySelectorMap.set(query, currentNodes);
1087
+ };
1088
+ const handleMutationChange = (targetNodes) => {
1089
+ for (const targetNode of targetNodes) {
1090
+ const lastValue = nodeToLastConnectionValueMap.get(targetNode);
1091
+ const isTargetNodeConnected = isConnected(targetNode);
1092
+ if (lastValue !== isTargetNodeConnected) {
1093
+ nodeToLastConnectionValueMap.set(targetNode, isTargetNodeConnected);
1094
+ addToQueue({
1095
+ connected: isTargetNodeConnected,
1096
+ target: targetNode
1097
+ });
1098
+ }
1099
+ }
1100
+ };
1101
+ const addObservedTarget = (target) => {
1102
+ rootObserverQueue.run();
1103
+ if (!hasFoundMissingRoots) {
1104
+ hasFoundMissingRoots = true;
1105
+ observeMissingRoots();
1106
+ }
1107
+ observedTargets.add(target);
1108
+ if (typeof target !== "string") {
1109
+ handleMutationChange([target]);
1110
+ } else {
1111
+ for (const root of OBSERVED_ROOTS) {
1112
+ queryRootAndHandleMutationChanges(root, target);
1113
+ }
1114
+ }
1115
+ };
1116
+ const internals = {
1117
+ observedTargets,
1118
+ queryRootAndHandleMutationChanges,
1119
+ handleMutationChange,
1120
+ addObservedTarget,
1121
+ clearObservedTargets,
1122
+ clearQueue
1123
+ };
1124
+ CONNECTION_OBSERVER_INTERNALS_MAP.set(observer, internals);
825
1125
  }
826
- const xt = (r) => {
827
- for (const e of r)
828
- if (e.type === "childList")
829
- for (const t of W.values())
830
- for (const a of t.observedTargets)
831
- typeof a == "string" ? t.queryRootAndHandleMutationChanges(e.target, a) : t.handleMutationChange([a]);
832
- }, re = /* @__PURE__ */ new Set(), Ae = /* @__PURE__ */ (() => {
833
- let r;
834
- return function(e) {
835
- re.has(e) || (re.add(e), r == null && (r = new MutationObserver(xt)), r.observe(e, yt));
1126
+ const mutationCallback = (mutations) => {
1127
+ for (const mutation of mutations) {
1128
+ if (mutation.type !== "childList")
1129
+ continue;
1130
+ for (const observer of CONNECTION_OBSERVER_INTERNALS_MAP.values()) {
1131
+ for (const target of observer.observedTargets) {
1132
+ if (typeof target === "string") {
1133
+ observer.queryRootAndHandleMutationChanges(mutation.target, target);
1134
+ } else {
1135
+ observer.handleMutationChange([target]);
1136
+ }
1137
+ }
1138
+ }
1139
+ }
1140
+ };
1141
+ const OBSERVED_ROOTS = /* @__PURE__ */ new Set();
1142
+ const observeRoot = /* @__PURE__ */ (() => {
1143
+ let instance;
1144
+ return function(root) {
1145
+ if (OBSERVED_ROOTS.has(root))
1146
+ return;
1147
+ OBSERVED_ROOTS.add(root);
1148
+ if (instance == null) {
1149
+ instance = new MutationObserver(mutationCallback);
1150
+ }
1151
+ instance.observe(root, MUTATION_OBSERVER_INIT);
836
1152
  };
837
- })(), ae = wt(Ae, document.documentElement);
838
- class N {
839
- constructor(e) {
840
- if (new.target === void 0)
841
- throw new TypeError(`Constructor ${N.name} requires 'new'`);
842
- if (e === void 0)
843
- throw new ReferenceError(`Failed to construct '${N.name}': 1 argument required, but only 0 present.`);
844
- if (typeof e != "function")
845
- throw new TypeError(`Failed to construct '${N.name}': The callback provided as parameter 1 is not a function.`);
846
- Tt(this, e);
1153
+ })();
1154
+ const rootObserverQueue = createPausableQueue(observeRoot, document.documentElement);
1155
+ class ConnectionObserver {
1156
+ constructor(callback) {
1157
+ if (new.target === void 0) {
1158
+ throw new TypeError(`Constructor ${ConnectionObserver.name} requires 'new'`);
1159
+ }
1160
+ if (callback === void 0) {
1161
+ throw new ReferenceError(`Failed to construct '${ConnectionObserver.name}': 1 argument required, but only 0 present.`);
1162
+ } else if (typeof callback !== "function") {
1163
+ throw new TypeError(`Failed to construct '${ConnectionObserver.name}': The callback provided as parameter 1 is not a function.`);
1164
+ }
1165
+ initializeConnectionObserver(this, callback);
847
1166
  }
848
1167
  /**
849
1168
  * The Symbol.@@toStringTag value
850
1169
  */
851
1170
  get [Symbol.toStringTag]() {
852
- return "ConnectionObserver";
1171
+ return `ConnectionObserver`;
853
1172
  }
854
1173
  /**
855
1174
  * Observe the given node or query selector for connections/disconnections.
@@ -857,121 +1176,148 @@ class N {
857
1176
  * as for example "img[data-some-attr]", for each new MutationRecord, the query selector
858
1177
  * will be executed and the matched nodes will be observed for connections/disconnections
859
1178
  */
860
- observe(e) {
861
- if (e === void 0)
862
- throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${N.name}': 1 argument required, but only 0 present.`);
863
- if (typeof e != "string" && !(e instanceof Node))
864
- throw new TypeError(`Failed to execute '${this.observe.name}' on '${N.name}': parameter 1 is not of type 'Node' or a DOMString.`);
865
- const t = W.get(this);
866
- t?.addObservedTarget(e);
1179
+ observe(target) {
1180
+ if (target === void 0) {
1181
+ throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${ConnectionObserver.name}': 1 argument required, but only 0 present.`);
1182
+ } else if (typeof target !== "string" && !(target instanceof Node)) {
1183
+ throw new TypeError(`Failed to execute '${this.observe.name}' on '${ConnectionObserver.name}': parameter 1 is not of type 'Node' or a DOMString.`);
1184
+ }
1185
+ const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
1186
+ if (internals == null)
1187
+ return;
1188
+ internals.addObservedTarget(target);
867
1189
  }
868
1190
  /**
869
1191
  * Takes the records immediately (instead of waiting for the next flush)
870
1192
  */
871
1193
  takeRecords() {
872
- const e = W.get(this);
873
- return e == null ? [] : e.clearQueue();
1194
+ const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
1195
+ if (internals == null)
1196
+ return [];
1197
+ return internals.clearQueue();
874
1198
  }
875
1199
  /**
876
1200
  * Disconnects the ConnectionObserver such that none of its callbacks will be invoked any longer
877
1201
  */
878
1202
  disconnect() {
879
- const e = W.get(this);
880
- e?.clearObservedTargets();
1203
+ const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
1204
+ if (internals == null)
1205
+ return;
1206
+ internals.clearObservedTargets();
881
1207
  }
882
1208
  }
883
- vt(ae.schedule.bind(ae));
884
- function Mt(r, ...e) {
885
- return r.addEventListener(...e), () => {
886
- r.removeEventListener(...e);
1209
+ patchElementPrototypeAttachShadow(rootObserverQueue.schedule.bind(rootObserverQueue));
1210
+ function radEventListener(element, ...args) {
1211
+ element.addEventListener(...args);
1212
+ return () => {
1213
+ element.removeEventListener(...args);
887
1214
  };
888
1215
  }
889
- function Rt(r, e) {
890
- let t;
891
- if (e((a, n) => {
892
- r.addEventListener(a, n), t = () => r.removeEventListener(a, n);
893
- }), !t)
1216
+ function rad(element, gen) {
1217
+ let cleanup;
1218
+ gen((listener, options) => {
1219
+ element.addEventListener(listener, options);
1220
+ cleanup = () => element.removeEventListener(listener, options);
1221
+ });
1222
+ if (!cleanup) {
894
1223
  throw new Error("you forgot to add event listener");
895
- return t;
1224
+ }
1225
+ return cleanup;
896
1226
  }
897
- function ne(r) {
898
- const e = $e(r);
899
- if ("detached" in e)
900
- return e.detached;
1227
+ function isBufferDetached(buffer) {
1228
+ const actualBuffer = getBuffer(buffer);
1229
+ if ("detached" in actualBuffer) {
1230
+ const detached = actualBuffer.detached;
1231
+ return detached;
1232
+ }
901
1233
  try {
902
- return new Uint8Array(e), !1;
903
- } catch {
904
- return !0;
1234
+ new Uint8Array(actualBuffer);
1235
+ return false;
1236
+ } catch (e) {
1237
+ return true;
905
1238
  }
906
1239
  }
907
- class At {
908
- #e;
909
- #o = null;
910
- #a = null;
911
- #r = null;
912
- #n = null;
913
- #t = null;
914
- #s = 0;
915
- #l = 0;
916
- #i;
917
- #u = 4;
918
- constructor(e = {}) {
919
- const { canvasRenderingMode: t = "webgl2", fallbackWebGlTo2d: a = !0 } = e;
920
- if (this.#i = t, this.#e = document.createElement("canvas"), t === "2d")
921
- this.#d();
922
- else if (t === "webgl2")
1240
+ class VideoFrameProcessor {
1241
+ #canvas;
1242
+ #context2d = null;
1243
+ #contextWebGl2 = null;
1244
+ #webGl2Texture = null;
1245
+ #webGl2Framebuffer = null;
1246
+ #buffer = null;
1247
+ #cachedWidth = 0;
1248
+ #cachedHeight = 0;
1249
+ #canvasRenderingMode;
1250
+ #requiredPackAlignment = 4;
1251
+ constructor(options = {}) {
1252
+ const { canvasRenderingMode = "webgl2", fallbackWebGlTo2d = true } = options;
1253
+ this.#canvasRenderingMode = canvasRenderingMode;
1254
+ this.#canvas = document.createElement("canvas");
1255
+ if (canvasRenderingMode === "2d") {
1256
+ this.#initialize2dContext();
1257
+ } else if (canvasRenderingMode === "webgl2") {
923
1258
  try {
924
- this.#h();
925
- } catch (n) {
926
- if (a)
1259
+ this.#initializeWebGl2Context();
1260
+ } catch (error) {
1261
+ if (fallbackWebGlTo2d) {
927
1262
  console.warn(
928
1263
  "Failed to create WebGL2 context, falling back to 2D canvas"
929
- ), this.#i = "2d", this.#d();
930
- else
931
- throw n;
1264
+ );
1265
+ this.#canvasRenderingMode = "2d";
1266
+ this.#initialize2dContext();
1267
+ } else {
1268
+ throw error;
1269
+ }
932
1270
  }
933
- else
1271
+ } else {
934
1272
  throw new Error(
935
- `Unsupported rendering context: ${t}`
1273
+ `Unsupported rendering context: ${canvasRenderingMode}`
936
1274
  );
1275
+ }
937
1276
  }
938
1277
  /**
939
1278
  * Initializes the 2D canvas context
940
1279
  */
941
- #d() {
942
- const e = this.#e.getContext("2d", {
943
- alpha: !1,
944
- willReadFrequently: !0
1280
+ #initialize2dContext() {
1281
+ const ctx = this.#canvas.getContext("2d", {
1282
+ alpha: false,
1283
+ willReadFrequently: true
945
1284
  });
946
- if (!e) throw new Error("CanvasRenderingContext2D is missing!");
947
- this.#o = e;
1285
+ if (!ctx) throw new Error("CanvasRenderingContext2D is missing!");
1286
+ this.#context2d = ctx;
948
1287
  }
949
1288
  /**
950
1289
  * Initializes the WebGL2 context and resources
951
1290
  */
952
- #h() {
953
- const e = this.#e.getContext("webgl2", {
954
- alpha: !1,
955
- depth: !1,
956
- stencil: !1,
957
- antialias: !1,
958
- premultipliedAlpha: !1,
959
- preserveDrawingBuffer: !1,
960
- desynchronized: !1,
1291
+ #initializeWebGl2Context() {
1292
+ const ctx = this.#canvas.getContext("webgl2", {
1293
+ alpha: false,
1294
+ depth: false,
1295
+ stencil: false,
1296
+ antialias: false,
1297
+ premultipliedAlpha: false,
1298
+ preserveDrawingBuffer: false,
1299
+ desynchronized: false,
961
1300
  powerPreference: "high-performance"
962
1301
  });
963
- if (!e) throw new Error("WebGL2RenderingContext is missing!");
964
- this.#a = e;
965
- const t = e.createTexture();
966
- if (!t) throw new Error("Failed to create WebGL texture");
967
- this.#r = t, e.bindTexture(e.TEXTURE_2D, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST);
968
- const a = e.createFramebuffer();
969
- if (!a) throw new Error("Failed to create framebuffer");
970
- this.#n = a, e.bindFramebuffer(e.FRAMEBUFFER, a), e.framebufferTexture2D(
971
- e.FRAMEBUFFER,
972
- e.COLOR_ATTACHMENT0,
973
- e.TEXTURE_2D,
974
- t,
1302
+ if (!ctx) throw new Error("WebGL2RenderingContext is missing!");
1303
+ this.#contextWebGl2 = ctx;
1304
+ const texture = ctx.createTexture();
1305
+ if (!texture) throw new Error("Failed to create WebGL texture");
1306
+ this.#webGl2Texture = texture;
1307
+ ctx.bindTexture(ctx.TEXTURE_2D, texture);
1308
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE);
1309
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE);
1310
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.NEAREST);
1311
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.NEAREST);
1312
+ const framebuffer = ctx.createFramebuffer();
1313
+ if (!framebuffer) throw new Error("Failed to create framebuffer");
1314
+ this.#webGl2Framebuffer = framebuffer;
1315
+ ctx.bindFramebuffer(ctx.FRAMEBUFFER, framebuffer);
1316
+ ctx.framebufferTexture2D(
1317
+ ctx.FRAMEBUFFER,
1318
+ ctx.COLOR_ATTACHMENT0,
1319
+ ctx.TEXTURE_2D,
1320
+ texture,
975
1321
  0
976
1322
  );
977
1323
  }
@@ -980,31 +1326,34 @@ class At {
980
1326
  * This should only be called with ArrayBuffers that were originally from this processor
981
1327
  * Typically used after transferring the buffer to/from a worker
982
1328
  */
983
- reattachArrayBuffer(e) {
984
- const t = $e(e);
985
- if (ne(t))
1329
+ reattachArrayBuffer(arrayBuffer) {
1330
+ const actualBuffer = getBuffer(arrayBuffer);
1331
+ if (isBufferDetached(actualBuffer)) {
986
1332
  throw new Error("Can't use a detached array buffer!");
987
- const a = this.#s * this.#l * 4;
988
- if (t.byteLength === a)
989
- this.#t = new Uint8ClampedArray(t);
990
- else
1333
+ }
1334
+ const requiredSize = this.#cachedWidth * this.#cachedHeight * 4;
1335
+ if (actualBuffer.byteLength === requiredSize) {
1336
+ this.#buffer = new Uint8ClampedArray(actualBuffer);
1337
+ } else {
991
1338
  throw new Error(
992
- `ArrayBuffer size mismatch: expected ${a}, got ${t.byteLength}`
1339
+ `ArrayBuffer size mismatch: expected ${requiredSize}, got ${actualBuffer.byteLength}`
993
1340
  );
1341
+ }
994
1342
  }
995
1343
  /**
996
1344
  * Used to check if the processor owns the buffer
997
1345
  */
998
1346
  isBufferDetached() {
999
- if (!this.#t)
1347
+ if (!this.#buffer) {
1000
1348
  throw new Error("Buffer is missing!");
1001
- return ne(this.#t.buffer);
1349
+ }
1350
+ return isBufferDetached(this.#buffer.buffer);
1002
1351
  }
1003
1352
  /**
1004
1353
  * Extracts image data from a source element
1005
1354
  */
1006
- getImageData(e, t) {
1007
- return this.#i === "2d" ? this.#m(e, t) : this.#g(e, t);
1355
+ getImageData(source, area) {
1356
+ return this.#canvasRenderingMode === "2d" ? this.#getImageData2d(source, area) : this.#getImageDataWebGl2(source, area);
1008
1357
  }
1009
1358
  /**
1010
1359
  * Used to get the current ImageData object with the current buffer. Useful
@@ -1013,126 +1362,178 @@ class At {
1013
1362
  * @returns ImageData object with the current buffer
1014
1363
  */
1015
1364
  getCurrentImageData() {
1016
- if (!this.#t)
1365
+ if (!this.#buffer) {
1017
1366
  throw new Error("Buffer is missing!");
1018
- return new ImageData(this.#t, this.#s, this.#l);
1367
+ }
1368
+ return new ImageData(this.#buffer, this.#cachedWidth, this.#cachedHeight);
1019
1369
  }
1020
1370
  /**
1021
1371
  * Extract image data using 2D canvas
1022
1372
  */
1023
- #m(e, t) {
1024
- if (!this.#o)
1373
+ #getImageData2d(source, area) {
1374
+ if (!this.#context2d)
1025
1375
  throw new Error("CanvasRenderingContext2D is missing!");
1026
- const a = "videoWidth" in e ? e.videoWidth : e.width, n = "videoHeight" in e ? e.videoHeight : e.height, o = t?.x ?? 0, i = t?.y ?? 0, l = t?.width ?? a, c = t?.height ?? n;
1027
- return this.#c(l, c), this.#o.drawImage(e, o, i, l, c), this.#o.getImageData(0, 0, l, c);
1376
+ const fullWidth = "videoWidth" in source ? source.videoWidth : source.width;
1377
+ const fullHeight = "videoHeight" in source ? source.videoHeight : source.height;
1378
+ const x = area?.x ?? 0;
1379
+ const y = area?.y ?? 0;
1380
+ const w = area?.width ?? fullWidth;
1381
+ const h = area?.height ?? fullHeight;
1382
+ this.#updateCanvasSize(w, h);
1383
+ this.#context2d.drawImage(source, x, y, w, h);
1384
+ return this.#context2d.getImageData(0, 0, w, h);
1028
1385
  }
1029
1386
  /**
1030
1387
  * Extract image data using WebGL2
1031
1388
  */
1032
- #g(e, t) {
1033
- if (!this.#a || !this.#r || !this.#n)
1389
+ #getImageDataWebGl2(source, area) {
1390
+ if (!this.#contextWebGl2 || !this.#webGl2Texture || !this.#webGl2Framebuffer) {
1034
1391
  throw new Error("WebGL2 context or resources are missing!");
1035
- const a = "videoWidth" in e ? e.videoWidth : e.width, n = "videoHeight" in e ? e.videoHeight : e.height, o = t?.x ?? 0, i = t?.y ?? 0, l = t?.width ?? a, c = t?.height ?? n, f = l * c * 4;
1036
- if (this.#c(l, c), this.isBufferDetached())
1392
+ }
1393
+ const fullWidth = "videoWidth" in source ? source.videoWidth : source.width;
1394
+ const fullHeight = "videoHeight" in source ? source.videoHeight : source.height;
1395
+ const x = area?.x ?? 0;
1396
+ const y = area?.y ?? 0;
1397
+ const w = area?.width ?? fullWidth;
1398
+ const h = area?.height ?? fullHeight;
1399
+ const requiredSize = w * h * 4;
1400
+ this.#updateCanvasSize(w, h);
1401
+ if (this.isBufferDetached()) {
1037
1402
  throw new Error("Buffer is detached!");
1038
- (!this.#t || this.#t.length !== f) && (this.#t = new Uint8ClampedArray(f));
1039
- const g = this.#a;
1040
- g.bindTexture(g.TEXTURE_2D, this.#r), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, e), g.bindFramebuffer(g.FRAMEBUFFER, this.#n);
1403
+ }
1404
+ if (!this.#buffer || this.#buffer.length !== requiredSize) {
1405
+ this.#buffer = new Uint8ClampedArray(requiredSize);
1406
+ }
1407
+ const gl = this.#contextWebGl2;
1408
+ gl.bindTexture(gl.TEXTURE_2D, this.#webGl2Texture);
1409
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
1410
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this.#webGl2Framebuffer);
1041
1411
  try {
1042
- g.pixelStorei(g.PACK_ALIGNMENT, this.#u), g.readPixels(o, i, l, c, g.RGBA, g.UNSIGNED_BYTE, this.#t);
1043
- } catch (y) {
1044
- if (this.#u !== 1) {
1045
- this.#u = 1, g.pixelStorei(g.PACK_ALIGNMENT, 1);
1046
- const u = new Uint8ClampedArray(f);
1047
- return g.readPixels(0, 0, l, c, g.RGBA, g.UNSIGNED_BYTE, u), this.#t = u, new ImageData(u, l, c);
1412
+ gl.pixelStorei(gl.PACK_ALIGNMENT, this.#requiredPackAlignment);
1413
+ gl.readPixels(x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, this.#buffer);
1414
+ } catch (error) {
1415
+ if (this.#requiredPackAlignment !== 1) {
1416
+ this.#requiredPackAlignment = 1;
1417
+ gl.pixelStorei(gl.PACK_ALIGNMENT, 1);
1418
+ const newBuffer = new Uint8ClampedArray(requiredSize);
1419
+ gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, newBuffer);
1420
+ this.#buffer = newBuffer;
1421
+ return new ImageData(newBuffer, w, h);
1048
1422
  }
1049
- throw y;
1423
+ throw error;
1050
1424
  }
1051
- return new ImageData(this.#t, l, c);
1425
+ return new ImageData(this.#buffer, w, h);
1052
1426
  }
1053
1427
  /**
1054
1428
  * Update canvas dimensions if needed
1055
1429
  *
1056
1430
  * This canvas is the orientation-aware
1057
1431
  */
1058
- #c(e, t) {
1059
- if (this.#s !== e || this.#l !== t) {
1060
- this.#e.width = e, this.#e.height = t, this.#s = e, this.#l = t;
1061
- const a = e * t * 4;
1062
- this.#t = new Uint8ClampedArray(a);
1432
+ #updateCanvasSize(width, height) {
1433
+ if (this.#cachedWidth !== width || this.#cachedHeight !== height) {
1434
+ this.#canvas.width = width;
1435
+ this.#canvas.height = height;
1436
+ this.#cachedWidth = width;
1437
+ this.#cachedHeight = height;
1438
+ const requiredSize = width * height * 4;
1439
+ this.#buffer = new Uint8ClampedArray(requiredSize);
1063
1440
  }
1064
1441
  }
1065
1442
  /**
1066
1443
  * Clean up resources
1067
1444
  */
1068
1445
  dispose() {
1069
- this.#a && (this.#r && (this.#a.deleteTexture(this.#r), this.#r = null), this.#n && (this.#a.deleteFramebuffer(this.#n), this.#n = null)), this.#o = null, this.#a = null, this.#t = null;
1446
+ if (this.#contextWebGl2) {
1447
+ if (this.#webGl2Texture) {
1448
+ this.#contextWebGl2.deleteTexture(this.#webGl2Texture);
1449
+ this.#webGl2Texture = null;
1450
+ }
1451
+ if (this.#webGl2Framebuffer) {
1452
+ this.#contextWebGl2.deleteFramebuffer(this.#webGl2Framebuffer);
1453
+ this.#webGl2Framebuffer = null;
1454
+ }
1455
+ }
1456
+ this.#context2d = null;
1457
+ this.#contextWebGl2 = null;
1458
+ this.#buffer = null;
1070
1459
  }
1071
1460
  }
1072
- const $e = (r) => ArrayBuffer.isView(r) ? r.buffer : r, $t = {
1073
- mirrorFrontCameras: !0
1461
+ const getBuffer = (buffer) => {
1462
+ if (ArrayBuffer.isView(buffer)) {
1463
+ return buffer.buffer;
1464
+ } else {
1465
+ return buffer;
1466
+ }
1467
+ };
1468
+ const defaultCameraManagerOptions = {
1469
+ mirrorFrontCameras: true
1074
1470
  };
1075
- class Qr {
1076
- #e;
1077
- #o = "4k";
1078
- #a;
1079
- #r;
1080
- #n;
1081
- #t;
1082
- #s;
1471
+ class CameraManager {
1472
+ #resumeRequest;
1473
+ #resolution = "4k";
1474
+ #extractionArea;
1475
+ #videoFrameRequestId;
1476
+ #videoFrameProcessor;
1477
+ #mirrorFrontCameras;
1478
+ #eventListenerCleanup;
1083
1479
  /**
1084
1480
  * If true, the user has initiated an abort. This will prevent the
1085
1481
  * CameraManager from throwing errors when the user interrupts the process.
1086
1482
  */
1087
- #l = !1;
1483
+ #userInitiatedAbort = false;
1088
1484
  get userInitiatedAbort() {
1089
- return this.#l;
1485
+ return this.#userInitiatedAbort;
1090
1486
  }
1091
- set userInitiatedAbort(e) {
1092
- this.#l = e;
1487
+ set userInitiatedAbort(value) {
1488
+ this.#userInitiatedAbort = value;
1093
1489
  }
1094
1490
  /**
1095
1491
  * Sets the area of the video frame that will be extracted.
1096
1492
  * @param extractionArea The area of the video frame that will be extracted.
1097
1493
  */
1098
- setExtractionArea(e) {
1099
- this.#a = e;
1494
+ setExtractionArea(extractionArea) {
1495
+ this.#extractionArea = extractionArea;
1100
1496
  }
1101
1497
  /**
1102
1498
  * Callbacks that will be triggered on each frame when the playback state is
1103
1499
  * "capturing".
1104
1500
  */
1105
- #i = /* @__PURE__ */ new Set();
1106
- constructor(e = {}, t) {
1107
- const { mirrorFrontCameras: a } = {
1108
- ...$t,
1109
- ...e
1501
+ #frameCaptureCallbacks = /* @__PURE__ */ new Set();
1502
+ constructor(options = {}, videoFrameProcessorOptions) {
1503
+ const { mirrorFrontCameras } = {
1504
+ ...defaultCameraManagerOptions,
1505
+ ...options
1110
1506
  };
1111
- this.#n = new At(
1112
- t
1113
- ), this.#t = a;
1507
+ this.#videoFrameProcessor = new VideoFrameProcessor(
1508
+ videoFrameProcessorOptions
1509
+ );
1510
+ this.#mirrorFrontCameras = mirrorFrontCameras;
1114
1511
  }
1115
1512
  /**
1116
1513
  * Sets the resolution of the camera stream
1117
1514
  */
1118
- setResolution = async (e) => {
1119
- this.#o = e;
1120
- const t = this.getState().playbackState;
1121
- t !== "idle" && (this.#e = t, this.stopStream(), await this.startCameraStream());
1515
+ setResolution = async (resolution) => {
1516
+ this.#resolution = resolution;
1517
+ const playbackState = this.getState().playbackState;
1518
+ if (playbackState !== "idle") {
1519
+ this.#resumeRequest = playbackState;
1520
+ this.stopStream();
1521
+ await this.startCameraStream();
1522
+ }
1122
1523
  };
1123
1524
  get resolution() {
1124
- return this.#o;
1525
+ return this.#resolution;
1125
1526
  }
1126
1527
  /**
1127
1528
  * True if there is a video playing or capturing
1128
1529
  * TODO: see if we can simplify this, by observing the video playback state
1129
1530
  */
1130
1531
  get isActive() {
1131
- return d.getState().playbackState !== "idle";
1532
+ return cameraManagerStore.getState().playbackState !== "idle";
1132
1533
  }
1133
- setFacingFilter(e) {
1134
- d.setState({
1135
- facingFilter: e
1534
+ setFacingFilter(facingFilter) {
1535
+ cameraManagerStore.setState({
1536
+ facingFilter
1136
1537
  });
1137
1538
  }
1138
1539
  /**
@@ -1140,28 +1541,37 @@ class Qr {
1140
1541
  * If no facing mode is set, all cameras are returned.
1141
1542
  */
1142
1543
  async getCameraDevices() {
1143
- let e = d.getState().cameras;
1144
- const t = d.getState().facingFilter;
1145
- return e.length || await this.refreshCameraDevices(), e = d.getState().cameras, t ? e.filter(
1146
- (n) => t.includes(n.facingMode)
1147
- ) : e;
1544
+ let allCameras = cameraManagerStore.getState().cameras;
1545
+ const facingFilter = cameraManagerStore.getState().facingFilter;
1546
+ if (!allCameras.length) {
1547
+ await this.refreshCameraDevices();
1548
+ }
1549
+ allCameras = cameraManagerStore.getState().cameras;
1550
+ if (!facingFilter) {
1551
+ return allCameras;
1552
+ }
1553
+ const filteredCameras = allCameras.filter(
1554
+ (camera) => facingFilter.includes(camera.facingMode)
1555
+ );
1556
+ return filteredCameras;
1148
1557
  }
1149
1558
  /**
1150
1559
  * Single-time setup for a video element
1151
1560
  */
1152
- #u(e) {
1153
- if (!(e instanceof HTMLVideoElement))
1561
+ #initVideoElement(videoElement) {
1562
+ if (!(videoElement instanceof HTMLVideoElement)) {
1154
1563
  throw new Error(
1155
- `Expected an HTMLVideoElement, got ${typeof e}`,
1564
+ `Expected an HTMLVideoElement, got ${typeof videoElement}`,
1156
1565
  {
1157
- cause: e
1566
+ cause: videoElement
1158
1567
  }
1159
1568
  );
1160
- d.setState({
1161
- videoElement: e
1569
+ }
1570
+ cameraManagerStore.setState({
1571
+ videoElement
1162
1572
  });
1163
- const t = Rt(e, (i) => {
1164
- [
1573
+ const videoEventCleanup = rad(videoElement, (add) => {
1574
+ const events = [
1165
1575
  "abort"
1166
1576
  // "error",
1167
1577
  // "canplay",
@@ -1180,49 +1590,62 @@ class Qr {
1180
1590
  // "timeupdate",
1181
1591
  // "ratechange",
1182
1592
  // "durationchange",
1183
- ].forEach((c) => {
1184
- i(c, () => {
1185
- console.debug(`Video event: ${c}`);
1593
+ ];
1594
+ events.forEach((event) => {
1595
+ add(event, () => {
1596
+ console.debug(`Video event: ${event}`);
1186
1597
  });
1187
1598
  });
1188
1599
  });
1189
- new N((i) => {
1190
- i[0].connected || this.releaseVideoElement();
1191
- }).observe(e), e.setAttribute("playsInline", ""), e.setAttribute("muted", ""), e.controls = !1;
1192
- let n = "idle";
1193
- const o = Mt(
1600
+ const connectionObserver = new ConnectionObserver((entries) => {
1601
+ if (!entries[0].connected) {
1602
+ this.releaseVideoElement();
1603
+ }
1604
+ });
1605
+ connectionObserver.observe(videoElement);
1606
+ videoElement.setAttribute("playsInline", "");
1607
+ videoElement.setAttribute("muted", "");
1608
+ videoElement.controls = false;
1609
+ let previousPlaybackState = "idle";
1610
+ const cleanupVisibilityListener = radEventListener(
1194
1611
  document,
1195
1612
  "visibilitychange",
1196
1613
  async () => {
1197
- if (document.hidden) {
1198
- n = d.getState().playbackState, this.stopStream();
1614
+ const isHidden = document.hidden;
1615
+ if (isHidden) {
1616
+ previousPlaybackState = cameraManagerStore.getState().playbackState;
1617
+ this.stopStream();
1199
1618
  return;
1200
1619
  }
1201
- switch (n) {
1620
+ switch (previousPlaybackState) {
1202
1621
  case "playback":
1203
- await this.startCameraStream(), await this.startPlayback();
1622
+ await this.startCameraStream();
1623
+ await this.startPlayback();
1204
1624
  break;
1205
1625
  case "capturing":
1206
- await this.startCameraStream(), await this.startFrameCapture();
1626
+ await this.startCameraStream();
1627
+ await this.startFrameCapture();
1207
1628
  break;
1208
1629
  }
1209
1630
  }
1210
1631
  );
1211
- this.#s = () => {
1212
- o(), t();
1632
+ this.#eventListenerCleanup = () => {
1633
+ cleanupVisibilityListener();
1634
+ videoEventCleanup();
1213
1635
  };
1214
1636
  }
1215
1637
  /**
1216
1638
  * Initializes the CameraManager with a video element.
1217
1639
  */
1218
- initVideoElement(e) {
1640
+ initVideoElement(videoElement) {
1219
1641
  try {
1220
- this.#u(e);
1221
- } catch (t) {
1222
- if (this.userInitiatedAbort)
1642
+ this.#initVideoElement(videoElement);
1643
+ } catch (error) {
1644
+ if (this.userInitiatedAbort) {
1223
1645
  this.reset();
1224
- else
1225
- throw t;
1646
+ } else {
1647
+ throw error;
1648
+ }
1226
1649
  }
1227
1650
  }
1228
1651
  /**
@@ -1232,74 +1655,108 @@ class Qr {
1232
1655
  * @param frameCaptureCallback
1233
1656
  * @returns a cleanup function to remove the callback
1234
1657
  */
1235
- addFrameCaptureCallback(e) {
1236
- return this.#i.add(e), () => this.#i.delete(e);
1658
+ addFrameCaptureCallback(frameCaptureCallback) {
1659
+ this.#frameCaptureCallbacks.add(frameCaptureCallback);
1660
+ return () => this.#frameCaptureCallbacks.delete(frameCaptureCallback);
1237
1661
  }
1238
1662
  releaseVideoElement() {
1239
- this.#s?.(), d.setState({
1663
+ this.#eventListenerCleanup?.();
1664
+ cameraManagerStore.setState({
1240
1665
  videoElement: void 0
1241
- }), this.stopStream();
1666
+ });
1667
+ this.stopStream();
1242
1668
  }
1243
1669
  /**
1244
1670
  * Select a camera device from available ones.
1245
1671
  *
1246
1672
  * TODO: might become a private method in the future as an implementation detail of `startStream`
1247
1673
  */
1248
- async selectCamera(e) {
1249
- const t = d.getState().playbackState;
1250
- t !== "idle" && (this.#e = t);
1251
- const a = d.getState();
1252
- if (a.selectedCamera === e) {
1674
+ async selectCamera(camera) {
1675
+ const playbackState = cameraManagerStore.getState().playbackState;
1676
+ if (playbackState !== "idle") {
1677
+ this.#resumeRequest = playbackState;
1678
+ }
1679
+ const state = cameraManagerStore.getState();
1680
+ if (state.selectedCamera === camera) {
1253
1681
  console.debug("Already selected");
1254
1682
  return;
1255
1683
  }
1256
- if (a.isSwappingCamera) {
1684
+ if (state.isSwappingCamera) {
1257
1685
  console.debug("Already swapping");
1258
1686
  return;
1259
1687
  }
1260
- d.setState({
1261
- isSwappingCamera: !0
1262
- }), a.selectedCamera?.activeStream && (console.debug("Stopping previous stream"), a.selectedCamera.stopStream()), a.videoElement && (a.videoElement.srcObject = null), d.setState({
1263
- selectedCamera: e,
1264
- isSwappingCamera: !1
1265
- }), this.#e === "playback" && (console.debug("Starting new stream"), await this.startPlayback()), this.#e === "capturing" && (console.debug("Resuming frame capture"), await this.startFrameCapture()), this.#e = void 0;
1688
+ cameraManagerStore.setState({
1689
+ isSwappingCamera: true
1690
+ });
1691
+ if (state.selectedCamera?.activeStream) {
1692
+ console.debug("Stopping previous stream");
1693
+ state.selectedCamera.stopStream();
1694
+ }
1695
+ if (state.videoElement) {
1696
+ state.videoElement.srcObject = null;
1697
+ }
1698
+ cameraManagerStore.setState({
1699
+ selectedCamera: camera,
1700
+ isSwappingCamera: false
1701
+ });
1702
+ if (this.#resumeRequest === "playback") {
1703
+ console.debug("Starting new stream");
1704
+ await this.startPlayback();
1705
+ }
1706
+ if (this.#resumeRequest === "capturing") {
1707
+ console.debug("Resuming frame capture");
1708
+ await this.startFrameCapture();
1709
+ }
1710
+ this.#resumeRequest = void 0;
1266
1711
  }
1267
1712
  /**
1268
1713
  * Refreshes available devices on the system and updates the state.
1269
1714
  */
1270
1715
  async refreshCameraDevices() {
1271
- if (d.getState().isQueryingCameras || d.getState().isSwappingCamera) {
1716
+ if (cameraManagerStore.getState().isQueryingCameras || cameraManagerStore.getState().isSwappingCamera) {
1272
1717
  console.debug("Already querying cameras");
1273
1718
  return;
1274
1719
  }
1275
- d.setState({
1276
- isQueryingCameras: !0
1720
+ cameraManagerStore.setState({
1721
+ isQueryingCameras: true
1277
1722
  });
1278
- const e = await ct().catch((a) => {
1279
- throw d.setState({
1280
- errorState: X(a),
1281
- isQueryingCameras: !1
1282
- }), a;
1283
- }), t = ht(e);
1284
- t.forEach((a) => {
1285
- a.notifyStateChange || (a.notifyStateChange = (n, o) => {
1723
+ const availableCameras = await obtainVideoInputDevices().catch((err) => {
1724
+ cameraManagerStore.setState({
1725
+ errorState: asError(err),
1726
+ isQueryingCameras: false
1727
+ });
1728
+ throw err;
1729
+ });
1730
+ const cameras = createCameras(availableCameras);
1731
+ cameras.forEach((camera) => {
1732
+ if (camera.notifyStateChange) {
1733
+ return;
1734
+ }
1735
+ camera.notifyStateChange = (camInstance, reason) => {
1286
1736
  window.queueMicrotask(() => {
1287
- d.setState({
1288
- cameras: [...d.getState().cameras]
1737
+ cameraManagerStore.setState({
1738
+ cameras: [...cameraManagerStore.getState().cameras]
1289
1739
  });
1290
- const i = d.getState().selectedCamera;
1291
- if (!i)
1740
+ const selectedCamera = cameraManagerStore.getState().selectedCamera;
1741
+ if (!selectedCamera) {
1292
1742
  return;
1293
- let l;
1294
- typeof o == "object" && o !== null && "payload" in o && o.payload === "TRACK_END" && (l = new Error("Camera stream ended unexpectedly")), n === i && d.setState({
1295
- selectedCamera: i,
1296
- errorState: l
1297
- });
1743
+ }
1744
+ let streamError;
1745
+ if (typeof reason === "object" && reason !== null && "payload" in reason && reason.payload === "TRACK_END") {
1746
+ streamError = new Error("Camera stream ended unexpectedly");
1747
+ }
1748
+ if (camInstance === selectedCamera) {
1749
+ cameraManagerStore.setState({
1750
+ selectedCamera,
1751
+ errorState: streamError
1752
+ });
1753
+ }
1298
1754
  });
1299
- });
1300
- }), d.setState({
1301
- cameras: t,
1302
- isQueryingCameras: !1
1755
+ };
1756
+ });
1757
+ cameraManagerStore.setState({
1758
+ cameras,
1759
+ isQueryingCameras: false
1303
1760
  });
1304
1761
  }
1305
1762
  /**
@@ -1308,140 +1765,181 @@ class Qr {
1308
1765
  * @returns resolves when playback starts
1309
1766
  */
1310
1767
  async startPlayback() {
1311
- const e = d.getState();
1312
- if (!(this.isActive && !this.#e)) {
1313
- if (!e.videoElement) {
1314
- console.warn("Starting playback - no video element present.");
1315
- return;
1316
- }
1317
- if (!e.selectedCamera) {
1318
- console.warn("Select a camera first.");
1319
- return;
1320
- }
1321
- if (!e.selectedCamera.activeStream) {
1322
- const t = await e.selectedCamera.startStream(this.resolution);
1323
- e.videoElement.srcObject = t;
1324
- }
1325
- try {
1326
- this.#f(), await e.videoElement.play(), d.setState({
1327
- playbackState: "playback"
1328
- });
1329
- } catch (t) {
1330
- throw console.error("Failed to start playback", t), d.setState({
1331
- errorState: X(t)
1332
- }), t;
1333
- }
1768
+ const state = cameraManagerStore.getState();
1769
+ if (this.isActive && !this.#resumeRequest) {
1770
+ return;
1771
+ }
1772
+ if (!state.videoElement) {
1773
+ console.warn("Starting playback - no video element present.");
1774
+ return;
1775
+ }
1776
+ if (!state.selectedCamera) {
1777
+ console.warn("Select a camera first.");
1778
+ return;
1779
+ }
1780
+ if (!state.selectedCamera.activeStream) {
1781
+ const stream = await state.selectedCamera.startStream(this.resolution);
1782
+ state.videoElement.srcObject = stream;
1783
+ }
1784
+ try {
1785
+ this.#applyMirrorIfNeeded();
1786
+ await state.videoElement.play();
1787
+ cameraManagerStore.setState({
1788
+ playbackState: "playback"
1789
+ });
1790
+ } catch (error) {
1791
+ console.error("Failed to start playback", error);
1792
+ cameraManagerStore.setState({
1793
+ errorState: asError(error)
1794
+ });
1795
+ throw error;
1334
1796
  }
1335
1797
  }
1336
1798
  /**
1337
1799
  * Starts playback and frame capturing.
1338
1800
  */
1339
- async #d() {
1340
- const e = d.getState();
1341
- if (!this.userInitiatedAbort && !(e.playbackState === "capturing" && this.#e !== "capturing")) {
1342
- if (!e.videoElement) {
1343
- console.warn(
1344
- "Missing video element. Setup a video element first using `initVideoElement`"
1345
- );
1346
- return;
1347
- }
1348
- if (!e.selectedCamera) {
1349
- console.warn(
1350
- "No active camera! Select a camera first, or use `startCameraStream`"
1351
- );
1352
- return;
1353
- }
1354
- await this.startPlayback(), d.setState({
1355
- playbackState: "capturing"
1356
- }), this.#c(), this.#e = void 0;
1801
+ async #startFrameCapture() {
1802
+ const state = cameraManagerStore.getState();
1803
+ if (this.userInitiatedAbort) {
1804
+ return;
1357
1805
  }
1806
+ if (state.playbackState === "capturing" && this.#resumeRequest !== "capturing") {
1807
+ return;
1808
+ }
1809
+ if (!state.videoElement) {
1810
+ console.warn(
1811
+ "Missing video element. Setup a video element first using `initVideoElement`"
1812
+ );
1813
+ return;
1814
+ }
1815
+ if (!state.selectedCamera) {
1816
+ console.warn(
1817
+ "No active camera! Select a camera first, or use `startCameraStream`"
1818
+ );
1819
+ return;
1820
+ }
1821
+ await this.startPlayback();
1822
+ cameraManagerStore.setState({
1823
+ playbackState: "capturing"
1824
+ });
1825
+ this.#queueFrame();
1826
+ this.#resumeRequest = void 0;
1358
1827
  }
1359
1828
  /**
1360
1829
  * Starts capturing frames from the video element.
1361
1830
  */
1362
1831
  startFrameCapture = async () => {
1363
1832
  try {
1364
- await this.#d();
1365
- } catch (e) {
1366
- if (this.userInitiatedAbort)
1833
+ await this.#startFrameCapture();
1834
+ } catch (error) {
1835
+ if (this.userInitiatedAbort) {
1367
1836
  this.reset();
1368
- else
1369
- throw e;
1837
+ } else {
1838
+ throw error;
1839
+ }
1370
1840
  }
1371
1841
  };
1372
- async #h({
1373
- autoplay: e = !0,
1374
- preferredCamera: t,
1375
- preferredFacing: a
1842
+ async #startCameraStream({
1843
+ autoplay = true,
1844
+ preferredCamera,
1845
+ preferredFacing
1376
1846
  } = {}) {
1377
- const n = d.getState().videoElement;
1378
- if (!n) {
1847
+ const videoElement = cameraManagerStore.getState().videoElement;
1848
+ if (!videoElement) {
1379
1849
  console.warn("Can't start stream without a video element");
1380
1850
  return;
1381
1851
  }
1382
- if (this.isActive && !this.#e) {
1852
+ if (this.isActive && !this.#resumeRequest) {
1383
1853
  console.warn("Already streaming");
1384
1854
  return;
1385
1855
  }
1386
- if (t instanceof Me && await this.selectCamera(t), !d.getState().selectedCamera)
1856
+ if (preferredCamera instanceof Camera) {
1857
+ await this.selectCamera(preferredCamera);
1858
+ }
1859
+ if (!cameraManagerStore.getState().selectedCamera) {
1387
1860
  try {
1388
- const l = await this.getCameraDevices();
1389
- let c;
1390
- if (!l.length)
1391
- throw console.log("Camera list is empty"), new Error(
1392
- `No cameras found matching the filter ${a}`
1861
+ const cameras = await this.getCameraDevices();
1862
+ let selectedCamera2;
1863
+ if (!cameras.length) {
1864
+ console.log("Camera list is empty");
1865
+ throw new Error(
1866
+ `No cameras found matching the filter ${preferredFacing}`
1393
1867
  );
1394
- if (typeof t == "function" && (c = t(l), c || console.warn(
1395
- "No camera found matching the preferred camera function, falling back to facing mode"
1396
- )), c || (c = await dt(
1397
- l,
1398
- this.resolution,
1399
- a
1400
- )), !c)
1868
+ }
1869
+ if (typeof preferredCamera === "function") {
1870
+ selectedCamera2 = preferredCamera(cameras);
1871
+ if (!selectedCamera2) {
1872
+ console.warn(
1873
+ `No camera found matching the preferred camera function, falling back to facing mode`
1874
+ );
1875
+ }
1876
+ }
1877
+ if (!selectedCamera2) {
1878
+ selectedCamera2 = await findIdealCamera(
1879
+ cameras,
1880
+ this.resolution,
1881
+ preferredFacing
1882
+ );
1883
+ }
1884
+ if (!selectedCamera2) {
1401
1885
  throw new Error(
1402
- `No cameras found matching the filter ${a}`
1886
+ `No cameras found matching the filter ${preferredFacing}`
1403
1887
  );
1404
- await this.selectCamera(c), this.#m() && d.setState({
1405
- errorState: void 0
1888
+ }
1889
+ await this.selectCamera(selectedCamera2);
1890
+ if (this.#hasPermissionError()) {
1891
+ cameraManagerStore.setState({
1892
+ errorState: void 0
1893
+ });
1894
+ }
1895
+ } catch (error) {
1896
+ cameraManagerStore.setState({
1897
+ errorState: asError(error)
1406
1898
  });
1407
- } catch (l) {
1408
- throw d.setState({
1409
- errorState: X(l)
1410
- }), l;
1899
+ throw error;
1411
1900
  }
1412
- const o = d.getState().selectedCamera;
1413
- if (!o)
1414
- throw console.warn("No selected camera!"), new Error("No selected camera");
1415
- const i = await o.startStream(this.#o);
1416
- if (!n.isConnected)
1901
+ }
1902
+ const selectedCamera = cameraManagerStore.getState().selectedCamera;
1903
+ if (!selectedCamera) {
1904
+ console.warn("No selected camera!");
1905
+ throw new Error("No selected camera");
1906
+ }
1907
+ const stream = await selectedCamera.startStream(this.#resolution);
1908
+ if (!videoElement.isConnected) {
1417
1909
  throw new Error("Video element needs to be in the document!");
1418
- n.srcObject = i, d.setState({
1419
- videoElement: n
1420
- }), e && await this.startPlayback();
1910
+ }
1911
+ videoElement.srcObject = stream;
1912
+ cameraManagerStore.setState({
1913
+ videoElement
1914
+ });
1915
+ if (autoplay) {
1916
+ await this.startPlayback();
1917
+ }
1421
1918
  }
1422
1919
  /**
1423
1920
  * Starts a best-effort camera stream. Will pick a camera automatically if
1424
1921
  * none is selected.
1425
1922
  */
1426
- async startCameraStream(e = {}) {
1923
+ async startCameraStream(params = {}) {
1427
1924
  try {
1428
- await this.#h(e);
1429
- } catch (t) {
1430
- if (this.userInitiatedAbort)
1925
+ await this.#startCameraStream(params);
1926
+ } catch (error) {
1927
+ if (this.userInitiatedAbort) {
1431
1928
  this.reset();
1432
- else
1433
- throw t;
1929
+ } else {
1930
+ throw error;
1931
+ }
1434
1932
  }
1435
1933
  }
1436
- #m = () => {
1437
- const e = d.getState().errorState;
1438
- return e instanceof Te && e.code === "PERMISSION_DENIED";
1934
+ #hasPermissionError = () => {
1935
+ const errorState = cameraManagerStore.getState().errorState;
1936
+ return errorState instanceof CameraError && errorState.code === "PERMISSION_DENIED";
1439
1937
  };
1440
1938
  /**
1441
1939
  * Pauses capturing frames without pausing playback.
1442
1940
  */
1443
1941
  stopFrameCapture() {
1444
- d.setState({
1942
+ cameraManagerStore.setState({
1445
1943
  playbackState: "playback"
1446
1944
  });
1447
1945
  }
@@ -1450,92 +1948,128 @@ class Qr {
1450
1948
  */
1451
1949
  stopStream() {
1452
1950
  console.debug("stopStream called");
1453
- const e = d.getState();
1454
- this.pausePlayback(), e.selectedCamera?.stopStream(), e.videoElement && (e.videoElement.srcObject = null);
1951
+ const state = cameraManagerStore.getState();
1952
+ this.pausePlayback();
1953
+ state.selectedCamera?.stopStream();
1954
+ if (state.videoElement) {
1955
+ state.videoElement.srcObject = null;
1956
+ }
1455
1957
  }
1456
1958
  /**
1457
1959
  * Pauses the video playback. This will also stop the capturing process.
1458
1960
  */
1459
1961
  pausePlayback() {
1460
1962
  console.debug("pausePlayback called");
1461
- const e = d.getState().videoElement;
1462
- d.setState({
1963
+ const video = cameraManagerStore.getState().videoElement;
1964
+ cameraManagerStore.setState({
1463
1965
  playbackState: "idle"
1464
- }), e && (this.#r && e.cancelVideoFrameCallback(this.#r), e.pause());
1966
+ });
1967
+ if (!video) {
1968
+ return;
1969
+ }
1970
+ if (this.#videoFrameRequestId) {
1971
+ video.cancelVideoFrameCallback(this.#videoFrameRequestId);
1972
+ }
1973
+ video.pause();
1465
1974
  }
1466
1975
  /**
1467
1976
  * The main recognition loop. Do not call this method directly, use #queueFrame instead.
1468
1977
  */
1469
- async #g() {
1470
- const e = d.getState();
1471
- if (this.#r === void 0) {
1978
+ async #loop() {
1979
+ const state = cameraManagerStore.getState();
1980
+ if (this.#videoFrameRequestId === void 0) {
1472
1981
  console.error("Missing request ID");
1473
1982
  return;
1474
1983
  }
1475
- if (!e.videoElement) {
1984
+ if (!state.videoElement) {
1476
1985
  console.warn("Missing video element, should not happen");
1477
1986
  return;
1478
1987
  }
1479
- if (!(e.videoElement.videoHeight >= e.videoElement.videoWidth == this.#a.height >= this.#a.width))
1480
- return this.#c();
1481
- if (this.#i.size !== 0) {
1482
- const a = this.#n.getImageData(
1483
- e.videoElement,
1484
- this.#a
1988
+ const isSameOrientation = state.videoElement.videoHeight >= state.videoElement.videoWidth === this.#extractionArea.height >= this.#extractionArea.width;
1989
+ if (!isSameOrientation) {
1990
+ return this.#queueFrame();
1991
+ }
1992
+ if (this.#frameCaptureCallbacks.size !== 0) {
1993
+ const capturedFrame = this.#videoFrameProcessor.getImageData(
1994
+ state.videoElement,
1995
+ this.#extractionArea
1485
1996
  );
1486
- for (const n of this.#i) {
1487
- const o = ne(a.data) ? this.#n.getCurrentImageData() : a, i = await n(o);
1488
- if (i) {
1489
- if (!(i instanceof ArrayBuffer))
1490
- throw new Error(
1491
- _e`
1997
+ for (const callback of this.#frameCaptureCallbacks) {
1998
+ const workingFrame = isBufferDetached(capturedFrame.data) ? this.#videoFrameProcessor.getCurrentImageData() : capturedFrame;
1999
+ const returnedBuffer = await callback(workingFrame);
2000
+ if (!returnedBuffer) {
2001
+ continue;
2002
+ }
2003
+ if (!(returnedBuffer instanceof ArrayBuffer)) {
2004
+ throw new Error(
2005
+ stripIndents`
1492
2006
  Frame capture callback did not return an ArrayBuffer.
1493
2007
  Make sure to return the underlying buffer, not the view.
1494
2008
  `
1495
- );
1496
- this.#n.reattachArrayBuffer(i);
2009
+ );
1497
2010
  }
2011
+ this.#videoFrameProcessor.reattachArrayBuffer(returnedBuffer);
1498
2012
  }
1499
2013
  }
1500
- this.#c();
2014
+ this.#queueFrame();
1501
2015
  }
1502
2016
  /**
1503
2017
  * Queues the next frame to be processed
1504
2018
  */
1505
- #c() {
1506
- const e = d.getState();
1507
- if (e.playbackState === "capturing") {
1508
- if (!e.videoElement) {
1509
- console.warn("Missing video element, should not happen");
1510
- return;
1511
- }
1512
- this.#r && e.videoElement.cancelVideoFrameCallback(this.#r), this.#r = e.videoElement.requestVideoFrameCallback(
1513
- () => void this.#g()
1514
- );
2019
+ #queueFrame() {
2020
+ const state = cameraManagerStore.getState();
2021
+ if (state.playbackState !== "capturing") {
2022
+ return;
2023
+ }
2024
+ if (!state.videoElement) {
2025
+ console.warn("Missing video element, should not happen");
2026
+ return;
1515
2027
  }
2028
+ if (this.#videoFrameRequestId) {
2029
+ state.videoElement.cancelVideoFrameCallback(this.#videoFrameRequestId);
2030
+ }
2031
+ this.#videoFrameRequestId = state.videoElement.requestVideoFrameCallback(
2032
+ () => void this.#loop()
2033
+ );
1516
2034
  }
1517
2035
  /**
1518
2036
  * Applies a mirror effect to the video if the camera is front-facing.
1519
2037
  * Assumes that desktop devices don't return a facing mode and that they are front-facing.
1520
2038
  */
1521
- #f() {
1522
- const e = d.getState().selectedCamera;
1523
- if (!e) {
2039
+ #applyMirrorIfNeeded() {
2040
+ const camera = cameraManagerStore.getState().selectedCamera;
2041
+ if (!camera) {
1524
2042
  console.warn("No camera selected");
1525
2043
  return;
1526
2044
  }
1527
- this.#t && (e.facingMode !== "back" ? this.setCameraMirrorX(!0) : this.setCameraMirrorX(!1));
2045
+ if (!this.#mirrorFrontCameras) {
2046
+ return;
2047
+ }
2048
+ if (camera.facingMode !== "back") {
2049
+ this.setCameraMirrorX(true);
2050
+ } else {
2051
+ this.setCameraMirrorX(false);
2052
+ }
1528
2053
  }
1529
2054
  /**
1530
2055
  * If true, the video and captured frames will be mirrored horizontally.
1531
2056
  */
1532
- setCameraMirrorX(e) {
1533
- const t = d.getState(), a = t.videoElement;
1534
- if (!a) {
2057
+ setCameraMirrorX(mirrorX) {
2058
+ const currentState = cameraManagerStore.getState();
2059
+ const videoElement = currentState.videoElement;
2060
+ if (!videoElement) {
1535
2061
  console.warn("Mirror video - no video element present.");
1536
2062
  return;
1537
2063
  }
1538
- t.mirrorX !== e && (e ? a.style.scale = "-1 1" : a.style.removeProperty("scale"), d.setState({ mirrorX: e }));
2064
+ if (currentState.mirrorX === mirrorX) {
2065
+ return;
2066
+ }
2067
+ if (mirrorX) {
2068
+ videoElement.style.scale = "-1 1";
2069
+ } else {
2070
+ videoElement.style.removeProperty("scale");
2071
+ }
2072
+ cameraManagerStore.setState({ mirrorX });
1539
2073
  }
1540
2074
  // The "typeof" is necessary to avoid a circular dependency when resolving types
1541
2075
  /**
@@ -1543,54 +2077,64 @@ class Qr {
1543
2077
  * Implemented using Zustand. For usage information, see
1544
2078
  * {@link https://github.com/pmndrs/zustand#using-subscribe-with-selector}
1545
2079
  */
1546
- subscribe = d.subscribe;
2080
+ subscribe = cameraManagerStore.subscribe;
1547
2081
  /**
1548
2082
  * Gets the current internal state of the CameraManager.
1549
2083
  */
1550
- getState = d.getState;
2084
+ getState = cameraManagerStore.getState;
1551
2085
  /**
1552
2086
  * Resets the CameraManager and stop all streams
1553
2087
  */
1554
2088
  reset() {
1555
- console.debug("Resetting camera manager"), this.#i.clear(), this.stopStream(), Ye();
2089
+ console.debug("Resetting camera manager");
2090
+ this.#frameCaptureCallbacks.clear();
2091
+ this.stopStream();
2092
+ resetCameraManagerStore();
1556
2093
  }
1557
2094
  }
1558
- const Fe = be();
1559
- function Ft() {
1560
- return we(d);
2095
+ const CameraUiStoreContext = createContext();
2096
+ function createCameraManagerSolidStore() {
2097
+ return createWithSignal(cameraManagerStore);
1561
2098
  }
1562
- const Dt = (r) => {
1563
- const e = {
1564
- cameraManagerSolidStore: Ft(),
2099
+ const CameraUiStoreProvider = (props) => {
2100
+ const contextValue = {
2101
+ cameraManagerSolidStore: createCameraManagerSolidStore(),
1565
2102
  // eslint-disable-next-line solid/reactivity
1566
- cameraManager: r.cameraManager,
2103
+ cameraManager: props.cameraManager,
1567
2104
  // eslint-disable-next-line solid/reactivity
1568
2105
  dismountCameraUi: () => {
1569
- r.cameraManager.userInitiatedAbort = !0, r.dismountCameraUi();
2106
+ props.cameraManager.userInitiatedAbort = true;
2107
+ props.dismountCameraUi();
1570
2108
  },
1571
2109
  // eslint-disable-next-line solid/reactivity
1572
- addOnDismountCallback: r.addOnDismountCallback,
2110
+ addOnDismountCallback: props.addOnDismountCallback,
2111
+ // eslint-disable-next-line solid/reactivity
2112
+ mountTarget: props.mountTarget,
1573
2113
  // eslint-disable-next-line solid/reactivity
1574
- mountTarget: r.mountTarget,
2114
+ showMirrorCameraButton: props.showMirrorCameraButton,
1575
2115
  // eslint-disable-next-line solid/reactivity
1576
- showMirrorCameraButton: r.showMirrorCameraButton
2116
+ showTorchButton: props.showTorchButton,
2117
+ // eslint-disable-next-line solid/reactivity
2118
+ showCloseButton: props.showCloseButton
1577
2119
  };
1578
- return ie(() => {
2120
+ onCleanup(() => {
1579
2121
  console.debug("CameraUiStoreProvider cleanup");
1580
- }), s(Fe.Provider, {
1581
- value: e,
2122
+ });
2123
+ return createComponent(CameraUiStoreContext.Provider, {
2124
+ value: contextValue,
1582
2125
  get children() {
1583
- return r.children;
2126
+ return props.children;
1584
2127
  }
1585
2128
  });
1586
2129
  };
1587
- function q() {
1588
- const r = pe(Fe);
1589
- if (!r)
2130
+ function useCameraUiStore() {
2131
+ const ctx = useContext(CameraUiStoreContext);
2132
+ if (!ctx) {
1590
2133
  throw new Error("StoreContext.Provider not in scope");
1591
- return r;
2134
+ }
2135
+ return ctx;
1592
2136
  }
1593
- const It = {
2137
+ const enLocaleStrings = {
1594
2138
  selected_camera: "Selected camera",
1595
2139
  loading_cameras: "Loading cameras...",
1596
2140
  select_a_camera: "Select a camera",
@@ -1603,229 +2147,277 @@ const It = {
1603
2147
  camera_error_details: "Please allow camera access in your browser and try again.",
1604
2148
  camera_error_cancel_btn: "Cancel",
1605
2149
  camera_error_primary_btn: "Retry"
1606
- }, De = be(), zt = (r) => {
1607
- const [e, t] = Xe(
2150
+ };
2151
+ const LocalizationContext = createContext();
2152
+ const LocalizationProvider = (props) => {
2153
+ const [localizationStore, updateLocalizationStore] = createStore$1(
1608
2154
  // we structure clone to avoid proxying to the original object
1609
2155
  structuredClone({
1610
- ...It,
2156
+ ...enLocaleStrings,
1611
2157
  // we don't care on init
1612
2158
  // eslint-disable-next-line solid/reactivity
1613
- ...r.userStrings
2159
+ ...props.userStrings
1614
2160
  })
1615
2161
  );
1616
- Q(() => {
1617
- r.setLocalizationRef(t);
2162
+ onMount(() => {
2163
+ props.setLocalizationRef(updateLocalizationStore);
1618
2164
  });
1619
- const a = {
1620
- t: e,
1621
- updateLocalization: t
2165
+ const contextValue = {
2166
+ t: localizationStore,
2167
+ updateLocalization: updateLocalizationStore
1622
2168
  };
1623
- return s(De.Provider, {
1624
- value: a,
2169
+ return createComponent(LocalizationContext.Provider, {
2170
+ value: contextValue,
1625
2171
  get children() {
1626
- return r.children;
2172
+ return props.children;
1627
2173
  }
1628
2174
  });
1629
2175
  };
1630
- function Y() {
1631
- const r = pe(De);
1632
- if (!r)
2176
+ function useLocalization() {
2177
+ const ctx = useContext(LocalizationContext);
2178
+ if (!ctx) {
1633
2179
  throw new Error("LocalizationContext.Provider not in scope.");
1634
- return r;
2180
+ }
2181
+ return ctx;
1635
2182
  }
1636
- var Lt = /* @__PURE__ */ S("<span>");
1637
- const J = (r) => {
1638
- const [e, t] = z(), [a, n] = z();
1639
- return Q(() => {
1640
- const o = a();
1641
- o && t(o.getRootNode());
1642
- }), s(E, {
2183
+ var _tmpl$$c = /* @__PURE__ */ template(`<span>`);
2184
+ const SmartEnvironmentProvider = (props) => {
2185
+ const [rootNode, setRootNode] = createSignal();
2186
+ const [ref, setRef] = createSignal();
2187
+ onMount(() => {
2188
+ const spanRef = ref();
2189
+ if (!spanRef) {
2190
+ return;
2191
+ }
2192
+ setRootNode(spanRef.getRootNode());
2193
+ });
2194
+ return createComponent(Show, {
1643
2195
  get when() {
1644
- return e();
2196
+ return rootNode();
1645
2197
  },
1646
2198
  get fallback() {
1647
2199
  return (() => {
1648
- var o = Lt();
1649
- return O(n, o), o;
2200
+ var _el$ = _tmpl$$c();
2201
+ use(setRef, _el$);
2202
+ return _el$;
1650
2203
  })();
1651
2204
  },
1652
- children: (o) => s(Ke, {
1653
- value: () => o(),
2205
+ children: (rootNode2) => createComponent(EnvironmentProvider, {
2206
+ value: () => rootNode2(),
1654
2207
  get children() {
1655
- return r.children(o());
2208
+ return props.children(rootNode2());
1656
2209
  }
1657
2210
  })
1658
2211
  });
1659
2212
  };
1660
- var Nt = /* @__PURE__ */ S('<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M6.4 19L5 17.6l5.6-5.6L5 6.4L6.4 5l5.6 5.6L17.6 5L19 6.4L13.4 12l5.6 5.6l-1.4 1.4l-5.6-5.6z">');
1661
- const Ot = (r = {}) => (() => {
1662
- var e = Nt();
1663
- return D(e, r, !0, !0), e;
2213
+ var _tmpl$$b = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M6.4 19L5 17.6l5.6-5.6L5 6.4L6.4 5l5.6 5.6L17.6 5L19 6.4L13.4 12l5.6 5.6l-1.4 1.4l-5.6-5.6z">`);
2214
+ const CloseIcon = (props = {}) => (() => {
2215
+ var _el$ = _tmpl$$b();
2216
+ spread(_el$, props, true, true);
2217
+ return _el$;
1664
2218
  })();
1665
- var Pt = /* @__PURE__ */ S('<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M7 2h10l-2 7h4l-2.925 4.225L7 4.15zm3 20v-8H7V9.85L1.375 4.225L2.8 2.8l18.4 18.4l-1.425 1.425L13.75 16.6z">');
1666
- const Bt = (r = {}) => (() => {
1667
- var e = Pt();
1668
- return D(e, r, !0, !0), e;
2219
+ var _tmpl$$a = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M7 2h10l-2 7h4l-2.925 4.225L7 4.15zm3 20v-8H7V9.85L1.375 4.225L2.8 2.8l18.4 18.4l-1.425 1.425L13.75 16.6z">`);
2220
+ const FlashOff = (props = {}) => (() => {
2221
+ var _el$ = _tmpl$$a();
2222
+ spread(_el$, props, true, true);
2223
+ return _el$;
1669
2224
  })();
1670
- var Vt = /* @__PURE__ */ S('<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M10 22v-8H7V2h10l-2 7h4z">');
1671
- const Ut = (r = {}) => (() => {
1672
- var e = Vt();
1673
- return D(e, r, !0, !0), e;
2225
+ var _tmpl$$9 = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M10 22v-8H7V2h10l-2 7h4z">`);
2226
+ const FlashOn = (props = {}) => (() => {
2227
+ var _el$ = _tmpl$$9();
2228
+ spread(_el$, props, true, true);
2229
+ return _el$;
1674
2230
  })();
1675
- var jt = /* @__PURE__ */ S('<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M9 21H5q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h4v2H5v14h4zm2 2V1h2v22zm4-2v-2h2v2zm0-16V3h2v2zm4 16v-2h2q0 .825-.587 1.413T19 21m0-4v-2h2v2zm0-4v-2h2v2zm0-4V7h2v2zm0-4V3q.825 0 1.413.588T21 5z">');
1676
- const qt = (r = {}) => (() => {
1677
- var e = jt();
1678
- return D(e, r, !0, !0), e;
2231
+ var _tmpl$$8 = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M9 21H5q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h4v2H5v14h4zm2 2V1h2v22zm4-2v-2h2v2zm0-16V3h2v2zm4 16v-2h2q0 .825-.587 1.413T19 21m0-4v-2h2v2zm0-4v-2h2v2zm0-4V7h2v2zm0-4V3q.825 0 1.413.588T21 5z">`);
2232
+ const MirrorIcon = (props = {}) => (() => {
2233
+ var _el$ = _tmpl$$8();
2234
+ spread(_el$, props, true, true);
2235
+ return _el$;
1679
2236
  })();
1680
- function Ie(r) {
1681
- const e = {};
1682
- return Object.entries(r).forEach(([t, a]) => {
1683
- const n = t.toLowerCase();
1684
- let o = n;
1685
- if (n.startsWith("on")) {
1686
- o = n.slice(2);
1687
- const i = `on:${o}`;
1688
- e[i] = a;
1689
- } else
1690
- e[o] = a;
1691
- }), e;
2237
+ function eventFixer(props) {
2238
+ const newObj = {};
2239
+ Object.entries(props).forEach(([key, value]) => {
2240
+ const lowerCaseKey = key.toLowerCase();
2241
+ let trimmedKey = lowerCaseKey;
2242
+ if (lowerCaseKey.startsWith("on")) {
2243
+ trimmedKey = lowerCaseKey.slice(2);
2244
+ const newKey = `on:${trimmedKey}`;
2245
+ newObj[newKey] = value;
2246
+ } else {
2247
+ newObj[trimmedKey] = value;
2248
+ }
2249
+ });
2250
+ return newObj;
1692
2251
  }
1693
- var Ht = /* @__PURE__ */ S('<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><g fill=#fff fill-rule=evenodd clip-rule=evenodd><path d="M6.322 2.988A1.67 1.67 0 0 1 7.5 2.5h5a1.667 1.667 0 0 1 1.667 1.667A.833.833 0 0 0 15 5h.833a2.5 2.5 0 0 1 2.5 2.5V15a2.5 2.5 0 0 1-2.5 2.5H4.167a2.5 2.5 0 0 1-2.5-2.5V7.5a2.5 2.5 0 0 1 2.5-2.5H5a.833.833 0 0 0 .833-.833c0-.442.176-.866.489-1.179M4.167 6.667a.833.833 0 0 0-.834.833V15a.833.833 0 0 0 .834.833h11.666a.834.834 0 0 0 .834-.833V7.5a.833.833 0 0 0-.834-.833H15a2.5 2.5 0 0 1-2.5-2.5h-5a2.5 2.5 0 0 1-2.5 2.5z"></path><path d="M10 9.167a1.667 1.667 0 1 0 0 3.333 1.667 1.667 0 0 0 0-3.333m-3.333 1.666a3.333 3.333 0 1 1 6.666 0 3.333 3.333 0 0 1-6.666 0">');
1694
- const Wt = (r = {}) => (() => {
1695
- var e = Ht();
1696
- return D(e, r, !0, !0), e;
2252
+ var _tmpl$$7 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><g fill=#fff fill-rule=evenodd clip-rule=evenodd><path d="M6.322 2.988A1.67 1.67 0 0 1 7.5 2.5h5a1.667 1.667 0 0 1 1.667 1.667A.833.833 0 0 0 15 5h.833a2.5 2.5 0 0 1 2.5 2.5V15a2.5 2.5 0 0 1-2.5 2.5H4.167a2.5 2.5 0 0 1-2.5-2.5V7.5a2.5 2.5 0 0 1 2.5-2.5H5a.833.833 0 0 0 .833-.833c0-.442.176-.866.489-1.179M4.167 6.667a.833.833 0 0 0-.834.833V15a.833.833 0 0 0 .834.833h11.666a.834.834 0 0 0 .834-.833V7.5a.833.833 0 0 0-.834-.833H15a2.5 2.5 0 0 1-2.5-2.5h-5a2.5 2.5 0 0 1-2.5 2.5z"></path><path d="M10 9.167a1.667 1.667 0 1 0 0 3.333 1.667 1.667 0 0 0 0-3.333m-3.333 1.666a3.333 3.333 0 1 1 6.666 0 3.333 3.333 0 0 1-6.666 0">`);
2253
+ const IconCamera = (props = {}) => (() => {
2254
+ var _el$ = _tmpl$$7();
2255
+ spread(_el$, props, true, true);
2256
+ return _el$;
1697
2257
  })();
1698
- var Gt = /* @__PURE__ */ S('<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path stroke=#fff stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4.167 10.833 7.5 14.167l8.333-8.334">');
1699
- const Xt = (r = {}) => (() => {
1700
- var e = Gt();
1701
- return D(e, r, !0, !0), e;
2258
+ var _tmpl$$6 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path stroke=#fff stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4.167 10.833 7.5 14.167l8.333-8.334">`);
2259
+ const IconCheck = (props = {}) => (() => {
2260
+ var _el$ = _tmpl$$6();
2261
+ spread(_el$, props, true, true);
2262
+ return _el$;
1702
2263
  })();
1703
- var Kt = /* @__PURE__ */ S('<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path fill=#fff fill-rule=evenodd d="M4.41 6.91a.833.833 0 0 1 1.18 0L10 11.323l4.41-4.411a.833.833 0 1 1 1.18 1.178l-5 5a.833.833 0 0 1-1.18 0l-5-5a.833.833 0 0 1 0-1.178"clip-rule=evenodd>');
1704
- const Qt = (r = {}) => (() => {
1705
- var e = Kt();
1706
- return D(e, r, !0, !0), e;
2264
+ var _tmpl$$5 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path fill=#fff fill-rule=evenodd d="M4.41 6.91a.833.833 0 0 1 1.18 0L10 11.323l4.41-4.411a.833.833 0 1 1 1.18 1.178l-5 5a.833.833 0 0 1-1.18 0l-5-5a.833.833 0 0 1 0-1.178"clip-rule=evenodd>`);
2265
+ const IconChevronDown = (props = {}) => (() => {
2266
+ var _el$ = _tmpl$$5();
2267
+ spread(_el$, props, true, true);
2268
+ return _el$;
1707
2269
  })();
1708
- var Yt = /* @__PURE__ */ S("<button>"), Jt = /* @__PURE__ */ S('<div class="h-[1px] absolute left-0 right-0 top-[-1px] bg-white pointer-events-none">');
1709
- const Zt = () => {
2270
+ var _tmpl$$4 = /* @__PURE__ */ template(`<button>`), _tmpl$2$3 = /* @__PURE__ */ template(`<div class="h-[1px] absolute left-0 right-0 top-[-1px] bg-white pointer-events-none">`);
2271
+ const CameraSelector = () => {
2272
+ const {
2273
+ cameraManagerSolidStore,
2274
+ cameraManager
2275
+ } = useCameraUiStore();
1710
2276
  const {
1711
- cameraManagerSolidStore: r,
1712
- cameraManager: e
1713
- } = q(), {
1714
2277
  t
1715
- } = Y(), a = r((m) => m.cameras), n = r((m) => m.selectedCamera), o = r((m) => m.isQueryingCameras), i = r((m) => m.facingFilter), [l, c] = z(!1), f = () => o() || l(), g = () => {
1716
- const m = i();
1717
- return m ? a().filter((b) => m.includes(b.facingMode)) : a();
1718
- }, y = () => [...g().map((m) => ({
1719
- value: m.deviceInfo.deviceId,
1720
- label: m.name
1721
- }))], u = () => Qe({
1722
- items: [...y()]
1723
- }), h = () => {
1724
- const m = n();
1725
- if (!m)
2278
+ } = useLocalization();
2279
+ const cameras = cameraManagerSolidStore((x) => x.cameras);
2280
+ const selectedCamera = cameraManagerSolidStore((x) => x.selectedCamera);
2281
+ const isQueryingCameras = cameraManagerSolidStore((x) => x.isQueryingCameras);
2282
+ const facingFilter = cameraManagerSolidStore((x) => x.facingFilter);
2283
+ const [isSwapping, setIsSwapping] = createSignal(false);
2284
+ const isDisabled = () => isQueryingCameras() || isSwapping();
2285
+ const camerasWithFacingFilter = () => {
2286
+ const $facingFilter = facingFilter();
2287
+ if (!$facingFilter) {
2288
+ return cameras();
2289
+ }
2290
+ return cameras().filter((camera) => $facingFilter.includes(camera.facingMode));
2291
+ };
2292
+ const createCameraOptions = () => [...camerasWithFacingFilter().map((camera) => ({
2293
+ value: camera.deviceInfo.deviceId,
2294
+ label: camera.name
2295
+ }))];
2296
+ const cameraCollection = () => createListCollection({
2297
+ items: [...createCameraOptions()]
2298
+ });
2299
+ const selectedCameraInCollection = () => {
2300
+ const $selectedCamera = selectedCamera();
2301
+ if (!$selectedCamera) {
2302
+ return;
2303
+ }
2304
+ const foundCamera = cameraCollection().find($selectedCamera.deviceInfo.deviceId);
2305
+ if (!foundCamera) {
1726
2306
  return;
1727
- const b = u().find(m.deviceInfo.deviceId);
1728
- if (b)
1729
- return [b.value];
1730
- }, p = (m) => er.some((b) => b.value === m), C = async (m) => {
1731
- c(!0);
1732
- const b = a().find((v) => v.deviceInfo.deviceId === m);
1733
- if (!b) {
2307
+ }
2308
+ return [foundCamera.value];
2309
+ };
2310
+ const isFakeCamera = (value) => {
2311
+ return fakeCameras.some((fakeCamera) => fakeCamera.value === value);
2312
+ };
2313
+ const selectCameraById = async (id) => {
2314
+ setIsSwapping(true);
2315
+ const camera = cameras().find((camera2) => camera2.deviceInfo.deviceId === id);
2316
+ if (!camera) {
1734
2317
  console.warn("No camera");
1735
2318
  return;
1736
2319
  }
1737
- await e.selectCamera(b), c(!1);
2320
+ await cameraManager.selectCamera(camera);
2321
+ setIsSwapping(false);
1738
2322
  };
1739
- return s(J, {
1740
- children: () => s(A.Root, {
2323
+ return createComponent(SmartEnvironmentProvider, {
2324
+ children: () => createComponent(Select.Root, {
2325
+ part: "camera-select-part",
1741
2326
  get collection() {
1742
- return u();
2327
+ return cameraCollection();
1743
2328
  },
1744
2329
  get value() {
1745
- return h();
2330
+ return selectedCameraInCollection();
1746
2331
  },
1747
2332
  positioning: {
1748
2333
  placement: "top"
1749
2334
  },
1750
- lazyMount: !0,
2335
+ lazyMount: true,
1751
2336
  get disabled() {
1752
- return f();
2337
+ return isDisabled();
1753
2338
  },
1754
- onValueChange: (m) => {
1755
- if (p(m.value[0])) {
2339
+ onValueChange: (details) => {
2340
+ if (isFakeCamera(details.value[0])) {
1756
2341
  console.warn("Fake camera, skipping");
1757
2342
  return;
1758
2343
  }
1759
- C(m.value[0]);
2344
+ void selectCameraById(details.value[0]);
1760
2345
  },
1761
2346
  get children() {
1762
- return [s(A.Label, {
1763
- class: "sr-only",
2347
+ return [createComponent(Select.Label, {
2348
+ "class": "sr-only",
1764
2349
  get children() {
1765
2350
  return t.selected_camera;
1766
2351
  }
1767
- }), s(A.Trigger, {
1768
- asChild: (m) => (() => {
1769
- var b = Yt();
1770
- return D(b, K(() => Ie(m()), {
1771
- class: `flex px-4 py-2 items-center gap-2 rounded-full bg-dark-100/50 backdrop-blur-xl
2352
+ }), createComponent(Select.Trigger, {
2353
+ asChild: (selectProps) => {
2354
+ return (() => {
2355
+ var _el$ = _tmpl$$4();
2356
+ spread(_el$, mergeProps(() => eventFixer(selectProps()), {
2357
+ "class": `flex px-4 py-2 items-center gap-2 rounded-full bg-dark-100/50 backdrop-blur-xl
1772
2358
  whitespace-nowrap text-base color-white font-500 cursor-pointer appearance-none
1773
2359
  border-none disabled:opacity-50 disabled:cursor-not-allowed max-w-[100%]`
1774
- }), !1, !0), w(b, s(Wt, {
1775
- class: "size-6 shrink-0",
1776
- "aria-hidden": !0
1777
- }), null), w(b, s(A.ValueText, {
1778
- class: "truncate",
1779
- get placeholder() {
1780
- return o() ? t.loading_cameras : t.select_a_camera;
1781
- }
1782
- }), null), w(b, s(A.Indicator, {
1783
- class: "shrink-0 data-[state=open]:scale-y-[-1]",
1784
- get children() {
1785
- return s(Qt, {
1786
- class: "size-6 shrink-0"
1787
- });
1788
- }
1789
- }), null), b;
1790
- })()
1791
- }), s(A.Positioner, {
2360
+ }), false, true);
2361
+ insert(_el$, createComponent(IconCamera, {
2362
+ "class": "size-6 shrink-0",
2363
+ "aria-hidden": true
2364
+ }), null);
2365
+ insert(_el$, createComponent(Select.ValueText, {
2366
+ "class": "truncate",
2367
+ get placeholder() {
2368
+ return isQueryingCameras() ? t.loading_cameras : t.select_a_camera;
2369
+ }
2370
+ }), null);
2371
+ insert(_el$, createComponent(Select.Indicator, {
2372
+ "class": "shrink-0 data-[state=open]:scale-y-[-1]",
2373
+ get children() {
2374
+ return createComponent(IconChevronDown, {
2375
+ "class": "size-6 shrink-0"
2376
+ });
2377
+ }
2378
+ }), null);
2379
+ return _el$;
2380
+ })();
2381
+ }
2382
+ }), createComponent(Select.Positioner, {
1792
2383
  get children() {
1793
- return s(A.Content, {
2384
+ return createComponent(Select.Content, {
1794
2385
  get children() {
1795
- return s(A.ItemGroup, {
1796
- class: "rounded-4 overflow-hidden text-base color-white",
2386
+ return createComponent(Select.ItemGroup, {
2387
+ "class": "rounded-4 overflow-hidden text-base color-white",
1797
2388
  get children() {
1798
- return s(qe, {
2389
+ return createComponent(Index, {
1799
2390
  get each() {
1800
- return u().items;
2391
+ return cameraCollection().items;
1801
2392
  },
1802
- children: (m, b) => s(A.Item, {
1803
- get item() {
1804
- return m();
1805
- },
1806
- class: `flex py-3 pl-4 pr-12 cursor-pointer select-none relative gap-[1px]
1807
- bg-dark-100/50 backdrop-blur-xl data-[highlighted]:bg-gray-500/50`,
1808
- get children() {
1809
- return [s(A.ItemText, {
1810
- class: "truncate",
1811
- get children() {
1812
- return m().label;
1813
- }
1814
- }), s(A.ItemIndicator, {
1815
- class: "absolute right-4",
1816
- get children() {
1817
- return s(Xt, {
1818
- class: "size-6 shrink-0"
1819
- });
1820
- }
1821
- }), s(E, {
1822
- when: b !== 0,
1823
- get children() {
1824
- return Jt();
1825
- }
1826
- })];
1827
- }
1828
- })
2393
+ children: (camera, index) => {
2394
+ return createComponent(Select.Item, {
2395
+ get item() {
2396
+ return camera();
2397
+ },
2398
+ "class": "flex py-3 pl-4 pr-12 cursor-pointer select-none relative gap-[1px]\n bg-dark-100/50 backdrop-blur-xl data-[highlighted]:bg-gray-500/50",
2399
+ get children() {
2400
+ return [createComponent(Select.ItemText, {
2401
+ "class": "truncate",
2402
+ get children() {
2403
+ return camera().label;
2404
+ }
2405
+ }), createComponent(Select.ItemIndicator, {
2406
+ "class": "absolute right-4",
2407
+ get children() {
2408
+ return createComponent(IconCheck, {
2409
+ "class": "size-6 shrink-0"
2410
+ });
2411
+ }
2412
+ }), createComponent(Show, {
2413
+ when: index !== 0,
2414
+ get children() {
2415
+ return _tmpl$2$3();
2416
+ }
2417
+ })];
2418
+ }
2419
+ });
2420
+ }
1829
2421
  });
1830
2422
  }
1831
2423
  });
@@ -1836,7 +2428,8 @@ const Zt = () => {
1836
2428
  }
1837
2429
  })
1838
2430
  });
1839
- }, er = [{
2431
+ };
2432
+ const fakeCameras = [{
1840
2433
  value: "5",
1841
2434
  label: "Back Camera 2"
1842
2435
  }, {
@@ -1852,307 +2445,389 @@ const Zt = () => {
1852
2445
  value: "4",
1853
2446
  label: "Some random desktop camera"
1854
2447
  }];
1855
- var Z = /* @__PURE__ */ S("<span class=sr-only>"), tr = /* @__PURE__ */ S('<div class="z-2 relative gap-2 grid justify-between items-center grid-cols-[1fr_auto_1fr] py-4 color-white lerp:px-3@xs,8@lg"><div class="justify-self-start flex flex-nowrap gap-4 auto-cols-auto"></div><div class="justify-self-center min-w-0 w-full"></div><div class=justify-self-end>'), rr = /* @__PURE__ */ S("<button>");
1856
- const ar = () => {
2448
+ var _tmpl$$3 = /* @__PURE__ */ template(`<span class=sr-only>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=justify-self-end>`), _tmpl$3$2 = /* @__PURE__ */ template(`<div class="z-2 relative gap-2 grid justify-between items-center grid-cols-[1fr_auto_1fr] py-4 color-white lerp:px-3@xs,8@lg"><div class="justify-self-start flex flex-nowrap gap-4 auto-cols-auto"></div><div class="justify-self-center min-w-0 w-full">`), _tmpl$4$1 = /* @__PURE__ */ template(`<button>`);
2449
+ const Header = () => {
1857
2450
  const {
1858
- dismountCameraUi: r,
1859
- cameraManagerSolidStore: e,
1860
- showMirrorCameraButton: t,
1861
- cameraManager: a
1862
- } = q(), {
1863
- t: n
1864
- } = Y(), o = e((h) => h.mirrorX), i = e((h) => h.selectedCamera), l = e((h) => h.cameras), c = e((h) => h.playbackState !== "idle"), f = e((h) => h.selectedCamera?.torchEnabled), g = () => i()?.torchSupported, y = () => {
1865
- const h = i();
1866
- h && h.toggleTorch();
1867
- }, u = () => {
1868
- a.setCameraMirrorX(!e.getState().mirrorX);
2451
+ dismountCameraUi,
2452
+ cameraManagerSolidStore,
2453
+ cameraManager,
2454
+ showMirrorCameraButton,
2455
+ showTorchButton,
2456
+ showCloseButton
2457
+ } = useCameraUiStore();
2458
+ const {
2459
+ t
2460
+ } = useLocalization();
2461
+ const isMirrored = cameraManagerSolidStore((s) => s.mirrorX);
2462
+ const selectedCamera = cameraManagerSolidStore((s) => s.selectedCamera);
2463
+ const cameras = cameraManagerSolidStore((s) => s.cameras);
2464
+ const isActive = cameraManagerSolidStore((s) => s.playbackState !== "idle");
2465
+ const torchEnabled = cameraManagerSolidStore((s) => s.selectedCamera?.torchEnabled);
2466
+ const hasTorch = () => selectedCamera()?.torchSupported;
2467
+ const toggleTorch = () => {
2468
+ const camera = selectedCamera();
2469
+ if (!camera) {
2470
+ return;
2471
+ }
2472
+ void camera.toggleTorch();
2473
+ };
2474
+ const toggleMirrorX = () => {
2475
+ cameraManager.setCameraMirrorX(!cameraManagerSolidStore.getState().mirrorX);
1869
2476
  };
1870
- return s(J, {
2477
+ return createComponent(SmartEnvironmentProvider, {
1871
2478
  children: () => (() => {
1872
- var h = tr(), p = h.firstChild, C = p.nextSibling, m = C.nextSibling;
1873
- return w(p, s(E, {
2479
+ var _el$ = _tmpl$3$2(), _el$2 = _el$.firstChild, _el$5 = _el$2.nextSibling;
2480
+ insert(_el$2, createComponent(Show, {
1874
2481
  get when() {
1875
- return t && c();
2482
+ return showMirrorCameraButton && isActive();
1876
2483
  },
1877
2484
  get children() {
1878
- return s(ee, {
2485
+ return createComponent(ToolbarButton, {
2486
+ part: "mirror-camera-button-part",
1879
2487
  get tooltipLabel() {
1880
- return n.mirror_camera;
2488
+ return t.mirror_camera;
1881
2489
  },
1882
- onClick: () => u(),
2490
+ onClick: () => toggleMirrorX(),
1883
2491
  get children() {
1884
2492
  return [(() => {
1885
- var b = Z();
1886
- return w(b, () => n.mirror_camera), b;
1887
- })(), s(qt, {
1888
- class: "size-6 shrink-0 transition-transform duration-300 ease-in-out",
2493
+ var _el$3 = _tmpl$$3();
2494
+ insert(_el$3, () => t.mirror_camera);
2495
+ return _el$3;
2496
+ })(), createComponent(MirrorIcon, {
2497
+ "class": "size-6 shrink-0 transition-transform duration-300 ease-in-out",
1889
2498
  get style() {
1890
2499
  return {
1891
- transform: o() ? "scaleX(-1)" : "scaleX(1)"
2500
+ transform: isMirrored() ? "scaleX(-1)" : "scaleX(1)"
1892
2501
  };
1893
2502
  }
1894
2503
  })];
1895
2504
  }
1896
2505
  });
1897
2506
  }
1898
- }), null), w(p, s(E, {
2507
+ }), null);
2508
+ insert(_el$2, createComponent(Show, {
1899
2509
  get when() {
1900
- return ge(() => !!g())() && c();
2510
+ return memo(() => !!(showTorchButton && hasTorch()))() && isActive();
1901
2511
  },
1902
2512
  get children() {
1903
- return s(ee, {
1904
- onClick: () => y(),
2513
+ return createComponent(ToolbarButton, {
2514
+ part: "torch-button-part",
2515
+ onClick: () => toggleTorch(),
1905
2516
  get tooltipLabel() {
1906
- return n.torch;
2517
+ return t.torch;
1907
2518
  },
1908
2519
  get children() {
1909
- return [s(E, {
2520
+ return [createComponent(Show, {
1910
2521
  get when() {
1911
- return !f();
2522
+ return !torchEnabled();
1912
2523
  },
1913
2524
  get children() {
1914
2525
  return [(() => {
1915
- var b = Z();
1916
- return w(b, () => n.torch), b;
1917
- })(), s(Ut, {
1918
- class: "size-6 shrink-0"
2526
+ var _el$4 = _tmpl$$3();
2527
+ insert(_el$4, () => t.torch);
2528
+ return _el$4;
2529
+ })(), createComponent(FlashOn, {
2530
+ "class": "size-6 shrink-0"
1919
2531
  })];
1920
2532
  }
1921
- }), s(E, {
2533
+ }), createComponent(Show, {
1922
2534
  get when() {
1923
- return f();
2535
+ return torchEnabled();
1924
2536
  },
1925
2537
  get children() {
1926
- return s(Bt, {
1927
- class: "size-6 shrink-0"
2538
+ return createComponent(FlashOff, {
2539
+ "class": "size-6 shrink-0"
1928
2540
  });
1929
2541
  }
1930
2542
  })];
1931
2543
  }
1932
2544
  });
1933
2545
  }
1934
- }), null), w(C, s(E, {
2546
+ }), null);
2547
+ insert(_el$5, createComponent(Show, {
1935
2548
  get when() {
1936
- return l().length > 1;
2549
+ return cameras().length > 1;
1937
2550
  },
1938
2551
  get children() {
1939
- return s(Zt, {});
2552
+ return createComponent(CameraSelector, {});
1940
2553
  }
1941
- })), w(m, s(ee, {
1942
- onClick: () => r(),
1943
- get tooltipLabel() {
1944
- return n.close;
1945
- },
2554
+ }));
2555
+ insert(_el$, createComponent(Show, {
2556
+ when: showCloseButton,
1946
2557
  get children() {
1947
- return [(() => {
1948
- var b = Z();
1949
- return w(b, () => n.close), b;
1950
- })(), s(Ot, {
1951
- class: "size-6 shrink-0"
1952
- })];
2558
+ var _el$6 = _tmpl$2$2();
2559
+ insert(_el$6, createComponent(ToolbarButton, {
2560
+ part: "close-button-part",
2561
+ onClick: () => dismountCameraUi(),
2562
+ get tooltipLabel() {
2563
+ return t.close;
2564
+ },
2565
+ get children() {
2566
+ return [(() => {
2567
+ var _el$7 = _tmpl$$3();
2568
+ insert(_el$7, () => t.close);
2569
+ return _el$7;
2570
+ })(), createComponent(CloseIcon, {
2571
+ "class": "size-6 shrink-0"
2572
+ })];
2573
+ }
2574
+ }));
2575
+ return _el$6;
1953
2576
  }
1954
- })), h;
2577
+ }), null);
2578
+ return _el$;
1955
2579
  })()
1956
2580
  });
1957
- }, ee = (r) => s(G.Root, {
1958
- get children() {
1959
- return [s(G.Trigger, K(r, {
1960
- asChild: (e) => (() => {
1961
- var t = rr();
1962
- return D(t, K(() => Ie(e()), {
1963
- class: `rounded-full bg-dark-500 bg-opacity-50 backdrop-blur grid place-items-center
2581
+ };
2582
+ const ToolbarButton = (props) => {
2583
+ return createComponent(Tooltip.Root, {
2584
+ get children() {
2585
+ return [createComponent(Tooltip.Trigger, mergeProps(props, {
2586
+ asChild: (tooltipProps) => {
2587
+ return (() => {
2588
+ var _el$8 = _tmpl$4$1();
2589
+ spread(_el$8, mergeProps(() => eventFixer(tooltipProps()), {
2590
+ "class": `rounded-full bg-dark-500 bg-opacity-50 backdrop-blur grid place-items-center
1964
2591
  size-12 appearance-none border-none cursor-pointer`
1965
- }), !1, !0), w(t, () => r.children), t;
1966
- })()
1967
- })), s(G.Positioner, {
1968
- get children() {
1969
- return s(G.Content, {
1970
- class: `bg-dark-500 bg-opacity-50 backdrop-blur color-white text-align-center p-2
2592
+ }), false, true);
2593
+ insert(_el$8, () => props.children);
2594
+ return _el$8;
2595
+ })();
2596
+ }
2597
+ })), createComponent(Tooltip.Positioner, {
2598
+ get children() {
2599
+ return createComponent(Tooltip.Content, {
2600
+ "class": `bg-dark-500 bg-opacity-50 backdrop-blur color-white text-align-center p-2
1971
2601
  rounded-md text-sm drop-shadow-md`,
1972
- get children() {
1973
- return r.tooltipLabel;
1974
- }
1975
- });
1976
- }
1977
- })];
1978
- }
1979
- }), nr = (r, e, t) => He((a) => (w(e, r(), e.firstChild ? null : void 0), () => {
1980
- a(), e.textContent = "";
1981
- }), t);
1982
- var or = /* @__PURE__ */ S("<div>");
1983
- const ir = (r) => {
1984
- const e = ve(), [t, a] = We(r, ["children", "disableShadowRoot", "getRef"]);
2602
+ get children() {
2603
+ return props.tooltipLabel;
2604
+ }
2605
+ });
2606
+ }
2607
+ })];
2608
+ }
2609
+ });
2610
+ };
2611
+ const renderWithOwner = (code, element, owner) => {
2612
+ return createRoot((dispose) => {
2613
+ insert(element, code(), element.firstChild ? null : void 0);
2614
+ return () => {
2615
+ dispose();
2616
+ element.textContent = "";
2617
+ };
2618
+ }, owner);
2619
+ };
2620
+ var _tmpl$$2 = /* @__PURE__ */ template(`<div>`);
2621
+ const SolidShadowRoot = (props) => {
2622
+ const owner = getOwner();
2623
+ const [local, others] = splitProps(props, ["children", "disableShadowRoot", "getRef"]);
1985
2624
  return (() => {
1986
- var n = or();
1987
- return O((o) => {
1988
- if (t.disableShadowRoot)
2625
+ var _el$ = _tmpl$$2();
2626
+ use((ref) => {
2627
+ if (local.disableShadowRoot) {
1989
2628
  return;
1990
- const i = o.attachShadow({
2629
+ }
2630
+ const shadowRoot = ref.attachShadow({
1991
2631
  mode: "open"
1992
2632
  });
1993
- nr(() => ge(() => t.children), i, e);
1994
- }, n), D(n, a, !1, !0), w(n, s(E, {
2633
+ renderWithOwner(() => memo(() => local.children), shadowRoot, owner);
2634
+ }, _el$);
2635
+ spread(_el$, others, false, true);
2636
+ insert(_el$, createComponent(Show, {
1995
2637
  get when() {
1996
- return t.disableShadowRoot;
2638
+ return local.disableShadowRoot;
1997
2639
  },
1998
2640
  get children() {
1999
- return t.children;
2641
+ return local.children;
2000
2642
  }
2001
- })), n;
2643
+ }));
2644
+ return _el$;
2002
2645
  })();
2003
- }, sr = ":where(html){line-height:1.15;-webkit-text-size-adjust:100%;text-size-adjust:100%}:where(h1){font-size:2em;margin-block-end:.67em;margin-block-start:.67em}:where(dl,ol,ul) :where(dl,ol,ul){margin-block-end:0;margin-block-start:0}:where(hr){box-sizing:content-box;color:inherit;height:0}:where(abbr[title]){text-decoration:underline;text-decoration:underline dotted}:where(b,strong){font-weight:bolder}:where(code,kbd,pre,samp){font-family:monospace,monospace;font-size:1em}:where(small){font-size:80%}:where(table){border-color:currentColor;text-indent:0}:where(button,input,select){margin:0}:where(button){text-transform:none}:where(button,input:is([type=button i],[type=reset i],[type=submit i])){-webkit-appearance:button}:where(progress){vertical-align:baseline}:where(select){text-transform:none}:where(textarea){margin:0}:where(input[type=search i]){-webkit-appearance:textfield;outline-offset:-2px}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}:where(button,input:is([type=button i],[type=color i],[type=reset i],[type=submit i]))::-moz-focus-inner{border-style:none;padding:0}:where(button,input:is([type=button i],[type=color i],[type=reset i],[type=submit i]))::-moz-focusring{outline:1px dotted ButtonText}:where(:-moz-ui-invalid){box-shadow:none}:where(dialog){background-color:#fff;border:solid;color:#000;height:-moz-fit-content;height:fit-content;left:0;margin:auto;padding:1em;position:absolute;right:0;width:-moz-fit-content;width:fit-content}:where(dialog:not([open])){display:none}:where(summary){display:list-item}", lr = ":host{font-family:var(--mb-ui-font);line-height:1.15;isolation:isolate;box-sizing:border-box}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word}code,pre{font-family:var(--mb-monospace-font-stack)}svg path{pointer-events:none}img,picture,video,canvas,svg{display:block;max-width:100%}img{pointer-events:none;user-select:none}:where(input,button,textarea,select){font:inherit}:where(button,select){cursor:pointer;color:inherit;font:inherit}:where(p,h1,h2,h3,h4,h5,h6){overflow-wrap:break-word}", cr = ':host{--mb-system-font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;--mb-monospace-font-stack: Menlo, Consolas, "Ubuntu Mono", "Roboto Mono", "DejaVu Sans Mono", monospace;--mb-ui-font: var(--mb-system-font-stack);--mb-size: 1;--color-accent-25-rgb-value: 242 247 255;--color-accent-50-rgb-value: 231 240 255;--color-accent-100-rgb-value: 220 234 255;--color-accent-200-rgb-value: 198 221 255;--color-accent-300-rgb-value: 158 197 255;--color-accent-400-rgb-value: 111 169 255;--color-accent-500-rgb-value: 58 137 253;--color-accent-600-rgb-value: 0 98 242;--color-accent-700-rgb-value: 0 80 197;--color-accent-800-rgb-value: 0 64 157;--color-accent-900-rgb-value: 0 54 133;--color-error-25-rgb-value: 255 248 249;--color-error-50-rgb-value: 255 241 242;--color-error-100-rgb-value: 255 228 230;--color-error-200-rgb-value: 254 205 211;--color-error-300-rgb-value: 253 164 175;--color-error-400-rgb-value: 251 113 133;--color-error-500-rgb-value: 244 63 94;--color-error-600-rgb-value: 225 29 72;--color-error-700-rgb-value: 190 18 60;--color-error-800-rgb-value: 136 19 39;--color-error-900-rgb-value: 89 13 40;--color-success-25-rgb-value: 245 254 250;--color-success-50-rgb-value: 236 253 245;--color-success-100-rgb-value: 209 250 229;--color-success-200-rgb-value: 167 243 208;--color-success-300-rgb-value: 110 231 183;--color-success-400-rgb-value: 52 211 153;--color-success-500-rgb-value: 16 185 144;--color-success-600-rgb-value: 22 163 138;--color-success-700-rgb-value: 39 121 106;--color-success-800-rgb-value: 23 92 79;--color-success-900-rgb-value: 12 59 50;--color-warning-25-rgb-value: 255 253 243;--color-warning-50-rgb-value: 254 252 232;--color-warning-100-rgb-value: 254 249 195;--color-warning-200-rgb-value: 254 240 138;--color-warning-300-rgb-value: 253 229 99;--color-warning-400-rgb-value: 252 218 59;--color-warning-500-rgb-value: 250 204 21;--color-warning-600-rgb-value: 234 179 8;--color-warning-700-rgb-value: 190 142 48;--color-warning-800-rgb-value: 132 83 28;--color-warning-900-rgb-value: 80 29 10;--color-deep-blue-25-rgb-value: 249 252 255;--color-deep-blue-50-rgb-value: 243 249 254;--color-deep-blue-100-rgb-value: 231 242 251;--color-deep-blue-200-rgb-value: 201 218 241;--color-deep-blue-300-rgb-value: 162 185 216;--color-deep-blue-400-rgb-value: 93 128 182;--color-deep-blue-500-rgb-value: 60 100 161;--color-deep-blue-600-rgb-value: 28 68 129;--color-deep-blue-700-rgb-value: 24 53 97;--color-deep-blue-800-rgb-value: 20 38 65;--color-deep-blue-900-rgb-value: 6 23 49;--color-light-blue-25-rgb-value: 248 251 253;--color-light-blue-50-rgb-value: 240 247 251;--color-light-blue-100-rgb-value: 228 238 244;--color-light-blue-200-rgb-value: 215 229 238;--color-light-blue-300-rgb-value: 190 218 237;--color-light-blue-400-rgb-value: 159 202 232;--color-light-blue-500-rgb-value: 135 180 211;--color-light-blue-600-rgb-value: 104 157 193;--color-light-blue-700-rgb-value: 78 129 164;--color-light-blue-800-rgb-value: 67 109 138;--color-light-blue-900-rgb-value: 55 84 104;--color-gray-50-rgb-value: 249 250 251;--color-gray-100-rgb-value: 243 244 246;--color-gray-200-rgb-value: 229 231 235;--color-gray-300-rgb-value: 209 213 219;--color-gray-400-rgb-value: 156 163 175;--color-gray-500-rgb-value: 107 114 128;--color-gray-600-rgb-value: 75 85 99;--color-gray-700-rgb-value: 55 65 81;--color-gray-800-rgb-value: 31 41 55;--color-blue-gray-50-rgb-value: 74 74 74;--color-blue-gray-100-rgb-value: 60 60 60;--color-blue-gray-200-rgb-value: 50 50 50;--color-blue-gray-300-rgb-value: 45 45 45;--color-blue-gray-400-rgb-value: 34 34 34;--color-blue-gray-500-rgb-value: 31 31 31;--color-blue-gray-600-rgb-value: 28 28 30;--color-blue-gray-700-rgb-value: 27 27 27;--color-blue-gray-800-rgb-value: 24 24 24;--color-blue-gray-900-rgb-value: 15 15 15;--color-black-rgb-value: 0 0 0;--color-white-rgb-value: 255 255 255;--color-primary: var(--color-accent-600-rgb-value);--color-error: var(--color-error-500-rgb-value);--color-success: var(--color-success-500-rgb-value);--color-warning: var(--color-warning-500-rgb-value);--color-deep-blue: var(--color-deep-blue-800-rgb-value);--color-light-blue: var(--color-light-blue-200-rgb-value);accent-color:var(--color-primary);caret-color:red}', ur = {
2646
+ };
2647
+ const normalize = '/* Document\n * ========================================================================== */\n\n/**\n * 1. Correct the line height in all browsers.\n * 2. Prevent adjustments of font size after orientation changes in iOS.\n */\n\n:where(html) {\n line-height: 1.15; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n text-size-adjust: 100%; /* 2 */\n}\n\n/* Sections\n * ========================================================================== */\n\n/**\n * Correct the font size and margin on `h1` elements within `section` and\n * `article` contexts in Chrome, Edge, Firefox, and Safari.\n */\n\n:where(h1) {\n font-size: 2em;\n margin-block-end: 0.67em;\n margin-block-start: 0.67em;\n}\n\n/* Grouping content\n * ========================================================================== */\n\n/**\n * Remove the margin on nested lists in Chrome, Edge, and Safari.\n */\n\n:where(dl, ol, ul) :where(dl, ol, ul) {\n margin-block-end: 0;\n margin-block-start: 0;\n}\n\n/**\n * 1. Add the correct box sizing in Firefox.\n * 2. Correct the inheritance of border color in Firefox.\n */\n\n:where(hr) {\n box-sizing: content-box; /* 1 */\n color: inherit; /* 2 */\n height: 0; /* 1 */\n}\n\n/* Text-level semantics\n * ========================================================================== */\n\n/**\n * Add the correct text decoration in Safari.\n */\n\n:where(abbr[title]) {\n text-decoration: underline;\n text-decoration: underline dotted;\n}\n\n/**\n * Add the correct font weight in Chrome, Edge, and Safari.\n */\n\n:where(b, strong) {\n font-weight: bolder;\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\n:where(code, kbd, pre, samp) {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/**\n * Add the correct font size in all browsers.\n */\n\n:where(small) {\n font-size: 80%;\n}\n\n/* Tabular data\n * ========================================================================== */\n\n/**\n * 1. Correct table border color in Chrome, Edge, and Safari.\n * 2. Remove text indentation from table contents in Chrome, Edge, and Safari.\n */\n\n:where(table) {\n border-color: currentColor; /* 1 */\n text-indent: 0; /* 2 */\n}\n\n/* Forms\n * ========================================================================== */\n\n/**\n * Remove the margin on controls in Safari.\n */\n\n:where(button, input, select) {\n margin: 0;\n}\n\n/**\n * Remove the inheritance of text transform in Firefox.\n */\n\n:where(button) {\n text-transform: none;\n}\n\n/**\n * Correct the inability to style buttons in iOS and Safari.\n */\n\n:where(button, input:is([type="button" i], [type="reset" i], [type="submit" i])) {\n -webkit-appearance: button;\n}\n\n/**\n * Add the correct vertical alignment in Chrome, Edge, and Firefox.\n */\n\n:where(progress) {\n vertical-align: baseline;\n}\n\n/**\n * Remove the inheritance of text transform in Firefox.\n */\n\n:where(select) {\n text-transform: none;\n}\n\n/**\n * Remove the margin in Firefox and Safari.\n */\n\n:where(textarea) {\n margin: 0;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome, Edge, and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n:where(input[type="search" i]) {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Safari.\n */\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/**\n * Correct the text style of placeholders in Chrome, Edge, and Safari.\n */\n\n::-webkit-input-placeholder {\n color: inherit;\n opacity: 0.54;\n}\n\n/**\n * Remove the inner padding in Chrome, Edge, and Safari on macOS.\n */\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style upload buttons in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/**\n * Remove the inner border and padding of focus outlines in Firefox.\n */\n\n:where(button, input:is([type="button" i], [type="color" i], [type="reset" i], [type="submit" i]))::-moz-focus-inner {\n border-style: none;\n padding: 0;\n}\n\n/**\n * Restore the focus outline styles unset by the previous rule in Firefox.\n */\n\n:where(button, input:is([type="button" i], [type="color" i], [type="reset" i], [type="submit" i]))::-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\n/**\n * Remove the additional :invalid styles in Firefox.\n */\n\n:where(:-moz-ui-invalid) {\n box-shadow: none;\n}\n\n/* Interactive\n * ========================================================================== */\n\n/*\n * Add the correct styles in Safari.\n */\n\n:where(dialog) {\n background-color: white;\n border: solid;\n color: black;\n height: -moz-fit-content;\n height: fit-content;\n left: 0;\n margin: auto;\n padding: 1em;\n position: absolute;\n right: 0;\n width: -moz-fit-content;\n width: fit-content;\n}\n\n:where(dialog:not([open])) {\n display: none;\n}\n\n/*\n * Add the correct display in all browsers.\n */\n\n:where(summary) {\n display: list-item;\n}\n';
2648
+ const rootStyles = ":host {\n font-family: var(--mb-ui-font);\n line-height: 1.15;\n isolation: isolate;\n box-sizing: border-box;\n}\n\n*,\n*::before,\n*::after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\np,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n overflow-wrap: break-word;\n}\n\ncode {\n font-family: var(--mb-monospace-font-stack);\n}\n\npre {\n font-family: var(--mb-monospace-font-stack);\n}\n\nsvg path {\n pointer-events: none;\n}\n\nimg,\npicture,\nvideo,\ncanvas,\nsvg {\n display: block;\n max-width: 100%;\n}\n\nimg {\n pointer-events: none;\n user-select: none;\n}\n\n:where(input, button, textarea, select) {\n font: inherit;\n}\n\n:where(button, select) {\n cursor: pointer;\n color: inherit;\n font: inherit;\n}\n\n:where(p, h1, h2, h3, h4, h5, h6) {\n overflow-wrap: break-word;\n}";
2649
+ const variables = ':host {\n --mb-system-font-stack:\n -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n --mb-monospace-font-stack:\n Menlo, Consolas, "Ubuntu Mono", "Roboto Mono", "DejaVu Sans Mono", monospace;\n --mb-ui-font: var(--mb-system-font-stack);\n --mb-size: 1;\n /***************************************/\n /* MB COLORS */\n /***************************************/\n --color-accent-25-rgb-value: 242 247 255; /* #F2F7FF */\n --color-accent-50-rgb-value: 231 240 255; /* #E7F0FF */\n --color-accent-100-rgb-value: 220 234 255; /* #DCEAFF */\n --color-accent-200-rgb-value: 198 221 255; /* #C6DDFF */\n --color-accent-300-rgb-value: 158 197 255; /* #9EC5FF */\n --color-accent-400-rgb-value: 111 169 255; /* #6FA9FF */\n --color-accent-500-rgb-value: 58 137 253; /* #3A89FD */\n --color-accent-600-rgb-value: 0 98 242; /* #0062F2 */\n --color-accent-700-rgb-value: 0 80 197; /* #0050C5 */\n --color-accent-800-rgb-value: 0 64 157; /* #00409D */\n --color-accent-900-rgb-value: 0 54 133; /* #003685 */\n --color-error-25-rgb-value: 255 248 249; /* #FFF8F9 */\n --color-error-50-rgb-value: 255 241 242; /* #FFF1F2 */\n --color-error-100-rgb-value: 255 228 230; /* #FFE4E6 */\n --color-error-200-rgb-value: 254 205 211; /* #FECDD3 */\n --color-error-300-rgb-value: 253 164 175; /* #FDA4AF */\n --color-error-400-rgb-value: 251 113 133; /* #FB7185 */\n --color-error-500-rgb-value: 244 63 94; /* #F43F5E */\n --color-error-600-rgb-value: 225 29 72; /* #E11D48 */\n --color-error-700-rgb-value: 190 18 60; /* #BE123C */\n --color-error-800-rgb-value: 136 19 39; /* #881337 */\n --color-error-900-rgb-value: 89 13 40; /* #590D28 */\n --color-success-25-rgb-value: 245 254 250; /* #F5FEFA */\n --color-success-50-rgb-value: 236 253 245; /* #ECFDF5 */\n --color-success-100-rgb-value: 209 250 229; /* #D1FAE5 */\n --color-success-200-rgb-value: 167 243 208; /* #A7F3D0 */\n --color-success-300-rgb-value: 110 231 183; /* #6EE7B7 */\n --color-success-400-rgb-value: 52 211 153; /* #34D399 */\n --color-success-500-rgb-value: 16 185 144; /* #10B990 */\n --color-success-600-rgb-value: 22 163 138; /* #16A38A */\n --color-success-700-rgb-value: 39 121 106; /* #27796A */\n --color-success-800-rgb-value: 23 92 79; /* #175C4F */\n --color-success-900-rgb-value: 12 59 50; /* #0C3B32 */\n --color-warning-25-rgb-value: 255 253 243; /* #FFFDF3 */\n --color-warning-50-rgb-value: 254 252 232; /* #FEFCE8 */\n --color-warning-100-rgb-value: 254 249 195; /* #FEF9C3 */\n --color-warning-200-rgb-value: 254 240 138; /* #FEF08A */\n --color-warning-300-rgb-value: 253 229 99; /* #FDE563 */\n --color-warning-400-rgb-value: 252 218 59; /* #FCDA3B */\n --color-warning-500-rgb-value: 250 204 21; /* #FACC15 */\n --color-warning-600-rgb-value: 234 179 8; /* #EAB308 */\n --color-warning-700-rgb-value: 190 142 48; /* #BE8E30 */\n --color-warning-800-rgb-value: 132 83 28; /* #84531C */\n --color-warning-900-rgb-value: 80 29 10; /* #501D0A */\n --color-deep-blue-25-rgb-value: 249 252 255; /* #F9FCFF */\n --color-deep-blue-50-rgb-value: 243 249 254; /* #F3F9FE */\n --color-deep-blue-100-rgb-value: 231 242 251; /* #E7F2FB */\n --color-deep-blue-200-rgb-value: 201 218 241; /* #C9DAF1 */\n --color-deep-blue-300-rgb-value: 162 185 216; /* #A2B9D8 */\n --color-deep-blue-400-rgb-value: 93 128 182; /* #5D80B6 */\n --color-deep-blue-500-rgb-value: 60 100 161; /* #3C64A1 */\n --color-deep-blue-600-rgb-value: 28 68 129; /* #1C4481 */\n --color-deep-blue-700-rgb-value: 24 53 97; /* #183561 */\n --color-deep-blue-800-rgb-value: 20 38 65; /* #142641 */\n --color-deep-blue-900-rgb-value: 6 23 49; /* #061731 */\n --color-light-blue-25-rgb-value: 248 251 253; /* #F8FBFD */\n --color-light-blue-50-rgb-value: 240 247 251; /* #F0F7FB */\n --color-light-blue-100-rgb-value: 228 238 244; /* #E4EEF4 */\n --color-light-blue-200-rgb-value: 215 229 238; /* #D7E5EE */\n --color-light-blue-300-rgb-value: 190 218 237; /* #BEDAED */\n --color-light-blue-400-rgb-value: 159 202 232; /* #9FCAE8 */\n --color-light-blue-500-rgb-value: 135 180 211; /* #87B4D3 */\n --color-light-blue-600-rgb-value: 104 157 193; /* #689DC1 */\n --color-light-blue-700-rgb-value: 78 129 164; /* #4E81A4 */\n --color-light-blue-800-rgb-value: 67 109 138; /* #436D8A */\n --color-light-blue-900-rgb-value: 55 84 104; /* #375468 */\n --color-gray-50-rgb-value: 249 250 251; /* #FAFAFA */\n --color-gray-100-rgb-value: 243 244 246; /* #F5F5F5 */\n --color-gray-200-rgb-value: 229 231 235; /* #F0F0F0 */\n --color-gray-300-rgb-value: 209 213 219; /* #D9D9D9 */\n --color-gray-400-rgb-value: 156 163 175; /* #BFBFBF */\n --color-gray-500-rgb-value: 107 114 128; /* #8C8C8C */\n --color-gray-600-rgb-value: 75 85 99; /* #595959 */\n --color-gray-700-rgb-value: 55 65 81; /* #434343 */\n --color-gray-800-rgb-value: 31 41 55; /* #262626 */\n --color-blue-gray-50-rgb-value: 74 74 74; /* #F9FAFB */\n --color-blue-gray-100-rgb-value: 60 60 60; /* #F3F4F6 */\n --color-blue-gray-200-rgb-value: 50 50 50; /* #E5E7EB */\n --color-blue-gray-300-rgb-value: 45 45 45; /* #D1D5DB */\n --color-blue-gray-400-rgb-value: 34 34 34; /* #9CA3AF */\n --color-blue-gray-500-rgb-value: 31 31 31; /* #6B7280 */\n --color-blue-gray-600-rgb-value: 28 28 30; /* #4B5563 */\n --color-blue-gray-700-rgb-value: 27 27 27; /* #374151 */\n --color-blue-gray-800-rgb-value: 24 24 24; /* #1F2937 */\n --color-blue-gray-900-rgb-value: 15 15 15; /* #111827 */\n --color-black-rgb-value: 0 0 0; /* #000000 */\n --color-white-rgb-value: 255 255 255; /* #FFFFFF */\n --color-primary: var(--color-accent-600-rgb-value);\n --color-error: var(--color-error-500-rgb-value);\n --color-success: var(--color-success-500-rgb-value);\n --color-warning: var(--color-warning-500-rgb-value);\n --color-deep-blue: var(--color-deep-blue-800-rgb-value);\n --color-light-blue: var(--color-light-blue-200-rgb-value);\n accent-color: var(--color-primary);\n caret-color: red;\n}';
2650
+ const initialState = {
2004
2651
  feedbackLayer: null,
2005
2652
  overlayLayer: null,
2006
2653
  owner: null
2007
- }, U = me()(
2008
- // this is important! Otherwise, solid-zustand will start mutating the initial state
2009
- he(() => structuredClone(ur))
2010
- ), oe = we(U), de = () => {
2011
2654
  };
2012
- function dr(r, e) {
2013
- if (Be)
2014
- return { observe: de, unobserve: de };
2015
- const t = new ResizeObserver(r);
2016
- return ie(t.disconnect.bind(t)), {
2017
- observe: (a) => t.observe(a, e),
2018
- unobserve: t.unobserve.bind(t)
2655
+ const cameraUiRefStore = createStore()(
2656
+ // this is important! Otherwise, solid-zustand will start mutating the initial state
2657
+ subscribeWithSelector(() => structuredClone(initialState))
2658
+ );
2659
+ const cameraUiRefSignalStore = createWithSignal(cameraUiRefStore);
2660
+ const noop = () => void 0;
2661
+ function makeResizeObserver(callback, options) {
2662
+ if (isServer) {
2663
+ return { observe: noop, unobserve: noop };
2664
+ }
2665
+ const observer = new ResizeObserver(callback);
2666
+ onCleanup(observer.disconnect.bind(observer));
2667
+ return {
2668
+ observe: (ref) => observer.observe(ref, options),
2669
+ unobserve: observer.unobserve.bind(observer)
2019
2670
  };
2020
2671
  }
2021
- const hr = (r, e, t, a) => {
2022
- const n = Math.max(r / t, e / a);
2023
- let o = 0;
2024
- if (r / t > e / a) {
2025
- const i = n * a;
2026
- o = 1 - e / i;
2672
+ const determineFitMode = (Cw, Ch, Vw, Vh) => {
2673
+ const scaleCover = Math.max(Cw / Vw, Ch / Vh);
2674
+ let croppedFraction = 0;
2675
+ if (Cw / Vw > Ch / Vh) {
2676
+ const visible = scaleCover * Vh;
2677
+ croppedFraction = 1 - Ch / visible;
2027
2678
  } else {
2028
- const i = n * t;
2029
- o = 1 - r / i;
2679
+ const visible = scaleCover * Vw;
2680
+ croppedFraction = 1 - Cw / visible;
2681
+ }
2682
+ if (croppedFraction < 0.1) {
2683
+ return "cover";
2684
+ } else {
2685
+ return "contain";
2030
2686
  }
2031
- return o < 0.1 ? "cover" : "contain";
2032
2687
  };
2033
- function mr(r, e, t, a) {
2034
- const n = r / t, o = e / a, i = Math.max(n, o);
2035
- if (n >= o) {
2036
- const l = Math.round(e / i);
2037
- return { x: 0, y: Math.round((a - l) / 2), width: t, height: l };
2688
+ function getVisibleVideoArea(containerWidth, containerHeight, videoWidth, videoHeight) {
2689
+ const scaleX = containerWidth / videoWidth;
2690
+ const scaleY = containerHeight / videoHeight;
2691
+ const s = Math.max(scaleX, scaleY);
2692
+ if (scaleX >= scaleY) {
2693
+ const visibleNaturalHeight = Math.round(containerHeight / s);
2694
+ const y = Math.round((videoHeight - visibleNaturalHeight) / 2);
2695
+ return { x: 0, y, width: videoWidth, height: visibleNaturalHeight };
2038
2696
  } else {
2039
- const l = Math.round(r / i);
2040
- return { x: Math.round((t - l) / 2), y: 0, width: l, height: a };
2697
+ const visibleNaturalWidth = Math.round(containerWidth / s);
2698
+ const x = Math.round((videoWidth - visibleNaturalWidth) / 2);
2699
+ return { x, y: 0, width: visibleNaturalWidth, height: videoHeight };
2041
2700
  }
2042
2701
  }
2043
- const gr = "_dialogPositioner_worsp_1", fr = "_dialogBackdrop_worsp_5", br = "_dialogContent_worsp_9", pr = "_large_worsp_13", vr = "_compact_worsp_16", wr = "_dialogTitle_worsp_30", yr = "_contentOut_worsp_34", Sr = "_closeButton_worsp_38", Cr = "_closeButtonInner_worsp_44", kr = "_primaryActionButton_worsp_49", Er = "_secondaryActionButton_worsp_53", _r = "_actions_worsp_57", Tr = "_alertTitle_worsp_64", xr = "_alertText_worsp_68", k = {
2044
- dialogPositioner: gr,
2045
- dialogBackdrop: fr,
2046
- dialogContent: br,
2047
- large: pr,
2048
- compact: vr,
2049
- dialogTitle: wr,
2050
- contentOut: yr,
2051
- closeButton: Sr,
2052
- closeButtonInner: Cr,
2053
- primaryActionButton: kr,
2054
- secondaryActionButton: Er,
2055
- actions: _r,
2056
- alertTitle: Tr,
2057
- alertText: xr
2702
+ const dialogPositioner = "_dialogPositioner_worsp_1";
2703
+ const dialogBackdrop = "_dialogBackdrop_worsp_5";
2704
+ const dialogContent = "_dialogContent_worsp_9";
2705
+ const large = "_large_worsp_13";
2706
+ const compact = "_compact_worsp_16";
2707
+ const dialogTitle = "_dialogTitle_worsp_30";
2708
+ const contentOut = "_contentOut_worsp_34";
2709
+ const closeButton = "_closeButton_worsp_38";
2710
+ const closeButtonInner = "_closeButtonInner_worsp_44";
2711
+ const primaryActionButton = "_primaryActionButton_worsp_49";
2712
+ const secondaryActionButton = "_secondaryActionButton_worsp_53";
2713
+ const actions = "_actions_worsp_57";
2714
+ const alertTitle = "_alertTitle_worsp_64";
2715
+ const alertText = "_alertText_worsp_68";
2716
+ const styles = {
2717
+ dialogPositioner,
2718
+ dialogBackdrop,
2719
+ dialogContent,
2720
+ large,
2721
+ compact,
2722
+ dialogTitle,
2723
+ contentOut,
2724
+ closeButton,
2725
+ closeButtonInner,
2726
+ primaryActionButton,
2727
+ secondaryActionButton,
2728
+ actions,
2729
+ alertTitle,
2730
+ alertText
2058
2731
  };
2059
- var Mr = /* @__PURE__ */ S("<span>&times;"), Rr = /* @__PURE__ */ S("<div>"), Ar = /* @__PURE__ */ S("<p>"), $r = /* @__PURE__ */ S("<span>"), Fr = /* @__PURE__ */ S("<div><button></button><button>");
2060
- const Dr = (r) => {
2061
- const e = () => {
2062
- switch (r.modalStyle) {
2732
+ var _tmpl$$1 = /* @__PURE__ */ template(`<span>&times;`), _tmpl$2$1 = /* @__PURE__ */ template(`<div>`), _tmpl$3$1 = /* @__PURE__ */ template(`<p>`), _tmpl$4 = /* @__PURE__ */ template(`<span>`), _tmpl$5 = /* @__PURE__ */ template(`<div><button></button><button>`);
2733
+ const Modal = (props) => {
2734
+ const getPaddingClass = () => {
2735
+ switch (props.modalStyle) {
2063
2736
  case "compact":
2064
- return k.compact;
2737
+ return styles.compact;
2065
2738
  case "large":
2066
- return k.compact;
2739
+ return styles.compact;
2067
2740
  case "default":
2068
2741
  default:
2069
- return;
2742
+ return void 0;
2070
2743
  }
2071
2744
  };
2072
- return s(J, {
2073
- children: () => s($.Root, K({
2074
- onFocusOutside: (t) => t.preventDefault(),
2075
- onInteractOutside: (t) => t.preventDefault(),
2076
- restoreFocus: !0,
2077
- unmountOnExit: !0,
2078
- lazyMount: !0
2079
- }, r, {
2745
+ return createComponent(SmartEnvironmentProvider, {
2746
+ children: () => createComponent(Dialog.Root, mergeProps({
2747
+ onFocusOutside: (e) => e.preventDefault(),
2748
+ onInteractOutside: (e) => e.preventDefault(),
2749
+ restoreFocus: true,
2750
+ unmountOnExit: true,
2751
+ lazyMount: true
2752
+ }, props, {
2080
2753
  get children() {
2081
- return s(E, {
2754
+ return createComponent(Show, {
2082
2755
  get when() {
2083
- return r.open;
2756
+ return props.open;
2084
2757
  },
2085
2758
  get children() {
2086
- return s(fe, {
2759
+ return createComponent(Portal, {
2087
2760
  get mount() {
2088
- return r.mountTarget;
2761
+ return props.mountTarget;
2089
2762
  },
2090
2763
  get children() {
2091
- return s($.Positioner, {
2092
- get class() {
2093
- return k.dialogPositioner;
2764
+ return createComponent(Dialog.Positioner, {
2765
+ get ["class"]() {
2766
+ return styles.dialogPositioner;
2094
2767
  },
2095
2768
  get children() {
2096
- return [s($.Backdrop, {
2097
- get class() {
2098
- return k.dialogBackdrop;
2769
+ return [createComponent(Dialog.Backdrop, {
2770
+ get ["class"]() {
2771
+ return styles.dialogBackdrop;
2099
2772
  }
2100
- }), s($.Content, {
2101
- get class() {
2102
- return `${k.dialogContent} ${e()}`;
2773
+ }), createComponent(Dialog.Content, {
2774
+ get ["class"]() {
2775
+ return `${styles.dialogContent} ${getPaddingClass()}`;
2103
2776
  },
2104
2777
  get children() {
2105
- return [s(E, {
2778
+ return [createComponent(Show, {
2106
2779
  get when() {
2107
- return r.showCloseButton;
2780
+ return props.showCloseButton;
2108
2781
  },
2109
2782
  get children() {
2110
- return s($.CloseTrigger, {
2111
- get class() {
2112
- return k.closeButton;
2783
+ return createComponent(Dialog.CloseTrigger, {
2784
+ get ["class"]() {
2785
+ return styles.closeButton;
2113
2786
  },
2114
2787
  get onClick() {
2115
- return r.onCloseClicked;
2788
+ return props.onCloseClicked;
2116
2789
  },
2117
2790
  get children() {
2118
- var t = Mr();
2119
- return H(() => V(t, k.closeButtonInner)), t;
2791
+ var _el$ = _tmpl$$1();
2792
+ effect(() => className(_el$, styles.closeButtonInner));
2793
+ return _el$;
2120
2794
  }
2121
2795
  });
2122
2796
  }
2123
- }), s(E, {
2797
+ }), createComponent(Show, {
2124
2798
  get when() {
2125
- return r.headerImage;
2799
+ return props.headerImage;
2126
2800
  },
2127
2801
  get children() {
2128
- return r.headerImage;
2802
+ return props.headerImage;
2129
2803
  }
2130
- }), s(E, {
2804
+ }), createComponent(Show, {
2131
2805
  get when() {
2132
- return r.header;
2806
+ return props.header;
2133
2807
  },
2134
- children: (t) => s($.Title, {
2135
- get class() {
2136
- return k.dialogTitle;
2808
+ children: (header) => createComponent(Dialog.Title, {
2809
+ get ["class"]() {
2810
+ return styles.dialogTitle;
2137
2811
  },
2138
2812
  get children() {
2139
- return t();
2813
+ return header();
2140
2814
  }
2141
2815
  })
2142
- }), s($.Description, {
2143
- get class() {
2144
- return k.contentOut;
2816
+ }), createComponent(Dialog.Description, {
2817
+ get ["class"]() {
2818
+ return styles.contentOut;
2145
2819
  },
2146
2820
  get children() {
2147
- return r.children;
2821
+ return props.children;
2148
2822
  }
2149
- }), s(E, {
2823
+ }), createComponent(Show, {
2150
2824
  get when() {
2151
- return r.actions;
2825
+ return props.actions;
2152
2826
  },
2153
2827
  get children() {
2154
- var t = Rr();
2155
- return w(t, () => r.actions), t;
2828
+ var _el$2 = _tmpl$2$1();
2829
+ insert(_el$2, () => props.actions);
2830
+ return _el$2;
2156
2831
  }
2157
2832
  })];
2158
2833
  }
@@ -2166,205 +2841,275 @@ const Dr = (r) => {
2166
2841
  }
2167
2842
  }))
2168
2843
  });
2169
- }, Ir = ({
2170
- mountTarget: r,
2171
- header: e,
2172
- text: t,
2173
- open: a,
2174
- onPrimaryClick: n,
2175
- onSecondaryClick: o,
2176
- primaryButtonText: i = "Retry",
2177
- secondaryButtonText: l = "Cancel"
2844
+ };
2845
+ const AlertModal = ({
2846
+ mountTarget,
2847
+ header,
2848
+ text,
2849
+ open,
2850
+ onPrimaryClick,
2851
+ onSecondaryClick,
2852
+ primaryButtonText = "Retry",
2853
+ secondaryButtonText = "Cancel"
2178
2854
  }) => {
2179
- let c;
2180
- return s(Dr, {
2181
- mountTarget: r,
2855
+ let primaryButtonEl;
2856
+ return createComponent(Modal, {
2857
+ mountTarget,
2182
2858
  get header() {
2183
2859
  return (() => {
2184
- var f = $r();
2185
- return w(f, e), H(() => V(f, k.alertTitle)), f;
2860
+ var _el$4 = _tmpl$4();
2861
+ insert(_el$4, header);
2862
+ effect(() => className(_el$4, styles.alertTitle));
2863
+ return _el$4;
2186
2864
  })();
2187
2865
  },
2188
- initialFocusEl: () => c,
2189
- open: a,
2866
+ initialFocusEl: () => primaryButtonEl,
2867
+ open,
2190
2868
  get actions() {
2191
2869
  return (() => {
2192
- var f = Fr(), g = f.firstChild, y = g.nextSibling;
2193
- g.$$click = () => o(), w(g, l), y.$$click = () => n();
2194
- var u = c;
2195
- return typeof u == "function" ? O(u, y) : c = y, w(y, i), H((h) => {
2196
- var p = k.actions, C = k.secondaryActionButton, m = k.primaryActionButton;
2197
- return p !== h.e && V(f, h.e = p), C !== h.t && V(g, h.t = C), m !== h.a && V(y, h.a = m), h;
2870
+ var _el$5 = _tmpl$5(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
2871
+ _el$6.$$click = () => onSecondaryClick();
2872
+ insert(_el$6, secondaryButtonText);
2873
+ _el$7.$$click = () => onPrimaryClick();
2874
+ var _ref$ = primaryButtonEl;
2875
+ typeof _ref$ === "function" ? use(_ref$, _el$7) : primaryButtonEl = _el$7;
2876
+ insert(_el$7, primaryButtonText);
2877
+ effect((_p$) => {
2878
+ var _v$ = styles.actions, _v$2 = styles.secondaryActionButton, _v$3 = styles.primaryActionButton;
2879
+ _v$ !== _p$.e && className(_el$5, _p$.e = _v$);
2880
+ _v$2 !== _p$.t && className(_el$6, _p$.t = _v$2);
2881
+ _v$3 !== _p$.a && className(_el$7, _p$.a = _v$3);
2882
+ return _p$;
2198
2883
  }, {
2199
2884
  e: void 0,
2200
2885
  t: void 0,
2201
2886
  a: void 0
2202
- }), f;
2887
+ });
2888
+ return _el$5;
2203
2889
  })();
2204
2890
  },
2205
2891
  modalStyle: "compact",
2206
2892
  get children() {
2207
- var f = Ar();
2208
- return w(f, t), H(() => V(f, k.alertText)), f;
2893
+ var _el$3 = _tmpl$3$1();
2894
+ insert(_el$3, text);
2895
+ effect(() => className(_el$3, styles.alertText));
2896
+ return _el$3;
2209
2897
  }
2210
2898
  });
2211
2899
  };
2212
- Ve(["click"]);
2213
- const zr = () => {
2900
+ delegateEvents(["click"]);
2901
+ const CameraErrorModal = () => {
2902
+ const {
2903
+ t
2904
+ } = useLocalization();
2214
2905
  const {
2215
- t: r
2216
- } = Y(), {
2217
- cameraManagerSolidStore: e,
2218
- cameraManager: t,
2219
- dismountCameraUi: a
2220
- } = q(), n = e((i) => i.errorState), o = oe((i) => i.overlayLayer);
2221
- return s(E, {
2906
+ cameraManagerSolidStore,
2907
+ cameraManager,
2908
+ dismountCameraUi
2909
+ } = useCameraUiStore();
2910
+ const errorState = cameraManagerSolidStore((x) => x.errorState);
2911
+ const overlayLayer = cameraUiRefSignalStore((x) => x.overlayLayer);
2912
+ return createComponent(Show, {
2222
2913
  get when() {
2223
- return n();
2914
+ return errorState();
2224
2915
  },
2225
2916
  get children() {
2226
- return s(Ir, {
2917
+ return createComponent(AlertModal, {
2227
2918
  get mountTarget() {
2228
- return o();
2919
+ return overlayLayer();
2229
2920
  },
2230
2921
  get header() {
2231
- return r.camera_error_title;
2922
+ return t.camera_error_title;
2232
2923
  },
2233
- open: !0,
2234
- onPrimaryClick: () => void t.startCameraStream(),
2235
- onSecondaryClick: () => a(),
2924
+ open: true,
2925
+ onPrimaryClick: () => void cameraManager.startCameraStream(),
2926
+ onSecondaryClick: () => dismountCameraUi(),
2236
2927
  get primaryButtonText() {
2237
- return r.camera_error_primary_btn;
2928
+ return t.camera_error_primary_btn;
2238
2929
  },
2239
2930
  get secondaryButtonText() {
2240
- return r.camera_error_cancel_btn;
2931
+ return t.camera_error_cancel_btn;
2241
2932
  },
2242
2933
  get text() {
2243
- return r.camera_error_details;
2934
+ return t.camera_error_details;
2244
2935
  }
2245
2936
  });
2246
2937
  }
2247
2938
  });
2248
2939
  };
2249
- var te = /* @__PURE__ */ S("<style>"), Lr = /* @__PURE__ */ S("<style id=camera-manager-style>"), Nr = /* @__PURE__ */ S('<div class="bg-dark-500 color-white size-full relative min-h-[300px]"part=capture-screen-part><video class="block absolute top-0 left-0 size-full"></video><div class="absolute top-0 left-0 w-full h-full z-1"id=feedback-layer></div><div class="absolute top-0 left-0 w-full h-full has-[[data-scope]]:z-2"id=overlay-layer>');
2250
- const ze = "capture-screen-host", Le = () => {
2940
+ var _tmpl$ = /* @__PURE__ */ template(`<style>`), _tmpl$2 = /* @__PURE__ */ template(`<style id=camera-manager-style>`), _tmpl$3 = /* @__PURE__ */ template(`<div class="bg-dark-500 color-white size-full relative min-h-[300px]"part=capture-screen-part><video part=video-element-part class="block absolute top-0 left-0 size-full"></video><div class="absolute top-0 left-0 w-full h-full z-1"id=feedback-layer></div><div class="absolute top-0 left-0 w-full h-full has-[[data-scope]]:z-2"id=overlay-layer>`);
2941
+ const CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID = "capture-screen-host";
2942
+ const CaptureScreen = () => {
2251
2943
  const {
2252
- cameraManager: r,
2253
- mountTarget: e
2254
- } = q(), [t, a] = z(), [n, o] = z(), [i, l] = z(), c = () => e.parentNode === document.body, [f, g] = z("contain");
2255
- function y() {
2256
- const u = t();
2257
- if (!u)
2944
+ cameraManager,
2945
+ mountTarget
2946
+ } = useCameraUiStore();
2947
+ const [videoRef, setVideoRef] = createSignal();
2948
+ const [feedbackRef, setFeedbackRef] = createSignal();
2949
+ const [overlayLayerRef, setOverlayLayerRef] = createSignal();
2950
+ const isPortalled = () => mountTarget.parentNode === document.body;
2951
+ const [fitMode, setFitMode] = createSignal("contain");
2952
+ function adjustVideoFit() {
2953
+ const video = videoRef();
2954
+ if (!video) {
2258
2955
  return;
2259
- const h = u.clientWidth, p = u.clientHeight, C = u.videoWidth, m = u.videoHeight, b = hr(h, p, C, m);
2260
- if (g(b), b === "cover") {
2261
- const v = mr(h, p, C, m);
2262
- r.setExtractionArea(v);
2263
- } else
2264
- r.setExtractionArea({
2956
+ }
2957
+ const Cw = video.clientWidth;
2958
+ const Ch = video.clientHeight;
2959
+ const Vw = video.videoWidth;
2960
+ const Vh = video.videoHeight;
2961
+ const newFitMode = determineFitMode(Cw, Ch, Vw, Vh);
2962
+ setFitMode(newFitMode);
2963
+ if (newFitMode === "cover") {
2964
+ const visibleArea = getVisibleVideoArea(Cw, Ch, Vw, Vh);
2965
+ cameraManager.setExtractionArea(visibleArea);
2966
+ } else {
2967
+ cameraManager.setExtractionArea({
2265
2968
  x: 0,
2266
2969
  y: 0,
2267
- width: C,
2268
- height: m
2970
+ width: Vw,
2971
+ height: Vh
2269
2972
  });
2973
+ }
2270
2974
  }
2271
- return Q(() => {
2272
- const u = t();
2273
- if (!u)
2975
+ onMount(() => {
2976
+ const video = videoRef();
2977
+ if (!video) {
2274
2978
  return;
2979
+ }
2275
2980
  const {
2276
- observe: h,
2277
- unobserve: p
2278
- } = dr(y);
2279
- h(u), u.addEventListener("loadedmetadata", y), ie(() => {
2280
- p(u), u.removeEventListener("loadedmetadata", y);
2981
+ observe,
2982
+ unobserve
2983
+ } = makeResizeObserver(adjustVideoFit);
2984
+ observe(video);
2985
+ video.addEventListener("loadedmetadata", adjustVideoFit);
2986
+ onCleanup(() => {
2987
+ unobserve(video);
2988
+ video.removeEventListener("loadedmetadata", adjustVideoFit);
2281
2989
  });
2282
- }), Q(() => {
2283
- const u = ve();
2284
- u && oe.setState({
2285
- owner: u
2990
+ });
2991
+ onMount(() => {
2992
+ const owner = getOwner();
2993
+ if (!owner) {
2994
+ return;
2995
+ }
2996
+ cameraUiRefSignalStore.setState({
2997
+ owner
2998
+ });
2999
+ });
3000
+ createEffect(() => {
3001
+ const $videoRef = videoRef();
3002
+ const $feedbackRef = feedbackRef();
3003
+ const $overlayLayerRef = overlayLayerRef();
3004
+ if (!$videoRef || !$feedbackRef || !$overlayLayerRef) {
3005
+ return;
3006
+ }
3007
+ cameraUiRefSignalStore.setState({
3008
+ feedbackLayer: $feedbackRef,
3009
+ overlayLayer: $overlayLayerRef
2286
3010
  });
2287
- }), Ge(() => {
2288
- const u = t(), h = n(), p = i();
2289
- !u || !h || !p || (oe.setState({
2290
- feedbackLayer: h,
2291
- overlayLayer: p
2292
- }), r.initVideoElement(u));
2293
- }), s(ir, {
3011
+ cameraManager.initVideoElement($videoRef);
3012
+ });
3013
+ return createComponent(SolidShadowRoot, {
2294
3014
  get id() {
2295
- return c() ? void 0 : ze;
3015
+ return !isPortalled() ? CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID : void 0;
2296
3016
  },
2297
3017
  get disableShadowRoot() {
2298
- return c();
3018
+ return isPortalled();
2299
3019
  },
2300
3020
  get style() {
2301
- return c() ? {
3021
+ return isPortalled() ? {
2302
3022
  height: "100%"
2303
3023
  } : void 0;
2304
3024
  },
2305
3025
  get children() {
2306
3026
  return [(() => {
2307
- var u = te();
2308
- return w(u, cr), u;
3027
+ var _el$ = _tmpl$();
3028
+ insert(_el$, variables);
3029
+ return _el$;
2309
3030
  })(), (() => {
2310
- var u = te();
2311
- return w(u, sr), u;
3031
+ var _el$2 = _tmpl$();
3032
+ insert(_el$2, normalize);
3033
+ return _el$2;
2312
3034
  })(), (() => {
2313
- var u = te();
2314
- return w(u, lr), u;
3035
+ var _el$3 = _tmpl$();
3036
+ insert(_el$3, rootStyles);
3037
+ return _el$3;
2315
3038
  })(), (() => {
2316
- var u = Lr();
2317
- return O((h) => {
2318
- window.__mbCameraManagerCssCode && (h.innerHTML = window.__mbCameraManagerCssCode);
2319
- }, u), u;
3039
+ var _el$4 = _tmpl$2();
3040
+ use((ref) => {
3041
+ if (window.__mbCameraManagerCssCode) {
3042
+ ref.innerHTML = window.__mbCameraManagerCssCode;
3043
+ }
3044
+ }, _el$4);
3045
+ return _el$4;
2320
3046
  })(), (() => {
2321
- var u = Nr(), h = u.firstChild, p = h.nextSibling, C = p.nextSibling;
2322
- return w(u, s(ar, {}), h), O(a, h), O(o, p), O(l, C), w(u, s(zr, {}), null), H((m) => (m = f()) != null ? h.style.setProperty("object-fit", m) : h.style.removeProperty("object-fit")), u;
3047
+ var _el$5 = _tmpl$3(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling, _el$8 = _el$7.nextSibling;
3048
+ insert(_el$5, createComponent(Header, {}), _el$6);
3049
+ use(setVideoRef, _el$6);
3050
+ use(setFeedbackRef, _el$7);
3051
+ use(setOverlayLayerRef, _el$8);
3052
+ insert(_el$5, createComponent(CameraErrorModal, {}), null);
3053
+ effect((_$p) => (_$p = fitMode()) != null ? _el$6.style.setProperty("object-fit", _$p) : _el$6.style.removeProperty("object-fit"));
3054
+ return _el$5;
2323
3055
  })()];
2324
3056
  }
2325
3057
  });
2326
- }, Or = () => {
3058
+ };
3059
+ const CaptureScreenPortalled = () => {
3060
+ const {
3061
+ t
3062
+ } = useLocalization();
3063
+ const [isOpen, setIsOpen] = createSignal(true);
2327
3064
  const {
2328
- t: r
2329
- } = Y(), [e, t] = z(!0), {
2330
- addOnDismountCallback: a
2331
- } = q();
2332
- return a(() => {
2333
- t(!1);
2334
- }), s(fe, {
2335
- useShadow: !0,
3065
+ addOnDismountCallback
3066
+ } = useCameraUiStore();
3067
+ addOnDismountCallback(() => {
3068
+ setIsOpen(false);
3069
+ });
3070
+ return createComponent(Portal, {
3071
+ useShadow: true,
2336
3072
  get mount() {
2337
- return document.getElementById(Ne);
3073
+ return document.getElementById(MOUNT_POINT_ID);
3074
+ },
3075
+ ref: (ref) => {
3076
+ ref.id = CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID;
3077
+ ref.style.zIndex = "1000";
3078
+ ref.style.position = "fixed";
3079
+ ref.id = "mb-camera-host";
3080
+ return ref;
2338
3081
  },
2339
- ref: (n) => (n.id = ze, n.style.zIndex = "1000", n.style.position = "fixed", n.id = "mb-camera-host", n),
2340
3082
  get children() {
2341
- return s(J, {
2342
- children: (n) => s($.Root, {
3083
+ return createComponent(SmartEnvironmentProvider, {
3084
+ children: (rootNode) => createComponent(Dialog.Root, {
2343
3085
  get open() {
2344
- return e();
3086
+ return isOpen();
2345
3087
  },
2346
- lazyMount: !0,
2347
- unmountOnExit: !0,
3088
+ lazyMount: true,
3089
+ unmountOnExit: true,
2348
3090
  initialFocusEl: () => {
2349
- const o = document.createElement("div");
2350
- return o.tabIndex = -1, n.appendChild(o), setTimeout(() => {
2351
- o.remove();
2352
- }, 0), o;
3091
+ const dummyNode = document.createElement("div");
3092
+ dummyNode.tabIndex = -1;
3093
+ rootNode.appendChild(dummyNode);
3094
+ setTimeout(() => {
3095
+ dummyNode.remove();
3096
+ }, 0);
3097
+ return dummyNode;
2353
3098
  },
2354
3099
  get children() {
2355
- return s($.Positioner, {
3100
+ return createComponent(Dialog.Positioner, {
2356
3101
  get children() {
2357
- return s($.Content, {
3102
+ return createComponent(Dialog.Content, {
2358
3103
  "aria-labelledby": "dialog-title",
2359
- class: "h-vh supports-[(height:100dvh)]:h-dvh top-0 left-0 w-full fixed",
3104
+ "class": "h-vh supports-[(height:100dvh)]:h-dvh top-0 left-0 w-full fixed",
2360
3105
  get children() {
2361
- return [s($.Title, {
2362
- class: "sr-only",
3106
+ return [createComponent(Dialog.Title, {
3107
+ "class": "sr-only",
2363
3108
  id: "dialog-title",
2364
3109
  get children() {
2365
- return r.scan_document;
3110
+ return t.scan_document;
2366
3111
  }
2367
- }), s(Le, {})];
3112
+ }), createComponent(CaptureScreen, {})];
2368
3113
  }
2369
3114
  });
2370
3115
  }
@@ -2374,65 +3119,89 @@ const ze = "capture-screen-host", Le = () => {
2374
3119
  });
2375
3120
  }
2376
3121
  });
2377
- }, Pr = () => {
3122
+ };
3123
+ const RootComponent = () => {
2378
3124
  const {
2379
- mountTarget: r
2380
- } = q();
2381
- return s(Ue, {
3125
+ mountTarget
3126
+ } = useCameraUiStore();
3127
+ return createComponent(Dynamic, {
2382
3128
  get component() {
2383
- return r.parentNode === document.body ? Or : Le;
3129
+ return mountTarget.parentNode === document.body ? CaptureScreenPortalled : CaptureScreen;
2384
3130
  }
2385
3131
  });
2386
- }, Ne = "camera-manager-mount-point";
2387
- function Yr(r, e, {
2388
- localizationStrings: t,
2389
- showMirrorCameraButton: a = !1
3132
+ };
3133
+ const MOUNT_POINT_ID = "camera-manager-mount-point";
3134
+ function createCameraManagerUi(cameraManager, target, {
3135
+ localizationStrings,
3136
+ showMirrorCameraButton = false,
3137
+ showTorchButton = true,
3138
+ showCloseButton = true
2390
3139
  } = {}) {
2391
- let n;
2392
- const o = /* @__PURE__ */ new Set();
2393
- let i;
2394
- const l = (p) => {
2395
- i = p;
2396
- }, c = () => {
2397
- r.reset();
3140
+ let mountTarget;
3141
+ const dismountCallbacks = /* @__PURE__ */ new Set();
3142
+ let updateLocalizationRef;
3143
+ const setLocalizationRef = (setter) => {
3144
+ updateLocalizationRef = setter;
2398
3145
  };
2399
- let f;
2400
- const g = () => {
3146
+ const cleanupCameraManager = () => {
3147
+ cameraManager.reset();
3148
+ };
3149
+ let dismountRef;
3150
+ const dismountCameraManagerUi = () => {
2401
3151
  try {
2402
3152
  console.debug("🧱 Dismounting camera manager UI");
2403
- for (const p of o)
2404
- p();
2405
- o.clear(), c(), requestAnimationFrame(() => {
3153
+ for (const callback of dismountCallbacks) {
3154
+ callback();
3155
+ }
3156
+ dismountCallbacks.clear();
3157
+ cleanupCameraManager();
3158
+ requestAnimationFrame(() => {
2406
3159
  requestAnimationFrame(() => {
2407
- f && f(), n.remove(), c();
3160
+ if (dismountRef) {
3161
+ dismountRef();
3162
+ }
3163
+ mountTarget.remove();
3164
+ cleanupCameraManager();
2408
3165
  });
2409
3166
  });
2410
- } catch (p) {
2411
- console.warn("Error while dismounting camera manager UI", p);
3167
+ } catch (e) {
3168
+ console.warn("Error while dismounting camera manager UI", e);
2412
3169
  }
2413
- }, y = document.createElement("div");
2414
- y.id = Ne, n = y, e ? e.appendChild(y) : document.body.appendChild(y);
2415
- const u = (p) => (o.add(p), () => {
2416
- o.delete(p);
2417
- });
2418
- f = je(() => s(zt, {
2419
- userStrings: t,
2420
- setLocalizationRef: l,
3170
+ };
3171
+ const newMountTarget = document.createElement("div");
3172
+ newMountTarget.id = MOUNT_POINT_ID;
3173
+ mountTarget = newMountTarget;
3174
+ if (target) {
3175
+ target.appendChild(newMountTarget);
3176
+ } else {
3177
+ document.body.appendChild(newMountTarget);
3178
+ }
3179
+ const addOnDismountCallback = (fn) => {
3180
+ dismountCallbacks.add(fn);
3181
+ return () => {
3182
+ dismountCallbacks.delete(fn);
3183
+ };
3184
+ };
3185
+ dismountRef = render(() => createComponent(LocalizationProvider, {
3186
+ userStrings: localizationStrings,
3187
+ setLocalizationRef,
2421
3188
  get children() {
2422
- return s(Dt, {
2423
- addOnDismountCallback: u,
2424
- dismountCameraUi: g,
2425
- cameraManager: r,
2426
- showMirrorCameraButton: a,
2427
- mountTarget: n,
3189
+ return createComponent(CameraUiStoreProvider, {
3190
+ addOnDismountCallback,
3191
+ dismountCameraUi: dismountCameraManagerUi,
3192
+ cameraManager,
3193
+ showMirrorCameraButton,
3194
+ showTorchButton,
3195
+ showCloseButton,
3196
+ mountTarget,
2428
3197
  get children() {
2429
- return s(Pr, {});
3198
+ return createComponent(RootComponent, {});
2430
3199
  }
2431
3200
  });
2432
3201
  }
2433
- }), n);
2434
- const h = {
2435
- updateLocalization: i,
3202
+ }), mountTarget);
3203
+ const exposedComponentApi = {
3204
+ updateLocalization: updateLocalizationRef,
2436
3205
  /**
2437
3206
  * Adds a callback to be called when the component is unmounted.
2438
3207
  * Returns a cleanup function that removes the callback when called.
@@ -2440,64 +3209,88 @@ function Yr(r, e, {
2440
3209
  * @param fn - The callback function to be called when the component is unmounted
2441
3210
  * @returns A cleanup function that removes the callback when called
2442
3211
  */
2443
- addOnDismountCallback: u,
2444
- cameraManager: r,
3212
+ addOnDismountCallback,
3213
+ cameraManager,
2445
3214
  // we know these are defined because `createCameraManagerUi` resolves when they are defined
2446
3215
  // TODO: maybe don't use getters but make sure they are defined
2447
3216
  get feedbackLayerNode() {
2448
- return U.getState().feedbackLayer;
3217
+ return cameraUiRefStore.getState().feedbackLayer;
2449
3218
  },
2450
3219
  get overlayLayerNode() {
2451
- return U.getState().overlayLayer;
3220
+ return cameraUiRefStore.getState().overlayLayer;
2452
3221
  },
2453
3222
  get owner() {
2454
- return U.getState().owner;
3223
+ return cameraUiRefStore.getState().owner;
2455
3224
  },
2456
- dismount: g
3225
+ dismount: dismountCameraManagerUi
2457
3226
  };
2458
- return new Promise((p) => {
2459
- let C = !1, m = !1, b = !1, v = () => {
2460
- }, x = () => {
2461
- }, R = () => {
3227
+ return new Promise((resolve) => {
3228
+ let videoExists = false;
3229
+ let feedbackExists = false;
3230
+ let overlayExists = false;
3231
+ let unsubscribeFeedbackLayer = () => {
3232
+ };
3233
+ let unsubscribeOverlayLayer = () => {
3234
+ };
3235
+ let unsubscribeVideo = () => {
2462
3236
  };
2463
- const F = () => {
2464
- C && m && b && (v(), x(), R(), p(h));
3237
+ const checkReady = () => {
3238
+ if (videoExists && feedbackExists && overlayExists) {
3239
+ unsubscribeFeedbackLayer();
3240
+ unsubscribeOverlayLayer();
3241
+ unsubscribeVideo();
3242
+ resolve(exposedComponentApi);
3243
+ }
2465
3244
  };
2466
- v = U.subscribe((M) => M.feedbackLayer, (M) => {
2467
- M && (m = !0), F();
3245
+ unsubscribeFeedbackLayer = cameraUiRefStore.subscribe((x) => x.feedbackLayer, (feedbackLayer) => {
3246
+ if (feedbackLayer) {
3247
+ feedbackExists = true;
3248
+ }
3249
+ checkReady();
2468
3250
  }, {
2469
- fireImmediately: !0
2470
- }), x = U.subscribe((M) => M.overlayLayer, (M) => {
2471
- M && (b = !0), F();
3251
+ fireImmediately: true
3252
+ });
3253
+ unsubscribeOverlayLayer = cameraUiRefStore.subscribe((x) => x.overlayLayer, (overlayLayer) => {
3254
+ if (overlayLayer) {
3255
+ overlayExists = true;
3256
+ }
3257
+ checkReady();
2472
3258
  }, {
2473
- fireImmediately: !0
2474
- }), R = r.subscribe((M) => M.videoElement, (M) => {
2475
- M && (C = !0, F());
3259
+ fireImmediately: true
3260
+ });
3261
+ unsubscribeVideo = cameraManager.subscribe((state) => state.videoElement, (videoElement) => {
3262
+ if (videoElement) {
3263
+ videoExists = true;
3264
+ checkReady();
3265
+ }
2476
3266
  }, {
2477
- fireImmediately: !0
3267
+ fireImmediately: true
2478
3268
  });
2479
3269
  });
2480
3270
  }
2481
- const Oe = Symbol();
2482
- globalThis.__CAMERA_MANAGER__ ||= Oe;
2483
- globalThis.__CAMERA_MANAGER__ !== Oe && console.warn(
2484
- "Detected multiple instances of @microblink/camera-manager. This can lead to unexpected behavior."
2485
- );
3271
+ const testSymbol = Symbol();
3272
+ globalThis.__CAMERA_MANAGER__ ||= testSymbol;
3273
+ if (globalThis.__CAMERA_MANAGER__ !== testSymbol) {
3274
+ console.warn(
3275
+ "Detected multiple instances of @microblink/camera-manager. This can lead to unexpected behavior."
3276
+ );
3277
+ }
2486
3278
  export {
2487
- Me as Camera,
2488
- Qr as CameraManager,
2489
- Ne as MOUNT_POINT_ID,
2490
- At as VideoFrameProcessor,
2491
- d as cameraManagerStore,
2492
- U as cameraUiRefStore,
2493
- Yr as createCameraManagerUi,
2494
- $t as defaultCameraManagerOptions,
2495
- bt as findResolutionKey,
2496
- $e as getBuffer,
2497
- gt as getNormalizedResolution,
2498
- ne as isBufferDetached,
2499
- ft as matchClosestResolution,
2500
- Ye as resetCameraManagerStore,
2501
- mt as returnLongerSide,
2502
- P as videoResolutions
3279
+ Camera,
3280
+ CameraManager,
3281
+ MOUNT_POINT_ID,
3282
+ VideoFrameProcessor,
3283
+ cameraManagerStore,
3284
+ cameraUiRefStore,
3285
+ createCameraManagerUi,
3286
+ defaultCameraManagerOptions,
3287
+ findResolutionKey,
3288
+ getBuffer,
3289
+ getNormalizedResolution,
3290
+ isBufferDetached,
3291
+ matchClosestResolution,
3292
+ resetCameraManagerStore,
3293
+ returnLongerSide,
3294
+ videoResolutions
2503
3295
  };
3296
+ //# sourceMappingURL=camera-manager.js.map