@useupup/preact 3.3.0

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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -0
  3. package/dist/AudioUploader-2WITC5YR-4WGBUCEB.js +298 -0
  4. package/dist/AudioUploader-2WITC5YR-4WGBUCEB.js.map +1 -0
  5. package/dist/AudioUploader-2WITC5YR-GCKVRJAT.cjs +298 -0
  6. package/dist/AudioUploader-2WITC5YR-GCKVRJAT.cjs.map +1 -0
  7. package/dist/BoxUploader-VE5LRJ7M-CWGNYYJV.js +170 -0
  8. package/dist/BoxUploader-VE5LRJ7M-CWGNYYJV.js.map +1 -0
  9. package/dist/BoxUploader-VE5LRJ7M-IE7LYW5P.cjs +170 -0
  10. package/dist/BoxUploader-VE5LRJ7M-IE7LYW5P.cjs.map +1 -0
  11. package/dist/CameraUploader-WF5A6UIS-3KBW647M.cjs +628 -0
  12. package/dist/CameraUploader-WF5A6UIS-3KBW647M.cjs.map +1 -0
  13. package/dist/CameraUploader-WF5A6UIS-DONVXSEZ.js +628 -0
  14. package/dist/CameraUploader-WF5A6UIS-DONVXSEZ.js.map +1 -0
  15. package/dist/DropboxUploader-VMUYG3OP-7FKTLIIL.cjs +172 -0
  16. package/dist/DropboxUploader-VMUYG3OP-7FKTLIIL.cjs.map +1 -0
  17. package/dist/DropboxUploader-VMUYG3OP-DBUPHIG7.js +172 -0
  18. package/dist/DropboxUploader-VMUYG3OP-DBUPHIG7.js.map +1 -0
  19. package/dist/GoogleDriveUploader-YA56X3QR-FMS6MTYU.js +175 -0
  20. package/dist/GoogleDriveUploader-YA56X3QR-FMS6MTYU.js.map +1 -0
  21. package/dist/GoogleDriveUploader-YA56X3QR-OR3CQLX2.cjs +175 -0
  22. package/dist/GoogleDriveUploader-YA56X3QR-OR3CQLX2.cjs.map +1 -0
  23. package/dist/ImageEditorInline-N2NSAODR-QWXPP3ON.js +184 -0
  24. package/dist/ImageEditorInline-N2NSAODR-QWXPP3ON.js.map +1 -0
  25. package/dist/ImageEditorInline-N2NSAODR-ZVAM6EOA.cjs +184 -0
  26. package/dist/ImageEditorInline-N2NSAODR-ZVAM6EOA.cjs.map +1 -0
  27. package/dist/ImageEditorModal-CWKMDVPY-PRD43JPH.cjs +236 -0
  28. package/dist/ImageEditorModal-CWKMDVPY-PRD43JPH.cjs.map +1 -0
  29. package/dist/ImageEditorModal-CWKMDVPY-ZRPTYHYN.js +236 -0
  30. package/dist/ImageEditorModal-CWKMDVPY-ZRPTYHYN.js.map +1 -0
  31. package/dist/OneDriveUploader-I25Y6AJP-FVXK6RGT.js +173 -0
  32. package/dist/OneDriveUploader-I25Y6AJP-FVXK6RGT.js.map +1 -0
  33. package/dist/OneDriveUploader-I25Y6AJP-GBOBEJQR.cjs +173 -0
  34. package/dist/OneDriveUploader-I25Y6AJP-GBOBEJQR.cjs.map +1 -0
  35. package/dist/ScreenCaptureUploader-WKDO4S75-3TT6GNEN.js +286 -0
  36. package/dist/ScreenCaptureUploader-WKDO4S75-3TT6GNEN.js.map +1 -0
  37. package/dist/ScreenCaptureUploader-WKDO4S75-G7ADH264.cjs +286 -0
  38. package/dist/ScreenCaptureUploader-WKDO4S75-G7ADH264.cjs.map +1 -0
  39. package/dist/chunk-2XFVSPFN.cjs +293 -0
  40. package/dist/chunk-2XFVSPFN.cjs.map +1 -0
  41. package/dist/chunk-7JLN2HMZ.cjs +4296 -0
  42. package/dist/chunk-7JLN2HMZ.cjs.map +1 -0
  43. package/dist/chunk-BVMKSTAE.js +4296 -0
  44. package/dist/chunk-BVMKSTAE.js.map +1 -0
  45. package/dist/chunk-C7QBCXAH.js +39 -0
  46. package/dist/chunk-C7QBCXAH.js.map +1 -0
  47. package/dist/chunk-CR6CXFRP.js +195 -0
  48. package/dist/chunk-CR6CXFRP.js.map +1 -0
  49. package/dist/chunk-ETIJATY7.cjs +39 -0
  50. package/dist/chunk-ETIJATY7.cjs.map +1 -0
  51. package/dist/chunk-FH3LYESR.js +411 -0
  52. package/dist/chunk-FH3LYESR.js.map +1 -0
  53. package/dist/chunk-GKMTOOTQ.cjs +411 -0
  54. package/dist/chunk-GKMTOOTQ.cjs.map +1 -0
  55. package/dist/chunk-KHH3WHWU.js +74 -0
  56. package/dist/chunk-KHH3WHWU.js.map +1 -0
  57. package/dist/chunk-V2O5HRJV.cjs +74 -0
  58. package/dist/chunk-V2O5HRJV.cjs.map +1 -0
  59. package/dist/chunk-WCI3AGJV.js +831 -0
  60. package/dist/chunk-WCI3AGJV.js.map +1 -0
  61. package/dist/chunk-YWJHE7U4.cjs +195 -0
  62. package/dist/chunk-YWJHE7U4.cjs.map +1 -0
  63. package/dist/chunk-ZGWETRKI.js +293 -0
  64. package/dist/chunk-ZGWETRKI.js.map +1 -0
  65. package/dist/chunk-ZKZJ5PPP.cjs +831 -0
  66. package/dist/chunk-ZKZJ5PPP.cjs.map +1 -0
  67. package/dist/filerobot-bridge-52YH7W2M.cjs +92 -0
  68. package/dist/filerobot-bridge-52YH7W2M.cjs.map +1 -0
  69. package/dist/filerobot-bridge-ED4XMHX4.js +92 -0
  70. package/dist/filerobot-bridge-ED4XMHX4.js.map +1 -0
  71. package/dist/filerobot-island.css +97 -0
  72. package/dist/filerobot-island.css.map +1 -0
  73. package/dist/filerobot-island.js +77951 -0
  74. package/dist/filerobot-island.js.map +1 -0
  75. package/dist/index.cjs +5600 -0
  76. package/dist/index.cjs.map +1 -0
  77. package/dist/index.d.cts +1 -0
  78. package/dist/index.d.ts +1 -0
  79. package/dist/index.js +5600 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/styles.d.ts +4 -0
  82. package/dist/tailwind-prefixed.css +2529 -0
  83. package/package.json +130 -0
