const targets = canvas.tokens.controlled;
const extra = { flavor: "Sanctuary!" }
const spellEffect = game.macros.getName("ApplySpellEffect");
const label = "Smite";
const id = "smite";
const icon = "systems/swade/assets/icons/status/status_smite.svg";
const duration = 5;

main();

async function main() {
    let effect = {
        changes: [
        ],
        duration: { rounds: duration },
        icon: icon,
        label: label,
        id: id
    }

    let applyChanges = false;
    let d = new Dialog({
        title: `Applying ${label} effects`,
        content: `Apply ${label} with raise?`,
        buttons: {
            raise: {
                icon: '<i class="fas fa-arrow-alt-circle-up"></i>',
                label: 'With raise',
                callback: () => {
                    applyChanges = true;
                    effect.label = effect.label + " with raise";
                }
            },
            noraise: {
                icon: '<i class="fas fa-arrow-alt-circle-right"></i>',
                label: 'Normal Success',
                callback: () => { applyChanges = true }
            }
        },
        default: "noraise",
        close: html => {
            if (applyChanges) {
                let value = await spellEffect.execute(effect, targets, extra);
                return value;
            }
        }
    });
    d.render(true);
}