sanity-plugin-mux-input 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  mod
20
20
  ));
21
21
  Object.defineProperty(exports, "__esModule", { value: !0 });
22
- var sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), React = require("react"), reactRx = require("react-rx"), compact = require("lodash/compact.js"), toLower = require("lodash/toLower.js"), trim = require("lodash/trim.js"), uniq = require("lodash/uniq.js"), words = require("lodash/words.js"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), rxjs = require("rxjs"), operators = require("rxjs/operators"), suspendReact = require("suspend-react"), MuxPlayer = require("@mux/mux-player-react"), desk = require("sanity/desk"), router = require("sanity/router"), isNumber = require("lodash/isNumber.js"), isString = require("lodash/isString.js"), useSWR = require("swr"), scrollIntoView = require("scroll-into-view-if-needed"), upchunk = require("@mux/upchunk"), reactIs = require("react-is"), LanguagesList = require("iso-639-1");
22
+ var sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), React = require("react"), compact = require("lodash/compact.js"), toLower = require("lodash/toLower.js"), trim = require("lodash/trim.js"), uniq = require("lodash/uniq.js"), words = require("lodash/words.js"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), rxjs = require("rxjs"), operators = require("rxjs/operators"), suspendReact = require("suspend-react"), MuxPlayer = require("@mux/mux-player-react"), desk = require("sanity/desk"), router = require("sanity/router"), isNumber = require("lodash/isNumber.js"), isString = require("lodash/isString.js"), reactRx = require("react-rx"), useSWR = require("swr"), scrollIntoView = require("scroll-into-view-if-needed"), upchunk = require("@mux/upchunk"), reactIs = require("react-is"), LanguagesList = require("iso-639-1");
23
23
  function _interopDefaultCompat(e) {
24
24
  return e && typeof e == "object" && "default" in e ? e : { default: e };
25
25
  }
