/*
typeof foo becomes

(function(){
    try {
        return foo.typeof ? foo.typeof : typeof foo
    } catch(e) {
        return typeof foo
    }
})()
*/
module.exports = (foo) => ({
	"type": "CallExpression",
	"autogenerated": true,
	"callee": {
		"type": "FunctionExpression",
		"id": null,
		"params": [],
		"defaults": [],
		"body": {
			"type": "BlockStatement",
			"body": [
				{
					"type": "TryStatement",
					"block": {
						"type": "BlockStatement",
						"body": [
							{
								"type": "ReturnStatement",
								"argument": {
									"type": "ConditionalExpression",
									"test": {
										"type": "MemberExpression",
										"computed": false,
										"object": foo,
										"property": {
											"type": "Identifier",
											"name": "typeof",
										},
									},
									"consequent": {
										"type": "MemberExpression",
										"computed": false,
										"object": foo,
										"property": {
											"type": "Identifier",
											"name": "typeof",
										},
									},
									"alternate": {
										"type": "UnaryExpression",
										"operator": "typeof",
										"argument": foo,
										"prefix": true,
									},
								},
							},
						],
					},
					"guardedHandlers": [],
					"handlers": [
						{
							"type": "CatchClause",
							"param": {
								"type": "Identifier",
								"name": "e",
							},
							"body": {
								"type": "BlockStatement",
								"body": [
									{
										"type": "ReturnStatement",
										"argument": {
											"type": "UnaryExpression",
											"operator": "typeof",
											"argument": foo,
											"prefix": true,
										},
									},
								],
							},
						},
					],
					"handler": {
						"type": "CatchClause",
						"param": {
							"type": "Identifier",
							"name": "e",
						},
						"body": {
							"type": "BlockStatement",
							"body": [
								{
									"type": "ReturnStatement",
									"argument": {
										"type": "UnaryExpression",
										"operator": "typeof",
										"argument": foo,
										"prefix": true,
									},
								},
							],
						},
					},
					"finalizer": null,
				},
			],
		},
		"generator": false,
		"expression": false,
	},
	"arguments": [],
});