this.primevue = this.primevue || {};
this.primevue.inputtext = (function (vue) {
  'use strict';

  var script = {
      name: 'InputText',
      emits: ['update:modelValue','update-editing-cell-class'],

      props: {
          modelValue: null,

          align:{
              type:String,
              default:null
          },

          case:{
              type:String,
              default:""
          },

          autoSelection:{
              type:Boolean,
              default:true
          },

          tableCellEditor:{
              type:Boolean,
              default:false
          }
      },
      data(){
         return {
             d_displayValue: this.modelValue
         }
      },
      watch: {
          modelValue(newValue) {
            if(newValue!==this.d_displayValue){
                this.d_displayValue = this.formatValue( newValue);
            }
          },
      },
      created(){
         if(this.tableCellEditor){
              this.$emit("update-editing-cell-class","p-cell-editing-border");
         }
      },
    
      methods: {
          onInput(event) {
              //this.$emit('update:modelValue', event.target.value);
              this.d_displayValue  = this.formatValue( event.target.value || '');
          },

          onChange(event) {
              const value= this.formatValue( event.target.value || '');

              if(value!==this.d_displayValue){
                  this.d_displayValue = value;
              }
              
              this.$emit('update:modelValue', value);
          },

          onFocus(){
              this.autoSelection && this.$el.select();
          },

          formatValue(value){

              if( value===null || value===undefined || value==='' )
                  return '';

              let case2=this.case.trim().toUpperCase();
           
              if(case2 ==='UPPER'){
                  value =value.toString().toUpperCase();
              }
              else if(case2 ==='LOWER'){
                  value = value.toString().toLowerCase();
              }

              return value;
           },
      },

      computed:{

          containerClass() {
              const align= this.align || '';
              const alignClass= (align==='')? null : 'text-'+align;

              return [{'p-cell-editor': this.tableCellEditor }, 'p-inputtext','p-component', alignClass, ];
          },
          // displayValue(){
          //     return this.formatValue(this.modelValue)
          // }
      }
  };

  const _hoisted_1 = ["value"];

  function render(_ctx, _cache, $props, $setup, $data, $options) {
    return (vue.openBlock(), vue.createElementBlock("input", {
      class: vue.normalizeClass($options.containerClass),
      value: $data.d_displayValue,
      onInput: _cache[0] || (_cache[0] = (...args) => ($options.onInput && $options.onInput(...args))),
      onChange: _cache[1] || (_cache[1] = (...args) => ($options.onChange && $options.onChange(...args))),
      onFocus: _cache[2] || (_cache[2] = (...args) => ($options.onFocus && $options.onFocus(...args)))
    }, null, 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_1))
  }

  script.render = render;
  script.__file = "components/lib/inputtext/InputText.vue";

  return script;

})(Vue);
