function n(n,r){if(!n)return n;const t=function(n){try{return new URL(n)}catch{return null}}(n);if(!t)return n;if("res.cloudinary.com"!==t.hostname)return n;const u=t.pathname.split("/"),o=u.indexOf("upload");if(-1===o||"image"!==u[o-1])return n;if((u[o+1]||"").split(",").some((n=>n.startsWith("f_")||n.startsWith("q_"))))return n;const i=[];return(null==r?void 0:r.width)&&i.push(`w_${r.width}`),(null==r?void 0:r.height)&&i.push(`h_${r.height}`),(null==r?void 0:r.width)||(null==r?void 0:r.height)||i.push("c_limit","w_3840"),i.push("f_auto","q_auto"),u.splice(o+1,0,i.join(",")),t.pathname=u.join("/"),t.toString()}export{n as o}