{
  "version": 0,
  "entry": "b1",
  "blocks": {
    "b1": {
      "type": "createFolder",
      "inputs": {
        "path": "::HOME::/automation-agent-runtime-tests/semantic-probing"
      },
      "next": "b2"
    },
    "b2": {
      "type": "setVar",
      "inputs": {
        "name": "selectedItems",
        "value": {
          "type": "prListProjectItems",
          "inputs": {
            "onlySelected": true,
            "includeSubbins": "BIN_AND_SUBBINS"
          }
        }
      },
      "next": "b3"
    },
    "b3": {
      "type": "setVar",
      "inputs": {
        "name": "selectedCount",
        "value": {
          "type": "listLength",
          "inputs": {
            "list": {
              "var": "selectedItems"
            }
          }
        }
      },
      "next": "b4"
    },
    "b4": {
      "type": "if",
      "inputs": {
        "branches": [
          {
            "condition": {
              "type": "logicCompare",
              "inputs": {
                "op": "EQ",
                "a": {
                  "var": "selectedCount"
                },
                "b": 0
              }
            },
            "body": [
              {
                "type": "fail",
                "inputs": {
                  "message": "Select one clip project item before running this transcript export probe."
                }
              }
            ]
          }
        ]
      },
      "next": "b5"
    },
    "b5": {
      "type": "setVar",
      "inputs": {
        "name": "itemRef",
        "value": {
          "type": "listGet",
          "inputs": {
            "list": {
              "var": "selectedItems"
            },
            "where": "FIRST"
          }
        }
      },
      "next": "b6"
    },
    "b6": {
      "type": "setVar",
      "inputs": {
        "name": "itemName",
        "value": {
          "type": "prGetProjectItemProperty",
          "inputs": {
            "item": {
              "var": "itemRef"
            },
            "property": "NAME"
          }
        }
      },
      "next": "b7"
    },
    "b7": {
      "type": "setVar",
      "inputs": {
        "name": "fileStem",
        "value": {
          "type": "prGetProjectItemProperty",
          "inputs": {
            "item": {
              "var": "itemRef"
            },
            "property": "MEDIA_FILENAME_WITHOUT_EXTENSION"
          }
        }
      },
      "next": "b8"
    },
    "b8": {
      "type": "setVar",
      "inputs": {
        "name": "hasTranscript",
        "value": {
          "type": "prGetProjectItemProperty",
          "inputs": {
            "item": {
              "var": "itemRef"
            },
            "property": "HAS_TRANSCRIPT"
          }
        }
      },
      "next": "b9"
    },
    "b9": {
      "type": "setVar",
      "inputs": {
        "name": "jsonText",
        "value": ""
      },
      "next": "b10"
    },
    "b10": {
      "type": "setVar",
      "inputs": {
        "name": "jsonLength",
        "value": 0
      },
      "next": "b11"
    },
    "b11": {
      "type": "setVar",
      "inputs": {
        "name": "outputPath",
        "value": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "::HOME::/automation-agent-runtime-tests/semantic-probing/",
              {
                "var": "fileStem"
              },
              "-transcript.json"
            ]
          }
        }
      },
      "next": "b12"
    },
    "b12": {
      "type": "setVar",
      "inputs": {
        "name": "outputExists",
        "value": false
      },
      "next": "b13"
    },
    "b13": {
      "type": "if",
      "inputs": {
        "branches": [
          {
            "condition": {
              "var": "hasTranscript"
            },
            "body": [
              {
                "type": "setVar",
                "inputs": {
                  "name": "jsonText",
                  "value": {
                    "type": "prExportTranscriptJson",
                    "inputs": {
                      "item": {
                        "var": "itemRef"
                      }
                    }
                  }
                }
              },
              {
                "type": "setVar",
                "inputs": {
                  "name": "jsonLength",
                  "value": {
                    "type": "textLength",
                    "inputs": {
                      "value": {
                        "var": "jsonText"
                      }
                    }
                  }
                }
              },
              {
                "type": "writeTextFile",
                "inputs": {
                  "path": {
                    "var": "outputPath"
                  },
                  "text": {
                    "var": "jsonText"
                  },
                  "append": false,
                  "flushNow": true
                }
              },
              {
                "type": "setVar",
                "inputs": {
                  "name": "outputExists",
                  "value": {
                    "type": "fileExists",
                    "inputs": {
                      "path": {
                        "var": "outputPath"
                      }
                    }
                  }
                }
              }
            ]
          }
        ]
      },
      "next": "b14"
    },
    "b14": {
      "type": "esConsoleLog",
      "inputs": {
        "message": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "SUMMARY|probe=transcript-export|itemName=\"",
              {
                "var": "itemName"
              },
              "\"|hasTranscript=",
              {
                "var": "hasTranscript"
              },
              "|jsonLength=",
              {
                "var": "jsonLength"
              },
              "|outputExists=",
              {
                "var": "outputExists"
              },
              "|outputPath=\"",
              {
                "var": "outputPath"
              },
              "\""
            ]
          }
        }
      },
      "next": null
    }
  }
}
