import { getAssetPath } from "@stencil/core";
import { getLocationBase } from "./environment";
const relativeAssetsPath = '../../assets';
export const createAssetUrlSafely = (file, pathFromAssetRoot) => {
    const relativeAssetPath = joinPath(relativeAssetsPath, pathFromAssetRoot, file);
    try {
        return getAssetPath(relativeAssetPath);
    }
    catch {
        console.warn(`Failed to create URL for asset "${file}" in path "${pathFromAssetRoot}".
           Please provide an absolute URL in your app's 'setAssetPath(...)' configuration! Falling back to a relative URL, which may work in some environments but is not guaranteed to be correct.`);
        return new URL(relativeAssetPath, getLocationBase());
    }
};
function joinPath(...parts) {
    return parts.filter(Boolean).join('/').replace('//', '/').replace('/./', '/');
}
