link_view = (
  url0,
  label,
  popup,
  link_style = "",
  link_size = "",
  link_icon = "",
  textStyle = "",
  link_bgcol,
  link_bordercol,
  link_textcol,
  extraClass,
  extraState,
  link_target_blank,
  label_attr, // for sorting
  link_title,
  link_class,
  req,
  in_row_click
) => {
  let style =
    link_style === "btn btn-custom-color"
      ? `background-color: ${link_bgcol || "#000000"};border-color: ${
          link_bordercol || "#000000"
        }; color: ${link_textcol || "#000000"}`
      : null;
  let url = url0;
  if (extraState) {
    if (url.includes("?")) url = `${url0}&${extraState}`;
    else url = `${url0}?${extraState}`;
  }
  if (popup) {
    let ajaxOpts = "";
    if (typeof popup === "object")
      ajaxOpts = `, {${Object.entries(popup)
        .map(([k, v]) => `'${k}': '${v}'`)
        .join(",")}}`;
    const stopProp = in_row_click ? ";event.stopPropagation()" : "";
    if (!link_style)
      return a(
        {
          ...(label_attr ? { "data-link-label": text_attr(label) } : {}),
          href: `javascript:void(0)`,
          onclick: isNode()
            ? `ajax_modal('${url}'${ajaxOpts})` + stopProp
            : `mobile_modal('${url}'${ajaxOpts})` + stopProp,
          style,
          title: link_title,
          class: [textStyle, link_style, link_size, extraClass, link_class],
        },
        show_icon_and_label(link_icon, label)
      );
    else
      return button(
        {
          ...(label_attr ? { "data-link-label": text_attr(label) } : {}),
          class: [
            textStyle,
            link_style,
            link_size,
            !link_style && "btn btn-link",
            extraClass,
            link_class,
          ],
          title: link_title,
          type: "button",
          onClick: isNode()
            ? `ajax_modal('${url}'${ajaxOpts})` + stopProp
            : `mobile_modal('${url}')` + stopProp,
          style,
        },
        show_icon_and_label(link_icon, label)
      );
  } else if (req?.generate_email && (link_style || "").includes("btn")) {
    return mjml.emailButton(
      {
        href: url,
        title: link_title,
        btnStyle: link_style,
        style,
      },
      label
    );
  } else
    return a(
      {
        ...(label_attr ? { "data-link-label": text_attr(label) } : {}),
        href: url,
        class: [textStyle, link_style, link_size, extraClass, link_class],
        style,
        title: link_title,
        onclick: in_row_click ? "event.stopPropagation()" : undefined,
        target: link_target_blank ? "_blank" : undefined,
      },
      show_icon_and_label(link_icon, label)
    );
}
@param {string} url0
@param {string} label
@param {boolean} [popup]
@param {string} [link_style = ""]
@param {string} [link_size = ""]
@param {string} [link_icon = ""]
@param {string} [textStyle = ""]
@param {string} [link_bgcol]
@param {string} [link_bordercol]
@param {string} [link_textcol]
@param extraClass
@param extraState
@param link_target_blank
@returns {button|a}