function transformImportAssertions({ types: t }) {
	return {
		name: 'transform-import-assertions',
		visitor: {
			ImportExpression(path) {
				const args = path.node.arguments;
				if (!args || !args.length) return;
				if (!t.isObjectExpression(args[0])) return;

				if (!args[0].properties) return;
				for (let i = 0; i < args[0].properties.length; i++) {
					const prop = args[0].properties[i];

					if (!t.isIdentifier(prop.key) || prop.key.name !== 'assert') {
						continue;
					}

					if (!t.isObjectExpression(prop.value) || !prop.value.properties || !prop.value.properties.length) {
						continue;
					}

					const innerProp = prop.value.properties[0];
					if (!t.isIdentifier(innerProp.key) || innerProp.key.name !== 'type') {
						continue;
					}

					const type = innerProp.value.value;
					path.replaceWith(t.importExpression(t.stringLiteral(`${type}:${path.node.source.value}`)));
				}
			},
			ImportDeclaration(path) {
				const { assertions } = path.node;
				if (assertions && assertions.length > 0) {
					for (let i = 0; i < assertions.length; i++) {
						const node = assertions[i];
						if (t.isImportAttribute(node) && t.isIdentifier(node.key) && node.key.name === 'type') {
							const type = node.value.value;
							path.replaceWith(
								t.importDeclaration(path.node.specifiers, t.stringLiteral(`${type}:${path.node.source.value}`))
							);
						}
					}
				}
			}
		}
	};
}
@type {import('../lib/acorn-traverse').Plugin}