sanity-plugin-cloudinary 0.2.1 → 1.0.0-v3-studio.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +160 -66
  3. package/lib/cjs/index.js +708 -0
  4. package/lib/cjs/index.js.map +1 -0
  5. package/lib/esm/index.js +697 -0
  6. package/lib/esm/index.js.map +1 -0
  7. package/lib/types/index.d.ts +22 -0
  8. package/lib/types/index.d.ts.map +1 -0
  9. package/package.json +66 -40
  10. package/sanity.json +3 -15
  11. package/src/arrayFunctions.tsx +71 -0
  12. package/src/components/AssetDiff.tsx +44 -0
  13. package/src/components/AssetPreview.tsx +41 -0
  14. package/src/components/CloudinaryInput.tsx +61 -0
  15. package/src/components/SecretsConfigView.tsx +39 -0
  16. package/src/components/VideoPlayer.tsx +62 -0
  17. package/src/components/WidgetInput.tsx +66 -0
  18. package/src/components/asset-source/CloudinaryAssetSource.tsx +155 -0
  19. package/src/components/asset-source/Icon.tsx +93 -0
  20. package/src/index.ts +30 -0
  21. package/src/schema/cloudinaryAsset.ts +99 -0
  22. package/src/schema/cloudinaryAssetDerived.ts +26 -0
  23. package/src/typings.d.ts +74 -0
  24. package/src/utils.ts +115 -0
  25. package/v2-incompatible.js +11 -0
  26. package/dist/arrayFunctions.js +0 -82
  27. package/dist/arrayFunctions.js.map +0 -1
  28. package/dist/components/AssetDiff.js +0 -62
  29. package/dist/components/AssetDiff.js.map +0 -1
  30. package/dist/components/AssetPreview.js +0 -46
  31. package/dist/components/AssetPreview.js.map +0 -1
  32. package/dist/components/CloudinaryInput.js +0 -90
  33. package/dist/components/CloudinaryInput.js.map +0 -1
  34. package/dist/components/SecretsConfigView.js +0 -37
  35. package/dist/components/SecretsConfigView.js.map +0 -1
  36. package/dist/components/VideoPlayer.js +0 -70
  37. package/dist/components/VideoPlayer.js.map +0 -1
  38. package/dist/components/WidgetInput.js +0 -87
  39. package/dist/components/WidgetInput.js.map +0 -1
  40. package/dist/index.js +0 -24
  41. package/dist/index.js.map +0 -1
  42. package/dist/schema/cloudinary.js +0 -19
  43. package/dist/schema/cloudinary.js.map +0 -1
  44. package/dist/schema/cloudinaryAsset.js +0 -100
  45. package/dist/schema/cloudinaryAsset.js.map +0 -1
  46. package/dist/schema/cloudinaryAssetDerived.js +0 -22
  47. package/dist/schema/cloudinaryAssetDerived.js.map +0 -1
  48. package/dist/typings.d.js +0 -8
  49. package/dist/typings.d.js.map +0 -1
  50. package/dist/utils.js +0 -92
  51. package/dist/utils.js.map +0 -1
