<form class="mass-edit-randomizer-form">

    {{#if numberForm}}
    <div class="form-group slim">
        <label>{{localize "MassEdit.common.range"}}</label>
        <div class="form-fields">
            <label>{{localize "MassEdit.common.min"}}</label>
            <input type="number" value="{{min}}" step="any" name="min">
            <label>{{localize "MassEdit.common.max"}}</label>
            <input type="number" value="{{max}}" step="any" name="max">
        </div>
    </div>
    <div class="form-group">
        <label>Step Size</label>
        <input type="number" value="{{step}}" step="any" name="step">
    </div>
    <div class="form-group">
        <label>{{localize "MassEdit.common.random"}}</label>
        <select name="method" data-dtype="string">
            <option value="random" {{#if (eq method "random")}}selected="selected"{{/if}}>{{localize "MassEdit.common.random"}}</option>
            <option value="interpolate" {{#if (eq method "interpolate")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.interpolate"}}</option>
            <option value="interpolateReverse" {{#if (eq method "interpolateReverse")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.interpolateReverse"}}</option>
        </select>
    </div>
    {{/if}}

    {{#if rangeForm}}
    <div class="form-group slim">
        <label>{{localize "MassEdit.common.min"}}</label>
        <div class="form-fields">
            <input type="range" name="min" value="{{minVal}}" min="{{min}}" max="{{max}}" step="{{step}}">
            <span class="range-value">{{minVal}}</span>
        </div>
    </div>
    <div class="form-group slim">
        <label>{{localize "MassEdit.common.max"}}</label>
        <div class="form-fields">
            <input type="range" name="max" value="{{maxVal}}" min="{{min}}" max="{{max}}" step="{{step}}">
            <span class="range-value">{{maxVal}}</span>
        </div>
    </div>
    <input type="hidden" value="{{step}}" name="step">
    <div class="form-group">
        <label>{{localize "MassEdit.common.method"}}</label>
        <select name="method" data-dtype="string">
            <option value="random" {{#if (eq method "random")}}selected="selected"{{/if}}>{{localize "MassEdit.common.random"}}</option>
            <option value="interpolate" {{#if (eq method "interpolate")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.interpolate"}}</option>
            <option value="interpolateReverse" {{#if (eq method "interpolateReverse")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.interpolateReverse"}}</option>
        </select>
    </div>
    {{/if}}

    {{#if selectForm}}
    <select name="{{fieldName}}" data-dtype="{{dtype}}" multiple="multiple">
        {{#each options as |option|}}
            <option value="{{option.value}}" {{#if option.selected}}selected="selected"{{/if}}>{{option.label}}</option>
        {{/each}}
    </select>
    {{/if}}

    {{#if booleanForm}}
    <p>Randomize <b>[</b> {{title}} <b>]</b> checkbox?</p>
    {{/if}}

    {{#if colorForm}}
    {{>me-color}}
    {{/if}}

    {{#if imageForm}}
    <div class="image-controls">
        <div class="form-group slim">
            <label>{{localize "MassEdit.randomizer.addImagesToList"}}</label>
            <div class="form-fields">
                {{#if tokenVariantsActive}}
                <button class="token-variants" type="button" title="Token Variant Art" tabindex="-1">
                    <i class="fas fa-images"></i>
                </button>
                {{/if}}
                <label>{{localize "MassEdit.randomizer.selectFolder"}}</label>
                <button type="button" class="folder-picker" data-type="imagevideo" title="Browse Folders" tabindex="-1">
                    <i class="fas fa-file-import fa-fw"></i>
                </button>
                <label>{{localize "MassEdit.randomizer.includeSubfolders"}}</label>
                <input class="subfolders" type="checkbox" checked="checked">
            </div>
        </div>
        <div><p class="notes">{{localize "MassEdit.randomizer.listOfImages"}}:</p></div>
        <textarea class="images" name="images" rows="4" cols="50">{{images}}</textarea>
        {{#if isTile}}
        <label>Maintain Aspect Ratio</label>
        <input name="maintainAspect" type="checkbox" {{#if maintainAspect}}checked{{/if}}>
        {{/if}}
    </div>
    <div class="find-and-replace" hidden>
        <div class="form-group">
            <label>{{localize "MassEdit.common.find"}}</label>
            <input name="find" type="text" value="{{find}}">
        </div>
        <div class="form-group">
            <label>{{localize "MassEdit.common.replace"}}</label>
            <input name="replace" type="text" value="{{replace}}">
        </div>
    </div>
    <div class="form-group">
        <label>{{localize "MassEdit.common.method"}}</label>
        <select name="method" data-dtype="string">
            <option value="random" {{#if (eq method "random")}}selected="selected"{{/if}}>{{localize "MassEdit.common.random"}}</option>
            <option value="sequential" {{#if (eq method "sequential")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.sequential"}}</option>
            <option value="findAndReplace" {{#if (eq method "findAndReplace")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.findAndReplace"}}</option>
            <option value="findAndReplaceRegex" {{#if (eq method "findAndReplaceRegex")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.findAndReplaceRegex"}}</option>
        </select>
    </div>
    {{/if}}

    {{#if textForm}}

    <div class="form-group">
        <label>{{localize "MassEdit.common.method"}}</label>
        <select name="method" data-dtype="string">
            <option value="list" {{#if (eq method "list")}}selected="selected"{{/if}}>{{localize "MassEdit.common.list"}}</option>
            <option value="findAndReplace" {{#if (eq method "findAndReplace")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.findAndReplace"}}</option>
            <option value="findAndReplaceRegex" {{#if (eq method "findAndReplaceRegex")}}selected="selected"{{/if}}>{{localize "MassEdit.randomizer.findAndReplaceRegex"}}</option>
        </select>
    </div>
    <div class="find-and-replace" hidden>
        <div class="form-group">
            <label>{{localize "MassEdit.common.find"}}</label>
            <input name="find" type="text" value="{{find}}">
        </div>
        <div class="form-group">
            <label>{{localize "MassEdit.common.replace"}}</label>
            <input name="replace" type="text" value="{{replace}}">
        </div>
    </div>
    <div class="string-list">
        <div class="form-group">
            <label>{{localize "MassEdit.randomizer.generators"}}</label>
            <select class="generator" data-dtype="String">
                {{#each generators}}
                <optgroup label="{{@key}}">
                    {{#each this as |gen|}}
                        <option value="{{gen.func}}">{{gen.label}}</option>
                    {{/each}}
                </optgroup>
                {{/each}}
            </select>
            <button type="button" class="generate" title="{{localize "MassEdit.common.generate"}}" tabindex="-1">
                <i class="fas fa-dice"></i>
            </button>
        </div>

        <div><p class="notes">{{localize "MassEdit.randomizer.listOfStrings"}}:</p></div>
        <textarea class="strings" name="strings" rows="4" cols="50">{{strings}}</textarea>

        <div class="form-group slim">
            <label>{{localize "MassEdit.randomizer.allowDuplicates"}}</label>
            <input class="duplicates" type="checkbox" {{#if duplicates}}checked{{/if}}>
        </div>
    </div>

    {{/if}}

    {{#if coordinateForm}}
    <div class="form-group slim">
        <label>{{localize "MassEdit.common.range"}} X</label>
        <div class="form-fields">
            <label>{{localize "MassEdit.common.min"}}</label>
            <input type="number" value="{{minX}}" name="minX" step="any">
            <label>{{localize "MassEdit.common.max"}}</label>
            <input type="number" value="{{maxX}}" name="maxX" step="any">
        </div>
    </div>

    <div class="form-group slim">
        <label>{{localize "MassEdit.common.range"}} Y</label>
        <div class="form-fields">
            <label>{{localize "MassEdit.common.min"}}</label>
            <input type="number" value="{{minY}}" name="minY" step="any">
            <label>{{localize "MassEdit.common.max"}}</label>
            <input type="number" value="{{maxY}}" name="maxY" step="any">
        </div>
    </div>

    <div class="form-group slim">
        <label>{{localize "MassEdit.randomizer.stepSize"}}</label>
        <div class="form-fields">
            <label>X</label>
            <input type="number" value="{{stepX}}" name="stepX" step="any">
            <label>Y</label>
            <input type="number" value="{{stepY}}" name="stepY" step="any">
        </div>
    </div>

    <div class="form-group">
        <label>{{localize "MassEdit.randomizer.pickRange"}}</label>
        <button type="button" class="pickBounds" tabindex="-1"><i class="fas fa-crosshairs"></i></button>
    </div>

    <div class="form-group">
        <label>{{localize "MassEdit.randomizer.snapToGrid"}}</label>
        <button type="button" class="snapToGrid" tabindex="-1"><i class="fas fa-vector-square"></i></button>
    </div>
    
    {{/if}}

    <footer class="sheet-footer flexrow" style="margin-top: auto;">
        <button type="submit"><i class="fas fa-dice"></i>{{localize "MassEdit.common.apply"}}</button>
        {{#if existing}}
        <button type="submit" value="delete"><i class="fas fa-trash"></i>{{localize "MassEdit.common.delete"}}</button>
        {{/if}}
    </footer>
</form>