define('bitbucket/internal/feature/audit-log/audit-log-table',
    ['jquery', 'bitbucket/internal/widget/paged-table'],
    function($, PagedTable) {

        function AuditLogTable(getAuditLogUrlBuilder, options) {
            this.getAuditLogUrlBuilder = getAuditLogUrlBuilder;

            var defaults = {
                bufferPixels: 150,
                target: '.audit-log-table',
                tableMessageClass: 'audit-log-table-message',
                allFetchedMessageHtml: bitbucket.internal.feature.auditLog.allFetchedMessage()
            };

            options = $.extend({}, defaults, options);
            PagedTable.call(this, options);
        }

        $.extend(AuditLogTable.prototype, PagedTable.prototype);

        AuditLogTable.prototype.buildUrl = function(start, limit) {
            return this.getAuditLogUrlBuilder().withParams({
                start: start,
                limit: limit,
                avatarSize: bitbucket.internal.widget.avatarSizeInPx({ size: 'xsmall' })
            }).build();
        };

        AuditLogTable.prototype.handleNewRows = function(data, attachmentMethod) {
            var html = bitbucket.internal.feature.auditLog.auditLogRows({ values: data.values });
            this.$table.children('tbody')[attachmentMethod](html);
        };

        return AuditLogTable;

    });