@@ -0,0 +1,628 @@
1
+ import {
2
+ useFetchFileByUrl
3
+ } from "./chunk-KHH3WHWU.js";
4
+ import {
5
+ SourceViewContainer
6
+ } from "./chunk-C7QBCXAH.js";
7
+ import {
8
+ Fragment,
9
+ u,
10
+ useUploaderFiles,
11
+ useUploaderI18n,
12
+ useUploaderOptions,
13
+ useUploaderRuntime,
14
+ useUploaderSource,
15
+ useUploaderTheme
16
+ } from "./chunk-ZGWETRKI.js";
17
+ import {
18
+ __commonJS,
19
+ __toCommonJS,
20
+ __toESM,
21
+ compat_module_exports,
22
+ init_compat_module
23
+ } from "./chunk-FH3LYESR.js";
24
+
25
+ // ../../node_modules/.pnpm/react-webcam@7.2.0_react-do_f6f53b4eb3348eafa88c2f475ee8ac87/node_modules/react-webcam/dist/react-webcam.js
26
+ var require_react_webcam = __commonJS({
27
+ "../../node_modules/.pnpm/react-webcam@7.2.0_react-do_f6f53b4eb3348eafa88c2f475ee8ac87/node_modules/react-webcam/dist/react-webcam.js"(exports, module) {
28
+ "use strict";
29
+ (function webpackUniversalModuleDefinition(root, factory) {
30
+ if (typeof exports === "object" && typeof module === "object")
31
+ module.exports = factory((init_compat_module(), __toCommonJS(compat_module_exports)));
32
+ else if (typeof define === "function" && define.amd)
33
+ define(["react"], factory);
34
+ else if (typeof exports === "object")
35
+ exports["Webcam"] = factory((init_compat_module(), __toCommonJS(compat_module_exports)));
36
+ else
37
+ root["Webcam"] = factory(root["React"]);
38
+ })(exports, function(__WEBPACK_EXTERNAL_MODULE_react__) {
39
+ return (
40
+ /******/
41
+ (function(modules) {
42
+ var installedModules = {};
43
+ function __webpack_require__(moduleId) {
44
+ if (installedModules[moduleId]) {
45
+ return installedModules[moduleId].exports;
46
+ }
47
+ var module2 = installedModules[moduleId] = {
48
+ /******/
49
+ i: moduleId,
50
+ /******/
51
+ l: false,
52
+ /******/
53
+ exports: {}
54
+ /******/
55
+ };
56
+ modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
57
+ module2.l = true;
58
+ return module2.exports;
59
+ }
60
+ __webpack_require__.m = modules;
61
+ __webpack_require__.c = installedModules;
62
+ __webpack_require__.d = function(exports2, name, getter) {
63
+ if (!__webpack_require__.o(exports2, name)) {
64
+ Object.defineProperty(exports2, name, { enumerable: true, get: getter });
65
+ }
66
+ };
67
+ __webpack_require__.r = function(exports2) {
68
+ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
69
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
70
+ }
71
+ Object.defineProperty(exports2, "__esModule", { value: true });
72
+ };
73
+ __webpack_require__.t = function(value, mode) {
74
+ if (mode & 1) value = __webpack_require__(value);
75
+ if (mode & 8) return value;
76
+ if (mode & 4 && typeof value === "object" && value && value.__esModule) return value;
77
+ var ns = /* @__PURE__ */ Object.create(null);
78
+ __webpack_require__.r(ns);
79
+ Object.defineProperty(ns, "default", { enumerable: true, value });
80
+ if (mode & 2 && typeof value != "string") for (var key in value) __webpack_require__.d(ns, key, function(key2) {
81
+ return value[key2];
82
+ }.bind(null, key));
83
+ return ns;
84
+ };
85
+ __webpack_require__.n = function(module2) {
86
+ var getter = module2 && module2.__esModule ? (
87
+ /******/
88
+ function getDefault() {
89
+ return module2["default"];
90
+ }
91
+ ) : (
92
+ /******/
93
+ function getModuleExports() {
94
+ return module2;
95
+ }
96
+ );
97
+ __webpack_require__.d(getter, "a", getter);
98
+ return getter;
99
+ };
100
+ __webpack_require__.o = function(object, property) {
101
+ return Object.prototype.hasOwnProperty.call(object, property);
102
+ };
103
+ __webpack_require__.p = "";
104
+ return __webpack_require__(__webpack_require__.s = "./src/react-webcam.tsx");
105
+ })({
106
+ /***/
107
+ "./src/react-webcam.tsx": (
108
+ /*!******************************!*\
109
+ !*** ./src/react-webcam.tsx ***!
110
+ \******************************/
111
+ /*! exports provided: default */
112
+ /***/
113
+ (function(module2, __webpack_exports__, __webpack_require__) {
114
+ "use strict";
115
+ __webpack_require__.r(__webpack_exports__);
116
+ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
117
+ /*! react */
118
+ "react"
119
+ );
120
+ var react__WEBPACK_IMPORTED_MODULE_0___default = /* @__PURE__ */ __webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
121
+ var __extends = /* @__PURE__ */ (function() {
122
+ var extendStatics = function(d, b) {
123
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
124
+ d2.__proto__ = b2;
125
+ } || function(d2, b2) {
126
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
127
+ };
128
+ return extendStatics(d, b);
129
+ };
130
+ return function(d, b) {
131
+ extendStatics(d, b);
132
+ function __() {
133
+ this.constructor = d;
134
+ }
135
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
136
+ };
137
+ })();
138
+ var __assign = function() {
139
+ __assign = Object.assign || function(t2) {
140
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
141
+ s = arguments[i];
142
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
143
+ t2[p] = s[p];
144
+ }
145
+ return t2;
146
+ };
147
+ return __assign.apply(this, arguments);
148
+ };
149
+ var __rest = function(s, e) {
150
+ var t2 = {};
151
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
152
+ t2[p] = s[p];
153
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
154
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
155
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
156
+ t2[p[i]] = s[p[i]];
157
+ }
158
+ return t2;
159
+ };
160
+ (function polyfillGetUserMedia() {
161
+ if (typeof window === "undefined") {
162
+ return;
163
+ }
164
+ if (navigator.mediaDevices === void 0) {
165
+ navigator.mediaDevices = {};
166
+ }
167
+ if (navigator.mediaDevices.getUserMedia === void 0) {
168
+ navigator.mediaDevices.getUserMedia = function(constraints) {
169
+ var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
170
+ if (!getUserMedia) {
171
+ return Promise.reject(new Error("getUserMedia is not implemented in this browser"));
172
+ }
173
+ return new Promise(function(resolve, reject) {
174
+ getUserMedia.call(navigator, constraints, resolve, reject);
175
+ });
176
+ };
177
+ }
178
+ })();
179
+ function hasGetUserMedia() {
180
+ return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia);
181
+ }
182
+ var Webcam2 = (
183
+ /** @class */
184
+ (function(_super) {
185
+ __extends(Webcam3, _super);
186
+ function Webcam3(props) {
187
+ var _this = _super.call(this, props) || this;
188
+ _this.canvas = null;
189
+ _this.ctx = null;
190
+ _this.requestUserMediaId = 0;
191
+ _this.unmounted = false;
192
+ _this.state = {
193
+ hasUserMedia: false
194
+ };
195
+ return _this;
196
+ }
197
+ Webcam3.prototype.componentDidMount = function() {
198
+ var _a = this, state = _a.state, props = _a.props;
199
+ this.unmounted = false;
200
+ if (!hasGetUserMedia()) {
201
+ props.onUserMediaError("getUserMedia not supported");
202
+ return;
203
+ }
204
+ if (!state.hasUserMedia) {
205
+ this.requestUserMedia();
206
+ }
207
+ if (props.children && typeof props.children != "function") {
208
+ console.warn("children must be a function");
209
+ }
210
+ };
211
+ Webcam3.prototype.componentDidUpdate = function(nextProps) {
212
+ var props = this.props;
213
+ if (!hasGetUserMedia()) {
214
+ props.onUserMediaError("getUserMedia not supported");
215
+ return;
216
+ }
217
+ var audioConstraintsChanged = JSON.stringify(nextProps.audioConstraints) !== JSON.stringify(props.audioConstraints);
218
+ var videoConstraintsChanged = JSON.stringify(nextProps.videoConstraints) !== JSON.stringify(props.videoConstraints);
219
+ var minScreenshotWidthChanged = nextProps.minScreenshotWidth !== props.minScreenshotWidth;
220
+ var minScreenshotHeightChanged = nextProps.minScreenshotHeight !== props.minScreenshotHeight;
221
+ if (videoConstraintsChanged || minScreenshotWidthChanged || minScreenshotHeightChanged) {
222
+ this.canvas = null;
223
+ this.ctx = null;
224
+ }
225
+ if (audioConstraintsChanged || videoConstraintsChanged) {
226
+ this.stopAndCleanup();
227
+ this.requestUserMedia();
228
+ }
229
+ };
230
+ Webcam3.prototype.componentWillUnmount = function() {
231
+ this.unmounted = true;
232
+ this.stopAndCleanup();
233
+ };
234
+ Webcam3.stopMediaStream = function(stream) {
235
+ if (stream) {
236
+ if (stream.getVideoTracks && stream.getAudioTracks) {
237
+ stream.getVideoTracks().map(function(track) {
238
+ stream.removeTrack(track);
239
+ track.stop();
240
+ });
241
+ stream.getAudioTracks().map(function(track) {
242
+ stream.removeTrack(track);
243
+ track.stop();
244
+ });
245
+ } else {
246
+ stream.stop();
247
+ }
248
+ }
249
+ };
250
+ Webcam3.prototype.stopAndCleanup = function() {
251
+ var state = this.state;
252
+ if (state.hasUserMedia) {
253
+ Webcam3.stopMediaStream(this.stream);
254
+ if (state.src) {
255
+ window.URL.revokeObjectURL(state.src);
256
+ }
257
+ }
258
+ };
259
+ Webcam3.prototype.getScreenshot = function(screenshotDimensions) {
260
+ var _a = this, state = _a.state, props = _a.props;
261
+ if (!state.hasUserMedia)
262
+ return null;
263
+ var canvas = this.getCanvas(screenshotDimensions);
264
+ return canvas && canvas.toDataURL(props.screenshotFormat, props.screenshotQuality);
265
+ };
266
+ Webcam3.prototype.getCanvas = function(screenshotDimensions) {
267
+ var _a = this, state = _a.state, props = _a.props;
268
+ if (!this.video) {
269
+ return null;
270
+ }
271
+ if (!state.hasUserMedia || !this.video.videoHeight)
272
+ return null;
273
+ if (!this.ctx) {
274
+ var canvasWidth = this.video.videoWidth;
275
+ var canvasHeight = this.video.videoHeight;
276
+ if (!this.props.forceScreenshotSourceSize) {
277
+ var aspectRatio = canvasWidth / canvasHeight;
278
+ canvasWidth = props.minScreenshotWidth || this.video.clientWidth;
279
+ canvasHeight = canvasWidth / aspectRatio;
280
+ if (props.minScreenshotHeight && canvasHeight < props.minScreenshotHeight) {
281
+ canvasHeight = props.minScreenshotHeight;
282
+ canvasWidth = canvasHeight * aspectRatio;
283
+ }
284
+ }
285
+ this.canvas = document.createElement("canvas");
286
+ this.canvas.width = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.width) || canvasWidth;
287
+ this.canvas.height = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.height) || canvasHeight;
288
+ this.ctx = this.canvas.getContext("2d");
289
+ }
290
+ var _b = this, ctx = _b.ctx, canvas = _b.canvas;
291
+ if (ctx && canvas) {
292
+ canvas.width = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.width) || canvas.width;
293
+ canvas.height = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.height) || canvas.height;
294
+ if (props.mirrored) {
295
+ ctx.translate(canvas.width, 0);
296
+ ctx.scale(-1, 1);
297
+ }
298
+ ctx.imageSmoothingEnabled = props.imageSmoothing;
299
+ ctx.drawImage(this.video, 0, 0, (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.width) || canvas.width, (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.height) || canvas.height);
300
+ if (props.mirrored) {
301
+ ctx.scale(-1, 1);
302
+ ctx.translate(-canvas.width, 0);
303
+ }
304
+ }
305
+ return canvas;
306
+ };
307
+ Webcam3.prototype.requestUserMedia = function() {
308
+ var _this = this;
309
+ var props = this.props;
310
+ var sourceSelected = function(audioConstraints, videoConstraints) {
311
+ var constraints = {
312
+ video: typeof videoConstraints !== "undefined" ? videoConstraints : true
313
+ };
314
+ if (props.audio) {
315
+ constraints.audio = typeof audioConstraints !== "undefined" ? audioConstraints : true;
316
+ }
317
+ _this.requestUserMediaId++;
318
+ var myRequestUserMediaId = _this.requestUserMediaId;
319
+ navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
320
+ if (_this.unmounted || myRequestUserMediaId !== _this.requestUserMediaId) {
321
+ Webcam3.stopMediaStream(stream);
322
+ } else {
323
+ _this.handleUserMedia(null, stream);
324
+ }
325
+ }).catch(function(e) {
326
+ _this.handleUserMedia(e);
327
+ });
328
+ };
329
+ if ("mediaDevices" in navigator) {
330
+ sourceSelected(props.audioConstraints, props.videoConstraints);
331
+ } else {
332
+ var optionalSource_1 = function(id) {
333
+ return { optional: [{ sourceId: id }] };
334
+ };
335
+ var constraintToSourceId_1 = function(constraint) {
336
+ var deviceId = constraint.deviceId;
337
+ if (typeof deviceId === "string") {
338
+ return deviceId;
339
+ }
340
+ if (Array.isArray(deviceId) && deviceId.length > 0) {
341
+ return deviceId[0];
342
+ }
343
+ if (typeof deviceId === "object" && deviceId.ideal) {
344
+ return deviceId.ideal;
345
+ }
346
+ return null;
347
+ };
348
+ MediaStreamTrack.getSources(function(sources) {
349
+ var audioSource = null;
350
+ var videoSource = null;
351
+ sources.forEach(function(source) {
352
+ if (source.kind === "audio") {
353
+ audioSource = source.id;
354
+ } else if (source.kind === "video") {
355
+ videoSource = source.id;
356
+ }
357
+ });
358
+ var audioSourceId = constraintToSourceId_1(props.audioConstraints);
359
+ if (audioSourceId) {
360
+ audioSource = audioSourceId;
361
+ }
362
+ var videoSourceId = constraintToSourceId_1(props.videoConstraints);
363
+ if (videoSourceId) {
364
+ videoSource = videoSourceId;
365
+ }
366
+ sourceSelected(optionalSource_1(audioSource), optionalSource_1(videoSource));
367
+ });
368
+ }
369
+ };
370
+ Webcam3.prototype.handleUserMedia = function(err, stream) {
371
+ var props = this.props;
372
+ if (err || !stream) {
373
+ this.setState({ hasUserMedia: false });
374
+ props.onUserMediaError(err);
375
+ return;
376
+ }
377
+ this.stream = stream;
378
+ try {
379
+ if (this.video) {
380
+ this.video.srcObject = stream;
381
+ }
382
+ this.setState({ hasUserMedia: true });
383
+ } catch (error) {
384
+ this.setState({
385
+ hasUserMedia: true,
386
+ src: window.URL.createObjectURL(stream)
387
+ });
388
+ }
389
+ props.onUserMedia(stream);
390
+ };
391
+ Webcam3.prototype.render = function() {
392
+ var _this = this;
393
+ var _a = this, state = _a.state, props = _a.props;
394
+ var audio = props.audio, forceScreenshotSourceSize = props.forceScreenshotSourceSize, disablePictureInPicture = props.disablePictureInPicture, onUserMedia = props.onUserMedia, onUserMediaError = props.onUserMediaError, screenshotFormat = props.screenshotFormat, screenshotQuality = props.screenshotQuality, minScreenshotWidth = props.minScreenshotWidth, minScreenshotHeight = props.minScreenshotHeight, audioConstraints = props.audioConstraints, videoConstraints = props.videoConstraints, imageSmoothing = props.imageSmoothing, mirrored = props.mirrored, _b = props.style, style = _b === void 0 ? {} : _b, children = props.children, rest = __rest(props, ["audio", "forceScreenshotSourceSize", "disablePictureInPicture", "onUserMedia", "onUserMediaError", "screenshotFormat", "screenshotQuality", "minScreenshotWidth", "minScreenshotHeight", "audioConstraints", "videoConstraints", "imageSmoothing", "mirrored", "style", "children"]);
395
+ var videoStyle = mirrored ? __assign(__assign({}, style), { transform: (style.transform || "") + " scaleX(-1)" }) : style;
396
+ var childrenProps = {
397
+ getScreenshot: this.getScreenshot.bind(this)
398
+ };
399
+ return react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
400
+ react__WEBPACK_IMPORTED_MODULE_0__["Fragment"],
401
+ null,
402
+ react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("video", __assign({ autoPlay: true, disablePictureInPicture, src: state.src, muted: !audio, playsInline: true, ref: function(ref) {
403
+ _this.video = ref;
404
+ }, style: videoStyle }, rest)),
405
+ children && children(childrenProps)
406
+ );
407
+ };
408
+ Webcam3.defaultProps = {
409
+ audio: false,
410
+ disablePictureInPicture: false,
411
+ forceScreenshotSourceSize: false,
412
+ imageSmoothing: true,
413
+ mirrored: false,
414
+ onUserMedia: function() {
415
+ return void 0;
416
+ },
417
+ onUserMediaError: function() {
418
+ return void 0;
419
+ },
420
+ screenshotFormat: "image/webp",
421
+ screenshotQuality: 0.92
422
+ };
423
+ return Webcam3;
424
+ })(react__WEBPACK_IMPORTED_MODULE_0__["Component"])
425
+ );
426
+ __webpack_exports__["default"] = Webcam2;
427
+ })
428
+ ),
429
+ /***/
430
+ "react": (
431
+ /*!**************************************************************************************!*\
432
+ !*** external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"} ***!
433
+ \**************************************************************************************/
434
+ /*! no static exports found */
435
+ /***/
436
+ (function(module2, exports2) {
437
+ module2.exports = __WEBPACK_EXTERNAL_MODULE_react__;
438
+ })
439
+ )
440
+ /******/
441
+ })["default"]
442
+ );
443
+ });
444
+ }
445
+ });
446
+
447
+ // ../react/dist/CameraUploader-WF5A6UIS.js
448
+ var import_react_webcam = __toESM(require_react_webcam(), 1);
449
+ init_compat_module();
450
+ import { formatUiMessage as t } from "@useupup/core";
451
+ import { cn } from "@useupup/core/internal";
452
+ function useCameraUploader() {
453
+ const { core } = useUploaderRuntime();
454
+ const { setFiles } = useUploaderFiles();
455
+ const { setActiveSource } = useUploaderSource();
456
+ const { translations } = useUploaderI18n();
457
+ const props = useUploaderOptions();
458
+ const theme = useUploaderTheme();
459
+ const { fetchImage } = useFetchFileByUrl();
460
+ const webcamRef = (0, compat_module_exports.useRef)(null);
461
+ const [url, setUrl] = (0, compat_module_exports.useState)("");
462
+ const [facingMode, setFacingMode] = (0, compat_module_exports.useState)(
463
+ "environment"
464
+ /* Environment */
465
+ );
466
+ const newCameraSide = facingMode === "environment" ? "front" : "back";
467
+ const clearUrl = () => {
468
+ setUrl("");
469
+ };
470
+ const capture = () => {
471
+ var _a;
472
+ const url2 = (_a = webcamRef.current) == null ? void 0 : _a.getScreenshot();
473
+ if (!url2) return;
474
+ setUrl(url2);
475
+ core == null ? void 0 : core.emit("camera-capture", { dataUrl: url2 });
476
+ };
477
+ const handleFetchImage = () => {
478
+ void (async () => {
479
+ const file = await fetchImage(url);
480
+ if (file) {
481
+ setFiles([file]);
482
+ setUrl("");
483
+ setActiveSource(void 0);
484
+ core == null ? void 0 : core.emit("camera-confirm", { file });
485
+ }
486
+ })();
487
+ };
488
+ const handleCameraSwitch = () => {
489
+ setFacingMode(
490
+ (prevState) => prevState === "environment" ? "user" : "environment"
491
+ /* Environment */
492
+ );
493
+ };
494
+ return {
495
+ url,
496
+ webcamRef,
497
+ facingMode,
498
+ capture,
499
+ handleFetchImage,
500
+ clearUrl,
501
+ handleCameraSwitch,
502
+ newCameraSide,
503
+ translations,
504
+ props,
505
+ theme
506
+ };
507
+ }
508
+ function CameraUploader() {
509
+ const {
510
+ capture,
511
+ handleFetchImage,
512
+ clearUrl,
513
+ handleCameraSwitch,
514
+ newCameraSide,
515
+ url,
516
+ webcamRef,
517
+ facingMode,
518
+ translations: tr,
519
+ props: {
520
+ icons: { CameraCaptureIcon, CameraDeleteIcon, CameraRotateIcon }
521
+ },
522
+ theme: { isDark: dark, slotOverrides: slotClasses }
523
+ } = useCameraUploader();
524
+ return /* @__PURE__ */ u(SourceViewContainer, { "data-upup-slot": "camera-uploader", children: /* @__PURE__ */ u(
525
+ "div",
526
+ {
527
+ "data-testid": "upup-camera-uploader",
528
+ className: "upup-flex upup-h-full upup-w-full upup-flex-col upup-justify-center upup-overflow-hidden upup-px-3 upup-py-2",
529
+ children: [
530
+ /* @__PURE__ */ u("div", { className: "upup-flex upup-min-h-0 upup-flex-1 upup-items-center upup-justify-center upup-pt-2", children: [
531
+ !!url && /* @__PURE__ */ u(
532
+ "div",
533
+ {
534
+ className: cn(
535
+ "upup-relative upup-aspect-video upup-max-h-full upup-max-w-full upup-bg-black/[0.025] upup-bg-contain upup-bg-center upup-bg-no-repeat upup-shadow-xl",
536
+ {
537
+ "upup-bg-white/5 dark:upup-bg-white/5": dark
538
+ },
539
+ slotClasses.cameraPreviewContainer
540
+ ),
541
+ style: { backgroundImage: `url(${url})` },
542
+ children: /* @__PURE__ */ u(
543
+ "button",
544
+ {
545
+ onClick: clearUrl,
546
+ className: cn(
547
+ "upup-absolute upup--right-2 upup--top-2 upup-z-10 upup-rounded-full upup-bg-[#272727] upup-p-1 upup-text-xl upup-text-[#f5f5f5]",
548
+ slotClasses.cameraDeleteButton
549
+ ),
550
+ type: "button",
551
+ children: /* @__PURE__ */ u(CameraDeleteIcon, {})
552
+ }
553
+ )
554
+ }
555
+ ),
556
+ !url && /* @__PURE__ */ u(
557
+ import_react_webcam.default,
558
+ {
559
+ audio: false,
560
+ ref: webcamRef,
561
+ screenshotFormat: "image/jpeg",
562
+ videoConstraints: { facingMode },
563
+ className: "upup-aspect-video upup-max-h-full upup-max-w-full upup-rounded-xl upup-object-contain"
564
+ }
565
+ )
566
+ ] }),
567
+ /* @__PURE__ */ u("div", { className: "upup-flex upup-shrink-0 upup-gap-4", children: [
568
+ !url && /* @__PURE__ */ u(Fragment, { children: [
569
+ /* @__PURE__ */ u(
570
+ "button",
571
+ {
572
+ className: cn(
573
+ "upup-mt-2 upup-flex upup-w-1/3 upup-flex-col upup-items-center upup-justify-center upup-rounded-md upup-bg-[#0ea5e9] upup-p-2 upup-text-white upup-transition-all upup-duration-300",
574
+ {
575
+ "upup-bg-[#38bdf8] dark:upup-bg-[#38bdf8]": dark
576
+ },
577
+ slotClasses.cameraCaptureButton
578
+ ),
579
+ onClick: capture,
580
+ type: "button",
581
+ children: [
582
+ /* @__PURE__ */ u("span", { children: /* @__PURE__ */ u(CameraCaptureIcon, {}) }),
583
+ /* @__PURE__ */ u("span", { children: tr.capture })
584
+ ]
585
+ }
586
+ ),
587
+ /* @__PURE__ */ u(
588
+ "button",
589
+ {
590
+ className: cn(
591
+ "upup-mt-2 upup-flex upup-w-1/3 upup-flex-col upup-items-center upup-rounded-md upup-bg-gray-500 upup-p-2 upup-text-white upup-transition-all upup-duration-300 hover:upup-bg-gray-600",
592
+ slotClasses.cameraRotateButton
593
+ ),
594
+ onClick: handleCameraSwitch,
595
+ type: "button",
596
+ children: [
597
+ /* @__PURE__ */ u("span", { children: /* @__PURE__ */ u(CameraRotateIcon, {}) }),
598
+ /* @__PURE__ */ u("span", { children: t(tr.switchToCamera, {
599
+ side: newCameraSide === "front" ? tr.front : tr.back
600
+ }) })
601
+ ]
602
+ }
603
+ )
604
+ ] }),
605
+ !!url && /* @__PURE__ */ u(
606
+ "button",
607
+ {
608
+ className: cn(
609
+ "upup-mt-2 upup-w-full upup-rounded-md upup-bg-[#0ea5e9] upup-p-2 upup-text-white upup-transition-all upup-duration-300",
610
+ {
611
+ "upup-bg-[#38bdf8] dark:upup-bg-[#38bdf8]": dark
612
+ },
613
+ slotClasses.cameraAddButton
614
+ ),
615
+ onClick: handleFetchImage,
616
+ type: "button",
617
+ children: tr.addImage
618
+ }
619
+ )
620
+ ] })
621
+ ]
622
+ }
623
+ ) });
624
+ }
625
+ export {
626
+ CameraUploader as default
627
+ };
628
+ //# sourceMappingURL=CameraUploader-WF5A6UIS-DONVXSEZ.js.map