import{C as q,r as l,u as $,P as K,a as L,q as k,O as C,m as J,b as W,c as R,T as X,H as Y,e as z}from"./index-Bkt-lHwp.js";function h(){return h=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)({}).hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},h.apply(null,arguments)}function g(t){"@babel/helpers - typeof";return g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},g(t)}function G(t,n){if(g(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,n||"default");if(g(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function Q(t){var n=G(t,"string");return g(n)=="symbol"?n:n+""}function Z(t,n,r){return(n=Q(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function ee(t){if(Array.isArray(t))return t}function te(t,n){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var o,e,x,d,y=[],b=!0,v=!1;try{if(x=(r=r.call(t)).next,n!==0)for(;!(b=(o=x.call(r)).done)&&(y.push(o.value),y.length!==n);b=!0);}catch(s){v=!0,e=s}finally{try{if(!b&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(v)throw e}}return y}}function I(t,n){(n==null||n>t.length)&&(n=t.length);for(var r=0,o=Array(n);r<n;r++)o[r]=t[r];return o}function ne(t,n){if(t){if(typeof t=="string")return I(t,n);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(t,n):void 0}}function re(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oe(t,n){return ee(t)||te(t,n)||ne(t,n)||re()}var ae={box:"p-checkbox-box",input:"p-checkbox-input",icon:"p-checkbox-icon",root:function(n){var r=n.props,o=n.checked,e=n.context;return R("p-checkbox p-component",{"p-highlight":o,"p-disabled":r.disabled,"p-invalid":r.invalid,"p-variant-filled":r.variant?r.variant==="filled":e&&e.inputStyle==="filled"})}},O=q.extend({defaultProps:{__TYPE:"Checkbox",autoFocus:!1,checked:!1,className:null,disabled:!1,falseValue:!1,icon:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,name:null,onChange:null,onContextMenu:null,onMouseDown:null,readOnly:!1,required:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,trueValue:!0,value:null,children:void 0},css:{classes:ae}});function w(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function _(t){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?w(Object(r),!0).forEach(function(o){Z(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}var le=l.memo(l.forwardRef(function(t,n){var r=$(),o=l.useContext(K),e=O.getProps(t,o),x=l.useState(!1),d=oe(x,2),y=d[0],b=d[1],v=O.setMetaData({props:e,state:{focused:y},context:{checked:e.checked===e.trueValue,disabled:e.disabled}}),s=v.ptm,P=v.cx,A=v.isUnstyled;L(O.css.styles,A,{name:"checkbox"});var S=l.useRef(null),u=l.useRef(e.inputRef),E=function(){return e.checked===e.trueValue},D=function(a){if(!(e.disabled||e.readonly)&&e.onChange){var f,m=E(),i=m?e.falseValue:e.trueValue,U={originalEvent:a,value:e.value,checked:i,stopPropagation:function(){a==null||a.stopPropagation()},preventDefault:function(){a==null||a.preventDefault()},target:{type:"checkbox",name:e.name,id:e.id,value:e.value,checked:i}};if(e==null||(f=e.onChange)===null||f===void 0||f.call(e,U),a.defaultPrevented)return;k.focus(u.current)}},B=function(){var a;b(!0),e==null||(a=e.onFocus)===null||a===void 0||a.call(e)},F=function(){var a;b(!1),e==null||(a=e.onBlur)===null||a===void 0||a.call(e)};l.useImperativeHandle(n,function(){return{props:e,focus:function(){return k.focus(u.current)},getElement:function(){return S.current},getInput:function(){return u.current}}}),l.useEffect(function(){C.combinedRefs(u,e.inputRef)},[u,e.inputRef]),J(function(){u.current.checked=E()},[e.checked,e.trueValue]),W(function(){e.autoFocus&&k.focus(u.current,e.autoFocus)});var p=E(),M=C.isNotEmpty(e.tooltip),j=O.getOtherProps(e),N=r({id:e.id,className:R(e.className,P("root",{checked:p,context:o})),style:e.style,"data-p-highlight":p,"data-p-disabled":e.disabled,onContextMenu:e.onContextMenu,onMouseDown:e.onMouseDown},j,s("root")),T=function(){var a=C.reduceKeys(j,k.ARIA_PROPS),f=r(_({id:e.inputId,type:"checkbox",className:P("input"),name:e.name,tabIndex:e.tabIndex,onFocus:function(i){return B()},onBlur:function(i){return F()},onChange:function(i){return D(i)},disabled:e.disabled,readOnly:e.readOnly,required:e.required,"aria-invalid":e.invalid,checked:p},a),s("input"));return l.createElement("input",h({ref:u},f))},V=function(){var a=r({className:P("icon")},s("icon")),f=r({className:P("box",{checked:p}),"data-p-highlight":p,"data-p-disabled":e.disabled},s("box")),m=p?e.icon||l.createElement(Y,a):null,i=z.getJSXIcon(m,_({},a),{props:e,checked:p});return l.createElement("div",f,i)};return l.createElement(l.Fragment,null,l.createElement("div",h({ref:S},N),T(),V()),M&&l.createElement(X,h({target:S,content:e.tooltip,pt:s("tooltip")},e.tooltipOptions)))}));le.displayName="Checkbox";export{le as C};
