/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import{r as t,g as n,a}from"./index-BM3Om9WE.js";import{h as i}from"./renderer-DpNDfhNy.js";const o=class{constructor(n){t(this,n)}get host(){return n(this)}inputElement;ignoreInputChange=!1;inputElementChanged(t,n){n&&n.removeEventListener("nanoChange",this.inputChangeHandler),this.inputElement&&(this.inputElement.label=this.inputElement.label||"Increment value",this.inputElement.hideLabel=!0,this.inputElement.type="number",this.inputElement.max=this.inputElement.max||"10",this.inputElement.min=this.inputElement.min||"0",this.inputElement.step=this.inputElement.step||"1",this.inputElement.value=this.inputElement.value||"0",this.inputElement.addEventListener("nanoChange",this.inputChangeHandler))}inputChangeHandler=()=>{if(!this.ignoreInputChange){this.ignoreInputChange=!0;let t=Number(this.inputElement.value);t=isNaN(t)?0:t,t=Math.max(t,parseFloat(this.inputElement.min)||0),t=Math.min(t,parseFloat(this.inputElement.max)||1/0),this.inputElement.value=t.toString(),requestAnimationFrame((()=>{this.ignoreInputChange=!1}))}};handleSlotChange=()=>{this.inputElement=this.host.querySelector("nano-input")};handleMinus=()=>{if(this.inputElement){const t=parseFloat(this.inputElement.value)||0,n=parseFloat(this.inputElement.step)||1,a=Math.max(t-n,parseFloat(this.inputElement.min)||0);this.ignoreInputChange=!0,this.inputElement.value=a.toString(),this.ignoreInputChange=!1}};handlePlus=()=>{if(this.inputElement){const t=parseFloat(this.inputElement.value)||0,n=parseFloat(this.inputElement.step)||1,a=Math.min(t+n,parseFloat(this.inputElement.max)||1/0);this.ignoreInputChange=!0,this.inputElement.value=a.toString(),this.ignoreInputChange=!1}};componentWillLoad(){this.handleSlotChange()}render(){return i(a,{key:"14c12f59b2f00d22bc58fb5ca64616a0a6b19749",class:"nano-increment"},i("div",{key:"77800505fe9e0d79fda864dc48cb199e6ea611c7",class:"root"},i("div",{key:"01576d846ca2708319d9faf1c7a0a25169f6c3f4",class:"minus"},i("nano-icon-button",{key:"a6b30034c64de602ac504a882aa3ff7c5a933083",iconName:"light/minus",label:"Decrement",onClick:this.handleMinus})),i("slot",{key:"f04566d5f4a52f23a36bfb1c86a8dadfa3638d66",onSlotchange:this.handleSlotChange}),i("div",{key:"4f1e183e7d547d5f72154115300d14cfbbe3d62b",class:"plus"},i("nano-icon-button",{key:"20af1b2a19cd8c9264e6375f4a5c05b9f917d979",iconName:"light/plus",label:"Increment",onClick:this.handlePlus}))))}static get watchers(){return{inputElement:["inputElementChanged"]}}};o.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{display:inline-block}.root{display:grid;grid-template-columns:min-content auto 1fr;grid-template-rows:max-content max-content;align-items:stretch}::slotted(*){text-align:center}nano-icon-button{background:var(--nano-color-base-0);color:var(--nano-color-primary-1000);display:flex;border-radius:var(--nano-border-radius-pill);position:relative;z-index:1;inline-size:fit-content;block-size:100%}nano-icon-button:hover{background:var(--nano-color-primary-100)}nano-icon-button:active{background:var(--nano-color-primary-300)}nano-icon-button::part(base){border:1px solid var(--nano-color-neutral-300)}nano-icon-button::part(base):focus-visible{outline:var(--nano-focus-ring-color) solid 3px;outline-offset:-2px}.minus{grid-column:1;grid-row:1}.minus nano-icon-button{--padding:0.4375em 0.625em 0.4375em 1.125em;border-start-end-radius:0;border-end-end-radius:0}.minus nano-icon-button::part(base){border-inline-end:none}.plus{grid-column:3;grid-row:1}.plus nano-icon-button{--padding:0.4375em 1.125em 0.4375em 0.625em;border-start-start-radius:0;border-end-start-radius:0}.plus nano-icon-button::part(base){border-inline-start:none}";export{o as nano_increment}