{
    "tailapp": 2,
    "manifest": {
        "format": 2,
        "app_id": "stage-timer",
        "name": "Stage Timer",
        "version": 1,
        "schema": "tailapps/v0",
        "exported_at": 1795967721,
        "from": "gallery",
        "connections": [],
        "files": {
            "app.json": "fa6ffd34da0ae3098c9015cf668d49f47987182e322c05f80964174a110d8b64"
        },
        "signature": "9uWSSUxVWDAsGzPZCn+tjeTOVzhhX1FAd/pt4RziJjk95b7ljMyWRIXT9CMyOsHgMpPDNbKt+MkCQX1/PL0MBg==",
        "key_id": "gallery-1"
    },
    "app": {
        "schema": "tailapps/v0",
        "app": "stage-timer",
        "name": "Stage Timer",
        "description": "Timer for talks: a rundown of segments, green, yellow and red as time runs out, overtime, and messages for the speaker. Run it on one device and show it big on another.",
        "icon": "stopwatch",
        "version": 1,
        "permissions": [],
        "state": {
            "rundown": {
                "type": "list",
                "sync": true,
                "default": [
                    {
                        "id": "welcome",
                        "title": "Welcome",
                        "length": 300
                    },
                    {
                        "id": "keynote",
                        "title": "Keynote",
                        "length": 1200
                    },
                    {
                        "id": "qa",
                        "title": "Q&A",
                        "length": 600
                    }
                ]
            },
            "current": {
                "type": "number",
                "sync": true,
                "default": 0
            },
            "length": {
                "type": "number",
                "sync": true,
                "default": 300
            },
            "left": {
                "type": "number",
                "sync": true,
                "default": 300
            },
            "ends_at": {
                "type": "number",
                "sync": true,
                "default": 0
            },
            "started_at": {
                "type": "number",
                "sync": true,
                "default": 0
            },
            "yellow_at": {
                "type": "number",
                "sync": true,
                "default": 0
            },
            "red_at": {
                "type": "number",
                "sync": true,
                "default": 0
            },
            "status": {
                "type": "text",
                "sync": true,
                "default": "idle"
            },
            "message": {
                "type": "text",
                "sync": true,
                "default": ""
            },
            "yellow": {
                "type": "number",
                "sync": true,
                "default": 60
            },
            "red": {
                "type": "number",
                "sync": true,
                "default": 15
            },
            "auto": {
                "type": "bool",
                "sync": true,
                "default": false
            },
            "fresh": {
                "type": "number",
                "default": 0
            },
            "message_entry": {
                "type": "text",
                "default": ""
            },
            "entry_title": {
                "type": "text",
                "default": ""
            },
            "entry_length": {
                "type": "text",
                "default": ""
            }
        },
        "cards": [
            {
                "id": "main",
                "layout": {
                    "column": [
                        {
                            "column": [
                                {
                                    "column": [
                                        {
                                            "timer": "$ends_at",
                                            "mode": "until",
                                            "size": "xxl"
                                        },
                                        {
                                            "row": [
                                                {
                                                    "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                                    "size": "m",
                                                    "emphasis": "strong",
                                                    "grow": true
                                                },
                                                {
                                                    "text": "{$current | add:1} of {$rundown | count}",
                                                    "size": "s",
                                                    "emphasis": "subtle",
                                                    "when": "$rundown | count"
                                                }
                                            ],
                                            "align": "center",
                                            "gap": "s"
                                        }
                                    ],
                                    "style": "tile",
                                    "hue": "$now | times:-1 | add:$yellow_at | tone:{good:'>0', else:'warn'} | map:{good:'green', else:'yellow'}",
                                    "gap": "xs",
                                    "when": "$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}"
                                },
                                {
                                    "column": [
                                        {
                                            "timer": "$ends_at",
                                            "mode": "until",
                                            "size": "xxl",
                                            "when": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}"
                                        },
                                        {
                                            "text": "+{$ends_at | times:-1 | add:$now | duration:'clock'}",
                                            "size": "xxl",
                                            "when": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}"
                                        },
                                        {
                                            "row": [
                                                {
                                                    "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                                    "size": "m",
                                                    "emphasis": "strong",
                                                    "grow": true
                                                },
                                                {
                                                    "text": "{$current | add:1} of {$rundown | count}",
                                                    "size": "s",
                                                    "emphasis": "subtle",
                                                    "when": "$rundown | count"
                                                }
                                            ],
                                            "align": "center",
                                            "gap": "s"
                                        }
                                    ],
                                    "style": "tile",
                                    "hue": "red",
                                    "gap": "xs",
                                    "when": "$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}"
                                }
                            ],
                            "when": "$status | map:{running:true, else:false}",
                            "gap": "s"
                        },
                        {
                            "column": [
                                {
                                    "text": "$left | duration:'clock'",
                                    "size": "xxl"
                                },
                                {
                                    "row": [
                                        {
                                            "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                            "size": "m",
                                            "emphasis": "strong",
                                            "grow": true
                                        },
                                        {
                                            "text": "$status | map:{paused:'Paused', else:'Ready'}",
                                            "size": "s",
                                            "emphasis": "subtle",
                                            "when": "$rundown | count"
                                        }
                                    ],
                                    "align": "center",
                                    "gap": "s"
                                }
                            ],
                            "style": "tile",
                            "hue": "$status | map:{paused:'gray', else:'blue'}",
                            "gap": "xs",
                            "when": "$status | map:{running:false, else:true}"
                        },
                        {
                            "column": [
                                {
                                    "text": "$message",
                                    "size": "xxl",
                                    "emphasis": "strong"
                                }
                            ],
                            "style": "tile",
                            "hue": "indigo",
                            "when": "$message"
                        },
                        {
                            "progress": "$ends_at",
                            "from": "$started_at",
                            "style": "bar",
                            "when": "$status | map:{running:true, else:false}"
                        },
                        {
                            "row": [
                                {
                                    "text": "Segment ends in",
                                    "size": "s",
                                    "emphasis": "subtle",
                                    "grow": true
                                },
                                {
                                    "timer": "$ends_at",
                                    "mode": "until",
                                    "format": "short",
                                    "size": "s",
                                    "on_end": "finished"
                                }
                            ],
                            "align": "center",
                            "gap": "s",
                            "when": "$status | map:{running:true, else:false}"
                        },
                        {
                            "row": [
                                {
                                    "button": "Previous",
                                    "icon": "backward.end.fill",
                                    "icon_only": true,
                                    "style": "plain",
                                    "size": "l",
                                    "on": "previous"
                                },
                                {
                                    "button": "Start",
                                    "icon": "play.fill",
                                    "icon_only": true,
                                    "style": "plain",
                                    "size": "l",
                                    "on": "start",
                                    "keys": "mod+return",
                                    "when": "$status | map:{running:false, else:true}"
                                },
                                {
                                    "button": "Pause",
                                    "icon": "pause.fill",
                                    "icon_only": true,
                                    "style": "plain",
                                    "size": "l",
                                    "on": "pause",
                                    "keys": "mod+return",
                                    "when": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}"
                                },
                                {
                                    "button": "Next",
                                    "icon": "forward.end.fill",
                                    "icon_only": true,
                                    "style": "plain",
                                    "size": "l",
                                    "on": "next"
                                },
                                {
                                    "button": "Reset",
                                    "icon": "arrow.counterclockwise",
                                    "icon_only": true,
                                    "style": "plain",
                                    "size": "l",
                                    "on": "reset"
                                },
                                {
                                    "button": "\u22121 min",
                                    "on": "adjust",
                                    "args": {
                                        "by": -60
                                    },
                                    "style": "secondary",
                                    "size": "s"
                                },
                                {
                                    "button": "+1 min",
                                    "on": "adjust",
                                    "args": {
                                        "by": 60
                                    },
                                    "style": "secondary",
                                    "size": "s"
                                }
                            ],
                            "align": "center",
                            "gap": "s",
                            "wrap": true
                        },
                        {
                            "section": "Message to the speaker",
                            "children": [
                                {
                                    "row": [
                                        {
                                            "button": "Wrap up",
                                            "on": "show_message",
                                            "args": {
                                                "text": "Wrap up"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        },
                                        {
                                            "button": "5 minutes",
                                            "on": "show_message",
                                            "args": {
                                                "text": "5 minutes"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        },
                                        {
                                            "button": "1 minute",
                                            "on": "show_message",
                                            "args": {
                                                "text": "1 minute"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        },
                                        {
                                            "button": "Time's up",
                                            "on": "show_message",
                                            "args": {
                                                "text": "Time's up"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        },
                                        {
                                            "button": "Slow down",
                                            "on": "show_message",
                                            "args": {
                                                "text": "Slow down"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        },
                                        {
                                            "button": "Speak up",
                                            "on": "show_message",
                                            "args": {
                                                "text": "Speak up"
                                            },
                                            "style": "secondary",
                                            "size": "s"
                                        }
                                    ],
                                    "wrap": true,
                                    "gap": "s"
                                },
                                {
                                    "row": [
                                        {
                                            "field": "Message",
                                            "type": "text",
                                            "bind": "$message_entry",
                                            "placeholder": "Type a message",
                                            "on_submit": "send_typed",
                                            "grow": true
                                        },
                                        {
                                            "button": "Show",
                                            "on": "send_typed",
                                            "style": "secondary",
                                            "disabled": "$message_entry | count | map:{0:true, else:false}"
                                        },
                                        {
                                            "button": "Clear",
                                            "on": "clear_message",
                                            "style": "plain",
                                            "when": "$message"
                                        }
                                    ],
                                    "align": "end",
                                    "gap": "s"
                                }
                            ]
                        },
                        {
                            "section": "Rundown",
                            "children": [
                                {
                                    "list": "$rundown",
                                    "empty": "No segments yet. Add one below.",
                                    "item": {
                                        "row": [
                                            {
                                                "icon": "$index | times:-1 | add:$current | map:{0:'play.circle.fill', else:'circle'}",
                                                "tone": "$index | times:-1 | add:$current | map:{0:'accent', else:'neutral'}",
                                                "size": "s"
                                            },
                                            {
                                                "text": "$item.title",
                                                "grow": true
                                            },
                                            {
                                                "text": "$item.length | duration:'clock'",
                                                "size": "s",
                                                "emphasis": "subtle"
                                            },
                                            {
                                                "button": "Start this segment",
                                                "icon": "play.fill",
                                                "icon_only": true,
                                                "style": "plain",
                                                "on": "jump",
                                                "args": {
                                                    "index": "$index"
                                                }
                                            }
                                        ],
                                        "align": "center",
                                        "gap": "s"
                                    },
                                    "swipe": {
                                        "trailing": [
                                            {
                                                "label": "Delete",
                                                "icon": "trash",
                                                "style": "destructive",
                                                "on": "remove_segment"
                                            }
                                        ]
                                    }
                                },
                                {
                                    "row": [
                                        {
                                            "field": "Segment",
                                            "type": "text",
                                            "bind": "$entry_title",
                                            "placeholder": "Keynote",
                                            "grow": true
                                        },
                                        {
                                            "field": "Length",
                                            "type": "text",
                                            "bind": "$entry_length",
                                            "placeholder": "20 or 4:30",
                                            "on_submit": "add_segment"
                                        },
                                        {
                                            "button": "Add",
                                            "on": "add_segment",
                                            "style": "secondary",
                                            "disabled": "$entry_length | seconds | map:{null:true, 0:true, else:false}"
                                        }
                                    ],
                                    "align": "end",
                                    "gap": "s"
                                }
                            ]
                        },
                        {
                            "section": "Settings",
                            "collapsible": true,
                            "collapsed": true,
                            "children": [
                                {
                                    "field": "Yellow at",
                                    "type": "stepper",
                                    "bind": "$yellow",
                                    "min": 0,
                                    "max": 900,
                                    "step": 15,
                                    "format": "duration",
                                    "on_change": "mark"
                                },
                                {
                                    "field": "Red at",
                                    "type": "stepper",
                                    "bind": "$red",
                                    "min": 0,
                                    "max": 900,
                                    "step": 15,
                                    "format": "duration",
                                    "on_change": "mark"
                                },
                                {
                                    "field": "Auto-start the next segment",
                                    "type": "toggle",
                                    "bind": "$auto"
                                },
                                {
                                    "button": "Clear the rundown",
                                    "on": "clear_rundown",
                                    "style": "destructive",
                                    "size": "s"
                                }
                            ]
                        }
                    ],
                    "gap": "m"
                }
            },
            {
                "id": "stage",
                "layout": {
                    "column": [
                        {
                            "column": [
                                {
                                    "column": [
                                        {
                                            "timer": "$ends_at",
                                            "mode": "until",
                                            "size": "fill"
                                        },
                                        {
                                            "row": [
                                                {
                                                    "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                                    "size": "xl",
                                                    "emphasis": "strong",
                                                    "grow": true
                                                },
                                                {
                                                    "text": "{$current | add:1} of {$rundown | count}",
                                                    "size": "s",
                                                    "emphasis": "subtle",
                                                    "when": "$rundown | count"
                                                }
                                            ],
                                            "align": "center",
                                            "gap": "s"
                                        }
                                    ],
                                    "style": "tile",
                                    "hue": "$now | times:-1 | add:$yellow_at | tone:{good:'>0', else:'warn'} | map:{good:'green', else:'yellow'}",
                                    "gap": "xs",
                                    "when": "$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}"
                                },
                                {
                                    "column": [
                                        {
                                            "timer": "$ends_at",
                                            "mode": "until",
                                            "size": "fill",
                                            "when": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}"
                                        },
                                        {
                                            "text": "+{$ends_at | times:-1 | add:$now | duration:'clock'}",
                                            "size": "fill",
                                            "when": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}"
                                        },
                                        {
                                            "row": [
                                                {
                                                    "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                                    "size": "xl",
                                                    "emphasis": "strong",
                                                    "grow": true
                                                },
                                                {
                                                    "text": "{$current | add:1} of {$rundown | count}",
                                                    "size": "s",
                                                    "emphasis": "subtle",
                                                    "when": "$rundown | count"
                                                }
                                            ],
                                            "align": "center",
                                            "gap": "s"
                                        }
                                    ],
                                    "style": "tile",
                                    "hue": "red",
                                    "gap": "xs",
                                    "when": "$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}"
                                }
                            ],
                            "when": "$status | map:{running:true, else:false}",
                            "gap": "s"
                        },
                        {
                            "column": [
                                {
                                    "text": "$left | duration:'clock'",
                                    "size": "fill"
                                },
                                {
                                    "row": [
                                        {
                                            "text": "$rundown | pick:$current | pick:'title' | default:'Stage timer'",
                                            "size": "xl",
                                            "emphasis": "strong",
                                            "grow": true
                                        },
                                        {
                                            "text": "$status | map:{paused:'Paused', else:'Ready'}",
                                            "size": "s",
                                            "emphasis": "subtle",
                                            "when": "$rundown | count"
                                        }
                                    ],
                                    "align": "center",
                                    "gap": "s"
                                }
                            ],
                            "style": "tile",
                            "hue": "$status | map:{paused:'gray', else:'blue'}",
                            "gap": "xs",
                            "when": "$status | map:{running:false, else:true}"
                        },
                        {
                            "column": [
                                {
                                    "text": "$message",
                                    "size": "xxl",
                                    "emphasis": "strong"
                                }
                            ],
                            "style": "tile",
                            "hue": "indigo",
                            "when": "$message"
                        }
                    ],
                    "gap": "s"
                }
            }
        ],
        "actions": {
            "start": {
                "steps": [
                    {
                        "if": "$left | map:{0:true, null:true, else:false}",
                        "then": [
                            {
                                "set": {
                                    "left": "$length"
                                }
                            }
                        ]
                    },
                    {
                        "set": {
                            "ends_at": "$now",
                            "started_at": "$now",
                            "status": "running"
                        }
                    },
                    {
                        "increment": {
                            "ends_at": "$left",
                            "started_at": "$left"
                        }
                    },
                    {
                        "increment": {
                            "started_at": "-$length"
                        }
                    },
                    {
                        "set": {
                            "yellow_at": "$ends_at",
                            "red_at": "$ends_at"
                        }
                    },
                    {
                        "increment": {
                            "yellow_at": "-$yellow",
                            "red_at": "-$red"
                        }
                    }
                ]
            },
            "pause": {
                "steps": [
                    {
                        "if": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}",
                        "then": [
                            {
                                "set": {
                                    "left": "$ends_at"
                                }
                            },
                            {
                                "increment": {
                                    "left": "-$now"
                                },
                                "min": 0
                            },
                            {
                                "set": {
                                    "ends_at": 0,
                                    "yellow_at": 0,
                                    "red_at": 0,
                                    "status": "paused"
                                }
                            }
                        ]
                    }
                ]
            },
            "reset": {
                "steps": [
                    {
                        "if": "$rundown | pick:$current",
                        "then": [
                            {
                                "set": {
                                    "length": "$rundown | pick:$current | pick:'length'"
                                }
                            }
                        ]
                    },
                    {
                        "set": {
                            "left": "$length",
                            "ends_at": 0,
                            "started_at": 0,
                            "yellow_at": 0,
                            "red_at": 0,
                            "status": "idle"
                        }
                    }
                ]
            },
            "next": {
                "steps": [
                    {
                        "increment": {
                            "current": 1
                        }
                    },
                    {
                        "if": "$rundown | pick:$current",
                        "then": [
                            {
                                "if": "$status | map:{running:true, else:false}",
                                "then": [
                                    {
                                        "if": "$rundown | pick:$current",
                                        "then": [
                                            {
                                                "set": {
                                                    "length": "$rundown | pick:$current | pick:'length'"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "set": {
                                            "left": "$length",
                                            "ends_at": 0,
                                            "started_at": 0,
                                            "yellow_at": 0,
                                            "red_at": 0,
                                            "status": "idle"
                                        }
                                    },
                                    {
                                        "if": "$left | map:{0:true, null:true, else:false}",
                                        "then": [
                                            {
                                                "set": {
                                                    "left": "$length"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "set": {
                                            "ends_at": "$now",
                                            "started_at": "$now",
                                            "status": "running"
                                        }
                                    },
                                    {
                                        "increment": {
                                            "ends_at": "$left",
                                            "started_at": "$left"
                                        }
                                    },
                                    {
                                        "increment": {
                                            "started_at": "-$length"
                                        }
                                    },
                                    {
                                        "set": {
                                            "yellow_at": "$ends_at",
                                            "red_at": "$ends_at"
                                        }
                                    },
                                    {
                                        "increment": {
                                            "yellow_at": "-$yellow",
                                            "red_at": "-$red"
                                        }
                                    }
                                ],
                                "else": [
                                    {
                                        "if": "$rundown | pick:$current",
                                        "then": [
                                            {
                                                "set": {
                                                    "length": "$rundown | pick:$current | pick:'length'"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "set": {
                                            "left": "$length",
                                            "ends_at": 0,
                                            "started_at": 0,
                                            "yellow_at": 0,
                                            "red_at": 0,
                                            "status": "idle"
                                        }
                                    }
                                ]
                            }
                        ],
                        "else": [
                            {
                                "increment": {
                                    "current": -1
                                },
                                "min": 0
                            }
                        ]
                    }
                ]
            },
            "previous": {
                "steps": [
                    {
                        "increment": {
                            "current": -1
                        },
                        "min": 0
                    },
                    {
                        "if": "$status | map:{running:true, else:false}",
                        "then": [
                            {
                                "if": "$rundown | pick:$current",
                                "then": [
                                    {
                                        "set": {
                                            "length": "$rundown | pick:$current | pick:'length'"
                                        }
                                    }
                                ]
                            },
                            {
                                "set": {
                                    "left": "$length",
                                    "ends_at": 0,
                                    "started_at": 0,
                                    "yellow_at": 0,
                                    "red_at": 0,
                                    "status": "idle"
                                }
                            },
                            {
                                "if": "$left | map:{0:true, null:true, else:false}",
                                "then": [
                                    {
                                        "set": {
                                            "left": "$length"
                                        }
                                    }
                                ]
                            },
                            {
                                "set": {
                                    "ends_at": "$now",
                                    "started_at": "$now",
                                    "status": "running"
                                }
                            },
                            {
                                "increment": {
                                    "ends_at": "$left",
                                    "started_at": "$left"
                                }
                            },
                            {
                                "increment": {
                                    "started_at": "-$length"
                                }
                            },
                            {
                                "set": {
                                    "yellow_at": "$ends_at",
                                    "red_at": "$ends_at"
                                }
                            },
                            {
                                "increment": {
                                    "yellow_at": "-$yellow",
                                    "red_at": "-$red"
                                }
                            }
                        ],
                        "else": [
                            {
                                "if": "$rundown | pick:$current",
                                "then": [
                                    {
                                        "set": {
                                            "length": "$rundown | pick:$current | pick:'length'"
                                        }
                                    }
                                ]
                            },
                            {
                                "set": {
                                    "left": "$length",
                                    "ends_at": 0,
                                    "started_at": 0,
                                    "yellow_at": 0,
                                    "red_at": 0,
                                    "status": "idle"
                                }
                            }
                        ]
                    }
                ]
            },
            "jump": {
                "args": {
                    "index": "int"
                },
                "steps": [
                    {
                        "set": {
                            "current": "$args.index"
                        }
                    },
                    {
                        "if": "$rundown | pick:$current",
                        "then": [
                            {
                                "set": {
                                    "length": "$rundown | pick:$current | pick:'length'"
                                }
                            }
                        ]
                    },
                    {
                        "set": {
                            "left": "$length",
                            "ends_at": 0,
                            "started_at": 0,
                            "yellow_at": 0,
                            "red_at": 0,
                            "status": "idle"
                        }
                    },
                    {
                        "if": "$left | map:{0:true, null:true, else:false}",
                        "then": [
                            {
                                "set": {
                                    "left": "$length"
                                }
                            }
                        ]
                    },
                    {
                        "set": {
                            "ends_at": "$now",
                            "started_at": "$now",
                            "status": "running"
                        }
                    },
                    {
                        "increment": {
                            "ends_at": "$left",
                            "started_at": "$left"
                        }
                    },
                    {
                        "increment": {
                            "started_at": "-$length"
                        }
                    },
                    {
                        "set": {
                            "yellow_at": "$ends_at",
                            "red_at": "$ends_at"
                        }
                    },
                    {
                        "increment": {
                            "yellow_at": "-$yellow",
                            "red_at": "-$red"
                        }
                    }
                ]
            },
            "finished": {
                "steps": [
                    {
                        "if": "$status | map:{running:true, else:false}",
                        "then": [
                            {
                                "set": {
                                    "fresh": "$ends_at"
                                }
                            },
                            {
                                "increment": {
                                    "fresh": 10
                                }
                            },
                            {
                                "increment": {
                                    "fresh": "-$now"
                                },
                                "min": 0
                            },
                            {
                                "if": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}",
                                "then": [
                                    {
                                        "if": "$fresh",
                                        "then": [
                                            {
                                                "sound": "alert"
                                            },
                                            {
                                                "if": "$auto",
                                                "then": [
                                                    {
                                                        "increment": {
                                                            "current": 1
                                                        }
                                                    },
                                                    {
                                                        "if": "$rundown | pick:$current",
                                                        "then": [
                                                            {
                                                                "if": "$rundown | pick:$current",
                                                                "then": [
                                                                    {
                                                                        "set": {
                                                                            "length": "$rundown | pick:$current | pick:'length'"
                                                                        }
                                                                    }
                                                                ]
                                                            },
                                                            {
                                                                "set": {
                                                                    "left": "$length",
                                                                    "ends_at": 0,
                                                                    "started_at": 0,
                                                                    "yellow_at": 0,
                                                                    "red_at": 0,
                                                                    "status": "idle"
                                                                }
                                                            },
                                                            {
                                                                "if": "$left | map:{0:true, null:true, else:false}",
                                                                "then": [
                                                                    {
                                                                        "set": {
                                                                            "left": "$length"
                                                                        }
                                                                    }
                                                                ]
                                                            },
                                                            {
                                                                "set": {
                                                                    "ends_at": "$now",
                                                                    "started_at": "$now",
                                                                    "status": "running"
                                                                }
                                                            },
                                                            {
                                                                "increment": {
                                                                    "ends_at": "$left",
                                                                    "started_at": "$left"
                                                                }
                                                            },
                                                            {
                                                                "increment": {
                                                                    "started_at": "-$length"
                                                                }
                                                            },
                                                            {
                                                                "set": {
                                                                    "yellow_at": "$ends_at",
                                                                    "red_at": "$ends_at"
                                                                }
                                                            },
                                                            {
                                                                "increment": {
                                                                    "yellow_at": "-$yellow",
                                                                    "red_at": "-$red"
                                                                }
                                                            }
                                                        ],
                                                        "else": [
                                                            {
                                                                "increment": {
                                                                    "current": -1
                                                                },
                                                                "min": 0
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "adjust": {
                "args": {
                    "by": "int"
                },
                "steps": [
                    {
                        "if": "$status | map:{running:true, else:false}",
                        "then": [
                            {
                                "if": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}",
                                "then": [
                                    {
                                        "increment": {
                                            "ends_at": "$args.by",
                                            "yellow_at": "$args.by",
                                            "red_at": "$args.by"
                                        }
                                    },
                                    {
                                        "if": "$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}",
                                        "then": [
                                            {
                                                "set": {
                                                    "ends_at": "$now"
                                                }
                                            },
                                            {
                                                "increment": {
                                                    "ends_at": 1
                                                }
                                            }
                                        ]
                                    }
                                ],
                                "else": [
                                    {
                                        "increment": {
                                            "ends_at": "$args.by",
                                            "yellow_at": "$args.by",
                                            "red_at": "$args.by"
                                        }
                                    }
                                ]
                            }
                        ],
                        "else": [
                            {
                                "increment": {
                                    "left": "$args.by",
                                    "length": "$args.by"
                                },
                                "min": 15
                            }
                        ]
                    }
                ]
            },
            "mark": {
                "steps": [
                    {
                        "if": "$status | map:{running:true, else:false}",
                        "then": [
                            {
                                "set": {
                                    "yellow_at": "$ends_at",
                                    "red_at": "$ends_at"
                                }
                            },
                            {
                                "increment": {
                                    "yellow_at": "-$yellow",
                                    "red_at": "-$red"
                                }
                            }
                        ]
                    }
                ]
            },
            "show_message": {
                "args": {
                    "text": "text"
                },
                "steps": [
                    {
                        "set": {
                            "message": "$args.text"
                        }
                    }
                ]
            },
            "send_typed": {
                "steps": [
                    {
                        "if": "$message_entry",
                        "then": [
                            {
                                "set": {
                                    "message": "$message_entry"
                                }
                            },
                            {
                                "set": {
                                    "message_entry": ""
                                }
                            }
                        ]
                    }
                ]
            },
            "clear_message": {
                "steps": [
                    {
                        "set": {
                            "message": ""
                        }
                    }
                ]
            },
            "add_segment": {
                "steps": [
                    {
                        "if": "$entry_length | seconds",
                        "then": [
                            {
                                "push": {
                                    "rundown": {
                                        "id": "{$now}-{$rundown | count}",
                                        "title": "$entry_title | default:'Segment'",
                                        "length": "$entry_length | seconds"
                                    }
                                },
                                "at": "end"
                            },
                            {
                                "set": {
                                    "entry_title": "",
                                    "entry_length": ""
                                }
                            },
                            {
                                "if": "$status | map:{idle:true, else:false}",
                                "then": [
                                    {
                                        "if": "$rundown | pick:$current",
                                        "then": [
                                            {
                                                "set": {
                                                    "length": "$rundown | pick:$current | pick:'length'"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "set": {
                                            "left": "$length",
                                            "ends_at": 0,
                                            "started_at": 0,
                                            "yellow_at": 0,
                                            "red_at": 0,
                                            "status": "idle"
                                        }
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "remove_segment": {
                "steps": [
                    {
                        "remove": {
                            "rundown": {
                                "match": {
                                    "id": "$args.item.id"
                                }
                            }
                        }
                    },
                    {
                        "if": "$args.index | times:-1 | add:$current | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}",
                        "then": [
                            {
                                "increment": {
                                    "current": -1
                                },
                                "min": 0
                            }
                        ],
                        "else": [
                            {
                                "if": "$args.index | times:-1 | add:$current | map:{0:true, else:false}",
                                "then": [
                                    {
                                        "set": {
                                            "status": "idle"
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "if": "$rundown | pick:$current",
                        "then": [],
                        "else": [
                            {
                                "increment": {
                                    "current": -1
                                },
                                "min": 0
                            }
                        ]
                    },
                    {
                        "if": "$status | map:{idle:true, else:false}",
                        "then": [
                            {
                                "if": "$rundown | pick:$current",
                                "then": [
                                    {
                                        "set": {
                                            "length": "$rundown | pick:$current | pick:'length'"
                                        }
                                    }
                                ]
                            },
                            {
                                "set": {
                                    "left": "$length",
                                    "ends_at": 0,
                                    "started_at": 0,
                                    "yellow_at": 0,
                                    "red_at": 0,
                                    "status": "idle"
                                }
                            }
                        ]
                    }
                ]
            },
            "clear_rundown": {
                "confirm": "Remove every segment from the rundown?",
                "steps": [
                    {
                        "set": {
                            "rundown": [],
                            "current": 0,
                            "length": 300
                        }
                    },
                    {
                        "if": "$rundown | pick:$current",
                        "then": [
                            {
                                "set": {
                                    "length": "$rundown | pick:$current | pick:'length'"
                                }
                            }
                        ]
                    },
                    {
                        "set": {
                            "left": "$length",
                            "ends_at": 0,
                            "started_at": 0,
                            "yellow_at": 0,
                            "red_at": 0,
                            "status": "idle"
                        }
                    }
                ]
            }
        },
        "views": {
            "menubar": {
                "icon": "stopwatch",
                "label": "{$ends_at | until}{$status | map:{paused:'Paused', idle:'Ready', else:''}}",
                "label_tone": "$status | map:{running:'accent', else:'neutral'}",
                "label_icon": "$status | map:{paused:'pause.circle', else:'stopwatch'}",
                "card": "main",
                "in_menu": "card"
            },
            "floating": {
                "card": "stage",
                "width": "wide",
                "chrome": "none"
            },
            "phone": {
                "tabs": [
                    {
                        "card": "main",
                        "label": "Control",
                        "icon": "slider.horizontal.3"
                    },
                    {
                        "card": "stage",
                        "label": "Stage",
                        "icon": "display"
                    }
                ]
            }
        },
        "style": {
            "accent": "#16a34a"
        }
    },
    "app_json": "{\n  \"schema\": \"tailapps/v0\",\n  \"app\": \"stage-timer\",\n  \"name\": \"Stage Timer\",\n  \"description\": \"Timer for talks: a rundown of segments, green, yellow and red as time runs out, overtime, and messages for the speaker. Run it on one device and show it big on another.\",\n  \"icon\": \"stopwatch\",\n  \"version\": 1,\n  \"permissions\": [],\n  \"state\": {\n    \"rundown\": {\n      \"type\": \"list\",\n      \"sync\": true,\n      \"default\": [\n        {\n          \"id\": \"welcome\",\n          \"title\": \"Welcome\",\n          \"length\": 300\n        },\n        {\n          \"id\": \"keynote\",\n          \"title\": \"Keynote\",\n          \"length\": 1200\n        },\n        {\n          \"id\": \"qa\",\n          \"title\": \"Q&A\",\n          \"length\": 600\n        }\n      ]\n    },\n    \"current\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 0\n    },\n    \"length\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 300\n    },\n    \"left\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 300\n    },\n    \"ends_at\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 0\n    },\n    \"started_at\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 0\n    },\n    \"yellow_at\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 0\n    },\n    \"red_at\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 0\n    },\n    \"status\": {\n      \"type\": \"text\",\n      \"sync\": true,\n      \"default\": \"idle\"\n    },\n    \"message\": {\n      \"type\": \"text\",\n      \"sync\": true,\n      \"default\": \"\"\n    },\n    \"yellow\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 60\n    },\n    \"red\": {\n      \"type\": \"number\",\n      \"sync\": true,\n      \"default\": 15\n    },\n    \"auto\": {\n      \"type\": \"bool\",\n      \"sync\": true,\n      \"default\": false\n    },\n    \"fresh\": {\n      \"type\": \"number\",\n      \"default\": 0\n    },\n    \"message_entry\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    },\n    \"entry_title\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    },\n    \"entry_length\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    }\n  },\n  \"cards\": [\n    {\n      \"id\": \"main\",\n      \"layout\": {\n        \"column\": [\n          {\n            \"column\": [\n              {\n                \"column\": [\n                  {\n                    \"timer\": \"$ends_at\",\n                    \"mode\": \"until\",\n                    \"size\": \"xxl\"\n                  },\n                  {\n                    \"row\": [\n                      {\n                        \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                        \"size\": \"m\",\n                        \"emphasis\": \"strong\",\n                        \"grow\": true\n                      },\n                      {\n                        \"text\": \"{$current | add:1} of {$rundown | count}\",\n                        \"size\": \"s\",\n                        \"emphasis\": \"subtle\",\n                        \"when\": \"$rundown | count\"\n                      }\n                    ],\n                    \"align\": \"center\",\n                    \"gap\": \"s\"\n                  }\n                ],\n                \"style\": \"tile\",\n                \"hue\": \"$now | times:-1 | add:$yellow_at | tone:{good:'>0', else:'warn'} | map:{good:'green', else:'yellow'}\",\n                \"gap\": \"xs\",\n                \"when\": \"$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\"\n              },\n              {\n                \"column\": [\n                  {\n                    \"timer\": \"$ends_at\",\n                    \"mode\": \"until\",\n                    \"size\": \"xxl\",\n                    \"when\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\"\n                  },\n                  {\n                    \"text\": \"+{$ends_at | times:-1 | add:$now | duration:'clock'}\",\n                    \"size\": \"xxl\",\n                    \"when\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\"\n                  },\n                  {\n                    \"row\": [\n                      {\n                        \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                        \"size\": \"m\",\n                        \"emphasis\": \"strong\",\n                        \"grow\": true\n                      },\n                      {\n                        \"text\": \"{$current | add:1} of {$rundown | count}\",\n                        \"size\": \"s\",\n                        \"emphasis\": \"subtle\",\n                        \"when\": \"$rundown | count\"\n                      }\n                    ],\n                    \"align\": \"center\",\n                    \"gap\": \"s\"\n                  }\n                ],\n                \"style\": \"tile\",\n                \"hue\": \"red\",\n                \"gap\": \"xs\",\n                \"when\": \"$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\"\n              }\n            ],\n            \"when\": \"$status | map:{running:true, else:false}\",\n            \"gap\": \"s\"\n          },\n          {\n            \"column\": [\n              {\n                \"text\": \"$left | duration:'clock'\",\n                \"size\": \"xxl\"\n              },\n              {\n                \"row\": [\n                  {\n                    \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                    \"size\": \"m\",\n                    \"emphasis\": \"strong\",\n                    \"grow\": true\n                  },\n                  {\n                    \"text\": \"$status | map:{paused:'Paused', else:'Ready'}\",\n                    \"size\": \"s\",\n                    \"emphasis\": \"subtle\",\n                    \"when\": \"$rundown | count\"\n                  }\n                ],\n                \"align\": \"center\",\n                \"gap\": \"s\"\n              }\n            ],\n            \"style\": \"tile\",\n            \"hue\": \"$status | map:{paused:'gray', else:'blue'}\",\n            \"gap\": \"xs\",\n            \"when\": \"$status | map:{running:false, else:true}\"\n          },\n          {\n            \"column\": [\n              {\n                \"text\": \"$message\",\n                \"size\": \"xxl\",\n                \"emphasis\": \"strong\"\n              }\n            ],\n            \"style\": \"tile\",\n            \"hue\": \"indigo\",\n            \"when\": \"$message\"\n          },\n          {\n            \"progress\": \"$ends_at\",\n            \"from\": \"$started_at\",\n            \"style\": \"bar\",\n            \"when\": \"$status | map:{running:true, else:false}\"\n          },\n          {\n            \"row\": [\n              {\n                \"text\": \"Segment ends in\",\n                \"size\": \"s\",\n                \"emphasis\": \"subtle\",\n                \"grow\": true\n              },\n              {\n                \"timer\": \"$ends_at\",\n                \"mode\": \"until\",\n                \"format\": \"short\",\n                \"size\": \"s\",\n                \"on_end\": \"finished\"\n              }\n            ],\n            \"align\": \"center\",\n            \"gap\": \"s\",\n            \"when\": \"$status | map:{running:true, else:false}\"\n          },\n          {\n            \"row\": [\n              {\n                \"button\": \"Previous\",\n                \"icon\": \"backward.end.fill\",\n                \"icon_only\": true,\n                \"style\": \"plain\",\n                \"size\": \"l\",\n                \"on\": \"previous\"\n              },\n              {\n                \"button\": \"Start\",\n                \"icon\": \"play.fill\",\n                \"icon_only\": true,\n                \"style\": \"plain\",\n                \"size\": \"l\",\n                \"on\": \"start\",\n                \"keys\": \"mod+return\",\n                \"when\": \"$status | map:{running:false, else:true}\"\n              },\n              {\n                \"button\": \"Pause\",\n                \"icon\": \"pause.fill\",\n                \"icon_only\": true,\n                \"style\": \"plain\",\n                \"size\": \"l\",\n                \"on\": \"pause\",\n                \"keys\": \"mod+return\",\n                \"when\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\"\n              },\n              {\n                \"button\": \"Next\",\n                \"icon\": \"forward.end.fill\",\n                \"icon_only\": true,\n                \"style\": \"plain\",\n                \"size\": \"l\",\n                \"on\": \"next\"\n              },\n              {\n                \"button\": \"Reset\",\n                \"icon\": \"arrow.counterclockwise\",\n                \"icon_only\": true,\n                \"style\": \"plain\",\n                \"size\": \"l\",\n                \"on\": \"reset\"\n              },\n              {\n                \"button\": \"\u22121 min\",\n                \"on\": \"adjust\",\n                \"args\": {\n                  \"by\": -60\n                },\n                \"style\": \"secondary\",\n                \"size\": \"s\"\n              },\n              {\n                \"button\": \"+1 min\",\n                \"on\": \"adjust\",\n                \"args\": {\n                  \"by\": 60\n                },\n                \"style\": \"secondary\",\n                \"size\": \"s\"\n              }\n            ],\n            \"align\": \"center\",\n            \"gap\": \"s\",\n            \"wrap\": true\n          },\n          {\n            \"section\": \"Message to the speaker\",\n            \"children\": [\n              {\n                \"row\": [\n                  {\n                    \"button\": \"Wrap up\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"Wrap up\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  },\n                  {\n                    \"button\": \"5 minutes\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"5 minutes\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  },\n                  {\n                    \"button\": \"1 minute\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"1 minute\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  },\n                  {\n                    \"button\": \"Time's up\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"Time's up\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  },\n                  {\n                    \"button\": \"Slow down\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"Slow down\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  },\n                  {\n                    \"button\": \"Speak up\",\n                    \"on\": \"show_message\",\n                    \"args\": {\n                      \"text\": \"Speak up\"\n                    },\n                    \"style\": \"secondary\",\n                    \"size\": \"s\"\n                  }\n                ],\n                \"wrap\": true,\n                \"gap\": \"s\"\n              },\n              {\n                \"row\": [\n                  {\n                    \"field\": \"Message\",\n                    \"type\": \"text\",\n                    \"bind\": \"$message_entry\",\n                    \"placeholder\": \"Type a message\",\n                    \"on_submit\": \"send_typed\",\n                    \"grow\": true\n                  },\n                  {\n                    \"button\": \"Show\",\n                    \"on\": \"send_typed\",\n                    \"style\": \"secondary\",\n                    \"disabled\": \"$message_entry | count | map:{0:true, else:false}\"\n                  },\n                  {\n                    \"button\": \"Clear\",\n                    \"on\": \"clear_message\",\n                    \"style\": \"plain\",\n                    \"when\": \"$message\"\n                  }\n                ],\n                \"align\": \"end\",\n                \"gap\": \"s\"\n              }\n            ]\n          },\n          {\n            \"section\": \"Rundown\",\n            \"children\": [\n              {\n                \"list\": \"$rundown\",\n                \"empty\": \"No segments yet. Add one below.\",\n                \"item\": {\n                  \"row\": [\n                    {\n                      \"icon\": \"$index | times:-1 | add:$current | map:{0:'play.circle.fill', else:'circle'}\",\n                      \"tone\": \"$index | times:-1 | add:$current | map:{0:'accent', else:'neutral'}\",\n                      \"size\": \"s\"\n                    },\n                    {\n                      \"text\": \"$item.title\",\n                      \"grow\": true\n                    },\n                    {\n                      \"text\": \"$item.length | duration:'clock'\",\n                      \"size\": \"s\",\n                      \"emphasis\": \"subtle\"\n                    },\n                    {\n                      \"button\": \"Start this segment\",\n                      \"icon\": \"play.fill\",\n                      \"icon_only\": true,\n                      \"style\": \"plain\",\n                      \"on\": \"jump\",\n                      \"args\": {\n                        \"index\": \"$index\"\n                      }\n                    }\n                  ],\n                  \"align\": \"center\",\n                  \"gap\": \"s\"\n                },\n                \"swipe\": {\n                  \"trailing\": [\n                    {\n                      \"label\": \"Delete\",\n                      \"icon\": \"trash\",\n                      \"style\": \"destructive\",\n                      \"on\": \"remove_segment\"\n                    }\n                  ]\n                }\n              },\n              {\n                \"row\": [\n                  {\n                    \"field\": \"Segment\",\n                    \"type\": \"text\",\n                    \"bind\": \"$entry_title\",\n                    \"placeholder\": \"Keynote\",\n                    \"grow\": true\n                  },\n                  {\n                    \"field\": \"Length\",\n                    \"type\": \"text\",\n                    \"bind\": \"$entry_length\",\n                    \"placeholder\": \"20 or 4:30\",\n                    \"on_submit\": \"add_segment\"\n                  },\n                  {\n                    \"button\": \"Add\",\n                    \"on\": \"add_segment\",\n                    \"style\": \"secondary\",\n                    \"disabled\": \"$entry_length | seconds | map:{null:true, 0:true, else:false}\"\n                  }\n                ],\n                \"align\": \"end\",\n                \"gap\": \"s\"\n              }\n            ]\n          },\n          {\n            \"section\": \"Settings\",\n            \"collapsible\": true,\n            \"collapsed\": true,\n            \"children\": [\n              {\n                \"field\": \"Yellow at\",\n                \"type\": \"stepper\",\n                \"bind\": \"$yellow\",\n                \"min\": 0,\n                \"max\": 900,\n                \"step\": 15,\n                \"format\": \"duration\",\n                \"on_change\": \"mark\"\n              },\n              {\n                \"field\": \"Red at\",\n                \"type\": \"stepper\",\n                \"bind\": \"$red\",\n                \"min\": 0,\n                \"max\": 900,\n                \"step\": 15,\n                \"format\": \"duration\",\n                \"on_change\": \"mark\"\n              },\n              {\n                \"field\": \"Auto-start the next segment\",\n                \"type\": \"toggle\",\n                \"bind\": \"$auto\"\n              },\n              {\n                \"button\": \"Clear the rundown\",\n                \"on\": \"clear_rundown\",\n                \"style\": \"destructive\",\n                \"size\": \"s\"\n              }\n            ]\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    },\n    {\n      \"id\": \"stage\",\n      \"layout\": {\n        \"column\": [\n          {\n            \"column\": [\n              {\n                \"column\": [\n                  {\n                    \"timer\": \"$ends_at\",\n                    \"mode\": \"until\",\n                    \"size\": \"fill\"\n                  },\n                  {\n                    \"row\": [\n                      {\n                        \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                        \"size\": \"xl\",\n                        \"emphasis\": \"strong\",\n                        \"grow\": true\n                      },\n                      {\n                        \"text\": \"{$current | add:1} of {$rundown | count}\",\n                        \"size\": \"s\",\n                        \"emphasis\": \"subtle\",\n                        \"when\": \"$rundown | count\"\n                      }\n                    ],\n                    \"align\": \"center\",\n                    \"gap\": \"s\"\n                  }\n                ],\n                \"style\": \"tile\",\n                \"hue\": \"$now | times:-1 | add:$yellow_at | tone:{good:'>0', else:'warn'} | map:{good:'green', else:'yellow'}\",\n                \"gap\": \"xs\",\n                \"when\": \"$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\"\n              },\n              {\n                \"column\": [\n                  {\n                    \"timer\": \"$ends_at\",\n                    \"mode\": \"until\",\n                    \"size\": \"fill\",\n                    \"when\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\"\n                  },\n                  {\n                    \"text\": \"+{$ends_at | times:-1 | add:$now | duration:'clock'}\",\n                    \"size\": \"fill\",\n                    \"when\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\"\n                  },\n                  {\n                    \"row\": [\n                      {\n                        \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                        \"size\": \"xl\",\n                        \"emphasis\": \"strong\",\n                        \"grow\": true\n                      },\n                      {\n                        \"text\": \"{$current | add:1} of {$rundown | count}\",\n                        \"size\": \"s\",\n                        \"emphasis\": \"subtle\",\n                        \"when\": \"$rundown | count\"\n                      }\n                    ],\n                    \"align\": \"center\",\n                    \"gap\": \"s\"\n                  }\n                ],\n                \"style\": \"tile\",\n                \"hue\": \"red\",\n                \"gap\": \"xs\",\n                \"when\": \"$now | times:-1 | add:$red_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\"\n              }\n            ],\n            \"when\": \"$status | map:{running:true, else:false}\",\n            \"gap\": \"s\"\n          },\n          {\n            \"column\": [\n              {\n                \"text\": \"$left | duration:'clock'\",\n                \"size\": \"fill\"\n              },\n              {\n                \"row\": [\n                  {\n                    \"text\": \"$rundown | pick:$current | pick:'title' | default:'Stage timer'\",\n                    \"size\": \"xl\",\n                    \"emphasis\": \"strong\",\n                    \"grow\": true\n                  },\n                  {\n                    \"text\": \"$status | map:{paused:'Paused', else:'Ready'}\",\n                    \"size\": \"s\",\n                    \"emphasis\": \"subtle\",\n                    \"when\": \"$rundown | count\"\n                  }\n                ],\n                \"align\": \"center\",\n                \"gap\": \"s\"\n              }\n            ],\n            \"style\": \"tile\",\n            \"hue\": \"$status | map:{paused:'gray', else:'blue'}\",\n            \"gap\": \"xs\",\n            \"when\": \"$status | map:{running:false, else:true}\"\n          },\n          {\n            \"column\": [\n              {\n                \"text\": \"$message\",\n                \"size\": \"xxl\",\n                \"emphasis\": \"strong\"\n              }\n            ],\n            \"style\": \"tile\",\n            \"hue\": \"indigo\",\n            \"when\": \"$message\"\n          }\n        ],\n        \"gap\": \"s\"\n      }\n    }\n  ],\n  \"actions\": {\n    \"start\": {\n      \"steps\": [\n        {\n          \"if\": \"$left | map:{0:true, null:true, else:false}\",\n          \"then\": [\n            {\n              \"set\": {\n                \"left\": \"$length\"\n              }\n            }\n          ]\n        },\n        {\n          \"set\": {\n            \"ends_at\": \"$now\",\n            \"started_at\": \"$now\",\n            \"status\": \"running\"\n          }\n        },\n        {\n          \"increment\": {\n            \"ends_at\": \"$left\",\n            \"started_at\": \"$left\"\n          }\n        },\n        {\n          \"increment\": {\n            \"started_at\": \"-$length\"\n          }\n        },\n        {\n          \"set\": {\n            \"yellow_at\": \"$ends_at\",\n            \"red_at\": \"$ends_at\"\n          }\n        },\n        {\n          \"increment\": {\n            \"yellow_at\": \"-$yellow\",\n            \"red_at\": \"-$red\"\n          }\n        }\n      ]\n    },\n    \"pause\": {\n      \"steps\": [\n        {\n          \"if\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\",\n          \"then\": [\n            {\n              \"set\": {\n                \"left\": \"$ends_at\"\n              }\n            },\n            {\n              \"increment\": {\n                \"left\": \"-$now\"\n              },\n              \"min\": 0\n            },\n            {\n              \"set\": {\n                \"ends_at\": 0,\n                \"yellow_at\": 0,\n                \"red_at\": 0,\n                \"status\": \"paused\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"reset\": {\n      \"steps\": [\n        {\n          \"if\": \"$rundown | pick:$current\",\n          \"then\": [\n            {\n              \"set\": {\n                \"length\": \"$rundown | pick:$current | pick:'length'\"\n              }\n            }\n          ]\n        },\n        {\n          \"set\": {\n            \"left\": \"$length\",\n            \"ends_at\": 0,\n            \"started_at\": 0,\n            \"yellow_at\": 0,\n            \"red_at\": 0,\n            \"status\": \"idle\"\n          }\n        }\n      ]\n    },\n    \"next\": {\n      \"steps\": [\n        {\n          \"increment\": {\n            \"current\": 1\n          }\n        },\n        {\n          \"if\": \"$rundown | pick:$current\",\n          \"then\": [\n            {\n              \"if\": \"$status | map:{running:true, else:false}\",\n              \"then\": [\n                {\n                  \"if\": \"$rundown | pick:$current\",\n                  \"then\": [\n                    {\n                      \"set\": {\n                        \"length\": \"$rundown | pick:$current | pick:'length'\"\n                      }\n                    }\n                  ]\n                },\n                {\n                  \"set\": {\n                    \"left\": \"$length\",\n                    \"ends_at\": 0,\n                    \"started_at\": 0,\n                    \"yellow_at\": 0,\n                    \"red_at\": 0,\n                    \"status\": \"idle\"\n                  }\n                },\n                {\n                  \"if\": \"$left | map:{0:true, null:true, else:false}\",\n                  \"then\": [\n                    {\n                      \"set\": {\n                        \"left\": \"$length\"\n                      }\n                    }\n                  ]\n                },\n                {\n                  \"set\": {\n                    \"ends_at\": \"$now\",\n                    \"started_at\": \"$now\",\n                    \"status\": \"running\"\n                  }\n                },\n                {\n                  \"increment\": {\n                    \"ends_at\": \"$left\",\n                    \"started_at\": \"$left\"\n                  }\n                },\n                {\n                  \"increment\": {\n                    \"started_at\": \"-$length\"\n                  }\n                },\n                {\n                  \"set\": {\n                    \"yellow_at\": \"$ends_at\",\n                    \"red_at\": \"$ends_at\"\n                  }\n                },\n                {\n                  \"increment\": {\n                    \"yellow_at\": \"-$yellow\",\n                    \"red_at\": \"-$red\"\n                  }\n                }\n              ],\n              \"else\": [\n                {\n                  \"if\": \"$rundown | pick:$current\",\n                  \"then\": [\n                    {\n                      \"set\": {\n                        \"length\": \"$rundown | pick:$current | pick:'length'\"\n                      }\n                    }\n                  ]\n                },\n                {\n                  \"set\": {\n                    \"left\": \"$length\",\n                    \"ends_at\": 0,\n                    \"started_at\": 0,\n                    \"yellow_at\": 0,\n                    \"red_at\": 0,\n                    \"status\": \"idle\"\n                  }\n                }\n              ]\n            }\n          ],\n          \"else\": [\n            {\n              \"increment\": {\n                \"current\": -1\n              },\n              \"min\": 0\n            }\n          ]\n        }\n      ]\n    },\n    \"previous\": {\n      \"steps\": [\n        {\n          \"increment\": {\n            \"current\": -1\n          },\n          \"min\": 0\n        },\n        {\n          \"if\": \"$status | map:{running:true, else:false}\",\n          \"then\": [\n            {\n              \"if\": \"$rundown | pick:$current\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"length\": \"$rundown | pick:$current | pick:'length'\"\n                  }\n                }\n              ]\n            },\n            {\n              \"set\": {\n                \"left\": \"$length\",\n                \"ends_at\": 0,\n                \"started_at\": 0,\n                \"yellow_at\": 0,\n                \"red_at\": 0,\n                \"status\": \"idle\"\n              }\n            },\n            {\n              \"if\": \"$left | map:{0:true, null:true, else:false}\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"left\": \"$length\"\n                  }\n                }\n              ]\n            },\n            {\n              \"set\": {\n                \"ends_at\": \"$now\",\n                \"started_at\": \"$now\",\n                \"status\": \"running\"\n              }\n            },\n            {\n              \"increment\": {\n                \"ends_at\": \"$left\",\n                \"started_at\": \"$left\"\n              }\n            },\n            {\n              \"increment\": {\n                \"started_at\": \"-$length\"\n              }\n            },\n            {\n              \"set\": {\n                \"yellow_at\": \"$ends_at\",\n                \"red_at\": \"$ends_at\"\n              }\n            },\n            {\n              \"increment\": {\n                \"yellow_at\": \"-$yellow\",\n                \"red_at\": \"-$red\"\n              }\n            }\n          ],\n          \"else\": [\n            {\n              \"if\": \"$rundown | pick:$current\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"length\": \"$rundown | pick:$current | pick:'length'\"\n                  }\n                }\n              ]\n            },\n            {\n              \"set\": {\n                \"left\": \"$length\",\n                \"ends_at\": 0,\n                \"started_at\": 0,\n                \"yellow_at\": 0,\n                \"red_at\": 0,\n                \"status\": \"idle\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"jump\": {\n      \"args\": {\n        \"index\": \"int\"\n      },\n      \"steps\": [\n        {\n          \"set\": {\n            \"current\": \"$args.index\"\n          }\n        },\n        {\n          \"if\": \"$rundown | pick:$current\",\n          \"then\": [\n            {\n              \"set\": {\n                \"length\": \"$rundown | pick:$current | pick:'length'\"\n              }\n            }\n          ]\n        },\n        {\n          \"set\": {\n            \"left\": \"$length\",\n            \"ends_at\": 0,\n            \"started_at\": 0,\n            \"yellow_at\": 0,\n            \"red_at\": 0,\n            \"status\": \"idle\"\n          }\n        },\n        {\n          \"if\": \"$left | map:{0:true, null:true, else:false}\",\n          \"then\": [\n            {\n              \"set\": {\n                \"left\": \"$length\"\n              }\n            }\n          ]\n        },\n        {\n          \"set\": {\n            \"ends_at\": \"$now\",\n            \"started_at\": \"$now\",\n            \"status\": \"running\"\n          }\n        },\n        {\n          \"increment\": {\n            \"ends_at\": \"$left\",\n            \"started_at\": \"$left\"\n          }\n        },\n        {\n          \"increment\": {\n            \"started_at\": \"-$length\"\n          }\n        },\n        {\n          \"set\": {\n            \"yellow_at\": \"$ends_at\",\n            \"red_at\": \"$ends_at\"\n          }\n        },\n        {\n          \"increment\": {\n            \"yellow_at\": \"-$yellow\",\n            \"red_at\": \"-$red\"\n          }\n        }\n      ]\n    },\n    \"finished\": {\n      \"steps\": [\n        {\n          \"if\": \"$status | map:{running:true, else:false}\",\n          \"then\": [\n            {\n              \"set\": {\n                \"fresh\": \"$ends_at\"\n              }\n            },\n            {\n              \"increment\": {\n                \"fresh\": 10\n              }\n            },\n            {\n              \"increment\": {\n                \"fresh\": \"-$now\"\n              },\n              \"min\": 0\n            },\n            {\n              \"if\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\",\n              \"then\": [\n                {\n                  \"if\": \"$fresh\",\n                  \"then\": [\n                    {\n                      \"sound\": \"alert\"\n                    },\n                    {\n                      \"if\": \"$auto\",\n                      \"then\": [\n                        {\n                          \"increment\": {\n                            \"current\": 1\n                          }\n                        },\n                        {\n                          \"if\": \"$rundown | pick:$current\",\n                          \"then\": [\n                            {\n                              \"if\": \"$rundown | pick:$current\",\n                              \"then\": [\n                                {\n                                  \"set\": {\n                                    \"length\": \"$rundown | pick:$current | pick:'length'\"\n                                  }\n                                }\n                              ]\n                            },\n                            {\n                              \"set\": {\n                                \"left\": \"$length\",\n                                \"ends_at\": 0,\n                                \"started_at\": 0,\n                                \"yellow_at\": 0,\n                                \"red_at\": 0,\n                                \"status\": \"idle\"\n                              }\n                            },\n                            {\n                              \"if\": \"$left | map:{0:true, null:true, else:false}\",\n                              \"then\": [\n                                {\n                                  \"set\": {\n                                    \"left\": \"$length\"\n                                  }\n                                }\n                              ]\n                            },\n                            {\n                              \"set\": {\n                                \"ends_at\": \"$now\",\n                                \"started_at\": \"$now\",\n                                \"status\": \"running\"\n                              }\n                            },\n                            {\n                              \"increment\": {\n                                \"ends_at\": \"$left\",\n                                \"started_at\": \"$left\"\n                              }\n                            },\n                            {\n                              \"increment\": {\n                                \"started_at\": \"-$length\"\n                              }\n                            },\n                            {\n                              \"set\": {\n                                \"yellow_at\": \"$ends_at\",\n                                \"red_at\": \"$ends_at\"\n                              }\n                            },\n                            {\n                              \"increment\": {\n                                \"yellow_at\": \"-$yellow\",\n                                \"red_at\": \"-$red\"\n                              }\n                            }\n                          ],\n                          \"else\": [\n                            {\n                              \"increment\": {\n                                \"current\": -1\n                              },\n                              \"min\": 0\n                            }\n                          ]\n                        }\n                      ]\n                    }\n                  ]\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    },\n    \"adjust\": {\n      \"args\": {\n        \"by\": \"int\"\n      },\n      \"steps\": [\n        {\n          \"if\": \"$status | map:{running:true, else:false}\",\n          \"then\": [\n            {\n              \"if\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\",\n              \"then\": [\n                {\n                  \"increment\": {\n                    \"ends_at\": \"$args.by\",\n                    \"yellow_at\": \"$args.by\",\n                    \"red_at\": \"$args.by\"\n                  }\n                },\n                {\n                  \"if\": \"$now | times:-1 | add:$ends_at | tone:{good:'>0', else:'bad'} | map:{good:false, else:true}\",\n                  \"then\": [\n                    {\n                      \"set\": {\n                        \"ends_at\": \"$now\"\n                      }\n                    },\n                    {\n                      \"increment\": {\n                        \"ends_at\": 1\n                      }\n                    }\n                  ]\n                }\n              ],\n              \"else\": [\n                {\n                  \"increment\": {\n                    \"ends_at\": \"$args.by\",\n                    \"yellow_at\": \"$args.by\",\n                    \"red_at\": \"$args.by\"\n                  }\n                }\n              ]\n            }\n          ],\n          \"else\": [\n            {\n              \"increment\": {\n                \"left\": \"$args.by\",\n                \"length\": \"$args.by\"\n              },\n              \"min\": 15\n            }\n          ]\n        }\n      ]\n    },\n    \"mark\": {\n      \"steps\": [\n        {\n          \"if\": \"$status | map:{running:true, else:false}\",\n          \"then\": [\n            {\n              \"set\": {\n                \"yellow_at\": \"$ends_at\",\n                \"red_at\": \"$ends_at\"\n              }\n            },\n            {\n              \"increment\": {\n                \"yellow_at\": \"-$yellow\",\n                \"red_at\": \"-$red\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"show_message\": {\n      \"args\": {\n        \"text\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"set\": {\n            \"message\": \"$args.text\"\n          }\n        }\n      ]\n    },\n    \"send_typed\": {\n      \"steps\": [\n        {\n          \"if\": \"$message_entry\",\n          \"then\": [\n            {\n              \"set\": {\n                \"message\": \"$message_entry\"\n              }\n            },\n            {\n              \"set\": {\n                \"message_entry\": \"\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"clear_message\": {\n      \"steps\": [\n        {\n          \"set\": {\n            \"message\": \"\"\n          }\n        }\n      ]\n    },\n    \"add_segment\": {\n      \"steps\": [\n        {\n          \"if\": \"$entry_length | seconds\",\n          \"then\": [\n            {\n              \"push\": {\n                \"rundown\": {\n                  \"id\": \"{$now}-{$rundown | count}\",\n                  \"title\": \"$entry_title | default:'Segment'\",\n                  \"length\": \"$entry_length | seconds\"\n                }\n              },\n              \"at\": \"end\"\n            },\n            {\n              \"set\": {\n                \"entry_title\": \"\",\n                \"entry_length\": \"\"\n              }\n            },\n            {\n              \"if\": \"$status | map:{idle:true, else:false}\",\n              \"then\": [\n                {\n                  \"if\": \"$rundown | pick:$current\",\n                  \"then\": [\n                    {\n                      \"set\": {\n                        \"length\": \"$rundown | pick:$current | pick:'length'\"\n                      }\n                    }\n                  ]\n                },\n                {\n                  \"set\": {\n                    \"left\": \"$length\",\n                    \"ends_at\": 0,\n                    \"started_at\": 0,\n                    \"yellow_at\": 0,\n                    \"red_at\": 0,\n                    \"status\": \"idle\"\n                  }\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    },\n    \"remove_segment\": {\n      \"steps\": [\n        {\n          \"remove\": {\n            \"rundown\": {\n              \"match\": {\n                \"id\": \"$args.item.id\"\n              }\n            }\n          }\n        },\n        {\n          \"if\": \"$args.index | times:-1 | add:$current | tone:{good:'>0', else:'bad'} | map:{good:true, else:false}\",\n          \"then\": [\n            {\n              \"increment\": {\n                \"current\": -1\n              },\n              \"min\": 0\n            }\n          ],\n          \"else\": [\n            {\n              \"if\": \"$args.index | times:-1 | add:$current | map:{0:true, else:false}\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"status\": \"idle\"\n                  }\n                }\n              ]\n            }\n          ]\n        },\n        {\n          \"if\": \"$rundown | pick:$current\",\n          \"then\": [],\n          \"else\": [\n            {\n              \"increment\": {\n                \"current\": -1\n              },\n              \"min\": 0\n            }\n          ]\n        },\n        {\n          \"if\": \"$status | map:{idle:true, else:false}\",\n          \"then\": [\n            {\n              \"if\": \"$rundown | pick:$current\",\n              \"then\": [\n                {\n                  \"set\": {\n                    \"length\": \"$rundown | pick:$current | pick:'length'\"\n                  }\n                }\n              ]\n            },\n            {\n              \"set\": {\n                \"left\": \"$length\",\n                \"ends_at\": 0,\n                \"started_at\": 0,\n                \"yellow_at\": 0,\n                \"red_at\": 0,\n                \"status\": \"idle\"\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"clear_rundown\": {\n      \"confirm\": \"Remove every segment from the rundown?\",\n      \"steps\": [\n        {\n          \"set\": {\n            \"rundown\": [],\n            \"current\": 0,\n            \"length\": 300\n          }\n        },\n        {\n          \"if\": \"$rundown | pick:$current\",\n          \"then\": [\n            {\n              \"set\": {\n                \"length\": \"$rundown | pick:$current | pick:'length'\"\n              }\n            }\n          ]\n        },\n        {\n          \"set\": {\n            \"left\": \"$length\",\n            \"ends_at\": 0,\n            \"started_at\": 0,\n            \"yellow_at\": 0,\n            \"red_at\": 0,\n            \"status\": \"idle\"\n          }\n        }\n      ]\n    }\n  },\n  \"views\": {\n    \"menubar\": {\n      \"icon\": \"stopwatch\",\n      \"label\": \"{$ends_at | until}{$status | map:{paused:'Paused', idle:'Ready', else:''}}\",\n      \"label_tone\": \"$status | map:{running:'accent', else:'neutral'}\",\n      \"label_icon\": \"$status | map:{paused:'pause.circle', else:'stopwatch'}\",\n      \"card\": \"main\",\n      \"in_menu\": \"card\"\n    },\n    \"floating\": {\n      \"card\": \"stage\",\n      \"width\": \"wide\",\n      \"chrome\": \"none\"\n    },\n    \"phone\": {\n      \"tabs\": [\n        {\n          \"card\": \"main\",\n          \"label\": \"Control\",\n          \"icon\": \"slider.horizontal.3\"\n        },\n        {\n          \"card\": \"stage\",\n          \"label\": \"Stage\",\n          \"icon\": \"display\"\n        }\n      ]\n    }\n  },\n  \"style\": {\n    \"accent\": \"#16a34a\"\n  }\n}\n",
    "files": []
}