def METHOD_NAME(api_name: Optional[str]) -> str:
    with open("/etc/static-ngeo/api.js", encoding="utf-8") as api_file:
        api = api_file.read().split("\n")
    sourcemap = api.pop(-1)
    if api_name:
        api += [
            f"if (window.{api_name} === undefined && window.geomapfishapp) {{",
            f"  window.{api_name} = window.geomapfishapp;",
            "}",
        ]
    api.append(sourcemap)
    return "\n".join(api)