sanity-plugin-mux-input 1.2.0-main.3 → 1.2.0-main.4

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.
package/lib/cjs/index.js CHANGED
@@ -1,11 +1,26 @@
1
1
  var $dyHF6$reactjsxruntime = require("react/jsx-runtime");
2
- var $dyHF6$sanityui = require("@sanity/ui");
3
2
  var $dyHF6$react = require("react");
4
- var $dyHF6$styledcomponents = require("styled-components");
5
3
  var $dyHF6$sanity = require("sanity");
4
+ var $dyHF6$sanityui = require("@sanity/ui");
6
5
  var $dyHF6$scrollintoviewifneeded = require("scroll-into-view-if-needed");
7
6
  var $dyHF6$suspendreact = require("suspend-react");
8
7
  var $dyHF6$useerrorboundary = require("use-error-boundary");
8
+ var $dyHF6$sanity_unstable = require("sanity/_unstable");
9
+ var $dyHF6$swr = require("swr");
10
+ var $dyHF6$rxjs = require("rxjs");
11
+ var $dyHF6$rxjsoperators = require("rxjs/operators");
12
+ var $dyHF6$sanityform = require("sanity/form");
13
+ var $dyHF6$sanityuuid = require("@sanity/uuid");
14
+ var $dyHF6$muxupchunk = require("@mux/upchunk");
15
+ var $dyHF6$reachautoid = require("@reach/auto-id");
16
+ var $dyHF6$sanityicons = require("@sanity/icons");
17
+ var $dyHF6$motion = require("motion");
18
+ var $dyHF6$styledcomponents = require("styled-components");
19
+ var $dyHF6$usedevicepixelratio = require("use-device-pixel-ratio");
20
+ var $dyHF6$jsonwebtokenesmsign = require("jsonwebtoken-esm/sign");
21
+ var $dyHF6$muxplaybackcore = require("@mux/playback-core");
22
+ var $dyHF6$mediachromedistreact = require("media-chrome/dist/react");
23
+ var $dyHF6$reactis = require("react-is");
9
24
 
