/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-explicit-any */
// #region Imports
import { nothing } from 'lit';
import { directive, PartType } from 'lit/directive.js';
import { DirectiveBase } from '../../Controls/Directives/Abstracts/DirectiveBase';
/**
 * Lit Directive for custom drag placeholder templates.
 * Defines the element that remains in place while dragging.
 *
 * @internal
 */
class DragPlaceholderDirective extends DirectiveBase {
    // #region Fields
    _placeholderElement = null;
    _lastConfig = null;
    // #endregion
    // #region Ctor
    /**
     * @param args - Directive args.
     */
    constructor(args) {
        super(args);
        // Validate part type
        if (args.type !== PartType.ELEMENT) {
            throw new Error('dragPlaceholder() directive can only be used on elements');
        }
    }
    // #endregion
    // #region Methods
    /**
     * Render method.
     *
     * @param config - Configuration.
     */
    render(_config) {
        return nothing;
    }
    update(part, [config]) {
        const element = part.element;
        // Store reference
        this._placeholderElement = element;
        this._lastConfig = config ?? null;
        element.setAttribute('data-drag-placeholder', '');
        element.style.display = 'none';
        // Store data directly as property (not serialized)
        if (config?.data !== undefined) {
            element.__placeholderData = config.data;
        }
        return this.render(config);
    }
}
// #endregion
/**
 * Define a custom drag placeholder template.
 * The element with this directive will be cloned and shown in place of the dragged element.
 *
 * @param config - Configuration options.
 * @returns Directive.
 *
 * @public
 *
 * @example
 * ```typescript
 * html`
 *   <div ${drag()}>
 *     <div ${dragPlaceholder()}>
 *       <div class="placeholder-style">Drop here...</div>
 *     </div>
 *     <div>Actual content</div>
 *   </div>
 * `
 * ```
 */
export const dragPlaceholder = directive(DragPlaceholderDirective);
//# sourceMappingURL=DragPlaceholderDirective.js.map