"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _Constants = require("./common/Constants");

var _reactNativeOrientation = _interopRequireDefault(require("react-native-orientation"));

var _reactNative = require("react-native");

var _react = _interopRequireWildcard(require("react"));

var _Colors = _interopRequireDefault(require("./common/Colors"));

var _reactNativeCamera = require("react-native-camera");

var _FontAwesome = _interopRequireDefault(require("react-native-vector-icons/FontAwesome"));

var _reactMoment = _interopRequireDefault(require("react-moment"));

var _geolocation = _interopRequireDefault(require("@react-native-community/geolocation"));

var _reactNativeVideoPlayer = _interopRequireDefault(require("react-native-video-player"));

var _ApiUrls = require("./Api/ApiUrls");

var _rnFetchBlob = _interopRequireDefault(require("rn-fetch-blob"));

var _reactNativeViewShot = _interopRequireDefault(require("react-native-view-shot"));

var _axios = _interopRequireDefault(require("axios"));

var _reactNativeBackgroundUpload = _interopRequireDefault(require("react-native-background-upload"));

var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));

var Progress = _interopRequireWildcard(require("react-native-progress"));

var _Status = _interopRequireDefault(require("./common/Status"));

var _reactNativeNavigationBarColor = require("react-native-navigation-bar-color");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactNativeImageMarker = _interopRequireDefault(require("react-native-image-marker"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// const IMEI = require('react-native-imei');
const initial = _reactNativeOrientation.default.getInitialOrientation();

let SCREEN_WIDTH;
let SCREEN_HEIGHT;

if (initial === 'PORTRAIT') {
  SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').width - 40);
  SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').height);
} else {
  SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').height);
  SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').width);
}

const crossMark = require('./common/Image/crossMark.png');

const tickMark = require('./common/Image/tickMark.png');

const car = require('./common/Image/car.png');

const Auto = require('./common/Image/Auto.png');

const Bike = require('./common/Image/Bike.png');

let dynammicactivityId = '';

class PI extends _react.Component {
  constructor(props) {
    super(props);

    _defineProperty(this, "takePicture", async function (camera) {
      const options = {
        quality: 0.2,
        base64: true
      };
      const data = await camera.takePictureAsync(options); //  eslint-disable-next-line

      this.setState({
        localPath: data.uri,
        cameraData: data,
        isDisplayCameraPreview: true,
        isDisplayCamera: false
      }); //path of photo
      // console.log(data);//path of photo

      this.watermarkLocation(); //Date calulation for the display on preciew Screen

      const date = new Date().getDate();
      const month = new Date().getMonth() + 1;
      const year = new Date().getFullYear(); //Time calulation for the display on preciew Screen

      const hour = new Date().getHours();
      const minute = new Date().getMinutes();
      const seconds = new Date().getSeconds(); //Alert.alert(date + '-' + month + '-' + year);
      // You can turn it in to your desired format

      this.setState({
        dateAndTime: date + '-' + month + '-' + year + "  " + hour + ':' + minute + ':' + seconds
      }); //format: dd-mm-yyyy;
    });

    _defineProperty(this, "renderItem", ({
      item
    }) => /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: styles.instructionText
    }, '\u2B24', " ", item.instructionData));

    _defineProperty(this, "uploadedDocumentStatus", ({
      item
    }) => /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        margin: 16,
        width: SCREEN_HEIGHT,
        height: SCREEN_WIDTH / 8.5,
        flexDirection: 'row'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.2
      }
    }, this.uploadedDocumentImageOrVideo(item)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.03,
        justifyContent: 'center'
      }
    }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.77
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.45,
        justifyContent: 'center'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, item.stepTitle)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.15,
        justifyContent: 'center'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, (item.imageSize / 1024).toString().split('.')[0], " KB")), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.15,
        justifyContent: 'center'
      }
    }, /*#__PURE__*/_react.default.createElement(Progress.Bar, {
      progress: item.upLoadStatus,
      width: SCREEN_HEIGHT / 1.5,
      color: _Colors.default.digitYellow,
      height: 2,
      borderColor: 'white'
    })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.25,
        justifyContent: 'center'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: {
        color: _Colors.default.digitYellow
      }
    }, item.upLoadStatus * 100, " % Completed")))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        borderRadius: 1,
        width: SCREEN_WIDTH,
        height: 1,
        borderWidth: 0.5,
        color: _Colors.default.borderBlack
      }
    })));

    this.state = {
      isDisplayQuoteInstruction: true,
      isWithQuote: true,
      isWithOutQuote: false,
      isDisplayInstruction: false,
      torchon: '',
      isDisplayCameraPreview: false,
      isDisplayCamera: false,
      localPath: '',
      flashState: true,
      //for flash
      dateAndTime: '',
      //date and time
      currentLongitude: 'unknown',
      //Initial Longitude
      currentLatitude: 'unknown',
      //Initial Latitude
      isDisplayVideoRecorder: false,
      instructionData: '',
      fullDataSource: '',
      assets: '',
      headerShown: false,
      count: 0,
      dataSource: '',
      cameraState: '',
      buttonText: '',
      skipdata: '',
      isBackButtonPressed: false,
      isSkipButtonPressed: false,
      extention: '',
      screenShotPath: '',
      isDisplayUploadDocument: false,
      upLoadIamgeDataSource: [],
      documentUploadPercentage: 0,
      odometerReading: '',
      ANDROID_ID: '',
      CurrentDate: '',
      showError: false,
      quoteNumber: '',
      showQuoteError: false,
      isLoading: true,
      registrationNumber: '',
      isSelected: false,
      isFocused: false
    };
  }

  componentDidMount() {
    this.handleBackButton();
  }

  handleBackButton() {
    if (_reactNative.Platform.OS === 'android') {
      this.backHandler = _reactNative.BackHandler.addEventListener('hardwareBackPress', () => {
        if (this.props !== undefined && this.props.screenProps !== undefined && this.props.screenProps.props !== undefined && this.props.screenProps.props.props !== undefined) {
          this.props.screenProps.props.props.navigation.pop();
        }

        return true;
      });
    }
  }

  captureButton() {
    //condition for Skip Documents
    if (this.state.skipdata == _Constants.PAN_CARD || this.state.skipdata == _Constants.AADHAR_CARD || this.state.skipdata == _Constants.CNG || this.state.skipdata == _Constants.POLICE_FIR || this.state.skipdata == _Constants.EXTERNAL_DAMAGE || this.state.skipdata == _Constants.INTERNAL_DAMAGE || this.state.skipdata == _Constants.DRIVING_LICENSE) {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 1,
          flexDirection: 'row'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.45
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => [this.setState({
          isDisplayInstruction: false
        })]
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.captureImageButtonText
      }, "Capture")))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.1
        }
      }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.45
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => [this.setState({
          isSkipButtonPressed: true
        }), this.increseCount()]
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.captureImageButtonText
      }, "Skip")))));
    } else if (this.state.rcbFront == 'RCB2') {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 1,
          flexDirection: 'row'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.45
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => [this.setState({
          isDisplayInstruction: false,
          count: this.state.count - 1
        })]
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontSize: 14,
          fontFamily: 'Muli-Black',
          alignSelf: 'center'
        }
      }, "Capture More")))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.1
        }
      }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.45
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => [this.setState({
          isSkipButtonPressed: true
        }), this.increseCount()]
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.captureImageButtonText
      }, "Skip")))));
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => this.validate()
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.captureImageButtonText
      }, this.state.buttonText)));
    }
  }

  validate() {
    if (this.state.skipdata == _Constants.ODOMETER) {
      if (this.state.odometerReading != '') {
        this.setState({
          isDisplayInstruction: false,
          showError: false,
          odometerReading: ''
        });
      } else {
        this.setState({
          isDisplayInstruction: true,
          showError: true
        });
      }
    } else {
      this.setState({
        isDisplayInstruction: false
      });
    }

    if (this.state.registrationNumber.length > 0 && this.state.isSelected == true && this.state.isDisplayInstruction == false) {
      this.setState({
        isDisplayInstruction: true,
        isWithOutQuote: false
      });
    }
  }

  validateQuote() {
    if (this.state.quoteNumber === '') {
      this.setState({
        showQuoteError: true
      });
      return false;
    } else {
      this.setState({
        showQuoteError: false
      });
      return true;
    }
  }
  /*
  **************************************************************************************************************
  */


  componentWillUnmount() {
    _geolocation.default.clearWatch(this.watchID); //For GeoLocation


    if (_reactNative.Platform.OS === 'android') {
      this.backHandler.remove();
    }
  }
  /*
  **************************************************************************************************************
  */

  /*
                             %%%%%%%%%%%%% For Take Picture %%%%%%%%%%%%%%%%
  */


  watermarkLocation() {
    return _reactNativeImageMarker.default.markText({
      src: this.state.localPath,
      text: 'lat: ' + this.state.currentLatitude + " " + "long: " + this.state.currentLongitude,
      position: 'topLeft',
      fontName: 'Muli-Regular',
      fontSize: 30,
      scale: 1,
      quality: 100,
      color: _Colors.default.digitYellow
    }).then(res => {
      this.setState({
        markLocationResult: 'file://' + res
      });
      console.log("the path is" + this.state.markLocationResult);
      this.watermarkDigitEdge();
    }).catch(err => {
      console.log(err);
      this.setState({
        err
      });
    }) // <Image
    //     source={this.state.ress}
    //     style={{ width: 500, height: 500, backgroundColor: 'blue' }}
    // />
    ;
  }

  watermarkDigitEdge() {
    return _reactNativeImageMarker.default.markText({
      src: this.state.markLocationResult,
      text: 'Digit Edge',
      position: 'topRight',
      fontName: 'Muli-Regular',
      fontSize: 30,
      scale: 1,
      quality: 100,
      color: _Colors.default.digitYellow
    }).then(res => {
      this.setState({
        markDigitEdgeResult: 'file://' + res
      });
      console.log("the path is" + this.state.markDigitEdgeResult);
      this.finalWatermark();
    }).catch(err => {
      console.log(err);
      this.setState({
        err
      });
    });
  }

  finalWatermark() {
    return _reactNativeImageMarker.default.markText({
      src: this.state.markDigitEdgeResult,
      text: this.state.dateAndTime,
      position: 'bottomLeft',
      fontName: 'Muli-Regular',
      fontSize: 30,
      scale: 1,
      quality: 30,
      color: _Colors.default.digitYellow
    }).then(res => {
      this.setState({
        finalWatermarkResult: 'file://' + res // isLoading: false

      });
      console.log("the path is" + this.state.finalWatermarkResult);
    }).catch(err => {
      console.log(err);
      this.setState({
        err
      });
    });
  }
  /*
  **************************************************************************************************************
  */

  /*
                               %%%%%%%%%%%%% For Video Record %%%%%%%%%%%%%%%%
    */


  async startRecording() {
    this.setState({
      recording: true
    }); // default to mp4 for android as codec is not set

    const options = {
      quality: 0.2,
      base64: true
    };
    const {
      uri,
      codec = "mp4"
    } = await this.camera.recordAsync(options);
    this.setState({
      localPath: uri
    });
    console.log(this.state.localPath);
  } //Stop Recording


  stopRecording() {
    this.camera.stopRecording();
    this.setState({
      isDisplayVideoPlayer: true,
      isDisplayVideoRecorder: false
    });
    this.setState({
      recording: false
    });
  }
  /*
  ******************************** for creating  floder at local storage*************************************
  */


  async createFloder(activityId, activityTypeId) {
    console.log(this.state.count);
    const POSP = _rnFetchBlob.default.fs.dirs.SDCardDir + '/POSP/'; //Create Floder in External storage

    this.setState({
      FilePath: POSP
    });
    let exists = await _rnFetchBlob.default.fs.exists(POSP); // checkExist 

    if (exists) {
      let isDir = await _rnFetchBlob.default.fs.isDir(POSP);

      if (isDir) {
        // Permission for storage
        const granted = await _reactNative.PermissionsAndroid.request(_reactNative.PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
          title: 'Read Internal Storage',
          message: 'Read Internal Storage',
          buttonPositive: 'Ok',
          buttonNegative: 'Cancle'
        });

        if (granted) {
          // if Granted
          const Image_Name = activityId + this.state.instructionData[this.state.count - 1].imageName + this.state.extention; //Image NAme with Extension

          this.setState({
            imageName: Image_Name
          });
          console.log(this.state.imageName);
          await _rnFetchBlob.default.fs.writeFile(POSP + Image_Name, 'base64'); // let _copy = await RNFetchBlob.fs.cp(this.state.screenShotPath, POSP + Image_Name);

          let _copy = await _rnFetchBlob.default.fs.cp(this.state.finalWatermarkResult, POSP + Image_Name);

          _rnFetchBlob.default.fs.stat(this.state.FilePath + this.state.imageName).then(stats => {
            console.log("FileName: " + stats.filename);
            console.log("FileSize: " + stats.size);
            console.log("type: " + stats.type);
            console.log("lastModified: " + stats.lastModified);
            this.setState({
              fileSize: stats.size
            });
          }).catch(err => {});

          this.uploadImage(activityId, activityTypeId);
        } else {
          // ask Permission
          this.createFloder();
        }
      }
    } else {
      //IF not then create floder
      _rnFetchBlob.default.fs.mkdir(POSP).catch(err => {
        console.log(err);
      });

      this.createFloder();
    }
  }
  /*
  **************************************************************************************************************
  */
  // For Flash


  toggleTorch() {
    if (this.state.flashState == true) {
      console.log('AUTO');
      this.setState({
        flashState: false
      });
    } else {
      this.setState({
        flashState: true
      });
      console.log('ON');
    }
  }
  /*
  **************************************************************************************************************
  */


  flatListOrNot() {
    if (this.state.skipdata != _Constants.ODOMETER) {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.infoScrollView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, null, /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
        data: this.state.dataSource,
        renderItem: this.renderItem,
        style: {
          fontFamily: 'Mulli-Regular'
        }
      })));
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.infoScrollViewWithTextInput
      }, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, null, /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
        data: this.state.dataSource,
        renderItem: this.renderItem
      }))), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.odometerText
      }, "Odometer Reading:"), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
        style: styles.odometerInputText,
        keyboardType: "numeric",
        onChangeText: odometerReading => this.setState({
          odometerReading
        })
      }), this.showErrorText());
    }
  }

  showErrorText() {
    if (this.state.showError) {
      return /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          color: 'red',
          marginLeft: 4,
          fontFamily: 'Muli-Regular'
        }
      }, "Enter Odometer Reading");
    }
  }

  showQuoteErrorText() {
    return /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: {
        color: 'red',
        marginLeft: 16,
        fontFamily: 'Muli-Regular'
      }
    }, "Enter quote number");
  }
  /*
  **************************************************************************************************************
  */
  //Display Data in FlatList


  //Checking the document image or Video
  uploadedDocumentImageOrVideo(item) {
    const type = item.imagePath.split('.');

    if (type[3] == 'mp4') {
      return /*#__PURE__*/_react.default.createElement(_reactNativeVideoPlayer.default, {
        video: {
          uri: item.imagePath
        },
        pauseOnPress: true,
        autoplay: true,
        disableSeek: true,
        style: {
          flex: 1
        }
      });
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
        source: {
          uri: item.imagePath
        },
        resizeMethod: "auto",
        resizeMode: "contain",
        style: {
          flex: 1,
          resizeMode: 'contain'
        }
      });
    }
  } //Display image or video


  imageOrVideo() {
    if (this.state.assets == _Constants.VIDEO_URL && this.state.isDisplayVideoRecorder == true) {
      return /*#__PURE__*/_react.default.createElement(_reactNativeVideoPlayer.default, {
        video: {
          uri: "https://d2h44aw7l5xdvz.cloudfront.net/videos/self-inspection-for-car.mp4"
        },
        videoHeight: SCREEN_HEIGHT,
        videoWidth: SCREEN_WIDTH,
        pauseOnPress: true,
        autoplay: true,
        disableSeek: true,
        style: {
          flex: 1
        }
      });
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
        source: {
          uri: this.state.assets
        },
        style: styles.productImageStyle,
        resizeMethod: "auto",
        resizeMode: "contain"
      });
    }
  }
  /*
  **************************************************************************************************************
  */
  //reduce the count


  reduceCount() {
    if (this.state.count >= 1) {
      this.setState({
        count: this.state.count - 1
      });
    }

    setInterval(() => {
      if (this.state.isBackButtonPressed == true) {
        this.renderDataToScreen();
      }

      this.setState({
        isBackButtonPressed: false
      });
    }, 100);
  }
  /*
  **************************************************************************************************************
  */
  //increase the count


  increseCount() {
    if (this.state.count <= this.state.instructionData.length) {
      this.setState({
        count: this.state.count + 1
      });
    }

    setInterval(() => {
      if (this.state.isSkipButtonPressed == true) {
        this.renderDataToScreen();
      }

      this.setState({
        isSkipButtonPressed: false
      });
    }, 100);
  }
  /*
    **************************************************************************************************************
    */
  //Load after screen shot 
  // onImageLoad = () => {
  //     this.setState({ isImageLoad: true })
  //     setInterval(() => {
  //         if (this.state.isImageLoad == true) {
  //             this.refs.viewShot.capture().then(uri => {
  //                 this.setState({ screenShotPath: uri })
  //                 console.log("do something with ", this.state.screenShotPath);
  //             })
  //         }
  //         this.setState({ isImageLoad: false })
  //     }, 300);
  // };

  /*
  **************************************************************************************************************
  */
  //upload images


  uploadImage(activityId) {
    const documentUploadData = {
      "activityId": activityId,
      "documentSource": "DigitEdge",
      "geoLocation": {
        "deviceIMEI": this.state.ANDROID_ID,
        "deviceName": this.state.DEVICE_NAME,
        "deviceTime": this.state.CurrentDate,
        "documentSource": "DigitEdge",
        "ipAddress": this.state.IP,
        "isBlocked": false,
        "latitude": this.state.currentLatitude,
        "longitude": this.state.currentLongitude,
        "macAddress": this.state.MAC,
        "operatingSystem": this.state.VERSION,
        "timezone": "Asia/Kolkata"
      },
      "isLast": false,
      "isLastData": false,
      "isLastDocument": false,
      "isSurveyor": false,
      "manualOdometerReading": "",
      "source": "DIGITEDGE"
    };

    _rnFetchBlob.default.fetch('POST', _ApiUrls.SELFSURVEYSERVICE_DOCUMENT_URL, {
      'Content-Type': 'multipart/form-data'
    }, [// element with property `filename` will be transformed into `file` in form data
    //file name is Original file name
    {
      name: 'file',
      filename: this.state.imageName,
      type: 'image/jpg',
      data: this.state.FilePath + this.state.imageName
    }, {
      name: 'documentData',
      data: JSON.stringify(documentUploadData)
    }]).uploadProgress({
      interval: 250
    }, (written, total) => {
      console.log('Written', written);
      console.log('total', total);
      console.log('uploaded', written / total);
      this.setState({
        documentUploadPercentage: written / total
      });
    }) // listen to download progress event, every 10%
    .progress({
      count: 10
    }, (received, total) => {
      console.log('progress', received / total); // let isExisist = this.state.upLoadIamgeDataSource.find(this.state.upLoadIamgeDataSource.stepTitle == this.state.instructionData[this.state.count - 1].stepTitle)

      this.state.upLoadIamgeDataSource.push({
        imagePath: 'file://' + this.state.FilePath + this.state.imageName,
        stepTitle: this.state.instructionData[this.state.count - 1].stepTitle,
        imageSize: this.state.fileSize,
        upLoadStatus: this.state.documentUploadPercentage
      });

      if (this.state.count == this.state.instructionData.length) {
        // if (this.state.count == 3) {
        console.log(this.state.count);
        this.props.navigation.navigate("DocumentUpload");
      }

      console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + this.state.upLoadIamgeDataSource.length);
    }).then(response => {
      console.log("******************** resp: " + JSON.stringify(response));
    }).catch(err => {
      console.log("******************** err: " + JSON.stringify(err));
    });

    this.renderDataToScreen();
  }

  render() {
    const {
      activityId,
      activityTypeId
    } = this.props.screenProps; //************************** Insruction Screen*************************************** */

    {
      console.log("activityId from user" + activityId);
    } // { console.log("activityTypeId from user" + activityTypeId) }
    //Activity ID

    dynammicactivityId = activityTypeId; // frist page 

    if (this.state.isWithQuote == true) {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 1,
          backgroundColor: '#FFFFFF'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.StatusBar, {
        hidden: true
      }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.9
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          width: SCREEN_WIDTH,
          height: 70,
          backgroundColor: '#F5F5F5',
          justifyContent: 'center',
          marginBottom: 16
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Bold',
          fontSize: 20,
          marginLeft: 16
        }
      }, "Pre Inspection")), /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          marginLeft: 16,
          fontSize: 16,
          fontFamily: 'Muli-Bold',
          marginBottom: 4
        }
      }, "Quote/Policy Number"), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
        style: {
          borderColor: 'black',
          borderWidth: 1,
          marginLeft: 16,
          borderRadius: 4,
          fontFamily: 'Muli-Regular',
          fontSize: 16
        },
        placeholder: "Quote Number",
        keyboardType: "default",
        onChangeText: quoteNumber => this.setState({
          quoteNumber
        })
      }), this.state.showQuoteError && this.showQuoteErrorText()), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          marginTop: 22
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => this.props.navigation.navigate("WithOutQuote")
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          marginLeft: 16,
          fontSize: 16,
          fontFamily: 'Muli-Bold',
          color: _Colors.default.digitYellow
        }
      }, "Don't have Quote Number")))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.1,
          justifyContent: 'flex-start'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          marginLeft: 16
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
        onPress: () => {
          this.validateQuote() && this.props.navigation.navigate("QuoteInstructions");
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styles.captureImageButtonView
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.captureImageButtonText
      }, "Continue"))))));
    } // if (this.state.isDisplayVideoRecorder == true) {
    //     const { recording, processing } = this.state;
    //     let button = (
    //         <View style={{ flex: 1, position: 'absolute', width: SCREEN_WIDTH, height: SCREEN_HEIGHT }}>
    //             <View style={{ flex: 0.5, justifyContent: 'flex-end' }}>
    //                 <TouchableOpacity onPress={() => [this.startRecording()]} style={styles.capture}>
    //                     {/* <Text style={{ fontSize: 14 }}> SNAP </Text> */}
    //                     <Icon
    //                         name="video-camera"
    //                     />
    //                 </TouchableOpacity>
    //             </View>
    //         </View>
    //     );
    //     if (recording) {
    //         button = (
    //             <View style={{ flex: 1, position: 'absolute', width: SCREEN_WIDTH, height: SCREEN_HEIGHT }}>
    //                 <View style={{ flex: 0.5, justifyContent: 'flex-end' }}>
    //                     <TouchableOpacity onPress={() => [this.stopRecording()]} style={styles.capture}>
    //                         {/* <Text style={{ fontSize: 14 }}> SNAP </Text> */}
    //                         <Icon
    //                             name="video-off-outline"
    //                         />
    //                     </TouchableOpacity>
    //                 </View>
    //             </View>
    //         );
    //     }
    //     return (
    //         <View style={styles.container}>
    //             <StatusBar
    //                 hidden={true}
    //             />
    //             <RNCamera
    //                 ref={ref => {
    //                     this.camera = ref;
    //                 }}
    //                 style={styles.preview}
    //                 type={RNCamera.Constants.Type.back}
    //                 flashMode={RNCamera.Constants.FlashMode.on}
    //                 permissionDialogTitle={"Permission to use camera"}
    //                 permissionDialogMessage={
    //                     "We need your permission to use your camera phone"
    //                 }
    //             >
    //                 {({ camera, status, recordAudioPermissionStatus }) => {
    //                     // if (status !== 'READY') return <PendingView />;
    //                     return (
    //                         <View style={{ flex: 1, position: 'absolute', width: SCREEN_WIDTH, height: SCREEN_HEIGHT }}>
    //                             <Image
    //                                 source={crossMark}
    //                                 style={{ width: 50, height: 50, position: 'absolute', left: 1, }}
    //                             />
    //                             <Image
    //                                 source={crossMark}
    //                                 style={{ width: 50, height: 50, position: 'absolute', left: 1, bottom: 1, }}
    //                             />
    //                             <Image
    //                                 source={crossMark}
    //                                 style={{ width: 50, height: 50, position: 'absolute', right: 1, bottom: 1, }}
    //                             />
    //                             <Image
    //                                 source={crossMark}
    //                                 style={{ width: 50, height: 50, position: 'absolute', right: 1 }}
    //                             />
    //                             {button}
    //                         </View>
    //                     );
    //                 }}
    //             </RNCamera>
    //         </View>
    //     );
    // }
    // //             //**************************Video Player*************************************** */
    // if (this.state.isDisplayVideoPlayer == true) {
    //     return (
    //         <View>
    //             <StatusBar
    //                 hidden={true}
    //             />
    //             <VideoPlayer
    //                 video={{ uri: this.state.localPath }}
    //                 videoWidth={SCREEN_WIDTH}
    //                 videoHeight={SCREEN_HEIGHT}
    //                 pauseOnPress={true}
    //                 seekBarWidth={5}
    //             >
    //             </VideoPlayer>
    //             {/* Buttons on video player */}
    //             <View style={{ position: 'absolute', left: 10, bottom: 50 }}>
    //                 <TouchableOpacity onPress={() => this.setState({ isDisplayVideoRecorder: true })}>
    //                     <Text style={{ backgroundColor: Colors.digitYellow, paddingTop: 3, paddingBottom: 3, paddingLeft: 6, paddingRight: 6, borderRadius: 4 }}>RETRY</Text>
    //                 </TouchableOpacity>
    //             </View>
    //             {/* Buttons on video player */}
    //             <View style={{ position: 'absolute', right: 10, bottom: 50 }}>
    //                 <TouchableOpacity onPress={() => [this.setState({ isDisplayVideoPlayer: false, isDisplayInstruction: true, isDisplayVideoRecorder: false, count: this.state.count + 1 }), this.createFloder(activityId, activityTypeId)]}>
    //                     <Text style={{ backgroundColor: Colors.digitYellow, paddingTop: 3, paddingBottom: 3, paddingLeft: 6, paddingRight: 6, borderRadius: 4 }}>SUBMIT</Text>
    //                 </TouchableOpacity>
    //             </View>
    //         </View>
    //     )
    // }
    // //////////////////////////////////////////////////////////////////////////////
    // if (this.state.isDisplayUploadDocument == true) {
    //     return (
    //         <View>
    //             <StatusBar
    //                 hidden={true}
    //             />
    //             <View style={styles.documentProcessView}>
    //                 <Text style={styles.documentProcessHeader}>Document being processd!</Text>
    //             </View>
    //             <View style={{ width: SCREEN_WIDTH, height: SCREEN_WIDTH }}>
    //                 <FlatList
    //                     data={this.state.upLoadIamgeDataSource}
    //                     keyExtractor={(item, index) => item.index}
    //                     renderItem={this.uploadedDocumentStatus}
    //                     maxToRenderPerBatch={100}
    //                     updateCellsBatchingPeriod={1000}
    //                     style={{
    //                         backgroundColor: 'white', marginBottom: 40, fontFamily: 'Mulli-Regular',
    //                     }}
    //                 />
    //             </View>
    //         </View>
    //     )
    // }

  }

}