10
25
  function $parcel$export(e, n, v, s) {
11
26
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
@@ -13,122 +28,12 @@ function $parcel$export(e, n, v, s) {
13
28
  function $parcel$interopDefault(a) {
14
29
  return a && a.__esModule ? a.default : a;
15
30
  }
16
- var $parcel$global =
17
- typeof globalThis !== 'undefined'
18
- ? globalThis
19
- : typeof self !== 'undefined'
20
- ? self
21
- : typeof window !== 'undefined'
22
- ? window
23
- : typeof global !== 'undefined'
24
- ? global
25
- : {};
26
- var $parcel$modules = {};
27
- var $parcel$inits = {};
28
-
29
- var parcelRequire = $parcel$global["parcelRequire4c51"];
30
- if (parcelRequire == null) {
31
- parcelRequire = function(id) {
32
- if (id in $parcel$modules) {
33
- return $parcel$modules[id].exports;
34
- }
35
- if (id in $parcel$inits) {
36
- var init = $parcel$inits[id];
37
- delete $parcel$inits[id];
38
- var module = {id: id, exports: {}};
39
- $parcel$modules[id] = module;
40
- init.call(module.exports, module, module.exports);
41
- return module.exports;
42
- }
43
- var err = new Error("Cannot find module '" + id + "'");
44
- err.code = 'MODULE_NOT_FOUND';
45
- throw err;
46
- };
47
-
48
- parcelRequire.register = function register(id, init) {
49
- $parcel$inits[id] = init;
50
- };
51
-
52
- $parcel$global["parcelRequire4c51"] = parcelRequire;
53
- }
54
- parcelRequire.register("bf6Cb", function(module, exports) {
55
-
56
- $parcel$export(module.exports, "name", () => $2ffcb7ef2a4a67d0$export$a8ff84c12d48cfa6);
57
- $parcel$export(module.exports, "cacheNs", () => $2ffcb7ef2a4a67d0$export$13cdb654d47e0703);
58
- $parcel$export(module.exports, "muxSecretsDocumentId", () => $2ffcb7ef2a4a67d0$export$64952397958089dd);
59
- const $2ffcb7ef2a4a67d0$export$a8ff84c12d48cfa6 = "mux-input";
60
- const $2ffcb7ef2a4a67d0$export$13cdb654d47e0703 = "sanity-plugin-mux-input";
61
- const $2ffcb7ef2a4a67d0$export$64952397958089dd = "secrets.mux";
62
-
63
- });
64
-
65
- parcelRequire.register("3PT7X", function(module, exports) {
66
-
67
- $parcel$export(module.exports, "AspectRatioCard", () => $5f180d117773fee7$export$f0c88bc5a320387d);
68
- $parcel$export(module.exports, "InputFallback", () => $5f180d117773fee7$export$18fe723e8683ca03);
69
-
70
-
71
-
72
-
73
- const $5f180d117773fee7$export$f0c88bc5a320387d = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
74
- aspect-ratio: 16 / 9;
75
- position: relative;
76
- width: 100%;
77
- `;
78
- const $5f180d117773fee7$export$18fe723e8683ca03 = ()=>{
79
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
80
- style: {
81
- padding: 1
82
- },
83
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
84
- shadow: 1,
85
- sizing: "border",
86
- style: {
87
- aspectRatio: "16/9",
88
- width: "100%",
89
- borderRadius: "1px"
90
- },
91
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
92
- align: "center",
93
- direction: "column",
94
- height: "fill",
95
- justify: "center",
96
- children: [
97
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {
98
- muted: true
99
- }),
100
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
101
- marginTop: 3,
102
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
103
- align: "center",
104
- muted: true,
105
- size: 1,
106
- children: "Loading\u2026"
107
- })
108
- })
109
- ]
110
- })
111
- })
112
- });
113
- };
114
-
115
- });
116
31
 
117
- parcelRequire.register("4M4Xk", function(module, exports) {
118
- module.exports = Promise.resolve(require("./Input.832bb406.js")).then(()=>parcelRequire("lo0FW"));
119
-
120
- });
121
-
122
- parcelRequire.register("2vLfV", function(module, exports) {
123
- module.exports = Promise.resolve(require("./Preview.3e13819d.js")).then(()=>parcelRequire("cjJaV"));
124
-
125
- });
126
-
127
-
128
- $parcel$export(module.exports, "Input", () => $329a1cedcedb1349$export$f5b8910cec6cf069);
129
- $parcel$export(module.exports, "Preview", () => $329a1cedcedb1349$export$133773870222880f);
130
32
  $parcel$export(module.exports, "defaultConfig", () => $329a1cedcedb1349$export$f84bd70098573c5c);
131
33
  $parcel$export(module.exports, "muxInput", () => $329a1cedcedb1349$export$4d2e76c338bb9fbd);
34
+ $parcel$export(module.exports, "Input", () => $6bca891f5dd9dfc9$export$2e2bcd8739ae039);
35
+ $parcel$export(module.exports, "Preview", () => $cbaf0acf64ca3573$export$2e2bcd8739ae039);
36
+
132
37
 
133
38
 
134
39
 
@@ -137,9 +42,11 @@ $parcel$export(module.exports, "muxInput", () => $329a1cedcedb1349$export$4d2e76
137
42
 
138
43
 
139
44
 
45
+ const $2ffcb7ef2a4a67d0$export$a8ff84c12d48cfa6 = "mux-input";
46
+ const $2ffcb7ef2a4a67d0$export$13cdb654d47e0703 = "sanity-plugin-mux-input";
47
+ const $2ffcb7ef2a4a67d0$export$64952397958089dd = "secrets.mux";
140
48
 
141
49
 
142
- var $bf6Cb = parcelRequire("bf6Cb");
143
50
  function $440e5e6a7a1a5e7d$var$ErrorBoundaryCard(props) {
144
51
  const { children: children , schemaType: schemaType } = props;
145
52
  const { push: pushToast } = (0, $dyHF6$sanityui.useToast)();
@@ -195,7 +102,7 @@ function $440e5e6a7a1a5e7d$var$ErrorBoundaryCard(props) {
195
102
  const handleRetry = (0, $dyHF6$react.useCallback)(()=>{
196
103
  // Purge request cache before retrying, otherwise the cached errors will rethrow
197
104
  (0, $dyHF6$suspendreact.clear)([
198
- (0, $bf6Cb.name)
105
+ (0, $2ffcb7ef2a4a67d0$export$a8ff84c12d48cfa6)
199
106
  ]);
200
107
  reset();
201
108
  }, [
@@ -230,7 +137,7 @@ function $440e5e6a7a1a5e7d$var$ErrorBoundaryCard(props) {
230
137
  children: [
231
138
  "The ",
232
139
  /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("code", {
233
- children: (0, $bf6Cb.name)
140
+ children: (0, $2ffcb7ef2a4a67d0$export$a8ff84c12d48cfa6)
234
141
  }),
235
142
  " plugin crashed"
236
143
  ]
@@ -262,77 +169,3758 @@ var $440e5e6a7a1a5e7d$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $dyHF6$react.me
262
169
 
263
170
 
264
171
 
265
- var $3PT7X = parcelRequire("3PT7X");
266
172
 
267
173
 
268
- const $75523cdda380b780$export$a8ff84c12d48cfa6 = "mux.videoAsset";
269
- const $75523cdda380b780$var$videoAsset = (0, $dyHF6$sanity.defineField)({
270
- name: $75523cdda380b780$export$a8ff84c12d48cfa6,
271
- type: "object",
272
- title: "Video asset",
273
- fields: [
274
- {
275
- type: "string",
276
- name: "status"
277
- },
278
- {
279
- type: "string",
280
- name: "assetId"
281
- },
282
- {
283
- type: "string",
284
- name: "playbackId"
285
- },
286
- {
287
- type: "string",
288
- name: "filename"
289
- },
290
- {
291
- type: "number",
292
- name: "thumbTime"
293
- },
294
- ]
295
- });
296
- var $75523cdda380b780$export$2e2bcd8739ae039 = $75523cdda380b780$var$videoAsset;
297
174
 
298
175
 
299
- const $ac55e63956aa9e84$export$a8ff84c12d48cfa6 = "mux.video";
300
- const $ac55e63956aa9e84$var$video = (0, $dyHF6$sanity.defineField)({
301
- name: $ac55e63956aa9e84$export$a8ff84c12d48cfa6,
302
- type: "object",
303
- title: "Video asset reference",
304
- fields: [
305
- {
306
- title: "Video",
307
- name: "asset",
308
- type: "reference",
309
- weak: true,
310
- to: [
311
- {
312
- type: (0, $75523cdda380b780$export$a8ff84c12d48cfa6)
313
- }
314
- ]
315
- },
316
- ]
317
- });
318
- var $ac55e63956aa9e84$export$2e2bcd8739ae039 = $ac55e63956aa9e84$var$video;
176
+ const $eef844dd0892040d$var$path = [
177
+ "assetId",
178
+ "data",
179
+ "playbackId",
180
+ "status",
181
+ "thumbTime",
182
+ "filename"
183
+ ];
184
+ const $eef844dd0892040d$export$e11a382d55e07f75 = (asset)=>(0, $dyHF6$sanity_unstable.useDocumentValues)((0, $dyHF6$sanity.isReference)(asset) ? asset._ref : "", $eef844dd0892040d$var$path);
319
185
 
320
186
 
321
187
 
188
+ function $af23ed16e7325a21$export$573903f1c655c034() {
189
+ return (0, $dyHF6$react.useState)(false);
190
+ }
322
191
 
323
192
 
324
- function $0c6ceed5d95aa3e9$export$c8119cbbd1c84da1(props) {
325
- return (0, $dyHF6$sanity.isObjectSchemaType)(props.schemaType) && props.schemaType.type?.name === (0, $ac55e63956aa9e84$export$a8ff84c12d48cfa6);
193
+
194
+
195
+
196
+ const $9427a85db5895988$export$fd270df25d7dbb88 = (asset)=>{
197
+ const client = (0, $dyHF6$sanity.useClient)();
198
+ const projectId = (0, $dyHF6$sanity.useProjectId)();
199
+ const dataset = (0, $dyHF6$sanity.useDataset)();
200
+ const shouldFetch = (0, $dyHF6$react.useMemo)(()=>!!asset?.assetId && (asset?.status === "preparing" || asset?.data?.static_renditions?.status === "preparing"), [
201
+ asset?.assetId,
202
+ asset?.data?.static_renditions?.status,
203
+ asset?.status
204
+ ]);
205
+ return (0, ($parcel$interopDefault($dyHF6$swr)))(shouldFetch ? `/${projectId}/addons/mux/assets/${dataset}/data/${asset?.assetId}` : null, async ()=>{
206
+ const { data: data } = await client.request({
207
+ url: `/addons/mux/assets/${dataset}/data/${asset.assetId}`,
208
+ withCredentials: true,
209
+ method: "GET"
210
+ });
211
+ client.patch(asset._id).set({
212
+ status: data.status,
213
+ data: data
214
+ }).commit({
215
+ returnDocuments: false
216
+ });
217
+ }, {
218
+ refreshInterval: 2000,
219
+ refreshWhenHidden: true,
220
+ dedupingInterval: 1000
221
+ });
222
+ };
223
+
224
+
225
+
226
+
227
+
228
+ const $8a0ef7d2f7c4ca7e$var$path = [
229
+ "token",
230
+ "secretKey",
231
+ "enableSignedUrls",
232
+ "signingKeyId",
233
+ "signingKeyPrivate"
234
+ ];
235
+ const $8a0ef7d2f7c4ca7e$export$4c2801830a129eb = ()=>{
236
+ const { error: error , isLoading: isLoading , value: value } = (0, $dyHF6$sanity_unstable.useDocumentValues)((0, $2ffcb7ef2a4a67d0$export$64952397958089dd), $8a0ef7d2f7c4ca7e$var$path);
237
+ const cache = (0, $dyHF6$react.useMemo)(()=>{
238
+ const exists = Boolean(value);
239
+ const secrets = {
240
+ token: value?.token || null,
241
+ secretKey: value?.secretKey || null,
242
+ enableSignedUrls: value?.enableSignedUrls || false,
243
+ signingKeyId: value?.signingKeyId || null,
244
+ signingKeyPrivate: value?.signingKeyPrivate || null
245
+ };
246
+ return {
247
+ isInitialSetup: !exists,
248
+ needsSetup: !secrets?.token || !secrets?.secretKey,
249
+ secrets: secrets
250
+ };
251
+ }, [
252
+ value
253
+ ]);
254
+ return {
255
+ error: error,
256
+ isLoading: isLoading,
257
+ value: cache
258
+ };
259
+ };
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+ function $3dde8b7caa07e0e7$export$ad6eab20b4b3876f(uuid, uploadUrl, source) {
273
+ return new (0, $dyHF6$rxjs.Observable)((subscriber)=>{
274
+ const upchunk = $dyHF6$muxupchunk.createUpload({
275
+ endpoint: uploadUrl,
276
+ file: source,
277
+ chunkSize: 30720
278
+ });
279
+ const successHandler = ()=>{
280
+ subscriber.next({
281
+ type: "success",
282
+ id: uuid
283
+ });
284
+ subscriber.complete();
285
+ };
286
+ const errorHandler = (data)=>subscriber.error(new Error(data.detail.message));
287
+ const progressHandler = (data)=>{
288
+ return subscriber.next({
289
+ type: "progress",
290
+ percent: data.detail
291
+ });
292
+ };
293
+ const offlineHandler = ()=>{
294
+ upchunk.pause();
295
+ subscriber.next({
296
+ type: "pause",
297
+ id: uuid
298
+ });
299
+ };
300
+ const onlineHandler = ()=>{
301
+ upchunk.resume();
302
+ subscriber.next({
303
+ type: "resume",
304
+ id: uuid
305
+ });
306
+ };
307
+ upchunk.on("success", successHandler);
308
+ upchunk.on("error", errorHandler);
309
+ upchunk.on("progress", progressHandler);
310
+ upchunk.on("offline", offlineHandler);
311
+ upchunk.on("online", onlineHandler);
312
+ return ()=>upchunk.abort();
313
+ });
326
314
  }
327
- function $0c6ceed5d95aa3e9$export$3542974c36e4d83f(props) {
328
- return props.schemaType.type?.name === (0, $ac55e63956aa9e84$export$a8ff84c12d48cfa6);
315
+
316
+
317
+ function $a0485042ac477352$export$df987b50509121ea(client, assetId) {
318
+ const { dataset: dataset } = client.config();
319
+ return client.request({
320
+ url: `/addons/mux/assets/${dataset}/${assetId}`,
321
+ withCredentials: true,
322
+ method: "DELETE"
323
+ });
324
+ }
325
+ function $a0485042ac477352$export$da446a5ee2572b7(client, assetId) {
326
+ const { dataset: dataset } = client.config();
327
+ return client.request({
328
+ url: `/addons/mux/assets/${dataset}/data/${assetId}`,
329
+ withCredentials: true,
330
+ method: "GET"
331
+ });
332
+ }
333
+
334
+
335
+
336
+ function $58acdddf66edce65$export$f16c6d66b9790f06(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate) {
337
+ const doc = {
338
+ _id: "secrets.mux",
339
+ _type: "mux.apiKey",
340
+ token: token,
341
+ secretKey: secretKey,
342
+ enableSignedUrls: enableSignedUrls,
343
+ signingKeyId: signingKeyId,
344
+ signingKeyPrivate: signingKeyPrivate
345
+ };
346
+ return client.createOrReplace(doc);
347
+ }
348
+ function $58acdddf66edce65$export$21cc0cab779cfac1(client) {
349
+ const { dataset: dataset } = client.config();
350
+ return client.request({
351
+ url: `/addons/mux/signing-keys/${dataset}`,
352
+ withCredentials: true,
353
+ method: "POST"
354
+ });
355
+ }
356
+ function $58acdddf66edce65$export$3a1df1322191b3ef(client) {
357
+ const { dataset: dataset } = client.config();
358
+ return client.request({
359
+ url: `/addons/mux/secrets/${dataset}/test`,
360
+ withCredentials: true,
361
+ method: "GET"
362
+ });
363
+ }
364
+ async function $58acdddf66edce65$export$f5836111430d17bc(client, signingKeyId, signingKeyPrivate) {
365
+ if (!(signingKeyId && signingKeyPrivate)) return false;
366
+ const { dataset: dataset } = client.config();
367
+ try {
368
+ const res = await client.request({
369
+ url: `/addons/mux/signing-keys/${dataset}/${signingKeyId}`,
370
+ withCredentials: true,
371
+ method: "GET"
372
+ });
373
+ //
374
+ // if this signing key is valid it will return { data: { id: 'xxxx' } }
375
+ //
376
+ return !!(res.data && res.data.id);
377
+ } catch (e) {
378
+ console.error("Error fetching signingKeyId", signingKeyId, "assuming it is not valid");
379
+ return false;
380
+ }
381
+ }
382
+ function $58acdddf66edce65$export$7d1f83854429bc73(client) {
383
+ const { dataset: dataset } = client.config();
384
+ return (0, $dyHF6$rxjs.defer)(()=>client.observable.request({
385
+ url: `/addons/mux/secrets/${dataset}/test`,
386
+ withCredentials: true,
387
+ method: "GET"
388
+ }));
389
+ }
390
+
391
+
392
+ function $4a210fa13f9688e9$export$5130fb4c263997a4(client, uuid) {
393
+ return client.observable.request({
394
+ url: `/addons/mux/uploads/${client.clientConfig.dataset}/${uuid}`,
395
+ withCredentials: true,
396
+ method: "DELETE"
397
+ });
398
+ }
399
+ function $4a210fa13f9688e9$export$f35af194eb27b25f(config, client, url, options = {}) {
400
+ return $4a210fa13f9688e9$var$testUrl(url).pipe((0, $dyHF6$rxjsoperators.switchMap)((validUrl)=>{
401
+ return (0, $dyHF6$rxjs.concat)((0, $dyHF6$rxjs.of)({
402
+ type: "url",
403
+ url: validUrl
404
+ }), (0, $58acdddf66edce65$export$7d1f83854429bc73)(client).pipe((0, $dyHF6$rxjsoperators.switchMap)((json)=>{
405
+ if (!json || !json.status) return (0, $dyHF6$rxjs.throwError)(new Error("Invalid credentials"));
406
+ const uuid = (0, $dyHF6$sanityuuid.uuid)();
407
+ const { enableSignedUrls: enableSignedUrls } = options;
408
+ const muxBody = {
409
+ input: validUrl,
410
+ playback_policy: [
411
+ enableSignedUrls ? "signed" : "public"
412
+ ],
413
+ mp4_support: config.mp4_support
414
+ };
415
+ const query = {
416
+ muxBody: JSON.stringify(muxBody),
417
+ filename: validUrl.split("/").slice(-1)[0]
418
+ };
419
+ const dataset = client.clientConfig.dataset;
420
+ return (0, $dyHF6$rxjs.defer)(()=>client.observable.request({
421
+ url: `/addons/mux/assets/${dataset}`,
422
+ withCredentials: true,
423
+ method: "POST",
424
+ headers: {
425
+ "MUX-Proxy-UUID": uuid,
426
+ "Content-Type": "application/json"
427
+ },
428
+ query: query
429
+ })).pipe((0, $dyHF6$rxjsoperators.mergeMap)((result)=>{
430
+ const asset = result && result.results && result.results[0] && result.results[0].document || null;
431
+ if (!asset) return (0, $dyHF6$rxjs.throwError)(new Error("No asset document returned"));
432
+ return (0, $dyHF6$rxjs.of)({
433
+ type: "success",
434
+ id: uuid,
435
+ asset: asset
436
+ });
437
+ }));
438
+ })));
439
+ }));
440
+ }
441
+ function $4a210fa13f9688e9$export$a5575dbeeffdad98(config, client, file, options = {}) {
442
+ return $4a210fa13f9688e9$var$testFile(file).pipe((0, $dyHF6$rxjsoperators.switchMap)((fileOptions)=>{
443
+ return (0, $dyHF6$rxjs.concat)((0, $dyHF6$rxjs.of)({
444
+ type: "file",
445
+ file: fileOptions
446
+ }), (0, $58acdddf66edce65$export$7d1f83854429bc73)(client).pipe((0, $dyHF6$rxjsoperators.switchMap)((json)=>{
447
+ if (!json || !json.status) return (0, $dyHF6$rxjs.throwError)(new Error("Invalid credentials"));
448
+ const uuid = (0, $dyHF6$sanityuuid.uuid)();
449
+ const { enableSignedUrls: enableSignedUrls } = options;
450
+ const body = {
451
+ mp4_support: config.mp4_support,
452
+ playback_policy: [
453
+ enableSignedUrls ? "signed" : "public"
454
+ ]
455
+ };
456
+ return (0, $dyHF6$rxjs.concat)((0, $dyHF6$rxjs.of)({
457
+ type: "uuid",
458
+ uuid: uuid
459
+ }), (0, $dyHF6$rxjs.defer)(()=>client.observable.request({
460
+ url: `/addons/mux/uploads/${client.clientConfig.dataset}`,
461
+ withCredentials: true,
462
+ method: "POST",
463
+ headers: {
464
+ "MUX-Proxy-UUID": uuid,
465
+ "Content-Type": "application/json"
466
+ },
467
+ body: body
468
+ })).pipe((0, $dyHF6$rxjsoperators.mergeMap)((result)=>{
469
+ return (0, $3dde8b7caa07e0e7$export$ad6eab20b4b3876f)(uuid, result.upload.url, file).pipe(// eslint-disable-next-line no-warning-comments
470
+ // @TODO type the observable events
471
+ // eslint-disable-next-line max-nested-callbacks
472
+ (0, $dyHF6$rxjsoperators.mergeMap)((event)=>{
473
+ if (event.type !== "success") return (0, $dyHF6$rxjs.of)(event);
474
+ return (0, $dyHF6$rxjs.from)($4a210fa13f9688e9$var$updateAssetDocumentFromUpload(client, uuid)).pipe(// eslint-disable-next-line max-nested-callbacks
475
+ (0, $dyHF6$rxjsoperators.mergeMap)((doc)=>(0, $dyHF6$rxjs.of)({
476
+ ...event,
477
+ asset: doc
478
+ })));
479
+ }), // eslint-disable-next-line max-nested-callbacks
480
+ (0, $dyHF6$rxjsoperators.catchError)((err)=>{
481
+ // Delete asset document
482
+ return $4a210fa13f9688e9$export$5130fb4c263997a4(client, uuid).pipe((0, $dyHF6$rxjsoperators.mergeMapTo)((0, $dyHF6$rxjs.throwError)(err)));
483
+ }));
484
+ })));
485
+ })));
486
+ }));
487
+ }
488
+ function $4a210fa13f9688e9$export$38276c014c550f86(client, assetId) {
489
+ const { dataset: dataset } = client.config();
490
+ return client.request({
491
+ url: `/addons/mux/uploads/${dataset}/${assetId}`,
492
+ withCredentials: true,
493
+ method: "GET"
494
+ });
495
+ }
496
+ function $4a210fa13f9688e9$var$pollUpload(client, uuid) {
497
+ const maxTries = 10;
498
+ let pollInterval;
499
+ let tries = 0;
500
+ let assetId;
501
+ let upload;
502
+ return new Promise((resolve, reject)=>{
503
+ pollInterval = setInterval(async ()=>{
504
+ try {
505
+ upload = await $4a210fa13f9688e9$export$38276c014c550f86(client, uuid);
506
+ } catch (err) {
507
+ reject(err);
508
+ return;
509
+ }
510
+ assetId = upload && upload.data && upload.data.asset_id;
511
+ if (assetId) {
512
+ clearInterval(pollInterval);
513
+ resolve(upload);
514
+ }
515
+ if (tries > maxTries) {
516
+ clearInterval(pollInterval);
517
+ reject(new Error("Upload did not finish"));
518
+ }
519
+ tries++;
520
+ }, 2000);
521
+ });
522
+ }
523
+ async function $4a210fa13f9688e9$var$updateAssetDocumentFromUpload(client, uuid) {
524
+ let upload;
525
+ let asset;
526
+ try {
527
+ upload = await $4a210fa13f9688e9$var$pollUpload(client, uuid);
528
+ } catch (err) {
529
+ return Promise.reject(err);
530
+ }
531
+ try {
532
+ asset = await (0, $a0485042ac477352$export$da446a5ee2572b7)(client, upload.data.asset_id);
533
+ } catch (err1) {
534
+ return Promise.reject(err1);
535
+ }
536
+ const doc = {
537
+ _id: uuid,
538
+ _type: "mux.videoAsset",
539
+ status: asset.data.status,
540
+ data: asset.data,
541
+ assetId: asset.data.id,
542
+ playbackId: asset.data.playback_ids[0].id,
543
+ uploadId: upload.data.id
544
+ };
545
+ return client.createOrReplace(doc).then(()=>{
546
+ return doc;
547
+ });
548
+ }
549
+ function $4a210fa13f9688e9$var$testFile(file) {
550
+ if (typeof window !== "undefined" && file instanceof window.File) {
551
+ const fileOptions = $4a210fa13f9688e9$var$optionsFromFile({}, file);
552
+ return (0, $dyHF6$rxjs.of)(fileOptions);
553
+ }
554
+ return (0, $dyHF6$rxjs.throwError)(new Error("Invalid file"));
555
+ }
556
+ function $4a210fa13f9688e9$var$testUrl(url) {
557
+ const error = new Error("Invalid URL");
558
+ if (typeof url !== "string") return (0, $dyHF6$rxjs.throwError)(error);
559
+ let parsed;
560
+ try {
561
+ parsed = new URL(url);
562
+ } catch (err) {
563
+ return (0, $dyHF6$rxjs.throwError)(error);
564
+ }
565
+ if (parsed && !parsed.protocol.match(/http:|https:/)) return (0, $dyHF6$rxjs.throwError)(error);
566
+ return (0, $dyHF6$rxjs.of)(url);
567
+ }
568
+ function $4a210fa13f9688e9$var$optionsFromFile(opts, file) {
569
+ if (typeof window === "undefined" || !(file instanceof window.File)) return opts;
570
+ return {
571
+ name: opts.preserveFilename === false ? undefined : file.name,
572
+ type: file.type
573
+ };
574
+ }
575
+
576
+
577
+ function $94a513daa91cd04e$export$73f6d6d8d794f645(dataTransfer) {
578
+ const files = Array.from(dataTransfer.files || []);
579
+ const items = Array.from(dataTransfer.items || []);
580
+ if (files && files.length > 0) return Promise.resolve(files);
581
+ return $94a513daa91cd04e$var$normalizeItems(items).then((arr)=>arr.flat());
582
+ }
583
+ function $94a513daa91cd04e$var$normalizeItems(items) {
584
+ return Promise.all(items.map((item)=>{
585
+ // directory
586
+ if (item.kind === "file" && item.webkitGetAsEntry) {
587
+ let entry;
588
+ // Edge throws
589
+ try {
590
+ entry = item.webkitGetAsEntry();
591
+ } catch (err) {
592
+ return [
593
+ item.getAsFile()
594
+ ];
595
+ }
596
+ if (!entry) return [];
597
+ return entry.isDirectory ? $94a513daa91cd04e$var$walk(entry) : [
598
+ item.getAsFile()
599
+ ];
600
+ }
601
+ // file
602
+ if (item.kind === "file") {
603
+ const file = item.getAsFile();
604
+ return Promise.resolve(file ? [
605
+ file
606
+ ] : []);
607
+ }
608
+ // others
609
+ return new Promise((resolve)=>item.getAsString(resolve)).then((str)=>str ? [
610
+ new File([
611
+ str
612
+ ], "unknown.txt", {
613
+ type: item.type
614
+ })
615
+ ] : []);
616
+ }));
617
+ }
618
+ function $94a513daa91cd04e$var$isFile(entry) {
619
+ return entry.isFile;
620
+ }
621
+ function $94a513daa91cd04e$var$isDirectory(entry) {
622
+ return entry.isDirectory;
623
+ }
624
+ function $94a513daa91cd04e$var$walk(entry) {
625
+ if ($94a513daa91cd04e$var$isFile(entry)) return new Promise((resolve)=>entry.file(resolve)).then((file)=>[
626
+ file
627
+ ]);
628
+ if ($94a513daa91cd04e$var$isDirectory(entry)) {
629
+ const dir = entry.createReader();
630
+ return new Promise((resolve)=>dir.readEntries(resolve)).then((entries)=>entries.filter((entr)=>!entr.name.startsWith("."))).then((entries)=>Promise.all(entries.map($94a513daa91cd04e$var$walk)).then((arr)=>arr.flat()));
631
+ }
632
+ return Promise.resolve([]);
633
+ }
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+ const $edbbfc11873e0f23$export$9c7ae676ac45430a = "secrets.mux";
668
+ function $edbbfc11873e0f23$export$e6f48a1ef9de02f7(client) {
669
+ const { projectId: projectId , dataset: dataset } = client.config();
670
+ return (0, $dyHF6$suspendreact.suspend)(async ()=>{
671
+ const data = await client.fetch(/* groq */ `*[_id == $_id][0]{
672
+ token,
673
+ secretKey,
674
+ enableSignedUrls,
675
+ signingKeyId,
676
+ signingKeyPrivate
677
+ }`, {
678
+ _id: $edbbfc11873e0f23$export$9c7ae676ac45430a
679
+ });
680
+ return {
681
+ token: data?.token || null,
682
+ secretKey: data?.secretKey || null,
683
+ enableSignedUrls: Boolean(data?.enableSignedUrls) || false,
684
+ signingKeyId: data?.signingKeyId || null,
685
+ signingKeyPrivate: data?.signingKeyPrivate || null
686
+ };
687
+ }, [
688
+ (0, $2ffcb7ef2a4a67d0$export$13cdb654d47e0703),
689
+ $edbbfc11873e0f23$export$9c7ae676ac45430a,
690
+ projectId,
691
+ dataset
692
+ ]);
329
693
  }
330
694
 
331
695
 
332
696
 
333
- const $329a1cedcedb1349$export$f5b8910cec6cf069 = /*#__PURE__*/ (0, $dyHF6$react.lazy)(()=>(parcelRequire("4M4Xk")));
697
+ function $d8ba7896129c9d6c$export$87b96baf1080652a(client, playbackId, aud, payload) {
698
+ const { signingKeyId: signingKeyId , signingKeyPrivate: signingKeyPrivate } = (0, $edbbfc11873e0f23$export$e6f48a1ef9de02f7)(client);
699
+ if (!signingKeyId) throw new TypeError("Missing signingKeyId");
700
+ if (!signingKeyPrivate) throw new TypeError("Missing signingKeyPrivate");
701
+ const { default: sign } = (0, $dyHF6$suspendreact.suspend)(()=>$dyHF6$jsonwebtokenesmsign, [
702
+ "sanity-plugin-mux-input",
703
+ "jsonwebtoken-esm/sign"
704
+ ]);
705
+ return sign(payload ? JSON.parse(JSON.stringify(payload, (_, v)=>v ?? undefined)) : {}, atob(signingKeyPrivate), {
706
+ algorithm: "RS256",
707
+ keyid: signingKeyId,
708
+ audience: aud,
709
+ subject: playbackId,
710
+ noTimestamp: true,
711
+ expiresIn: "12h"
712
+ });
713
+ }
714
+
715
+
716
+ function $96cfb4479805b243$export$bdfa34d24bb44333(asset) {
717
+ if (!asset?.playbackId) {
718
+ console.error("Asset is missing a playbackId", {
719
+ asset: asset
720
+ });
721
+ throw new TypeError(`Missing playbackId`);
722
+ }
723
+ return asset.playbackId;
724
+ }
725
+
726
+
727
+ function $5bbe48978fdc9616$export$f7d2546fac75bbd(asset) {
728
+ return asset.data?.playback_ids?.[0]?.policy ?? "public";
729
+ }
730
+
731
+
732
+ function $d116a96f272a1c22$export$6adb108e2a577699({ asset: asset , client: client , height: height , width: width , start: start = asset.thumbTime ? Math.max(0, asset.thumbTime - 2.5) : 0 , end: end = start + 5 , fps: fps = 15 }) {
733
+ const params = {
734
+ height: height,
735
+ width: width,
736
+ start: start,
737
+ end: end,
738
+ fps: fps
739
+ };
740
+ const playbackId = (0, $96cfb4479805b243$export$bdfa34d24bb44333)(asset);
741
+ let searchParams = new URLSearchParams(JSON.parse(JSON.stringify(params, (_, v)=>v ?? undefined)));
742
+ if ((0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed") {
743
+ const token = (0, $d8ba7896129c9d6c$export$87b96baf1080652a)(client, playbackId, "g", params);
744
+ searchParams = new URLSearchParams({
745
+ token: token
746
+ });
747
+ }
748
+ return `https://image.mux.com/${playbackId}/animated.gif?${searchParams}`;
749
+ }
750
+
751
+
752
+
753
+
754
+
755
+
756
+ function $2ed67348dc6c5cb5$export$8081e7a11b9f1345({ asset: asset , client: client , fit_mode: fit_mode , height: height , time: time = asset.thumbTime , width: width }) {
757
+ const params = {
758
+ fit_mode: fit_mode,
759
+ height: height,
760
+ time: time,
761
+ width: width
762
+ };
763
+ const playbackId = (0, $96cfb4479805b243$export$bdfa34d24bb44333)(asset);
764
+ let searchParams = new URLSearchParams(JSON.parse(JSON.stringify(params, (_, v)=>v ?? undefined)));
765
+ if ((0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed") {
766
+ const token = (0, $d8ba7896129c9d6c$export$87b96baf1080652a)(client, playbackId, "t", params);
767
+ searchParams = new URLSearchParams({
768
+ token: token
769
+ });
770
+ }
771
+ return `https://image.mux.com/${playbackId}/thumbnail.png?${searchParams}`;
772
+ }
773
+
774
+
775
+ const $6de6709202a3b061$var$mediaDimensions = {
776
+ aspect: 16 / 9
777
+ };
778
+ const $6de6709202a3b061$var$ImageLoader = /*#__PURE__*/ (0, $dyHF6$react.memo)(function ImageLoader({ alt: alt , src: src , height: height , width: width , aspectRatio: aspectRatio }) {
779
+ (0, $dyHF6$suspendreact.suspend)(async ()=>{
780
+ const img = new Image(width, height);
781
+ img.decoding = "async";
782
+ img.src = src;
783
+ await img.decode();
784
+ }, [
785
+ "sanity-plugin-mux-input",
786
+ "image",
787
+ src
788
+ ]);
789
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("img", {
790
+ alt: alt,
791
+ src: src,
792
+ height: height,
793
+ width: width,
794
+ style: {
795
+ aspectRatio: aspectRatio
796
+ }
797
+ });
798
+ });
799
+ const $6de6709202a3b061$var$VideoMediaPreview = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanity_unstable.MediaPreview))`
800
+ img {
801
+ object-fit: cover;
802
+ }
803
+ `;
804
+ const $6de6709202a3b061$var$VideoMediaPreviewSignedSubtitle = ({ solo: solo })=>{
805
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Inline), {
806
+ space: 1,
807
+ style: {
808
+ marginTop: solo ? "-1.35em" : undefined,
809
+ marginBottom: solo ? undefined : "0.35rem"
810
+ },
811
+ children: [
812
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.LockIcon), {}),
813
+ "Signed playback policy"
814
+ ]
815
+ });
816
+ };
817
+ const $6de6709202a3b061$var$PosterImage = ({ asset: asset , height: height , width: width , showTip: showTip })=>{
818
+ const client = (0, $dyHF6$sanity.useClient)();
819
+ const src = (0, $2ed67348dc6c5cb5$export$8081e7a11b9f1345)({
820
+ asset: asset,
821
+ client: client,
822
+ height: height,
823
+ width: width,
824
+ fit_mode: "smartcrop"
825
+ });
826
+ const subtitle = (0, $dyHF6$react.useMemo)(()=>showTip && (0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed" ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreviewSignedSubtitle, {
827
+ solo: true
828
+ }) : undefined, [
829
+ asset,
830
+ showTip
831
+ ]);
832
+ // eslint-disable-next-line no-warning-comments
833
+ // @TODO support setting the alt text in the schema, like how we deal with images
834
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreview, {
835
+ mediaDimensions: $6de6709202a3b061$var$mediaDimensions,
836
+ subtitle: subtitle,
837
+ title: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
838
+ children: null
839
+ }),
840
+ media: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$ImageLoader, {
841
+ alt: "",
842
+ src: src,
843
+ height: height,
844
+ width: width
845
+ })
846
+ });
847
+ };
848
+ const $6de6709202a3b061$export$bd4b73f15688a160 = /*#__PURE__*/ (0, $dyHF6$react.memo)(function VideoThumbnail({ asset: asset , width: width , showTip: showTip }) {
849
+ const { ErrorBoundary: ErrorBoundary , didCatch: didCatch , error: error } = (0, $dyHF6$useerrorboundary.useErrorBoundary)();
850
+ const height = Math.round(width * 9 / 16);
851
+ const subtitle = (0, $dyHF6$react.useMemo)(()=>showTip && (0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed" ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreviewSignedSubtitle, {}) : undefined, [
852
+ showTip,
853
+ asset
854
+ ]);
855
+ if (didCatch) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreview, {
856
+ subtitle: error.message,
857
+ mediaDimensions: $6de6709202a3b061$var$mediaDimensions,
858
+ title: "Error when loading thumbnail",
859
+ media: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
860
+ radius: 2,
861
+ height: "fill",
862
+ style: {
863
+ position: "relative",
864
+ width: "100%"
865
+ },
866
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
867
+ style: {
868
+ display: "flex",
869
+ justifyContent: "center",
870
+ alignItems: "center",
871
+ position: "absolute",
872
+ top: 0,
873
+ left: 0,
874
+ right: 0,
875
+ bottom: 0
876
+ },
877
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.UnknownIcon), {})
878
+ })
879
+ })
880
+ });
881
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)(ErrorBoundary, {
882
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$react.Suspense), {
883
+ fallback: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreview, {
884
+ isPlaceholder: true,
885
+ title: "Loading thumbnail...",
886
+ subtitle: subtitle,
887
+ mediaDimensions: $6de6709202a3b061$var$mediaDimensions
888
+ }),
889
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$PosterImage, {
890
+ showTip: showTip,
891
+ asset: asset,
892
+ height: height,
893
+ width: width
894
+ })
895
+ })
896
+ });
897
+ });
898
+ const $6de6709202a3b061$var$AnimatedVideoMediaPreview = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanity_unstable.MediaPreview))`
899
+ img {
900
+ object-fit: contain;
901
+ }
902
+ `;
903
+ const $6de6709202a3b061$var$AnimatedPosterImage = ({ asset: asset , width: width })=>{
904
+ const client = (0, $dyHF6$sanity.useClient)();
905
+ const src = (0, $d116a96f272a1c22$export$6adb108e2a577699)({
906
+ asset: asset,
907
+ client: client,
908
+ width: width
909
+ });
910
+ // eslint-disable-next-line no-warning-comments
911
+ // @TODO support setting the alt text in the schema, like how we deal with images
912
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$AnimatedVideoMediaPreview, {
913
+ withBorder: false,
914
+ mediaDimensions: $6de6709202a3b061$var$mediaDimensions,
915
+ media: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$ImageLoader, {
916
+ alt: "",
917
+ src: src,
918
+ width: width,
919
+ aspectRatio: "16:9"
920
+ })
921
+ });
922
+ };
923
+ const $6de6709202a3b061$export$357b57aa2db6117e = /*#__PURE__*/ (0, $dyHF6$react.memo)(function AnimatedVideoThumbnail({ asset: asset , width: width }) {
924
+ const { ErrorBoundary: ErrorBoundary , didCatch: didCatch } = (0, $dyHF6$useerrorboundary.useErrorBoundary)();
925
+ if (didCatch) return null;
926
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)(ErrorBoundary, {
927
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$react.Suspense), {
928
+ fallback: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$FancyBackdrop, {
929
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$VideoMediaPreview, {
930
+ mediaDimensions: $6de6709202a3b061$var$mediaDimensions,
931
+ withBorder: false,
932
+ media: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {
933
+ muted: true
934
+ })
935
+ })
936
+ }),
937
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
938
+ height: "fill",
939
+ tone: "transparent",
940
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($6de6709202a3b061$var$AnimatedPosterImage, {
941
+ asset: asset,
942
+ width: width
943
+ })
944
+ })
945
+ })
946
+ });
947
+ });
948
+ const $6de6709202a3b061$var$FancyBackdrop = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
949
+ backdrop-filter: blur(8px) brightness(0.5) saturate(2);
950
+ mix-blend-mode: color-dodge;
951
+ `;
952
+ const $6de6709202a3b061$export$e20c438ffc62921 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Grid))`
953
+ grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
954
+ `;
955
+ const $6de6709202a3b061$export$7431cee690d58bc9 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
956
+ border-top: 1px solid var(--card-border-color);
957
+ position: sticky;
958
+ bottom: 0;
959
+ z-index: 200;
960
+ `;
961
+
962
+
963
+ function $216715c95525676f$var$AssetActionsMenu(props) {
964
+ const { asset: asset } = props;
965
+ const id = (0, $dyHF6$reachautoid.useId)();
966
+ const [dialogState, setDialogState] = (0, $dyHF6$react.useState)();
967
+ const [open, setOpen] = (0, $dyHF6$react.useState)(false);
968
+ const [menuElement, setMenuRef] = (0, $dyHF6$react.useState)(null);
969
+ const handleDelete = (0, $dyHF6$react.useCallback)(()=>setDialogState("confirm-delete"), []);
970
+ const handleClick = (0, $dyHF6$react.useCallback)(()=>{
971
+ setDialogState(false);
972
+ setOpen(true);
973
+ }, [
974
+ setDialogState
975
+ ]);
976
+ const handleClose = (0, $dyHF6$react.useCallback)(()=>{
977
+ setDialogState(false);
978
+ setOpen(false);
979
+ }, [
980
+ setDialogState
981
+ ]);
982
+ (0, $dyHF6$react.useEffect)(()=>{
983
+ if (open && dialogState) setOpen(false);
984
+ }, [
985
+ dialogState,
986
+ open
987
+ ]);
988
+ (0, $dyHF6$sanityui.useClickOutside)((0, $dyHF6$react.useCallback)(()=>setOpen(false), []), [
989
+ menuElement
990
+ ]);
991
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
992
+ children: [
993
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuButton), {
994
+ id: `${id}-asset-menu`,
995
+ button: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
996
+ icon: (0, $dyHF6$sanityicons.EllipsisVerticalIcon),
997
+ mode: "ghost",
998
+ onClick: handleClick,
999
+ padding: 2
1000
+ }),
1001
+ menu: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Menu), {
1002
+ ref: setMenuRef,
1003
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuItem), {
1004
+ tone: "critical",
1005
+ icon: (0, $dyHF6$sanityicons.TrashIcon),
1006
+ text: "Delete",
1007
+ onClick: handleDelete
1008
+ })
1009
+ }),
1010
+ portal: true,
1011
+ placement: "right"
1012
+ }),
1013
+ dialogState === "confirm-delete" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($216715c95525676f$var$DeleteDialog, {
1014
+ asset: asset,
1015
+ onClose: handleClose
1016
+ })
1017
+ ]
1018
+ });
1019
+ }
1020
+ function $216715c95525676f$var$DeleteDialog(props) {
1021
+ const { asset: asset , onClose: onClose } = props;
1022
+ const client = (0, $dyHF6$sanity.useClient)();
1023
+ const { push: pushToast } = (0, $dyHF6$sanityui.useToast)();
1024
+ const [deleting, setDeleting] = (0, $dyHF6$react.useState)(false);
1025
+ const [deleteOnMux, setDeleteOnMux] = (0, $dyHF6$react.useState)(false);
1026
+ const id = (0, $dyHF6$reachautoid.useId)();
1027
+ const noPaddingOnStack = true;
1028
+ const width = 200 * (0, $dyHF6$usedevicepixelratio.getDevicePixelRatio)({
1029
+ maxDpr: 2
1030
+ });
1031
+ const handleDelete = (0, $dyHF6$react.useCallback)(async ()=>{
1032
+ setDeleting(true);
1033
+ try {
1034
+ if (asset?._id) await client.delete(asset._id);
1035
+ if (deleteOnMux && asset?.assetId) await (0, $a0485042ac477352$export$df987b50509121ea)(client, asset.assetId);
1036
+ document.querySelector(`[data-id="${asset._id}"]`)?.parentElement?.setAttribute?.("hidden", "true");
1037
+ } catch (err) {
1038
+ console.error("Failed during delete", err);
1039
+ pushToast({
1040
+ closable: true,
1041
+ description: err.message,
1042
+ duration: 5000,
1043
+ title: "Uncaught error",
1044
+ status: "error"
1045
+ });
1046
+ } finally{
1047
+ setDeleting(false);
1048
+ onClose();
1049
+ }
1050
+ }, [
1051
+ asset._id,
1052
+ asset.assetId,
1053
+ client,
1054
+ deleteOnMux,
1055
+ onClose,
1056
+ pushToast
1057
+ ]);
1058
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Dialog), {
1059
+ onClose: onClose,
1060
+ id: `${id}-confirm-delete`,
1061
+ header: "Delete video",
1062
+ footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Grid), {
1063
+ padding: 2,
1064
+ gap: 2,
1065
+ columns: 2,
1066
+ children: [
1067
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
1068
+ mode: "bleed",
1069
+ text: "Cancel",
1070
+ onClick: onClose
1071
+ }),
1072
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
1073
+ text: "Delete",
1074
+ tone: "critical",
1075
+ icon: (0, $dyHF6$sanityicons.TrashIcon),
1076
+ onClick: handleDelete,
1077
+ loading: deleting
1078
+ })
1079
+ ]
1080
+ }),
1081
+ // __unstable_autoFocus
1082
+ width: 1,
1083
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
1084
+ paddingX: noPaddingOnStack ? 0 : [
1085
+ 2,
1086
+ 3,
1087
+ 4
1088
+ ],
1089
+ paddingY: noPaddingOnStack ? 0 : [
1090
+ 3,
1091
+ 3,
1092
+ 3,
1093
+ 4
1094
+ ],
1095
+ space: 1,
1096
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
1097
+ paddingX: [
1098
+ 2,
1099
+ 3,
1100
+ 4
1101
+ ],
1102
+ paddingY: [
1103
+ 3,
1104
+ 3,
1105
+ 3,
1106
+ 4
1107
+ ],
1108
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Grid), {
1109
+ columns: 3,
1110
+ gap: 3,
1111
+ children: [
1112
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
1113
+ style: {
1114
+ gridColumn: "span 2"
1115
+ },
1116
+ align: "center",
1117
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
1118
+ padding: 4,
1119
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
1120
+ space: 4,
1121
+ children: [
1122
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
1123
+ align: "center",
1124
+ as: "label",
1125
+ children: [
1126
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Checkbox), {
1127
+ checked: deleteOnMux,
1128
+ onChange: ()=>setDeleteOnMux((prev)=>!prev)
1129
+ }),
1130
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1131
+ style: {
1132
+ margin: "0 10px"
1133
+ },
1134
+ children: "Delete asset on Mux"
1135
+ })
1136
+ ]
1137
+ }),
1138
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
1139
+ align: "center",
1140
+ as: "label",
1141
+ children: [
1142
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Checkbox), {
1143
+ disabled: true,
1144
+ checked: true
1145
+ }),
1146
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1147
+ style: {
1148
+ margin: "0 10px"
1149
+ },
1150
+ children: "Delete video from dataset"
1151
+ })
1152
+ ]
1153
+ })
1154
+ ]
1155
+ })
1156
+ })
1157
+ }),
1158
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$bd4b73f15688a160), {
1159
+ asset: asset,
1160
+ width: width,
1161
+ showTip: true
1162
+ })
1163
+ ]
1164
+ })
1165
+ })
1166
+ })
1167
+ });
1168
+ }
1169
+ function $216715c95525676f$export$2e2bcd8739ae039({ assets: assets , isLoading: isLoading , isLastPage: isLastPage , onSelect: onSelect , onLoadMore: onLoadMore }) {
1170
+ const handleClick = (0, $dyHF6$react.useCallback)((event)=>onSelect(event.currentTarget.dataset.id), [
1171
+ onSelect
1172
+ ]);
1173
+ const handleKeyPress = (0, $dyHF6$react.useCallback)((event)=>{
1174
+ if (event.key === "Enter") onSelect(event.currentTarget.dataset.id);
1175
+ }, [
1176
+ onSelect
1177
+ ]);
1178
+ const width = 200 * (0, $dyHF6$usedevicepixelratio.getDevicePixelRatio)({
1179
+ maxDpr: 2
1180
+ });
1181
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
1182
+ children: [
1183
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Box), {
1184
+ padding: 4,
1185
+ children: [
1186
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$e20c438ffc62921), {
1187
+ gap: 2,
1188
+ children: assets.map((asset)=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($216715c95525676f$var$VideoSourceItem, {
1189
+ asset: asset,
1190
+ onClick: handleClick,
1191
+ onKeyPress: handleKeyPress,
1192
+ width: width
1193
+ }, asset._id))
1194
+ }),
1195
+ isLoading && assets.length === 0 && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
1196
+ justify: "center",
1197
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {
1198
+ muted: true
1199
+ })
1200
+ }),
1201
+ !isLoading && assets.length === 0 && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1202
+ align: "center",
1203
+ muted: true,
1204
+ children: "No videos"
1205
+ })
1206
+ ]
1207
+ }),
1208
+ assets.length > 0 && !isLastPage && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$7431cee690d58bc9), {
1209
+ tone: "default",
1210
+ padding: 4,
1211
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
1212
+ direction: "column",
1213
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
1214
+ type: "button",
1215
+ icon: (0, $dyHF6$sanityicons.DownloadIcon),
1216
+ loading: isLoading,
1217
+ onClick: onLoadMore,
1218
+ text: "Load more",
1219
+ tone: "primary"
1220
+ })
1221
+ })
1222
+ })
1223
+ ]
1224
+ });
1225
+ }
1226
+ const $216715c95525676f$var$_VideoSourceItem = ({ asset: asset , onClick: onClick , onKeyPress: onKeyPress , width: width })=>{
1227
+ const [hover, setHover] = (0, $dyHF6$react.useState)(null);
1228
+ const ref = (0, $dyHF6$react.useRef)(null);
1229
+ (0, $dyHF6$react.useLayoutEffect)(()=>{
1230
+ if (!ref.current || hover === null) return;
1231
+ if (hover) (0, $dyHF6$motion.animate)(ref.current, {
1232
+ opacity: 1
1233
+ });
1234
+ else (0, $dyHF6$motion.animate)(ref.current, {
1235
+ opacity: 0
1236
+ });
1237
+ }, [
1238
+ hover
1239
+ ]);
1240
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Box), {
1241
+ height: "fill",
1242
+ style: {
1243
+ position: "relative"
1244
+ },
1245
+ children: [
1246
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Card), {
1247
+ as: "button",
1248
+ "data-id": asset._id,
1249
+ onClick: onClick,
1250
+ onKeyPress: onKeyPress,
1251
+ tabIndex: 0,
1252
+ radius: 2,
1253
+ padding: 1,
1254
+ style: {
1255
+ lineHeight: 0,
1256
+ position: "relative"
1257
+ },
1258
+ __unstable_focusRing: true,
1259
+ onMouseEnter: ()=>setHover(true),
1260
+ onMouseLeave: ()=>setHover(false),
1261
+ children: [
1262
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$bd4b73f15688a160), {
1263
+ asset: asset,
1264
+ width: width,
1265
+ showTip: true
1266
+ }),
1267
+ asset?.playbackId && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($216715c95525676f$var$AnimateWrapper, {
1268
+ tone: "transparent",
1269
+ ref: ref,
1270
+ margin: 1,
1271
+ radius: 1,
1272
+ children: hover !== null && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$357b57aa2db6117e), {
1273
+ asset: asset,
1274
+ width: width
1275
+ })
1276
+ })
1277
+ ]
1278
+ }),
1279
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($216715c95525676f$var$ActionsAssetsContainer, {
1280
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($216715c95525676f$var$AssetActionsMenu, {
1281
+ asset: asset
1282
+ })
1283
+ })
1284
+ ]
1285
+ });
1286
+ };
1287
+ const $216715c95525676f$var$VideoSourceItem = /*#__PURE__*/ (0, $dyHF6$react.memo)($216715c95525676f$var$_VideoSourceItem);
1288
+ const $216715c95525676f$var$AnimateWrapper = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
1289
+ position: absolute;
1290
+ top: 0;
1291
+ left: 0;
1292
+ right: 0;
1293
+ bottom: 0;
1294
+ will-change: opacity;
1295
+ background: transparent;
1296
+ opacity: 0;
1297
+ pointer-events: none;
1298
+ `;
1299
+ const $216715c95525676f$var$ActionsAssetsContainer = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).div`
1300
+ box-sizing: border-box;
1301
+ position: absolute;
1302
+ z-index: 300;
1303
+ opacity: 0;
1304
+ top: 7px;
1305
+ right: 7px;
1306
+
1307
+ button:hover + &,
1308
+ button:focus-visible + &,
1309
+ &:hover,
1310
+ &:focus-visible {
1311
+ opacity: 1;
1312
+ }
1313
+ `;
1314
+
1315
+
1316
+ const $43923b4c880150fa$var$PER_PAGE = 20;
1317
+ function $43923b4c880150fa$var$createQuery(start = 0, end = $43923b4c880150fa$var$PER_PAGE) {
1318
+ return /* groq */ `*[_type == "mux.videoAsset"] | order(_updatedAt desc) [${start}...${end}]`;
1319
+ }
1320
+ function $43923b4c880150fa$export$2e2bcd8739ae039({ asset: asset , onChange: onChange , setDialogState: setDialogState }) {
1321
+ const client = (0, $dyHF6$sanity.useClient)();
1322
+ const pageNoRef = (0, $dyHF6$react.useRef)(0);
1323
+ const [isLastPage, setLastPage] = (0, $dyHF6$react.useState)(false);
1324
+ const [isLoading, setLoading] = (0, $dyHF6$react.useState)(false);
1325
+ const [assets, setAssets] = (0, $dyHF6$react.useState)([]);
1326
+ const fetchPage = (0, $dyHF6$react.useCallback)((pageNo)=>{
1327
+ const start = pageNo * $43923b4c880150fa$var$PER_PAGE;
1328
+ const end = start + $43923b4c880150fa$var$PER_PAGE;
1329
+ setLoading(true);
1330
+ return client.fetch($43923b4c880150fa$var$createQuery(start, end)).then((result)=>{
1331
+ setLastPage(result.length < $43923b4c880150fa$var$PER_PAGE);
1332
+ setAssets((prev)=>prev.concat(result));
1333
+ }).finally(()=>setLoading(false));
1334
+ }, [
1335
+ client
1336
+ ]);
1337
+ const handleSelect = (0, $dyHF6$react.useCallback)((id)=>{
1338
+ const selected = assets.find((doc)=>doc._id === id);
1339
+ if (!selected) throw new TypeError(`Failed to find video asset with id: ${id}`);
1340
+ onChange((0, $dyHF6$sanityform.PatchEvent).from([
1341
+ (0, $dyHF6$sanityform.setIfMissing)({
1342
+ asset: {}
1343
+ }),
1344
+ (0, $dyHF6$sanityform.set)({
1345
+ _type: "reference",
1346
+ _weak: true,
1347
+ _ref: selected._id
1348
+ }, [
1349
+ "asset"
1350
+ ]),
1351
+ ]));
1352
+ setDialogState(false);
1353
+ }, [
1354
+ assets,
1355
+ onChange,
1356
+ setDialogState
1357
+ ]);
1358
+ const handleLoadMore = (0, $dyHF6$react.useCallback)(()=>{
1359
+ fetchPage(++pageNoRef.current);
1360
+ }, [
1361
+ fetchPage
1362
+ ]);
1363
+ (0, $dyHF6$react.useEffect)(()=>void fetchPage(pageNoRef.current), [
1364
+ fetchPage
1365
+ ]);
1366
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $216715c95525676f$export$2e2bcd8739ae039), {
1367
+ onSelect: handleSelect,
1368
+ assets: assets,
1369
+ isLastPage: isLastPage,
1370
+ isLoading: isLoading,
1371
+ onLoadMore: handleLoadMore
1372
+ });
1373
+ }
1374
+
1375
+
1376
+ function $002b8d5a97e55801$export$2e2bcd8739ae039({ setDialogState: setDialogState , asset: asset , onChange: onChange }) {
1377
+ const id = `InputBrowser${(0, $dyHF6$reachautoid.useId)()}`;
1378
+ const handleClose = (0, $dyHF6$react.useCallback)(()=>setDialogState(false), [
1379
+ setDialogState
1380
+ ]);
1381
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Dialog), {
1382
+ scheme: "dark",
1383
+ __unstable_autoFocus: true,
1384
+ header: "Select video",
1385
+ id: id,
1386
+ onClose: handleClose,
1387
+ width: 2,
1388
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $43923b4c880150fa$export$2e2bcd8739ae039), {
1389
+ asset: asset,
1390
+ onChange: onChange,
1391
+ setDialogState: setDialogState
1392
+ })
1393
+ });
1394
+ }
1395
+
1396
+
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+ const $aaf33e116b8198b5$export$b07ce35d92a46f4b = (asset, onChange)=>{
1408
+ const client = (0, $dyHF6$sanity.useClient)();
1409
+ return (0, $dyHF6$react.useCallback)(()=>{
1410
+ if (!asset) return;
1411
+ onChange((0, $dyHF6$sanityform.PatchEvent).from((0, $dyHF6$sanityform.unset)()));
1412
+ if (asset.assetId) (0, $a0485042ac477352$export$df987b50509121ea)(client, asset.assetId);
1413
+ if (asset._id) client.delete(asset._id);
1414
+ }, [
1415
+ asset,
1416
+ client,
1417
+ onChange
1418
+ ]);
1419
+ };
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+ function $23be88c51cb37a0a$export$b704b622b4125987({ asset: asset , client: client }) {
1426
+ const playbackId = (0, $96cfb4479805b243$export$bdfa34d24bb44333)(asset);
1427
+ const searchParams = new URLSearchParams();
1428
+ if ((0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed") {
1429
+ const token = (0, $d8ba7896129c9d6c$export$87b96baf1080652a)(client, playbackId, "v");
1430
+ searchParams.set("token", token);
1431
+ }
1432
+ return `https://stream.mux.com/${playbackId}.m3u8?${searchParams}`;
1433
+ }
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1442
+
1443
+ function $e9dd88be70c34bc0$export$2e2bcd8739ae039({ asset: asset , getCurrentTime: getCurrentTime , setDialogState: setDialogState }) {
1444
+ const client = (0, $dyHF6$sanity.useClient)();
1445
+ const dialogId = `EditThumbnailDialog${(0, $dyHF6$reachautoid.useId)()}`;
1446
+ const nextTime = (0, $dyHF6$react.useMemo)(()=>getCurrentTime(), [
1447
+ getCurrentTime
1448
+ ]);
1449
+ const assetWithNewThumbnail = (0, $dyHF6$react.useMemo)(()=>({
1450
+ ...asset,
1451
+ thumbTime: nextTime
1452
+ }), [
1453
+ asset,
1454
+ nextTime
1455
+ ]);
1456
+ const [saving, setSaving] = (0, $dyHF6$react.useState)(false);
1457
+ const [error, setError] = (0, $dyHF6$react.useState)(null);
1458
+ const handleSave = (0, $dyHF6$react.useCallback)(()=>{
1459
+ setSaving(true);
1460
+ client.patch(asset._id).set({
1461
+ thumbTime: nextTime
1462
+ }).commit({
1463
+ returnDocuments: false
1464
+ }).then(()=>void setDialogState(false)).catch(setError).finally(()=>void setSaving(false));
1465
+ }, [
1466
+ client,
1467
+ asset._id,
1468
+ nextTime,
1469
+ setDialogState
1470
+ ]);
1471
+ const width = 300 * (0, $dyHF6$usedevicepixelratio.getDevicePixelRatio)({
1472
+ maxDpr: 2
1473
+ });
1474
+ if (error) // eslint-disable-next-line no-warning-comments
1475
+ // @TODO handle errors more gracefully
1476
+ throw error;
1477
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Dialog), {
1478
+ id: dialogId,
1479
+ header: "Edit thumbnail",
1480
+ onClose: ()=>setDialogState(false),
1481
+ footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
1482
+ padding: 3,
1483
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
1484
+ mode: "ghost",
1485
+ tone: "primary",
1486
+ loading: saving,
1487
+ onClick: handleSave,
1488
+ text: "Set new thumbnail"
1489
+ }, "thumbnail")
1490
+ }),
1491
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
1492
+ space: 3,
1493
+ padding: 3,
1494
+ children: [
1495
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
1496
+ space: 2,
1497
+ children: [
1498
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1499
+ size: 1,
1500
+ weight: "semibold",
1501
+ children: "Current:"
1502
+ }),
1503
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$bd4b73f15688a160), {
1504
+ asset: asset,
1505
+ width: width
1506
+ })
1507
+ ]
1508
+ }),
1509
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
1510
+ space: 2,
1511
+ children: [
1512
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1513
+ size: 1,
1514
+ weight: "semibold",
1515
+ children: "New:"
1516
+ }),
1517
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$bd4b73f15688a160), {
1518
+ asset: assetWithNewThumbnail,
1519
+ width: width
1520
+ })
1521
+ ]
1522
+ })
1523
+ ]
1524
+ })
1525
+ });
1526
+ }
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+
1533
+
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+ function $ff9ed2112976f4c6$export$445f1a1fda135dc9({ asset: asset , client: client }) {
1540
+ const playbackId = (0, $96cfb4479805b243$export$bdfa34d24bb44333)(asset);
1541
+ const searchParams = new URLSearchParams();
1542
+ if ((0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed") {
1543
+ const token = (0, $d8ba7896129c9d6c$export$87b96baf1080652a)(client, playbackId, "s");
1544
+ searchParams.set("token", token);
1545
+ }
1546
+ return `https://image.mux.com/${playbackId}/storyboard.vtt?${searchParams}`;
1547
+ }
1548
+
1549
+
1550
+ const $f31b07fd20c626b4$export$b302ef9d8310f71 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
1551
+ position: relative;
1552
+ min-height: 150px;
1553
+ aspect-ratio: 16 / 9;
1554
+ overflow: hidden;
1555
+ border-radius: 1px;
1556
+ media-airplay-button[media-airplay-unavailable] {
1557
+ display: none;
1558
+ }
1559
+ media-volume-range[media-volume-unavailable] {
1560
+ display: none;
1561
+ }
1562
+ media-pip-button[media-pip-unavailable] {
1563
+ display: none;
1564
+ }
1565
+ media-controller {
1566
+ --media-control-background: transparent;
1567
+ --media-control-hover-background: transparent;
1568
+ --media-range-track-background-color: rgba(255, 255, 255, 0.5);
1569
+ --media-range-track-border-radius: 3px;
1570
+ width: 100%;
1571
+ height: 100%;
1572
+ background-color: transparent;
1573
+ }
1574
+ media-control-bar {
1575
+ --media-button-icon-width: 18px;
1576
+ --media-preview-time-margin: 0px;
1577
+ }
1578
+ media-control-bar:not([slot]) :is([role='button'], [role='switch'], button) {
1579
+ height: 44px;
1580
+ }
1581
+ .size-extra-small media-control-bar [role='button'],
1582
+ .size-extra-small media-control-bar [role='switch'] {
1583
+ height: auto;
1584
+ padding: 4.4% 3.2%;
1585
+ }
1586
+ .mxp-spacer {
1587
+ flex-grow: 1;
1588
+ height: 100%;
1589
+ background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));
1590
+ }
1591
+ media-controller::part(vertical-layer) {
1592
+ transition: background-color 1s;
1593
+ }
1594
+ media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer) {
1595
+ background-color: rgba(0, 0, 0, 0.6);
1596
+ transition: background-color 0.25s;
1597
+ }
1598
+ .mxp-center-controls {
1599
+ --media-background-color: transparent;
1600
+ --media-button-icon-width: 100%;
1601
+ --media-button-icon-height: auto;
1602
+ pointer-events: none;
1603
+ width: 100%;
1604
+ display: flex;
1605
+ flex-flow: row;
1606
+ align-items: center;
1607
+ justify-content: center;
1608
+ }
1609
+ .mxp-center-controls media-play-button {
1610
+ --media-control-background: transparent;
1611
+ --media-control-hover-background: transparent;
1612
+ padding: 0;
1613
+ width: max(27px, min(9%, 90px));
1614
+ }
1615
+ .mxp-center-controls media-seek-backward-button,
1616
+ .mxp-center-controls media-seek-forward-button {
1617
+ --media-control-background: transparent;
1618
+ --media-control-hover-background: transparent;
1619
+ padding: 0;
1620
+ margin: 0 10%;
1621
+ width: min(7%, 70px);
1622
+ }
1623
+ media-loading-indicator {
1624
+ --media-loading-icon-width: 100%;
1625
+ --media-button-icon-height: auto;
1626
+ pointer-events: none;
1627
+ position: absolute;
1628
+ width: min(15%, 150px);
1629
+ display: flex;
1630
+ flex-flow: row;
1631
+ align-items: center;
1632
+ justify-content: center;
1633
+ }
1634
+ /* Intentionally don't target the div for transition but the children
1635
+ of the div. Prevents messing with media-chrome's autohide feature. */
1636
+ media-loading-indicator + div * {
1637
+ transition: opacity 0.15s;
1638
+ opacity: 1;
1639
+ }
1640
+ media-loading-indicator[media-loading]:not([media-paused]) ~ div > * {
1641
+ opacity: 0;
1642
+ transition-delay: 400ms;
1643
+ }
1644
+ media-volume-range {
1645
+ width: min(100%, 100px);
1646
+ }
1647
+ media-time-display {
1648
+ white-space: nowrap;
1649
+ }
1650
+ :is(media-time-display, media-text-display, media-playback-rate-button) {
1651
+ color: inherit;
1652
+ }
1653
+ media-controller:fullscreen media-control-bar[slot='top-chrome'] {
1654
+ /* Hide menus and buttons that trigger modals when in full-screen */
1655
+ display: none;
1656
+ }
1657
+ video {
1658
+ background: transparent;
1659
+ }
1660
+ media-controller:not(:fullscreen) video {
1661
+ aspect-ratio: 16 / 9;
1662
+ }
1663
+ media-controller:not(:-webkit-full-screen) video {
1664
+ aspect-ratio: 16 / 9;
1665
+ }
1666
+ `;
1667
+ const $f31b07fd20c626b4$export$ec21f2fe322b745c = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).div`
1668
+ && {
1669
+ --media-background-color: transparent;
1670
+ --media-button-icon-width: 100%;
1671
+ --media-button-icon-height: auto;
1672
+ pointer-events: none;
1673
+ width: 100%;
1674
+ display: flex;
1675
+ flex-flow: row;
1676
+ align-items: center;
1677
+ justify-content: center;
1678
+ media-play-button {
1679
+ --media-control-background: transparent;
1680
+ --media-control-hover-background: transparent;
1681
+ padding: 0;
1682
+ width: max(27px, min(9%, 90px));
1683
+ }
1684
+ }
1685
+ `;
1686
+ const $f31b07fd20c626b4$export$fa0cb91fe5adf3c5 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$mediachromedistreact.MediaControlBar))`
1687
+ justify-content: flex-end;
1688
+ button {
1689
+ height: auto;
1690
+ }
1691
+ `;
1692
+ function $f31b07fd20c626b4$export$5ebdf79245c1c64a({ asset: asset }) {
1693
+ const client = (0, $dyHF6$sanity.useClient)();
1694
+ const ref = (0, $dyHF6$react.useRef)(null);
1695
+ const src = (0, $dyHF6$react.useMemo)(()=>(0, $2ed67348dc6c5cb5$export$8081e7a11b9f1345)({
1696
+ client: client,
1697
+ asset: asset,
1698
+ width: 1920,
1699
+ height: 1080
1700
+ }), [
1701
+ client,
1702
+ asset
1703
+ ]);
1704
+ (0, $dyHF6$react.useEffect)(()=>{
1705
+ if (ref.current) {
1706
+ const style = document.createElement("style");
1707
+ style.innerHTML = "img { object-fit: contain; }";
1708
+ if (ref.current?.shadowRoot) ref.current.shadowRoot.appendChild(style);
1709
+ }
1710
+ }, []);
1711
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaPosterImage), {
1712
+ ref: ref,
1713
+ slot: "poster",
1714
+ src: src
1715
+ });
1716
+ }
1717
+ function $f31b07fd20c626b4$export$95073c0c4bf2add1({ asset: asset }) {
1718
+ const client = (0, $dyHF6$sanity.useClient)();
1719
+ // Why useState instead of useMemo? Because we really really only want to run it exactly once and useMemo doesn't make that guarantee
1720
+ const [src] = (0, $dyHF6$react.useState)(()=>(0, $ff9ed2112976f4c6$export$445f1a1fda135dc9)({
1721
+ asset: asset,
1722
+ client: client
1723
+ }));
1724
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("track", {
1725
+ label: "thumbnails",
1726
+ default: true,
1727
+ kind: "metadata",
1728
+ src: src
1729
+ });
1730
+ }
1731
+
1732
+
1733
+
1734
+
1735
+
1736
+
1737
+
1738
+ const $18e643189121e331$export$6aa22a823032b784 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
1739
+ min-height: 82px;
1740
+ box-sizing: border-box;
1741
+ `;
1742
+ const $18e643189121e331$export$245cfede9308c835 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Flex))`
1743
+ text-overflow: ellipsis;
1744
+ overflow: hidden;
1745
+ `;
1746
+ const $18e643189121e331$export$e3b4754a92ccf466 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Stack))`
1747
+ position: relative;
1748
+ width: 60%;
1749
+ `;
1750
+ const $18e643189121e331$export$bedb6b8ab184f038 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Code))`
1751
+ position: relative;
1752
+ width: 100%;
1753
+
1754
+ code {
1755
+ overflow: hidden;
1756
+ text-overflow: ellipsis;
1757
+ position: relative;
1758
+ max-width: 200px;
1759
+ }
1760
+ `;
1761
+ const $18e643189121e331$export$98a3886347b629fb = ({ progress: progress = 100 , onCancel: onCancel , filename: filename , text: text = "Uploading" })=>{
1762
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($18e643189121e331$export$6aa22a823032b784, {
1763
+ tone: "primary",
1764
+ padding: 4,
1765
+ border: true,
1766
+ height: "fill",
1767
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($18e643189121e331$export$245cfede9308c835, {
1768
+ align: "center",
1769
+ justify: "space-between",
1770
+ height: "fill",
1771
+ direction: "row",
1772
+ gap: 2,
1773
+ children: [
1774
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($18e643189121e331$export$e3b4754a92ccf466, {
1775
+ children: [
1776
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
1777
+ justify: "center",
1778
+ gap: [
1779
+ 3,
1780
+ 3,
1781
+ 2,
1782
+ 2
1783
+ ],
1784
+ direction: [
1785
+ "column",
1786
+ "column",
1787
+ "row"
1788
+ ],
1789
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1790
+ size: 1,
1791
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Inline), {
1792
+ space: 2,
1793
+ children: [
1794
+ text,
1795
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($18e643189121e331$export$bedb6b8ab184f038, {
1796
+ size: 1,
1797
+ children: filename ? filename : "..."
1798
+ })
1799
+ ]
1800
+ })
1801
+ })
1802
+ }),
1803
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
1804
+ marginTop: 3,
1805
+ radius: 5,
1806
+ shadow: 1,
1807
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanity_unstable.LinearProgress), {
1808
+ value: progress
1809
+ })
1810
+ })
1811
+ ]
1812
+ }),
1813
+ onCancel ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
1814
+ fontSize: 2,
1815
+ text: "Cancel upload",
1816
+ mode: "ghost",
1817
+ tone: "critical",
1818
+ onClick: onCancel
1819
+ }) : null
1820
+ ]
1821
+ })
1822
+ });
1823
+ };
1824
+
1825
+
1826
+ const $4b270840a4c34b64$var$MuxVideo = ({ asset: asset , buttons: buttons , readOnly: readOnly , onChange: onChange , dialogState: dialogState , setDialogState: setDialogState })=>{
1827
+ const client = (0, $dyHF6$sanity.useClient)();
1828
+ const isLoading = (0, $dyHF6$react.useMemo)(()=>{
1829
+ if (asset?.status === "preparing") return "Preparing the video";
1830
+ if (asset?.status === "waiting_for_upload") return "Waiting for upload to start";
1831
+ if (asset?.status === "waiting") return "Processing upload";
1832
+ if (asset?.status === "ready") return false;
1833
+ if (typeof asset?.status === "undefined") return false;
1834
+ return true;
1835
+ }, [
1836
+ asset
1837
+ ]);
1838
+ const isPreparingStaticRenditions = (0, $dyHF6$react.useMemo)(()=>{
1839
+ if (asset?.data?.static_renditions?.status === "preparing") return true;
1840
+ if (asset?.data?.static_renditions?.status === "ready") return false;
1841
+ return false;
1842
+ }, [
1843
+ asset?.data?.static_renditions?.status
1844
+ ]);
1845
+ const videoSrc = (0, $dyHF6$react.useMemo)(()=>asset.playbackId && (0, $23be88c51cb37a0a$export$b704b622b4125987)({
1846
+ client: client,
1847
+ asset: asset
1848
+ }), [
1849
+ asset,
1850
+ client
1851
+ ]);
1852
+ const [error, setError] = (0, $dyHF6$react.useState)(null);
1853
+ const handleError = (0, $dyHF6$react.useCallback)((event)=>setError(event.currentTarget.error), []);
1854
+ const playRef = (0, $dyHF6$react.useRef)(null);
1855
+ const muteRef = (0, $dyHF6$react.useRef)(null);
1856
+ const video = (0, $dyHF6$react.useRef)(null);
1857
+ const getCurrentTime = (0, $dyHF6$react.useCallback)(()=>video.current?.currentTime ?? 0, [
1858
+ video
1859
+ ]);
1860
+ const handleCancelUpload = (0, $aaf33e116b8198b5$export$b07ce35d92a46f4b)(asset, onChange);
1861
+ (0, $dyHF6$react.useEffect)(()=>{
1862
+ const style = document.createElement("style");
1863
+ style.innerHTML = "button svg { vertical-align: middle; }";
1864
+ if (playRef.current?.shadowRoot) playRef.current.shadowRoot.appendChild(style);
1865
+ if (muteRef?.current?.shadowRoot) muteRef.current.shadowRoot.appendChild(style.cloneNode(true));
1866
+ }, []);
1867
+ const [playerInitTime] = (0, $dyHF6$react.useState)(()=>(0, $dyHF6$muxplaybackcore.generatePlayerInitTime)());
1868
+ const playbackEngineRef = (0, $dyHF6$react.useRef)(undefined);
1869
+ (0, $dyHF6$react.useEffect)(()=>{
1870
+ if (isLoading || !videoSrc) return;
1871
+ const nextPlaybackEngineRef = (0, $dyHF6$muxplaybackcore.initialize)({
1872
+ src: videoSrc,
1873
+ playerInitTime: playerInitTime,
1874
+ playerSoftwareName: "sanity-plugin-mux-input",
1875
+ playerSoftwareVersion: "dev-preview"
1876
+ }, video.current, playbackEngineRef.current);
1877
+ playbackEngineRef.current = nextPlaybackEngineRef;
1878
+ }, [
1879
+ videoSrc,
1880
+ isLoading,
1881
+ playerInitTime
1882
+ ]);
1883
+ (0, $dyHF6$react.useEffect)(()=>{
1884
+ if (asset?.status === "errored") {
1885
+ handleCancelUpload();
1886
+ // eslint-disable-next-line no-warning-comments
1887
+ // @TODO use better error handling
1888
+ throw new Error(asset.data?.errors?.messages?.join(" "));
1889
+ }
1890
+ }, [
1891
+ asset.data?.errors?.messages,
1892
+ asset?.status,
1893
+ handleCancelUpload
1894
+ ]);
1895
+ if (error) // @TODO better error handling
1896
+ throw error;
1897
+ if (!asset || !asset.status) return null;
1898
+ if (isLoading) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $18e643189121e331$export$98a3886347b629fb), {
1899
+ progress: 100,
1900
+ filename: asset?.filename,
1901
+ text: isLoading !== true && isLoading || "Waiting for Mux to complete the file",
1902
+ onCancel: readOnly ? undefined : ()=>handleCancelUpload()
1903
+ });
1904
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
1905
+ children: [
1906
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $f31b07fd20c626b4$export$b302ef9d8310f71), {
1907
+ shadow: 1,
1908
+ tone: "transparent",
1909
+ scheme: "dark",
1910
+ children: [
1911
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$mediachromedistreact.MediaController), {
1912
+ children: [
1913
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("video", {
1914
+ playsInline: true,
1915
+ ref: video,
1916
+ onError: handleError,
1917
+ slot: "media",
1918
+ preload: "metadata",
1919
+ crossOrigin: "anonomous",
1920
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f31b07fd20c626b4$export$95073c0c4bf2add1), {
1921
+ asset: asset
1922
+ })
1923
+ }),
1924
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f31b07fd20c626b4$export$5ebdf79245c1c64a), {
1925
+ asset: asset
1926
+ }),
1927
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaLoadingIndicator), {
1928
+ slot: "centered-chrome",
1929
+ noAutoHide: true
1930
+ }),
1931
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f31b07fd20c626b4$export$ec21f2fe322b745c), {
1932
+ slot: "centered-chrome",
1933
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaPlayButton), {})
1934
+ }),
1935
+ buttons && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f31b07fd20c626b4$export$fa0cb91fe5adf3c5), {
1936
+ slot: "top-chrome",
1937
+ children: buttons
1938
+ }),
1939
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$mediachromedistreact.MediaControlBar), {
1940
+ children: [
1941
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaMuteButton), {}),
1942
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaTimeDisplay), {}),
1943
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaTimeRange), {}),
1944
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaDurationDisplay), {}),
1945
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$mediachromedistreact.MediaFullscreenButton), {})
1946
+ ]
1947
+ })
1948
+ ]
1949
+ }),
1950
+ isPreparingStaticRenditions && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
1951
+ padding: 2,
1952
+ radius: 1,
1953
+ style: {
1954
+ background: "var(--card-fg-color)",
1955
+ position: "absolute",
1956
+ top: "0.5em",
1957
+ left: "0.5em"
1958
+ },
1959
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
1960
+ size: 1,
1961
+ style: {
1962
+ color: "var(--card-bg-color)"
1963
+ },
1964
+ children: "MUX is preparing static renditions, please stand by"
1965
+ })
1966
+ })
1967
+ ]
1968
+ }),
1969
+ dialogState === "edit-thumbnail" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $e9dd88be70c34bc0$export$2e2bcd8739ae039), {
1970
+ asset: asset,
1971
+ getCurrentTime: getCurrentTime,
1972
+ setDialogState: setDialogState
1973
+ })
1974
+ ]
1975
+ });
1976
+ };
1977
+ var $4b270840a4c34b64$export$2e2bcd8739ae039 = $4b270840a4c34b64$var$MuxVideo;
1978
+
1979
+
1980
+
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1991
+
1992
+
1993
+
1994
+ function $c3640926d3b4b579$export$a79bcc1dc439e294(border) {
1995
+ return `inset 0 0 0 ${border.width}px ${border.color}`;
1996
+ }
1997
+ function $c3640926d3b4b579$export$c339ddc20364daad(opts) {
1998
+ const { base: base , border: border , focusRing: focusRing } = opts;
1999
+ const focusRingOutsetWidth = focusRing.offset + focusRing.width;
2000
+ const focusRingInsetWidth = 0 - focusRing.offset;
2001
+ const bgColor = base ? base.bg : "var(--card-bg-color)";
2002
+ return [
2003
+ focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
2004
+ border && $c3640926d3b4b579$export$a79bcc1dc439e294(border),
2005
+ focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
2006
+ focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`,
2007
+ ].filter(Boolean).join(",");
2008
+ }
2009
+
2010
+
2011
+ const $59667831b98d647c$export$de1df6cdafc19206 = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.MenuItem))(({ theme: theme })=>{
2012
+ const { focusRing: focusRing } = theme.sanity;
2013
+ const base = theme.sanity.color.base;
2014
+ const border = {
2015
+ width: 1,
2016
+ color: "var(--card-border-color)"
2017
+ };
2018
+ return (0, $dyHF6$styledcomponents.css)`
2019
+ position: relative;
2020
+
2021
+ &:not([data-disabled='true']) {
2022
+ &:focus-within {
2023
+ box-shadow: ${(0, $c3640926d3b4b579$export$c339ddc20364daad)({
2024
+ base: base,
2025
+ border: border,
2026
+ focusRing: focusRing
2027
+ })};
2028
+ }
2029
+ }
2030
+
2031
+ & input {
2032
+ overflow: hidden;
2033
+ top: 0;
2034
+ left: 0;
2035
+ width: 100%;
2036
+ height: 100%;
2037
+ position: absolute;
2038
+ min-width: 0;
2039
+ display: block;
2040
+ appearance: none;
2041
+ padding: 0;
2042
+ margin: 0;
2043
+ border: 0;
2044
+ opacity: 0;
2045
+ }
2046
+ `;
2047
+ });
2048
+
2049
+
2050
+ const $a1238a31a065a28d$export$c1c647ae58701638 = /*#__PURE__*/ (0, ($parcel$interopDefault($dyHF6$react))).forwardRef(function FileInputMenuItem(props, forwardedRef) {
2051
+ const { icon: icon , id: idProp , accept: accept , capture: capture , fontSize: fontSize , multiple: multiple , onSelect: onSelect , padding: padding = 3 , space: space = 3 , textAlign: textAlign , text: text , disabled: disabled , ...rest } = props;
2052
+ const id = (0, $dyHF6$reachautoid.useId)(idProp);
2053
+ const handleChange = (0, ($parcel$interopDefault($dyHF6$react))).useCallback((event)=>{
2054
+ if (onSelect && event.target.files) onSelect(Array.from(event.target.files));
2055
+ }, [
2056
+ onSelect
2057
+ ]);
2058
+ const content = /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
2059
+ align: "center",
2060
+ justify: "flex-start",
2061
+ padding: padding,
2062
+ children: [
2063
+ icon && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
2064
+ marginRight: text ? space : undefined,
2065
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
2066
+ size: fontSize,
2067
+ children: [
2068
+ /*#__PURE__*/ (0, $dyHF6$react.isValidElement)(icon) && icon,
2069
+ (0, $dyHF6$reactis.isValidElementType)(icon) && /*#__PURE__*/ (0, $dyHF6$react.createElement)(icon)
2070
+ ]
2071
+ })
2072
+ }),
2073
+ text && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
2074
+ align: textAlign,
2075
+ size: fontSize,
2076
+ textOverflow: "ellipsis",
2077
+ children: text
2078
+ })
2079
+ ]
2080
+ });
2081
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $59667831b98d647c$export$de1df6cdafc19206), {
2082
+ ...rest,
2083
+ htmlFor: id,
2084
+ padding: 0,
2085
+ fontSize: 2,
2086
+ disabled: disabled,
2087
+ ref: forwardedRef,
2088
+ children: [
2089
+ content,
2090
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("input", {
2091
+ "data-testid": "file-button-input",
2092
+ accept: accept,
2093
+ capture: capture,
2094
+ id: id,
2095
+ multiple: multiple,
2096
+ onChange: handleChange,
2097
+ type: "file",
2098
+ value: "",
2099
+ disabled: disabled
2100
+ })
2101
+ ]
2102
+ });
2103
+ });
2104
+
2105
+
2106
+ const $8a74cfcfbdb3efdf$var$LockCard = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
2107
+ position: absolute;
2108
+ top: 0;
2109
+ left: 0;
2110
+ opacity: 0.6;
2111
+ mix-blend-mode: screen;
2112
+ background: transparent;
2113
+ `;
2114
+ const $8a74cfcfbdb3efdf$var$LockButton = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Button))`
2115
+ background: transparent;
2116
+ color: white;
2117
+ `;
2118
+ function $8a74cfcfbdb3efdf$var$PlayerActionsMenu(props) {
2119
+ const { asset: asset , readOnly: readOnly , dialogState: dialogState , setDialogState: setDialogState , onChange: onChange , onUpload: onUpload } = props;
2120
+ const [open, setOpen] = (0, $dyHF6$react.useState)(false);
2121
+ const [menuElement, setMenuRef] = (0, $dyHF6$react.useState)(null);
2122
+ const isSigned = (0, $dyHF6$react.useMemo)(()=>(0, $5bbe48978fdc9616$export$f7d2546fac75bbd)(asset) === "signed", [
2123
+ asset
2124
+ ]);
2125
+ const onReset = (0, $dyHF6$react.useCallback)(()=>onChange((0, $dyHF6$sanityform.PatchEvent).from((0, $dyHF6$sanityform.unset)([]))), [
2126
+ onChange
2127
+ ]);
2128
+ (0, $dyHF6$react.useEffect)(()=>{
2129
+ if (open && dialogState) setOpen(false);
2130
+ }, [
2131
+ dialogState,
2132
+ open
2133
+ ]);
2134
+ (0, $dyHF6$sanityui.useClickOutside)((0, $dyHF6$react.useCallback)(()=>setOpen(false), []), [
2135
+ menuElement
2136
+ ]);
2137
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Inline), {
2138
+ space: 1,
2139
+ padding: 2,
2140
+ children: [
2141
+ isSigned && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Tooltip), {
2142
+ content: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
2143
+ padding: 2,
2144
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
2145
+ muted: true,
2146
+ size: 1,
2147
+ children: "Signed playback policy"
2148
+ })
2149
+ }),
2150
+ placement: "right",
2151
+ portal: true,
2152
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($8a74cfcfbdb3efdf$var$LockCard, {
2153
+ radius: 2,
2154
+ margin: 2,
2155
+ scheme: "dark",
2156
+ tone: "positive",
2157
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($8a74cfcfbdb3efdf$var$LockButton, {
2158
+ icon: (0, $dyHF6$sanityicons.LockIcon),
2159
+ mode: "bleed",
2160
+ tone: "positive"
2161
+ })
2162
+ })
2163
+ }),
2164
+ !readOnly && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
2165
+ icon: (0, $dyHF6$sanityicons.EditIcon),
2166
+ mode: "ghost",
2167
+ onClick: ()=>setDialogState("edit-thumbnail")
2168
+ }),
2169
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Popover), {
2170
+ content: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Menu), {
2171
+ ref: setMenuRef,
2172
+ children: [
2173
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
2174
+ padding: 2,
2175
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Label), {
2176
+ muted: true,
2177
+ size: 1,
2178
+ children: "Replace"
2179
+ })
2180
+ }),
2181
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $a1238a31a065a28d$export$c1c647ae58701638), {
2182
+ accept: "video/*",
2183
+ icon: (0, $dyHF6$sanityicons.UploadIcon),
2184
+ mode: "bleed",
2185
+ onSelect: onUpload,
2186
+ text: "Upload",
2187
+ disabled: readOnly,
2188
+ fontSize: 2
2189
+ }),
2190
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuItem), {
2191
+ icon: (0, $dyHF6$sanityicons.SearchIcon),
2192
+ text: "Browse",
2193
+ onClick: ()=>setDialogState("select-video")
2194
+ }),
2195
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuDivider), {}),
2196
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuItem), {
2197
+ icon: (0, $dyHF6$sanityicons.PlugIcon),
2198
+ text: "Configure API",
2199
+ onClick: ()=>setDialogState("secrets")
2200
+ }),
2201
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuDivider), {}),
2202
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.MenuItem), {
2203
+ tone: "critical",
2204
+ icon: (0, $dyHF6$sanityicons.ResetIcon),
2205
+ text: "Clear field",
2206
+ onClick: onReset,
2207
+ disabled: readOnly
2208
+ })
2209
+ ]
2210
+ }),
2211
+ portal: true,
2212
+ open: open,
2213
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
2214
+ icon: (0, $dyHF6$sanityicons.EllipsisVerticalIcon),
2215
+ mode: "ghost",
2216
+ onClick: ()=>{
2217
+ setDialogState(false);
2218
+ setOpen(true);
2219
+ }
2220
+ })
2221
+ })
2222
+ ]
2223
+ });
2224
+ }
2225
+ var $8a74cfcfbdb3efdf$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $dyHF6$react.memo)($8a74cfcfbdb3efdf$var$PlayerActionsMenu);
2226
+
2227
+
2228
+
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+ function $ef74f13c86627be6$export$ed320981107bc6bd(component) {
2236
+ return (0, ($parcel$interopDefault($dyHF6$styledcomponents)))(component)((props)=>{
2237
+ const border = {
2238
+ width: props.$border ? 1 : 0,
2239
+ color: "var(--card-border-color)"
2240
+ };
2241
+ return (0, $dyHF6$styledcomponents.css)`
2242
+ --card-focus-box-shadow: ${(0, $c3640926d3b4b579$export$a79bcc1dc439e294)(border)};
2243
+
2244
+ border-radius: ${(0, $dyHF6$sanityui.rem)(props.theme.sanity.radius[1])};
2245
+ outline: none;
2246
+ box-shadow: var(--card-focus-box-shadow);
2247
+
2248
+ &:focus {
2249
+ --card-focus-box-shadow: ${(0, $c3640926d3b4b579$export$c339ddc20364daad)({
2250
+ base: props.theme.sanity.color.base,
2251
+ border: border,
2252
+ focusRing: props.theme.sanity.focusRing
2253
+ })};
2254
+ }
2255
+ `;
2256
+ });
2257
+ }
2258
+
2259
+
2260
+
2261
+
2262
+ const $59b5a0f5519b63e4$var$ctrlKey = 17;
2263
+ const $59b5a0f5519b63e4$var$cmdKey = 91;
2264
+ const $59b5a0f5519b63e4$var$UploadCardWithFocusRing = (0, $ef74f13c86627be6$export$ed320981107bc6bd)((0, $dyHF6$sanityui.Card));
2265
+ const $59b5a0f5519b63e4$export$88f8ee83ae881d58 = /*#__PURE__*/ (0, $dyHF6$react.forwardRef)(({ children: children , tone: tone , onPaste: onPaste , onFocus: onFocus , onBlur: onBlur , onDrop: onDrop , onDragEnter: onDragEnter , onDragLeave: onDragLeave , onDragOver: onDragOver }, forwardedRef)=>{
2266
+ const ctrlDown = (0, $dyHF6$react.useRef)(false);
2267
+ const inputRef = (0, $dyHF6$react.useRef)(null);
2268
+ const handleKeyDown = (0, $dyHF6$react.useCallback)((event)=>{
2269
+ if (event.keyCode == $59b5a0f5519b63e4$var$ctrlKey || event.keyCode == $59b5a0f5519b63e4$var$cmdKey) ctrlDown.current = true;
2270
+ const vKey = 86;
2271
+ if (ctrlDown.current && event.keyCode == vKey) inputRef.current.focus();
2272
+ }, []);
2273
+ const handleKeyUp = (0, $dyHF6$react.useCallback)((event)=>{
2274
+ if (event.keyCode == $59b5a0f5519b63e4$var$ctrlKey || event.keyCode == $59b5a0f5519b63e4$var$cmdKey) ctrlDown.current = false;
2275
+ }, []);
2276
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($59b5a0f5519b63e4$var$UploadCardWithFocusRing, {
2277
+ tone: tone,
2278
+ height: "fill",
2279
+ ref: forwardedRef,
2280
+ padding: 0,
2281
+ radius: 2,
2282
+ shadow: 0,
2283
+ tabIndex: 0,
2284
+ onKeyDown: handleKeyDown,
2285
+ onKeyUp: handleKeyUp,
2286
+ onPaste: onPaste,
2287
+ onFocus: onFocus,
2288
+ onBlur: onBlur,
2289
+ onDrop: onDrop,
2290
+ onDragEnter: onDragEnter,
2291
+ onDragLeave: onDragLeave,
2292
+ onDragOver: onDragOver,
2293
+ children: [
2294
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($59b5a0f5519b63e4$var$HiddenInput, {
2295
+ ref: inputRef,
2296
+ onPaste: onPaste
2297
+ }),
2298
+ children
2299
+ ]
2300
+ });
2301
+ });
2302
+ const $59b5a0f5519b63e4$var$HiddenInput = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).input.attrs({
2303
+ type: "text"
2304
+ })`
2305
+ position: absolute;
2306
+ border: 0;
2307
+ color: white;
2308
+ opacity: 0;
2309
+
2310
+ &:focus {
2311
+ outline: none;
2312
+ }
2313
+ `;
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+
2324
+
2325
+
2326
+
2327
+ const $71bea6581a27d1cb$var$HiddenInput = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).input`
2328
+ overflow: hidden;
2329
+ width: 0.1px;
2330
+ height: 0.1px;
2331
+ opacity: 0;
2332
+ position: absolute;
2333
+ z-index: -1;
2334
+ `;
2335
+ const $71bea6581a27d1cb$var$Label = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).label`
2336
+ position: relative;
2337
+ `;
2338
+ const $71bea6581a27d1cb$export$c6c4e824471beee6 = ({ onSelect: onSelect , ...props })=>{
2339
+ const inputId = `FileSelect${(0, $dyHF6$reachautoid.useId)()}`;
2340
+ const inputRef = (0, $dyHF6$react.useRef)(null);
2341
+ const handleSelect = (0, $dyHF6$react.useCallback)((event)=>{
2342
+ if (onSelect) onSelect(event.target.files);
2343
+ }, [
2344
+ onSelect
2345
+ ]);
2346
+ const handleButtonClick = (0, $dyHF6$react.useCallback)(()=>inputRef.current?.click(), []);
2347
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($71bea6581a27d1cb$var$Label, {
2348
+ htmlFor: inputId,
2349
+ children: [
2350
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($71bea6581a27d1cb$var$HiddenInput, {
2351
+ accept: "video/*",
2352
+ ref: inputRef,
2353
+ tabIndex: 0,
2354
+ type: "file",
2355
+ id: inputId,
2356
+ onChange: handleSelect,
2357
+ value: ""
2358
+ }),
2359
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
2360
+ onClick: handleButtonClick,
2361
+ mode: "default",
2362
+ tone: "primary",
2363
+ style: {
2364
+ width: "100%"
2365
+ },
2366
+ ...props
2367
+ })
2368
+ ]
2369
+ });
2370
+ };
2371
+
2372
+
2373
+ const $c862462ae08f977b$var$UploadCard = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
2374
+ && {
2375
+ border-style: dashed;
2376
+ }
2377
+ `;
2378
+ const $c862462ae08f977b$var$ConfigureApiBox = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
2379
+ position: absolute;
2380
+ top: 0;
2381
+ right: 0;
2382
+ `;
2383
+ function $c862462ae08f977b$export$2e2bcd8739ae039(props) {
2384
+ const { setDialogState: setDialogState , readOnly: readOnly , onSelect: onSelect , hovering: hovering , needsSetup: needsSetup } = props;
2385
+ const handleBrowse = (0, $dyHF6$react.useCallback)(()=>setDialogState("select-video"), [
2386
+ setDialogState
2387
+ ]);
2388
+ const handleConfigureApi = (0, $dyHF6$react.useCallback)(()=>setDialogState("secrets"), [
2389
+ setDialogState
2390
+ ]);
2391
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
2392
+ style: {
2393
+ padding: 1,
2394
+ position: "relative"
2395
+ },
2396
+ height: "stretch",
2397
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($c862462ae08f977b$var$UploadCard, {
2398
+ sizing: "border",
2399
+ height: "fill",
2400
+ tone: readOnly ? "transparent" : "inherit",
2401
+ border: true,
2402
+ padding: 3,
2403
+ style: hovering ? {
2404
+ borderColor: "transparent"
2405
+ } : undefined,
2406
+ children: [
2407
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($c862462ae08f977b$var$ConfigureApiBox, {
2408
+ padding: 3,
2409
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
2410
+ padding: 3,
2411
+ radius: 3,
2412
+ tone: needsSetup ? "critical" : undefined,
2413
+ onClick: handleConfigureApi,
2414
+ icon: (0, $dyHF6$sanityicons.PlugIcon),
2415
+ mode: "bleed"
2416
+ })
2417
+ }),
2418
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
2419
+ align: "center",
2420
+ justify: "space-between",
2421
+ gap: 4,
2422
+ direction: [
2423
+ "column",
2424
+ "column",
2425
+ "row"
2426
+ ],
2427
+ paddingY: [
2428
+ 2,
2429
+ 2,
2430
+ 0
2431
+ ],
2432
+ sizing: "border",
2433
+ height: "fill",
2434
+ children: [
2435
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
2436
+ align: "center",
2437
+ justify: "center",
2438
+ gap: 2,
2439
+ flex: 1,
2440
+ children: [
2441
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
2442
+ justify: "center",
2443
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
2444
+ muted: true,
2445
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.DocumentVideoIcon), {})
2446
+ })
2447
+ }),
2448
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
2449
+ justify: "center",
2450
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
2451
+ size: 1,
2452
+ muted: true,
2453
+ children: "Drag video or paste URL here"
2454
+ })
2455
+ })
2456
+ ]
2457
+ }),
2458
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Inline), {
2459
+ space: 2,
2460
+ children: [
2461
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $71bea6581a27d1cb$export$c6c4e824471beee6), {
2462
+ mode: "ghost",
2463
+ tone: "default",
2464
+ icon: (0, $dyHF6$sanityicons.UploadIcon),
2465
+ text: "Upload",
2466
+ onSelect: onSelect
2467
+ }),
2468
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
2469
+ mode: "ghost",
2470
+ icon: (0, $dyHF6$sanityicons.SearchIcon),
2471
+ text: "Select",
2472
+ onClick: handleBrowse
2473
+ })
2474
+ ]
2475
+ })
2476
+ ]
2477
+ })
2478
+ ]
2479
+ })
2480
+ });
2481
+ }
2482
+
2483
+
2484
+
2485
+ class $ee85957326065d04$var$MuxVideoInputUploader extends (0, $dyHF6$react.Component) {
2486
+ state = {
2487
+ isDraggingOver: false,
2488
+ invalidPaste: false,
2489
+ invalidFile: false,
2490
+ uploadProgress: null,
2491
+ fileInfo: null,
2492
+ uuid: null,
2493
+ error: null,
2494
+ url: null
2495
+ };
2496
+ dragEnteredEls = [];
2497
+ ctrlDown = false;
2498
+ // eslint-disable-next-line no-warning-comments
2499
+ // @TODO add proper typings for the return values of uploadFile and uploadUrl
2500
+ upload = null;
2501
+ container = /*#__PURE__*/ (0, ($parcel$interopDefault($dyHF6$react))).createRef();
2502
+ componentWillUnmount() {
2503
+ this.unSubscribeToUpload();
2504
+ }
2505
+ componentDidMount() {
2506
+ const events$ = new (0, $dyHF6$rxjs.Subject)();
2507
+ this.onCancelUploadButtonClick$ = events$.asObservable();
2508
+ this.handleCancelUploadButtonClick = (event)=>events$.next(event);
2509
+ }
2510
+ unSubscribeToUpload() {
2511
+ if (this.upload && !this.upload.closed) this.upload.unsubscribe();
2512
+ }
2513
+ handleProgress = (evt)=>{
2514
+ this.setState({
2515
+ uploadProgress: evt.percent
2516
+ });
2517
+ };
2518
+ onUpload = (files)=>{
2519
+ this.setState({
2520
+ uploadProgress: 0,
2521
+ fileInfo: null,
2522
+ uuid: null
2523
+ });
2524
+ this.upload = (0, $4a210fa13f9688e9$export$a5575dbeeffdad98)(this.props.config, this.props.client, files[0], {
2525
+ enableSignedUrls: this.props.secrets.enableSignedUrls
2526
+ }).pipe((0, $dyHF6$rxjsoperators.takeUntil)(this.onCancelUploadButtonClick$.pipe((0, $dyHF6$rxjsoperators.tap)(()=>{
2527
+ if (this.state.uuid) this.props.client.delete(this.state.uuid);
2528
+ })))).subscribe({
2529
+ complete: ()=>{
2530
+ this.setState({
2531
+ error: null,
2532
+ uploadProgress: null,
2533
+ uuid: null
2534
+ });
2535
+ },
2536
+ next: (event)=>{
2537
+ this.handleUploadEvent(event);
2538
+ },
2539
+ error: (err)=>{
2540
+ this.setState({
2541
+ error: err,
2542
+ uploadProgress: null,
2543
+ uuid: null
2544
+ });
2545
+ }
2546
+ });
2547
+ };
2548
+ // eslint-disable-next-line no-warning-comments
2549
+ // @TODO add proper typings for the Observable events
2550
+ handleUploadEvent = (event)=>{
2551
+ switch(event.type){
2552
+ case "success":
2553
+ return this.handleUploadSuccess(event.asset);
2554
+ case "progress":
2555
+ return this.handleProgress(event);
2556
+ case "file":
2557
+ return this.setState({
2558
+ fileInfo: event.file
2559
+ });
2560
+ case "uuid":
2561
+ // Means we created a mux.videoAsset document with an uuid
2562
+ return this.setState({
2563
+ uuid: event.uuid
2564
+ });
2565
+ case "url":
2566
+ return this.setState({
2567
+ url: event.url,
2568
+ uploadProgress: 100
2569
+ });
2570
+ default:
2571
+ return null;
2572
+ }
2573
+ };
2574
+ handleUploadSuccess = (asset)=>{
2575
+ this.setState({
2576
+ uploadProgress: 100
2577
+ });
2578
+ this.props.onChange((0, $dyHF6$sanityform.PatchEvent).from([
2579
+ (0, $dyHF6$sanityform.setIfMissing)({
2580
+ asset: {}
2581
+ }),
2582
+ (0, $dyHF6$sanityform.set)({
2583
+ _type: "reference",
2584
+ _weak: true,
2585
+ _ref: asset._id
2586
+ }, [
2587
+ "asset"
2588
+ ]),
2589
+ ]));
2590
+ };
2591
+ handlePaste = (event)=>{
2592
+ const clipboardData = event.clipboardData || window.clipboardData;
2593
+ const url = clipboardData.getData("text");
2594
+ const options = {
2595
+ enableSignedUrls: this.props.secrets.enableSignedUrls
2596
+ };
2597
+ this.upload = (0, $4a210fa13f9688e9$export$f35af194eb27b25f)(this.props.config, this.props.client, url, options).subscribe({
2598
+ complete: ()=>{
2599
+ this.setState({
2600
+ error: null,
2601
+ uploadProgress: null,
2602
+ url: null
2603
+ });
2604
+ },
2605
+ next: (sEvent)=>{
2606
+ this.handleUploadEvent(sEvent);
2607
+ },
2608
+ error: (err)=>{
2609
+ let error;
2610
+ // Don't output error dialog when just invalid url
2611
+ if (!err.message.toLowerCase().match("invalid url")) error = err;
2612
+ this.setState({
2613
+ invalidPaste: true,
2614
+ error: error
2615
+ }, ()=>{
2616
+ setTimeout(()=>{
2617
+ this.setState({
2618
+ invalidPaste: false,
2619
+ uploadProgress: null
2620
+ });
2621
+ }, 2000);
2622
+ });
2623
+ }
2624
+ });
2625
+ };
2626
+ handleDrop = (event)=>{
2627
+ this.setState({
2628
+ isDraggingOver: false
2629
+ });
2630
+ event.preventDefault();
2631
+ event.stopPropagation();
2632
+ (0, $94a513daa91cd04e$export$73f6d6d8d794f645)(event.nativeEvent.dataTransfer).then((files)=>{
2633
+ if (files) // eslint-disable-next-line no-warning-comments
2634
+ // @TODO fix the typing on files
2635
+ this.onUpload(files);
2636
+ });
2637
+ };
2638
+ handleDragOver = (event)=>{
2639
+ event.preventDefault();
2640
+ event.stopPropagation();
2641
+ };
2642
+ handleDragEnter = (event)=>{
2643
+ event.stopPropagation();
2644
+ this.dragEnteredEls.push(event.target);
2645
+ this.setState({
2646
+ isDraggingOver: true
2647
+ });
2648
+ const type = event.dataTransfer.items?.[0]?.type;
2649
+ this.setState({
2650
+ invalidFile: !type.startsWith("video/")
2651
+ });
2652
+ };
2653
+ handleDragLeave = (event)=>{
2654
+ event.stopPropagation();
2655
+ const idx = this.dragEnteredEls.indexOf(event.target);
2656
+ if (idx > -1) this.dragEnteredEls.splice(idx, 1);
2657
+ if (this.dragEnteredEls.length === 0) this.setState({
2658
+ isDraggingOver: false
2659
+ });
2660
+ };
2661
+ render() {
2662
+ if (this.state.uploadProgress !== null) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $18e643189121e331$export$98a3886347b629fb), {
2663
+ onCancel: this.handleCancelUploadButtonClick,
2664
+ progress: this.state.uploadProgress,
2665
+ filename: this.state.fileInfo?.name || this.state.url
2666
+ });
2667
+ if (this.state.error) // @TODO better error handling
2668
+ throw this.state.error;
2669
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
2670
+ children: [
2671
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $59b5a0f5519b63e4$export$88f8ee83ae881d58), {
2672
+ tone: this.state.isDraggingOver && (this.state.invalidPaste || this.state.invalidFile) ? "critical" : this.state.isDraggingOver ? "positive" : undefined,
2673
+ onBlur: this.props.onBlur,
2674
+ onFocus: this.props.onFocus,
2675
+ onDrop: this.handleDrop,
2676
+ onDragOver: this.handleDragOver,
2677
+ onDragLeave: this.handleDragLeave,
2678
+ onDragEnter: this.handleDragEnter,
2679
+ onPaste: this.handlePaste,
2680
+ ref: this.container,
2681
+ children: this.props.asset ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $4b270840a4c34b64$export$2e2bcd8739ae039), {
2682
+ readOnly: this.props.readOnly,
2683
+ asset: this.props.asset,
2684
+ onChange: this.props.onChange,
2685
+ dialogState: this.props.dialogState,
2686
+ setDialogState: this.props.setDialogState,
2687
+ buttons: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $8a74cfcfbdb3efdf$export$2e2bcd8739ae039), {
2688
+ asset: this.props.asset,
2689
+ dialogState: this.props.dialogState,
2690
+ setDialogState: this.props.setDialogState,
2691
+ onChange: this.props.onChange,
2692
+ onUpload: this.onUpload,
2693
+ readOnly: this.props.readOnly
2694
+ })
2695
+ }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $c862462ae08f977b$export$2e2bcd8739ae039), {
2696
+ hovering: this.state.isDraggingOver,
2697
+ onSelect: this.onUpload,
2698
+ readOnly: this.props.readOnly,
2699
+ setDialogState: this.props.setDialogState,
2700
+ needsSetup: this.props.needsSetup
2701
+ })
2702
+ }),
2703
+ this.props.dialogState === "select-video" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $002b8d5a97e55801$export$2e2bcd8739ae039), {
2704
+ asset: this.props.asset,
2705
+ onChange: this.props.onChange,
2706
+ setDialogState: this.props.setDialogState
2707
+ })
2708
+ ]
2709
+ });
2710
+ }
2711
+ }
2712
+ var $ee85957326065d04$export$2e2bcd8739ae039 = $ee85957326065d04$var$MuxVideoInputUploader;
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+ const $624f4dcaee76afb6$export$e1d4ef4fde5dbdf2 = (client, secrets)=>{
2724
+ return (0, $dyHF6$react.useCallback)(async ({ token: token , secretKey: secretKey , enableSignedUrls: enableSignedUrls })=>{
2725
+ let { signingKeyId: signingKeyId , signingKeyPrivate: signingKeyPrivate } = secrets;
2726
+ try {
2727
+ await (0, $58acdddf66edce65$export$f16c6d66b9790f06)(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate);
2728
+ const valid = await (0, $58acdddf66edce65$export$3a1df1322191b3ef)(client);
2729
+ if (!valid?.status && token && secretKey) throw new Error("Invalid secrets");
2730
+ } catch (err) {
2731
+ console.error("Error while trying to save secrets:", err);
2732
+ throw err;
2733
+ }
2734
+ if (enableSignedUrls) {
2735
+ const hasValidSigningKeys = await (0, $58acdddf66edce65$export$f5836111430d17bc)(client, signingKeyId, signingKeyPrivate);
2736
+ if (!hasValidSigningKeys) try {
2737
+ const { data: data } = await (0, $58acdddf66edce65$export$21cc0cab779cfac1)(client);
2738
+ signingKeyId = data.id;
2739
+ signingKeyPrivate = data.private_key;
2740
+ await (0, $58acdddf66edce65$export$f16c6d66b9790f06)(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate);
2741
+ } catch (err) {
2742
+ // eslint-disable-next-line no-console
2743
+ console.log("Error while creating and saving signing key:", err.message);
2744
+ throw err;
2745
+ }
2746
+ }
2747
+ return {
2748
+ token: token,
2749
+ secretKey: secretKey,
2750
+ enableSignedUrls: enableSignedUrls,
2751
+ signingKeyId: signingKeyId,
2752
+ signingKeyPrivate: signingKeyPrivate
2753
+ };
2754
+ }, [
2755
+ client,
2756
+ secrets
2757
+ ]);
2758
+ };
2759
+
2760
+
2761
+
2762
+ function $2f6a2877401ba7f3$var$init({ token: token , secretKey: secretKey , enableSignedUrls: enableSignedUrls }) {
2763
+ return {
2764
+ submitting: false,
2765
+ error: null,
2766
+ // Form inputs don't set the state back to null when clearing a field, but uses empty strings
2767
+ // This ensures the `dirty` check works correctly
2768
+ token: token ?? "",
2769
+ secretKey: secretKey ?? "",
2770
+ enableSignedUrls: enableSignedUrls ?? false
2771
+ };
2772
+ }
2773
+ function $2f6a2877401ba7f3$var$reducer(state, action) {
2774
+ switch(action?.type){
2775
+ case "submit":
2776
+ return {
2777
+ ...state,
2778
+ submitting: true,
2779
+ error: null
2780
+ };
2781
+ case "error":
2782
+ return {
2783
+ ...state,
2784
+ submitting: false,
2785
+ error: action.payload
2786
+ };
2787
+ case "reset":
2788
+ return $2f6a2877401ba7f3$var$init(action.payload);
2789
+ case "change":
2790
+ return {
2791
+ ...state,
2792
+ [action.payload.name]: action.payload.value
2793
+ };
2794
+ default:
2795
+ throw new Error(`Unknown action type: ${action?.type}`);
2796
+ }
2797
+ }
2798
+ const $2f6a2877401ba7f3$export$e24a74f4fce2446c = (secrets)=>(0, $dyHF6$react.useReducer)($2f6a2877401ba7f3$var$reducer, secrets, $2f6a2877401ba7f3$var$init);
2799
+
2800
+
2801
+
2802
+
2803
+
2804
+
2805
+
2806
+
2807
+
2808
+
2809
+ // Mapping ids to ensure filter refs are unique, otherwise all Logo instances are hidden if the first SVG is hidden, due to how SVGs deal with relative links and ids
2810
+ const $81c579b2354bfb4d$var$ids = [
2811
+ "title",
2812
+ "a",
2813
+ "b",
2814
+ "c",
2815
+ "d",
2816
+ "e",
2817
+ "f",
2818
+ "g",
2819
+ "h",
2820
+ "i",
2821
+ "j",
2822
+ "k",
2823
+ "l",
2824
+ "m",
2825
+ "n",
2826
+ "o",
2827
+ "p",
2828
+ "q",
2829
+ "r",
2830
+ ];
2831
+ function $81c579b2354bfb4d$export$2e2bcd8739ae039({ height: height = 26 }) {
2832
+ const id = (0, $dyHF6$reachautoid.useId)();
2833
+ const [titleId, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = (0, $dyHF6$react.useMemo)(()=>$81c579b2354bfb4d$var$ids.map((field)=>`${id}-${field}`), [
2834
+ id
2835
+ ]);
2836
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("svg", {
2837
+ "aria-labelledby": titleId,
2838
+ role: "img",
2839
+ xmlns: "http://www.w3.org/2000/svg",
2840
+ xmlSpace: "preserve",
2841
+ viewBox: "92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",
2842
+ style: {
2843
+ height: `${height}px`
2844
+ },
2845
+ children: [
2846
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("title", {
2847
+ id: titleId,
2848
+ children: "Mux Logo"
2849
+ }),
2850
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("defs", {
2851
+ children: [
2852
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2853
+ id: c,
2854
+ spreadMethod: "pad",
2855
+ gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
2856
+ gradientUnits: "userSpaceOnUse",
2857
+ y2: 0,
2858
+ x2: 1,
2859
+ y1: 0,
2860
+ x1: 0,
2861
+ children: [
2862
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2863
+ offset: 0,
2864
+ style: {
2865
+ stopOpacity: 1,
2866
+ stopColor: "#ff4e00"
2867
+ }
2868
+ }),
2869
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2870
+ offset: 1,
2871
+ style: {
2872
+ stopOpacity: 1,
2873
+ stopColor: "#ff1791"
2874
+ }
2875
+ })
2876
+ ]
2877
+ }),
2878
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2879
+ id: d,
2880
+ spreadMethod: "pad",
2881
+ gradientTransform: "matrix(523.66766 0 0 -523.66766 67.897 159.5)",
2882
+ gradientUnits: "userSpaceOnUse",
2883
+ y2: 0,
2884
+ x2: 1,
2885
+ y1: 0,
2886
+ x1: 0,
2887
+ children: [
2888
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2889
+ offset: 0,
2890
+ style: {
2891
+ stopOpacity: 1,
2892
+ stopColor: "#ff4e00"
2893
+ }
2894
+ }),
2895
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2896
+ offset: 1,
2897
+ style: {
2898
+ stopOpacity: 1,
2899
+ stopColor: "#ff1791"
2900
+ }
2901
+ })
2902
+ ]
2903
+ }),
2904
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2905
+ id: g,
2906
+ spreadMethod: "pad",
2907
+ gradientTransform: "rotate(180 296.075 79.75) scale(524.84045)",
2908
+ gradientUnits: "userSpaceOnUse",
2909
+ y2: 0,
2910
+ x2: 1,
2911
+ y1: 0,
2912
+ x1: 0,
2913
+ children: [
2914
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2915
+ offset: 0,
2916
+ style: {
2917
+ stopOpacity: 1,
2918
+ stopColor: "#ff4e00"
2919
+ }
2920
+ }),
2921
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2922
+ offset: 1,
2923
+ style: {
2924
+ stopOpacity: 1,
2925
+ stopColor: "#ff1791"
2926
+ }
2927
+ })
2928
+ ]
2929
+ }),
2930
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2931
+ id: i,
2932
+ spreadMethod: "pad",
2933
+ gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2934
+ gradientUnits: "userSpaceOnUse",
2935
+ y2: 0,
2936
+ x2: 1,
2937
+ y1: 0,
2938
+ x1: 0,
2939
+ children: [
2940
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2941
+ offset: 0,
2942
+ style: {
2943
+ stopOpacity: 1,
2944
+ stopColor: "#ff4e00"
2945
+ }
2946
+ }),
2947
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2948
+ offset: 1,
2949
+ style: {
2950
+ stopOpacity: 1,
2951
+ stopColor: "#ff1791"
2952
+ }
2953
+ })
2954
+ ]
2955
+ }),
2956
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2957
+ id: j,
2958
+ spreadMethod: "pad",
2959
+ gradientTransform: "matrix(523.08514 0 0 -523.08514 67.897 224.446)",
2960
+ gradientUnits: "userSpaceOnUse",
2961
+ y2: 0,
2962
+ x2: 1,
2963
+ y1: 0,
2964
+ x1: 0,
2965
+ children: [
2966
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2967
+ offset: 0,
2968
+ style: {
2969
+ stopOpacity: 1,
2970
+ stopColor: "#ff4e00"
2971
+ }
2972
+ }),
2973
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2974
+ offset: 1,
2975
+ style: {
2976
+ stopOpacity: 1,
2977
+ stopColor: "#ff1791"
2978
+ }
2979
+ })
2980
+ ]
2981
+ }),
2982
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
2983
+ id: k,
2984
+ spreadMethod: "pad",
2985
+ gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.553)",
2986
+ gradientUnits: "userSpaceOnUse",
2987
+ y2: 0,
2988
+ x2: 1,
2989
+ y1: 0,
2990
+ x1: 0,
2991
+ children: [
2992
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
2993
+ offset: 0,
2994
+ style: {
2995
+ stopOpacity: 1,
2996
+ stopColor: "#ff4e00"
2997
+ }
2998
+ }),
2999
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3000
+ offset: 1,
3001
+ style: {
3002
+ stopOpacity: 1,
3003
+ stopColor: "#ff1791"
3004
+ }
3005
+ })
3006
+ ]
3007
+ }),
3008
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
3009
+ id: l,
3010
+ spreadMethod: "pad",
3011
+ gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
3012
+ gradientUnits: "userSpaceOnUse",
3013
+ y2: 0,
3014
+ x2: 1,
3015
+ y1: 0,
3016
+ x1: 0,
3017
+ children: [
3018
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3019
+ offset: 0,
3020
+ style: {
3021
+ stopOpacity: 1,
3022
+ stopColor: "#ff4e00"
3023
+ }
3024
+ }),
3025
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3026
+ offset: 1,
3027
+ style: {
3028
+ stopOpacity: 1,
3029
+ stopColor: "#ff1791"
3030
+ }
3031
+ })
3032
+ ]
3033
+ }),
3034
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
3035
+ id: m,
3036
+ spreadMethod: "pad",
3037
+ gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.554)",
3038
+ gradientUnits: "userSpaceOnUse",
3039
+ y2: 0,
3040
+ x2: 1,
3041
+ y1: 0,
3042
+ x1: 0,
3043
+ children: [
3044
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3045
+ offset: 0,
3046
+ style: {
3047
+ stopOpacity: 1,
3048
+ stopColor: "#ff4e00"
3049
+ }
3050
+ }),
3051
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3052
+ offset: 1,
3053
+ style: {
3054
+ stopOpacity: 1,
3055
+ stopColor: "#ff1791"
3056
+ }
3057
+ })
3058
+ ]
3059
+ }),
3060
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
3061
+ id: p,
3062
+ spreadMethod: "pad",
3063
+ gradientTransform: "matrix(521.97632 0 0 -521.97632 69.067 191.973)",
3064
+ gradientUnits: "userSpaceOnUse",
3065
+ y2: 0,
3066
+ x2: 1,
3067
+ y1: 0,
3068
+ x1: 0,
3069
+ children: [
3070
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3071
+ offset: 0,
3072
+ style: {
3073
+ stopOpacity: 1,
3074
+ stopColor: "#ff4e00"
3075
+ }
3076
+ }),
3077
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3078
+ offset: 1,
3079
+ style: {
3080
+ stopOpacity: 1,
3081
+ stopColor: "#ff1791"
3082
+ }
3083
+ })
3084
+ ]
3085
+ }),
3086
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
3087
+ id: q,
3088
+ spreadMethod: "pad",
3089
+ gradientTransform: "matrix(523.09039 0 0 -523.09039 67.312 191.973)",
3090
+ gradientUnits: "userSpaceOnUse",
3091
+ y2: 0,
3092
+ x2: 1,
3093
+ y1: 0,
3094
+ x1: 0,
3095
+ children: [
3096
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3097
+ offset: 0,
3098
+ style: {
3099
+ stopOpacity: 1,
3100
+ stopColor: "#ff4e00"
3101
+ }
3102
+ }),
3103
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3104
+ offset: 1,
3105
+ style: {
3106
+ stopOpacity: 1,
3107
+ stopColor: "#ff1791"
3108
+ }
3109
+ })
3110
+ ]
3111
+ }),
3112
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("linearGradient", {
3113
+ id: r,
3114
+ spreadMethod: "pad",
3115
+ gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
3116
+ gradientUnits: "userSpaceOnUse",
3117
+ y2: 0,
3118
+ x2: 1,
3119
+ y1: 0,
3120
+ x1: 0,
3121
+ children: [
3122
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3123
+ offset: 0,
3124
+ style: {
3125
+ stopOpacity: 1,
3126
+ stopColor: "#ff4e00"
3127
+ }
3128
+ }),
3129
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("stop", {
3130
+ offset: 1,
3131
+ style: {
3132
+ stopOpacity: 1,
3133
+ stopColor: "#ff1791"
3134
+ }
3135
+ })
3136
+ ]
3137
+ }),
3138
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3139
+ id: a,
3140
+ clipPathUnits: "userSpaceOnUse",
3141
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3142
+ d: "M0 319h657.706V0H0Z"
3143
+ })
3144
+ }),
3145
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3146
+ id: b,
3147
+ clipPathUnits: "userSpaceOnUse",
3148
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3149
+ d: "M423.64 242h164.999V77H423.64Z"
3150
+ })
3151
+ }),
3152
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3153
+ id: e,
3154
+ clipPathUnits: "userSpaceOnUse",
3155
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3156
+ d: "M0 319h657.706V0H0Z"
3157
+ })
3158
+ }),
3159
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3160
+ id: f,
3161
+ clipPathUnits: "userSpaceOnUse",
3162
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3163
+ d: "M311.3 242h93.031V77H311.3Z"
3164
+ })
3165
+ }),
3166
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3167
+ id: h,
3168
+ clipPathUnits: "userSpaceOnUse",
3169
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3170
+ d: "M198.96 242h35.106V77H198.96Z"
3171
+ })
3172
+ }),
3173
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3174
+ id: n,
3175
+ clipPathUnits: "userSpaceOnUse",
3176
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3177
+ d: "M0 319h657.706V0H0Z"
3178
+ })
3179
+ }),
3180
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("clipPath", {
3181
+ id: o,
3182
+ clipPathUnits: "userSpaceOnUse",
3183
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3184
+ d: "M69.067 242H169.12V141.947H69.067Z"
3185
+ })
3186
+ })
3187
+ ]
3188
+ }),
3189
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3190
+ clipPath: `url(#${a})`,
3191
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
3192
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3193
+ style: {
3194
+ opacity: 0.69999701
3195
+ },
3196
+ clipPath: `url(#${b})`,
3197
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3198
+ style: {
3199
+ fill: `url(#${c})`,
3200
+ stroke: "none"
3201
+ },
3202
+ d: "M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
3203
+ })
3204
+ })
3205
+ }),
3206
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3207
+ style: {
3208
+ fill: `url(#${d})`,
3209
+ stroke: "none"
3210
+ },
3211
+ d: "M558.674 236.858 428.781 106.966c-6.855-6.855-6.855-17.969 0-24.825 6.855-6.854 17.969-6.854 24.823 0l129.894 129.894c6.854 6.855 6.854 17.968 0 24.823A17.498 17.498 0 0 1 571.086 242a17.495 17.495 0 0 1-12.412-5.142",
3212
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3213
+ }),
3214
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("g", {
3215
+ clipPath: `url(#${e})`,
3216
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
3217
+ children: [
3218
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3219
+ style: {
3220
+ opacity: 0.69999701
3221
+ },
3222
+ clipPath: `url(#${f})`,
3223
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3224
+ style: {
3225
+ fill: `url(#${g})`,
3226
+ stroke: "none"
3227
+ },
3228
+ d: "M328.853 112.107c22.297 0 40.372 18.075 40.372 40.372v71.315c0 10.054 7.505 18.206 17.554 18.206 10.048 0 17.552-8.152 17.552-18.206v-71.315c0-41.686-33.793-75.479-75.478-75.479-9.694 0-17.553 7.859-17.553 17.554 0 9.694 7.859 17.553 17.553 17.553"
3229
+ })
3230
+ }),
3231
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3232
+ style: {
3233
+ opacity: 0.69999701
3234
+ },
3235
+ clipPath: `url(#${h})`,
3236
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3237
+ style: {
3238
+ fill: `url(#${i})`,
3239
+ stroke: "none"
3240
+ },
3241
+ d: "M216.513 242c-10.049 0-17.553-8.152-17.553-18.206V95.206c0-10.054 7.504-18.206 17.553-18.206 10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.054-7.505 18.206-17.553 18.206"
3242
+ })
3243
+ })
3244
+ ]
3245
+ }),
3246
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3247
+ style: {
3248
+ fill: `url(#${j})`,
3249
+ stroke: "none"
3250
+ },
3251
+ d: "M369.225 224.447c0-9.694 7.859-17.553 17.553-17.553 9.695 0 17.553 7.859 17.553 17.553s-7.858 17.552-17.553 17.552c-9.694 0-17.553-7.858-17.553-17.552",
3252
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3253
+ }),
3254
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3255
+ style: {
3256
+ fill: `url(#${k})`,
3257
+ stroke: "none"
3258
+ },
3259
+ d: "M553.532 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.552-17.554 17.552-9.694 0-17.553-7.858-17.553-17.552",
3260
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3261
+ }),
3262
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3263
+ style: {
3264
+ fill: `url(#${l})`,
3265
+ stroke: "none"
3266
+ },
3267
+ d: "M69.067 223.794V95.206C69.067 85.152 76.571 77 86.62 77c10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.055-7.505 18.205-17.553 18.205-10.049 0-17.553-8.15-17.553-18.205",
3268
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3269
+ }),
3270
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3271
+ style: {
3272
+ fill: `url(#${m})`,
3273
+ stroke: "none"
3274
+ },
3275
+ d: "M198.96 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.553-17.554 17.553-9.694 0-17.553-7.859-17.553-17.553",
3276
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3277
+ }),
3278
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3279
+ clipPath: `url(#${n})`,
3280
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
3281
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("g", {
3282
+ style: {
3283
+ opacity: 0.69999701
3284
+ },
3285
+ clipPath: `url(#${o})`,
3286
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3287
+ style: {
3288
+ fill: `url(#${p})`,
3289
+ stroke: "none"
3290
+ },
3291
+ d: "M139.155 147.088c6.855-6.855 17.969-6.855 24.824 0s6.855 17.969 0 24.824l-64.947 64.946c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
3292
+ })
3293
+ })
3294
+ }),
3295
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3296
+ style: {
3297
+ fill: `url(#${q})`,
3298
+ stroke: "none"
3299
+ },
3300
+ d: "m204.101 236.858-64.947-64.946c-6.854-6.855-6.854-17.969 0-24.824 6.856-6.855 17.97-6.855 24.824 0l64.947 64.947c6.855 6.855 6.855 17.968 0 24.823A17.495 17.495 0 0 1 216.513 242a17.498 17.498 0 0 1-12.412-5.142",
3301
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3302
+ }),
3303
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
3304
+ style: {
3305
+ fill: `url(#${r})`,
3306
+ stroke: "none"
3307
+ },
3308
+ d: "M253.374 223.794v-71.315c0-41.685 33.793-75.479 75.479-75.479 9.695 0 17.553 7.859 17.553 17.554 0 9.694-7.858 17.553-17.553 17.553-22.297 0-40.372 18.075-40.372 40.372v71.315c0 10.055-7.505 18.205-17.554 18.205s-17.553-8.15-17.553-18.205",
3309
+ transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
3310
+ })
3311
+ ]
3312
+ });
3313
+ }
3314
+
3315
+
3316
+ const $97292a102d486fd6$var$Logo = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).span`
3317
+ display: inline-block;
3318
+ height: 0.8em;
3319
+ margin-right: 1em;
3320
+ transform: translate(0.3em, -0.2em);
3321
+ `;
3322
+ const $97292a102d486fd6$export$8b251419efc915eb = ()=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
3323
+ children: [
3324
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($97292a102d486fd6$var$Logo, {
3325
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $81c579b2354bfb4d$export$2e2bcd8739ae039), {
3326
+ height: 13
3327
+ })
3328
+ }),
3329
+ "API Credentials"
3330
+ ]
3331
+ });
3332
+
3333
+
3334
+
3335
+
3336
+
3337
+ function $696fc2bd3580ef7e$var$FormField(props) {
3338
+ const { children: children , title: title , description: description , inputId: inputId } = props;
3339
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
3340
+ space: 1,
3341
+ children: [
3342
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
3343
+ align: "flex-end",
3344
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
3345
+ flex: 1,
3346
+ paddingY: 2,
3347
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
3348
+ space: 2,
3349
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
3350
+ children: [
3351
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3352
+ as: "label",
3353
+ htmlFor: inputId,
3354
+ weight: "semibold",
3355
+ size: 1,
3356
+ children: title || /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("em", {
3357
+ children: "Untitled"
3358
+ })
3359
+ }),
3360
+ description && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3361
+ muted: true,
3362
+ size: 1,
3363
+ children: description
3364
+ })
3365
+ ]
3366
+ })
3367
+ })
3368
+ })
3369
+ }),
3370
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
3371
+ children: children
3372
+ })
3373
+ ]
3374
+ });
3375
+ }
3376
+ var $696fc2bd3580ef7e$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $dyHF6$react.memo)($696fc2bd3580ef7e$var$FormField);
3377
+
3378
+
3379
+ const $4a8a0e20ccb63ea2$var$fieldNames = [
3380
+ "token",
3381
+ "secretKey",
3382
+ "enableSignedUrls"
3383
+ ];
3384
+ function $4a8a0e20ccb63ea2$var$ConfigureApi({ secrets: secrets , setDialogState: setDialogState }) {
3385
+ const client = (0, $dyHF6$sanity.useClient)();
3386
+ const [state, dispatch] = (0, $2f6a2877401ba7f3$export$e24a74f4fce2446c)(secrets);
3387
+ const hasSecretsInitially = (0, $dyHF6$react.useMemo)(()=>secrets.token && secrets.secretKey, [
3388
+ secrets
3389
+ ]);
3390
+ const handleClose = (0, $dyHF6$react.useCallback)(()=>setDialogState(false), [
3391
+ setDialogState
3392
+ ]);
3393
+ const dirty = (0, $dyHF6$react.useMemo)(()=>secrets.token !== state.token || secrets.secretKey !== state.secretKey || secrets.enableSignedUrls !== state.enableSignedUrls, [
3394
+ secrets,
3395
+ state
3396
+ ]);
3397
+ const id = `ConfigureApi${(0, $dyHF6$reachautoid.useId)()}`;
3398
+ const [tokenId, secretKeyId, enableSignedUrlsId] = (0, $dyHF6$react.useMemo)(()=>$4a8a0e20ccb63ea2$var$fieldNames.map((field)=>`${id}-${field}`), [
3399
+ id
3400
+ ]);
3401
+ const firstField = (0, $dyHF6$react.useRef)(null);
3402
+ const handleSaveSecrets = (0, $624f4dcaee76afb6$export$e1d4ef4fde5dbdf2)(client, secrets);
3403
+ const saving = (0, $dyHF6$react.useRef)(false);
3404
+ const handleSubmit = (0, $dyHF6$react.useCallback)((event)=>{
3405
+ event.preventDefault();
3406
+ if (!saving.current && event.currentTarget.reportValidity()) {
3407
+ saving.current = true;
3408
+ dispatch({
3409
+ type: "submit"
3410
+ });
3411
+ const { token: token , secretKey: secretKey , enableSignedUrls: enableSignedUrls } = state;
3412
+ handleSaveSecrets({
3413
+ token: token,
3414
+ secretKey: secretKey,
3415
+ enableSignedUrls: enableSignedUrls
3416
+ }).then((savedSecrets)=>{
3417
+ const { projectId: projectId , dataset: dataset } = client.config();
3418
+ (0, $dyHF6$suspendreact.clear)([
3419
+ (0, $2ffcb7ef2a4a67d0$export$13cdb654d47e0703),
3420
+ (0, $edbbfc11873e0f23$export$9c7ae676ac45430a),
3421
+ projectId,
3422
+ dataset
3423
+ ]);
3424
+ (0, $dyHF6$suspendreact.preload)(()=>Promise.resolve(savedSecrets), [
3425
+ (0, $2ffcb7ef2a4a67d0$export$13cdb654d47e0703),
3426
+ (0, $edbbfc11873e0f23$export$9c7ae676ac45430a),
3427
+ projectId,
3428
+ dataset
3429
+ ]);
3430
+ setDialogState(false);
3431
+ }).catch((err)=>dispatch({
3432
+ type: "error",
3433
+ payload: err.message
3434
+ })).finally(()=>{
3435
+ saving.current = false;
3436
+ });
3437
+ }
3438
+ }, [
3439
+ client,
3440
+ dispatch,
3441
+ handleSaveSecrets,
3442
+ setDialogState,
3443
+ state
3444
+ ]);
3445
+ const handleChangeToken = (0, $dyHF6$react.useCallback)((event)=>{
3446
+ dispatch({
3447
+ type: "change",
3448
+ payload: {
3449
+ name: "token",
3450
+ value: event.currentTarget.value
3451
+ }
3452
+ });
3453
+ }, [
3454
+ dispatch
3455
+ ]);
3456
+ const handleChangeSecretKey = (0, $dyHF6$react.useCallback)((event)=>{
3457
+ dispatch({
3458
+ type: "change",
3459
+ payload: {
3460
+ name: "secretKey",
3461
+ value: event.currentTarget.value
3462
+ }
3463
+ });
3464
+ }, [
3465
+ dispatch
3466
+ ]);
3467
+ const handleChangeEnableSignedUrls = (0, $dyHF6$react.useCallback)((event)=>{
3468
+ dispatch({
3469
+ type: "change",
3470
+ payload: {
3471
+ name: "enableSignedUrls",
3472
+ value: event.currentTarget.checked
3473
+ }
3474
+ });
3475
+ }, [
3476
+ dispatch
3477
+ ]);
3478
+ (0, $dyHF6$react.useEffect)(()=>{
3479
+ if (firstField.current) firstField.current.focus();
3480
+ }, [
3481
+ firstField
3482
+ ]);
3483
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Dialog), {
3484
+ id: id,
3485
+ onClose: handleClose,
3486
+ header: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $97292a102d486fd6$export$8b251419efc915eb), {}),
3487
+ width: 0,
3488
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
3489
+ padding: 4,
3490
+ style: {
3491
+ position: "relative"
3492
+ },
3493
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("form", {
3494
+ onSubmit: handleSubmit,
3495
+ noValidate: true,
3496
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
3497
+ space: 4,
3498
+ children: [
3499
+ !hasSecretsInitially && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
3500
+ padding: [
3501
+ 3,
3502
+ 3,
3503
+ 3
3504
+ ],
3505
+ radius: 2,
3506
+ shadow: 1,
3507
+ tone: "primary",
3508
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
3509
+ space: 3,
3510
+ children: [
3511
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
3512
+ size: 1,
3513
+ children: [
3514
+ "To set up a new access token, go to your",
3515
+ " ",
3516
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("a", {
3517
+ href: "https://dashboard.mux.com/settings/access-tokens",
3518
+ target: "_blank",
3519
+ rel: "noreferrer noopener",
3520
+ children: "account on mux.com"
3521
+ }),
3522
+ "."
3523
+ ]
3524
+ }),
3525
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
3526
+ size: 1,
3527
+ children: [
3528
+ "The access token needs permissions: ",
3529
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("strong", {
3530
+ children: "Mux Video "
3531
+ }),
3532
+ "(Full Access) and ",
3533
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("strong", {
3534
+ children: "Mux Data"
3535
+ }),
3536
+ " (Read)",
3537
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("br", {}),
3538
+ "The credentials will be stored safely in a hidden document only available to editors."
3539
+ ]
3540
+ })
3541
+ ]
3542
+ })
3543
+ }),
3544
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $696fc2bd3580ef7e$export$2e2bcd8739ae039), {
3545
+ title: "Access Token",
3546
+ inputId: tokenId,
3547
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.TextInput), {
3548
+ id: tokenId,
3549
+ ref: firstField,
3550
+ onChange: handleChangeToken,
3551
+ type: "text",
3552
+ value: state.token ?? "",
3553
+ required: !!state.secretKey || state.enableSignedUrls
3554
+ })
3555
+ }),
3556
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $696fc2bd3580ef7e$export$2e2bcd8739ae039), {
3557
+ title: "Secret Key",
3558
+ inputId: secretKeyId,
3559
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.TextInput), {
3560
+ id: secretKeyId,
3561
+ onChange: handleChangeSecretKey,
3562
+ type: "text",
3563
+ value: state.secretKey ?? "",
3564
+ required: !!state.token || state.enableSignedUrls
3565
+ })
3566
+ }),
3567
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
3568
+ space: 4,
3569
+ children: [
3570
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
3571
+ align: "center",
3572
+ children: [
3573
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Checkbox), {
3574
+ id: enableSignedUrlsId,
3575
+ onChange: handleChangeEnableSignedUrls,
3576
+ checked: state.enableSignedUrls,
3577
+ style: {
3578
+ display: "block"
3579
+ }
3580
+ }),
3581
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
3582
+ flex: 1,
3583
+ paddingLeft: 3,
3584
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3585
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("label", {
3586
+ htmlFor: enableSignedUrlsId,
3587
+ children: "Enable Signed Urls"
3588
+ })
3589
+ })
3590
+ })
3591
+ ]
3592
+ }),
3593
+ secrets.signingKeyId && state.enableSignedUrls ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
3594
+ padding: [
3595
+ 3,
3596
+ 3,
3597
+ 3
3598
+ ],
3599
+ radius: 2,
3600
+ shadow: 1,
3601
+ tone: "caution",
3602
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
3603
+ space: 3,
3604
+ children: [
3605
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3606
+ size: 1,
3607
+ children: "The signing key ID that Sanity will use is:"
3608
+ }),
3609
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Code), {
3610
+ size: 1,
3611
+ children: secrets.signingKeyId
3612
+ }),
3613
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
3614
+ size: 1,
3615
+ children: [
3616
+ "This key is only used for previewing content in the Sanity UI.",
3617
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("br", {}),
3618
+ "You should generate a different key to use in your application server."
3619
+ ]
3620
+ })
3621
+ ]
3622
+ })
3623
+ }) : null
3624
+ ]
3625
+ }),
3626
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Inline), {
3627
+ space: 2,
3628
+ children: [
3629
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
3630
+ text: "Save",
3631
+ disabled: !dirty,
3632
+ loading: state.submitting,
3633
+ tone: "primary",
3634
+ mode: "default",
3635
+ type: "submit"
3636
+ }),
3637
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
3638
+ disabled: state.submitting,
3639
+ text: "Cancel",
3640
+ mode: "bleed",
3641
+ onClick: handleClose
3642
+ })
3643
+ ]
3644
+ }),
3645
+ state.error && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
3646
+ padding: [
3647
+ 3,
3648
+ 3,
3649
+ 3
3650
+ ],
3651
+ radius: 2,
3652
+ shadow: 1,
3653
+ tone: "critical",
3654
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3655
+ children: state.error
3656
+ })
3657
+ })
3658
+ ]
3659
+ })
3660
+ })
3661
+ })
3662
+ });
3663
+ }
3664
+ var $4a8a0e20ccb63ea2$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $dyHF6$react.memo)($4a8a0e20ccb63ea2$var$ConfigureApi);
3665
+
3666
+
3667
+
3668
+
3669
+
3670
+
3671
+ const $5f180d117773fee7$export$f0c88bc5a320387d = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
3672
+ aspect-ratio: 16 / 9;
3673
+ position: relative;
3674
+ width: 100%;
3675
+ `;
3676
+ const $5f180d117773fee7$export$18fe723e8683ca03 = ()=>{
3677
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
3678
+ style: {
3679
+ padding: 1
3680
+ },
3681
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
3682
+ shadow: 1,
3683
+ sizing: "border",
3684
+ style: {
3685
+ aspectRatio: "16/9",
3686
+ width: "100%",
3687
+ borderRadius: "1px"
3688
+ },
3689
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
3690
+ align: "center",
3691
+ direction: "column",
3692
+ height: "fill",
3693
+ justify: "center",
3694
+ children: [
3695
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {
3696
+ muted: true
3697
+ }),
3698
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
3699
+ marginTop: 3,
3700
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
3701
+ align: "center",
3702
+ muted: true,
3703
+ size: 1,
3704
+ children: "Loading\u2026"
3705
+ })
3706
+ })
3707
+ ]
3708
+ })
3709
+ })
3710
+ });
3711
+ };
3712
+
3713
+
3714
+
3715
+
3716
+
3717
+
3718
+
3719
+ function $20bd1aaec92888dd$export$2e2bcd8739ae039(props) {
3720
+ const { setDialogState: setDialogState } = props;
3721
+ const handleOpen = (0, $dyHF6$react.useCallback)(()=>setDialogState("secrets"), [
3722
+ setDialogState
3723
+ ]);
3724
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
3725
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
3726
+ style: {
3727
+ padding: 2
3728
+ },
3729
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
3730
+ display: "flex",
3731
+ sizing: "border",
3732
+ style: {
3733
+ aspectRatio: "16/9",
3734
+ width: "100%",
3735
+ boxShadow: "var(--card-bg-color) 0 0 0 2px"
3736
+ },
3737
+ paddingX: [
3738
+ 2,
3739
+ 3,
3740
+ 4,
3741
+ 4
3742
+ ],
3743
+ radius: 1,
3744
+ tone: "transparent",
3745
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
3746
+ justify: "flex-start",
3747
+ align: "center",
3748
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Grid), {
3749
+ columns: 1,
3750
+ gap: [
3751
+ 2,
3752
+ 3,
3753
+ 4,
3754
+ 4
3755
+ ],
3756
+ children: [
3757
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Inline), {
3758
+ paddingY: 1,
3759
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
3760
+ style: {
3761
+ height: "32px"
3762
+ },
3763
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $81c579b2354bfb4d$export$2e2bcd8739ae039), {})
3764
+ })
3765
+ }),
3766
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Inline), {
3767
+ paddingY: 1,
3768
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
3769
+ size: [
3770
+ 0,
3771
+ 1,
3772
+ 2,
3773
+ 2
3774
+ ],
3775
+ children: "Upload and preview videos directly from your studio."
3776
+ })
3777
+ }),
3778
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Inline), {
3779
+ paddingY: 1,
3780
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
3781
+ mode: "ghost",
3782
+ icon: (0, $dyHF6$sanityicons.PlugIcon),
3783
+ text: "Configure API",
3784
+ onClick: handleOpen
3785
+ })
3786
+ })
3787
+ ]
3788
+ })
3789
+ })
3790
+ })
3791
+ })
3792
+ });
3793
+ }
3794
+
3795
+
3796
+ const $6bca891f5dd9dfc9$var$Input = (props)=>{
3797
+ const client = (0, $dyHF6$sanity.useClient)();
3798
+ const secretDocumentValues = (0, $8a0ef7d2f7c4ca7e$export$4c2801830a129eb)();
3799
+ const assetDocumentValues = (0, $eef844dd0892040d$export$e11a382d55e07f75)(props.value?.asset);
3800
+ const poll = (0, $9427a85db5895988$export$fd270df25d7dbb88)(props.readOnly ? undefined : assetDocumentValues?.value || undefined);
3801
+ const [dialogState, setDialogState] = (0, $af23ed16e7325a21$export$573903f1c655c034)();
3802
+ const error = secretDocumentValues.error || assetDocumentValues.error || poll.error /*||
3803
+ // @TODO move errored logic to Uploader, where handleRemoveVideo can be called
3804
+ (assetDocumentValues.value?.status === 'errored'
3805
+ ? new Error(assetDocumentValues.value.data?.errors?.messages?.join(' '))
3806
+ : undefined)
3807
+ // */ ;
3808
+ if (error) // @TODO deal with it more gracefully
3809
+ throw error;
3810
+ const isLoading = secretDocumentValues.isLoading || assetDocumentValues.isLoading;
3811
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
3812
+ children: isLoading ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $5f180d117773fee7$export$18fe723e8683ca03), {}) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
3813
+ children: [
3814
+ secretDocumentValues.value.needsSetup && !assetDocumentValues.value ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $20bd1aaec92888dd$export$2e2bcd8739ae039), {
3815
+ setDialogState: setDialogState
3816
+ }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $ee85957326065d04$export$2e2bcd8739ae039), {
3817
+ ...props,
3818
+ client: client,
3819
+ secrets: secretDocumentValues.value.secrets,
3820
+ asset: assetDocumentValues.value,
3821
+ dialogState: dialogState,
3822
+ setDialogState: setDialogState,
3823
+ needsSetup: secretDocumentValues.value.needsSetup
3824
+ }),
3825
+ dialogState === "secrets" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $4a8a0e20ccb63ea2$export$2e2bcd8739ae039), {
3826
+ setDialogState: setDialogState,
3827
+ secrets: secretDocumentValues.value.secrets
3828
+ })
3829
+ ]
3830
+ })
3831
+ });
3832
+ };
3833
+ var $6bca891f5dd9dfc9$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $dyHF6$react.memo)($6bca891f5dd9dfc9$var$Input);
3834
+
3835
+
3836
+
3837
+
3838
+
3839
+
3840
+
3841
+
3842
+ const $cbaf0acf64ca3573$var$MuxVideoPreview = ({ value: value })=>{
3843
+ const assetDocumentValues = (0, $eef844dd0892040d$export$e11a382d55e07f75)(value?.asset);
3844
+ if (assetDocumentValues.value) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6de6709202a3b061$export$bd4b73f15688a160), {
3845
+ asset: assetDocumentValues.value,
3846
+ width: 640
3847
+ });
3848
+ // @ts-expect-error
3849
+ const { filename: filename , playbackId: playbackId , status: status } = value ?? {};
3850
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanity_unstable.SanityDefaultPreview), {
3851
+ title: filename || playbackId || "",
3852
+ subtitle: status ? `status: ${status}` : null
3853
+ });
3854
+ };
3855
+ var $cbaf0acf64ca3573$export$2e2bcd8739ae039 = $cbaf0acf64ca3573$var$MuxVideoPreview;
3856
+
3857
+
3858
+
3859
+
3860
+ const $75523cdda380b780$export$a8ff84c12d48cfa6 = "mux.videoAsset";
3861
+ const $75523cdda380b780$var$videoAsset = (0, $dyHF6$sanity.defineField)({
3862
+ name: $75523cdda380b780$export$a8ff84c12d48cfa6,
3863
+ type: "object",
3864
+ title: "Video asset",
3865
+ fields: [
3866
+ {
3867
+ type: "string",
3868
+ name: "status"
3869
+ },
3870
+ {
3871
+ type: "string",
3872
+ name: "assetId"
3873
+ },
3874
+ {
3875
+ type: "string",
3876
+ name: "playbackId"
3877
+ },
3878
+ {
3879
+ type: "string",
3880
+ name: "filename"
3881
+ },
3882
+ {
3883
+ type: "number",
3884
+ name: "thumbTime"
3885
+ },
3886
+ ]
3887
+ });
3888
+ var $75523cdda380b780$export$2e2bcd8739ae039 = $75523cdda380b780$var$videoAsset;
3889
+
3890
+
3891
+ const $ac55e63956aa9e84$export$a8ff84c12d48cfa6 = "mux.video";
3892
+ const $ac55e63956aa9e84$var$video = (0, $dyHF6$sanity.defineField)({
3893
+ name: $ac55e63956aa9e84$export$a8ff84c12d48cfa6,
3894
+ type: "object",
3895
+ title: "Video asset reference",
3896
+ fields: [
3897
+ {
3898
+ title: "Video",
3899
+ name: "asset",
3900
+ type: "reference",
3901
+ weak: true,
3902
+ to: [
3903
+ {
3904
+ type: (0, $75523cdda380b780$export$a8ff84c12d48cfa6)
3905
+ }
3906
+ ]
3907
+ },
3908
+ ]
3909
+ });
3910
+ var $ac55e63956aa9e84$export$2e2bcd8739ae039 = $ac55e63956aa9e84$var$video;
3911
+
3912
+
3913
+
3914
+
3915
+
3916
+ function $0c6ceed5d95aa3e9$export$c8119cbbd1c84da1(props) {
3917
+ return (0, $dyHF6$sanity.isObjectSchemaType)(props.schemaType) && props.schemaType.type?.name === (0, $ac55e63956aa9e84$export$a8ff84c12d48cfa6);
3918
+ }
3919
+ function $0c6ceed5d95aa3e9$export$3542974c36e4d83f(props) {
3920
+ return props.schemaType.type?.name === (0, $ac55e63956aa9e84$export$a8ff84c12d48cfa6);
3921
+ }
3922
+
334
3923
 
335
- const $329a1cedcedb1349$export$133773870222880f = /*#__PURE__*/ (0, $dyHF6$react.lazy)(()=>(parcelRequire("2vLfV")));
336
3924
  const $329a1cedcedb1349$export$f84bd70098573c5c = {
337
3925
  mp4_support: "none"
338
3926
  };
@@ -345,12 +3933,12 @@ const $329a1cedcedb1349$export$4d2e76c338bb9fbd = (0, $dyHF6$sanity.createPlugin
345
3933
  name: "mux-input",
346
3934
  form: {
347
3935
  renderInput (props, next) {
348
- if ((0, $0c6ceed5d95aa3e9$export$c8119cbbd1c84da1)(props)) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $3PT7X.AspectRatioCard), {
3936
+ if ((0, $0c6ceed5d95aa3e9$export$c8119cbbd1c84da1)(props)) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $5f180d117773fee7$export$f0c88bc5a320387d), {
349
3937
  children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $440e5e6a7a1a5e7d$export$2e2bcd8739ae039), {
350
3938
  schemaType: props.schemaType,
351
3939
  children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$react.Suspense), {
352
- fallback: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $3PT7X.InputFallback), {}),
353
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($329a1cedcedb1349$export$f5b8910cec6cf069, {
3940
+ fallback: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $5f180d117773fee7$export$18fe723e8683ca03), {}),
3941
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $6bca891f5dd9dfc9$export$2e2bcd8739ae039), {
354
3942
  config: config,
355
3943
  ...props
356
3944
  })
@@ -360,8 +3948,8 @@ const $329a1cedcedb1349$export$4d2e76c338bb9fbd = (0, $dyHF6$sanity.createPlugin
360
3948
  return next(props);
361
3949
  },
362
3950
  renderPreview (props, next) {
363
- if ((0, $0c6ceed5d95aa3e9$export$3542974c36e4d83f)(props)) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $3PT7X.AspectRatioCard), {
364
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($329a1cedcedb1349$export$133773870222880f, {
3951
+ if ((0, $0c6ceed5d95aa3e9$export$3542974c36e4d83f)(props)) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $5f180d117773fee7$export$f0c88bc5a320387d), {
3952
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $cbaf0acf64ca3573$export$2e2bcd8739ae039), {
365
3953
  ...props
366
3954
  })
367
3955
  });