{
  "version": 0,
  "entry": "b1",
  "blocks": {
    "b1": {
      "type": "setVar",
      "inputs": {
        "name": "outputFolder",
        "value": "::HOME::/automation-agent-runtime-tests/marker-frames"
      },
      "next": "b2"
    },
    "b2": {
      "type": "setVar",
      "inputs": {
        "name": "resolvedOutputFolder",
        "value": {
          "type": "resolveSpecialPath",
          "inputs": {
            "path": {
              "var": "outputFolder"
            }
          }
        }
      },
      "next": "b3"
    },
    "b3": {
      "type": "createFolder",
      "inputs": {
        "path": {
          "var": "resolvedOutputFolder"
        }
      },
      "next": "b4"
    },
    "b4": {
      "type": "setVar",
      "inputs": {
        "name": "frameWidth",
        "value": {
          "type": "prGetSequenceProperty",
          "inputs": {
            "sequence": "::SEQ\\ACTIVE",
            "property": "FRAME_WIDTH"
          }
        }
      },
      "next": "b5"
    },
    "b5": {
      "type": "setVar",
      "inputs": {
        "name": "frameHeight",
        "value": {
          "type": "prGetSequenceProperty",
          "inputs": {
            "sequence": "::SEQ\\ACTIVE",
            "property": "FRAME_HEIGHT"
          }
        }
      },
      "next": "b6"
    },
    "b6": {
      "type": "setVar",
      "inputs": {
        "name": "exportedFrameCount",
        "value": 0
      },
      "next": "b7"
    },
    "b7": {
      "type": "setVar",
      "inputs": {
        "name": "firstFramePath",
        "value": ""
      },
      "next": "b8"
    },
    "b8": {
      "type": "prForEachMarker",
      "inputs": {
        "owner": "::SEQ\\ACTIVE",
        "order": "ASC",
        "markerVar": "markerRef",
        "indexVar": "i"
      },
      "body": [
        {
          "type": "setVar",
          "inputs": {
            "name": "markerIndexOneBased",
            "value": {
              "type": "mathArithmetic",
              "inputs": {
                "op": "ADD",
                "a": {
                  "var": "i"
                },
                "b": 1
              }
            }
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "markerStartSeconds",
            "value": {
              "type": "prGetMarkerProperty",
              "inputs": {
                "marker": {
                  "var": "markerRef"
                },
                "property": "START_SECONDS"
              }
            }
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "markerStartTextRaw",
            "value": {
              "type": "prFormatTime",
              "inputs": {
                "timeSeconds": {
                  "var": "markerStartSeconds"
                },
                "format": "HH_MM_SS_MS"
              }
            }
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "markerStartText",
            "value": {
              "type": "textReplace",
              "inputs": {
                "text": {
                  "type": "textReplace",
                  "inputs": {
                    "text": {
                      "var": "markerStartTextRaw"
                    },
                    "from": ":",
                    "to": "_"
                  }
                },
                "from": ",",
                "to": "_"
              }
            }
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "framePath",
            "value": {
              "type": "textJoin",
              "inputs": {
                "items": [
                  {
                    "var": "resolvedOutputFolder"
                  },
                  "/marker-",
                  {
                    "var": "markerIndexOneBased"
                  },
                  "-",
                  {
                    "var": "markerStartText"
                  },
                  ".png"
                ]
              }
            }
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "lastFrameExportOk",
            "value": false
          }
        },
        {
          "type": "if",
          "inputs": {
            "branches": [
              {
                "condition": {
                  "type": "logicCompare",
                  "inputs": {
                    "op": "EQ",
                    "a": {
                      "var": "exportedFrameCount"
                    },
                    "b": 0
                  }
                },
                "body": [
                  {
                    "type": "setVar",
                    "inputs": {
                      "name": "firstFramePath",
                      "value": {
                        "var": "framePath"
                      }
                    }
                  }
                ]
              }
            ]
          }
        },
        {
          "type": "prExportSequenceFrame",
          "inputs": {
            "sequence": "::SEQ\\ACTIVE",
            "timeSeconds": {
              "var": "markerStartSeconds"
            },
            "outputPath": {
              "var": "framePath"
            },
            "width": {
              "var": "frameWidth"
            },
            "height": {
              "var": "frameHeight"
            },
            "onError": "STOP",
            "storeResultIn": "lastFrameExportOk"
          }
        },
        {
          "type": "setVar",
          "inputs": {
            "name": "exportedFrameCount",
            "value": {
              "type": "mathArithmetic",
              "inputs": {
                "op": "ADD",
                "a": {
                  "var": "exportedFrameCount"
                },
                "b": 1
              }
            }
          }
        }
      ],
      "next": "b9"
    },
    "b9": {
      "type": "setVar",
      "inputs": {
        "name": "firstFrameExists",
        "value": false
      },
      "next": "b10"
    },
    "b10": {
      "type": "if",
      "inputs": {
        "branches": [
          {
            "condition": {
              "type": "logicCompare",
              "inputs": {
                "op": "GT",
                "a": {
                  "var": "exportedFrameCount"
                },
                "b": 0
              }
            },
            "body": [
              {
                "type": "setVar",
                "inputs": {
                  "name": "firstFrameExists",
                  "value": {
                    "type": "fileExists",
                    "inputs": {
                      "path": {
                        "var": "firstFramePath"
                      }
                    }
                  }
                }
              }
            ]
          }
        ]
      },
      "next": "b11"
    },
    "b11": {
      "type": "esConsoleLog",
      "inputs": {
        "message": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "markerFrameExportCount=",
              {
                "var": "exportedFrameCount"
              }
            ]
          }
        }
      },
      "next": null
    }
  }
}