exports.default = PI;

_defineProperty(PI, "navigationOptions", {
  //To hide the NavigationBar from current Screen
  headerShown: false
});

PI.propTypes = {
  activityId: _propTypes.default.string,
  activityTypeId: _propTypes.default.string
};
PI.defaultProps = {
  activityId: '-1',
  activityTypeId: '-1'
};

const styles = _reactNative.StyleSheet.create({
  main: {
    flex: 1,
    flexDirection: 'row',
    backgroundColor: '#FFFFFF'
  },
  productImageView: {
    flex: 0.475
  },
  blankView: {
    flex: 0.05
  },
  productInfoView: {
    flex: 0.475,
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT
  },
  headerView: {
    backgroundColor: '#F5F5F5',
    height: 60,
    justifyContent: 'center'
  },
  headerText: {
    marginLeft: 16,
    fontSize: 16,
    fontFamily: 'Muli-Black',
    marginRight: 16
  },
  documentProcessHeader: {
    marginLeft: 16,
    fontSize: 26,
    fontFamily: 'Muli-Black',
    marginRight: 16,
    justifyContent: 'center'
  },
  documentProcessView: {
    width: SCREEN_WIDTH,
    height: 60,
    justifyContent: 'center',
    backgroundColor: '#F5F5F5'
  },
  productImageStyle: {
    marginTop: 8,
    marginLeft: 16,
    marginBottom: 40,
    height: SCREEN_HEIGHT - 70
  },
  backButtonImageStyle: {
    marginLeft: 32,
    height: 30,
    width: 40,
    backgroundColor: 'red'
  },
  subHeaderText: {
    fontFamily: 'Mulli-Regular',
    fontSize: 16,
    marginLeft: 16,
    marginRight: 16
  },
  instructionText: {
    fontFamily: 'Mulli-Regular',
    fontSize: 16,
    marginLeft: 32,
    marginBottom: 20,
    marginRight: 16
  },
  captureImageButtonView: {
    height: 48,
    borderRadius: 4,
    backgroundColor: _Colors.default.digitYellow,
    marginTop: 2,
    flexDirection: 'row',
    justifyContent: 'center',
    marginRight: 16
  },
  captureImageButtonText: {
    fontSize: 16,
    fontFamily: 'Muli-Black',
    alignSelf: 'center'
  },
  container: {
    flex: 1 // flexDirection: 'row',
    // backgroundColor: 'black',

  },
  preview: {
    flex: 1,
    justifyContent: 'flex-end',
    alignItems: 'center'
  },
  capture: {
    flex: 0,
    backgroundColor: '#fff',
    borderRadius: 5,
    padding: 15,
    paddingHorizontal: 20,
    alignSelf: 'flex-end',
    margin: 20,
    position: 'absolute'
  },
  flash: {
    flex: 0,
    backgroundColor: '#fff',
    borderRadius: 5,
    padding: 15,
    paddingHorizontal: 20,
    alignSelf: 'flex-end',
    margin: 20,
    position: 'absolute'
  },
  previewImageStyle: {
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT,
    resizeMode: 'contain'
  },
  dateAndTimeText: {
    position: 'absolute',
    fontSize: 20,
    color: _Colors.default.digitYellow,
    left: 1,
    bottom: 1
  },
  previewImageIconMainView: {
    flex: 0.05,
    backgroundColor: 'black'
  },
  tickMarkImageView: {
    flex: 0.6,
    justifyContent: 'flex-end'
  },
  tickMarkImageStyle: {
    width: 30,
    height: 30,
    backgroundColor: 'white',
    alignSelf: 'center',
    marginBottom: 20
  },
  crossImageView: {
    flex: 0.4,
    justifyContent: 'flex-end',
    marginBottom: 20
  },
  crossImageStyle: {
    width: 30,
    height: 30,
    backgroundColor: 'white',
    alignSelf: 'center'
  },
  cameraIconView: {
    flexDirection: 'row',
    justifyContent: 'center',
    width: SCREEN_WIDTH,
    position: 'absolute'
  },
  infoScrollView: {
    marginTop: 40,
    height: SCREEN_HEIGHT - 220
  },
  subHeaderTextView: {
    height: 40,
    marginTop: 8
  },
  backButtonImageView: {
    backgroundColor: '#F5F5F5',
    height: 60,
    justifyContent: 'center'
  },
  latLongText: {
    position: 'absolute',
    fontSize: 20,
    color: _Colors.default.digitYellow,
    left: 1
  },
  digitEdgeText: {
    position: 'absolute',
    fontSize: 20,
    color: _Colors.default.digitYellow,
    right: 1
  },
  odometerText: {
    fontSize: 16,
    fontFamily: 'Muli-Black',
    marginLeft: 16
  },
  odometerInputText: {
    fontSize: 16,
    fontFamily: 'Muli-Black',
    borderRadius: 4,
    borderColor: _Colors.default.digitYellow,
    borderWidth: 1,
    marginTop: 5,
    marginRight: 16,
    marginBottom: 5
  },
  infoScrollViewWithTextInput: {
    height: SCREEN_HEIGHT - 270
  } // productImageView: {
  //     flexDirection: 'row',
  //     justifyContent: 'center'
  // },
  // productImage: {
  //     width: 50,
  //     height: 50,
  //     marginTop: 16,
  //     flexDirection: 'row',
  //     justifyContent: 'space-around',
  //     marginLeft: 16,
  //     marginRight: 16
  // },

});
//# sourceMappingURL=PI.js.map