@@ -71,38 +71,33 @@ const ASSET_SORT_OPTIONS = {
71
71
  createdAsc: { groq: "_createdAt asc", label: "First created (oldest)" },
72
72
  filenameAsc: { groq: "filename asc", label: "By filename (A-Z)" },
73
73
  filenameDesc: { groq: "filename desc", label: "By filename (Z-A)" }
74
- }, useAssetDocuments = ({
75
- documentStore,
76
- sort,
77
- searchQuery
78
- }) => {
79
- const memoizedObservable = React.useMemo(() => {
80
- const search = createSearchFilter(searchQuery), filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && "), sortFragment = ASSET_SORT_OPTIONS[sort].groq;
81
- return documentStore.listenQuery(
82
- /* groq */
83
- `*[${filter}] | order(${sortFragment})`,
84
- search.params,
85
- {
86
- apiVersion: SANITY_API_VERSION
87
- }
88
- );
89
- }, [documentStore, sort, searchQuery]);
90
- return reactRx.useObservable(memoizedObservable, void 0);
91
- };
74
+ }, useAssetDocuments = sanity.createHookFromObservableFactory(({ documentStore, sort, searchQuery }) => {
75
+ const search = createSearchFilter(searchQuery), filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && "), sortFragment = ASSET_SORT_OPTIONS[sort].groq;
76
+ return documentStore.listenQuery(
77
+ /* groq */
78
+ `*[${filter}] | order(${sortFragment})`,
79
+ search.params,
80
+ {
81
+ apiVersion: SANITY_API_VERSION
82
+ }
83
+ );
84
+ });
92
85
  function useAssets() {
93
- const documentStore = sanity.useDocumentStore(), [sort, setSort] = React.useState("createdDesc"), [searchQuery, setSearchQuery] = React.useState(""), assetDocumentsObservable = useAssetDocuments({ documentStore, sort, searchQuery }), isLoading = assetDocumentsObservable === void 0;
86
+ const documentStore = sanity.useDocumentStore(), [sort, setSort] = React.useState("createdDesc"), [searchQuery, setSearchQuery] = React.useState(""), [assetDocuments = [], isLoading] = useAssetDocuments(
87
+ React.useMemo(() => ({ documentStore, sort, searchQuery }), [documentStore, sort, searchQuery])
88
+ );
94
89
  return {
95
90
  assets: React.useMemo(
96
91
  () => (
97
92
  // Avoid displaying both drafts & published assets by collating them together and giving preference to drafts
98
- sanity.collate(assetDocumentsObservable ?? []).map(
93
+ sanity.collate(assetDocuments).map(
99
94
  (collated) => ({
100
95
  ...collated.draft || collated.published || {},
101
96
  _id: collated.id
102
97
  })
103
98
  )
104
99
  ),
105
- [assetDocumentsObservable]
100
+ [assetDocuments]
106
101
  ),
107
102
  isLoading,
108
103
  sort,
@@ -923,7 +918,7 @@ function VideoPlayer({
923
918
  crossOrigin: "anonymous",
924
919
  metadata: {
925
920
  player_name: "Sanity Admin Dashboard",
926
- player_version: "2.5.0",
921
+ player_version: "2.6.0",
927
922
  page_type: "Preview Player"
928
923
  },
929
924
  audio: isAudio,
@@ -1291,10 +1286,9 @@ function getVideoMetadata(doc) {
1291
1286
  };
1292
1287
  }
1293
1288
  function useVideoDetails(props) {
1294
- const documentStore = sanity.useDocumentStore(), toast = ui.useToast(), client = useClient(), [references, referencesLoading] = useDocReferences({
1295
- documentStore,
1296
- id: props.asset._id
1297
- }), [originalAsset, setOriginalAsset] = React.useState(() => props.asset), [filename, setFilename] = React.useState(props.asset.filename), modified = filename !== originalAsset.filename, displayInfo = getVideoMetadata({ ...props.asset, filename }), [state, setState] = React.useState("idle");
1289
+ const documentStore = sanity.useDocumentStore(), toast = ui.useToast(), client = useClient(), [references, referencesLoading] = useDocReferences(
1290
+ React.useMemo(() => ({ documentStore, id: props.asset._id }), [documentStore, props.asset._id])
1291
+ ), [originalAsset, setOriginalAsset] = React.useState(() => props.asset), [filename, setFilename] = React.useState(props.asset.filename), modified = filename !== originalAsset.filename, displayInfo = getVideoMetadata({ ...props.asset, filename }), [state, setState] = React.useState("idle");
1298
1292
  function handleClose() {
1299
1293
  if (state === "idle") {
1300
1294
  if (modified) {
@@ -1936,13 +1930,19 @@ function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, s
1936
1930
  };
1937
1931
  return client.createOrReplace(doc);
1938
1932
  }
1939
- function createSigningKeys(client) {
1940
- const { dataset } = client.config();
1941
- return client.request({
1942
- url: `/addons/mux/signing-keys/${dataset}`,
1943
- withCredentials: !0,
1944
- method: "POST"
1945
- });
1933
+ async function createSigningKeys(client) {
1934
+ try {
1935
+ const { dataset } = client.config();
1936
+ return await client.request({
1937
+ url: `/addons/mux/signing-keys/${dataset}`,
1938
+ withCredentials: !0,
1939
+ method: "POST"
1940
+ });
1941
+ } catch (error) {
1942
+ console.error("Error creating signing keys", error);
1943
+ const message = error.response?.statusCode === 401 ? 'Unauthorized - Failed to create the Signing Key. Please ensure that the token has "System" permissions' : error.message;
1944
+ throw new Error(message);
1945
+ }
1946
1946
  }
1947
1947
  function testSecrets(client) {
1948
1948
  const { dataset } = client.config();
@@ -2050,593 +2050,43 @@ function reducer(state, action) {
2050
2050
  throw new Error(`Unknown action type: ${action?.type}`);
2051
2051
  }
2052
2052
  }
2053
- const useSecretsFormState = (secrets) => React.useReducer(reducer, secrets, init), ids = [
2054
- "title",
2055
- "a",
2056
- "b",
2057
- "c",
2058
- "d",
2059
- "e",
2060
- "f",
2061
- "g",
2062
- "h",
2063
- "i",
2064
- "j",
2065
- "k",
2066
- "l",
2067
- "m",
2068
- "n",
2069
- "o",
2070
- "p",
2071
- "q",
2072
- "r"
2073
- ];
2053
+ const useSecretsFormState = (secrets) => React.useReducer(reducer, secrets, init);
2074
2054
  function MuxLogo({ height = 26 }) {
2075
- const id = React.useId(), [titleId, a2, b, c2, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = React.useMemo(
2076
- () => ids.map((field) => `${id}-${field}`),
2077
- [id]
2078
- );
2079
- return /* @__PURE__ */ jsxRuntime.jsxs(
2055
+ const id = React.useId(), fillColor = ui.useTheme_v2().color._dark ? "white" : "black", titleId = React.useMemo(() => `${id}-title`, [id]), pathStyle = {
2056
+ fillRule: "nonzero"
2057
+ };
2058
+ return /* @__PURE__ */ jsxRuntime.jsx(
2080
2059
  "svg",
2081
2060
  {
2082
2061
  "aria-labelledby": titleId,
2083
- role: "img",
2062
+ style: { height: `${height}px` },
2063
+ viewBox: "0 0 1600 500",
2064
+ version: "1.1",
2084
2065
  xmlns: "http://www.w3.org/2000/svg",
2085
2066
  xmlSpace: "preserve",
2086
- viewBox: "92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",
2087
- style: { height: `${height}px` },
2088
- children: [
2089
- /* @__PURE__ */ jsxRuntime.jsx("title", { id: titleId, children: "Mux Logo" }),
2090
- /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
2091
- /* @__PURE__ */ jsxRuntime.jsxs(
2092
- "linearGradient",
2093
- {
2094
- id: c2,
2095
- spreadMethod: "pad",
2096
- gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
2097
- gradientUnits: "userSpaceOnUse",
2098
- y2: 0,
2099
- x2: 1,
2100
- y1: 0,
2101
- x1: 0,
2102
- children: [
2103
- /* @__PURE__ */ jsxRuntime.jsx(
2104
- "stop",
2105
- {
2106
- offset: 0,
2107
- style: {
2108
- stopOpacity: 1,
2109
- stopColor: "#ff4e00"
2110
- }
2111
- }
2112
- ),
2113
- /* @__PURE__ */ jsxRuntime.jsx(
2114
- "stop",
2115
- {
2116
- offset: 1,
2117
- style: {
2118
- stopOpacity: 1,
2119
- stopColor: "#ff1791"
2120
- }
2121
- }
2122
- )
2123
- ]
2124
- }
2125
- ),
2126
- /* @__PURE__ */ jsxRuntime.jsxs(
2127
- "linearGradient",
2128
- {
2129
- id: d,
2130
- spreadMethod: "pad",
2131
- gradientTransform: "matrix(523.66766 0 0 -523.66766 67.897 159.5)",
2132
- gradientUnits: "userSpaceOnUse",
2133
- y2: 0,
2134
- x2: 1,
2135
- y1: 0,
2136
- x1: 0,
2137
- children: [
2138
- /* @__PURE__ */ jsxRuntime.jsx(
2139
- "stop",
2140
- {
2141
- offset: 0,
2142
- style: {
2143
- stopOpacity: 1,
2144
- stopColor: "#ff4e00"
2145
- }
2146
- }
2147
- ),
2148
- /* @__PURE__ */ jsxRuntime.jsx(
2149
- "stop",
2150
- {
2151
- offset: 1,
2152
- style: {
2153
- stopOpacity: 1,
2154
- stopColor: "#ff1791"
2155
- }
2156
- }
2157
- )
2158
- ]
2159
- }
2160
- ),
2161
- /* @__PURE__ */ jsxRuntime.jsxs(
2162
- "linearGradient",
2163
- {
2164
- id: g,
2165
- spreadMethod: "pad",
2166
- gradientTransform: "rotate(180 296.075 79.75) scale(524.84045)",
2167
- gradientUnits: "userSpaceOnUse",
2168
- y2: 0,
2169
- x2: 1,
2170
- y1: 0,
2171
- x1: 0,
2172
- children: [
2173
- /* @__PURE__ */ jsxRuntime.jsx(
2174
- "stop",
2175
- {
2176
- offset: 0,
2177
- style: {
2178
- stopOpacity: 1,
2179
- stopColor: "#ff4e00"
2180
- }
2181
- }
2182
- ),
2183
- /* @__PURE__ */ jsxRuntime.jsx(
2184
- "stop",
2185
- {
2186
- offset: 1,
2187
- style: {
2188
- stopOpacity: 1,
2189
- stopColor: "#ff1791"
2190
- }
2191
- }
2192
- )
2193
- ]
2194
- }
2195
- ),
2196
- /* @__PURE__ */ jsxRuntime.jsxs(
2197
- "linearGradient",
2198
- {
2199
- id: i,
2200
- spreadMethod: "pad",
2201
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2202
- gradientUnits: "userSpaceOnUse",
2203
- y2: 0,
2204
- x2: 1,
2205
- y1: 0,
2206
- x1: 0,
2207
- children: [
2208
- /* @__PURE__ */ jsxRuntime.jsx(
2209
- "stop",
2210
- {
2211
- offset: 0,
2212
- style: {
2213
- stopOpacity: 1,
2214
- stopColor: "#ff4e00"
2215
- }
2216
- }
2217
- ),
2218
- /* @__PURE__ */ jsxRuntime.jsx(
2219
- "stop",
2220
- {
2221
- offset: 1,
2222
- style: {
2223
- stopOpacity: 1,
2224
- stopColor: "#ff1791"
2225
- }
2226
- }
2227
- )
2228
- ]
2229
- }
2230
- ),
2231
- /* @__PURE__ */ jsxRuntime.jsxs(
2232
- "linearGradient",
2233
- {
2234
- id: j,
2235
- spreadMethod: "pad",
2236
- gradientTransform: "matrix(523.08514 0 0 -523.08514 67.897 224.446)",
2237
- gradientUnits: "userSpaceOnUse",
2238
- y2: 0,
2239
- x2: 1,
2240
- y1: 0,
2241
- x1: 0,
2242
- children: [
2243
- /* @__PURE__ */ jsxRuntime.jsx(
2244
- "stop",
2245
- {
2246
- offset: 0,
2247
- style: {
2248
- stopOpacity: 1,
2249
- stopColor: "#ff4e00"
2250
- }
2251
- }
2252
- ),
2253
- /* @__PURE__ */ jsxRuntime.jsx(
2254
- "stop",
2255
- {
2256
- offset: 1,
2257
- style: {
2258
- stopOpacity: 1,
2259
- stopColor: "#ff1791"
2260
- }
2261
- }
2262
- )
2263
- ]
2264
- }
2265
- ),
2266
- /* @__PURE__ */ jsxRuntime.jsxs(
2267
- "linearGradient",
2268
- {
2269
- id: k,
2270
- spreadMethod: "pad",
2271
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.553)",
2272
- gradientUnits: "userSpaceOnUse",
2273
- y2: 0,
2274
- x2: 1,
2275
- y1: 0,
2276
- x1: 0,
2277
- children: [
2278
- /* @__PURE__ */ jsxRuntime.jsx(
2279
- "stop",
2280
- {
2281
- offset: 0,
2282
- style: {
2283
- stopOpacity: 1,
2284
- stopColor: "#ff4e00"
2285
- }
2286
- }
2287
- ),
2288
- /* @__PURE__ */ jsxRuntime.jsx(
2289
- "stop",
2290
- {
2291
- offset: 1,
2292
- style: {
2293
- stopOpacity: 1,
2294
- stopColor: "#ff1791"
2295
- }
2296
- }
2297
- )
2298
- ]
2299
- }
2300
- ),
2301
- /* @__PURE__ */ jsxRuntime.jsxs(
2302
- "linearGradient",
2303
- {
2304
- id: l,
2305
- spreadMethod: "pad",
2306
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2307
- gradientUnits: "userSpaceOnUse",
2308
- y2: 0,
2309
- x2: 1,
2310
- y1: 0,
2311
- x1: 0,
2312
- children: [
2313
- /* @__PURE__ */ jsxRuntime.jsx(
2314
- "stop",
2315
- {
2316
- offset: 0,
2317
- style: {
2318
- stopOpacity: 1,
2319
- stopColor: "#ff4e00"
2320
- }
2321
- }
2322
- ),
2323
- /* @__PURE__ */ jsxRuntime.jsx(
2324
- "stop",
2325
- {
2326
- offset: 1,
2327
- style: {
2328
- stopOpacity: 1,
2329
- stopColor: "#ff1791"
2330
- }
2331
- }
2332
- )
2333
- ]
2334
- }
2335
- ),
2336
- /* @__PURE__ */ jsxRuntime.jsxs(
2337
- "linearGradient",
2338
- {
2339
- id: m,
2340
- spreadMethod: "pad",
2341
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.554)",
2342
- gradientUnits: "userSpaceOnUse",
2343
- y2: 0,
2344
- x2: 1,
2345
- y1: 0,
2346
- x1: 0,
2347
- children: [
2348
- /* @__PURE__ */ jsxRuntime.jsx(
2349
- "stop",
2350
- {
2351
- offset: 0,
2352
- style: {
2353
- stopOpacity: 1,
2354
- stopColor: "#ff4e00"
2355
- }
2356
- }
2357
- ),
2358
- /* @__PURE__ */ jsxRuntime.jsx(
2359
- "stop",
2360
- {
2361
- offset: 1,
2362
- style: {
2363
- stopOpacity: 1,
2364
- stopColor: "#ff1791"
2365
- }
2366
- }
2367
- )
2368
- ]
2369
- }
2370
- ),
2371
- /* @__PURE__ */ jsxRuntime.jsxs(
2372
- "linearGradient",
2373
- {
2374
- id: p,
2375
- spreadMethod: "pad",
2376
- gradientTransform: "matrix(521.97632 0 0 -521.97632 69.067 191.973)",
2377
- gradientUnits: "userSpaceOnUse",
2378
- y2: 0,
2379
- x2: 1,
2380
- y1: 0,
2381
- x1: 0,
2382
- children: [
2383
- /* @__PURE__ */ jsxRuntime.jsx(
2384
- "stop",
2385
- {
2386
- offset: 0,
2387
- style: {
2388
- stopOpacity: 1,
2389
- stopColor: "#ff4e00"
2390
- }
2391
- }
2392
- ),
2393
- /* @__PURE__ */ jsxRuntime.jsx(
2394
- "stop",
2395
- {
2396
- offset: 1,
2397
- style: {
2398
- stopOpacity: 1,
2399
- stopColor: "#ff1791"
2400
- }
2401
- }
2402
- )
2403
- ]
2404
- }
2405
- ),
2406
- /* @__PURE__ */ jsxRuntime.jsxs(
2407
- "linearGradient",
2408
- {
2409
- id: q,
2410
- spreadMethod: "pad",
2411
- gradientTransform: "matrix(523.09039 0 0 -523.09039 67.312 191.973)",
2412
- gradientUnits: "userSpaceOnUse",
2413
- y2: 0,
2414
- x2: 1,
2415
- y1: 0,
2416
- x1: 0,
2417
- children: [
2418
- /* @__PURE__ */ jsxRuntime.jsx(
2419
- "stop",
2420
- {
2421
- offset: 0,
2422
- style: {
2423
- stopOpacity: 1,
2424
- stopColor: "#ff4e00"
2425
- }
2426
- }
2427
- ),
2428
- /* @__PURE__ */ jsxRuntime.jsx(
2429
- "stop",
2430
- {
2431
- offset: 1,
2432
- style: {
2433
- stopOpacity: 1,
2434
- stopColor: "#ff1791"
2435
- }
2436
- }
2437
- )
2438
- ]
2439
- }
2440
- ),
2441
- /* @__PURE__ */ jsxRuntime.jsxs(
2442
- "linearGradient",
2443
- {
2444
- id: r,
2445
- spreadMethod: "pad",
2446
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2447
- gradientUnits: "userSpaceOnUse",
2448
- y2: 0,
2449
- x2: 1,
2450
- y1: 0,
2451
- x1: 0,
2452
- children: [
2453
- /* @__PURE__ */ jsxRuntime.jsx(
2454
- "stop",
2455
- {
2456
- offset: 0,
2457
- style: {
2458
- stopOpacity: 1,
2459
- stopColor: "#ff4e00"
2460
- }
2461
- }
2462
- ),
2463
- /* @__PURE__ */ jsxRuntime.jsx(
2464
- "stop",
2465
- {
2466
- offset: 1,
2467
- style: {
2468
- stopOpacity: 1,
2469
- stopColor: "#ff1791"
2470
- }
2471
- }
2472
- )
2473
- ]
2474
- }
2475
- ),
2476
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2477
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
2478
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2479
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
2480
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: h, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M198.96 242h35.106V77H198.96Z" }) }),
2481
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2482
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
2483
- ] }),
2484
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsxRuntime.jsx(
2485
- "g",
2486
- {
2487
- style: {
2488
- opacity: 0.69999701
2489
- },
2490
- clipPath: `url(#${b})`,
2491
- children: /* @__PURE__ */ jsxRuntime.jsx(
2492
- "path",
2493
- {
2494
- style: {
2495
- fill: `url(#${c2})`,
2496
- stroke: "none"
2497
- },
2498
- 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"
2499
- }
2500
- )
2501
- }
2502
- ) }),
2067
+ children: /* @__PURE__ */ jsxRuntime.jsxs("g", { id: "Layer-1", fill: fillColor, children: [
2503
2068
  /* @__PURE__ */ jsxRuntime.jsx(
2504
2069
  "path",
2505
2070
  {
2506
- style: {
2507
- fill: `url(#${d})`,
2508
- stroke: "none"
2509
- },
2510
- 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",
2511
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2071
+ d: "M994.287,93.486c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m0,-93.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,68.943 -56.09,125.033 -125.032,125.033c-68.942,-0 -125.03,-56.09 -125.03,-125.033l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,137.853 112.149,250.003 249.999,250.003c137.851,-0 250.001,-112.15 250.001,-250.003l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486",
2072
+ style: pathStyle
2512
2073
  }
2513
2074
  ),
2514
- /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: `url(#${e})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: [
2515
- /* @__PURE__ */ jsxRuntime.jsx(
2516
- "g",
2517
- {
2518
- style: {
2519
- opacity: 0.69999701
2520
- },
2521
- clipPath: `url(#${f})`,
2522
- children: /* @__PURE__ */ jsxRuntime.jsx(
2523
- "path",
2524
- {
2525
- style: {
2526
- fill: `url(#${g})`,
2527
- stroke: "none"
2528
- },
2529
- 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"
2530
- }
2531
- )
2532
- }
2533
- ),
2534
- /* @__PURE__ */ jsxRuntime.jsx(
2535
- "g",
2536
- {
2537
- style: {
2538
- opacity: 0.69999701
2539
- },
2540
- clipPath: `url(#${h})`,
2541
- children: /* @__PURE__ */ jsxRuntime.jsx(
2542
- "path",
2543
- {
2544
- style: {
2545
- fill: `url(#${i})`,
2546
- stroke: "none"
2547
- },
2548
- 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"
2549
- }
2550
- )
2551
- }
2552
- )
2553
- ] }),
2554
2075
  /* @__PURE__ */ jsxRuntime.jsx(
2555
2076
  "path",
2556
2077
  {
2557
- style: {
2558
- fill: `url(#${j})`,
2559
- stroke: "none"
2560
- },
2561
- 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",
2562
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2078
+ d: "M1537.51,468.511c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m-275.883,-218.509l-143.33,143.329c-24.402,24.402 -24.402,63.966 0,88.368c24.402,24.402 63.967,24.402 88.369,-0l143.33,-143.329l143.328,143.329c24.402,24.4 63.967,24.402 88.369,-0c24.403,-24.402 24.403,-63.966 0.001,-88.368l-143.33,-143.329l0.001,-0.004l143.329,-143.329c24.402,-24.402 24.402,-63.965 0,-88.367c-24.402,-24.402 -63.967,-24.402 -88.369,-0l-143.329,143.328l-143.329,-143.328c-24.402,-24.401 -63.967,-24.402 -88.369,-0c-24.402,24.402 -24.402,63.965 0,88.367l143.329,143.329l0,0.004Z",
2079
+ style: pathStyle
2563
2080
  }
2564
2081
  ),
2565
2082
  /* @__PURE__ */ jsxRuntime.jsx(
2566
2083
  "path",
2567
2084
  {
2568
- style: {
2569
- fill: `url(#${k})`,
2570
- stroke: "none"
2571
- },
2572
- 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",
2573
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2574
- }
2575
- ),
2576
- /* @__PURE__ */ jsxRuntime.jsx(
2577
- "path",
2578
- {
2579
- style: {
2580
- fill: `url(#${l})`,
2581
- stroke: "none"
2582
- },
2583
- 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",
2584
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2585
- }
2586
- ),
2587
- /* @__PURE__ */ jsxRuntime.jsx(
2588
- "path",
2589
- {
2590
- style: {
2591
- fill: `url(#${m})`,
2592
- stroke: "none"
2593
- },
2594
- 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",
2595
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2596
- }
2597
- ),
2598
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${n})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsxRuntime.jsx(
2599
- "g",
2600
- {
2601
- style: {
2602
- opacity: 0.69999701
2603
- },
2604
- clipPath: `url(#${o})`,
2605
- children: /* @__PURE__ */ jsxRuntime.jsx(
2606
- "path",
2607
- {
2608
- style: {
2609
- fill: `url(#${p})`,
2610
- stroke: "none"
2611
- },
2612
- 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"
2613
- }
2614
- )
2615
- }
2616
- ) }),
2617
- /* @__PURE__ */ jsxRuntime.jsx(
2618
- "path",
2619
- {
2620
- style: {
2621
- fill: `url(#${q})`,
2622
- stroke: "none"
2623
- },
2624
- 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",
2625
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2626
- }
2627
- ),
2628
- /* @__PURE__ */ jsxRuntime.jsx(
2629
- "path",
2630
- {
2631
- style: {
2632
- fill: `url(#${r})`,
2633
- stroke: "none"
2634
- },
2635
- 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",
2636
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2085
+ d: "M437.511,468.521c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m23.915,-463.762c-23.348,-9.672 -50.226,-4.327 -68.096,13.544l-143.331,143.329l-143.33,-143.329c-17.871,-17.871 -44.747,-23.216 -68.096,-13.544c-23.349,9.671 -38.574,32.455 -38.574,57.729l0,375.026c0,34.51 27.977,62.486 62.487,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-224.173l80.843,80.844c24.404,24.402 63.965,24.402 88.369,-0l80.843,-80.844l0,224.173c0,34.51 27.976,62.486 62.486,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-375.026c0,-25.274 -15.224,-48.058 -38.573,-57.729",
2086
+ style: pathStyle
2637
2087
  }
2638
2088
  )
2639
- ]
2089
+ ] })
2640
2090
  }
