'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _reactIntl = require('react-intl');

exports.default = pluginContext => {
  var _pluginContext$inputC = pluginContext.inputComponents;
  const AutocompleteInput = _pluginContext$inputC.AutocompleteInput,
        CompoundInput = _pluginContext$inputC.CompoundInput,
        DateInput = _pluginContext$inputC.DateInput,
        HierarchyInput = _pluginContext$inputC.HierarchyInput,
        OptionPickerInput = _pluginContext$inputC.OptionPickerInput,
        TextInput = _pluginContext$inputC.TextInput,
        TermPickerInput = _pluginContext$inputC.TermPickerInput,
        CheckboxInput = _pluginContext$inputC.CheckboxInput,
        StructuredDateInput = _pluginContext$inputC.StructuredDateInput;
  const config = pluginContext.configHelpers.configKey;
  var _pluginContext$dataTy = pluginContext.dataTypes;
  const DATA_TYPE_BOOL = _pluginContext$dataTy.DATA_TYPE_BOOL,
        DATA_TYPE_STRUCTURED_DATE = _pluginContext$dataTy.DATA_TYPE_STRUCTURED_DATE;
  const extensions = pluginContext.config.extensions;


  return {
    document: Object.assign({
      [config]: {
        view: {
          type: CompoundInput,
          props: {
            defaultChildSubpath: 'ns2:organizations_common'
          }
        }
      },
      'rel:relations-common-list': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/relation'
          }
        },
        'relation-list-item': {
          [config]: {
            view: {
              type: HierarchyInput,
              props: {
                messages: (0, _reactIntl.defineMessages)({
                  parent: {
                    'id': 'hierarchyInput.organization.parent',
                    'defaultMessage': 'Broader organization'
                  },
                  children: {
                    'id': 'hierarchyInput.organization.children',
                    'defaultMessage': 'Narrower organizations'
                  },
                  siblings: {
                    'id': 'hierarchyInput.organization.siblings',
                    'defaultMessage': 'Adjacent organizations'
                  }
                })
              }
            }
          }
        }
      }
    }, extensions.core.fields, {
      'ns2:organizations_common': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/organization'
          }
        },
        csid: {
          [config]: {
            cloneable: false
          }
        },
        inAuthority: {
          [config]: {
            cloneable: false
          }
        },
        refName: {
          [config]: {
            cloneable: false
          }
        },
        shortIdentifier: {
          [config]: {
            cloneable: false
          }
        },
        orgTermGroupList: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              required: {
                'id': 'field.organizations_common.orgTermGroupList.required',
                'defaultMessage': 'At least one term display name is required. Please enter a value.'
              }
            }),
            required: true,
            view: {
              type: CompoundInput
            }
          },
          orgTermGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.orgTermGroup.name',
                  'defaultMessage': 'Term'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput
              }
            },
            termDisplayName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termDisplayName.name',
                    'defaultMessage': 'Display name'
                  }
                }),
                required: true,
                view: {
                  type: TextInput
                }
              }
            },
            termName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termName.name',
                    'defaultMessage': 'Name'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'orgTermTypes'
                  }
                }
              }
            },
            termFlag: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.organizations_common.termFlag.fullName',
                    'defaultMessage': 'Term flag'
                  },
                  name: {
                    'id': 'field.organizations_common.termFlag.name',
                    'defaultMessage': 'Flag'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'orgtermflag'
                  }
                }
              }
            },
            termStatus: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termStatus.name',
                    'defaultMessage': 'Status'
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'orgTermStatuses'
                  }
                }
              }
            },
            termQualifier: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termQualifier.name',
                    'defaultMessage': 'Qualifier'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termLanguage: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.organizations_common.termLanguage.fullName',
                    'defaultMessage': 'Term language'
                  },
                  name: {
                    'id': 'field.organizations_common.termLanguage.name',
                    'defaultMessage': 'Language'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'languages'
                  }
                }
              }
            },
            termPrefForLang: {
              [config]: {
                dataType: DATA_TYPE_BOOL,
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termPrefForLang.name',
                    'defaultMessage': 'Preferred for lang'
                  }
                }),
                view: {
                  type: CheckboxInput
                }
              }
            },
            termSource: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termSource.name',
                    'defaultMessage': 'Name'
                  },
                  fullName: {
                    'id': 'field.organizations_common.termSource.fullName',
                    'defaultMessage': 'Source name'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'citation/local,citation/worldcat'
                  }
                }
              }
            },
            termSourceDetail: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termSourceDetail.name',
                    'defaultMessage': 'Detail'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceID: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termSourceID.name',
                    'defaultMessage': 'ID'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceNote: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.termSourceNote.name',
                    'defaultMessage': 'Note'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            mainBodyName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.mainBodyName.name',
                    'defaultMessage': 'Main body name'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            additionsToName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.organizations_common.additionsToName.name',
                    'defaultMessage': 'Addition'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            }
          }
        },
        organizationRecordTypes: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          organizationRecordType: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.organizationRecordType.name',
                  'defaultMessage': 'Organization type'
                }
              }),
              repeating: true,
              view: {
                type: TermPickerInput,
                props: {
                  source: 'organizationtype'
                }
              }
            }
          }
        },
        foundingDateGroup: Object.assign({
          [config]: {
            dataType: DATA_TYPE_STRUCTURED_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.organizations_common.foundingDateGroup.name',
                'defaultMessage': 'Foundation date'
              }
            }),
            searchView: {
              type: DateInput
            },
            view: {
              type: StructuredDateInput
            }
          }
        }, extensions.structuredDate.fields),
        dissolutionDateGroup: Object.assign({
          [config]: {
            dataType: DATA_TYPE_STRUCTURED_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.organizations_common.dissolutionDateGroup.name',
                'defaultMessage': 'Dissolution date'
              }
            }),
            searchView: {
              type: DateInput
            },
            view: {
              type: StructuredDateInput
            }
          }
        }, extensions.structuredDate.fields),
        foundingPlace: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.organizations_common.foundingPlace.name',
                'defaultMessage': 'Foundation place'
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        groups: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          group: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.group.name',
                  'defaultMessage': 'Group'
                }
              }),
              repeating: true,
              view: {
                type: TextInput
              }
            }
          }
        },
        functions: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          function: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.function.name',
                  'defaultMessage': 'Function'
                }
              }),
              repeating: true,
              view: {
                type: TextInput
              }
            }
          }
        },
        historyNotes: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          historyNote: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.historyNote.name',
                  'defaultMessage': 'History'
                }
              }),
              repeating: true,
              view: {
                type: TextInput,
                props: {
                  multiline: true
                }
              }
            }
          }
        },
        contactNames: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          contactName: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.organizations_common.contactName.name',
                  'defaultMessage': 'Contact name'
                }
              }),
              repeating: true,
              view: {
                type: AutocompleteInput,
                props: {
                  source: 'person/local'
                }
              }
            }
          }
        }
      }
    })
  };
};