{
    "tailapp": 2,
    "manifest": {
        "format": 2,
        "app_id": "battery",
        "name": "Battery",
        "version": 1,
        "schema": "tailapps/v0",
        "exported_at": 1795904004,
        "from": "gallery",
        "connections": [],
        "files": {
            "app.json": "b0dff4ccb8dcd50b0de5bae768a5e607bb61f1e00b2964312cd0e6eec4cd1dc8"
        },
        "signature": "IaVRfQUkNWV5KwGszHPQG3VzVNyY8lgD6YeMrEZE0d2zpIdJFvbkrP+wUbOrC4EDLhryPyu95jnnpe5NzbA1BQ==",
        "key_id": "gallery-1"
    },
    "app": {
        "schema": "tailapps/v0",
        "app": "battery",
        "name": "Battery",
        "description": "Your battery in the menu bar with its health, cycles and temperature, your AirPods, mouse and keyboard, and alerts when it's low, charged enough or the charger goes in or out.",
        "icon": "battery.75percent",
        "version": 1,
        "permissions": [
            "power.read",
            "bluetooth.read",
            "notify"
        ],
        "state": {
            "warn_low": {
                "type": "bool",
                "default": true
            },
            "low_at": {
                "type": "number",
                "default": 20
            },
            "warn_high": {
                "type": "bool",
                "default": false
            },
            "high_at": {
                "type": "number",
                "default": 80
            },
            "warn_plug": {
                "type": "bool",
                "default": false
            },
            "sound": {
                "type": "text",
                "default": "alert"
            },
            "warned": {
                "type": "text",
                "default": ""
            },
            "plug": {
                "type": "text",
                "default": ""
            },
            "icon": {
                "type": "text",
                "default": "battery.75percent"
            },
            "gear": {
                "type": "list",
                "default": [],
                "sync": true
            },
            "mac": {
                "type": "object",
                "default": [],
                "sync": true
            },
            "phone": {
                "type": "object",
                "default": [],
                "sync": true
            }
        },
        "sources": {
            "power": {
                "system": "power",
                "on_change": {
                    "action": "check",
                    "watch": "{$power.battery} {$power.status}"
                }
            },
            "me": {
                "system": "device"
            },
            "bt": {
                "system": "bluetooth",
                "every": 120,
                "platforms": [
                    "macos"
                ],
                "on_change": "keep_gear"
            },
            "mac_now": {
                "system": "power",
                "platforms": [
                    "macos"
                ],
                "on_change": {
                    "action": "keep_mac",
                    "watch": "{$mac_now.battery} {$mac_now.status}"
                }
            },
            "phone_now": {
                "system": "power",
                "platforms": [
                    "ios"
                ],
                "on_change": {
                    "action": "keep_phone",
                    "watch": "{$phone_now.battery} {$phone_now.status}"
                }
            }
        },
        "actions": {
            "check": {
                "steps": [
                    {
                        "if": "$power.has_battery",
                        "then": [
                            {
                                "if": "$power.on_ac",
                                "then": [
                                    {
                                        "if": "$plug | map:{off:true, else:false}",
                                        "then": [
                                            {
                                                "if": "$warn_plug",
                                                "then": [
                                                    {
                                                        "notify": {
                                                            "title": "Charger connected",
                                                            "body": "Battery at {$power.battery}%"
                                                        }
                                                    },
                                                    {
                                                        "if": "$sound | map:{none:false, else:true}",
                                                        "then": [
                                                            {
                                                                "sound": "$sound"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                "else": [
                                    {
                                        "if": "$plug | map:{on:true, else:false}",
                                        "then": [
                                            {
                                                "if": "$warn_plug",
                                                "then": [
                                                    {
                                                        "notify": {
                                                            "title": "Charger disconnected",
                                                            "body": "Battery at {$power.battery}%{$power.time_left | map:{null:'', else:', '}}{$power.time_left | duration}{$power.time_left | map:{null:'', else:' left'}}"
                                                        }
                                                    },
                                                    {
                                                        "if": "$sound | map:{none:false, else:true}",
                                                        "then": [
                                                            {
                                                                "sound": "$sound"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                "set": {
                                    "plug": "$power.on_ac | map:{true:'on', else:'off'}"
                                }
                            },
                            {
                                "if": "$power.battery | times:-1 | add:$low_at | tone:{good:'>=0', else:'bad'} | map:{good:true, else:false}",
                                "then": [
                                    {
                                        "if": "$power.on_ac | map:{true:false, else:true}",
                                        "then": [
                                            {
                                                "if": "$warned | map:{low:false, else:true}",
                                                "then": [
                                                    {
                                                        "if": "$warn_low",
                                                        "then": [
                                                            {
                                                                "notify": {
                                                                    "title": "Battery low",
                                                                    "body": "{$power.battery}% left. Time to plug in."
                                                                }
                                                            },
                                                            {
                                                                "if": "$sound | map:{none:false, else:true}",
                                                                "then": [
                                                                    {
                                                                        "sound": "$sound"
                                                                    }
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "set": {
                                                            "warned": "low"
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                "else": [
                                    {
                                        "if": "$power.battery | times:-1 | add:$high_at | tone:{good:'<=0', else:'bad'} | map:{good:true, else:false}",
                                        "then": [
                                            {
                                                "if": "$power.on_ac",
                                                "then": [
                                                    {
                                                        "if": "$warned | map:{high:false, else:true}",
                                                        "then": [
                                                            {
                                                                "if": "$warn_high",
                                                                "then": [
                                                                    {
                                                                        "notify": {
                                                                            "title": "Battery at {$power.battery}%",
                                                                            "body": "You can unplug the charger now."
                                                                        }
                                                                    },
                                                                    {
                                                                        "if": "$sound | map:{none:false, else:true}",
                                                                        "then": [
                                                                            {
                                                                                "sound": "$sound"
                                                                            }
                                                                        ]
                                                                    }
                                                                ]
                                                            },
                                                            {
                                                                "set": {
                                                                    "warned": "high"
                                                                }
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ],
                                        "else": [
                                            {
                                                "set": {
                                                    "warned": ""
                                                }
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                "if": "$power.status | map:{charging:true, else:false}",
                                "then": [
                                    {
                                        "set": {
                                            "icon": "battery.100percent.bolt"
                                        }
                                    }
                                ],
                                "else": [
                                    {
                                        "set": {
                                            "icon": "$power.battery | times:0.04 | round | map:{0:'battery.0percent', 1:'battery.25percent', 2:'battery.50percent', 3:'battery.75percent', else:'battery.100percent'}"
                                        }
                                    }
                                ]
                            }
                        ],
                        "else": [
                            {
                                "set": {
                                    "icon": "powerplug"
                                }
                            }
                        ]
                    }
                ]
            },
            "keep_gear": {
                "steps": [
                    {
                        "set": {
                            "gear": "$args.value.devices | where:{connected:true}"
                        }
                    }
                ]
            },
            "keep_mac": {
                "steps": [
                    {
                        "set": {
                            "mac": {
                                "battery": "$mac_now.battery",
                                "status": "$mac_now.status",
                                "at": "$now"
                            }
                        }
                    }
                ]
            },
            "keep_phone": {
                "steps": [
                    {
                        "set": {
                            "phone": {
                                "battery": "$phone_now.battery",
                                "status": "$phone_now.status",
                                "at": "$now"
                            }
                        }
                    }
                ]
            },
            "preview": {
                "steps": [
                    {
                        "if": "$args.value | map:{none:false, else:true}",
                        "then": [
                            {
                                "sound": "$args.value"
                            }
                        ]
                    }
                ]
            },
            "test": {
                "steps": [
                    {
                        "notify": {
                            "title": "Battery alerts are on",
                            "body": "Battery at {$power.battery | default:'\u2014'}%"
                        }
                    },
                    {
                        "if": "$sound | map:{none:false, else:true}",
                        "then": [
                            {
                                "sound": "$sound"
                            }
                        ]
                    }
                ]
            }
        },
        "cards": [
            {
                "id": "main",
                "layout": {
                    "column": [
                        {
                            "row": [
                                {
                                    "stat": "{$power.battery | default:'\u2014'}%",
                                    "label": "$power.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}",
                                    "size": "xl",
                                    "tone": "$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', warn:'>=-20', good:'<-20', else:'neutral'}"
                                },
                                {
                                    "spacer": true
                                },
                                {
                                    "column": [
                                        {
                                            "text": "{$power.time_left | duration} {$power.charging | map:{true:'to full', else:'left'}}",
                                            "emphasis": "strong",
                                            "when": "$power.time_left | map:{null:false, else:true}"
                                        },
                                        {
                                            "text": "{$power.adapter_watts} W charger",
                                            "size": "s",
                                            "emphasis": "subtle",
                                            "when": "$power.adapter_watts | map:{null:false, else:true}"
                                        }
                                    ],
                                    "gap": "xs",
                                    "align": "end"
                                }
                            ],
                            "align": "center",
                            "when": "$power.has_battery"
                        },
                        {
                            "progress": "$power.battery | times:0.01",
                            "tone": "$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', warn:'>=-20', good:'<-20', else:'neutral'}",
                            "when": "$power.has_battery"
                        },
                        {
                            "text": "No battery here: running on mains power.",
                            "size": "s",
                            "emphasis": "subtle",
                            "when": "$power.has_battery | map:{true:false, else:true}"
                        },
                        {
                            "section": "Battery health",
                            "collapsible": true,
                            "children": [
                                {
                                    "column": [
                                        {
                                            "cell": "Health",
                                            "leading": "heart",
                                            "trailing": {
                                                "text": "{$power.health}%",
                                                "emphasis": "strong"
                                            },
                                            "status": "$power.health | tone:{good:'>=80', warn:'>=60', else:'bad'}",
                                            "when": "$power.health | map:{null:false, else:true}"
                                        },
                                        {
                                            "cell": "Condition",
                                            "leading": "checkmark.seal",
                                            "trailing": {
                                                "badge": "$power.condition | map:{good:'Normal', fair:'Fair', poor:'Poor', service:'Service recommended'}",
                                                "tone": "$power.condition | tone:{good:'good', fair:'warn', else:'bad'}"
                                            },
                                            "when": "$power.condition | map:{null:false, else:true}"
                                        },
                                        {
                                            "cell": "Charge cycles",
                                            "leading": "arrow.triangle.2.circlepath",
                                            "trailing": {
                                                "text": "$power.cycles | number",
                                                "emphasis": "subtle"
                                            },
                                            "when": "$power.cycles | map:{null:false, else:true}"
                                        },
                                        {
                                            "cell": "Temperature",
                                            "leading": "thermometer.medium",
                                            "trailing": {
                                                "text": "{$power.temperature | round:1} \u00b0C",
                                                "emphasis": "subtle"
                                            },
                                            "when": "$power.temperature | map:{null:false, else:true}"
                                        },
                                        {
                                            "cell": "Charger",
                                            "leading": "powerplug",
                                            "trailing": {
                                                "text": "{$power.adapter_watts} W",
                                                "emphasis": "subtle"
                                            },
                                            "when": "$power.adapter_watts | map:{null:false, else:true}"
                                        },
                                        {
                                            "cell": "Heat",
                                            "leading": "flame",
                                            "trailing": {
                                                "badge": "$power.thermal | map:{nominal:'Normal', fair:'Warm', serious:'Hot', critical:'Very hot'}",
                                                "tone": "$power.thermal | tone:{nominal:'good', fair:'warn', else:'bad'}"
                                            }
                                        },
                                        {
                                            "cell": "Low Power Mode",
                                            "leading": "leaf",
                                            "trailing": {
                                                "badge": "$power.low_power | map:{true:'On', else:'Off'}",
                                                "tone": "$power.low_power | tone:{true:'warn', else:'neutral'}"
                                            }
                                        }
                                    ],
                                    "style": "inset"
                                }
                            ],
                            "when": "$power.has_battery"
                        },
                        {
                            "section": "Devices",
                            "children": [
                                {
                                    "column": [
                                        {
                                            "cell": "iPhone",
                                            "subtitle": "{$phone.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}} \u00b7 {$phone.at | ago}",
                                            "leading": "iphone",
                                            "trailing": {
                                                "text": "{$phone.battery | default:'\u2014'}%",
                                                "emphasis": "strong"
                                            },
                                            "status": "$phone.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}",
                                            "when": "$phone.battery | map:{null:false, else:true}"
                                        }
                                    ],
                                    "when": "$me.kind | map:{mac:true, else:false}"
                                },
                                {
                                    "column": [
                                        {
                                            "cell": "Mac",
                                            "subtitle": "{$mac.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}} \u00b7 {$mac.at | ago}",
                                            "leading": "laptopcomputer",
                                            "trailing": {
                                                "text": "{$mac.battery | default:'\u2014'}%",
                                                "emphasis": "strong"
                                            },
                                            "status": "$mac.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}",
                                            "when": "$mac.battery | map:{null:false, else:true}"
                                        }
                                    ],
                                    "when": "$me.kind | map:{iphone:true, ipad:true, else:false}"
                                },
                                {
                                    "list": "$gear",
                                    "item": {
                                        "cell": "$item.name",
                                        "subtitle": "{$item.left | map:{null:'', else:'L '}}{$item.left | default:''}{$item.left | map:{null:'', else:'%'}}{$item.right | map:{null:'', else:' \u00b7 R '}}{$item.right | default:''}{$item.right | map:{null:'', else:'%'}}{$item.case | map:{null:'', else:' \u00b7 Case '}}{$item.case | default:''}{$item.case | map:{null:'', else:'%'}}",
                                        "leading": "$item.kind | map:{headphones:'headphones', speaker:'hifispeaker', keyboard:'keyboard', mouse:'computermouse', phone:'iphone', computer:'laptopcomputer', else:'dot.radiowaves.left.and.right'}",
                                        "trailing": {
                                            "text": "{$item.battery | default:'\u2014'}%",
                                            "emphasis": "strong"
                                        },
                                        "status": "$item.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}"
                                    },
                                    "empty": "No Bluetooth devices connected to your Mac."
                                }
                            ]
                        }
                    ],
                    "gap": "m"
                }
            },
            {
                "id": "alerts",
                "layout": {
                    "column": [
                        {
                            "text": "Alerts for this device's battery, with a notification and a sound.",
                            "size": "s",
                            "emphasis": "subtle"
                        },
                        {
                            "field": "Low battery",
                            "type": "toggle",
                            "bind": "$warn_low"
                        },
                        {
                            "field": "Warn at",
                            "type": "stepper",
                            "bind": "$low_at",
                            "min": 5,
                            "max": 50,
                            "step": 5,
                            "unit": "%",
                            "disabled": "$warn_low | map:{true:false, else:true}"
                        },
                        {
                            "divider": true
                        },
                        {
                            "field": "Charged enough (unplug)",
                            "type": "toggle",
                            "bind": "$warn_high"
                        },
                        {
                            "field": "Tell me at",
                            "type": "stepper",
                            "bind": "$high_at",
                            "min": 50,
                            "max": 100,
                            "step": 5,
                            "unit": "%",
                            "disabled": "$warn_high | map:{true:false, else:true}"
                        },
                        {
                            "divider": true
                        },
                        {
                            "field": "Charger plugged in or out",
                            "type": "toggle",
                            "bind": "$warn_plug"
                        },
                        {
                            "divider": true
                        },
                        {
                            "field": "Sound",
                            "type": "select",
                            "bind": "$sound",
                            "on_change": "preview",
                            "options": [
                                {
                                    "label": "Alert",
                                    "value": "alert"
                                },
                                {
                                    "label": "Done",
                                    "value": "done"
                                },
                                {
                                    "label": "Pop",
                                    "value": "pop"
                                },
                                {
                                    "label": "Tap",
                                    "value": "tap"
                                },
                                {
                                    "label": "Error",
                                    "value": "error"
                                },
                                {
                                    "label": "None",
                                    "value": "none"
                                }
                            ]
                        },
                        {
                            "row": [
                                {
                                    "spacer": true
                                },
                                {
                                    "button": "Test alert",
                                    "icon": "bell",
                                    "on": "test",
                                    "style": "secondary"
                                }
                            ]
                        }
                    ],
                    "gap": "m"
                }
            }
        ],
        "views": {
            "menubar": {
                "icon": "battery.75percent",
                "label": "{$power.battery | default:''}{$power.battery | map:{null:'', else:'%'}}",
                "label_tone": "$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', good:'<0', else:'neutral'}",
                "label_icon": "$icon",
                "card": "main",
                "in_menu": "card"
            },
            "floating": {
                "width": "default",
                "tabs": [
                    {
                        "card": "main",
                        "label": "Battery",
                        "icon": "battery.75percent"
                    },
                    {
                        "card": "alerts",
                        "label": "Alerts",
                        "icon": "bell"
                    }
                ]
            },
            "phone": {
                "tabs": [
                    {
                        "card": "main",
                        "label": "Battery",
                        "icon": "battery.75percent"
                    },
                    {
                        "card": "alerts",
                        "label": "Alerts",
                        "icon": "bell"
                    }
                ]
            }
        }
    },
    "app_json": "{\n  \"schema\": \"tailapps/v0\",\n  \"app\": \"battery\",\n  \"name\": \"Battery\",\n  \"description\": \"Your battery in the menu bar with its health, cycles and temperature, your AirPods, mouse and keyboard, and alerts when it's low, charged enough or the charger goes in or out.\",\n  \"icon\": \"battery.75percent\",\n  \"version\": 1,\n  \"permissions\": [\n    \"power.read\",\n    \"bluetooth.read\",\n    \"notify\"\n  ],\n  \"state\": {\n    \"warn_low\": {\n      \"type\": \"bool\",\n      \"default\": true\n    },\n    \"low_at\": {\n      \"type\": \"number\",\n      \"default\": 20\n    },\n    \"warn_high\": {\n      \"type\": \"bool\",\n      \"default\": false\n    },\n    \"high_at\": {\n      \"type\": \"number\",\n      \"default\": 80\n    },\n    \"warn_plug\": {\n      \"type\": \"bool\",\n      \"default\": false\n    },\n    \"sound\": {\n      \"type\": \"text\",\n      \"default\": \"alert\"\n    },\n    \"warned\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    },\n    \"plug\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    },\n    \"icon\": {\n      \"type\": \"text\",\n      \"default\": \"battery.75percent\"\n    },\n    \"gear\": {\n      \"type\": \"list\",\n      \"default\": [],\n      \"sync\": true\n    },\n    \"mac\": {\n      \"type\": \"object\",\n      \"default\": {},\n      \"sync\": true\n    },\n    \"phone\": {\n      \"type\": \"object\",\n      \"default\": {},\n      \"sync\": true\n    }\n  },\n  \"sources\": {\n    \"power\": {\n      \"system\": \"power\",\n      \"on_change\": {\n        \"action\": \"check\",\n        \"watch\": \"{$power.battery} {$power.status}\"\n      }\n    },\n    \"me\": {\n      \"system\": \"device\"\n    },\n    \"bt\": {\n      \"system\": \"bluetooth\",\n      \"every\": 120,\n      \"platforms\": [\n        \"macos\"\n      ],\n      \"on_change\": \"keep_gear\"\n    },\n    \"mac_now\": {\n      \"system\": \"power\",\n      \"platforms\": [\n        \"macos\"\n      ],\n      \"on_change\": {\n        \"action\": \"keep_mac\",\n        \"watch\": \"{$mac_now.battery} {$mac_now.status}\"\n      }\n    },\n    \"phone_now\": {\n      \"system\": \"power\",\n      \"platforms\": [\n        \"ios\"\n      ],\n      \"on_change\": {\n        \"action\": \"keep_phone\",\n        \"watch\": \"{$phone_now.battery} {$phone_now.status}\"\n      }\n    }\n  },\n  \"actions\": {\n    \"check\": {\n      \"steps\": [\n        {\n          \"if\": \"$power.has_battery\",\n          \"then\": [\n            {\n              \"if\": \"$power.on_ac\",\n              \"then\": [\n                {\n                  \"if\": \"$plug | map:{off:true, else:false}\",\n                  \"then\": [\n                    {\n                      \"if\": \"$warn_plug\",\n                      \"then\": [\n                        {\n                          \"notify\": {\n                            \"title\": \"Charger connected\",\n                            \"body\": \"Battery at {$power.battery}%\"\n                          }\n                        },\n                        {\n                          \"if\": \"$sound | map:{none:false, else:true}\",\n                          \"then\": [\n                            {\n                              \"sound\": \"$sound\"\n                            }\n                          ]\n                        }\n                      ]\n                    }\n                  ]\n                }\n              ],\n              \"else\": [\n                {\n                  \"if\": \"$plug | map:{on:true, else:false}\",\n                  \"then\": [\n                    {\n                      \"if\": \"$warn_plug\",\n                      \"then\": [\n                        {\n                          \"notify\": {\n                            \"title\": \"Charger disconnected\",\n                            \"body\": \"Battery at {$power.battery}%{$power.time_left | map:{null:'', else:', '}}{$power.time_left | duration}{$power.time_left | map:{null:'', else:' left'}}\"\n                          }\n                        },\n                        {\n                          \"if\": \"$sound | map:{none:false, else:true}\",\n                          \"then\": [\n                            {\n                              \"sound\": \"$sound\"\n                            }\n                          ]\n                        }\n                      ]\n                    }\n                  ]\n                }\n              ]\n            },\n            {\n              \"set\": {\n                \"plug\": \"$power.on_ac | map:{true:'on', else:'off'}\"\n              }\n            },\n            {\n              \"if\": \"$power.battery | times:-1 | add:$low_at | tone:{good:'>=0', else:'bad'} | map:{good:true, else:false}\",\n              \"then\": [\n                {\n                  \"if\": \"$power.on_ac | map:{true:false, else:true}\",\n                  \"then\": [\n                    {\n                      \"if\": \"$warned | map:{low:false, else:true}\",\n                      \"then\": [\n                        {\n                          \"if\": \"$warn_low\",\n                          \"then\": [\n                            {\n                              \"notify\": {\n                                \"title\": \"Battery low\",\n                                \"body\": \"{$power.battery}% left. Time to plug in.\"\n                              }\n                            },\n                            {\n                              \"if\": \"$sound | map:{none:false, else:true}\",\n                              \"then\": [\n                                {\n                                  \"sound\": \"$sound\"\n                                }\n                              ]\n                            }\n                          ]\n                        },\n                        {\n                          \"set\": {\n                            \"warned\": \"low\"\n                          }\n                        }\n                      ]\n                    }\n                  ]\n                }\n              ],\n              \"else\": [\n                {\n                  \"if\": \"$power.battery | times:-1 | add:$high_at | tone:{good:'<=0', else:'bad'} | map:{good:true, else:false}\",\n                  \"then\": [\n                    {\n                      \"if\": \"$power.on_ac\",\n                      \"then\": [\n                        {\n                          \"if\": \"$warned | map:{high:false, else:true}\",\n                          \"then\": [\n                            {\n                              \"if\": \"$warn_high\",\n                              \"then\": [\n                                {\n                                  \"notify\": {\n                                    \"title\": \"Battery at {$power.battery}%\",\n                                    \"body\": \"You can unplug the charger now.\"\n                                  }\n                                },\n                                {\n                                  \"if\": \"$sound | map:{none:false, else:true}\",\n                                  \"then\": [\n                                    {\n                                      \"sound\": \"$sound\"\n                                    }\n                                  ]\n                                }\n                              ]\n                            },\n                            {\n                              \"set\": {\n                                \"warned\": \"high\"\n                              }\n                            }\n                          ]\n                        }\n                      ]\n                    }\n                  ],\n                  \"else\": [\n                    {\n                      \"set\": {\n                        \"warned\": \"\"\n                      }\n                    }\n                  ]\n                }\n              ]\n            },\n            {\n              \"if\": \"$power.status | map:{charging:true, else:false}\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"icon\": \"battery.100percent.bolt\"\n                  }\n                }\n              ],\n              \"else\": [\n                {\n                  \"set\": {\n                    \"icon\": \"$power.battery | times:0.04 | round | map:{0:'battery.0percent', 1:'battery.25percent', 2:'battery.50percent', 3:'battery.75percent', else:'battery.100percent'}\"\n                  }\n                }\n              ]\n            }\n          ],\n          \"else\": [\n            {\n              \"set\": {\n                \"icon\": \"powerplug\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"keep_gear\": {\n      \"steps\": [\n        {\n          \"set\": {\n            \"gear\": \"$args.value.devices | where:{connected:true}\"\n          }\n        }\n      ]\n    },\n    \"keep_mac\": {\n      \"steps\": [\n        {\n          \"set\": {\n            \"mac\": {\n              \"battery\": \"$mac_now.battery\",\n              \"status\": \"$mac_now.status\",\n              \"at\": \"$now\"\n            }\n          }\n        }\n      ]\n    },\n    \"keep_phone\": {\n      \"steps\": [\n        {\n          \"set\": {\n            \"phone\": {\n              \"battery\": \"$phone_now.battery\",\n              \"status\": \"$phone_now.status\",\n              \"at\": \"$now\"\n            }\n          }\n        }\n      ]\n    },\n    \"preview\": {\n      \"steps\": [\n        {\n          \"if\": \"$args.value | map:{none:false, else:true}\",\n          \"then\": [\n            {\n              \"sound\": \"$args.value\"\n            }\n          ]\n        }\n      ]\n    },\n    \"test\": {\n      \"steps\": [\n        {\n          \"notify\": {\n            \"title\": \"Battery alerts are on\",\n            \"body\": \"Battery at {$power.battery | default:'\u2014'}%\"\n          }\n        },\n        {\n          \"if\": \"$sound | map:{none:false, else:true}\",\n          \"then\": [\n            {\n              \"sound\": \"$sound\"\n            }\n          ]\n        }\n      ]\n    }\n  },\n  \"cards\": [\n    {\n      \"id\": \"main\",\n      \"layout\": {\n        \"column\": [\n          {\n            \"row\": [\n              {\n                \"stat\": \"{$power.battery | default:'\u2014'}%\",\n                \"label\": \"$power.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}\",\n                \"size\": \"xl\",\n                \"tone\": \"$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', warn:'>=-20', good:'<-20', else:'neutral'}\"\n              },\n              {\n                \"spacer\": true\n              },\n              {\n                \"column\": [\n                  {\n                    \"text\": \"{$power.time_left | duration} {$power.charging | map:{true:'to full', else:'left'}}\",\n                    \"emphasis\": \"strong\",\n                    \"when\": \"$power.time_left | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"text\": \"{$power.adapter_watts} W charger\",\n                    \"size\": \"s\",\n                    \"emphasis\": \"subtle\",\n                    \"when\": \"$power.adapter_watts | map:{null:false, else:true}\"\n                  }\n                ],\n                \"gap\": \"xs\",\n                \"align\": \"end\"\n              }\n            ],\n            \"align\": \"center\",\n            \"when\": \"$power.has_battery\"\n          },\n          {\n            \"progress\": \"$power.battery | times:0.01\",\n            \"tone\": \"$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', warn:'>=-20', good:'<-20', else:'neutral'}\",\n            \"when\": \"$power.has_battery\"\n          },\n          {\n            \"text\": \"No battery here: running on mains power.\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\",\n            \"when\": \"$power.has_battery | map:{true:false, else:true}\"\n          },\n          {\n            \"section\": \"Battery health\",\n            \"collapsible\": true,\n            \"children\": [\n              {\n                \"column\": [\n                  {\n                    \"cell\": \"Health\",\n                    \"leading\": \"heart\",\n                    \"trailing\": {\n                      \"text\": \"{$power.health}%\",\n                      \"emphasis\": \"strong\"\n                    },\n                    \"status\": \"$power.health | tone:{good:'>=80', warn:'>=60', else:'bad'}\",\n                    \"when\": \"$power.health | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"cell\": \"Condition\",\n                    \"leading\": \"checkmark.seal\",\n                    \"trailing\": {\n                      \"badge\": \"$power.condition | map:{good:'Normal', fair:'Fair', poor:'Poor', service:'Service recommended'}\",\n                      \"tone\": \"$power.condition | tone:{good:'good', fair:'warn', else:'bad'}\"\n                    },\n                    \"when\": \"$power.condition | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"cell\": \"Charge cycles\",\n                    \"leading\": \"arrow.triangle.2.circlepath\",\n                    \"trailing\": {\n                      \"text\": \"$power.cycles | number\",\n                      \"emphasis\": \"subtle\"\n                    },\n                    \"when\": \"$power.cycles | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"cell\": \"Temperature\",\n                    \"leading\": \"thermometer.medium\",\n                    \"trailing\": {\n                      \"text\": \"{$power.temperature | round:1} \u00b0C\",\n                      \"emphasis\": \"subtle\"\n                    },\n                    \"when\": \"$power.temperature | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"cell\": \"Charger\",\n                    \"leading\": \"powerplug\",\n                    \"trailing\": {\n                      \"text\": \"{$power.adapter_watts} W\",\n                      \"emphasis\": \"subtle\"\n                    },\n                    \"when\": \"$power.adapter_watts | map:{null:false, else:true}\"\n                  },\n                  {\n                    \"cell\": \"Heat\",\n                    \"leading\": \"flame\",\n                    \"trailing\": {\n                      \"badge\": \"$power.thermal | map:{nominal:'Normal', fair:'Warm', serious:'Hot', critical:'Very hot'}\",\n                      \"tone\": \"$power.thermal | tone:{nominal:'good', fair:'warn', else:'bad'}\"\n                    }\n                  },\n                  {\n                    \"cell\": \"Low Power Mode\",\n                    \"leading\": \"leaf\",\n                    \"trailing\": {\n                      \"badge\": \"$power.low_power | map:{true:'On', else:'Off'}\",\n                      \"tone\": \"$power.low_power | tone:{true:'warn', else:'neutral'}\"\n                    }\n                  }\n                ],\n                \"style\": \"inset\"\n              }\n            ],\n            \"when\": \"$power.has_battery\"\n          },\n          {\n            \"section\": \"Devices\",\n            \"children\": [\n              {\n                \"column\": [\n                  {\n                    \"cell\": \"iPhone\",\n                    \"subtitle\": \"{$phone.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}} \u00b7 {$phone.at | ago}\",\n                    \"leading\": \"iphone\",\n                    \"trailing\": {\n                      \"text\": \"{$phone.battery | default:'\u2014'}%\",\n                      \"emphasis\": \"strong\"\n                    },\n                    \"status\": \"$phone.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}\",\n                    \"when\": \"$phone.battery | map:{null:false, else:true}\"\n                  }\n                ],\n                \"when\": \"$me.kind | map:{mac:true, else:false}\"\n              },\n              {\n                \"column\": [\n                  {\n                    \"cell\": \"Mac\",\n                    \"subtitle\": \"{$mac.status | map:{charging:'Charging', plugged_in:'Plugged in', else:'On battery'}} \u00b7 {$mac.at | ago}\",\n                    \"leading\": \"laptopcomputer\",\n                    \"trailing\": {\n                      \"text\": \"{$mac.battery | default:'\u2014'}%\",\n                      \"emphasis\": \"strong\"\n                    },\n                    \"status\": \"$mac.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}\",\n                    \"when\": \"$mac.battery | map:{null:false, else:true}\"\n                  }\n                ],\n                \"when\": \"$me.kind | map:{iphone:true, ipad:true, else:false}\"\n              },\n              {\n                \"list\": \"$gear\",\n                \"item\": {\n                  \"cell\": \"$item.name\",\n                  \"subtitle\": \"{$item.left | map:{null:'', else:'L '}}{$item.left | default:''}{$item.left | map:{null:'', else:'%'}}{$item.right | map:{null:'', else:' \u00b7 R '}}{$item.right | default:''}{$item.right | map:{null:'', else:'%'}}{$item.case | map:{null:'', else:' \u00b7 Case '}}{$item.case | default:''}{$item.case | map:{null:'', else:'%'}}\",\n                  \"leading\": \"$item.kind | map:{headphones:'headphones', speaker:'hifispeaker', keyboard:'keyboard', mouse:'computermouse', phone:'iphone', computer:'laptopcomputer', else:'dot.radiowaves.left.and.right'}\",\n                  \"trailing\": {\n                    \"text\": \"{$item.battery | default:'\u2014'}%\",\n                    \"emphasis\": \"strong\"\n                  },\n                  \"status\": \"$item.battery | tone:{bad:'<20', warn:'<40', good:'>=40', else:'neutral'}\"\n                },\n                \"empty\": \"No Bluetooth devices connected to your Mac.\"\n              }\n            ]\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    },\n    {\n      \"id\": \"alerts\",\n      \"layout\": {\n        \"column\": [\n          {\n            \"text\": \"Alerts for this device's battery, with a notification and a sound.\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          },\n          {\n            \"field\": \"Low battery\",\n            \"type\": \"toggle\",\n            \"bind\": \"$warn_low\"\n          },\n          {\n            \"field\": \"Warn at\",\n            \"type\": \"stepper\",\n            \"bind\": \"$low_at\",\n            \"min\": 5,\n            \"max\": 50,\n            \"step\": 5,\n            \"unit\": \"%\",\n            \"disabled\": \"$warn_low | map:{true:false, else:true}\"\n          },\n          {\n            \"divider\": true\n          },\n          {\n            \"field\": \"Charged enough (unplug)\",\n            \"type\": \"toggle\",\n            \"bind\": \"$warn_high\"\n          },\n          {\n            \"field\": \"Tell me at\",\n            \"type\": \"stepper\",\n            \"bind\": \"$high_at\",\n            \"min\": 50,\n            \"max\": 100,\n            \"step\": 5,\n            \"unit\": \"%\",\n            \"disabled\": \"$warn_high | map:{true:false, else:true}\"\n          },\n          {\n            \"divider\": true\n          },\n          {\n            \"field\": \"Charger plugged in or out\",\n            \"type\": \"toggle\",\n            \"bind\": \"$warn_plug\"\n          },\n          {\n            \"divider\": true\n          },\n          {\n            \"field\": \"Sound\",\n            \"type\": \"select\",\n            \"bind\": \"$sound\",\n            \"on_change\": \"preview\",\n            \"options\": [\n              {\n                \"label\": \"Alert\",\n                \"value\": \"alert\"\n              },\n              {\n                \"label\": \"Done\",\n                \"value\": \"done\"\n              },\n              {\n                \"label\": \"Pop\",\n                \"value\": \"pop\"\n              },\n              {\n                \"label\": \"Tap\",\n                \"value\": \"tap\"\n              },\n              {\n                \"label\": \"Error\",\n                \"value\": \"error\"\n              },\n              {\n                \"label\": \"None\",\n                \"value\": \"none\"\n              }\n            ]\n          },\n          {\n            \"row\": [\n              {\n                \"spacer\": true\n              },\n              {\n                \"button\": \"Test alert\",\n                \"icon\": \"bell\",\n                \"on\": \"test\",\n                \"style\": \"secondary\"\n              }\n            ]\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    }\n  ],\n  \"views\": {\n    \"menubar\": {\n      \"icon\": \"battery.75percent\",\n      \"label\": \"{$power.battery | default:''}{$power.battery | map:{null:'', else:'%'}}\",\n      \"label_tone\": \"$power.battery | times:-1 | add:$low_at | tone:{bad:'>=0', good:'<0', else:'neutral'}\",\n      \"label_icon\": \"$icon\",\n      \"card\": \"main\",\n      \"in_menu\": \"card\"\n    },\n    \"floating\": {\n      \"width\": \"default\",\n      \"tabs\": [\n        {\n          \"card\": \"main\",\n          \"label\": \"Battery\",\n          \"icon\": \"battery.75percent\"\n        },\n        {\n          \"card\": \"alerts\",\n          \"label\": \"Alerts\",\n          \"icon\": \"bell\"\n        }\n      ]\n    },\n    \"phone\": {\n      \"tabs\": [\n        {\n          \"card\": \"main\",\n          \"label\": \"Battery\",\n          \"icon\": \"battery.75percent\"\n        },\n        {\n          \"card\": \"alerts\",\n          \"label\": \"Alerts\",\n          \"icon\": \"bell\"\n        }\n      ]\n    }\n  }\n}",
    "files": []
}