text: import e,{Component as t}from"react";import{classNames as n,ObjectUtils as o}from"primereact/core";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){return!t||"object"!==p(t)&&"function"!=typeof t?l(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var m,y,h,b=function(s){c(g,t);var p,m,y,h,b,v=(p=g,m=f(),function(){var e,t=u(p);if(m){var n=u(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return a(this,e)});function g(e){var t;return r(this,g),(t=v.call(this,e)).state={visible:!0},t.close=t.close.bind(l(t)),t.onKeyDown=t.onKeyDown.bind(l(t)),t}return y=g,(h=[{key:"onKeyDown",value:function(e){13===e.keyCode&&this.close(e)}},{key:"close",value:function(e){var t=this;e.persist(),this.setState({visible:!1},(function(){t.props.onRemove&&t.props.onRemove(e)}))}},{key:"renderContent",value:function(){var t=this,o=[];if(this.props.image)o.push(e.createElement("img",{key:"image",src:this.props.image,alt:this.props.imageAlt,onError:function(e){t.props.onImageError&&t.props.onImageError(e)}}));else if(this.props.icon){var r=n("p-chip-icon",this.props.icon);o.push(e.createElement("span",{key:"icon",className:r}))}if(this.props.label&&o.push(e.createElement("span",{key:"label",className:"p-chip-text"},this.props.label)),this.props.removable){var i=n("p-chip-remove-icon",this.props.removeIcon);o.push(e.createElement("span",{key:"removeIcon",tabIndex:0,className:i,onClick:this.close,onKeyDown:this.onKeyDown}))}return o}},{key:"renderElement",value:function(){var t=n("p-chip p-component",{"p-chip-image":null!=this.props.image},this.props.className),r=this.props.template?o.getJSXElement(this.props.template,this.props):this.renderContent();return e.createElement("div",{className:t,style:this.props.style},r)}},{key:"render",value:function(){return this.state.visible&&this.renderElement()}}])&&i(y.prototype,h),b&&i(y,b),g}();h={label:null,icon:null,image:null,removable:!1,removeIcon:"pi pi-times-circle",className:null,style:null,template:null,imageAlt:"chip",onImageError:null,onRemove:null},(y="defaultProps")in(m=b)?Object.defineProperty(m,y,{value:h,enumerable:!0,configurable:!0,writable:!0}):m[y]=h;export{b as Chip};
  