2641
2091
  );
2642
2092
  }
@@ -2731,6 +2181,8 @@ function ConfigureApi({ secrets, setDialogState }) {
2731
2181
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Mux Data" }),
2732
2182
  " (Read)",
2733
2183
  /* @__PURE__ */ jsxRuntime.jsx("br", {}),
2184
+ "To use Signed URLs, the token must also have System permissions.",
2185
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
2734
2186
  "The credentials will be stored safely in a hidden document only available to editors."
2735
2187
  ] })
2736
2188
  ] }) }),
@@ -3603,6 +3055,88 @@ function TextTracksEditor({
3603
3055
  )
3604
3056
  ] }) });
3605
3057
  }
3058
+ function PlaybackPolicyOption({
3059
+ id,
3060
+ checked,
3061
+ optionName,
3062
+ description,
3063
+ dispatch,
3064
+ action
3065
+ }) {
3066
+ const [scale, setScale] = React.useState(1), boxStyle = {
3067
+ outline: "0.01rem solid grey",
3068
+ transform: `scale(${scale})`,
3069
+ transition: "transform 0.1s ease-in-out",
3070
+ cursor: "pointer",
3071
+ borderRadius: "0.25rem"
3072
+ }, triggerAnimation = () => {
3073
+ setScale(0.98), setTimeout(() => {
3074
+ setScale(1);
3075
+ }, 100);
3076
+ };
3077
+ return /* @__PURE__ */ jsxRuntime.jsx("label", { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, padding: 3, style: boxStyle, children: [
3078
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { id, required: !0, checked, onChange: () => {
3079
+ triggerAnimation(), dispatch({
3080
+ action,
3081
+ value: !checked
3082
+ });
3083
+ } }),
3084
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { gap: 3, children: [
3085
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 3, weight: "bold", children: optionName }),
3086
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 2, muted: !0, children: description })
3087
+ ] })
3088
+ ] }) });
3089
+ }
3090
+ function PlaybackPolicyWarning() {
3091
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, style: {
3092
+ outline: "0.01rem solid grey",
3093
+ backgroundColor: "#979cb0",
3094
+ borderRadius: "0.5rem",
3095
+ width: "max-content",
3096
+ color: "#13141A"
3097
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, children: [
3098
+ /* @__PURE__ */ jsxRuntime.jsx(icons.WarningFilledIcon, {}),
3099
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: {
3100
+ color: "#13141A",
3101
+ fontWeight: 500
3102
+ }, children: "Please select at least one Playback Policy" })
3103
+ ] }) });
3104
+ }
3105
+ function PlaybackPolicy({
3106
+ id,
3107
+ config,
3108
+ secrets,
3109
+ dispatch
3110
+ }) {
3111
+ const noPolicySelected = !(config.public_policy || config.signed_policy);
3112
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { gap: 3, children: [
3113
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "bold", children: "Advanced Playback Policies" }),
3114
+ /* @__PURE__ */ jsxRuntime.jsx(
3115
+ PlaybackPolicyOption,
3116
+ {
3117
+ id: `${id}--public`,
3118
+ checked: config.public_policy,
3119
+ optionName: "Public",
3120
+ description: "Playback IDs are accessible by constructing an HLS URL like https://stream.mux.com/{PLAYBACK_ID}",
3121
+ dispatch,
3122
+ action: "public_policy"
3123
+ }
3124
+ ),
3125
+ secrets.enableSignedUrls && /* @__PURE__ */ jsxRuntime.jsx(
3126
+ PlaybackPolicyOption,
3127
+ {
3128
+ id: `${id}--signed`,
3129
+ checked: config.signed_policy,
3130
+ optionName: "Signed",
3131
+ description: `Playback IDs should be used with tokens https://stream.mux.com/{PLAYBACK_ID}?token={TOKEN}.
3132
+ // See Secure video playback for details about creating tokens.`,
3133
+ dispatch,
3134
+ action: "signed_policy"
3135
+ }
3136
+ ),
3137
+ noPolicySelected && /* @__PURE__ */ jsxRuntime.jsx(PlaybackPolicyWarning, {})
3138
+ ] });
3139
+ }
3606
3140
  const ENCODING_OPTIONS = [
3607
3141
  { value: "smart", label: "Smart" },
3608
3142
  { value: "baseline", label: "Baseline" }
@@ -3635,7 +3169,9 @@ function UploadConfiguration({
3635
3169
  encoding_tier: action.value,
3636
3170
  mp4_support: "none",
3637
3171
  max_resolution_tier: "1080p",
3638
- text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated")
3172
+ text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated"),
3173
+ public_policy: !0,
3174
+ signed_policy: !1
3639
3175
  }) : Object.assign({}, prev, {
3640
3176
  encoding_tier: action.value,
3641
3177
  mp4_support: pluginConfig.mp4_support,
@@ -3645,7 +3181,9 @@ function UploadConfiguration({
3645
3181
  case "mp4_support":
3646
3182
  case "max_resolution_tier":
3647
3183
  case "normalize_audio":
3648
- case "signed":
3184
+ case "signed_policy":
3185
+ return Object.assign({}, prev, { [action.action]: action.value });
3186
+ case "public_policy":
3649
3187
  return Object.assign({}, prev, { [action.action]: action.value });
3650
3188
  // Updating individual tracks
3651
3189
  case "track": {
@@ -3680,7 +3218,8 @@ function UploadConfiguration({
3680
3218
  encoding_tier: pluginConfig.encoding_tier,
3681
3219
  max_resolution_tier: pluginConfig.max_resolution_tier,
3682
3220
  mp4_support: pluginConfig.mp4_support,
3683
- signed: secrets.enableSignedUrls && pluginConfig.defaultSigned,
3221
+ signed_policy: secrets.enableSignedUrls && pluginConfig.defaultSigned,
3222
+ public_policy: !0,
3684
3223
  normalize_audio: pluginConfig.normalize_audio,
3685
3224
  text_tracks: autoTextTracks
3686
3225
  }
@@ -3799,25 +3338,9 @@ function UploadConfiguration({
3799
3338
  }) })
3800
3339
  }
3801
3340
  ),
3802
- (secrets.enableSignedUrls || config.encoding_tier === "smart") && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Additional Configuration", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
3803
- secrets.enableSignedUrls && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, children: [
3804
- /* @__PURE__ */ jsxRuntime.jsx(
3805
- ui.Checkbox,
3806
- {
3807
- id: `${id}--signed`,
3808
- style: { display: "block" },
3809
- name: "signed",
3810
- required: !0,
3811
- checked: config.signed,
3812
- onChange: (e) => dispatch({
3813
- action: "signed",
3814
- value: e.currentTarget.checked
3815
- })
3816
- }
3817
- ),
3818
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: `${id}--signed`, children: "Signed playback URL" }) })
3819
- ] }),
3820
- config.encoding_tier === "smart" && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, children: [
3341
+ config.encoding_tier === "smart" && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Additional Configuration", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
3342
+ /* @__PURE__ */ jsxRuntime.jsx(PlaybackPolicy, { id, config, secrets, dispatch }),
3343
+ config.encoding_tier === "smart" && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, padding: [0, 2], children: [
3821
3344
  /* @__PURE__ */ jsxRuntime.jsx(
3822
3345
  ui.Checkbox,
3823
3346
  {
@@ -3847,6 +3370,7 @@ function UploadConfiguration({
3847
3370
  /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
3848
3371
  ui.Button,
3849
3372
  {
3373
+ disabled: config.encoding_tier === "smart" && !config.public_policy && !config.signed_policy,
3850
3374
  icon: icons.UploadIcon,
3851
3375
  text: "Upload",
3852
3376
  tone: "positive",
@@ -3857,6 +3381,10 @@ function UploadConfiguration({
3857
3381
  }
3858
3382
  );
3859
3383
  }
3384
+ function setPlaybackPolicy(config) {
3385
+ const playback_policy = [];
3386
+ return config.public_policy && playback_policy.push("public"), config.signed_policy && playback_policy.push("signed"), playback_policy;
3387
+ }
3860
3388
  function formatUploadConfig(config) {
3861
3389
  const generated_subtitles = config.text_tracks.filter(isAutogeneratedTrack).map((track) => ({
3862
3390
  name: track.name,
@@ -3881,7 +3409,7 @@ function formatUploadConfig(config) {
3881
3409
  )
3882
3410
  ],
3883
3411
  mp4_support: config.mp4_support,
3884
- playback_policy: config.signed ? ["public", "signed"] : ["public"],
3412
+ playback_policy: setPlaybackPolicy(config),
3885
3413
  max_resolution_tier: config.max_resolution_tier,
3886
3414
  encoding_tier: config.encoding_tier,
3887
3415
  normalize_audio: config.normalize_audio