/* @oracle/oraclejet-preact: undefined */
import { fireEvent } from '@testing-library/preact';
import { expect } from '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) {
    fireEvent.dragStart(dragTarget);
    fireEvent.dragEnter(dropTarget, dropOptions);
    fireEvent.dragOver(dropTarget, dropOptions);
    const styles = window.getComputedStyle(feedbackTarget);
    const fill = styles.getPropertyValue(isSVG ? 'fill' : 'background-color');
    expect(fill).to.be.equal(rejected ? 'rgba(0, 0, 0, 0)' : 'rgb(208, 229, 238)');
    const cursor = styles.getPropertyValue('cursor');
    expect(cursor).to.be.equal(rejected ? 'no-drop' : 'auto');
    fireEvent.drop(dropTarget, dropOptions);
    expect(callbacks.dragDetailCorrect).to.be.true;
    expect(callbacks.startCalled).to.be.true;
    expect(callbacks.enterCalled).to.be.true;
    expect(callbacks.overCalled).to.be.true;
    expect(callbacks.dropCalled).to.be.true;
    if (rejected) {
        expect(callbacks.dropDetailCorrect).to.be.false;
    }
    else {
        expect(callbacks.dropDetailCorrect).to.be.true;
    }
}

export { getDndCallbacks as g, testDnd as t };
//# sourceMappingURL=dndUtils-9fb07485.js.map
