text: (function(g,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(g=typeof globalThis!="undefined"?globalThis:g||self,y(g.toggle={}))})(this,function(g){"use strict";function y(r){return r!=null&&typeof r=="object"&&r["@@functional/placeholder"]===!0}var E=y,D=E;function W(r){return function e(t){return arguments.length===0||D(t)?e:r.apply(this,arguments)}}var _=W,$=_,h=E;function G(r){return function e(t,n){switch(arguments.length){case 0:return e;case 1:return h(t)?e:$(function(a){return r(t,a)});default:return h(t)&&h(n)?e:h(t)?$(function(a){return r(a,n)}):h(n)?$(function(a){return r(t,a)}):r(t,n)}}}var m=G;function L(r){for(var e=[],t;!(t=r.next()).done;)e.push(t.value);return e}var X=L;function K(r,e,t){for(var n=0,a=t.length;n<a;){if(r(e,t[n]))return!0;n+=1}return!1}var H=K;function J(r){var e=String(r).match(/^function (\w*)/);return e==null?"":e[1]}var Q=J;function Y(r,e){return Object.prototype.hasOwnProperty.call(e,r)}var w=Y;function Z(r,e){return r===e?r!==0||1/r==1/e:r!==r&&e!==e}var ee=typeof Object.is=="function"?Object.is:Z,re=w,q=Object.prototype.toString,te=function(){return q.call(arguments)==="[object Arguments]"?function(e){return q.call(e)==="[object Arguments]"}:function(e){return re("callee",e)}}(),ne=te,A=_,x=w,ae=ne,ue=!{toString:null}.propertyIsEnumerable("toString"),k=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],j=function(){return arguments.propertyIsEnumerable("length")}(),ie=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1},oe=A(typeof Object.keys=="function"&&!j?function(e){return Object(e)!==e?[]:Object.keys(e)}:function(e){if(Object(e)!==e)return[];var t,n,a=[],i=j&&ae(e);for(t in e)x(t,e)&&(!i||t!=="length")&&(a[a.length]=t);if(ue)for(n=k.length-1;n>=0;)t=k[n],x(t,e)&&!ie(a,t)&&(a[a.length]=t),n-=1;return a}),se=oe,le=_,ce=le(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}),fe=ce,I=X,P=H,ge=Q,me=w,N=ee,z=se,F=fe;function T(r,e,t,n){var a=I(r),i=I(e);function l(u,o){return O(u,o,t.slice(),n.slice())}return!P(function(u,o){return!P(l,o,u)},i,a)}function O(r,e,t,n){if(N(r,e))return!0;var a=F(r);if(a!==F(e)||r==null||e==null)return!1;if(typeof r["fantasy-land/equals"]=="function"||typeof e["fantasy-land/equals"]=="function")return typeof r["fantasy-land/equals"]=="function"&&r["fantasy-land/equals"](e)&&typeof e["fantasy-land/equals"]=="function"&&e["fantasy-land/equals"](r);if(typeof r.equals=="function"||typeof e.equals=="function")return typeof r.equals=="function"&&r.equals(e)&&typeof e.equals=="function"&&e.equals(r);switch(a){case"Arguments":case"Array":case"Object":if(typeof r.constructor=="function"&&ge(r.constructor)==="Promise")return r===e;break;case"Boolean":case"Number":case"String":if(!(typeof r==typeof e&&N(r.valueOf(),e.valueOf())))return!1;break;case"Date":if(!N(r.valueOf(),e.valueOf()))return!1;break;case"Error":return r.name===e.name&&r.message===e.message;case"RegExp":if(!(r.source===e.source&&r.global===e.global&&r.ignoreCase===e.ignoreCase&&r.multiline===e.multiline&&r.sticky===e.sticky&&r.unicode===e.unicode))return!1;break}for(var i=t.length-1;i>=0;){if(t[i]===r)return n[i]===e;i-=1}switch(a){case"Map":return r.size!==e.size?!1:T(r.entries(),e.entries(),t.concat([r]),n.concat([e]));case"Set":return r.size!==e.size?!1:T(r.values(),e.values(),t.concat([r]),n.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var l=z(r);if(l.length!==z(e).length)return!1;var u=t.concat([r]),o=n.concat([e]);for(i=l.length-1;i>=0;){var d=l[i];if(!(me(d,e)&&O(e[d],r[d],u,o)))return!1;i-=1}return!0}var ve=O,ye=m,_e=ve,he=ye(function(e,t){return _e(e,t,[],[])}),de=he,s=de,pe=m,we=pe(function(e,t){return e>t}),be=we,b=be,$e=m,Ne=$e(function(e,t){return e>=t}),Oe=Ne,f=Oe,Se=_,Ee=Se(function(e){return e==null}),M=Ee,qe=M,Ae=m,xe=w,B=M,ke=Ae(function(e,t){if(e.length===0||B(t))return!1;for(var n=t,a=0;a<e.length;)if(!B(n)&&xe(e[a],n))n=n[e[a]],a+=1;else return!1;return!0}),je=ke,Ie=m,Pe=je,ze=Ie(function(e,t){return Pe([e],t)}),Fe=ze,Te=Fe,Me=m,Be=Me(function(e,t){return t!=null&&t.constructor===e||t instanceof e}),Ue=Be,v=Ue;function Ce(r){return Object.prototype.toString.call(r)==="[object Number]"}var Re=Ce,Ve=_,De=Re,We=Ve(function(e){return e!=null&&De(e.length)?e.length:NaN}),Ge=We,Le=Ge;function S(r){return typeof r!="object"||r===null||qe(r)?!1:Object.getPrototypeOf(r)===Object.prototype}function Xe(r){if(!v(Boolean,r))throw new Error("'defaultValuel' must be boolean")}function U(r,e){if(!v(Number,r)||!Number.isFinite(r)||!Number.isInteger(r)||!f(r,0))throw new Error("'max' must be zero or a positive integer");if(!v(Number,e)||!Number.isFinite(e)||!Number.isInteger(e)||!f(e,0))throw new Error("'min' must be zero or a positive integer");if(!f(r,e))throw new Error("'max' must be greater or equal to 'min'");if(s(r,e)&&b(r,1))throw new Error("'max' must be zero or one when 'min' and 'max' are equal");if(b(r,Number.MAX_SAFE_INTEGER))throw new Error(`max must be ${Number.MAX_SAFE_INTEGER} or lower`)}function C(r,e){if(!v(Number,r)||!Number.isFinite(r)||!Number.isInteger(r)||!f(r,0))throw new Error("'min' must be zero or a positive integer");if(!v(Number,e)||!Number.isFinite(e)||!Number.isInteger(e)||!f(e,0))throw new Error("'max' must be zero or a positive integer");if(!f(e,r))throw new Error("'min' must be less than or equal to 'max'");if(s(e,r)&&b(r,1))throw new Error("'min' must be zero or one when 'max' and 'min' are equal")}function Ke(r){if(!v(String,r))throw new Error("'name' must be a string");if(s(0,Le(r)))throw new Error("'name' cannot be blank")}function He(r){if(!S(r))throw new Error("'target' must be an object")}function Je(...r){const[e,t,n,a,i]=r,l=S(e)?e:{},u=S(e)?"selected":e;let o={defaultValue:a!=null?a:!1,max:t!=null?t:1,min:n!=null?n:0,name:u!=null?u:"selected",oSet:i!=null?i:new Set};return o=Object.assign(o,l),Xe(o.defaultValue),Ke(o.name),U(o.max,o.min),C(o.min,o.max),o}function Qe(...r){const e=Je(...r);let t=function(a){He(a);const i=`__${e.name}Toggle`,l=Te(e.name,a)?a[e.name]:e.defaultValue,u={__key:Symbol("key"),get isToggled(){return e.oSet.has(u.__key)},get memento(){return l},set memento(c){throw new Error("memento cannot be reset")},get max(){return e.max},get min(){return e.min},get size(){return e.oSet.size},toggle:function(c){return s(0,e.max)?u.isToggled:s(1,e.max)&&s(1,e.min)?o():d(c)}};Object.defineProperty(u,"__key",{configurable:!1,enumerable:!1,writable:!1}),Object.defineProperty(u,"__target",{configurable:!1,enumerable:!1,writable:!1,value:a}),Boolean(l)&&(s(0,e.max)||b(e.max,e.oSet.size))&&e.oSet.add(u.__key);function o(){const{value:c}=e.oSet.keys().next();return s(c,u.__key)||(c&&e.oSet.delete(c),e.oSet.add(u.__key)),!0}function d(c){const p=u.isToggled,R=s(void 0,c)?!p:Boolean(c);if(s(p,R))return p;const V=e.oSet.size;return R?f(V,e.max)?p:(e.oSet.add(u.__key),!0):f(e.min,V)?p:(e.oSet.delete(u.__key),!1)}return a[i]=u,a};return t=Object.defineProperties(t,{max:{configurable:!1,enumerable:!0,get:function(){return e.max},set:function(n){U(n,e.min),e.max=n}},min:{configurable:!1,enumerable:!0,get:function(){return e.min},set:function(n){C(n,e.max),e.min=n}},size:{configurable:!1,enumerable:!0,writeable:!1,get:function(){return e.oSet.size}}}),t}g.toggle=Qe,Object.defineProperty(g,"__esModule",{value:!0}),g[Symbol.toStringTag]="Module"});
  