{
 "schema_version": "1.0",
 "nodes": [
  {
   "id": "photos",
   "type": "input/json_value",
   "label": "Photos to list",
   "parameters": { "value": [{"sku": "TP-01", "photo": "__TP_01__"}, {"sku": "TP-02", "photo": "__TP_02__"}, {"sku": "VS-01", "photo": "__VS_01__"}, {"sku": "VS-02", "photo": "__VS_02__"}, {"sku": "AM-01", "photo": "__AM_01__"}, {"sku": "AM-02", "photo": "__AM_02__"}, {"sku": "PB-01", "photo": "__PB_01__"}],
    "required": true
   }
  },
  {
   "id": "each",
   "type": "enumerate/json",
   "label": "One photo at a time",
   "parameters": {
    "emptyBehavior": "fail",
    "jsonConfig": {
     "arrayPath": "(root)",
     "properties": [
      {
       "sourcePath": "sku",
       "outputPort": "sku",
       "outputType": "text",
       "selected": true,
       "label": "SKU"
      },
      {
       "sourcePath": "photo",
       "outputPort": "photo",
       "outputType": "image",
       "selected": true,
       "label": "Photo"
      }
     ]
    }
   }
  },
  {
   "id": "check",
   "type": "ai/decide",
   "label": "Check the photo",
   "parameters": {
    "questions": {
     "schema": "madoo.decision-questions/v1",
     "questions": [
      {
       "name": "in_focus",
       "type": "yes_no",
       "instructions": "The photo is in focus: the product is sharp, not blurred.",
       "threshold": 0.8
      },
      {
       "name": "well_exposed",
       "type": "yes_no",
       "instructions": "The photo is well exposed: neither too dark nor too bright to see the product.",
       "threshold": 0.8
      },
      {
       "name": "clean",
       "type": "yes_no",
       "instructions": "The image is free of watermarks, logos and overlaid text.",
       "threshold": 0.8
      },
      {
       "name": "whole_product",
       "type": "yes_no",
       "instructions": "The whole product is inside the frame, not cut off by the edges.",
       "threshold": 0.8
      },
      {
       "name": "background",
       "type": "choice",
       "instructions": "What is behind the product?",
       "options": [
        {
         "value": "plain",
         "description": "A plain studio background, white, grey or one colour"
        },
        {
         "value": "scene",
         "description": "A room, a table, outdoors or any real setting"
        },
        {
         "value": "other",
         "description": "Anything else"
        }
       ],
       "threshold": 0.7
      }
     ]
    },
    "image_detail": "low"
   }
  },
  {
   "id": "plain",
   "type": "utility/predicate",
   "label": "Plain background?",
   "parameters": {
    "operation": "equals",
    "compare_text": "plain"
   }
  },
  {
   "id": "publishable",
   "type": "utility/boolean_combine",
   "label": "Every check passed, every answer sure",
   "parameters": {
    "mode": "all"
   }
  },
  {
   "id": "keep",
   "type": "utility/filter",
   "label": "Only publishable photos",
   "parameters": {
    "invert": false
   }
  },
  {
   "id": "square",
   "type": "image/resize",
   "label": "Marketplace square",
   "parameters": {
    "unit": "px",
    "width": 1600,
    "height": 1600,
    "mode": "pad",
    "backgroundColor": "#FFFFFF",
    "never_enlarge": false
   }
  },
  {
   "id": "ready",
   "type": "aggregate/json",
   "label": "Ready to list",
   "parameters": {
    "emptyBehavior": "empty",
    "jsonAggregateConfig": {
     "prettyPrint": true,
     "outputName": "ready",
     "columns": [
      {
       "name": "sku",
       "inputPort": "sku",
       "type": "text"
      },
      {
       "name": "image",
       "inputPort": "image",
       "type": "image",
       "whenAbsent": "skip_row"
      }
     ]
    }
   }
  },
  {
   "id": "report",
   "type": "aggregate/json",
   "label": "Screening report",
   "parameters": {
    "jsonAggregateConfig": {
     "prettyPrint": true,
     "outputName": "screening",
     "columns": [
      {
       "name": "sku",
       "inputPort": "sku",
       "type": "text"
      },
      {
       "name": "publishable",
       "inputPort": "publishable",
       "type": "boolean"
      },
      {
       "name": "in_focus",
       "inputPort": "in_focus",
       "type": "boolean"
      },
      {
       "name": "well_exposed",
       "inputPort": "well_exposed",
       "type": "boolean"
      },
      {
       "name": "clean",
       "inputPort": "clean",
       "type": "boolean"
      },
      {
       "name": "whole_product",
       "inputPort": "whole_product",
       "type": "boolean"
      },
      {
       "name": "background",
       "inputPort": "background",
       "type": "text"
      },
      {
       "name": "model_sure",
       "inputPort": "model_sure",
       "type": "boolean"
      }
     ]
    }
   }
  },
  {
   "id": "o_ready",
   "type": "output/json",
   "label": "Ready to list",
   "parameters": {
    "output_name": "ready"
   }
  },
  {
   "id": "o_report",
   "type": "output/json",
   "label": "Screening report",
   "parameters": {
    "output_name": "screening_report"
   }
  }
 ],
 "connections": [
  {
   "from_node": "photos",
   "from_output": "json",
   "to_node": "each",
   "to_input": "json"
  },
  {
   "from_node": "each",
   "from_output": "photo",
   "to_node": "check",
   "to_input": "images_0"
  },
  {
   "from_node": "check",
   "from_output": "background",
   "to_node": "plain",
   "to_input": "a"
  },
  {
   "from_node": "check",
   "from_output": "in_focus",
   "to_node": "publishable",
   "to_input": "conditions_0"
  },
  {
   "from_node": "check",
   "from_output": "well_exposed",
   "to_node": "publishable",
   "to_input": "conditions_1"
  },
  {
   "from_node": "check",
   "from_output": "clean",
   "to_node": "publishable",
   "to_input": "conditions_2"
  },
  {
   "from_node": "check",
   "from_output": "whole_product",
   "to_node": "publishable",
   "to_input": "conditions_3"
  },
  {
   "from_node": "plain",
   "from_output": "result",
   "to_node": "publishable",
   "to_input": "conditions_4"
  },
  {
   "from_node": "check",
   "from_output": "all_accepted",
   "to_node": "publishable",
   "to_input": "conditions_5"
  },
  {
   "from_node": "publishable",
   "from_output": "result",
   "to_node": "keep",
   "to_input": "condition"
  },
  {
   "from_node": "each",
   "from_output": "photo",
   "to_node": "keep",
   "to_input": "value"
  },
  {
   "from_node": "keep",
   "from_output": "value",
   "to_node": "square",
   "to_input": "image"
  },
  {
   "from_node": "each",
   "from_output": "sku",
   "to_node": "ready",
   "to_input": "sku"
  },
  {
   "from_node": "square",
   "from_output": "result",
   "to_node": "ready",
   "to_input": "image"
  },
  {
   "from_node": "each",
   "from_output": "sku",
   "to_node": "report",
   "to_input": "sku"
  },
  {
   "from_node": "publishable",
   "from_output": "result",
   "to_node": "report",
   "to_input": "publishable"
  },
  {
   "from_node": "check",
   "from_output": "in_focus",
   "to_node": "report",
   "to_input": "in_focus"
  },
  {
   "from_node": "check",
   "from_output": "well_exposed",
   "to_node": "report",
   "to_input": "well_exposed"
  },
  {
   "from_node": "check",
   "from_output": "clean",
   "to_node": "report",
   "to_input": "clean"
  },
  {
   "from_node": "check",
   "from_output": "whole_product",
   "to_node": "report",
   "to_input": "whole_product"
  },
  {
   "from_node": "check",
   "from_output": "background",
   "to_node": "report",
   "to_input": "background"
  },
  {
   "from_node": "check",
   "from_output": "all_accepted",
   "to_node": "report",
   "to_input": "model_sure"
  },
  {
   "from_node": "ready",
   "from_output": "result",
   "to_node": "o_ready",
   "to_input": "json"
  },
  {
   "from_node": "report",
   "from_output": "result",
   "to_node": "o_report",
   "to_input": "json"
  }
 ]
}