{"version":3,"file":"9d808834.js","sources":["../../../node_modules/@sanity/image-url/lib/browser/image-url.umd.js","../../../node_modules/@sanity/asset-utils/dist/asset-utils.esm.js","../../../src/lib/sanity-image.js"],"sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.SanityImageUrlBuilder = factory());\n}(this, (function () {\n var example = 'image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg';\n function parseAssetId(ref) {\n var ref$1 = ref.split('-');\n var id = ref$1[1];\n var dimensionString = ref$1[2];\n var format = ref$1[3];\n\n if (!id || !dimensionString || !format) {\n throw new Error((\"Malformed asset _ref '\" + ref + \"'. Expected an id like \\\"\" + example + \"\\\".\"));\n }\n\n var ref$2 = dimensionString.split('x');\n var imgWidthStr = ref$2[0];\n var imgHeightStr = ref$2[1];\n var width = +imgWidthStr;\n var height = +imgHeightStr;\n var isValidAssetId = isFinite(width) && isFinite(height);\n\n if (!isValidAssetId) {\n throw new Error((\"Malformed asset _ref '\" + ref + \"'. Expected an id like \\\"\" + example + \"\\\".\"));\n }\n\n return {\n id: id,\n width: width,\n height: height,\n format: format\n };\n }\n\n var isRef = function (src) {\n var source = src;\n return source ? typeof source._ref === 'string' : false;\n };\n\n var isAsset = function (src) {\n var source = src;\n return source ? typeof source._id === 'string' : false;\n };\n\n var isAssetStub = function (src) {\n var source = src;\n return source && source.asset ? typeof source.asset.url === 'string' : false;\n }; // Convert an asset-id, asset or image to an image record suitable for processing\n // eslint-disable-next-line complexity\n\n\n function parseSource(source) {\n if (!source) {\n return null;\n }\n\n var image;\n\n if (typeof source === 'string' && isUrl(source)) {\n // Someone passed an existing image url?\n image = {\n asset: {\n _ref: urlToId(source)\n }\n };\n } else if (typeof source === 'string') {\n // Just an asset id\n image = {\n asset: {\n _ref: source\n }\n };\n } else if (isRef(source)) {\n // We just got passed an asset directly\n image = {\n asset: source\n };\n } else if (isAsset(source)) {\n // If we were passed an image asset document\n image = {\n asset: {\n _ref: source._id || ''\n }\n };\n } else if (isAssetStub(source)) {\n // If we were passed a partial asset (`url`, but no `_id`)\n image = {\n asset: {\n _ref: urlToId(source.asset.url)\n }\n };\n } else if (typeof source.asset === 'object') {\n // Probably an actual image with materialized asset\n image = source;\n } else {\n // We got something that does not look like an image, or it is an image\n // that currently isn't sporting an asset.\n return null;\n }\n\n var img = source;\n\n if (img.crop) {\n image.crop = img.crop;\n }\n\n if (img.hotspot) {\n image.hotspot = img.hotspot;\n }\n\n return applyDefaults(image);\n }\n\n function isUrl(url) {\n return /^https?:\\/\\//.test((\"\" + url));\n }\n\n function urlToId(url) {\n var parts = url.split('/').slice(-1);\n return (\"image-\" + (parts[0])).replace(/\\.([a-z]+)$/, '-$1');\n } // Mock crop and hotspot if image lacks it\n\n\n function applyDefaults(image) {\n if (image.crop && image.hotspot) {\n return image;\n } // We need to pad in default values for crop or hotspot\n\n\n var result = Object.assign({}, image);\n\n if (!result.crop) {\n result.crop = {\n left: 0,\n top: 0,\n bottom: 0,\n right: 0\n };\n }\n\n if (!result.hotspot) {\n result.hotspot = {\n x: 0.5,\n y: 0.5,\n height: 1.0,\n width: 1.0\n };\n }\n\n return result;\n }\n\n var SPEC_NAME_TO_URL_NAME_MAPPINGS = [['width', 'w'], ['height', 'h'], ['format', 'fm'], ['download', 'dl'], ['blur', 'blur'], ['sharpen', 'sharp'], ['invert', 'invert'], ['orientation', 'or'], ['minHeight', 'min-h'], ['maxHeight', 'max-h'], ['minWidth', 'min-w'], ['maxWidth', 'max-w'], ['quality', 'q'], ['fit', 'fit'], ['crop', 'crop'], ['saturation', 'sat'], ['auto', 'auto'], ['dpr', 'dpr'], ['pad', 'pad']];\n function urlForImage(options) {\n var spec = Object.assign({}, (options || {}));\n var source = spec.source;\n delete spec.source;\n var image = parseSource(source);\n\n if (!image) {\n throw new Error((\"Unable to resolve image URL from source (\" + (JSON.stringify(source)) + \")\"));\n }\n\n var id = image.asset._ref || image.asset._id || '';\n var asset = parseAssetId(id); // Compute crop rect in terms of pixel coordinates in the raw source image\n\n var cropLeft = Math.round(image.crop.left * asset.width);\n var cropTop = Math.round(image.crop.top * asset.height);\n var crop = {\n left: cropLeft,\n top: cropTop,\n width: Math.round(asset.width - image.crop.right * asset.width - cropLeft),\n height: Math.round(asset.height - image.crop.bottom * asset.height - cropTop)\n }; // Compute hot spot rect in terms of pixel coordinates\n\n var hotSpotVerticalRadius = image.hotspot.height * asset.height / 2;\n var hotSpotHorizontalRadius = image.hotspot.width * asset.width / 2;\n var hotSpotCenterX = image.hotspot.x * asset.width;\n var hotSpotCenterY = image.hotspot.y * asset.height;\n var hotspot = {\n left: hotSpotCenterX - hotSpotHorizontalRadius,\n top: hotSpotCenterY - hotSpotVerticalRadius,\n right: hotSpotCenterX + hotSpotHorizontalRadius,\n bottom: hotSpotCenterY + hotSpotVerticalRadius\n }; // If irrelevant, or if we are requested to: don't perform crop/fit based on\n // the crop/hotspot.\n\n if (!(spec.rect || spec.focalPoint || spec.ignoreImageParams || spec.crop)) {\n spec = Object.assign({}, spec,\n fit({\n crop: crop,\n hotspot: hotspot\n }, spec));\n }\n\n return specToImageUrl(Object.assign({}, spec,\n {asset: asset}));\n } // eslint-disable-next-line complexity\n\n function specToImageUrl(spec) {\n var cdnUrl = spec.baseUrl || 'https://cdn.sanity.io';\n var filename = (spec.asset.id) + \"-\" + (spec.asset.width) + \"x\" + (spec.asset.height) + \".\" + (spec.asset.format);\n var baseUrl = cdnUrl + \"/images/\" + (spec.projectId) + \"/\" + (spec.dataset) + \"/\" + filename;\n var params = [];\n\n if (spec.rect) {\n // Only bother url with a crop if it actually crops anything\n var ref = spec.rect;\n var left = ref.left;\n var top = ref.top;\n var width = ref.width;\n var height = ref.height;\n var isEffectiveCrop = left !== 0 || top !== 0 || height !== spec.asset.height || width !== spec.asset.width;\n\n if (isEffectiveCrop) {\n params.push((\"rect=\" + left + \",\" + top + \",\" + width + \",\" + height));\n }\n }\n\n if (spec.bg) {\n params.push((\"bg=\" + (spec.bg)));\n }\n\n if (spec.focalPoint) {\n params.push((\"fp-x=\" + (spec.focalPoint.x)));\n params.push((\"fp-y=\" + (spec.focalPoint.y)));\n }\n\n var flip = [spec.flipHorizontal && 'h', spec.flipVertical && 'v'].filter(Boolean).join('');\n\n if (flip) {\n params.push((\"flip=\" + flip));\n } // Map from spec name to url param name, and allow using the actual param name as an alternative\n\n\n SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach(function (mapping) {\n var specName = mapping[0];\n var param = mapping[1];\n\n if (typeof spec[specName] !== 'undefined') {\n params.push((param + \"=\" + (encodeURIComponent(spec[specName]))));\n } else if (typeof spec[param] !== 'undefined') {\n params.push((param + \"=\" + (encodeURIComponent(spec[param]))));\n }\n });\n\n if (params.length === 0) {\n return baseUrl;\n }\n\n return (baseUrl + \"?\" + (params.join('&')));\n }\n\n function fit(source, spec) {\n var cropRect;\n var imgWidth = spec.width;\n var imgHeight = spec.height; // If we are not constraining the aspect ratio, we'll just use the whole crop\n\n if (!(imgWidth && imgHeight)) {\n return {\n width: imgWidth,\n height: imgHeight,\n rect: source.crop\n };\n }\n\n var crop = source.crop;\n var hotspot = source.hotspot; // If we are here, that means aspect ratio is locked and fitting will be a bit harder\n\n var desiredAspectRatio = imgWidth / imgHeight;\n var cropAspectRatio = crop.width / crop.height;\n\n if (cropAspectRatio > desiredAspectRatio) {\n // The crop is wider than the desired aspect ratio. That means we are cutting from the sides\n var height = Math.round(crop.height);\n var width = Math.round(height * desiredAspectRatio);\n var top = Math.max(0, Math.round(crop.top)); // Center output horizontally over hotspot\n\n var hotspotXCenter = Math.round((hotspot.right - hotspot.left) / 2 + hotspot.left);\n var left = Math.max(0, Math.round(hotspotXCenter - width / 2)); // Keep output within crop\n\n if (left < crop.left) {\n left = crop.left;\n } else if (left + width > crop.left + crop.width) {\n left = crop.left + crop.width - width;\n }\n\n cropRect = {\n left: left,\n top: top,\n width: width,\n height: height\n };\n } else {\n // The crop is taller than the desired ratio, we are cutting from top and bottom\n var width$1 = crop.width;\n var height$1 = Math.round(width$1 / desiredAspectRatio);\n var left$1 = Math.max(0, Math.round(crop.left)); // Center output vertically over hotspot\n\n var hotspotYCenter = Math.round((hotspot.bottom - hotspot.top) / 2 + hotspot.top);\n var top$1 = Math.max(0, Math.round(hotspotYCenter - height$1 / 2)); // Keep output rect within crop\n\n if (top$1 < crop.top) {\n top$1 = crop.top;\n } else if (top$1 + height$1 > crop.top + crop.height) {\n top$1 = crop.top + crop.height - height$1;\n }\n\n cropRect = {\n left: left$1,\n top: top$1,\n width: width$1,\n height: height$1\n };\n }\n\n return {\n width: imgWidth,\n height: imgHeight,\n rect: cropRect\n };\n } // For backwards-compatibility\n\n var validFits = ['clip', 'crop', 'fill', 'fillmax', 'max', 'scale', 'min'];\n var validCrops = ['top', 'bottom', 'left', 'right', 'center', 'focalpoint', 'entropy'];\n var validAutoModes = ['format'];\n\n function isSanityClientLike(client) {\n return client ? typeof client.clientConfig === 'object' : false;\n }\n\n function rewriteSpecName(key) {\n var specs = SPEC_NAME_TO_URL_NAME_MAPPINGS;\n\n for (var i = 0, list = specs; i < list.length; i += 1) {\n var entry = list[i];\n\n var specName = entry[0];\n var param = entry[1];\n\n if (key === specName || key === param) {\n return specName;\n }\n }\n\n return key;\n }\n\n function urlBuilder(options) {\n // Did we get a SanityClient?\n var client = options;\n\n if (isSanityClientLike(client)) {\n // Inherit config from client\n var ref = client.clientConfig;\n var apiUrl = ref.apiHost;\n var projectId = ref.projectId;\n var dataset = ref.dataset;\n var apiHost = apiUrl || 'https://api.sanity.io';\n return new ImageUrlBuilder(null, {\n baseUrl: apiHost.replace(/^https:\\/\\/api\\./, 'https://cdn.'),\n projectId: projectId,\n dataset: dataset\n });\n } // Or just accept the options as given\n\n\n return new ImageUrlBuilder(null, options);\n }\n var ImageUrlBuilder = function ImageUrlBuilder(parent, options) {\n this.options = parent ? Object.assign({}, (parent.options || {}),\n (options || {})) // Merge parent options\n : Object.assign({}, (options || {})); // Copy options\n };\n\n ImageUrlBuilder.prototype.withOptions = function withOptions (options) {\n var baseUrl = options.baseUrl || this.options.baseUrl;\n var newOptions = {\n baseUrl: baseUrl\n };\n\n for (var key in options) {\n if (options.hasOwnProperty(key)) {\n var specKey = rewriteSpecName(key);\n newOptions[specKey] = options[key];\n }\n }\n\n return new ImageUrlBuilder(this, Object.assign({}, {baseUrl: baseUrl},\n newOptions));\n }; // The image to be represented. Accepts a Sanity 'image'-document, 'asset'-document or\n // _id of asset. To get the benefit of automatic hot-spot/crop integration with the content\n // studio, the 'image'-document must be provided.\n\n\n ImageUrlBuilder.prototype.image = function image (source) {\n return this.withOptions({\n source: source\n });\n }; // Specify the dataset\n\n\n ImageUrlBuilder.prototype.dataset = function dataset (dataset$1) {\n return this.withOptions({\n dataset: dataset$1\n });\n }; // Specify the projectId\n\n\n ImageUrlBuilder.prototype.projectId = function projectId (projectId$1) {\n return this.withOptions({\n projectId: projectId$1\n });\n }; // Specify background color\n\n\n ImageUrlBuilder.prototype.bg = function bg (bg$1) {\n return this.withOptions({\n bg: bg$1\n });\n }; // Set DPR scaling factor\n\n\n ImageUrlBuilder.prototype.dpr = function dpr (dpr$1) {\n // A DPR of 1 is the default - so only include it if we have a different value\n return this.withOptions(dpr$1 && dpr$1 !== 1 ? {\n dpr: dpr$1\n } : {});\n }; // Specify the width of the image in pixels\n\n\n ImageUrlBuilder.prototype.width = function width (width$1) {\n return this.withOptions({\n width: width$1\n });\n }; // Specify the height of the image in pixels\n\n\n ImageUrlBuilder.prototype.height = function height (height$1) {\n return this.withOptions({\n height: height$1\n });\n }; // Specify focal point in fraction of image dimensions. Each component 0.0-1.0\n\n\n ImageUrlBuilder.prototype.focalPoint = function focalPoint (x, y) {\n return this.withOptions({\n focalPoint: {\n x: x,\n y: y\n }\n });\n };\n\n ImageUrlBuilder.prototype.maxWidth = function maxWidth (maxWidth$1) {\n return this.withOptions({\n maxWidth: maxWidth$1\n });\n };\n\n ImageUrlBuilder.prototype.minWidth = function minWidth (minWidth$1) {\n return this.withOptions({\n minWidth: minWidth$1\n });\n };\n\n ImageUrlBuilder.prototype.maxHeight = function maxHeight (maxHeight$1) {\n return this.withOptions({\n maxHeight: maxHeight$1\n });\n };\n\n ImageUrlBuilder.prototype.minHeight = function minHeight (minHeight$1) {\n return this.withOptions({\n minHeight: minHeight$1\n });\n }; // Specify width and height in pixels\n\n\n ImageUrlBuilder.prototype.size = function size (width, height) {\n return this.withOptions({\n width: width,\n height: height\n });\n }; // Specify blur between 0 and 100\n\n\n ImageUrlBuilder.prototype.blur = function blur (blur$1) {\n return this.withOptions({\n blur: blur$1\n });\n };\n\n ImageUrlBuilder.prototype.sharpen = function sharpen (sharpen$1) {\n return this.withOptions({\n sharpen: sharpen$1\n });\n }; // Specify the desired rectangle of the image\n\n\n ImageUrlBuilder.prototype.rect = function rect (left, top, width, height) {\n return this.withOptions({\n rect: {\n left: left,\n top: top,\n width: width,\n height: height\n }\n });\n }; // Specify the image format of the image. 'jpg', 'pjpg', 'png', 'webp'\n\n\n ImageUrlBuilder.prototype.format = function format (format$1) {\n return this.withOptions({\n format: format$1\n });\n };\n\n ImageUrlBuilder.prototype.invert = function invert (invert$1) {\n return this.withOptions({\n invert: invert$1\n });\n }; // Rotation in degrees 0, 90, 180, 270\n\n\n ImageUrlBuilder.prototype.orientation = function orientation (orientation$1) {\n return this.withOptions({\n orientation: orientation$1\n });\n }; // Compression quality 0-100\n\n\n ImageUrlBuilder.prototype.quality = function quality (quality$1) {\n return this.withOptions({\n quality: quality$1\n });\n }; // Make it a download link. Parameter is default filename.\n\n\n ImageUrlBuilder.prototype.forceDownload = function forceDownload (download) {\n return this.withOptions({\n download: download\n });\n }; // Flip image horizontally\n\n\n ImageUrlBuilder.prototype.flipHorizontal = function flipHorizontal () {\n return this.withOptions({\n flipHorizontal: true\n });\n }; // Flip image vertically\n\n\n ImageUrlBuilder.prototype.flipVertical = function flipVertical () {\n return this.withOptions({\n flipVertical: true\n });\n }; // Ignore crop/hotspot from image record, even when present\n\n\n ImageUrlBuilder.prototype.ignoreImageParams = function ignoreImageParams () {\n return this.withOptions({\n ignoreImageParams: true\n });\n };\n\n ImageUrlBuilder.prototype.fit = function fit (value) {\n if (validFits.indexOf(value) === -1) {\n throw new Error((\"Invalid fit mode \\\"\" + value + \"\\\"\"));\n }\n\n return this.withOptions({\n fit: value\n });\n };\n\n ImageUrlBuilder.prototype.crop = function crop (value) {\n if (validCrops.indexOf(value) === -1) {\n throw new Error((\"Invalid crop mode \\\"\" + value + \"\\\"\"));\n }\n\n return this.withOptions({\n crop: value\n });\n }; // Saturation\n\n\n ImageUrlBuilder.prototype.saturation = function saturation (saturation$1) {\n return this.withOptions({\n saturation: saturation$1\n });\n };\n\n ImageUrlBuilder.prototype.auto = function auto (value) {\n if (validAutoModes.indexOf(value) === -1) {\n throw new Error((\"Invalid auto mode \\\"\" + value + \"\\\"\"));\n }\n\n return this.withOptions({\n auto: value\n });\n }; // Specify the number of pixels to pad the image\n\n\n ImageUrlBuilder.prototype.pad = function pad (pad$1) {\n return this.withOptions({\n pad: pad$1\n });\n }; // Gets the url based on the submitted parameters\n\n\n ImageUrlBuilder.prototype.url = function url () {\n return urlForImage(this.options);\n }; // Alias for url()\n\n\n ImageUrlBuilder.prototype.toString = function toString () {\n return this.url();\n };\n\n return urlBuilder;\n\n})));\n//# sourceMappingURL=image-url.umd.js.map\n","function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n return _extends.apply(this, arguments);\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n\n _setPrototypeOf(subClass, superClass);\n}\n\nfunction _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}\n\nfunction _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _construct(Parent, args, Class) {\n if (_isNativeReflectConstruct()) {\n _construct = Reflect.construct.bind();\n } else {\n _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) _setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\n\nfunction _isNativeFunction(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\n\nfunction _wrapNativeSuper(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n\n _wrapNativeSuper = function _wrapNativeSuper(Class) {\n if (Class === null || !_isNativeFunction(Class)) return Class;\n\n if (typeof Class !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Class);\n\n _cache.set(Class, Wrapper);\n }\n\n function Wrapper() {\n return _construct(Class, arguments, _getPrototypeOf(this).constructor);\n }\n\n Wrapper.prototype = Object.create(Class.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _setPrototypeOf(Wrapper, Class);\n };\n\n return _wrapNativeSuper(Class);\n}\n\n/**\r\n * Default crop (equals to \"whole image\")\r\n */\nvar DEFAULT_CROP = /*#__PURE__*/Object.freeze({\n left: 0,\n top: 0,\n bottom: 0,\n right: 0\n});\n/**\r\n * Default hotspot (equals to horizontal/vertical center, full size of image)\r\n */\n\nvar DEFAULT_HOTSPOT = /*#__PURE__*/Object.freeze({\n x: 0.5,\n y: 0.5,\n height: 1,\n width: 1\n});\n/**\r\n * Returns cloned version of the default crop (prevents accidental mutations)\r\n *\r\n * @returns Default image crop object\r\n */\n\nvar getDefaultCrop = function getDefaultCrop() {\n return _extends({}, DEFAULT_CROP);\n};\n/**\r\n * Returns cloned version of the default hotspot (prevents accidental mutations)\r\n *\r\n * @returns Default image hotspot object\r\n */\n\nvar getDefaultHotspot = function getDefaultHotspot() {\n return _extends({}, DEFAULT_HOTSPOT);\n};\n/**\r\n * Returns whether or not the passed crop has the default values for a crop region\r\n *\r\n * @param crop The crop to return whether or not is the default crop\r\n * @returns True if passed crop matches default, false otherwise\r\n */\n\nvar isDefaultCrop = function isDefaultCrop(crop) {\n var top = crop.top,\n bottom = crop.bottom,\n left = crop.left,\n right = crop.right;\n var defaultTop = DEFAULT_CROP.top,\n defaultBottom = DEFAULT_CROP.bottom,\n defaultLeft = DEFAULT_CROP.left,\n defaultRight = DEFAULT_CROP.right;\n return top === defaultTop && bottom === defaultBottom && left === defaultLeft && right === defaultRight;\n};\n/**\r\n * Returns whether or not the passed hotspot has the default values for a hotspot region\r\n *\r\n * @param hotspot The hotspot to return whether or not is the default hotspot\r\n * @returns True if passed hotspot matches default, false otherwise\r\n */\n\nvar isDefaultHotspot = function isDefaultHotspot(hotspot) {\n var x = hotspot.x,\n y = hotspot.y,\n width = hotspot.width,\n height = hotspot.height;\n var defaultX = DEFAULT_HOTSPOT.x,\n defaultY = DEFAULT_HOTSPOT.y,\n defaultWidth = DEFAULT_HOTSPOT.width,\n defaultHeight = DEFAULT_HOTSPOT.height;\n return x === defaultX && y === defaultY && width === defaultWidth && height === defaultHeight;\n};\n\n/**\r\n * Error type thrown when the library fails to resolve a value, such as an asset ID,\r\n * filename or project ID/dataset information.\r\n *\r\n * The `input` property holds the value passed as the input, which failed to be\r\n * resolved to something meaningful.\r\n */\nvar UnresolvableError = /*#__PURE__*/function (_Error) {\n _inheritsLoose(UnresolvableError, _Error);\n\n function UnresolvableError(inputSource, message) {\n var _this;\n\n if (message === void 0) {\n message = 'Failed to resolve asset ID from source';\n }\n\n _this = _Error.call(this, message) || this;\n _this.unresolvable = true;\n _this.input = inputSource;\n return _this;\n }\n\n return UnresolvableError;\n}( /*#__PURE__*/_wrapNativeSuper(Error));\n/**\r\n * Checks whether or not an error instance is of type UnresolvableError\r\n *\r\n * @param err - Error to check for unresolvable error type\r\n * @returns True if the passed error instance appears to be an unresolveable error\r\n */\n\nfunction isUnresolvableError(err) {\n var error = err;\n return Boolean(error.unresolvable && 'input' in error);\n}\n/**\r\n * Returns a getter which returns `undefined` instead of throwing,\r\n * if encountering an `UnresolvableError`\r\n *\r\n * @param method - Function to use as resolver\r\n * @returns Function that returns `undefined` if passed resolver throws UnresolvableError\r\n * @internal\r\n */\n\nfunction getForgivingResolver(method) {\n return function () {\n try {\n return method.apply(void 0, arguments);\n } catch (err) {\n if (isUnresolvableError(err)) {\n return undefined;\n }\n\n throw err;\n }\n };\n}\n\n/**\r\n * @internal\r\n */\nvar cdnUrl = 'https://cdn.sanity.io';\n/**\r\n * @internal\r\n */\n\nvar fileAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+\\.[a-z0-9]+$/;\n/**\r\n * @internal\r\n */\n\nvar fileAssetIdPattern = /^file-([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+-[a-z0-9]+$/;\n/**\r\n * @internal\r\n */\n\nvar imageAssetFilenamePattern = /^([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})-\\d+x\\d+\\.[a-z0-9]+$/;\n/**\r\n * @internal\r\n */\n\nvar imageAssetIdPattern = /^image-([a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+-\\d+x\\d+-[a-z0-9]+$/;\n/**\r\n * @internal\r\n */\n\nvar pathPattern = /^(images|files)\\/([a-z0-9]+)\\/([a-z0-9][-\\w]*)\\//;\n/**\r\n * @internal\r\n */\n\nvar idPattern = /^(?:image-(?:[a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+-\\d+x\\d+-[a-z0-9]+|file-(?:[a-zA-Z0-9_]{24,40}|[a-f0-9]{40})+-[a-z0-9]+)$/;\n/**\r\n * For use in cases where the project and dataset doesn't really matter\r\n *\r\n * @internal\r\n */\n\nvar dummyProject = {\n projectId: 'a',\n dataset: 'b'\n};\n\n/**\r\n * Checks whether or not the given source is a Sanity reference\r\n * (an object containing _ref string key)\r\n *\r\n * @param ref - Possible reference\r\n * @returns Whether or not the passed object is a reference\r\n */\n\nfunction isReference(ref) {\n return isObject(ref) && typeof ref._ref === 'string';\n}\n/**\r\n * Checks whether or not the given source is an asset ID stub\r\n * (an object containing an `_id` property)\r\n *\r\n * @param stub - Possible asset id stub\r\n * @returns Whether or not the passed object is an object id stub\r\n */\n\nfunction isAssetIdStub(stub) {\n return isObject(stub) && typeof stub._id === 'string';\n}\n/**\r\n * Checks whether or not the given source is an asset path stub\r\n * (an object containing a `path` property)\r\n *\r\n * @param stub - Possible asset path stub\r\n * @returns Whether or not the passed object is an object path stub\r\n */\n\nfunction isAssetPathStub(stub) {\n return isObject(stub) && typeof stub.path === 'string';\n}\n/**\r\n * Checks whether or not the given source is an asset URL stub\r\n * (an object containing a `url` property)\r\n *\r\n * @param stub - Possible asset url stub\r\n * @returns Whether or not the passed object is an object url stub\r\n */\n\nfunction isAssetUrlStub(stub) {\n return isObject(stub) && typeof stub.url === 'string';\n}\n/**\r\n * Checks whether or not the given source is a (partial) sanity file asset document.\r\n * Only checks the `_type` property, all other properties _may_ be missing\r\n *\r\n * @param src - Source to check\r\n * @returns Whether or not the given source is a file asset\r\n */\n\nfunction isSanityFileAsset(src) {\n return isObject(src) && src._type === 'sanity.fileAsset';\n}\n/**\r\n * Checks whether or not the given source is a (partial) sanity image asset document.\r\n * Only checks the `_type` property, all other properties _may_ be missing\r\n *\r\n * @param src - Source to check\r\n * @returns Whether or not the given source is a file asset\r\n */\n\nfunction isSanityImageAsset(src) {\n return isObject(src) && src._type === 'sanity.imageAsset';\n}\n/**\r\n * Checks whether or not the given document ID is a valid Sanity image asset document ID\r\n *\r\n * @param documentId - Document ID to check\r\n * @returns Whether or not the given document ID is a Sanity image asset document ID\r\n */\n\nfunction isImageAssetId(documentId) {\n return imageAssetIdPattern.test(documentId);\n}\n/**\r\n * Checks whether or not the given document ID is a valid Sanity file asset document ID\r\n *\r\n * @param documentId - Document ID to check\r\n * @returns Whether or not the given document ID is a Sanity file asset document ID\r\n */\n\nfunction isFileAssetId(documentId) {\n return fileAssetIdPattern.test(documentId);\n}\n/**\r\n * Checks whether or not the given document ID is a valid Sanity asset document ID (file or image)\r\n *\r\n * @param documentId - Document ID to check\r\n * @returns Whether or not the given document ID is a Sanity asset document ID (file or image)\r\n */\n\nfunction isAssetId(documentId) {\n return isImageAssetId(documentId) || isFileAssetId(documentId);\n}\n/**\r\n * Checks whether or not the given source is an asset object stub\r\n *\r\n * @param stub - Possible asset object stub\r\n * @returns Whether or not the passed object is an object stub\r\n */\n\nfunction isAssetObjectStub(stub) {\n var item = stub;\n return isObject(item) && item.asset && typeof item.asset === 'object';\n}\n/**\r\n * Checks whether or not the passed object is an object (and not `null`)\r\n *\r\n * @param obj Item to check whether or not is an object\r\n * @returns Whether or not `obj` is an object\r\n * @internal\r\n */\n\nfunction isObject(obj) {\n return obj !== null && !Array.isArray(obj) && typeof obj === 'object';\n}\n\n/**\r\n * Builds the base image path from the minimal set of parts required to assemble it\r\n *\r\n * @param asset - An asset-like shape defining ID, dimensions and extension\r\n * @param options - Project ID and dataset the image belongs to, along with other options\r\n * @return string\r\n */\n\nfunction buildImagePath(asset, options) {\n var projectId = (options == null ? void 0 : options.projectId) || asset.projectId;\n var dataset = (options == null ? void 0 : options.dataset) || asset.dataset;\n\n if (!projectId || !dataset) {\n throw new Error('Project details (projectId and dataset) required to resolve path for image');\n }\n\n var dimensions = 'metadata' in asset ? asset.metadata.dimensions : {\n width: asset.width,\n height: asset.height\n };\n var originalFilename = 'originalFilename' in asset ? asset.originalFilename : undefined;\n var assetId = asset.assetId,\n extension = asset.extension,\n vanityFilename = asset.vanityFilename;\n var width = dimensions.width,\n height = dimensions.height;\n var vanity = getVanityStub(originalFilename, vanityFilename, options);\n return \"images/\" + projectId + \"/\" + dataset + \"/\" + assetId + \"-\" + width + \"x\" + height + \".\" + extension + vanity;\n}\n/**\r\n * Builds the base image URL from the minimal set of parts required to assemble it\r\n *\r\n * @param asset - An asset-like shape defining ID, dimensions and extension\r\n * @param options - Project ID and dataset the image belongs to\r\n * @return string\r\n */\n\nfunction buildImageUrl(asset, options) {\n return cdnUrl + \"/\" + buildImagePath(asset, options);\n}\n/**\r\n * Builds the base file path from the minimal set of parts required to assemble it\r\n *\r\n * @param asset - An asset-like shape defining ID, dimensions and extension\r\n * @param options - Project ID and dataset the file belongs to, along with other options\r\n * @return string\r\n */\n\nfunction buildFilePath(asset, options) {\n var projectId = (options == null ? void 0 : options.projectId) || asset.projectId;\n var dataset = (options == null ? void 0 : options.dataset) || asset.dataset;\n\n if (!projectId || !dataset) {\n throw new Error('Project details (projectId and dataset) required to resolve path for file');\n }\n\n var originalFilename = 'originalFilename' in asset ? asset.originalFilename : undefined;\n var assetId = asset.assetId,\n extension = asset.extension,\n vanityFilename = asset.vanityFilename;\n var vanity = getVanityStub(originalFilename, vanityFilename, options);\n return \"files/\" + projectId + \"/\" + dataset + \"/\" + assetId + \".\" + extension + vanity;\n}\n/**\r\n * Builds the base file URL from the minimal set of parts required to assemble it\r\n *\r\n * @param asset - An asset-like shape defining ID and extension\r\n * @param options - Project ID and dataset the file belongs to, along with other options\r\n * @return string\r\n */\n\nfunction buildFileUrl(asset, project) {\n return cdnUrl + \"/\" + buildFilePath(asset, project);\n}\n/**\r\n * Checks whether or not the given URL contains an asset path\r\n *\r\n * @param url - URL or path name\r\n * @returns Whether or not it contained an asset path\r\n */\n\nfunction hasPath(urlOrPath) {\n return pathPattern.test(tryGetUrlPath(urlOrPath) || '');\n}\n/**\r\n * Tries to get the asset path from a given asset source\r\n *\r\n * @param src - The source image to infer an asset path from\r\n * @returns A path if resolvable, undefined otherwise\r\n */\n\n\nfunction tryGetAssetPath(src) {\n if (isAssetObjectStub(src)) {\n return tryGetAssetPath(src.asset);\n }\n\n if (isReference(src)) {\n return undefined;\n }\n\n if (typeof src === 'string') {\n return hasPath(src) ? getUrlPath(src) : undefined;\n }\n\n if (isAssetPathStub(src)) {\n return src.path;\n }\n\n if (isAssetUrlStub(src)) {\n return getUrlPath(src.url);\n }\n\n return undefined;\n}\n/**\r\n * Strips the CDN URL and query params from a URL, eg:\r\n * `https://cdn.sanity.io/images/project/dataset/filename-200x200.jpg?foo=bar` =>\r\n * `images/project/dataset/filename-200x200.jpg`\r\n *\r\n * @param url - URL to get path name from\r\n * @returns The path of a CDN URL\r\n * @throws If URL is not a valid Sanity asset URL\r\n */\n\nfunction getUrlPath(url) {\n if (pathPattern.test(url)) {\n // Already just a path\n return url;\n }\n\n if (!url.startsWith(cdnUrl + \"/\")) {\n throw new UnresolvableError(\"Failed to resolve path from URL \\\"\" + url + \"\\\"\");\n }\n\n var qsPos = url.indexOf('?');\n var toIndex = qsPos === -1 ? undefined : qsPos;\n return url.slice(cdnUrl.length + 1, toIndex);\n}\n/**\r\n * See {@link getUrlPath}\r\n *\r\n * @inheritFrom {@link getUrlPath}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetUrlPath = /*#__PURE__*/getForgivingResolver(getUrlPath);\n/**\r\n * Strips the CDN URL, path and query params from a URL, eg:\r\n * `https://cdn.sanity.io/images/project/dataset/filename-200x200.jpg?foo=bar` =>\r\n * `filename-200x200.jpg`\r\n *\r\n * @param url - URL to get filename from\r\n * @returns The filename of an URL, if URL matches the CDN URL\r\n * @throws If URL is not a valid Sanity asset URL\r\n */\n\nfunction getUrlFilename(url) {\n var path = tryGetUrlPath(url) || url;\n var filename = path.replace(/^(images|files)\\/[a-z0-9]+\\/[a-z0-9][-\\w]\\/*/, '');\n\n if (!isValidFilename(filename)) {\n throw new UnresolvableError(\"Failed to resolve filename from URL \\\"\" + url + \"\\\"\");\n }\n\n return filename;\n}\n/**\r\n * See {@link getUrlFilename}\r\n *\r\n * @inheritFrom {@link getUrlFilename}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetUrlFilename = /*#__PURE__*/getForgivingResolver(getUrlFilename);\n/**\r\n * Checks whether or not a given filename matches the expected Sanity asset filename pattern\r\n *\r\n * @param filename - Filename to check for validity\r\n * @returns Whether or not the specified filename is valid\r\n */\n\nfunction isValidFilename(filename) {\n return fileAssetFilenamePattern.test(filename) || imageAssetFilenamePattern.test(filename);\n}\n/**\r\n * Get the \"path stub\" at the end of the path, if the user hasn't explicitly opted out of this behavior\r\n */\n\nfunction getVanityStub(originalFilename, vanityFilename, options) {\n var vanity = vanityFilename || originalFilename;\n return (options == null ? void 0 : options.useVanityName) === false || !vanity ? '' : \"/\" + vanity;\n}\n\n/**\r\n * @internal\r\n */\n\nvar exampleFileId = 'file-027401f31c3ac1e6d78c5d539ccd1beff72b9b11-pdf';\n/**\r\n * @internal\r\n */\n\nvar exampleImageId = 'image-027401f31c3ac1e6d78c5d539ccd1beff72b9b11-2000x3000-jpg';\n/**\r\n * Parses a Sanity asset document ID into individual parts (type, id, extension, width/height etc)\r\n *\r\n * @param documentId - Document ID to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If document ID is invalid\r\n */\n\nfunction parseAssetId(documentId) {\n if (imageAssetIdPattern.test(documentId)) {\n return parseImageAssetId(documentId);\n }\n\n if (fileAssetIdPattern.test(documentId)) {\n return parseFileAssetId(documentId);\n }\n\n throw new Error(\"Invalid image/file asset ID: \" + documentId);\n}\n/**\r\n * Parses a Sanity file asset document ID into individual parts (type, id, extension)\r\n *\r\n * @param documentId - File asset document ID to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If document ID invalid\r\n */\n\nfunction parseFileAssetId(documentId) {\n if (!fileAssetIdPattern.test(documentId)) {\n throw new Error(\"Malformed file asset ID '\" + documentId + \"'. Expected an id like \\\"\" + exampleFileId + \"\\\"\");\n }\n\n var _documentId$split = documentId.split('-'),\n assetId = _documentId$split[1],\n extension = _documentId$split[2];\n\n return {\n type: 'file',\n assetId: assetId,\n extension: extension\n };\n}\n/**\r\n * Parses a Sanity image asset document ID into individual parts (type, id, extension, width, height)\r\n *\r\n * @param documentId - Image asset document ID to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If document ID invalid\r\n */\n\nfunction parseImageAssetId(documentId) {\n var _documentId$split2 = documentId.split('-'),\n assetId = _documentId$split2[1],\n dimensionString = _documentId$split2[2],\n extension = _documentId$split2[3];\n\n var _split$map = (dimensionString || '').split('x').map(Number),\n width = _split$map[0],\n height = _split$map[1];\n\n if (!assetId || !dimensionString || !extension || !(width > 0) || !(height > 0)) {\n throw new Error(\"Malformed asset ID '\" + documentId + \"'. Expected an id like \\\"\" + exampleImageId + \"\\\".\");\n }\n\n return {\n type: 'image',\n assetId: assetId,\n width: width,\n height: height,\n extension: extension\n };\n}\n/**\r\n * Parses a Sanity asset filename into individual parts (type, id, extension, width, height)\r\n *\r\n * @param filename - Filename to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If image/filename is invalid\r\n */\n\nfunction parseAssetFilename(filename) {\n var file = tryGetUrlFilename(filename) || '';\n\n if (!isValidFilename(file)) {\n throw new Error(\"Invalid image/file asset filename: \" + filename);\n }\n\n try {\n var type = imageAssetFilenamePattern.test(file) ? 'image' : 'file';\n var assetId = file.replace(/\\.([a-z0-9+]+)$/i, '-$1');\n return parseAssetId(type + \"-\" + assetId);\n } catch (err) {\n throw new Error(\"Invalid image/file asset filename: \" + filename);\n }\n}\n/**\r\n * Parses a full Sanity asset URL into individual parts\r\n * (type, project ID, dataset, id, extension, width, height)\r\n *\r\n * @param url - Full URL to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If URL is invalid or not a Sanity asset URL\r\n */\n\nfunction parseAssetUrl(url) {\n if (!url.startsWith(cdnUrl)) {\n throw new Error(\"URL is not a valid Sanity asset URL: \" + url);\n }\n\n var path = url.slice(cdnUrl.length).replace(/^\\/+/, '');\n\n var _ref = path.match(pathPattern) || [],\n projectPath = _ref[0],\n projectId = _ref[2],\n dataset = _ref[3];\n\n if (!projectId || !dataset) {\n throw new Error(\"URL is not a valid Sanity asset URL: \" + url);\n }\n\n var _path$slice$split = path.slice(projectPath.length).split('/'),\n filename = _path$slice$split[0],\n vanityFilename = _path$slice$split[1];\n\n var parsed = parseAssetFilename(filename);\n return _extends({}, parsed, {\n projectId: projectId,\n dataset: dataset,\n vanityFilename: vanityFilename\n });\n}\n/**\r\n * Parses a full Sanity image asset URL into individual parts\r\n * (type, project ID, dataset, id, extension, width, height)\r\n *\r\n * @param url - Full URL to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If URL is invalid or not a Sanity image asset URL\r\n */\n\nfunction parseImageAssetUrl(url) {\n var parsed = parseAssetUrl(url);\n\n if (parsed.type !== 'image') {\n throw new Error(\"URL is not a valid Sanity image asset URL: \" + url);\n }\n\n return parsed;\n}\n/**\r\n * Parses a full Sanity file asset URL into individual parts\r\n * (type, project ID, dataset, id, extension, width, height)\r\n *\r\n * @param url - Full URL to parse into named parts\r\n * @returns Object of named properties\r\n * @throws If URL is invalid or not a Sanity file asset URL\r\n */\n\nfunction parseFileAssetUrl(url) {\n var parsed = parseAssetUrl(url);\n\n if (parsed.type !== 'file') {\n throw new Error(\"URL is not a valid Sanity file asset URL: \" + url);\n }\n\n return parsed;\n}\n/**\r\n * Validates that a given URL is a Sanity asset URL, and returns the asset type if valid.\r\n *\r\n * @param url URL to extract asset type from\r\n * @returns Asset type if valid URL, false otherwise\r\n * @internal\r\n */\n\nfunction getAssetUrlType(url) {\n try {\n return parseAssetUrl(url).type;\n } catch (err) {\n return false;\n }\n}\n\n/**\r\n * Returns the width, height and aspect ratio of a passed image asset, from any\r\n * inferrable structure (id, url, path, asset document, image object etc)\r\n *\r\n * @param src - Input source (image object, asset, reference, id, url, path)\r\n * @returns Object with width, height and aspect ratio properties\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed image source could not be resolved to an asset ID\r\n */\n\nfunction getImageDimensions(src) {\n var imageId = getAssetDocumentId(src);\n\n var _parseImageAssetId = parseImageAssetId(imageId),\n width = _parseImageAssetId.width,\n height = _parseImageAssetId.height;\n\n var aspectRatio = width / height;\n return {\n width: width,\n height: height,\n aspectRatio: aspectRatio\n };\n}\n/**\r\n * See {@link getImageDimensions}\r\n *\r\n * @inheritFrom {@link getImageDimensions}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetImageDimensions = /*#__PURE__*/getForgivingResolver(getImageDimensions);\n/**\r\n * Returns the file extension for a given asset\r\n *\r\n * @param src - Input source (file/image object, asset, reference, id, url, path)\r\n * @returns The file extension, if resolvable (no `.` included)\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed asset source could not be resolved to an asset ID\r\n */\n\nfunction getExtension(src) {\n return isFileSource(src) ? getFile(src, dummyProject).asset.extension : getImage(src, dummyProject).asset.extension;\n}\n/**\r\n * See {@link getExtension}\r\n *\r\n * @inheritFrom {@link getExtension}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetExtension = /*#__PURE__*/getForgivingResolver(getExtension);\n/**\r\n * Tries to resolve an image object with as much information as possible,\r\n * from any inferrable structure (id, url, path, image object etc)\r\n *\r\n * @param src - Input source (image object, asset, reference, id, url, path)\r\n * @param project Project ID and dataset the image belongs to\r\n * @returns Image object\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed image source could not be resolved to an asset ID\r\n */\n\nfunction getImage(src, project) {\n var projectDetails = project || tryGetProject(src);\n var asset = getImageAsset(src, projectDetails);\n var img = src;\n return {\n asset: asset,\n crop: img.crop || getDefaultCrop(),\n hotspot: img.hotspot || getDefaultHotspot()\n };\n}\n/**\r\n * See {@link getImage}\r\n *\r\n * @inheritFrom {@link getImage}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetImage = /*#__PURE__*/getForgivingResolver(getImage);\n/**\r\n * Tries to resolve a (partial) image asset document with as much information as possible,\r\n * from any inferrable structure (id, url, path, image object etc)\r\n *\r\n * @param src - Input source (image object, asset, reference, id, url, path)\r\n * @param project - Project ID and dataset the image belongs to\r\n * @returns Image asset document\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed image source could not be resolved to an asset ID\r\n */\n\nfunction getImageAsset(src, project) {\n var projectDetails = project || getProject(src);\n\n var pathOptions = _extends({}, projectDetails, {\n useVanityName: false\n });\n\n var _id = getAssetDocumentId(src);\n\n var sourceObj = src;\n var source = sourceObj.asset || src;\n var metadata = source.metadata || {};\n\n var _parseImageAssetId2 = parseImageAssetId(_id),\n assetId = _parseImageAssetId2.assetId,\n width = _parseImageAssetId2.width,\n height = _parseImageAssetId2.height,\n extension = _parseImageAssetId2.extension;\n\n var aspectRatio = width / height;\n\n var baseAsset = _extends({}, isSanityImageAsset(src) ? src : {}, {\n _id: _id,\n _type: 'sanity.imageAsset',\n assetId: assetId,\n extension: extension,\n metadata: _extends({}, metadata, {\n dimensions: {\n width: width,\n height: height,\n aspectRatio: aspectRatio\n }\n }),\n // Placeholders, overwritten below\n url: '',\n path: ''\n });\n\n return _extends({}, baseAsset, {\n path: buildImagePath(baseAsset, pathOptions),\n url: buildImageUrl(baseAsset, pathOptions)\n });\n}\n/**\r\n * See {@link getImageAsset}\r\n *\r\n * @inheritFrom {@link getImageAsset}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetImageAsset = /*#__PURE__*/getForgivingResolver(getImageAsset);\n/**\r\n * Tries to resolve an file object with as much information as possible,\r\n * from any inferrable structure (id, url, path, file object etc)\r\n *\r\n * @param src - Input source (file object, asset, reference, id, url, path)\r\n * @param project Project ID and dataset the file belongs to\r\n * @returns File object\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed file source could not be resolved to an asset ID\r\n */\n\nfunction getFile(src, project) {\n var projectDetails = project || tryGetProject(src);\n var asset = getFileAsset(src, projectDetails);\n return {\n asset: asset\n };\n}\n/**\r\n * See {@link getFile}\r\n *\r\n * @inheritFrom {@link getFile}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetFile = /*#__PURE__*/getForgivingResolver(getFile);\n/**\r\n * Tries to resolve a (partial) file asset document with as much information as possible,\r\n * from any inferrable structure (id, url, path, file object etc)\r\n *\r\n * @param src - Input source (file object, asset, reference, id, url, path)\r\n * @param options - Project ID and dataset the file belongs to, along with other options\r\n * @returns File asset document\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed file source could not be resolved to an asset ID\r\n */\n\nfunction getFileAsset(src, options) {\n var projectDetails = _extends({}, options || getProject(src), {\n useVanityName: false\n });\n\n var _id = getAssetDocumentId(src);\n\n var sourceObj = src;\n var source = sourceObj.asset || src;\n\n var _parseFileAssetId = parseFileAssetId(_id),\n assetId = _parseFileAssetId.assetId,\n extension = _parseFileAssetId.extension;\n\n var baseAsset = _extends({}, isSanityFileAsset(src) ? src : {}, {\n _id: _id,\n _type: 'sanity.fileAsset',\n assetId: assetId,\n extension: extension,\n metadata: source.metadata || {},\n // Placeholders, overwritten below\n url: '',\n path: ''\n });\n\n return _extends({}, baseAsset, {\n path: buildFilePath(baseAsset, projectDetails),\n url: buildFileUrl(baseAsset, projectDetails)\n });\n}\n/**\r\n * See {@link getFileAsset}\r\n *\r\n * @inheritFrom {@link getFileAsset}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetFileAsset = /*#__PURE__*/getForgivingResolver(getFileAsset);\n/**\r\n * Tries to resolve the asset document ID from any inferrable structure\r\n *\r\n * @param src - Input source (image/file object, asset, reference, id, url, path)\r\n * @returns The asset document ID\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed asset source could not be resolved to an asset document ID\r\n */\n\nfunction getAssetDocumentId(src) {\n var source = isAssetObjectStub(src) ? src.asset : src;\n var id = '';\n\n if (typeof source === 'string') {\n id = getIdFromString(source);\n } else if (isReference(source)) {\n id = source._ref;\n } else if (isAssetIdStub(source)) {\n id = source._id;\n } else if (isAssetPathStub(source)) {\n id = idFromUrl(cdnUrl + \"/\" + source.path);\n } else if (isAssetUrlStub(source)) {\n id = idFromUrl(source.url);\n }\n\n var hasId = id && idPattern.test(id);\n\n if (!hasId) {\n throw new UnresolvableError(src);\n }\n\n return id;\n}\n/**\r\n * See {@link getAssetDocumentId}\r\n *\r\n * @inheritFrom {@link getAssetDocumentId}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetAssetDocumentId = /*#__PURE__*/getForgivingResolver(getAssetDocumentId);\n/**\r\n * Tries to cooerce a string (ID, URL or path) to an image asset ID\r\n *\r\n * @param str - Input string (ID, URL or path)\r\n * @returns string\r\n *\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed image source could not be resolved to an asset ID\r\n */\n\nfunction getIdFromString(str) {\n if (idPattern.test(str)) {\n // Already an ID\n return str;\n }\n\n if (str.indexOf(cdnUrl + \"/images\") === 0 || str.indexOf(cdnUrl + \"/files\") === 0) {\n // Full URL\n return idFromUrl(str);\n }\n\n if (pathPattern.test(str)) {\n // Path\n return idFromUrl(cdnUrl + \"/\" + str);\n }\n\n if (isFileAssetFilename(str)) {\n // Just a filename (projectId/dataset irrelevant: just need asset ID)\n return idFromUrl(cdnUrl + \"/files/a/b/\" + str);\n }\n\n if (isImageAssetFilename(str)) {\n // Just a filename (projectId/dataset irrelevant: just need asset ID)\n return idFromUrl(cdnUrl + \"/images/a/b/\" + str);\n }\n\n throw new UnresolvableError(str);\n}\n/**\r\n * See {@link getIdFromString}\r\n *\r\n * @inheritFrom {@link getIdFromString}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetIdFromString = /*#__PURE__*/getForgivingResolver(getIdFromString);\n/**\r\n * Converts from a full asset URL to just the asset document ID\r\n *\r\n * @param url - A full asset URL to convert\r\n * @returns string\r\n */\n\nfunction idFromUrl(url) {\n var path = getUrlPath(url);\n\n var _path$split = path.split('/'),\n type = _path$split[0],\n fileName = _path$split[3];\n\n var prefix = type.replace(/s$/, '');\n return prefix + \"-\" + fileName.replace(/\\./g, '-');\n}\n/**\r\n * Resolves project ID and dataset the image belongs to, based on full URL or path\r\n * @param source - Image URL or path\r\n * @returns object | undefined\r\n *\r\n * @throws {@link UnresolvableError}\r\n * Throws if passed image source could not be resolved to an asset ID\r\n */\n\n\nfunction getProject(src) {\n var path = tryGetAssetPath(src);\n\n if (!path) {\n throw new UnresolvableError(src, 'Failed to resolve project ID and dataset from source');\n }\n\n var _ref = path.match(pathPattern) || [],\n projectId = _ref[2],\n dataset = _ref[3];\n\n if (!projectId || !dataset) {\n throw new UnresolvableError(src, 'Failed to resolve project ID and dataset from source');\n }\n\n return {\n projectId: projectId,\n dataset: dataset\n };\n}\n/**\r\n * See {@link getProject}\r\n *\r\n * @inheritFrom {@link getProject}\r\n * @returns Returns `undefined` instead of throwing if a value cannot be resolved\r\n */\n\nvar tryGetProject = /*#__PURE__*/getForgivingResolver(getProject);\n/**\r\n * Returns whether or not the passed filename is a valid image asset filename\r\n *\r\n * @param filename - Filename to validate\r\n * @returns Whether or not the filename is an image asset filename\r\n */\n\nfunction isImageAssetFilename(filename) {\n return imageAssetFilenamePattern.test(filename);\n}\n/**\r\n * Returns whether or not the passed filename is a valid file asset filename\r\n *\r\n * @param filename - Filename to validate\r\n * @returns Whether or not the filename is a file asset filename\r\n */\n\nfunction isFileAssetFilename(filename) {\n return fileAssetFilenamePattern.test(filename);\n}\n/**\r\n * Returns whether or not the passed filename is a valid file or image asset filename\r\n *\r\n * @param filename - Filename to validate\r\n * @returns Whether or not the filename is an asset filename\r\n */\n\nfunction isAssetFilename(filename) {\n return isImageAssetFilename(filename) || isFileAssetFilename(filename);\n}\n/**\r\n * Return whether or not the passed source is a file source\r\n *\r\n * @param src - Source to check\r\n * @returns Whether or not the given source is a file source\r\n */\n\nfunction isFileSource(src) {\n var assetId = tryGetAssetDocumentId(src);\n return assetId ? assetId.startsWith('file-') : false;\n}\n/**\r\n * Return whether or not the passed source is an image source\r\n *\r\n * @param src - Source to check\r\n * @returns Whether or not the given source is an image source\r\n */\n\nfunction isImageSource(src) {\n var assetId = tryGetAssetDocumentId(src);\n return assetId ? assetId.startsWith('image-') : false;\n}\n\n/**\r\n * Checks whether or not a given URL is a valid Sanity asset URL\r\n *\r\n * @param url URL to test\r\n * @returns True if url is a valid Sanity asset URL, false otherwise\r\n */\n\nfunction isSanityAssetUrl(url) {\n return getAssetUrlType(url) !== false;\n}\n/**\r\n * Checks whether or not a given URL is a valid Sanity image asset URL\r\n *\r\n * @param url URL to test\r\n * @returns True if url is a valid Sanity image asset URL, false otherwise\r\n */\n\nfunction isSanityImageUrl(url) {\n return getAssetUrlType(url) === 'image';\n}\n/**\r\n * Checks whether or not a given URL is a valid Sanity file asset URL\r\n *\r\n * @param url URL to test\r\n * @returns True if url is a valid Sanity file asset URL, false otherwise\r\n */\n\nfunction isSanityFileUrl(url) {\n return getAssetUrlType(url) === 'file';\n}\n\nexport { DEFAULT_CROP, DEFAULT_HOTSPOT, buildFilePath, buildFileUrl, buildImagePath, buildImageUrl, getAssetDocumentId, getAssetUrlType, getDefaultCrop, getDefaultHotspot, getExtension, getFile, getFileAsset, getIdFromString, getImage, getImageAsset, getImageDimensions, getProject, getUrlFilename, getUrlPath, isAssetFilename, isAssetId, isAssetIdStub, isAssetObjectStub, isAssetPathStub, isAssetUrlStub, isDefaultCrop, isDefaultHotspot, isFileAssetFilename, isFileAssetId, isFileSource, isImageAssetFilename, isImageAssetId, isImageSource, isObject, isReference, isSanityAssetUrl, isSanityFileAsset, isSanityFileUrl, isSanityImageAsset, isSanityImageUrl, isValidFilename, parseAssetFilename, parseAssetId, parseAssetUrl, parseFileAssetId, parseFileAssetUrl, parseImageAssetId, parseImageAssetUrl, tryGetAssetDocumentId, tryGetAssetPath, tryGetExtension, tryGetFile, tryGetFileAsset, tryGetIdFromString, tryGetImage, tryGetImageAsset, tryGetImageDimensions, tryGetProject, tryGetUrlFilename, tryGetUrlPath };\n//# sourceMappingURL=asset-utils.esm.js.map\n","import {client, projectParams} from './sanity-client';\nimport imageUrlBuilder from '@sanity/image-url';\nimport {getFileAsset} from '@sanity/asset-utils';\nimport {tryGetImageDimensions} from '@sanity/asset-utils';\n\n/**\n * Sanity image\n * @description returns image url given a Sanity image source object\n * @param {object} source\n * @param {number} width - optional\n * @param {number} height - optional\n * @return {string}\n */\nexport const sanityImage = function (\n source,\n isSrcSet,\n width = null,\n height = null,\n) {\n if (!source) return '';\n\n const builder = imageUrlBuilder(client);\n const widths = [\n 180,\n 360,\n 540,\n 720,\n 900,\n 1080,\n 1296,\n 1512,\n 1728,\n 1944,\n 2160,\n 2376,\n 2592,\n 2880,\n 3024,\n width,\n ];\n\n if (isSrcSet) {\n const srcArray = widths\n .sort((a, b) => a - b)\n .map((widthItem) => {\n if (width && widthItem > width) return null;\n\n const urlFor = builder\n .image(source)\n .auto('format')\n .width(widthItem)\n .url();\n return `${urlFor} ${widthItem}w`;\n });\n\n return srcArray.filter((src) => !!src).join(', ');\n }\n\n let urlFor = builder.image(source).auto('format');\n if (width) urlFor = urlFor.width(width);\n if (height) urlFor = urlFor.height(height);\n return urlFor.url();\n};\n\n/**\n * Sanity Asset\n * @param {Object} source\n * @returns Object\n */\nexport const sanityAsset = function (source) {\n if (!source || !source.asset) return false;\n\n const params = {\n ...projectParams,\n originalFilename: false,\n };\n\n return getFileAsset(source.asset, params);\n};\n\n/**\n * Sanity image dimensions\n * @description returns image dimensions object given a Sanity image source object\n * @param {object} source\n * @return {string}\n */\nexport const sanityImageDimensions = function (source) {\n return tryGetImageDimensions(source);\n};\n\n/**\n * Intrinsic ratio helper\n * @param {Object} source\n * @returns Object\n */\nexport const intrinsicRatio = function (source) {\n const imageDimensions = sanityImageDimensions(source);\n if (imageDimensions) {\n return {\n paddingBottom: `${100 / imageDimensions.aspectRatio}%`,\n };\n }\n return undefined;\n};\n\n/**\n * Get Video Opject\n * @description returns an object compatible with Shopify Video component\n * @param {Object} videoFile Sanity video asset object\n * @param {Object} imageFile Sanity image asset object\n * @param {String} alt\n * @returns {Object}\n */\nexport const getVideoObject = (\n videoFile,\n imageFile,\n display = '',\n alt = '',\n) => ({\n alt,\n id: videoFile._id,\n display,\n mediaContentType: 'EXTERNAL_VIDEO',\n height: imageFile?.dimensions?.height,\n previewImage: imageFile.src,\n width: imageFile?.dimensions?.width,\n sources: [\n {\n format: 'mp4',\n height: imageFile?.dimensions?.height,\n mimeType: `video/${videoFile.extension}`,\n url: videoFile.url,\n width: imageFile?.dimensions?.width,\n },\n ],\n});\n\n/**\n * Get Image Object\n * @description returns an combined object with src/srcset and image dimensions\n * @param {Object} source Sanity image source\n * @param {String} display tailwind display class\n * @param {Boolean} getSrcSet get full responsive srcset\n * @returns {Object}\n */\nexport const getImageObject = (source, display = '', getSrcSet = true) => {\n const imageDimensions = sanityImageDimensions(source);\n return {\n display,\n src:\n source && imageDimensions\n ? sanityImage(source, getSrcSet, imageDimensions?.width)\n : '',\n dimensions: imageDimensions,\n ref: source?._ref,\n };\n};\n"],"names":["global","factory","module","this","example","parseAssetId","ref","ref$1","id","dimensionString","format","ref$2","imgWidthStr","imgHeightStr","width","height","isValidAssetId","isRef","src","source","isAsset","isAssetStub","parseSource","image","isUrl","urlToId","img","applyDefaults","url","parts","result","SPEC_NAME_TO_URL_NAME_MAPPINGS","urlForImage","options","spec","asset","cropLeft","cropTop","crop","hotSpotVerticalRadius","hotSpotHorizontalRadius","hotSpotCenterX","hotSpotCenterY","hotspot","fit","specToImageUrl","cdnUrl","filename","baseUrl","params","left","top","isEffectiveCrop","flip","mapping","specName","param","cropRect","imgWidth","imgHeight","desiredAspectRatio","cropAspectRatio","hotspotXCenter","width$1","height$1","left$1","hotspotYCenter","top$1","validFits","validCrops","validAutoModes","isSanityClientLike","client","rewriteSpecName","key","specs","i","list","entry","urlBuilder","apiUrl","projectId","dataset","apiHost","ImageUrlBuilder","parent","newOptions","specKey","dataset$1","projectId$1","bg$1","dpr$1","x","y","maxWidth$1","minWidth$1","maxHeight$1","minHeight$1","blur$1","sharpen$1","format$1","invert$1","orientation$1","quality$1","download","value","saturation$1","pad$1","_inheritsLoose","subClass","superClass","_setPrototypeOf","_getPrototypeOf","o","p","_isNativeReflectConstruct","_construct","Parent","args","Class","a","Constructor","instance","_isNativeFunction","fn","_wrapNativeSuper","_cache","Wrapper","UnresolvableError","_Error","inputSource","message","_this","isUnresolvableError","err","error","getForgivingResolver","method","fileAssetFilenamePattern","imageAssetFilenamePattern","pathPattern","idPattern","isReference","isObject","isAssetIdStub","stub","isAssetPathStub","isAssetUrlStub","isAssetObjectStub","item","obj","getUrlPath","qsPos","toIndex","exampleImageId","parseImageAssetId","documentId","_documentId$split2","assetId","extension","_split$map","getImageDimensions","imageId","getAssetDocumentId","_parseImageAssetId","aspectRatio","tryGetImageDimensions","getIdFromString","idFromUrl","hasId","str","isFileAssetFilename","isImageAssetFilename","path","_path$split","type","fileName","prefix","sanityImage","isSrcSet","builder","imageUrlBuilder","widths","b","widthItem","urlFor","sanityImageDimensions","getImageObject","display","getSrcSet","imageDimensions"],"mappings":"4EAAC,SAAUA,EAAQC,EAAS,CACqCC,EAAiB,QAAAD,EAAO,CAGzF,GAAEE,EAAO,UAAY,CACnB,IAAIC,EAAU,+CACd,SAASC,EAAaC,EAAK,CACzB,IAAIC,EAAQD,EAAI,MAAM,GAAG,EACrBE,EAAKD,EAAM,GACXE,EAAkBF,EAAM,GACxBG,EAASH,EAAM,GAEnB,GAAI,CAACC,GAAM,CAACC,G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