/* @oracle/oraclejet-preact: undefined */
'use strict';

var preact = require('@testing-library/preact');
var chai = require('chai');

/**
 * @license
 * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 * @ignore
 */
function getDndCallbacks(callbacks, dragStartCallback, dropCallback) {
    return {
        onDragStart: (detail) => {
            callbacks.startCalled = true;
            dragStartCallback(detail);
        },
        onDragEnter: (detail) => {
            if (detail.event) {
                callbacks.enterCalled = true;
                detail.event.preventDefault();
            }
        },
        onDragOver: (detail) => {
            callbacks.overCalled = true;
            const accept = dropCallback(detail);
            if (accept)
                detail.event.preventDefault();
        },
        onDrop: (detail) => {
            callbacks.dropCalled = true;
            dropCallback(detail);
        }
    };
}
function testDnd(dragTarget, dropTarget, feedbackTarget, callbacks, isSVG, dropOptions, rejected) {
    preact.fireEvent.dragStart(dragTarget);
    preact.fireEvent.dragEnter(dropTarget, dropOptions);
    preact.fireEvent.dragOver(dropTarget, dropOptions);
    const styles = window.getComputedStyle(feedbackTarget);
    const fill = styles.getPropertyValue(isSVG ? 'fill' : 'background-color');
    chai.expect(fill).to.be.equal(rejected ? 'rgba(0, 0, 0, 0)' : 'rgb(208, 229, 238)');
    const cursor = styles.getPropertyValue('cursor');
    chai.expect(cursor).to.be.equal(rejected ? 'no-drop' : 'auto');
    preact.fireEvent.drop(dropTarget, dropOptions);
    chai.expect(callbacks.dragDetailCorrect).to.be.true;
    chai.expect(callbacks.startCalled).to.be.true;
    chai.expect(callbacks.enterCalled).to.be.true;
    chai.expect(callbacks.overCalled).to.be.true;
    chai.expect(callbacks.dropCalled).to.be.true;
    if (rejected) {
        chai.expect(callbacks.dropDetailCorrect).to.be.false;
    }
    else {
        chai.expect(callbacks.dropDetailCorrect).to.be.true;
    }
}

exports.getDndCallbacks = getDndCallbacks;
exports.testDnd = testDnd;
//# sourceMappingURL=dndUtils-f0693dd5.js.map
