:root {
    /* List of file filters used in the URL chooser toolbar */
    --file-filters: "gif, jpg, jpeg, bmp, png, svg, svgz, wmf, mathml, mml, cgm, tif, tiff, eps, ai, pdf, psd";

    /* Default toolbar configuration for images with @keyref */
    --default-toolbar-keyref: 
        oxy_label(text, " keyref: ")
        oxy_combobox(edit, '@keyref', editable, false);

    /* Default toolbar configuration for images with @href */
    --default-toolbar-href: 
        oxy_urlChooser(edit, '@href', columns, 25, fileFilter, var(--file-filters));

    /* “Generate Alternate Text” button used when the alt text is missing */
    --toolbar-gen-alt-btn: 
    oxy_button(
        action, 
        oxy_action(
            name, 'Generate Alternate Text',
            icon, url('img/AlternateText16.png')
            description, 'Generate alternate text for this image using AI.', 
            operation, 'XSLTOperation', 
            arg-script, '${framework(Image Alternate Text Generation)}/image-alt-text.xsl', 
            arg-action, 'Replace', 
            arg-sourceLocation, 'oxy:current-selected-element()', 
            arg-targetLocation, 'oxy:current-selected-element()'),
        showIcon, true
    );
}

/* Keyref – non-empty alt */
dita image:has(alt)[keyref]:-oxy-selected,
:root[class~='topic/topic'] image:has(alt)[keyref]:-oxy-selected,
dita image[alt][keyref]:-oxy-selected,
:root[class~='topic/topic'] image[alt][keyref]:-oxy-selected {
    -oxy-floating-toolbar: var(--default-toolbar-keyref);
}

/* Href – non-empty alt */
dita image:has(alt):not([keyref]):-oxy-selected,
:root[class~='topic/topic'] image:has(alt):not([keyref]):-oxy-selected,
dita image[alt]:not([keyref]):-oxy-selected,
:root[class~='topic/topic'] image[alt]:not([keyref]):-oxy-selected {
    -oxy-floating-toolbar: var(--default-toolbar-href);
}

/* Keyref - missing alt text */
dita image[keyref]:-oxy-selected,
:root[class~='topic/topic'] image[keyref]:-oxy-selected,
dita image[alt=""][keyref]:-oxy-selected,
:root[class~='topic/topic'] image[alt=""][keyref]:-oxy-selected,
dita image:has(alt:empty)[keyref]:-oxy-selected,
:root[class~='topic/topic'] image:has(alt:empty)[keyref]:-oxy-selected {
    -oxy-floating-toolbar: var(--default-toolbar-href) '|' var(--toolbar-gen-alt-btn);
}

/* Href - missing alt text */
dita image:not([keyref]):-oxy-selected,
:root[class~='topic/topic'] image:not([keyref]):-oxy-selected,
dita image[alt=""]:not([keyref]):-oxy-selected,
:root[class~='topic/topic'] image[alt=""]:not([keyref]):-oxy-selected,
dita image:has(alt:empty):not([keyref]):-oxy-selected,
:root[class~='topic/topic'] image:has(alt:empty):not([keyref]):-oxy-selected {
    -oxy-floating-toolbar: var(--default-toolbar-href) '|' var(--toolbar-gen-alt-btn);
}