@@ -0,0 +1,708 @@
1
+ var $k7rGe$sanity = require("sanity");
2
+ var $k7rGe$reactjsxruntime = require("react/jsx-runtime");
3
+ var $k7rGe$react = require("react");
4
+ var $k7rGe$nanoid = require("nanoid");
5
+ var $k7rGe$sanitystudiosecrets = require("@sanity/studio-secrets");
6
+ var $k7rGe$sanityui = require("@sanity/ui");
7
+ var $k7rGe$sanityicons = require("@sanity/icons");
8
+ var $k7rGe$styledcomponents = require("styled-components");
9
+ var $k7rGe$videojs = require("video.js");
10
+
11
+ function $parcel$export(e, n, v, s) {
12
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
+ }
14
+ function $parcel$interopDefault(a) {
15
+ return a && a.__esModule ? a.default : a;
16
+ }
17
+
18
+ $parcel$export(module.exports, "cloudinarySchemaPlugin", () => $244e63ca53592e4d$export$d69fa36e91cd4a95);
19
+ $parcel$export(module.exports, "cloudinaryImageSource", () => $244e63ca53592e4d$export$f3531f7607fb0a50);
20
+ $parcel$export(module.exports, "cloudinaryAssetSourcePlugin", () => $244e63ca53592e4d$export$4e2fc220d417fe6a);
21
+ $parcel$export(module.exports, "cloudinaryAssetSchema", () => $e1357c706847471f$export$3ed2e98ebe80ce58);
22
+ $parcel$export(module.exports, "cloudinaryAssetDerivedSchema", () => $f4ab4b5f606c4dbd$export$26e4781cb23ffde8);
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ class $95dcba7b768af49e$export$2e2bcd8739ae039 extends (0, ($parcel$interopDefault($k7rGe$react))).Component {
37
+ componentDidMount() {
38
+ const { src: src } = this.props;
39
+ this.player = (0, ($parcel$interopDefault($k7rGe$videojs)))(this.videoNode, {
40
+ sources: [
41
+ {
42
+ src: src
43
+ }
44
+ ],
45
+ controls: true
46
+ });
47
+ }
48
+ componentWillUnmount() {
49
+ if (this.player) this.player.dispose();
50
+ }
51
+ render() {
52
+ const { kind: kind } = this.props;
53
+ const className = {
54
+ player: "video-js vjs-16-9 vjs-big-play-centered",
55
+ diff: "video-js vjs-layout-tiny vjs-fluid"
56
+ };
57
+ const style = {
58
+ position: "relative"
59
+ };
60
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)("div", {
61
+ children: [
62
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("link", {
63
+ href: "https://vjs.zencdn.net/7.8.4/video-js.css",
64
+ rel: "stylesheet"
65
+ }),
66
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("div", {
67
+ "data-vjs-player": true,
68
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("video", {
69
+ onClick: (event)=>event.stopPropagation(),
70
+ style: kind === "diff" ? style : {},
71
+ className: className[kind],
72
+ ref: (node)=>{
73
+ if (node) this.videoNode = node;
74
+ }
75
+ })
76
+ })
77
+ ]
78
+ });
79
+ }
80
+ }
81
+
82
+
83
+ const $f5b36b9feac7c9dc$var$widgetSrc = "https://media-library.cloudinary.com/global/all.js";
84
+ function $f5b36b9feac7c9dc$export$e762090a5452d842(asset) {
85
+ if (asset.derived && asset.derived.length > 0) {
86
+ const [derived] = asset.derived;
87
+ if (derived.secure_url) return derived.secure_url;
88
+ return derived.url;
89
+ }
90
+ if (asset.secure_url) return asset.secure_url;
91
+ return asset.url;
92
+ }
93
+ const $f5b36b9feac7c9dc$export$7a7ae4f24e5cd9dc = (cloudName, apiKey, multiple, insertHandler, selectedAsset)=>{
94
+ $f5b36b9feac7c9dc$export$93b33d367be6802b($f5b36b9feac7c9dc$var$widgetSrc, ()=>{
95
+ const options = {
96
+ cloud_name: cloudName,
97
+ api_key: apiKey,
98
+ insert_caption: "Select",
99
+ multiple: multiple
100
+ };
101
+ if (selectedAsset) options.asset = {
102
+ public_id: selectedAsset.public_id,
103
+ type: selectedAsset.type,
104
+ resource_type: selectedAsset.resource_type
105
+ };
106
+ window.cloudinary.openMediaLibrary(options, {
107
+ insertHandler: insertHandler
108
+ });
109
+ });
110
+ };
111
+ const $f5b36b9feac7c9dc$export$fa8126b76e785c83 = ({ cloudName: cloudName , apiKey: apiKey , inlineContainer: inlineContainer , libraryCreated: libraryCreated , insertHandler: insertHandler })=>{
112
+ $f5b36b9feac7c9dc$export$93b33d367be6802b($f5b36b9feac7c9dc$var$widgetSrc, ()=>{
113
+ const options = {
114
+ cloud_name: cloudName,
115
+ api_key: apiKey,
116
+ insert_caption: "Select",
117
+ inline_container: inlineContainer,
118
+ remove_header: true
119
+ };
120
+ libraryCreated(window.cloudinary.createMediaLibrary(options, {
121
+ insertHandler: insertHandler
122
+ }));
123
+ });
124
+ };
125
+ function $f5b36b9feac7c9dc$export$93b33d367be6802b(url, callback) {
126
+ const existingScript = document.getElementById("damWidget");
127
+ if (!existingScript) {
128
+ const script = document.createElement("script");
129
+ script.src = url;
130
+ script.id = "damWidget";
131
+ document.body.appendChild(script);
132
+ script.onload = ()=>{
133
+ if (callback) return callback();
134
+ return true;
135
+ };
136
+ }
137
+ if (existingScript && callback) return callback();
138
+ return true;
139
+ }
140
+ function $f5b36b9feac7c9dc$export$f58729bedbec21be(asset) {
141
+ const { resource_type: resource_type , public_id: public_id , type: type } = asset;
142
+ return btoa(JSON.stringify({
143
+ public_id: public_id,
144
+ resource_type: resource_type,
145
+ type: type
146
+ })) // Sort keys alphabetically!
147
+ ;
148
+ }
149
+ function $f5b36b9feac7c9dc$export$e708ba11f5ba43ca(asset) {
150
+ return `${asset.public_id.split("/").slice(-1)[0]}.${asset.format}`;
151
+ }
152
+ function $f5b36b9feac7c9dc$export$369dff7d11616ebd(sourceId) {
153
+ let sourceIdDecoded;
154
+ try {
155
+ sourceIdDecoded = JSON.parse(atob(sourceId));
156
+ } catch (err) {
157
+ // Do nothing
158
+ }
159
+ return sourceIdDecoded;
160
+ }
161
+
162
+
163
+
164
+ const $ce38f38a3448fcbe$var$AssetPreview = ({ value: value , layout: layout })=>{
165
+ const url = value && (0, $f5b36b9feac7c9dc$export$e762090a5452d842)(value);
166
+ if (!value || !url) return null;
167
+ switch(value.resource_type){
168
+ case "video":
169
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Box), {
170
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $95dcba7b768af49e$export$2e2bcd8739ae039), {
171
+ src: url,
172
+ kind: "player"
173
+ })
174
+ });
175
+ default:
176
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Box), {
177
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("img", {
178
+ alt: "preview",
179
+ src: url,
180
+ style: {
181
+ maxWidth: layout === "default" ? "80px" : "100%",
182
+ height: "auto"
183
+ }
184
+ })
185
+ });
186
+ }
187
+ };
188
+ var $ce38f38a3448fcbe$export$2e2bcd8739ae039 = $ce38f38a3448fcbe$var$AssetPreview;
189
+
190
+
191
+ const $9c71038cf8934db5$var$SetupButtonContainer = (0, ($parcel$interopDefault($k7rGe$styledcomponents))).div`
192
+ position: relative;
193
+ display: block;
194
+ font-size: 0.8em;
195
+ transform: translate(0%, -10%);
196
+ `;
197
+ const $9c71038cf8934db5$var$WidgetInput = (props)=>{
198
+ const { onChange: onChange , readOnly: readOnly , value: value , openMediaSelector: openMediaSelector } = props;
199
+ const removeValue = (0, $k7rGe$react.useCallback)(()=>{
200
+ onChange((0, $k7rGe$sanity.PatchEvent).from([
201
+ (0, $k7rGe$sanity.unset)()
202
+ ]));
203
+ }, [
204
+ onChange
205
+ ]);
206
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$sanityui.Stack), {
207
+ children: [
208
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)($9c71038cf8934db5$var$SetupButtonContainer, {
209
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Flex), {
210
+ flex: 1,
211
+ justify: "flex-end",
212
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Button), {
213
+ color: "primary",
214
+ icon: (0, $k7rGe$sanityicons.PlugIcon),
215
+ mode: "bleed",
216
+ title: "Configure",
217
+ onClick: props.onSetup,
218
+ tabIndex: 1
219
+ })
220
+ })
221
+ }),
222
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Flex), {
223
+ style: {
224
+ textAlign: "center"
225
+ },
226
+ marginBottom: 2,
227
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $ce38f38a3448fcbe$export$2e2bcd8739ae039), {
228
+ value: value
229
+ })
230
+ }),
231
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$sanityui.Grid), {
232
+ gap: 1,
233
+ style: {
234
+ gridTemplateColumns: "repeat(auto-fit, minmax(100px, 1fr))"
235
+ },
236
+ children: [
237
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Button), {
238
+ disabled: readOnly,
239
+ mode: "ghost",
240
+ title: "Select an asset",
241
+ tone: "default",
242
+ onClick: openMediaSelector,
243
+ text: "Select\u2026"
244
+ }),
245
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Button), {
246
+ disabled: readOnly || !value,
247
+ tone: "critical",
248
+ mode: "ghost",
249
+ title: "Remove asset",
250
+ text: "Remove",
251
+ onClick: removeValue
252
+ })
253
+ ]
254
+ })
255
+ ]
256
+ });
257
+ };
258
+ var $9c71038cf8934db5$export$2e2bcd8739ae039 = $9c71038cf8934db5$var$WidgetInput;
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+ const $dd59fa4f97eba425$var$pluginConfigKeys = [
269
+ {
270
+ key: "cloudName",
271
+ title: "Cloud name",
272
+ description: ""
273
+ },
274
+ {
275
+ key: "apiKey",
276
+ title: "API key",
277
+ description: ""
278
+ },
279
+ ];
280
+ const $dd59fa4f97eba425$export$76a88f7de6507443 = "cloudinary";
281
+ const $dd59fa4f97eba425$var$SecretsConfigView = (props)=>{
282
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanitystudiosecrets.SettingsView), {
283
+ title: "Cloudinary config",
284
+ namespace: $dd59fa4f97eba425$export$76a88f7de6507443,
285
+ keys: $dd59fa4f97eba425$var$pluginConfigKeys,
286
+ onClose: props.onClose
287
+ });
288
+ };
289
+ var $dd59fa4f97eba425$export$2e2bcd8739ae039 = $dd59fa4f97eba425$var$SecretsConfigView;
290
+
291
+
292
+ const $33cd2e288485a815$var$CloudinaryInput = (props)=>{
293
+ const [showSettings, setShowSettings] = (0, $k7rGe$react.useState)(false);
294
+ const { secrets: secrets } = (0, $k7rGe$sanitystudiosecrets.useSecrets)((0, $dd59fa4f97eba425$export$76a88f7de6507443));
295
+ const { onChange: onChange , schemaType: type } = props;
296
+ const value = props.value || undefined;
297
+ const handleSelect = (0, $k7rGe$react.useCallback)((payload)=>{
298
+ const [asset] = payload.assets;
299
+ if (!asset) return;
300
+ onChange((0, $k7rGe$sanity.PatchEvent).from([
301
+ (0, $k7rGe$sanity.set)(Object.assign({
302
+ _type: type.name,
303
+ _version: 1,
304
+ ...value?._key ? {
305
+ _key: value._key
306
+ } : {
307
+ _key: (0, $k7rGe$nanoid.nanoid)()
308
+ }
309
+ }, asset)),
310
+ ]));
311
+ }, [
312
+ onChange,
313
+ type,
314
+ value?._key
315
+ ]);
316
+ const action = secrets ? ()=>(0, $f5b36b9feac7c9dc$export$7a7ae4f24e5cd9dc)(secrets.cloudName, secrets.apiKey, false, handleSelect, value) : ()=>setShowSettings(true);
317
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$reactjsxruntime.Fragment), {
318
+ children: [
319
+ showSettings && /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $dd59fa4f97eba425$export$2e2bcd8739ae039), {
320
+ onClose: ()=>setShowSettings(false)
321
+ }),
322
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $9c71038cf8934db5$export$2e2bcd8739ae039), {
323
+ onSetup: ()=>setShowSettings(true),
324
+ openMediaSelector: action,
325
+ ...props
326
+ })
327
+ ]
328
+ });
329
+ };
330
+ var $33cd2e288485a815$export$2e2bcd8739ae039 = $33cd2e288485a815$var$CloudinaryInput;
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+ const $fe3d0290f00d135c$var$CloudinaryDiffPreview = ({ value: value })=>{
339
+ if (!value) return null;
340
+ const url = (0, $f5b36b9feac7c9dc$export$e762090a5452d842)(value);
341
+ if (value.resource_type === "video") return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("section", {
342
+ style: {
343
+ display: "flex",
344
+ flexWrap: "wrap",
345
+ justifyContent: "space-between"
346
+ },
347
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $95dcba7b768af49e$export$2e2bcd8739ae039), {
348
+ src: url,
349
+ kind: "diff"
350
+ })
351
+ });
352
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("img", {
353
+ alt: "preview",
354
+ src: url,
355
+ style: {
356
+ maxWidth: "100%",
357
+ height: "auto"
358
+ }
359
+ });
360
+ };
361
+ const $fe3d0290f00d135c$var$AssetDiff = ({ diff: diff , schemaType: schemaType })=>{
362
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanity.DiffFromTo), {
363
+ diff: diff,
364
+ schemaType: schemaType,
365
+ previewComponent: $fe3d0290f00d135c$var$CloudinaryDiffPreview
366
+ });
367
+ };
368
+ var $fe3d0290f00d135c$export$2e2bcd8739ae039 = $fe3d0290f00d135c$var$AssetDiff;
369
+
370
+
371
+
372
+
373
+ const $e1357c706847471f$export$3ed2e98ebe80ce58 = (0, $k7rGe$sanity.defineType)({
374
+ type: "object",
375
+ name: "cloudinary.asset",
376
+ fields: [
377
+ {
378
+ type: "string",
379
+ name: "public_id"
380
+ },
381
+ {
382
+ type: "string",
383
+ name: "resource_type"
384
+ },
385
+ {
386
+ type: "string",
387
+ name: "type"
388
+ },
389
+ {
390
+ type: "string",
391
+ name: "format"
392
+ },
393
+ {
394
+ type: "number",
395
+ name: "version"
396
+ },
397
+ {
398
+ type: "url",
399
+ name: "url"
400
+ },
401
+ {
402
+ type: "url",
403
+ name: "secure_url"
404
+ },
405
+ {
406
+ type: "number",
407
+ name: "width"
408
+ },
409
+ {
410
+ type: "number",
411
+ name: "height"
412
+ },
413
+ {
414
+ type: "number",
415
+ name: "bytes"
416
+ },
417
+ {
418
+ type: "number",
419
+ name: "duration"
420
+ },
421
+ {
422
+ type: "array",
423
+ name: "tags",
424
+ of: [
425
+ {
426
+ type: "string"
427
+ }
428
+ ]
429
+ },
430
+ {
431
+ type: "datetime",
432
+ name: "created_at"
433
+ },
434
+ {
435
+ type: "array",
436
+ name: "derived",
437
+ of: [
438
+ {
439
+ type: "cloudinary.assetDerived"
440
+ }
441
+ ]
442
+ },
443
+ {
444
+ type: "string",
445
+ name: "access_mode"
446
+ }
447
+ ],
448
+ components: {
449
+ input: (0, $33cd2e288485a815$export$2e2bcd8739ae039),
450
+ diff: (0, $fe3d0290f00d135c$export$2e2bcd8739ae039),
451
+ preview: (0, $ce38f38a3448fcbe$export$2e2bcd8739ae039)
452
+ },
453
+ preview: {
454
+ select: {
455
+ url: "url",
456
+ resource_type: "resource_type",
457
+ derived: "derived.0.url"
458
+ },
459
+ prepare ({ url: url , derived: derived , resource_type: resource_type }) {
460
+ return {
461
+ title: url,
462
+ resource_type: resource_type,
463
+ url: derived || url
464
+ };
465
+ }
466
+ }
467
+ });
468
+
469
+
470
+
471
+ const $f4ab4b5f606c4dbd$export$26e4781cb23ffde8 = (0, $k7rGe$sanity.defineType)({
472
+ type: "object",
473
+ name: "cloudinary.assetDerived",
474
+ fields: [
475
+ {
476
+ type: "string",
477
+ name: "raw_transformation"
478
+ },
479
+ {
480
+ type: "url",
481
+ name: "url"
482
+ },
483
+ {
484
+ type: "url",
485
+ name: "secure_url"
486
+ },
487
+ ]
488
+ });
489
+
490
+
491
+
492
+
493
+
494
+ function $322289a7e26b0974$export$41acf4847aa33418() {
495
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("svg", {
496
+ version: "1.1",
497
+ id: "Layer_1",
498
+ x: "0px",
499
+ y: "0px",
500
+ width: "1em",
501
+ height: "1em",
502
+ viewBox: "0 0 141.732 141.747",
503
+ enableBackground: "new 0 0 141.732 141.747",
504
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)("g", {
505
+ children: [
506
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("path", {
507
+ fill: "#0071CE",
508
+ d: "M115.585,109.242c-1.609,0-3.107-1.024-3.635-2.637c-0.657-2.008,0.438-4.169,2.447-4.826 c7.278-2.382,11.98-8.761,11.98-16.252c0-9.487-7.718-17.206-17.205-17.206c-0.659,0-1.368,0.052-2.231,0.164l-3.741,0.485 l-0.537-3.735c-2.299-16.016-16.251-28.094-32.454-28.094c-13.395,0-25.32,8.019-30.377,20.43l-0.952,2.335l-2.52,0.046 c-11.581,0.213-21.003,9.804-21.003,21.379c0,8.45,4.906,16.156,12.498,19.631c1.921,0.88,2.766,3.15,1.886,5.071 c-0.88,1.921-3.149,2.764-5.07,1.887C14.363,103.202,7.703,92.766,7.703,81.331c0-14.88,11.465-27.345,26.028-28.876 c6.71-14.03,20.773-22.965,36.477-22.965c18.796,0,35.135,13.178,39.372,31.184c13.519,0.219,24.45,11.284,24.45,24.854 c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z"
509
+ }),
510
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("path", {
511
+ fill: "#DC8327",
512
+ d: "M57.12,111.02c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001 c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001c0.001-0.001-0.001-0.001-0.001-0.001 l-0.001-0.001c0,0-0.001,0-0.001,0l-0.001-0.001c0.001,0.001-0.001-0.001-0.001-0.001s-0.002-0.001-0.003-0.001l-0.001-0.001H57.1 c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.003-0.001c-0.001,0.001-0.001-0.001-0.002-0.001 l-0.001-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001s-0.003-0.001-0.004-0.001 c-0.001-0.001-0.001-0.001-0.002-0.001h-0.001c-0.001-0.001-0.002-0.001-0.003-0.001c-0.001-0.001-0.003-0.001-0.003-0.001 c-0.001,0-0.001,0-0.001,0l-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001h-0.001c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002 h-0.002c-0.001,0-0.001,0-0.002,0c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c-0.001-0.001-0.001-0.001-0.001-0.001 c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001h-0.001h-0.001c-0.001,0-0.002,0-0.002,0h-0.001H56.86h-0.001h-0.001 c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001h-0.001c-0.001,0-0.001,0-0.001,0c-1.656,0-3.011-1.348-3.021-3V74.29h2.567 c0.004,0,0.009,0,0.013,0c0.393,0.017,0.661-0.285,0.661-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.379-8.544 c-0.222-0.153-0.515-0.153-0.737,0l-12.476,8.611c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.58 l0.002,33.674c0.013,2.328,1.883,4.228,4.262,4.288c0.027,0.003,0.053,0.005,0.08,0.005h18.481c0.004,0,0.007,0,0.011,0 c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.004-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003 c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001c0.001-0.001,0.001-0.001,0.001-0.001 c0.002-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447 v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002C57.498,111.345,57.343,111.121,57.12,111.02z"
513
+ }),
514
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("path", {
515
+ fill: "#F4B21B",
516
+ d: "M83.889,111.02c0,0-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001 c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001c0,0-0.001-0.001-0.001-0.001 c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.002,0.001-0.002-0.001-0.002-0.001 l-0.002-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001-0.001-0.002-0.001-0.002-0.001 c-0.001,0.001-0.001-0.001-0.003-0.001l-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.002-0.001c-0.001-0.001-0.003-0.001-0.004-0.001 s-0.003-0.001-0.004-0.001c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.001,0-0.002-0.001c0,0-0.001,0-0.002-0.001 c-0.003-0.001-0.001-0.001-0.002-0.001c-0.003,0-0.001,0-0.002-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001 c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002c-0.001,0-0.001,0-0.001,0c-0.001,0-0.002,0-0.002,0s-0.001,0-0.001,0h-0.001h-0.001 l-0.001-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001 c-0.001,0-0.002,0-0.002,0s-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001 h-0.001c-0.001,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V81.829h2.579c0.009-0.001,0.016-0.001,0.026,0 c0.358,0,0.648-0.29,0.648-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.222-0.153-0.515-0.153-0.737,0L57.86,80.647 c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.568l0.002,26.135 c0.011,2.329,1.884,4.23,4.264,4.289c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0 c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.006-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003 c0.001-0.001,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001c0,0,0.001,0,0.001-0.001l0.001-0.001 c0.001,0,0.001-0.001,0.001-0.001c0.003-0.001,0.002-0.001,0.002-0.002c0,0,0,0,0.001-0.001c0,0,0,0,0.001-0.001 c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002 C84.267,111.345,84.112,111.121,83.889,111.02z"
517
+ }),
518
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("path", {
519
+ fill: "#F2D864",
520
+ d: "M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001 c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001 c-0.001-0.001-0.001-0.001-0.001-0.001s-0.001,0-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001 c-0.001,0.001-0.001-0.001-0.002-0.001c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001,0 c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.002-0.001c-0.001,0.001-0.001-0.001-0.003-0.001 l-0.001-0.001c0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001 s-0.003-0.001-0.004-0.001l-0.002-0.001c0,0-0.001,0-0.002-0.001l-0.002-0.001c-0.003-0.001-0.003-0.001-0.002-0.001 c-0.003,0-0.003,0-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.001,0-0.002-0.001-0.002-0.001h-0.001 c-0.059-0.021-0.122-0.034-0.188-0.037h-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.003,0h-0.001h-0.001h-0.001 c-0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.002,0c0,0-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001 c-0.001,0-0.002,0-0.002,0h-0.002c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c0,0-0.001,0-0.001,0h-0.001h-0.001h-0.001H110.4 c0,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V89.365h2.573c0.004,0,0.009,0,0.013,0c0.365-0.009,0.661-0.285,0.661-0.648 c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.221-0.153-0.515-0.153-0.737,0l-12.476,8.61c-0.234,0.161-0.335,0.456-0.251,0.727 c0.085,0.271,0.335,0.455,0.619,0.455h2.573l0.002,18.599c0.013,2.329,1.885,4.231,4.264,4.289 c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0c0.17-0.003,0.324-0.071,0.438-0.18l0.001-0.001 c0.002-0.002,0.005-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001 l0.001-0.001l0.001-0.001l0.001-0.001c0.003-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001 c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002 C111.045,111.345,110.889,111.121,110.667,111.02z"
521
+ })
522
+ ]
523
+ })
524
+ });
525
+ }
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+ const $6307c4f1c8970a7e$export$a829527ff4e4114a = (0, ($parcel$interopDefault($k7rGe$styledcomponents))).div`
537
+ height: 70vh;
538
+ `;
539
+ function $6307c4f1c8970a7e$export$d86b01636c6a833b(props) {
540
+ const { onClose: onClose } = props;
541
+ const [loadingMessage, setLoadingMessage] = (0, $k7rGe$react.useState)("Loading Cloudinary Media Libary");
542
+ const library = (0, $k7rGe$react.useRef)();
543
+ const contentRef = (0, $k7rGe$react.useRef)(null);
544
+ const { secrets: secrets } = (0, $k7rGe$sanitystudiosecrets.useSecrets)((0, $dd59fa4f97eba425$export$76a88f7de6507443));
545
+ const cloudName = secrets?.cloudName;
546
+ const apiKey = secrets?.apiKey;
547
+ const [widgetId] = (0, $k7rGe$react.useState)(()=>`cloundinaryWidget-${Date.now()}`);
548
+ const [showSettings, setShowSettings] = (0, $k7rGe$react.useState)(false);
549
+ const propsRef = (0, $k7rGe$react.useRef)(props);
550
+ (0, $k7rGe$react.useEffect)(()=>{
551
+ // because we have to access props after loading js in a callback,
552
+ // we cannot pass props as dependecnies as that will cause infinite updates
553
+ // this takes a snapshot of props, so we can access them later
554
+ propsRef.current = props;
555
+ }, [
556
+ props
557
+ ]);
558
+ const handleClose = (0, $k7rGe$react.useCallback)(()=>{
559
+ if (library.current) library.current.hide();
560
+ onClose();
561
+ }, [
562
+ onClose,
563
+ library
564
+ ]);
565
+ (0, $k7rGe$react.useEffect)(()=>{
566
+ if (!cloudName || !apiKey) return;
567
+ (0, $f5b36b9feac7c9dc$export$fa8126b76e785c83)({
568
+ cloudName: cloudName,
569
+ apiKey: apiKey,
570
+ inlineContainer: `#${widgetId}`,
571
+ libraryCreated: (lib)=>{
572
+ library.current = lib;
573
+ const selectedAssets = propsRef.current.selectedAssets;
574
+ const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null;
575
+ // eslint-disable-next-line no-undef
576
+ const iframe = contentRef.current && contentRef.current.firstChild;
577
+ if (iframe && iframe instanceof HTMLIFrameElement) {
578
+ setLoadingMessage(undefined);
579
+ let asset;
580
+ if (propsRef.current.selectionType === "single" && firstSelectedAsset && firstSelectedAsset.source && firstSelectedAsset.source.id) asset = (0, $f5b36b9feac7c9dc$export$369dff7d11616ebd)(firstSelectedAsset.source.id);
581
+ const folder = asset ? {
582
+ path: asset.public_id.split("/").slice(0, -1).join("/"),
583
+ resource_type: "image"
584
+ } : {
585
+ path: "",
586
+ resource_type: "image"
587
+ };
588
+ if (lib && contentRef.current) {
589
+ lib.show({
590
+ folder: folder,
591
+ asset: asset
592
+ });
593
+ contentRef.current.style.visibility = "visible";
594
+ }
595
+ }
596
+ },
597
+ insertHandler: ({ assets: assets })=>{
598
+ if (!library.current) return;
599
+ const imageAssets = assets.filter((asset)=>asset.resource_type === "image");
600
+ if (imageAssets.length === 0) throw new Error("The selection did not contain any images.");
601
+ library.current.hide();
602
+ propsRef.current.onSelect(imageAssets.map((asset)=>{
603
+ const url = asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url;
604
+ return {
605
+ kind: "url",
606
+ value: url,
607
+ assetDocumentProps: {
608
+ _type: "sanity.imageAsset",
609
+ originalFilename: (0, $f5b36b9feac7c9dc$export$e708ba11f5ba43ca)(asset),
610
+ source: {
611
+ id: (0, $f5b36b9feac7c9dc$export$f58729bedbec21be)(asset),
612
+ name: `cloudinary:${cloudName}`
613
+ }
614
+ }
615
+ };
616
+ }));
617
+ }
618
+ });
619
+ }, [
620
+ cloudName,
621
+ apiKey,
622
+ widgetId
623
+ ]);
624
+ const hasConfig = apiKey && cloudName;
625
+ return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Dialog), {
626
+ id: "cloudinary-asset-source",
627
+ header: "Select image from Cloudinary",
628
+ onClose: handleClose,
629
+ open: true,
630
+ width: 4,
631
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$sanityui.Box), {
632
+ padding: 4,
633
+ children: [
634
+ showSettings && /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $dd59fa4f97eba425$export$2e2bcd8739ae039), {
635
+ onClose: ()=>setShowSettings(false)
636
+ }),
637
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Flex), {
638
+ flex: 1,
639
+ justify: "flex-end",
640
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Button), {
641
+ color: "primary",
642
+ icon: (0, $k7rGe$sanityicons.PlugIcon),
643
+ mode: "bleed",
644
+ title: "Configure",
645
+ onClick: ()=>setShowSettings(true),
646
+ tabIndex: 1,
647
+ text: hasConfig ? undefined : "Configure Cloudinary plugin"
648
+ })
649
+ }),
650
+ hasConfig && loadingMessage && /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$sanityui.Stack), {
651
+ space: 3,
652
+ children: [
653
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Flex), {
654
+ align: "center",
655
+ justify: "center",
656
+ children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Spinner), {
657
+ muted: true
658
+ })
659
+ }),
660
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Text), {
661
+ size: 1,
662
+ muted: true,
663
+ align: "center",
664
+ children: loadingMessage
665
+ })
666
+ ]
667
+ }),
668
+ /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)($6307c4f1c8970a7e$export$a829527ff4e4114a, {
669
+ style: {
670
+ visibility: "hidden"
671
+ },
672
+ ref: contentRef,
673
+ id: widgetId
674
+ })
675
+ ]
676
+ })
677
+ });
678
+ }
679
+
680
+
681
+ const $244e63ca53592e4d$export$d69fa36e91cd4a95 = (0, $k7rGe$sanity.createPlugin)({
682
+ name: "cloudinary-schema",
683
+ schema: {
684
+ types: [
685
+ (0, $e1357c706847471f$export$3ed2e98ebe80ce58),
686
+ (0, $f4ab4b5f606c4dbd$export$26e4781cb23ffde8)
687
+ ]
688
+ }
689
+ });
690
+ const $244e63ca53592e4d$export$f3531f7607fb0a50 = {
691
+ name: "cloudinary-image",
692
+ title: "Cloudinary",
693
+ icon: (0, $322289a7e26b0974$export$41acf4847aa33418),
694
+ component: (0, $6307c4f1c8970a7e$export$d86b01636c6a833b)
695
+ };
696
+ const $244e63ca53592e4d$export$4e2fc220d417fe6a = (0, $k7rGe$sanity.createPlugin)({
697
+ name: "cloudinart-asset-source",
698
+ form: {
699
+ image: {
700
+ assetSources: [
701
+ $244e63ca53592e4d$export$f3531f7607fb0a50
702
+ ]
703
+ }
704
+ }
705
+ });
706
+
707
+
708
+ //# sourceMappingURL=index.js.map