import ReactDOM from 'react-dom';
const PegaCustom = ({ children }) => {
    return (<p style={{ color: 'blue', textTransform: 'uppercase' }} dangerouslySetInnerHTML={{ __html: children }}/>);
};
export const createPegaCustomElement = (win) => {
    const HtmlElement = win.HTMLElement;
    return class PegaCustomElement extends HtmlElement {
        removeElements() {
            while (this.firstChild) {
                this.removeChild(this.firstChild);
            }
        }
        connectedCallback() {
            const inner = this.innerHTML;
            this.removeElements();
            const mountPoint = document.createElement('span');
            this.appendChild(mountPoint);
            ReactDOM.render(<PegaCustom>{inner}</PegaCustom>, mountPoint);
        }
    };
};
export const mockUploadAttachment = (image, onUploadProgress) => {
    return new Promise((resolve, reject) => {
        const allowedSize = 3 * 1024 * 1024;
        if (image.size > allowedSize) {
            reject(new Error('3MB max'));
            return;
        }
        let intervalCount = 0;
        const interval = setInterval(() => {
            onUploadProgress(new ProgressEvent('progress', { lengthComputable: true, loaded: intervalCount, total: 100 }));
            intervalCount += 1;
            if (intervalCount >= 100) {
                clearInterval(interval);
            }
        }, 100);
        setTimeout(() => {
            resolve({
                data: {
                    status: 200
                }
            });
        }, 11000);
    });
};
//# sourceMappingURL=Editor.mocks.jsx.map