sanity-plugin-cloudinary

2.1.62.1.7
dist/index.js.map
~dist/index.js.mapModified
+1−1
Index: package/dist/index.js.map
===================================================================
--- package/dist/index.js.map
+++ package/dist/index.js.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.js","names":["<SettingsView\n      title=\"Cloudinary config\"\n      namespace={namespace}\n      keys={pluginConfigKeys}\n      onClose={props.onClose}\n    />","onClose","_c","() => `cloudinaryWidget-${Date.now()}`","() => {\n    // because we have to access props after loading js in a callback,\n    // we cannot pass props as dependencies as that will cause infinite updates\n    // this takes a snapshot of props, so we can access them later\n    propsRef.current = props\n  }","[props]","() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }","useCallback(() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }, [onClose, library])","() => {\n    if (!cloudName || !apiKey) {\n      return\n    }\n\n    createMediaLibrary({\n      cloudName,\n      apiKey,\n      inlineContainer: `#${widgetId}`,\n      libraryCreated: (lib: CloudinaryMediaLibrary) => {\n        library.current = lib\n        const selectedAssets = propsRef.current.selectedAssets\n        const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null\n\n        const iframe: ChildNode | null | undefined =\n          contentRef.current && contentRef.current.firstChild\n        if (iframe && iframe instanceof HTMLIFrameElement) {\n          setLoadingMessage(undefined)\n          let asset\n          if (\n            propsRef.current.selectionType === 'single' &&\n            firstSelectedAsset &&\n            firstSelectedAsset.source &&\n            firstSelectedAsset.source.id\n          ) {\n            asset = decodeSourceId(firstSelectedAsset.source.id)\n          }\n          const folder = asset\n            ? {\n                path: asset.public_id.split('/').slice(0, -1).join('/'),\n                resource_type: 'image',\n              }\n            : {path: '', resource_type: 'image'}\n          if (lib && contentRef.current) {\n            lib.show({folder, asset})\n            contentRef.current.style.visibility = 'visible'\n          }\n        }\n      },\n      insertHandler: ({assets}: InsertHandlerParams) => {\n        if (!library.current) {\n          return\n        }\n        const imageAssets = assets.filter((asset) => asset.resource_type === 'image')\n        if (imageAssets.length === 0) {\n          throw new Error('The selection did not contain any images.')\n        }\n        library.current.hide()\n        propsRef.current.onSelect(\n          imageAssets.map((asset) => {\n            const url =\n              asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url\n            return {\n              kind: 'url',\n              value: url,\n              assetDocumentProps: {\n                _type: 'sanity.imageAsset',\n                originalFilename: encodeFilename(asset),\n                source: {\n                  id: encodeSourceId(asset),\n                  name: `cloudinary:${cloudName}`,\n                },\n              } as ImageAsset,\n            }\n          }),\n        )\n      },\n    })\n  }","[cloudName, apiKey, widgetId]","{assets}: InsertHandlerParams","(asset) => asset.resource_type === 'image'","asset","showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />","() => setShowSettings(true)","<Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>","hasConfig ? undefined : 'Configure Cloudinary plugin'","hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )","{visibility: 'hidden'}","<Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />","<Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>","<Dialog\n      id=\"cloudinary-asset-source\"\n      header={dialogHeaderTitle ?? 'Select image from Cloudinary'}\n      onClose={handleClose}\n      open\n      width={4}\n    >\n      <Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>\n    </Dialog>","dialogHeaderTitle ?? 'Select image from Cloudinary'","_c","_temp","_temp2","<svg\n      version=\"1.1\"\n      id=\"Layer_1\"\n      x=\"0px\"\n      y=\"0px\"\n      width=\"1em\"\n      height=\"1em\"\n      viewBox=\"0 0 141.732 141.747\"\n      enableBackground=\"new 0 0 141.732 141.747\"\n    >\n      <g>\n        <path\n          fill=\"#0071CE\"\n          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\n        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\n        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\n        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\n        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\n        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\n        c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z\"\n        />\n        <path\n          fill=\"#DC8327\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\"\n        />\n        <path\n          fill=\"#F4B21B\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C84.267,111.345,84.112,111.121,83.889,111.02z\"\n        />\n        <path\n          fill=\"#F2D864\"\n          d=\"M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C111.045,111.345,110.889,111.121,110.667,111.02z\"\n        />\n      </g>\n    </svg>","_c","{\n    width: '100%',\n    height: 'auto',\n  }","<video controls aria-label=\"Cloudinary video preview\" style={style}>\n      <source src={src} type=\"video/mp4\" />\n    </video>","_c","{value}: Props","assetUrl(value, cloudName)","{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }","<section\n        style={{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }}\n      >\n        <VideoPlayer src={url} kind=\"diff\" />\n      </section>","{maxWidth: '100%', height: 'auto'}","<img alt=\"preview\" src={url} style={{maxWidth: '100%', height: 'auto'}} />","{diff, schemaType}: DiffProps","<DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />","_c","{value, layout}: ComponentProps","{\n            maxWidth: layout === 'default' ? '80px' : '100%',\n          }","layout === 'default' ? '80px' : '100%'","<DocumentIcon />","{marginLeft: '0.5em'}","<Flex align=\"center\">\n          <DocumentIcon />\n          <Text size={1} style={{marginLeft: '0.5em'}}>\n            {value.display_name ?? 'Raw file'}\n          </Text>\n        </Flex>","value.display_name ?? 'Raw file'","layout === 'default' ? (\n        <Flex align=\"center\" justify=\"center\" style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{maxWidth: '80px', height: 'auto', display: 'block'}}\n          />\n        </Flex>\n      ) : (\n        <div style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{width: '100%', height: 'auto', display: 'block'}}\n          />\n        </div>\n      )","_c","() => {\n    onChange(PatchEvent.from([unset()]))\n  }","useCallback(() => {\n    onChange(PatchEvent.from([unset()]))\n  }, [onChange])","<SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>","onSetup","{textAlign: 'center', width: '100%'}","<Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>","value as CloudinaryAsset","{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}","<Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />","<Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />","readOnly || !value","<Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>","<Stack>\n      <SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>\n\n      <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>\n\n      <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>\n    </Stack>","_c","(payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    }","type.name","useCallback(\n    (payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    },\n    [onChange, type, valueKey],\n  )","secrets\n    ? () =>\n        openMediaSelector(\n          secrets.cloudName,\n          secrets.apiKey,\n          false, // single selection\n          handleSelect,\n          value,\n        )\n    : () => setShowSettings(true)","showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />","() => setShowSettings(true)","<WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />","<>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n      <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />\n    </>","_c","_Fragment","() => setShowSettings(true)","useCallback(() => setShowSettings(true), [setShowSettings])","() => setShowSettings(false)","useCallback(() => setShowSettings(false), [setShowSettings])","props.schemaType.of.find(\n    (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n  )","of","(t: {name: string}) => t.name === cloudinaryAssetSchema.name","(t) => t.name","(selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    }","useCallback(\n    (selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    },\n    [onValueCreate, onChange, cloudinaryType],\n  )","() =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      )","useCallback(\n    () =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      ),\n    [secrets, handleSelect],\n  )","showSettings && <SecretsConfigView onClose={hide} />","<Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>","cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )","readOnly","<Flex gap={2} flex={1}>\n      {showSettings && <SecretsConfigView onClose={hide} />}\n      <Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>\n      {cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )}\n    </Flex>","t","_c","_Fragment","revision = 0","{apiVersion: API_VERSION}","() => {\n    if (!ref) {\n      return undefined\n    }\n\n    let cancelled = false\n    client\n      .getDocument<{asset?: CloudinaryAsset}>(ref)\n      .then((document) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: document?.asset ?? null})\n        }\n        return null\n      })\n      .catch((err) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: null})\n        }\n        console.error('Error fetching referenced asset:', err)\n      })\n\n    return () => {\n      cancelled = true\n    }\n  }","[ref, client, revision]","<div>Loading asset...</div>","<AssetPreview value={result.asset} layout=\"block\" />","asset","API_VERSION","_c","\"id\"","\"asset\"","\"folder\""],"sources":["../src/utils.ts","../src/components/SecretsConfigView.tsx","../src/components/asset-source/CloudinaryAssetSource.tsx","../src/components/asset-source/Icon.tsx","../src/components/VideoPlayer.tsx","../src/components/AssetDiff.tsx","../src/components/AssetPreview.tsx","../src/components/WidgetInput.tsx","../src/components/CloudinaryInput.tsx","../src/schema/cloudinaryAsset.ts","../src/components/AssetListFunctions.tsx","../src/schema/cloudinaryAssetContext.ts","../src/schema/cloudinaryAssetContextCustom.ts","../src/schema/cloudinaryAssetDerived.ts","../src/schema/cloudinaryAssetDocument.ts","../src/components/ReferencePreview.tsx","../src/components/CloudinaryReferenceInput.tsx","../src/schema/cloudinaryAssetReference.ts","../src/index.ts"],"sourcesContent":["import {CloudConfig, CloudinaryImage} from '@cloudinary/url-gen'\nimport {scale} from '@cloudinary/url-gen/actions/resize'\n\nimport type {\n  CloudinaryAsset,\n  CloudinaryAssetResponse,\n  CloudinaryMediaLibrary,\n  InsertHandlerParams,\n  ShowHandlerParams,\n} from './types'\n\nconst widgetSrc = 'https://media-library.cloudinary.com/global/all.js'\n\nexport function assetUrl(\n  asset: Partial<\n    Pick<\n      CloudinaryAsset,\n      'url' | 'secure_url' | 'derived' | 'public_id' | 'format' | 'resource_type' | 'type'\n    >\n  >,\n  cloudName?: string,\n): string | undefined {\n  const [derived] = asset.derived ?? []\n\n  // When the cloud name and public id are known and there is no Media Library\n  // derived transform, build an on-the-fly preview with url-gen instead of\n  // serving the full-size original. Scaling to a 400px width keeps previews\n  // crisp while avoiding multi-megabyte source downloads.\n  // Only public `upload` images use CloudinaryImage — video/raw would get an\n  // /image/upload URL that breaks VideoPlayer/raw previews, and private or\n  // authenticated assets need their stored (often signed) URL rather than an\n  // unsigned /upload/ path. Derived transforms are preferred over the scaled\n  // original so Studio still shows the editor's chosen crop/effects.\n  if (\n    cloudName &&\n    asset.public_id &&\n    !derived &&\n    asset.resource_type !== 'video' &&\n    asset.resource_type !== 'raw' &&\n    (!asset.type || asset.type === 'upload')\n  ) {\n    return new CloudinaryImage(asset.public_id, new CloudConfig({cloudName}))\n      .resize(scale().width(400))\n      .toURL()\n  }\n\n  if (derived) {\n    if (derived.secure_url) {\n      return derived.secure_url\n    }\n    return derived.url\n  }\n  if (asset.secure_url) {\n    return asset.secure_url\n  }\n  return asset.url\n}\n\n/**\n * Normalize a Media Library payload into a shape that matches the `cloudinary.asset`\n * schema: drop nulls, sanitize context keys, and tag derived items with `_type`.\n */\nexport function normalizeCloudinaryAsset(asset: CloudinaryAssetResponse): Record<string, unknown> {\n  const assetWithoutNulls = Object.fromEntries(\n    Object.entries(asset).filter(([, assetValue]) => assetValue !== null),\n  ) as CloudinaryAssetResponse\n\n  const requiredFields = {\n    public_id: asset.public_id,\n    resource_type: asset.resource_type,\n    type: asset.type,\n    url: asset.url,\n    secure_url: asset.secure_url,\n    format: asset.format,\n    width: asset.width,\n    height: asset.height,\n    bytes: asset.bytes,\n    tags: asset.tags,\n  }\n\n  let updatedAsset: Record<string, unknown> = {\n    ...assetWithoutNulls,\n    ...requiredFields,\n  }\n\n  // Only persist Cloudinary's asset id when the Media Library actually provides one.\n  // Do not delete a missing id here — callers that replace a whole asset object should\n  // preserve any previously stored id themselves (see CloudinaryReferenceInput).\n  if (asset.id) {\n    updatedAsset['id'] = asset.id\n  }\n\n  // Sanity object keys cannot contain special characters, so rename Cloudinary context keys\n  if (asset.context) {\n    const objectWithRenamedKeys = Object.fromEntries(\n      Object.entries(asset.context.custom).map(([contextKey, contextValue]) => {\n        return [contextKey.replace(/[^a-zA-Z0-9_]|-/g, '_'), contextValue]\n      }),\n    )\n\n    updatedAsset = {\n      ...updatedAsset,\n      context: {\n        ...asset.context,\n        custom: objectWithRenamedKeys,\n      },\n    }\n  }\n\n  if (asset.derived) {\n    updatedAsset = {\n      ...updatedAsset,\n      derived: asset.derived.map((derivedItem) => ({\n        _type: 'derived',\n        url: derivedItem.url,\n        secure_url: derivedItem.secure_url,\n        raw_transformation: derivedItem.raw_transformation,\n      })),\n    }\n  }\n\n  return updatedAsset\n}\n\nexport const openMediaSelector = (\n  cloudName: string,\n  apiKey: string,\n  multiple: boolean,\n  insertHandler: (params: InsertHandlerParams) => void,\n  selectedAsset?: CloudinaryAsset,\n  showHandler?: (params: ShowHandlerParams) => void,\n  folder?: {resource_type?: 'image' | 'video'; path?: string},\n) => {\n  loadJS(widgetSrc, (cloudinary) => {\n    const options: Record<string, any> = {\n      cloud_name: cloudName,\n      api_key: apiKey,\n      insert_caption: 'Select',\n      multiple,\n    }\n\n    if (selectedAsset) {\n      options['asset'] = {\n        public_id: selectedAsset.public_id,\n        type: selectedAsset.type,\n        resource_type: selectedAsset.resource_type,\n      }\n    }\n\n    if (folder?.path || folder?.resource_type) {\n      options['folder'] = {\n        ...(folder.path ? {path: folder.path} : {}),\n        ...(folder.resource_type ? {resource_type: folder.resource_type} : {}),\n      }\n    }\n\n    const callbacks: {\n      insertHandler: (params: InsertHandlerParams) => void\n      showHandler?: (params: ShowHandlerParams) => void\n    } = {insertHandler}\n\n    if (showHandler) {\n      callbacks.showHandler = showHandler\n    }\n\n    cloudinary.openMediaLibrary(options, callbacks)\n  })\n}\n\nexport const createMediaLibrary = ({\n  cloudName,\n  apiKey,\n  inlineContainer,\n  libraryCreated,\n  insertHandler,\n}: {\n  cloudName: string\n  apiKey: string\n  inlineContainer: string\n  libraryCreated: (library: CloudinaryMediaLibrary) => void\n  insertHandler: (params: InsertHandlerParams) => void\n}) => {\n  loadJS(widgetSrc, (cloudinary) => {\n    const options: Record<string, any> = {\n      cloud_name: cloudName,\n      api_key: apiKey,\n      insert_caption: 'Select',\n      inline_container: inlineContainer,\n      remove_header: true,\n    }\n\n    libraryCreated(cloudinary.createMediaLibrary(options, {insertHandler}))\n  })\n}\n\nfunction loadJS(url: string, callback: (cloudinary: NonNullable<Window['cloudinary']>) => void) {\n  // The widget exposes `window.cloudinary` only once the script has finished\n  // loading. When it's already available, run the callback right away.\n  if (window.cloudinary) {\n    callback(window.cloudinary)\n    return\n  }\n\n  // Guard against double-invocation if load fires in the same tick as the\n  // post-listener readiness re-check below.\n  let settled = false\n  const handleLoad = () => {\n    if (settled || !window.cloudinary) {\n      return\n    }\n    settled = true\n    callback(window.cloudinary)\n  }\n\n  const existingScript = document.getElementById('damWidget')\n  if (existingScript) {\n    // Another input already injected the script, but it hasn't finished\n    // loading yet (the global isn't ready). Wait for the load event instead\n    // of invoking the callback too early.\n    existingScript.addEventListener('load', handleLoad, {once: true})\n    // Re-check immediately: the load event may have fired between the initial\n    // `window.cloudinary` check and registering this listener, in which case\n    // the event will never fire again and the callback would otherwise hang.\n    handleLoad()\n    return\n  }\n\n  const script = document.createElement('script')\n  script.src = url\n  script.id = 'damWidget'\n  script.addEventListener('load', handleLoad, {once: true})\n  document.body.appendChild(script)\n}\n\nexport function encodeSourceId(asset: CloudinaryAssetResponse): string {\n  const {resource_type, public_id, type} = asset\n  return btoa(JSON.stringify({public_id, resource_type, type})) // Sort keys alphabetically!\n}\n\nexport function encodeFilename(asset: CloudinaryAssetResponse) {\n  return `${asset.public_id.split('/').slice(-1)[0]}.${asset.format}`\n}\n\nexport function decodeSourceId(sourceId: string): CloudinaryAssetResponse | undefined {\n  let sourceIdDecoded: any\n  try {\n    sourceIdDecoded = JSON.parse(atob(sourceId))\n  } catch {\n    // Do nothing\n  }\n  return sourceIdDecoded\n}\n","import {SettingsView} from '@sanity/studio-secrets'\n\nexport type Secrets = {\n  cloudName: string\n  apiKey: string\n}\n\nconst pluginConfigKeys = [\n  {\n    key: 'cloudName',\n    title: 'Cloud name',\n    description: '',\n  },\n  {\n    key: 'apiKey',\n    title: 'API key',\n    description: '',\n  },\n]\n\nexport const namespace = 'cloudinary'\n\ntype Props = {\n  onClose: () => void\n}\n\nconst SecretsConfigView = (props: Props) => {\n  return (\n    <SettingsView\n      title=\"Cloudinary config\"\n      namespace={namespace}\n      keys={pluginConfigKeys}\n      onClose={props.onClose}\n    />\n  )\n}\n\nexport default SecretsConfigView\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Box, Button, Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {useCallback, useEffect, useRef, useState} from 'react'\nimport type {AssetSourceComponentProps, ImageAsset} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {CloudinaryMediaLibrary, InsertHandlerParams} from '../../types'\nimport {createMediaLibrary, decodeSourceId, encodeFilename, encodeSourceId} from '../../utils'\nimport SecretsConfigView, {namespace, type Secrets} from '../SecretsConfigView'\n\nconst Widget = styled.div`\n  height: 70vh;\n`\n\nexport function CloudinaryAssetSource(props: AssetSourceComponentProps) {\n  const {onClose, dialogHeaderTitle} = props\n\n  const [loadingMessage, setLoadingMessage] = useState<string | undefined>(\n    'Loading Cloudinary Media Library',\n  )\n  const library = useRef<CloudinaryMediaLibrary | undefined>(undefined)\n  const contentRef = useRef<HTMLDivElement | null>(null)\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n  const apiKey = secrets?.apiKey\n  const [widgetId] = useState(() => `cloudinaryWidget-${Date.now()}`)\n  const [showSettings, setShowSettings] = useState(false)\n\n  const propsRef = useRef(props)\n\n  useEffect(() => {\n    // because we have to access props after loading js in a callback,\n    // we cannot pass props as dependencies as that will cause infinite updates\n    // this takes a snapshot of props, so we can access them later\n    propsRef.current = props\n  }, [props])\n\n  const handleClose = useCallback(() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }, [onClose, library])\n\n  useEffect(() => {\n    if (!cloudName || !apiKey) {\n      return\n    }\n\n    createMediaLibrary({\n      cloudName,\n      apiKey,\n      inlineContainer: `#${widgetId}`,\n      libraryCreated: (lib: CloudinaryMediaLibrary) => {\n        library.current = lib\n        const selectedAssets = propsRef.current.selectedAssets\n        const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null\n\n        const iframe: ChildNode | null | undefined =\n          contentRef.current && contentRef.current.firstChild\n        if (iframe && iframe instanceof HTMLIFrameElement) {\n          setLoadingMessage(undefined)\n          let asset\n          if (\n            propsRef.current.selectionType === 'single' &&\n            firstSelectedAsset &&\n            firstSelectedAsset.source &&\n            firstSelectedAsset.source.id\n          ) {\n            asset = decodeSourceId(firstSelectedAsset.source.id)\n          }\n          const folder = asset\n            ? {\n                path: asset.public_id.split('/').slice(0, -1).join('/'),\n                resource_type: 'image',\n              }\n            : {path: '', resource_type: 'image'}\n          if (lib && contentRef.current) {\n            lib.show({folder, asset})\n            contentRef.current.style.visibility = 'visible'\n          }\n        }\n      },\n      insertHandler: ({assets}: InsertHandlerParams) => {\n        if (!library.current) {\n          return\n        }\n        const imageAssets = assets.filter((asset) => asset.resource_type === 'image')\n        if (imageAssets.length === 0) {\n          throw new Error('The selection did not contain any images.')\n        }\n        library.current.hide()\n        propsRef.current.onSelect(\n          imageAssets.map((asset) => {\n            const url =\n              asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url\n            return {\n              kind: 'url',\n              value: url,\n              assetDocumentProps: {\n                _type: 'sanity.imageAsset',\n                originalFilename: encodeFilename(asset),\n                source: {\n                  id: encodeSourceId(asset),\n                  name: `cloudinary:${cloudName}`,\n                },\n              } as ImageAsset,\n            }\n          }),\n        )\n      },\n    })\n  }, [cloudName, apiKey, widgetId])\n\n  const hasConfig = apiKey && cloudName\n  return (\n    <Dialog\n      id=\"cloudinary-asset-source\"\n      header={dialogHeaderTitle ?? 'Select image from Cloudinary'}\n      onClose={handleClose}\n      open\n      width={4}\n    >\n      <Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>\n    </Dialog>\n  )\n}\n","export function CloudinaryIcon() {\n  return (\n    <svg\n      version=\"1.1\"\n      id=\"Layer_1\"\n      x=\"0px\"\n      y=\"0px\"\n      width=\"1em\"\n      height=\"1em\"\n      viewBox=\"0 0 141.732 141.747\"\n      enableBackground=\"new 0 0 141.732 141.747\"\n    >\n      <g>\n        <path\n          fill=\"#0071CE\"\n          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\n        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\n        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\n        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\n        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\n        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\n        c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z\"\n        />\n        <path\n          fill=\"#DC8327\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\"\n        />\n        <path\n          fill=\"#F4B21B\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C84.267,111.345,84.112,111.121,83.889,111.02z\"\n        />\n        <path\n          fill=\"#F2D864\"\n          d=\"M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C111.045,111.345,110.889,111.121,110.667,111.02z\"\n        />\n      </g>\n    </svg>\n  )\n}\n","import type {CSSProperties} from 'react'\n\ntype PlayerKind = 'player' | 'diff'\n\nexport type VideoPlayerProps = {\n  src: string\n  kind: PlayerKind\n}\n\nexport default function VideoPlayer(props: VideoPlayerProps) {\n  const {src} = props\n\n  const style: CSSProperties = {\n    width: '100%',\n    height: 'auto',\n  }\n\n  return (\n    // Cloudinary videos are user-uploaded and have no caption files to point a\n    // `<track>` at; a `src`-less `<track>` would be invalid HTML, so omit it.\n    // eslint-disable-next-line jsx-a11y/media-has-caption -- no captions available for arbitrary Cloudinary videos\n    <video controls aria-label=\"Cloudinary video preview\" style={style}>\n      <source src={src} type=\"video/mp4\" />\n    </video>\n  )\n}\n","import {useSecrets} from '@sanity/studio-secrets'\nimport {DiffFromTo} from 'sanity'\n\nimport type {CloudinaryAsset} from '../types'\nimport {assetUrl} from '../utils'\nimport {namespace, type Secrets} from './SecretsConfigView'\nimport VideoPlayer from './VideoPlayer'\n\ntype Props = {\n  value: CloudinaryAsset | undefined\n}\n\nconst CloudinaryDiffPreview = ({value}: Props) => {\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n\n  if (!value) {\n    return null\n  }\n\n  const url = assetUrl(value, cloudName)\n\n  if (value.resource_type === 'video' && url) {\n    return (\n      <section\n        style={{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }}\n      >\n        <VideoPlayer src={url} kind=\"diff\" />\n      </section>\n    )\n  }\n\n  return <img alt=\"preview\" src={url} style={{maxWidth: '100%', height: 'auto'}} />\n}\n\ntype DiffProps = {\n  diff: any\n  schemaType: any\n}\n\nconst AssetDiff = ({diff, schemaType}: DiffProps) => {\n  return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />\n}\n\nexport default AssetDiff\n","import {DocumentIcon} from '@sanity/icons/Document'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Flex, Text} from '@sanity/ui'\n\nimport type {CloudinaryAsset} from '../types'\nimport {assetUrl} from '../utils'\nimport {namespace, type Secrets} from './SecretsConfigView'\nimport VideoPlayer from './VideoPlayer'\n\ninterface ComponentProps {\n  layout?: 'default' | 'block'\n  value: CloudinaryAsset | undefined\n}\n\nconst AssetPreview = ({value, layout}: ComponentProps) => {\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n\n  if (!value || !cloudName) {\n    return null\n  }\n\n  const url = assetUrl(value, cloudName)\n  if (!url) {\n    return null\n  }\n\n  switch (value.resource_type) {\n    case 'video':\n      return (\n        <Flex\n          align=\"center\"\n          style={{\n            maxWidth: layout === 'default' ? '80px' : '100%',\n          }}\n        >\n          <VideoPlayer src={url} kind=\"player\" />\n        </Flex>\n      )\n    case 'raw':\n      return (\n        <Flex align=\"center\">\n          <DocumentIcon />\n          <Text size={1} style={{marginLeft: '0.5em'}}>\n            {value.display_name ?? 'Raw file'}\n          </Text>\n        </Flex>\n      )\n    default: {\n      // Cloudinary returns resource_type as \"image\" even for PDFs, so we check\n      // the format to handle PDFs specifically: convert the first page to JPG\n      // and overlay a \"PDF\" label for thumbnail clarity.\n      const previewSrc =\n        value.format === 'pdf'\n          ? url.replace(\n              'image/upload',\n              'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n            )\n          : url\n\n      return layout === 'default' ? (\n        <Flex align=\"center\" justify=\"center\" style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{maxWidth: '80px', height: 'auto', display: 'block'}}\n          />\n        </Flex>\n      ) : (\n        <div style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{width: '100%', height: 'auto', display: 'block'}}\n          />\n        </div>\n      )\n    }\n  }\n}\n\nexport default AssetPreview\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {Button, Flex, Grid, Stack} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {type ObjectInputProps, PatchEvent, unset} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {CloudinaryAsset} from '../types'\nimport AssetPreview from './AssetPreview'\n\nconst SetupButtonContainer = styled.div`\n  position: relative;\n  display: block;\n  font-size: 0.8em;\n  transform: translate(0%, -10%);\n`\n\ntype WidgetInputProps = ObjectInputProps & {openMediaSelector: () => void; onSetup: () => void}\n\nconst WidgetInput = (props: WidgetInputProps) => {\n  const {onChange, readOnly, value, openMediaSelector} = props\n\n  const removeValue = useCallback(() => {\n    onChange(PatchEvent.from([unset()]))\n  }, [onChange])\n\n  return (\n    <Stack>\n      <SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>\n\n      <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>\n\n      <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>\n    </Stack>\n  )\n}\n\nexport default WidgetInput\n","import {useSecrets} from '@sanity/studio-secrets'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useState} from 'react'\nimport {type ObjectInputProps, PatchEvent, set} from 'sanity'\n\nimport type {CloudinaryAsset, InsertHandlerParams} from '../types'\nimport {normalizeCloudinaryAsset, openMediaSelector} from '../utils'\nimport SecretsConfigView, {namespace, type Secrets} from './SecretsConfigView'\nimport WidgetInput from './WidgetInput'\n\nconst CloudinaryInput = (props: ObjectInputProps) => {\n  const [showSettings, setShowSettings] = useState(false)\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const {onChange, schemaType: type} = props\n  const value = (props.value as CloudinaryAsset) || undefined\n  const valueKey = value?._key\n\n  const handleSelect = useCallback(\n    (payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    },\n    [onChange, type, valueKey],\n  )\n\n  const action = secrets\n    ? () =>\n        openMediaSelector(\n          secrets.cloudName,\n          secrets.apiKey,\n          false, // single selection\n          handleSelect,\n          value,\n        )\n    : () => setShowSettings(true)\n\n  return (\n    <>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n      <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />\n    </>\n  )\n}\n\nexport default CloudinaryInput\n","import {defineType} from 'sanity'\n\nimport AssetDiff from '../components/AssetDiff'\nimport AssetPreview from '../components/AssetPreview'\nimport CloudinaryInput from '../components/CloudinaryInput'\n\nexport const cloudinaryAssetSchema = defineType({\n  type: 'object',\n  name: 'cloudinary.asset',\n  fields: [\n    {\n      type: 'string',\n      name: 'id',\n      // Cloudinary asset id (used by cloudinaryAssetDocument lookups)\n    },\n    {\n      type: 'string',\n      name: 'public_id',\n    },\n    {\n      type: 'string',\n      name: 'resource_type',\n      // \"image\", \"?\"\n    },\n    {\n      type: 'string',\n      name: 'type',\n      // \"upload\", \"?\"\n    },\n    {\n      type: 'string',\n      name: 'format',\n      // \"jpg\"\n    },\n    {\n      type: 'number',\n      name: 'version',\n    },\n    {\n      type: 'url',\n      name: 'url',\n    },\n    {\n      type: 'url',\n      name: 'secure_url',\n    },\n    {\n      type: 'number',\n      name: 'width',\n    },\n    {\n      type: 'number',\n      name: 'height',\n    },\n    {\n      type: 'number',\n      name: 'bytes',\n    },\n    {\n      type: 'number',\n      name: 'duration',\n      // can be null\n    },\n    {\n      type: 'array',\n      name: 'tags',\n      of: [{type: 'string'}],\n    },\n    {\n      type: 'datetime',\n      name: 'created_at',\n    },\n    {\n      type: 'array',\n      name: 'derived',\n      of: [{type: 'cloudinary.assetDerived', name: 'derived'}],\n    },\n    {\n      type: 'string',\n      name: 'access_mode',\n    },\n    {\n      type: 'cloudinary.assetContext',\n      name: 'context',\n    },\n    // metadata array of unknown content\n  ],\n  // The custom preview component receives legacy props that don't match the\n  // PreviewProps type, so the components block is widened to keep type checking happy.\n  ...({\n    components: {\n      input: CloudinaryInput,\n      diff: AssetDiff,\n      preview: AssetPreview,\n    },\n  } as {}),\n  preview: {\n    select: {\n      url: 'url',\n      resource_type: 'resource_type',\n      derived: 'derived.0.url',\n    },\n    prepare({url, derived, resource_type}) {\n      return {\n        title: url,\n        value: {\n          title: url,\n          resource_type,\n          url: derived || url,\n        },\n      }\n    },\n  },\n})\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Box, Button, Flex} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {\n  type ArrayInputFunctionsProps,\n  ArrayOfObjectsFunctions,\n  type ArraySchemaType,\n  insert,\n  type ObjectSchemaType,\n  PatchEvent,\n  setIfMissing,\n} from 'sanity'\n\nimport {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'\nimport type {InsertHandlerParams} from '../types'\nimport {openMediaSelector} from '../utils'\nimport SecretsConfigView, {namespace} from './SecretsConfigView'\n\ninterface ApiConfig {\n  cloudName: string\n  apiKey: string\n}\n\nexport const AssetListFunctions = (\n  props: ArrayInputFunctionsProps<{_key: string}, ArraySchemaType>,\n) => {\n  const {onValueCreate, onChange} = props\n\n  const {secrets, loading} = useSecrets<ApiConfig>(namespace)\n  const [showSettings, setShowSettings] = useState(false)\n\n  const show = useCallback(() => setShowSettings(true), [setShowSettings])\n  const hide = useCallback(() => setShowSettings(false), [setShowSettings])\n\n  const cloudinaryType = props.schemaType.of.find(\n    (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n  ) as ObjectSchemaType | undefined\n\n  if (!cloudinaryType) {\n    throw new Error(`AssetListFunctions can only be used in array.of ${\n      cloudinaryAssetSchema.name\n    }, but it was array.of\n    ${props.schemaType.of.map((t) => t.name).join(', ')}`)\n  }\n\n  const handleSelect = useCallback(\n    (selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    },\n    [onValueCreate, onChange, cloudinaryType],\n  )\n\n  const handleOpenSelector = useCallback(\n    () =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      ),\n    [secrets, handleSelect],\n  )\n  return (\n    <Flex gap={2} flex={1}>\n      {showSettings && <SecretsConfigView onClose={hide} />}\n      <Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>\n      {cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )}\n    </Flex>\n  )\n}\n","import {defineType} from 'sanity'\n\nexport interface CloudinaryAssetContext {\n  custom: object\n}\n\nexport const cloudinaryAssetContext = defineType({\n  type: 'object',\n  name: 'cloudinary.assetContext',\n  fields: [\n    {\n      type: 'cloudinary.assetContextCustom',\n      name: 'custom',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetContextCustom = {\n  alt: string\n  caption: string\n}\n\nexport const cloudinaryAssetContextCustom = defineType({\n  type: 'object',\n  name: 'cloudinary.assetContextCustom',\n  fields: [\n    {\n      type: 'string',\n      name: 'alt',\n    },\n    {\n      type: 'string',\n      name: 'caption',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetDerived = {\n  raw_transformation: string\n  url: string\n  secure_url: string\n}\n\nexport const cloudinaryAssetDerivedSchema = defineType({\n  type: 'object',\n  name: 'cloudinary.assetDerived',\n  fields: [\n    {\n      type: 'string',\n      name: 'raw_transformation',\n    },\n    {\n      type: 'url',\n      name: 'url',\n    },\n    {\n      type: 'url',\n      name: 'secure_url',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nimport {cloudinaryAssetSchema} from './cloudinaryAsset'\n\nexport const cloudinaryAssetDocument = defineType({\n  name: 'cloudinaryAssetDocument',\n  title: 'Cloudinary Asset',\n  type: 'document',\n  // Shared assets are patched in place by the reference input; liveEdit avoids\n  // desk drafts that could later publish over those updates.\n  liveEdit: true,\n  fields: [\n    {\n      name: 'asset',\n      type: cloudinaryAssetSchema.name,\n      title: 'Cloudinary Asset',\n    },\n  ],\n  preview: {\n    select: {\n      caption: 'asset.context.custom.caption',\n      alt: 'asset.context.custom.alt',\n      publicId: 'asset.public_id',\n      resourceType: 'asset.resource_type',\n      format: 'asset.format',\n      // Desk list `media` needs a URL (or React element), not the raw asset object\n      secureUrl: 'asset.secure_url',\n      url: 'asset.url',\n      derivedUrl: 'asset.derived.0.secure_url',\n    },\n    prepare(selection) {\n      const {caption, alt, publicId, resourceType, format, secureUrl, url, derivedUrl} =\n        selection as {\n          caption?: string\n          alt?: string\n          publicId?: string\n          resourceType?: string\n          format?: string\n          secureUrl?: string\n          url?: string\n          derivedUrl?: string\n        }\n\n      // Prefer caption/alt from Cloudinary context; fall back to public_id\n      const title = caption || alt || publicId || 'Untitled Asset'\n\n      const type = resourceType || 'image'\n      const formatInfo = format ? `(${format})` : ''\n      const subtitle = `${type} ${formatInfo}`\n\n      let media = derivedUrl || secureUrl || url\n      // Desk/list media is rendered as an <img>; only pass image (and PDF) URLs\n      if (type !== 'image' || !media) {\n        media = undefined\n      } else if (format === 'pdf') {\n        media = media.replace(\n          'image/upload',\n          'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n        )\n      }\n\n      return {\n        title,\n        subtitle,\n        media,\n      }\n    },\n  },\n})\n","import {useEffect, useState} from 'react'\nimport {useClient} from 'sanity'\n\nimport type {CloudinaryAsset} from '../types'\nimport AssetPreview from './AssetPreview'\n\nconst API_VERSION = '2023-01-01'\n\ninterface ReferencePreviewProps {\n  value?: {_ref?: string}\n  /** Bump to force a refetch when the referenced document is updated in place */\n  revision?: number\n}\n\nconst ReferencePreview = (props: ReferencePreviewProps) => {\n  const {value, revision = 0} = props\n  const client = useClient({apiVersion: API_VERSION})\n  const ref = value?._ref\n  const [result, setResult] = useState<{\n    ref: string\n    revision: number\n    asset: CloudinaryAsset | null\n  } | null>(null)\n\n  useEffect(() => {\n    if (!ref) {\n      return undefined\n    }\n\n    let cancelled = false\n    client\n      .getDocument<{asset?: CloudinaryAsset}>(ref)\n      .then((document) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: document?.asset ?? null})\n        }\n        return null\n      })\n      .catch((err) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: null})\n        }\n        console.error('Error fetching referenced asset:', err)\n      })\n\n    return () => {\n      cancelled = true\n    }\n  }, [ref, client, revision])\n\n  if (!ref) {\n    return null\n  }\n\n  // Derive loading/asset from the fetched result for the current ref+revision\n  if (result?.ref !== ref || result.revision !== revision) {\n    return <div>Loading asset...</div>\n  }\n\n  if (!result.asset) {\n    return null\n  }\n\n  return <AssetPreview value={result.asset} layout=\"block\" />\n}\n\nexport default ReferencePreview\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Button, Flex, Grid, Stack} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {type ObjectInputProps, getPublishedId, PatchEvent, set, unset, useClient} from 'sanity'\n\nimport {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'\nimport type {InsertHandlerParams} from '../types'\nimport {normalizeCloudinaryAsset, openMediaSelector} from '../utils'\nimport ReferencePreview from './ReferencePreview'\nimport SecretsConfigView, {namespace, type Secrets} from './SecretsConfigView'\n\nconst API_VERSION = '2023-01-01'\n\n// Fallback so the button doesn't stay disabled if the media library never reports it opened\nconst SELECTOR_FALLBACK_TIMEOUT = 30_000\n\ntype FolderOption = {path?: string; resource_type?: 'image' | 'video'}\n\ntype ReferenceValue = {\n  _key?: string\n  _type?: string\n  asset?: {_type?: 'reference'; _ref?: string; _weak?: boolean}\n}\n\nconst CloudinaryReferenceInput = (props: ObjectInputProps) => {\n  const {onChange, value, schemaType, readOnly} = props\n  const [showSettings, setShowSettings] = useState(false)\n  const [isLoading, setIsLoading] = useState(false)\n  const [previewRevision, setPreviewRevision] = useState(0)\n  const fallbackTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n  const saveInProgressRef = useRef(false)\n  const {secrets, loading: secretsLoading} = useSecrets<Secrets>(namespace)\n  const client = useClient({apiVersion: API_VERSION})\n  // Lookups should see published docs only so we never store drafts.* in _ref\n  const publishedClient = useMemo(() => client.withConfig({perspective: 'published'}), [client])\n\n  const cloudName = secrets?.cloudName\n  const apiKey = secrets?.apiKey\n  const hasConfig = Boolean(apiKey && cloudName)\n  const currentValue = value as ReferenceValue | undefined\n  const valueKey = currentValue?._key\n  const schemaTypeName = schemaType.name\n  const actionsDisabled = Boolean(readOnly) || isLoading || secretsLoading\n\n  const folder = (schemaType.options as {folder?: FolderOption} | undefined)?.folder\n  const folderOption = useMemo(\n    () =>\n      folder?.path || folder?.resource_type\n        ? {path: folder.path, resource_type: folder.resource_type}\n        : undefined,\n    [folder],\n  )\n\n  const setAssetReference = useCallback(\n    (documentId: string) => {\n      onChange(\n        PatchEvent.from(\n          set({\n            _type: schemaTypeName,\n            // Preserve array item identity when this field is used inside an array\n            ...(valueKey ? {_key: valueKey} : {}),\n            asset: {\n              _type: 'reference',\n              _ref: getPublishedId(documentId),\n              _weak: true,\n            },\n          }),\n        ),\n      )\n    },\n    [onChange, schemaTypeName, valueKey],\n  )\n\n  const handleSelect = useCallback(\n    async (payload: InsertHandlerParams) => {\n      if (readOnly) {\n        return\n      }\n\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      const normalizedAsset: Record<string, unknown> = {\n        _type: cloudinaryAssetSchema.name,\n        _key: nanoid(),\n        _version: 1,\n        ...normalizeCloudinaryAsset(asset),\n      }\n\n      setIsLoading(true)\n      saveInProgressRef.current = true\n      try {\n        type ExistingAssetDoc = {_id: string; asset?: {id?: string}}\n\n        // Prefer Cloudinary asset `id` when present; if that misses (or id is\n        // absent), fall back to public_id + resource_type + type so we still\n        // reuse an existing shared document.\n        let existingAsset: ExistingAssetDoc | null = null\n\n        if (asset.id) {\n          existingAsset = await publishedClient.fetch<ExistingAssetDoc | null>(\n            `*[_type == \"cloudinaryAssetDocument\" && asset.id == $id][0]{_id, asset}`,\n            {id: asset.id},\n          )\n        }\n\n        if (!existingAsset && asset.public_id) {\n          existingAsset = await publishedClient.fetch<ExistingAssetDoc | null>(\n            `*[_type == \"cloudinaryAssetDocument\" && asset.public_id == $publicId && asset.resource_type == $resourceType && asset.type == $type][0]{_id, asset}`,\n            {\n              publicId: asset.public_id,\n              resourceType: asset.resource_type,\n              type: asset.type,\n            },\n          )\n        }\n\n        if (existingAsset) {\n          const publishedId = getPublishedId(existingAsset._id)\n          // Preserve a previously stored Cloudinary id if this selection omits it\n          const assetToStore =\n            normalizedAsset['id'] || !existingAsset.asset?.id\n              ? normalizedAsset\n              : {...normalizedAsset, id: existingAsset.asset.id}\n\n          await client.patch(publishedId).set({asset: assetToStore}).commit()\n          setAssetReference(publishedId)\n        } else {\n          // Create a new asset document and reference it (let Sanity assign a valid _id)\n          const newAsset = await client.create({\n            _type: 'cloudinaryAssetDocument',\n            asset: normalizedAsset,\n          })\n          setAssetReference(newAsset._id)\n        }\n\n        // Force preview refresh when the same document is updated in place\n        setPreviewRevision((revision) => revision + 1)\n      } catch (err) {\n        console.error('Error creating/updating Cloudinary asset:', err)\n        // oxlint-disable-next-line react/todo\n      } finally {\n        saveInProgressRef.current = false\n        setIsLoading(false)\n      }\n    },\n    [readOnly, client, publishedClient, setAssetReference],\n  )\n\n  const handleOpenSelector = useCallback(() => {\n    if (readOnly || secretsLoading) {\n      return\n    }\n\n    if (!cloudName || !apiKey) {\n      setShowSettings(true)\n      return\n    }\n\n    setIsLoading(true)\n\n    if (fallbackTimerRef.current) {\n      clearTimeout(fallbackTimerRef.current)\n    }\n\n    try {\n      openMediaSelector(\n        cloudName,\n        apiKey,\n        false, // single selection\n        (payload) => {\n          if (fallbackTimerRef.current) {\n            clearTimeout(fallbackTimerRef.current)\n            fallbackTimerRef.current = undefined\n          }\n          // handleSelect manages isLoading for the create/patch work\n          void handleSelect(payload)\n        },\n        undefined,\n        () => {\n          // Don't clear loading while create/patch is in flight — closing the\n          // library after insert can fire showHandler mid-save.\n          if (saveInProgressRef.current) {\n            return\n          }\n          setIsLoading(false)\n        },\n        folderOption,\n      )\n\n      fallbackTimerRef.current = setTimeout(() => {\n        if (!saveInProgressRef.current) {\n          setIsLoading(false)\n        }\n      }, SELECTOR_FALLBACK_TIMEOUT)\n    } catch (error) {\n      console.error('Error opening Cloudinary media selector:', error)\n      setIsLoading(false)\n    }\n  }, [readOnly, secretsLoading, cloudName, apiKey, handleSelect, folderOption])\n\n  const reference = currentValue?.asset\n\n  let selectButtonText = 'Configure Cloudinary to Select Assets'\n  if (secretsLoading) {\n    selectButtonText = 'Loading Cloudinary config...'\n  } else if (hasConfig) {\n    selectButtonText = isLoading ? 'Opening Media Library...' : 'Select Asset'\n  }\n\n  return (\n    <Stack gap={3}>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n\n      <Flex justify=\"flex-end\">\n        <Button\n          color=\"primary\"\n          icon={PlugIcon}\n          mode=\"bleed\"\n          title=\"Configure\"\n          onClick={() => setShowSettings(true)}\n          text={hasConfig || secretsLoading ? undefined : 'Configure Cloudinary plugin'}\n          disabled={Boolean(readOnly) || secretsLoading}\n        />\n      </Flex>\n\n      <Flex marginBottom={2} style={{textAlign: 'center', width: '100%'}}>\n        <ReferencePreview value={reference} revision={previewRevision} />\n      </Flex>\n\n      <Stack gap={2}>\n        <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n          <Button\n            text={selectButtonText}\n            onClick={handleOpenSelector}\n            tone=\"primary\"\n            mode=\"ghost\"\n            disabled={actionsDisabled}\n            loading={isLoading || secretsLoading}\n          />\n\n          {reference?._ref ? (\n            <Button\n              text=\"Remove\"\n              tone=\"critical\"\n              mode=\"ghost\"\n              onClick={() => onChange(PatchEvent.from(unset()))}\n              disabled={actionsDisabled}\n            />\n          ) : null}\n        </Grid>\n      </Stack>\n    </Stack>\n  )\n}\n\nexport default CloudinaryReferenceInput\n","import {defineType} from 'sanity'\n\nimport CloudinaryReferenceInput from '../components/CloudinaryReferenceInput'\n\nexport const cloudinaryAssetReference = defineType({\n  name: 'cloudinaryAssetReference',\n  title: 'Cloudinary Asset Reference',\n  type: 'object',\n  fields: [\n    {\n      name: 'asset',\n      type: 'reference',\n      to: [{type: 'cloudinaryAssetDocument'}],\n      weak: true,\n    },\n  ],\n  components: {\n    input: CloudinaryReferenceInput,\n  },\n  preview: {\n    select: {\n      caption: 'asset.asset.context.custom.caption',\n      alt: 'asset.asset.context.custom.alt',\n      publicId: 'asset.asset.public_id',\n      resourceType: 'asset.asset.resource_type',\n      format: 'asset.asset.format',\n      secureUrl: 'asset.asset.secure_url',\n      url: 'asset.asset.url',\n      derivedUrl: 'asset.asset.derived.0.secure_url',\n    },\n    prepare(selection) {\n      const {caption, alt, publicId, resourceType, format, secureUrl, url, derivedUrl} =\n        selection as {\n          caption?: string\n          alt?: string\n          publicId?: string\n          resourceType?: string\n          format?: string\n          secureUrl?: string\n          url?: string\n          derivedUrl?: string\n        }\n\n      const title = caption || alt || publicId || 'Untitled Asset'\n      const type = resourceType || 'image'\n      const formatInfo = format ? `(${format})` : ''\n      const subtitle = `${type} ${formatInfo}`\n\n      let media = derivedUrl || secureUrl || url\n      // Desk/list media is rendered as an <img>; only pass image (and PDF) URLs\n      if (type !== 'image' || !media) {\n        media = undefined\n      } else if (format === 'pdf') {\n        media = media.replace(\n          'image/upload',\n          'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n        )\n      }\n\n      return {\n        title,\n        subtitle,\n        media,\n      }\n    },\n  },\n})\n","import '@sanity/ui/styles.css'\nimport {type AssetSource, definePlugin, isArrayOfObjectsInputProps} from 'sanity'\n\nimport {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'\nimport {CloudinaryIcon} from './components/asset-source/Icon'\nimport {AssetListFunctions} from './components/AssetListFunctions'\nimport {cloudinaryAssetSchema} from './schema/cloudinaryAsset'\nimport {cloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nimport {cloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\nimport {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'\nimport {cloudinaryAssetDocument} from './schema/cloudinaryAssetDocument'\nimport {cloudinaryAssetReference} from './schema/cloudinaryAssetReference'\n\nexport {type CloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nexport {type CloudinaryAssetDerived} from './schema/cloudinaryAssetDerived'\nexport {type CloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\n\nexport type {AssetDocument, CloudinaryAsset} from './types'\n\nexport {\n  cloudinaryAssetSchema,\n  cloudinaryAssetDerivedSchema,\n  cloudinaryAssetContext,\n  cloudinaryAssetContextCustom,\n  cloudinaryAssetDocument,\n  cloudinaryAssetReference,\n}\n\nexport const cloudinaryReferencePlugin = definePlugin({\n  name: 'cloudinary-reference',\n  schema: {\n    types: [\n      cloudinaryAssetDocument,\n      cloudinaryAssetReference,\n      cloudinaryAssetSchema,\n      cloudinaryAssetDerivedSchema,\n      cloudinaryAssetContext,\n      cloudinaryAssetContextCustom,\n    ],\n  },\n})\n\nexport const cloudinarySchemaPlugin = definePlugin({\n  name: 'cloudinary-schema',\n  form: {\n    components: {\n      input: (props) => {\n        if (isArrayOfObjectsInputProps(props)) {\n          const cloudinaryType = props.schemaType.of.find(\n            (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n          )\n          if (cloudinaryType) {\n            return props.renderDefault({...props, arrayFunctions: AssetListFunctions})\n          }\n        }\n        return props.renderDefault(props)\n      },\n    },\n  },\n  schema: {\n    types: [\n      cloudinaryAssetSchema,\n      cloudinaryAssetDerivedSchema,\n      cloudinaryAssetContext,\n      cloudinaryAssetContextCustom,\n    ],\n  },\n})\n\nexport const cloudinaryImageSource: AssetSource = {\n  name: 'cloudinary-image',\n  // oxlint-disable-next-line no-deprecated -- `i18nKey` requires a locale bundle; a plain title is intentional here\n  title: 'Cloudinary',\n  icon: CloudinaryIcon,\n  component: CloudinaryAssetSource,\n}\n\nexport const cloudinaryAssetSourcePlugin = definePlugin({\n  name: 'cloudinary-asset-source',\n  form: {\n    image: {\n      assetSources: [cloudinaryImageSource],\n    },\n  },\n})\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,YAAY;AAElB,SAAgB,SACd,OAMA,WACoB;CACpB,IAAM,CAAC,WAAW,MAAM,WAAW,CAAC;CAiCpC,OArBE,aACA,MAAM,aACN,CAAC,WACD,MAAM,kBAAkB,WACxB,MAAM,kBAAkB,UACvB,CAAC,MAAM,QAAQ,MAAM,SAAS,YAExB,IAAI,gBAAgB,MAAM,WAAW,IAAI,YAAY,EAAC,UAAS,CAAC,CAAC,CAAC,CACtE,OAAO,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAC1B,MAAM,IAGP,UACE,QAAQ,aACH,QAAQ,aAEV,QAAQ,MAEb,MAAM,aACD,MAAM,aAER,MAAM;AACf;;;;;AAMA,SAAgB,yBAAyB,OAAyD;CAChG,IAAM,oBAAoB,OAAO,YAC/B,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,GAAG,gBAAgB,eAAe,IAAI,CACtE,GAEM,iBAAiB;EACrB,WAAW,MAAM;EACjB,eAAe,MAAM;EACrB,MAAM,MAAM;EACZ,KAAK,MA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aAAa;CACpD,MAAM;CACN,QAAQ,EACN,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF,EACF;AACF,CAAC,GAEY,yBAAyB,aAAa;CACjD,MAAM;CACN,MAAM,EACJ,YAAY,EACV,QAAQ,UACF,2BAA2B,KAAK,KACX,MAAM,WAAW,GAAG,MACxC,MAAsB,EAAE,SAAS,sBAAsB,IAEtD,IACK,MAAM,cAAc;EAAC,GAAG;EAAO,gBAAgB;CAAkB,CAAC,IAGtE,MAAM,cAAc,KAAK,EAEpC,EACF;CACA,QAAQ,EACN,OAAO;EACL;EACA;EACA;EACA;CACF,EACF;AACF,CAAC,GAEY,wBAAqC;CAChD,MAAM;CAEN,OAAO;CACP,MAAM;CACN,WAAW;AACb,GAEa,8BAA8B,aAAa;CACtD,MAAM;CACN,MAAM,EACJ,OAAO,EACL,cAAc,CAAC,qBAAqB,EACtC,EACF;AACF,CAAC"}
\ No newline at end of file
+{"version":3,"file":"index.js","names":["<SettingsView\n      title=\"Cloudinary config\"\n      namespace={namespace}\n      keys={pluginConfigKeys}\n      onClose={props.onClose}\n    />","onClose","_c","() => `cloudinaryWidget-${Date.now()}`","() => {\n    // because we have to access props after loading js in a callback,\n    // we cannot pass props as dependencies as that will cause infinite updates\n    // this takes a snapshot of props, so we can access them later\n    propsRef.current = props\n  }","[props]","() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }","useCallback(() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }, [onClose, library])","() => {\n    if (!cloudName || !apiKey) {\n      return\n    }\n\n    createMediaLibrary({\n      cloudName,\n      apiKey,\n      inlineContainer: `#${widgetId}`,\n      libraryCreated: (lib: CloudinaryMediaLibrary) => {\n        library.current = lib\n        const selectedAssets = propsRef.current.selectedAssets\n        const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null\n\n        const iframe: ChildNode | null | undefined =\n          contentRef.current && contentRef.current.firstChild\n        if (iframe && iframe instanceof HTMLIFrameElement) {\n          setLoadingMessage(undefined)\n          let asset\n          if (\n            propsRef.current.selectionType === 'single' &&\n            firstSelectedAsset &&\n            firstSelectedAsset.source &&\n            firstSelectedAsset.source.id\n          ) {\n            asset = decodeSourceId(firstSelectedAsset.source.id)\n          }\n          const folder = asset\n            ? {\n                path: asset.public_id.split('/').slice(0, -1).join('/'),\n                resource_type: 'image',\n              }\n            : {path: '', resource_type: 'image'}\n          if (lib && contentRef.current) {\n            lib.show({folder, asset})\n            contentRef.current.style.visibility = 'visible'\n          }\n        }\n      },\n      insertHandler: ({assets}: InsertHandlerParams) => {\n        if (!library.current) {\n          return\n        }\n        const imageAssets = assets.filter((asset) => asset.resource_type === 'image')\n        if (imageAssets.length === 0) {\n          throw new Error('The selection did not contain any images.')\n        }\n        library.current.hide()\n        propsRef.current.onSelect(\n          imageAssets.map((asset) => {\n            const url =\n              asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url\n            return {\n              kind: 'url',\n              value: url,\n              assetDocumentProps: {\n                _type: 'sanity.imageAsset',\n                originalFilename: encodeFilename(asset),\n                source: {\n                  id: encodeSourceId(asset),\n                  name: `cloudinary:${cloudName}`,\n                },\n              } as ImageAsset,\n            }\n          }),\n        )\n      },\n    })\n  }","[cloudName, apiKey, widgetId]","{assets}: InsertHandlerParams","(asset) => asset.resource_type === 'image'","asset","showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />","() => setShowSettings(true)","<Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>","hasConfig ? undefined : 'Configure Cloudinary plugin'","hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )","{visibility: 'hidden'}","<Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />","<Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>","<Dialog\n      id=\"cloudinary-asset-source\"\n      header={dialogHeaderTitle ?? 'Select image from Cloudinary'}\n      onClose={handleClose}\n      open\n      width={4}\n    >\n      <Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>\n    </Dialog>","dialogHeaderTitle ?? 'Select image from Cloudinary'","_c","_temp","_temp2","<svg\n      version=\"1.1\"\n      id=\"Layer_1\"\n      x=\"0px\"\n      y=\"0px\"\n      width=\"1em\"\n      height=\"1em\"\n      viewBox=\"0 0 141.732 141.747\"\n      enableBackground=\"new 0 0 141.732 141.747\"\n    >\n      <g>\n        <path\n          fill=\"#0071CE\"\n          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\n        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\n        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\n        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\n        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\n        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\n        c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z\"\n        />\n        <path\n          fill=\"#DC8327\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\"\n        />\n        <path\n          fill=\"#F4B21B\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C84.267,111.345,84.112,111.121,83.889,111.02z\"\n        />\n        <path\n          fill=\"#F2D864\"\n          d=\"M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C111.045,111.345,110.889,111.121,110.667,111.02z\"\n        />\n      </g>\n    </svg>","_c","{\n    width: '100%',\n    height: 'auto',\n  }","<video controls aria-label=\"Cloudinary video preview\" style={style}>\n      <source src={src} type=\"video/mp4\" />\n    </video>","_c","{value}: Props","assetUrl(value, cloudName)","{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }","<section\n        style={{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }}\n      >\n        <VideoPlayer src={url} kind=\"diff\" />\n      </section>","{maxWidth: '100%', height: 'auto'}","<img alt=\"preview\" src={url} style={{maxWidth: '100%', height: 'auto'}} />","{diff, schemaType}: DiffProps","<DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />","_c","{value, layout}: ComponentProps","{\n            maxWidth: layout === 'default' ? '80px' : '100%',\n          }","layout === 'default' ? '80px' : '100%'","<DocumentIcon />","{marginLeft: '0.5em'}","<Flex align=\"center\">\n          <DocumentIcon />\n          <Text size={1} style={{marginLeft: '0.5em'}}>\n            {value.display_name ?? 'Raw file'}\n          </Text>\n        </Flex>","value.display_name ?? 'Raw file'","layout === 'default' ? (\n        <Flex align=\"center\" justify=\"center\" style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{maxWidth: '80px', height: 'auto', display: 'block'}}\n          />\n        </Flex>\n      ) : (\n        <div style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{width: '100%', height: 'auto', display: 'block'}}\n          />\n        </div>\n      )","_c","() => {\n    onChange(PatchEvent.from([unset()]))\n  }","useCallback(() => {\n    onChange(PatchEvent.from([unset()]))\n  }, [onChange])","<SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>","onSetup","{textAlign: 'center', width: '100%'}","<Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>","value as CloudinaryAsset","{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}","<Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />","<Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />","readOnly || !value","<Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>","<Stack>\n      <SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>\n\n      <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>\n\n      <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>\n    </Stack>","_c","(payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    }","type.name","useCallback(\n    (payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    },\n    [onChange, type, valueKey],\n  )","secrets\n    ? () =>\n        openMediaSelector(\n          secrets.cloudName,\n          secrets.apiKey,\n          false, // single selection\n          handleSelect,\n          value,\n        )\n    : () => setShowSettings(true)","showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />","() => setShowSettings(true)","<WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />","<>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n      <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />\n    </>","_c","_Fragment","() => setShowSettings(true)","useCallback(() => setShowSettings(true), [setShowSettings])","() => setShowSettings(false)","useCallback(() => setShowSettings(false), [setShowSettings])","props.schemaType.of.find(\n    (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n  )","of","(t: {name: string}) => t.name === cloudinaryAssetSchema.name","(t) => t.name","(selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    }","useCallback(\n    (selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    },\n    [onValueCreate, onChange, cloudinaryType],\n  )","() =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      )","useCallback(\n    () =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      ),\n    [secrets, handleSelect],\n  )","showSettings && <SecretsConfigView onClose={hide} />","<Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>","cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )","readOnly","<Flex gap={2} flex={1}>\n      {showSettings && <SecretsConfigView onClose={hide} />}\n      <Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>\n      {cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )}\n    </Flex>","t","_c","_Fragment","revision = 0","{apiVersion: API_VERSION}","() => {\n    if (!ref) {\n      return undefined\n    }\n\n    let cancelled = false\n    client\n      .getDocument<{asset?: CloudinaryAsset}>(ref)\n      .then((document) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: document?.asset ?? null})\n        }\n        return null\n      })\n      .catch((err) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: null})\n        }\n        console.error('Error fetching referenced asset:', err)\n      })\n\n    return () => {\n      cancelled = true\n    }\n  }","[ref, client, revision]","<div>Loading asset...</div>","<AssetPreview value={result.asset} layout=\"block\" />","asset","API_VERSION","_c","\"id\"","\"asset\"","\"folder\""],"sources":["../src/utils.ts","../src/components/SecretsConfigView.tsx","../src/components/asset-source/CloudinaryAssetSource.tsx","../src/components/asset-source/Icon.tsx","../src/components/VideoPlayer.tsx","../src/components/AssetDiff.tsx","../src/components/AssetPreview.tsx","../src/components/WidgetInput.tsx","../src/components/CloudinaryInput.tsx","../src/schema/cloudinaryAsset.ts","../src/components/AssetListFunctions.tsx","../src/schema/cloudinaryAssetContext.ts","../src/schema/cloudinaryAssetContextCustom.ts","../src/schema/cloudinaryAssetDerived.ts","../src/schema/cloudinaryAssetDocument.ts","../src/components/ReferencePreview.tsx","../src/components/CloudinaryReferenceInput.tsx","../src/schema/cloudinaryAssetReference.ts","../src/index.ts"],"sourcesContent":["import {CloudConfig, CloudinaryImage} from '@cloudinary/url-gen'\nimport {scale} from '@cloudinary/url-gen/actions/resize'\n\nimport type {\n  CloudinaryAsset,\n  CloudinaryAssetResponse,\n  CloudinaryMediaLibrary,\n  InsertHandlerParams,\n  ShowHandlerParams,\n} from './types'\n\nconst widgetSrc = 'https://media-library.cloudinary.com/global/all.js'\n\nexport function assetUrl(\n  asset: Partial<\n    Pick<\n      CloudinaryAsset,\n      'url' | 'secure_url' | 'derived' | 'public_id' | 'format' | 'resource_type' | 'type'\n    >\n  >,\n  cloudName?: string,\n): string | undefined {\n  const [derived] = asset.derived ?? []\n\n  // When the cloud name and public id are known and there is no Media Library\n  // derived transform, build an on-the-fly preview with url-gen instead of\n  // serving the full-size original. Scaling to a 400px width keeps previews\n  // crisp while avoiding multi-megabyte source downloads.\n  // Only public `upload` images use CloudinaryImage — video/raw would get an\n  // /image/upload URL that breaks VideoPlayer/raw previews, and private or\n  // authenticated assets need their stored (often signed) URL rather than an\n  // unsigned /upload/ path. Derived transforms are preferred over the scaled\n  // original so Studio still shows the editor's chosen crop/effects.\n  if (\n    cloudName &&\n    asset.public_id &&\n    !derived &&\n    asset.resource_type !== 'video' &&\n    asset.resource_type !== 'raw' &&\n    (!asset.type || asset.type === 'upload')\n  ) {\n    return new CloudinaryImage(asset.public_id, new CloudConfig({cloudName}))\n      .resize(scale().width(400))\n      .toURL()\n  }\n\n  if (derived) {\n    if (derived.secure_url) {\n      return derived.secure_url\n    }\n    return derived.url\n  }\n  if (asset.secure_url) {\n    return asset.secure_url\n  }\n  return asset.url\n}\n\n/**\n * Normalize a Media Library payload into a shape that matches the `cloudinary.asset`\n * schema: drop nulls, sanitize context keys, and tag derived items with `_type`.\n */\nexport function normalizeCloudinaryAsset(asset: CloudinaryAssetResponse): Record<string, unknown> {\n  const assetWithoutNulls = Object.fromEntries(\n    Object.entries(asset).filter(([, assetValue]) => assetValue !== null),\n  ) as CloudinaryAssetResponse\n\n  const requiredFields = {\n    public_id: asset.public_id,\n    resource_type: asset.resource_type,\n    type: asset.type,\n    url: asset.url,\n    secure_url: asset.secure_url,\n    format: asset.format,\n    width: asset.width,\n    height: asset.height,\n    bytes: asset.bytes,\n    tags: asset.tags,\n  }\n\n  let updatedAsset: Record<string, unknown> = {\n    ...assetWithoutNulls,\n    ...requiredFields,\n  }\n\n  // Only persist Cloudinary's asset id when the Media Library actually provides one.\n  // Do not delete a missing id here — callers that replace a whole asset object should\n  // preserve any previously stored id themselves (see CloudinaryReferenceInput).\n  if (asset.id) {\n    updatedAsset['id'] = asset.id\n  }\n\n  // Sanity object keys cannot contain special characters, so rename Cloudinary context keys\n  if (asset.context) {\n    const objectWithRenamedKeys = Object.fromEntries(\n      Object.entries(asset.context.custom).map(([contextKey, contextValue]) => {\n        return [contextKey.replace(/[^a-zA-Z0-9_]|-/g, '_'), contextValue]\n      }),\n    )\n\n    updatedAsset = {\n      ...updatedAsset,\n      context: {\n        ...asset.context,\n        custom: objectWithRenamedKeys,\n      },\n    }\n  }\n\n  if (asset.derived) {\n    updatedAsset = {\n      ...updatedAsset,\n      derived: asset.derived.map((derivedItem) => ({\n        _type: 'derived',\n        url: derivedItem.url,\n        secure_url: derivedItem.secure_url,\n        raw_transformation: derivedItem.raw_transformation,\n      })),\n    }\n  }\n\n  return updatedAsset\n}\n\nexport const openMediaSelector = (\n  cloudName: string,\n  apiKey: string,\n  multiple: boolean,\n  insertHandler: (params: InsertHandlerParams) => void,\n  selectedAsset?: CloudinaryAsset,\n  showHandler?: (params: ShowHandlerParams) => void,\n  folder?: {resource_type?: 'image' | 'video'; path?: string},\n) => {\n  loadJS(widgetSrc, (cloudinary) => {\n    const options: Record<string, any> = {\n      cloud_name: cloudName,\n      api_key: apiKey,\n      insert_caption: 'Select',\n      multiple,\n    }\n\n    if (selectedAsset) {\n      options['asset'] = {\n        public_id: selectedAsset.public_id,\n        type: selectedAsset.type,\n        resource_type: selectedAsset.resource_type,\n      }\n    }\n\n    if (folder?.path || folder?.resource_type) {\n      options['folder'] = {\n        ...(folder.path ? {path: folder.path} : {}),\n        ...(folder.resource_type ? {resource_type: folder.resource_type} : {}),\n      }\n    }\n\n    const callbacks: {\n      insertHandler: (params: InsertHandlerParams) => void\n      showHandler?: (params: ShowHandlerParams) => void\n    } = {insertHandler}\n\n    if (showHandler) {\n      callbacks.showHandler = showHandler\n    }\n\n    cloudinary.openMediaLibrary(options, callbacks)\n  })\n}\n\nexport const createMediaLibrary = ({\n  cloudName,\n  apiKey,\n  inlineContainer,\n  libraryCreated,\n  insertHandler,\n}: {\n  cloudName: string\n  apiKey: string\n  inlineContainer: string\n  libraryCreated: (library: CloudinaryMediaLibrary) => void\n  insertHandler: (params: InsertHandlerParams) => void\n}) => {\n  loadJS(widgetSrc, (cloudinary) => {\n    const options: Record<string, any> = {\n      cloud_name: cloudName,\n      api_key: apiKey,\n      insert_caption: 'Select',\n      inline_container: inlineContainer,\n      remove_header: true,\n    }\n\n    libraryCreated(cloudinary.createMediaLibrary(options, {insertHandler}))\n  })\n}\n\nfunction loadJS(url: string, callback: (cloudinary: NonNullable<Window['cloudinary']>) => void) {\n  // The widget exposes `window.cloudinary` only once the script has finished\n  // loading. When it's already available, run the callback right away.\n  if (window.cloudinary) {\n    callback(window.cloudinary)\n    return\n  }\n\n  // Guard against double-invocation if load fires in the same tick as the\n  // post-listener readiness re-check below.\n  let settled = false\n  const handleLoad = () => {\n    if (settled || !window.cloudinary) {\n      return\n    }\n    settled = true\n    callback(window.cloudinary)\n  }\n\n  const existingScript = document.getElementById('damWidget')\n  if (existingScript) {\n    // Another input already injected the script, but it hasn't finished\n    // loading yet (the global isn't ready). Wait for the load event instead\n    // of invoking the callback too early.\n    existingScript.addEventListener('load', handleLoad, {once: true})\n    // Re-check immediately: the load event may have fired between the initial\n    // `window.cloudinary` check and registering this listener, in which case\n    // the event will never fire again and the callback would otherwise hang.\n    handleLoad()\n    return\n  }\n\n  const script = document.createElement('script')\n  script.src = url\n  script.id = 'damWidget'\n  script.addEventListener('load', handleLoad, {once: true})\n  document.body.appendChild(script)\n}\n\nexport function encodeSourceId(asset: CloudinaryAssetResponse): string {\n  const {resource_type, public_id, type} = asset\n  return btoa(JSON.stringify({public_id, resource_type, type})) // Sort keys alphabetically!\n}\n\nexport function encodeFilename(asset: CloudinaryAssetResponse) {\n  return `${asset.public_id.split('/').slice(-1)[0]}.${asset.format}`\n}\n\nexport function decodeSourceId(sourceId: string): CloudinaryAssetResponse | undefined {\n  let sourceIdDecoded: any\n  try {\n    sourceIdDecoded = JSON.parse(atob(sourceId))\n  } catch {\n    // Do nothing\n  }\n  return sourceIdDecoded\n}\n","import {SettingsView} from '@sanity/studio-secrets'\n\nexport type Secrets = {\n  cloudName: string\n  apiKey: string\n}\n\nconst pluginConfigKeys = [\n  {\n    key: 'cloudName',\n    title: 'Cloud name',\n    description: '',\n  },\n  {\n    key: 'apiKey',\n    title: 'API key',\n    description: '',\n  },\n]\n\nexport const namespace = 'cloudinary'\n\ntype Props = {\n  onClose: () => void\n}\n\nconst SecretsConfigView = (props: Props) => {\n  return (\n    <SettingsView\n      title=\"Cloudinary config\"\n      namespace={namespace}\n      keys={pluginConfigKeys}\n      onClose={props.onClose}\n    />\n  )\n}\n\nexport default SecretsConfigView\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Box, Button, Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {useCallback, useEffect, useRef, useState} from 'react'\nimport type {AssetSourceComponentProps, ImageAsset} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {CloudinaryMediaLibrary, InsertHandlerParams} from '../../types'\nimport {createMediaLibrary, decodeSourceId, encodeFilename, encodeSourceId} from '../../utils'\nimport SecretsConfigView, {namespace, type Secrets} from '../SecretsConfigView'\n\nconst Widget = styled.div`\n  height: 70vh;\n`\n\nexport function CloudinaryAssetSource(props: AssetSourceComponentProps) {\n  const {onClose, dialogHeaderTitle} = props\n\n  const [loadingMessage, setLoadingMessage] = useState<string | undefined>(\n    'Loading Cloudinary Media Library',\n  )\n  const library = useRef<CloudinaryMediaLibrary | undefined>(undefined)\n  const contentRef = useRef<HTMLDivElement | null>(null)\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n  const apiKey = secrets?.apiKey\n  const [widgetId] = useState(() => `cloudinaryWidget-${Date.now()}`)\n  const [showSettings, setShowSettings] = useState(false)\n\n  const propsRef = useRef(props)\n\n  useEffect(() => {\n    // because we have to access props after loading js in a callback,\n    // we cannot pass props as dependencies as that will cause infinite updates\n    // this takes a snapshot of props, so we can access them later\n    propsRef.current = props\n  }, [props])\n\n  const handleClose = useCallback(() => {\n    if (library.current) {\n      library.current.hide()\n    }\n    onClose()\n  }, [onClose, library])\n\n  useEffect(() => {\n    if (!cloudName || !apiKey) {\n      return\n    }\n\n    createMediaLibrary({\n      cloudName,\n      apiKey,\n      inlineContainer: `#${widgetId}`,\n      libraryCreated: (lib: CloudinaryMediaLibrary) => {\n        library.current = lib\n        const selectedAssets = propsRef.current.selectedAssets\n        const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null\n\n        const iframe: ChildNode | null | undefined =\n          contentRef.current && contentRef.current.firstChild\n        if (iframe && iframe instanceof HTMLIFrameElement) {\n          setLoadingMessage(undefined)\n          let asset\n          if (\n            propsRef.current.selectionType === 'single' &&\n            firstSelectedAsset &&\n            firstSelectedAsset.source &&\n            firstSelectedAsset.source.id\n          ) {\n            asset = decodeSourceId(firstSelectedAsset.source.id)\n          }\n          const folder = asset\n            ? {\n                path: asset.public_id.split('/').slice(0, -1).join('/'),\n                resource_type: 'image',\n              }\n            : {path: '', resource_type: 'image'}\n          if (lib && contentRef.current) {\n            lib.show({folder, asset})\n            contentRef.current.style.visibility = 'visible'\n          }\n        }\n      },\n      insertHandler: ({assets}: InsertHandlerParams) => {\n        if (!library.current) {\n          return\n        }\n        const imageAssets = assets.filter((asset) => asset.resource_type === 'image')\n        if (imageAssets.length === 0) {\n          throw new Error('The selection did not contain any images.')\n        }\n        library.current.hide()\n        propsRef.current.onSelect(\n          imageAssets.map((asset) => {\n            const url =\n              asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url\n            return {\n              kind: 'url',\n              value: url,\n              assetDocumentProps: {\n                _type: 'sanity.imageAsset',\n                originalFilename: encodeFilename(asset),\n                source: {\n                  id: encodeSourceId(asset),\n                  name: `cloudinary:${cloudName}`,\n                },\n              } as ImageAsset,\n            }\n          }),\n        )\n      },\n    })\n  }, [cloudName, apiKey, widgetId])\n\n  const hasConfig = apiKey && cloudName\n  return (\n    <Dialog\n      id=\"cloudinary-asset-source\"\n      header={dialogHeaderTitle ?? 'Select image from Cloudinary'}\n      onClose={handleClose}\n      open\n      width={4}\n    >\n      <Box padding={4}>\n        {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={() => setShowSettings(true)}\n            tabIndex={0}\n            text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n          />\n        </Flex>\n\n        {hasConfig && loadingMessage && (\n          <Stack gap={3}>\n            <Flex align=\"center\" justify=\"center\">\n              <Spinner muted />\n            </Flex>\n            <Text size={1} muted align=\"center\">\n              {loadingMessage}\n            </Text>\n          </Stack>\n        )}\n\n        <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n      </Box>\n    </Dialog>\n  )\n}\n","export function CloudinaryIcon() {\n  return (\n    <svg\n      version=\"1.1\"\n      id=\"Layer_1\"\n      x=\"0px\"\n      y=\"0px\"\n      width=\"1em\"\n      height=\"1em\"\n      viewBox=\"0 0 141.732 141.747\"\n      enableBackground=\"new 0 0 141.732 141.747\"\n    >\n      <g>\n        <path\n          fill=\"#0071CE\"\n          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\n        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\n        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\n        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\n        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\n        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\n        c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z\"\n        />\n        <path\n          fill=\"#DC8327\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\"\n        />\n        <path\n          fill=\"#F4B21B\"\n          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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C84.267,111.345,84.112,111.121,83.889,111.02z\"\n        />\n        <path\n          fill=\"#F2D864\"\n          d=\"M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        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\n        C111.045,111.345,110.889,111.121,110.667,111.02z\"\n        />\n      </g>\n    </svg>\n  )\n}\n","import type {CSSProperties} from 'react'\n\ntype PlayerKind = 'player' | 'diff'\n\nexport type VideoPlayerProps = {\n  src: string\n  kind: PlayerKind\n}\n\nexport default function VideoPlayer(props: VideoPlayerProps) {\n  const {src} = props\n\n  const style: CSSProperties = {\n    width: '100%',\n    height: 'auto',\n  }\n\n  return (\n    // Cloudinary videos are user-uploaded and have no caption files to point a\n    // `<track>` at; a `src`-less `<track>` would be invalid HTML, so omit it.\n    // eslint-disable-next-line jsx-a11y/media-has-caption -- no captions available for arbitrary Cloudinary videos\n    <video controls aria-label=\"Cloudinary video preview\" style={style}>\n      <source src={src} type=\"video/mp4\" />\n    </video>\n  )\n}\n","import {useSecrets} from '@sanity/studio-secrets'\nimport {DiffFromTo} from 'sanity'\n\nimport type {CloudinaryAsset} from '../types'\nimport {assetUrl} from '../utils'\nimport {namespace, type Secrets} from './SecretsConfigView'\nimport VideoPlayer from './VideoPlayer'\n\ntype Props = {\n  value: CloudinaryAsset | undefined\n}\n\nconst CloudinaryDiffPreview = ({value}: Props) => {\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n\n  if (!value) {\n    return null\n  }\n\n  const url = assetUrl(value, cloudName)\n\n  if (value.resource_type === 'video' && url) {\n    return (\n      <section\n        style={{\n          display: 'flex',\n          flexWrap: 'wrap',\n          justifyContent: 'space-between',\n        }}\n      >\n        <VideoPlayer src={url} kind=\"diff\" />\n      </section>\n    )\n  }\n\n  return <img alt=\"preview\" src={url} style={{maxWidth: '100%', height: 'auto'}} />\n}\n\ntype DiffProps = {\n  diff: any\n  schemaType: any\n}\n\nconst AssetDiff = ({diff, schemaType}: DiffProps) => {\n  return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />\n}\n\nexport default AssetDiff\n","import {DocumentIcon} from '@sanity/icons/Document'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Flex, Text} from '@sanity/ui'\n\nimport type {CloudinaryAsset} from '../types'\nimport {assetUrl} from '../utils'\nimport {namespace, type Secrets} from './SecretsConfigView'\nimport VideoPlayer from './VideoPlayer'\n\ninterface ComponentProps {\n  layout?: 'default' | 'block'\n  value: CloudinaryAsset | undefined\n}\n\nconst AssetPreview = ({value, layout}: ComponentProps) => {\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const cloudName = secrets?.cloudName\n\n  if (!value || !cloudName) {\n    return null\n  }\n\n  const url = assetUrl(value, cloudName)\n  if (!url) {\n    return null\n  }\n\n  switch (value.resource_type) {\n    case 'video':\n      return (\n        <Flex\n          align=\"center\"\n          style={{\n            maxWidth: layout === 'default' ? '80px' : '100%',\n          }}\n        >\n          <VideoPlayer src={url} kind=\"player\" />\n        </Flex>\n      )\n    case 'raw':\n      return (\n        <Flex align=\"center\">\n          <DocumentIcon />\n          <Text size={1} style={{marginLeft: '0.5em'}}>\n            {value.display_name ?? 'Raw file'}\n          </Text>\n        </Flex>\n      )\n    default: {\n      // Cloudinary returns resource_type as \"image\" even for PDFs, so we check\n      // the format to handle PDFs specifically: convert the first page to JPG\n      // and overlay a \"PDF\" label for thumbnail clarity.\n      const previewSrc =\n        value.format === 'pdf'\n          ? url.replace(\n              'image/upload',\n              'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n            )\n          : url\n\n      return layout === 'default' ? (\n        <Flex align=\"center\" justify=\"center\" style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{maxWidth: '80px', height: 'auto', display: 'block'}}\n          />\n        </Flex>\n      ) : (\n        <div style={{width: '100%'}}>\n          <img\n            alt=\"preview\"\n            src={previewSrc}\n            style={{width: '100%', height: 'auto', display: 'block'}}\n          />\n        </div>\n      )\n    }\n  }\n}\n\nexport default AssetPreview\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {Button, Flex, Grid, Stack} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {type ObjectInputProps, PatchEvent, unset} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {CloudinaryAsset} from '../types'\nimport AssetPreview from './AssetPreview'\n\nconst SetupButtonContainer = styled.div`\n  position: relative;\n  display: block;\n  font-size: 0.8em;\n  transform: translate(0%, -10%);\n`\n\ntype WidgetInputProps = ObjectInputProps & {openMediaSelector: () => void; onSetup: () => void}\n\nconst WidgetInput = (props: WidgetInputProps) => {\n  const {onChange, readOnly, value, openMediaSelector} = props\n\n  const removeValue = useCallback(() => {\n    onChange(PatchEvent.from([unset()]))\n  }, [onChange])\n\n  return (\n    <Stack>\n      <SetupButtonContainer>\n        <Flex flex={1} justify=\"flex-end\">\n          <Button\n            color=\"primary\"\n            icon={PlugIcon}\n            mode=\"bleed\"\n            title=\"Configure\"\n            onClick={props.onSetup}\n            tabIndex={0}\n          />\n        </Flex>\n      </SetupButtonContainer>\n\n      <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n        <AssetPreview value={value as CloudinaryAsset} />\n      </Flex>\n\n      <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n        <Button\n          disabled={readOnly}\n          mode=\"ghost\"\n          title=\"Select an asset\"\n          tone=\"default\"\n          onClick={openMediaSelector}\n          text=\"Select…\"\n        />\n        <Button\n          disabled={readOnly || !value}\n          tone=\"critical\"\n          mode=\"ghost\"\n          title=\"Remove asset\"\n          text=\"Remove\"\n          onClick={removeValue}\n        />\n      </Grid>\n    </Stack>\n  )\n}\n\nexport default WidgetInput\n","import {useSecrets} from '@sanity/studio-secrets'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useState} from 'react'\nimport {type ObjectInputProps, PatchEvent, set} from 'sanity'\n\nimport type {CloudinaryAsset, InsertHandlerParams} from '../types'\nimport {normalizeCloudinaryAsset, openMediaSelector} from '../utils'\nimport SecretsConfigView, {namespace, type Secrets} from './SecretsConfigView'\nimport WidgetInput from './WidgetInput'\n\nconst CloudinaryInput = (props: ObjectInputProps) => {\n  const [showSettings, setShowSettings] = useState(false)\n  const {secrets} = useSecrets<Secrets>(namespace)\n  const {onChange, schemaType: type} = props\n  const value = (props.value as CloudinaryAsset) || undefined\n  const valueKey = value?._key\n\n  const handleSelect = useCallback(\n    (payload: InsertHandlerParams) => {\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      onChange(\n        PatchEvent.from([\n          set({\n            _type: type.name,\n            _version: 1,\n            _key: valueKey || nanoid(),\n            ...normalizeCloudinaryAsset(asset),\n          }),\n        ]),\n      )\n    },\n    [onChange, type, valueKey],\n  )\n\n  const action = secrets\n    ? () =>\n        openMediaSelector(\n          secrets.cloudName,\n          secrets.apiKey,\n          false, // single selection\n          handleSelect,\n          value,\n        )\n    : () => setShowSettings(true)\n\n  return (\n    <>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n      <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />\n    </>\n  )\n}\n\nexport default CloudinaryInput\n","import {defineType} from 'sanity'\n\nimport AssetDiff from '../components/AssetDiff'\nimport AssetPreview from '../components/AssetPreview'\nimport CloudinaryInput from '../components/CloudinaryInput'\n\nexport const cloudinaryAssetSchema = defineType({\n  type: 'object',\n  name: 'cloudinary.asset',\n  fields: [\n    {\n      type: 'string',\n      name: 'id',\n      // Cloudinary asset id (used by cloudinaryAssetDocument lookups)\n    },\n    {\n      type: 'string',\n      name: 'public_id',\n    },\n    {\n      type: 'string',\n      name: 'resource_type',\n      // \"image\", \"?\"\n    },\n    {\n      type: 'string',\n      name: 'type',\n      // \"upload\", \"?\"\n    },\n    {\n      type: 'string',\n      name: 'format',\n      // \"jpg\"\n    },\n    {\n      type: 'number',\n      name: 'version',\n    },\n    {\n      type: 'url',\n      name: 'url',\n    },\n    {\n      type: 'url',\n      name: 'secure_url',\n    },\n    {\n      type: 'number',\n      name: 'width',\n    },\n    {\n      type: 'number',\n      name: 'height',\n    },\n    {\n      type: 'number',\n      name: 'bytes',\n    },\n    {\n      type: 'number',\n      name: 'duration',\n      // can be null\n    },\n    {\n      type: 'array',\n      name: 'tags',\n      of: [{type: 'string'}],\n    },\n    {\n      type: 'datetime',\n      name: 'created_at',\n    },\n    {\n      type: 'array',\n      name: 'derived',\n      of: [{type: 'cloudinary.assetDerived', name: 'derived'}],\n    },\n    {\n      type: 'string',\n      name: 'access_mode',\n    },\n    {\n      type: 'cloudinary.assetContext',\n      name: 'context',\n    },\n    // metadata array of unknown content\n  ],\n  // The custom preview component receives legacy props that don't match the\n  // PreviewProps type, so the components block is widened to keep type checking happy.\n  ...({\n    components: {\n      input: CloudinaryInput,\n      diff: AssetDiff,\n      preview: AssetPreview,\n    },\n  } as {}),\n  preview: {\n    select: {\n      url: 'url',\n      resource_type: 'resource_type',\n      derived: 'derived.0.url',\n    },\n    prepare({url, derived, resource_type}) {\n      return {\n        title: url,\n        value: {\n          title: url,\n          resource_type,\n          url: derived || url,\n        },\n      }\n    },\n  },\n})\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Box, Button, Flex} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {\n  type ArrayInputFunctionsProps,\n  ArrayOfObjectsFunctions,\n  type ArraySchemaType,\n  insert,\n  type ObjectSchemaType,\n  PatchEvent,\n  setIfMissing,\n} from 'sanity'\n\nimport {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'\nimport type {InsertHandlerParams} from '../types'\nimport {openMediaSelector} from '../utils'\nimport SecretsConfigView, {namespace} from './SecretsConfigView'\n\ninterface ApiConfig {\n  cloudName: string\n  apiKey: string\n}\n\nexport const AssetListFunctions = (\n  props: ArrayInputFunctionsProps<{_key: string}, ArraySchemaType>,\n) => {\n  const {onValueCreate, onChange} = props\n\n  const {secrets, loading} = useSecrets<ApiConfig>(namespace)\n  const [showSettings, setShowSettings] = useState(false)\n\n  const show = useCallback(() => setShowSettings(true), [setShowSettings])\n  const hide = useCallback(() => setShowSettings(false), [setShowSettings])\n\n  const cloudinaryType = props.schemaType.of.find(\n    (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n  ) as ObjectSchemaType | undefined\n\n  if (!cloudinaryType) {\n    throw new Error(`AssetListFunctions can only be used in array.of ${\n      cloudinaryAssetSchema.name\n    }, but it was array.of\n    ${props.schemaType.of.map((t) => t.name).join(', ')}`)\n  }\n\n  const handleSelect = useCallback(\n    (selected: InsertHandlerParams) => {\n      const items = selected.assets.map((asset) =>\n        Object.assign(\n          {},\n          asset,\n          {\n            // Schema version. In case we ever change our schema.\n            _version: 1,\n          },\n          onValueCreate(cloudinaryType as any), // onValueCreate is mistyped\n        ),\n      )\n      onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n    },\n    [onValueCreate, onChange, cloudinaryType],\n  )\n\n  const handleOpenSelector = useCallback(\n    () =>\n      secrets &&\n      openMediaSelector(\n        secrets.cloudName,\n        secrets.apiKey,\n        true, // multi-selection\n        handleSelect,\n      ),\n    [secrets, handleSelect],\n  )\n  return (\n    <Flex gap={2} flex={1}>\n      {showSettings && <SecretsConfigView onClose={hide} />}\n      <Box flex={1}>\n        <ArrayOfObjectsFunctions {...props} />\n      </Box>\n      {cloudinaryType && (\n        <>\n          <Box flex={1}>\n            <Button\n              style={{width: '100%'}}\n              disabled={props.readOnly || loading}\n              mode=\"bleed\"\n              text=\"Add multiple\"\n              onClick={handleOpenSelector}\n            />\n          </Box>\n          <Box>\n            <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n          </Box>\n        </>\n      )}\n    </Flex>\n  )\n}\n","import {defineType} from 'sanity'\n\nexport interface CloudinaryAssetContext {\n  custom: object\n}\n\nexport const cloudinaryAssetContext = defineType({\n  type: 'object',\n  name: 'cloudinary.assetContext',\n  fields: [\n    {\n      type: 'cloudinary.assetContextCustom',\n      name: 'custom',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetContextCustom = {\n  alt: string\n  caption: string\n}\n\nexport const cloudinaryAssetContextCustom = defineType({\n  type: 'object',\n  name: 'cloudinary.assetContextCustom',\n  fields: [\n    {\n      type: 'string',\n      name: 'alt',\n    },\n    {\n      type: 'string',\n      name: 'caption',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetDerived = {\n  raw_transformation: string\n  url: string\n  secure_url: string\n}\n\nexport const cloudinaryAssetDerivedSchema = defineType({\n  type: 'object',\n  name: 'cloudinary.assetDerived',\n  fields: [\n    {\n      type: 'string',\n      name: 'raw_transformation',\n    },\n    {\n      type: 'url',\n      name: 'url',\n    },\n    {\n      type: 'url',\n      name: 'secure_url',\n    },\n  ],\n})\n","import {defineType} from 'sanity'\n\nimport {cloudinaryAssetSchema} from './cloudinaryAsset'\n\nexport const cloudinaryAssetDocument = defineType({\n  name: 'cloudinaryAssetDocument',\n  title: 'Cloudinary Asset',\n  type: 'document',\n  // Shared assets are patched in place by the reference input; liveEdit avoids\n  // desk drafts that could later publish over those updates.\n  liveEdit: true,\n  fields: [\n    {\n      name: 'asset',\n      type: cloudinaryAssetSchema.name,\n      title: 'Cloudinary Asset',\n    },\n  ],\n  preview: {\n    select: {\n      caption: 'asset.context.custom.caption',\n      alt: 'asset.context.custom.alt',\n      publicId: 'asset.public_id',\n      resourceType: 'asset.resource_type',\n      format: 'asset.format',\n      // Desk list `media` needs a URL (or React element), not the raw asset object\n      secureUrl: 'asset.secure_url',\n      url: 'asset.url',\n      derivedUrl: 'asset.derived.0.secure_url',\n    },\n    prepare(selection) {\n      const {caption, alt, publicId, resourceType, format, secureUrl, url, derivedUrl} =\n        selection as {\n          caption?: string\n          alt?: string\n          publicId?: string\n          resourceType?: string\n          format?: string\n          secureUrl?: string\n          url?: string\n          derivedUrl?: string\n        }\n\n      // Prefer caption/alt from Cloudinary context; fall back to public_id\n      const title = caption || alt || publicId || 'Untitled Asset'\n\n      const type = resourceType || 'image'\n      const formatInfo = format ? `(${format})` : ''\n      const subtitle = `${type} ${formatInfo}`\n\n      let media = derivedUrl || secureUrl || url\n      // Desk/list media is rendered as an <img>; only pass image (and PDF) URLs\n      if (type !== 'image' || !media) {\n        media = undefined\n      } else if (format === 'pdf') {\n        media = media.replace(\n          'image/upload',\n          'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n        )\n      }\n\n      return {\n        title,\n        subtitle,\n        media,\n      }\n    },\n  },\n})\n","import {useEffect, useState} from 'react'\nimport {useClient} from 'sanity'\n\nimport type {CloudinaryAsset} from '../types'\nimport AssetPreview from './AssetPreview'\n\nconst API_VERSION = '2023-01-01'\n\ninterface ReferencePreviewProps {\n  value?: {_ref?: string}\n  /** Bump to force a refetch when the referenced document is updated in place */\n  revision?: number\n}\n\nconst ReferencePreview = (props: ReferencePreviewProps) => {\n  const {value, revision = 0} = props\n  const client = useClient({apiVersion: API_VERSION})\n  const ref = value?._ref\n  const [result, setResult] = useState<{\n    ref: string\n    revision: number\n    asset: CloudinaryAsset | null\n  } | null>(null)\n\n  useEffect(() => {\n    if (!ref) {\n      return undefined\n    }\n\n    let cancelled = false\n    client\n      .getDocument<{asset?: CloudinaryAsset}>(ref)\n      .then((document) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: document?.asset ?? null})\n        }\n        return null\n      })\n      .catch((err) => {\n        if (!cancelled) {\n          setResult({ref, revision, asset: null})\n        }\n        console.error('Error fetching referenced asset:', err)\n      })\n\n    return () => {\n      cancelled = true\n    }\n  }, [ref, client, revision])\n\n  if (!ref) {\n    return null\n  }\n\n  // Derive loading/asset from the fetched result for the current ref+revision\n  if (result?.ref !== ref || result.revision !== revision) {\n    return <div>Loading asset...</div>\n  }\n\n  if (!result.asset) {\n    return null\n  }\n\n  return <AssetPreview value={result.asset} layout=\"block\" />\n}\n\nexport default ReferencePreview\n","import {PlugIcon} from '@sanity/icons/Plug'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {Button, Flex, Grid, Stack} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {type ObjectInputProps, getPublishedId, PatchEvent, set, unset, useClient} from 'sanity'\n\nimport {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'\nimport type {InsertHandlerParams} from '../types'\nimport {normalizeCloudinaryAsset, openMediaSelector} from '../utils'\nimport ReferencePreview from './ReferencePreview'\nimport SecretsConfigView, {namespace, type Secrets} from './SecretsConfigView'\n\nconst API_VERSION = '2023-01-01'\n\n// Fallback so the button doesn't stay disabled if the media library never reports it opened\nconst SELECTOR_FALLBACK_TIMEOUT = 30_000\n\ntype FolderOption = {path?: string; resource_type?: 'image' | 'video'}\n\ntype ReferenceValue = {\n  _key?: string\n  _type?: string\n  asset?: {_type?: 'reference'; _ref?: string; _weak?: boolean}\n}\n\nconst CloudinaryReferenceInput = (props: ObjectInputProps) => {\n  const {onChange, value, schemaType, readOnly} = props\n  const [showSettings, setShowSettings] = useState(false)\n  const [isLoading, setIsLoading] = useState(false)\n  const [previewRevision, setPreviewRevision] = useState(0)\n  const fallbackTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n  const saveInProgressRef = useRef(false)\n  const {secrets, loading: secretsLoading} = useSecrets<Secrets>(namespace)\n  const client = useClient({apiVersion: API_VERSION})\n  // Lookups should see published docs only so we never store drafts.* in _ref\n  const publishedClient = useMemo(() => client.withConfig({perspective: 'published'}), [client])\n\n  const cloudName = secrets?.cloudName\n  const apiKey = secrets?.apiKey\n  const hasConfig = Boolean(apiKey && cloudName)\n  const currentValue = value as ReferenceValue | undefined\n  const valueKey = currentValue?._key\n  const schemaTypeName = schemaType.name\n  const actionsDisabled = Boolean(readOnly) || isLoading || secretsLoading\n\n  const folder = (schemaType.options as {folder?: FolderOption} | undefined)?.folder\n  const folderOption = useMemo(\n    () =>\n      folder?.path || folder?.resource_type\n        ? {path: folder.path, resource_type: folder.resource_type}\n        : undefined,\n    [folder],\n  )\n\n  const setAssetReference = useCallback(\n    (documentId: string) => {\n      onChange(\n        PatchEvent.from(\n          set({\n            _type: schemaTypeName,\n            // Preserve array item identity when this field is used inside an array\n            ...(valueKey ? {_key: valueKey} : {}),\n            asset: {\n              _type: 'reference',\n              _ref: getPublishedId(documentId),\n              _weak: true,\n            },\n          }),\n        ),\n      )\n    },\n    [onChange, schemaTypeName, valueKey],\n  )\n\n  const handleSelect = useCallback(\n    async (payload: InsertHandlerParams) => {\n      if (readOnly) {\n        return\n      }\n\n      const [asset] = payload.assets\n\n      if (!asset) {\n        return\n      }\n\n      const normalizedAsset: Record<string, unknown> = {\n        _type: cloudinaryAssetSchema.name,\n        _key: nanoid(),\n        _version: 1,\n        ...normalizeCloudinaryAsset(asset),\n      }\n\n      setIsLoading(true)\n      saveInProgressRef.current = true\n      try {\n        type ExistingAssetDoc = {_id: string; asset?: {id?: string}}\n\n        // Prefer Cloudinary asset `id` when present; if that misses (or id is\n        // absent), fall back to public_id + resource_type + type so we still\n        // reuse an existing shared document.\n        let existingAsset: ExistingAssetDoc | null = null\n\n        if (asset.id) {\n          existingAsset = await publishedClient.fetch<ExistingAssetDoc | null>(\n            `*[_type == \"cloudinaryAssetDocument\" && asset.id == $id][0]{_id, asset}`,\n            {id: asset.id},\n          )\n        }\n\n        if (!existingAsset && asset.public_id) {\n          existingAsset = await publishedClient.fetch<ExistingAssetDoc | null>(\n            `*[_type == \"cloudinaryAssetDocument\" && asset.public_id == $publicId && asset.resource_type == $resourceType && asset.type == $type][0]{_id, asset}`,\n            {\n              publicId: asset.public_id,\n              resourceType: asset.resource_type,\n              type: asset.type,\n            },\n          )\n        }\n\n        if (existingAsset) {\n          const publishedId = getPublishedId(existingAsset._id)\n          // Preserve a previously stored Cloudinary id if this selection omits it\n          const assetToStore =\n            normalizedAsset['id'] || !existingAsset.asset?.id\n              ? normalizedAsset\n              : {...normalizedAsset, id: existingAsset.asset.id}\n\n          await client.patch(publishedId).set({asset: assetToStore}).commit()\n          setAssetReference(publishedId)\n        } else {\n          // Create a new asset document and reference it (let Sanity assign a valid _id)\n          const newAsset = await client.create({\n            _type: 'cloudinaryAssetDocument',\n            asset: normalizedAsset,\n          })\n          setAssetReference(newAsset._id)\n        }\n\n        // Force preview refresh when the same document is updated in place\n        setPreviewRevision((revision) => revision + 1)\n      } catch (err) {\n        console.error('Error creating/updating Cloudinary asset:', err)\n        // oxlint-disable-next-line react/todo\n      } finally {\n        saveInProgressRef.current = false\n        setIsLoading(false)\n      }\n    },\n    [readOnly, client, publishedClient, setAssetReference],\n  )\n\n  const handleOpenSelector = useCallback(() => {\n    if (readOnly || secretsLoading) {\n      return\n    }\n\n    if (!cloudName || !apiKey) {\n      setShowSettings(true)\n      return\n    }\n\n    setIsLoading(true)\n\n    if (fallbackTimerRef.current) {\n      clearTimeout(fallbackTimerRef.current)\n    }\n\n    try {\n      openMediaSelector(\n        cloudName,\n        apiKey,\n        false, // single selection\n        (payload) => {\n          if (fallbackTimerRef.current) {\n            clearTimeout(fallbackTimerRef.current)\n            fallbackTimerRef.current = undefined\n          }\n          // handleSelect manages isLoading for the create/patch work\n          void handleSelect(payload)\n        },\n        undefined,\n        () => {\n          // Don't clear loading while create/patch is in flight — closing the\n          // library after insert can fire showHandler mid-save.\n          if (saveInProgressRef.current) {\n            return\n          }\n          setIsLoading(false)\n        },\n        folderOption,\n      )\n\n      fallbackTimerRef.current = setTimeout(() => {\n        if (!saveInProgressRef.current) {\n          setIsLoading(false)\n        }\n      }, SELECTOR_FALLBACK_TIMEOUT)\n    } catch (error) {\n      console.error('Error opening Cloudinary media selector:', error)\n      setIsLoading(false)\n    }\n  }, [readOnly, secretsLoading, cloudName, apiKey, handleSelect, folderOption])\n\n  const reference = currentValue?.asset\n\n  let selectButtonText = 'Configure Cloudinary to Select Assets'\n  if (secretsLoading) {\n    selectButtonText = 'Loading Cloudinary config...'\n  } else if (hasConfig) {\n    selectButtonText = isLoading ? 'Opening Media Library...' : 'Select Asset'\n  }\n\n  return (\n    <Stack gap={3}>\n      {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n\n      <Flex justify=\"flex-end\">\n        <Button\n          color=\"primary\"\n          icon={PlugIcon}\n          mode=\"bleed\"\n          title=\"Configure\"\n          onClick={() => setShowSettings(true)}\n          text={hasConfig || secretsLoading ? undefined : 'Configure Cloudinary plugin'}\n          disabled={Boolean(readOnly) || secretsLoading}\n        />\n      </Flex>\n\n      <Flex marginBottom={2} style={{textAlign: 'center', width: '100%'}}>\n        <ReferencePreview value={reference} revision={previewRevision} />\n      </Flex>\n\n      <Stack gap={2}>\n        <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n          <Button\n            text={selectButtonText}\n            onClick={handleOpenSelector}\n            tone=\"primary\"\n            mode=\"ghost\"\n            disabled={actionsDisabled}\n            loading={isLoading || secretsLoading}\n          />\n\n          {reference?._ref ? (\n            <Button\n              text=\"Remove\"\n              tone=\"critical\"\n              mode=\"ghost\"\n              onClick={() => onChange(PatchEvent.from(unset()))}\n              disabled={actionsDisabled}\n            />\n          ) : null}\n        </Grid>\n      </Stack>\n    </Stack>\n  )\n}\n\nexport default CloudinaryReferenceInput\n","import {defineType} from 'sanity'\n\nimport CloudinaryReferenceInput from '../components/CloudinaryReferenceInput'\n\nexport const cloudinaryAssetReference = defineType({\n  name: 'cloudinaryAssetReference',\n  title: 'Cloudinary Asset Reference',\n  type: 'object',\n  fields: [\n    {\n      name: 'asset',\n      type: 'reference',\n      to: [{type: 'cloudinaryAssetDocument'}],\n      weak: true,\n    },\n  ],\n  components: {\n    input: CloudinaryReferenceInput,\n  },\n  preview: {\n    select: {\n      caption: 'asset.asset.context.custom.caption',\n      alt: 'asset.asset.context.custom.alt',\n      publicId: 'asset.asset.public_id',\n      resourceType: 'asset.asset.resource_type',\n      format: 'asset.asset.format',\n      secureUrl: 'asset.asset.secure_url',\n      url: 'asset.asset.url',\n      derivedUrl: 'asset.asset.derived.0.secure_url',\n    },\n    prepare(selection) {\n      const {caption, alt, publicId, resourceType, format, secureUrl, url, derivedUrl} =\n        selection as {\n          caption?: string\n          alt?: string\n          publicId?: string\n          resourceType?: string\n          format?: string\n          secureUrl?: string\n          url?: string\n          derivedUrl?: string\n        }\n\n      const title = caption || alt || publicId || 'Untitled Asset'\n      const type = resourceType || 'image'\n      const formatInfo = format ? `(${format})` : ''\n      const subtitle = `${type} ${formatInfo}`\n\n      let media = derivedUrl || secureUrl || url\n      // Desk/list media is rendered as an <img>; only pass image (and PDF) URLs\n      if (type !== 'image' || !media) {\n        media = undefined\n      } else if (format === 'pdf') {\n        media = media.replace(\n          'image/upload',\n          'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF',\n        )\n      }\n\n      return {\n        title,\n        subtitle,\n        media,\n      }\n    },\n  },\n})\n","import '@sanity/ui/styles.css'\nimport {type AssetSource, definePlugin, isArrayOfObjectsInputProps} from 'sanity'\n\nimport {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'\nimport {CloudinaryIcon} from './components/asset-source/Icon'\nimport {AssetListFunctions} from './components/AssetListFunctions'\nimport {cloudinaryAssetSchema} from './schema/cloudinaryAsset'\nimport {cloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nimport {cloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\nimport {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'\nimport {cloudinaryAssetDocument} from './schema/cloudinaryAssetDocument'\nimport {cloudinaryAssetReference} from './schema/cloudinaryAssetReference'\n\nexport {type CloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nexport {type CloudinaryAssetDerived} from './schema/cloudinaryAssetDerived'\nexport {type CloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\n\nexport type {AssetDocument, CloudinaryAsset} from './types'\n\nexport {\n  cloudinaryAssetSchema,\n  cloudinaryAssetDerivedSchema,\n  cloudinaryAssetContext,\n  cloudinaryAssetContextCustom,\n  cloudinaryAssetDocument,\n  cloudinaryAssetReference,\n}\n\nexport const cloudinaryReferencePlugin = definePlugin({\n  name: 'cloudinary-reference',\n  schema: {\n    types: [\n      cloudinaryAssetDocument,\n      cloudinaryAssetReference,\n      cloudinaryAssetSchema,\n      cloudinaryAssetDerivedSchema,\n      cloudinaryAssetContext,\n      cloudinaryAssetContextCustom,\n    ],\n  },\n})\n\nexport const cloudinarySchemaPlugin = definePlugin({\n  name: 'cloudinary-schema',\n  form: {\n    components: {\n      input: (props) => {\n        if (isArrayOfObjectsInputProps(props)) {\n          const cloudinaryType = props.schemaType.of.find(\n            (t: {name: string}) => t.name === cloudinaryAssetSchema.name,\n          )\n          if (cloudinaryType) {\n            return props.renderDefault({...props, arrayFunctions: AssetListFunctions})\n          }\n        }\n        return props.renderDefault(props)\n      },\n    },\n  },\n  schema: {\n    types: [\n      cloudinaryAssetSchema,\n      cloudinaryAssetDerivedSchema,\n      cloudinaryAssetContext,\n      cloudinaryAssetContextCustom,\n    ],\n  },\n})\n\nexport const cloudinaryImageSource: AssetSource = {\n  name: 'cloudinary-image',\n  // oxlint-disable-next-line no-deprecated -- `i18nKey` requires a locale bundle; a plain title is intentional here\n  title: 'Cloudinary',\n  icon: CloudinaryIcon,\n  component: CloudinaryAssetSource,\n}\n\nexport const cloudinaryAssetSourcePlugin = definePlugin({\n  name: 'cloudinary-asset-source',\n  form: {\n    image: {\n      assetSources: [cloudinaryImageSource],\n    },\n  },\n})\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,YAAY;AAElB,SAAgB,SACd,OAMA,WACoB;CACpB,IAAM,CAAC,WAAW,MAAM,WAAW,CAAC;CAiCpC,OArBE,aACA,MAAM,aACN,CAAC,WACD,MAAM,kBAAkB,WACxB,MAAM,kBAAkB,UACvB,CAAC,MAAM,QAAQ,MAAM,SAAS,YAEx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