@decidables/discountable-elements 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1033,7 +1033,7 @@ const Ca=2;let aa=class{constructor(B){}get _$AU(){return this._$AM._$AU}_$AT(B,
1033
1033
  * @license
1034
1034
  * Copyright 2017 Google LLC
1035
1035
  * SPDX-License-Identifier: BSD-3-Clause
1036
- */function ua(B){void 0!==this._$AN?(oa(this),this._$AM=B,Ga(this)):this._$AM=B}function ra(B,Q=!1,F=0){const U=this._$AH,t=this._$AN;if(void 0!==t&&0!==t.size)if(Q)if(Array.isArray(U))for(let B=F;B<U.length;B++)ba(U[B],!1),oa(U[B]);else null!=U&&(ba(U,!1),oa(U));else ba(this,B)}const xa=B=>{B.type==Ca&&(B._$AP??=ra,B._$AQ??=ua)};class Aa extends aa{constructor(){super(...arguments),this._$AN=void 0}_$AT(B,Q,F){super._$AT(B,Q,F),Ga(this),this.isConnected=B._$AU}_$AO(B,Q=!0){B!==this.isConnected&&(this.isConnected=B,B?this.reconnected?.():this.disconnected?.()),Q&&(ba(this,B),oa(this))}setValue(B){if((B=>void 0===B.strings)(this._$Ct))this._$Ct._$AI(B,this);else{const Q=[...this._$Ct._$AH];Q[this._$Ci]=B,this._$Ct._$AI(Q,this,0)}}disconnected(){}reconnected(){}}const La=new WeakMap;let ha=0;const ya=new Map,Ra=new WeakSet,Za=()=>new Promise(B=>requestAnimationFrame(B)),Va=[{opacity:0},{opacity:1}],Sa=(B,Q)=>{const F=B-Q;return 0===F?void 0:F},ma=(B,Q)=>{const F=B/Q;return 1===F?void 0:F},Ea={left:(B,Q)=>{const F=Sa(B,Q);return{value:F,transform:null==F||isNaN(F)?void 0:`translateX(${F}px)`}},top:(B,Q)=>{const F=Sa(B,Q);return{value:F,transform:null==F||isNaN(F)?void 0:`translateY(${F}px)`}},width:(B,Q)=>{let F;0===Q&&(Q=1,F={width:"1px"});const U=ma(B,Q);return{value:U,overrideFrom:F,transform:null==U||isNaN(U)?void 0:`scaleX(${U})`}},height:(B,Q)=>{let F;0===Q&&(Q=1,F={height:"1px"});const U=ma(B,Q);return{value:U,overrideFrom:F,transform:null==U||isNaN(U)?void 0:`scaleY(${U})`}}},Na={duration:333,easing:"ease-in-out"},Xa=["left","top","width","height","opacity","color","background"],pa=new WeakMap;const Wa=(B=>(...Q)=>({_$litDirective$:B,values:Q}))(class extends Aa{constructor(B){if(super(B),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,B.type===Ca)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){this.resolveFinished?.(),this.finished=new Promise(B=>{this.l=B})}async resolveFinished(){this.l?.(),this.l=void 0}render(B){return K}getController(){return La.get(this.u)}isDisabled(){return this.options.disabled||this.getController()?.disabled}update(B,[Q]){const F=void 0===this.u;return F&&(this.u=B.options?.host,this.u.addController(this),this.u.updateComplete.then(B=>this.t=!0),this.element=B.element,pa.set(this.element,this)),this.optionsOrCallback=Q,(F||"function"!=typeof Q)&&this.p(Q),this.render(Q)}p(B){B=B??{};const Q=this.getController();void 0!==Q&&((B={...Q.defaultOptions,...B}).keyframeOptions={...Q.defaultOptions.keyframeOptions,...B.keyframeOptions}),B.properties??=Xa,this.options=B}m(){const B={},Q=this.element.getBoundingClientRect(),F=getComputedStyle(this.element);return this.options.properties.forEach(U=>{const t=Q[U]??(Ea[U]?void 0:F[U]),s=Number(t);B[U]=isNaN(s)?t+"":s}),B}v(){let B,Q=!0;return this.options.guard&&(B=this.options.guard(),Q=((B,Q)=>{if(Array.isArray(B)){if(Array.isArray(Q)&&Q.length===B.length&&B.every((B,F)=>B===Q[F]))return!1}else if(Q===B)return!1;return!0})(B,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&Q&&this.element.isConnected,this.h&&(this._=Array.isArray(B)?Array.from(B):B),this.h}hostUpdate(){"function"==typeof this.optionsOrCallback&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let B;this.prepare(),await Za;const Q=this.O(),F=this.j(this.options.keyframeOptions,Q),U=this.m();if(void 0!==this.A){const{from:F,to:t}=this.N(this.A,U,Q);this.log("measured",[this.A,U,F,t]),B=this.calculateKeyframes(F,t)}else{const F=ya.get(this.options.inId);if(F){ya.delete(this.options.inId);const{from:t,to:s}=this.N(F,U,Q);B=this.calculateKeyframes(t,s),B=this.options.in?[{...this.options.in[0],...B[0]},...this.options.in.slice(1),B[1]]:B,ha++,B.forEach(B=>B.zIndex=ha)}else this.options.in&&(B=[...this.options.in,{}])}this.animate(B,F)}resetStyles(){void 0!==this.P&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){this.P=this.element.getAttribute("style"),this.webAnimation?.commitStyles(),this.webAnimation?.cancel()}reconnected(){}async disconnected(){if(!this.h)return;if(void 0!==this.options.id&&ya.set(this.options.id,this.A),void 0===this.options.out)return;if(this.prepare(),await Za(),this.i?.isConnected){const B=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,B),this.options.stabilizeOut){const B=this.m();this.log("stabilizing out");const Q=this.A.left-B.left,F=this.A.top-B.top;!("static"===getComputedStyle(this.element).position)||0===Q&&0===F||(this.element.style.position="relative"),0!==Q&&(this.element.style.left=Q+"px"),0!==F&&(this.element.style.top=F+"px")}}const B=this.j(this.options.keyframeOptions);await this.animate(this.options.out,B),this.element.remove()}prepare(){this.createFinished()}start(){this.options.onStart?.(this)}didFinish(B){B&&this.options.onComplete?.(this),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){const B=[];for(let Q=this.element.parentNode;Q;Q=Q?.parentNode){const F=pa.get(Q);F&&!F.isDisabled()&&F&&B.push(F)}return B}get isHostRendered(){const B=Ra.has(this.u);return B||this.u.updateComplete.then(()=>{Ra.add(this.u)}),B}j(B,Q=this.O()){const F={...Na};return Q.forEach(B=>Object.assign(F,B.options.keyframeOptions)),Object.assign(F,B),F}N(B,Q,F){B={...B},Q={...Q};const U=F.map(B=>B.animatingProperties).filter(B=>void 0!==B);let t=1,s=1;return U.length>0&&(U.forEach(B=>{B.width&&(t/=B.width),B.height&&(s/=B.height)}),void 0!==B.left&&void 0!==Q.left&&(B.left=t*B.left,Q.left=t*Q.left),void 0!==B.top&&void 0!==Q.top&&(B.top=s*B.top,Q.top=s*Q.top)),{from:B,to:Q}}calculateKeyframes(B,Q,F=!1){const U={},t={};let s=!1;const I={};for(const F in Q){const g=B[F],i=Q[F];if(F in Ea){const B=Ea[F];if(void 0===g||void 0===i)continue;const Q=B(g,i);void 0!==Q.transform&&(I[F]=Q.value,s=!0,U.transform=`${U.transform??""} ${Q.transform}`,void 0!==Q.overrideFrom&&Object.assign(U,Q.overrideFrom))}else g!==i&&void 0!==g&&void 0!==i&&(s=!0,U[F]=g,t[F]=i)}return U.transformOrigin=t.transformOrigin=F?"center center":"top left",this.animatingProperties=I,s?[U,t]:void 0}async animate(B,Q=this.options.keyframeOptions){this.start(),this.frames=B;let F=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=B=this.options.onFrames(this),this.log("modified frames",B)),void 0!==B)){this.log("animate",[B,Q]),F=!0,this.webAnimation=this.element.animate(B,Q);const U=this.getController();U?.add(this);try{await this.webAnimation.finished}catch(B){}U?.remove(this)}return this.didFinish(F),F}isAnimating(){return"running"===this.webAnimation?.playState||this.webAnimation?.pending}log(B,Q){this.shouldLog&&!this.isDisabled()&&console.log(B,this.options.id,Q)}});class Ha{static k={DEFAULT:.05,MIN:0,MAX:100,STEP:.001,JUMP:.01};static adk2v(B,Q,F){return B/(1+F*Q)}static adv2k(B,Q,F){return(B-F)/(F*Q)}}class Da extends ea{static get properties(){return{numeric:{attribute:"numeric",type:Boolean,reflect:!0}}}constructor(){super(),this.numeric=!1}static get styles(){return[super.styles,g`
1036
+ */function ua(B){void 0!==this._$AN?(oa(this),this._$AM=B,Ga(this)):this._$AM=B}function ra(B,Q=!1,F=0){const U=this._$AH,t=this._$AN;if(void 0!==t&&0!==t.size)if(Q)if(Array.isArray(U))for(let B=F;B<U.length;B++)ba(U[B],!1),oa(U[B]);else null!=U&&(ba(U,!1),oa(U));else ba(this,B)}const xa=B=>{B.type==Ca&&(B._$AP??=ra,B._$AQ??=ua)};class Aa extends aa{constructor(){super(...arguments),this._$AN=void 0}_$AT(B,Q,F){super._$AT(B,Q,F),Ga(this),this.isConnected=B._$AU}_$AO(B,Q=!0){B!==this.isConnected&&(this.isConnected=B,B?this.reconnected?.():this.disconnected?.()),Q&&(ba(this,B),oa(this))}setValue(B){if((B=>void 0===B.strings)(this._$Ct))this._$Ct._$AI(B,this);else{const Q=[...this._$Ct._$AH];Q[this._$Ci]=B,this._$Ct._$AI(Q,this,0)}}disconnected(){}reconnected(){}}const La=new WeakMap;let ha=0;const ya=new Map,Ra=new WeakSet,Za=()=>new Promise(B=>requestAnimationFrame(B)),Va=[{opacity:0},{opacity:1}],Sa=(B,Q)=>{const F=B-Q;return 0===F?void 0:F},ma=(B,Q)=>{const F=B/Q;return 1===F?void 0:F},Ea={left:(B,Q)=>{const F=Sa(B,Q);return{value:F,transform:null==F||isNaN(F)?void 0:`translateX(${F}px)`}},top:(B,Q)=>{const F=Sa(B,Q);return{value:F,transform:null==F||isNaN(F)?void 0:`translateY(${F}px)`}},width:(B,Q)=>{let F;0===Q&&(Q=1,F={width:"1px"});const U=ma(B,Q);return{value:U,overrideFrom:F,transform:null==U||isNaN(U)?void 0:`scaleX(${U})`}},height:(B,Q)=>{let F;0===Q&&(Q=1,F={height:"1px"});const U=ma(B,Q);return{value:U,overrideFrom:F,transform:null==U||isNaN(U)?void 0:`scaleY(${U})`}}},Na={duration:333,easing:"ease-in-out"},Xa=["left","top","width","height","opacity","color","background"],pa=new WeakMap;const Wa=(B=>(...Q)=>({_$litDirective$:B,values:Q}))(class extends Aa{constructor(B){if(super(B),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,B.type===Ca)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){this.resolveFinished?.(),this.finished=new Promise(B=>{this.l=B})}async resolveFinished(){this.l?.(),this.l=void 0}render(B){return K}getController(){return La.get(this.u)}isDisabled(){return this.options.disabled||this.getController()?.disabled}update(B,[Q]){const F=void 0===this.u;return F&&(this.u=B.options?.host,this.u.addController(this),this.u.updateComplete.then(B=>this.t=!0),this.element=B.element,pa.set(this.element,this)),this.optionsOrCallback=Q,(F||"function"!=typeof Q)&&this.m(Q),this.render(Q)}m(B){B=B??{};const Q=this.getController();void 0!==Q&&((B={...Q.defaultOptions,...B}).keyframeOptions={...Q.defaultOptions.keyframeOptions,...B.keyframeOptions}),B.properties??=Xa,this.options=B}p(){const B={},Q=this.element.getBoundingClientRect(),F=getComputedStyle(this.element);return this.options.properties.forEach(U=>{const t=Q[U]??(Ea[U]?void 0:F[U]),s=Number(t);B[U]=isNaN(s)?t+"":s}),B}v(){let B,Q=!0;return this.options.guard&&(B=this.options.guard(),Q=((B,Q)=>{if(Array.isArray(B)){if(Array.isArray(Q)&&Q.length===B.length&&B.every((B,F)=>B===Q[F]))return!1}else if(Q===B)return!1;return!0})(B,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&Q&&this.element.isConnected,this.h&&(this._=Array.isArray(B)?Array.from(B):B),this.h}hostUpdate(){"function"==typeof this.optionsOrCallback&&this.m(this.optionsOrCallback()),this.v()&&(this.A=this.p(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let B;this.prepare(),await Za;const Q=this.P(),F=this.V(this.options.keyframeOptions,Q),U=this.p();if(void 0!==this.A){const{from:F,to:t}=this.O(this.A,U,Q);this.log("measured",[this.A,U,F,t]),B=this.calculateKeyframes(F,t)}else{const F=ya.get(this.options.inId);if(F){ya.delete(this.options.inId);const{from:t,to:s}=this.O(F,U,Q);B=this.calculateKeyframes(t,s),B=this.options.in?[{...this.options.in[0],...B[0]},...this.options.in.slice(1),B[1]]:B,ha++,B.forEach(B=>B.zIndex=ha)}else this.options.in&&(B=[...this.options.in,{}])}this.animate(B,F)}resetStyles(){void 0!==this.j&&(this.element.setAttribute("style",this.j??""),this.j=void 0)}commitStyles(){this.j=this.element.getAttribute("style"),this.webAnimation?.commitStyles(),this.webAnimation?.cancel()}reconnected(){}async disconnected(){if(!this.h)return;if(void 0!==this.options.id&&ya.set(this.options.id,this.A),void 0===this.options.out)return;if(this.prepare(),await Za(),this.i?.isConnected){const B=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,B),this.options.stabilizeOut){const B=this.p();this.log("stabilizing out");const Q=this.A.left-B.left,F=this.A.top-B.top;!("static"===getComputedStyle(this.element).position)||0===Q&&0===F||(this.element.style.position="relative"),0!==Q&&(this.element.style.left=Q+"px"),0!==F&&(this.element.style.top=F+"px")}}const B=this.V(this.options.keyframeOptions);await this.animate(this.options.out,B),this.element.remove()}prepare(){this.createFinished()}start(){this.options.onStart?.(this)}didFinish(B){B&&this.options.onComplete?.(this),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}P(){const B=[];for(let Q=this.element.parentNode;Q;Q=Q?.parentNode){const F=pa.get(Q);F&&!F.isDisabled()&&F&&B.push(F)}return B}get isHostRendered(){const B=Ra.has(this.u);return B||this.u.updateComplete.then(()=>{Ra.add(this.u)}),B}V(B,Q=this.P()){const F={...Na};return Q.forEach(B=>Object.assign(F,B.options.keyframeOptions)),Object.assign(F,B),F}O(B,Q,F){B={...B},Q={...Q};const U=F.map(B=>B.animatingProperties).filter(B=>void 0!==B);let t=1,s=1;return U.length>0&&(U.forEach(B=>{B.width&&(t/=B.width),B.height&&(s/=B.height)}),void 0!==B.left&&void 0!==Q.left&&(B.left=t*B.left,Q.left=t*Q.left),void 0!==B.top&&void 0!==Q.top&&(B.top=s*B.top,Q.top=s*Q.top)),{from:B,to:Q}}calculateKeyframes(B,Q,F=!1){const U={},t={};let s=!1;const I={};for(const F in Q){const g=B[F],i=Q[F];if(F in Ea){const B=Ea[F];if(void 0===g||void 0===i)continue;const Q=B(g,i);void 0!==Q.transform&&(I[F]=Q.value,s=!0,U.transform=`${U.transform??""} ${Q.transform}`,void 0!==Q.overrideFrom&&Object.assign(U,Q.overrideFrom))}else g!==i&&void 0!==g&&void 0!==i&&(s=!0,U[F]=g,t[F]=i)}return U.transformOrigin=t.transformOrigin=F?"center center":"top left",this.animatingProperties=I,s?[U,t]:void 0}async animate(B,Q=this.options.keyframeOptions){this.start(),this.frames=B;let F=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=B=this.options.onFrames(this),this.log("modified frames",B)),void 0!==B)){this.log("animate",[B,Q]),F=!0,this.webAnimation=this.element.animate(B,Q);const U=this.getController();U?.add(this);try{await this.webAnimation.finished}catch(B){}U?.remove(this)}return this.didFinish(F),F}isAnimating(){return"running"===this.webAnimation?.playState||this.webAnimation?.pending}log(B,Q){this.shouldLog&&!this.isDisabled()&&console.log(B,this.options.id,Q)}});class Ha{static k={DEFAULT:.05,MIN:0,MAX:100,STEP:.001,JUMP:.01};static adk2v(B,Q,F){return B/(1+F*Q)}static adv2k(B,Q,F){return(B-F)/(F*Q)}}class Da extends ea{static get properties(){return{numeric:{attribute:"numeric",type:Boolean,reflect:!0}}}constructor(){super(),this.numeric=!1}static get styles(){return[super.styles,g`
1037
1037
  :host {
1038
1038
  display: block;
1039
1039
 
@@ -1389,7 +1389,7 @@ const Ca=2;let aa=class{constructor(B){}get _$AU(){return this._$AM._$AU}_$AT(B,
1389
1389
  transform: translateY(0);
1390
1390
  }
1391
1391
 
1392
- :host(.keyboard) .option .body.interactive:has(~ .point:focus-within) {
1392
+ :host(.keyboard) .body.interactive:has(~ .point:focus-within) {
1393
1393
  filter: url("#shadow-8");
1394
1394
 
1395
1395
  /* HACK: This gets Safari to correctly apply the filter! */