/**
 * Editor-side registration for the `print-price/calculator` block.
 *
 * Vanilla JS on purpose — no JSX/webpack build step in this plugin yet.
 * Server-side rendered: the editor view is just a placeholder; the
 * actual widget renders on the frontend via the
 * print-price/calculator render_callback in print-price.php (which
 * delegates to the [print_price_widget] shortcode).
 */
( function ( wp ) {
	if ( ! wp || ! wp.blocks || ! wp.element ) {
		return;
	}

	var registerBlockType = wp.blocks.registerBlockType;
	var el = wp.element.createElement;
	var __ = ( wp.i18n && wp.i18n.__ ) ? wp.i18n.__ : function ( s ) { return s; };

	registerBlockType( 'print-price/calculator', {
		edit: function () {
			return el(
				'div',
				{
					style: {
						border: '2px dashed #c5c9cc',
						padding: '24px',
						textAlign: 'center',
						color: '#555',
						background: '#f6f7f7',
						borderRadius: '4px',
						fontFamily: 'system-ui, -apple-system, sans-serif',
					},
				},
				[
					el(
						'div',
						{ key: 'title', style: { fontWeight: 600, fontSize: '15px', marginBottom: '6px', color: '#1d2327' } },
						__( 'PrintPrice Calculator', 'printprice-3d-calculator' )
					),
					el(
						'div',
						{ key: 'sub', style: { fontSize: '13px' } },
						__( 'STL / OBJ / 3MF upload + price quote. Renders on the live page.', 'printprice-3d-calculator' )
					),
				]
			);
		},
		// No save() output — render_callback in PHP produces the frontend HTML.
		save: function () { return null; },
	} );
} )( window.wp );
