import{r as k,a3 as r,L as c,h as n,H as f,b as v}from"./index-Di6F0tPl.js";import{B as d}from"./variant-quote-DI6q8gPw-CeInbXEy.js";import{C as b,a as L}from"./controller-C79A2P0n-CdBTZ0wg.js";import{c as p,n as _}from"./normalizers-C14RETgU-C323STio.js";import{B as S}from"./base-controller-CXhqh4cR-D2BOZI1P.js";import"./_Uint8Array-kJHDjtoP-jmGEpw_T.js";import"./isArray-CcrBs4JM-CqO_RI43.js";import"./label-DK7sT-k5-DlQTN4B-.js";const h=p("name","",_),a=v.forBlock("kol-skeleton"),B=a("actions"),g=a("container"),E=a("counter"),w=a("name"),N=o=>{const{count:e,label:t,name:s,show:l,handleClick:u,refButton:m}=o,i=!!(l&&s?.trim()),C=a({"has-name":i,"is-hidden":!l});return n("div",{class:C},n("div",{class:g},i&&n("span",{class:w},s),n("div",{class:E},"Count: ",e)),n("div",{class:B},n(L,{label:t,handleClick:u,refButton:m})))},y={required:[h]};class I extends S{constructor(e){super(e,y),this.onKeydown=t=>{t.key==="Escape"&&(console.log("Show should be toggled"),this.toggle())},this.handleClick=()=>{var t,s;c.debug("Button clicked, count should be increased"),this.setState("count",((s=(t=this.getState)===null||t===void 0?void 0:t.call(this,"count"))!==null&&s!==void 0?s:0)+1)},this.setButtonRef=t=>{this.clickButtonCtrl.setButtonRef(t)},this.clickButtonCtrl=new b(d.stateLess),this.startLoadedEventInterval()}componentWillLoad(e){const{name:t}=e;this.watchName(t),this.clickButtonCtrl.componentWillLoad({label:"Click me"})}watchName(e){h.apply(e,t=>{this.setRenderProp("name",t)})}toggle(){var e,t;this.setState("show",!((t=(e=this.getState)===null||e===void 0?void 0:e.call(this,"show"))!==null&&t!==void 0&&t))}focus(){return this.clickButtonCtrl.focus()}startLoadedEventInterval(){this.intervalId=setInterval(()=>{var e,t;this.emitLoaded((t=(e=this.getState)===null||e===void 0?void 0:e.call(this,"count"))!==null&&t!==void 0?t:0)},2e3)}emitLoaded(e){this.onLoadedCallback&&this.onLoadedCallback(e)}setOnLoadedCallback(e){this.onLoadedCallback=e}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}}const x=class extends d{constructor(o){super(),k(this,o),this.loaded=r(this,"loaded"),this.rendered=r(this,"rendered"),this.ctrl=new I(this.stateAccess),this.count=0,this.label="Label",this.show=!0}async focus(){return Promise.resolve(this.ctrl.focus())}async toggle(){return Promise.resolve(this.ctrl.toggle())}watchName(o){this.ctrl.watchName(o)}handleKeyDown(o){(o.key==="Enter"||o.key===" ")&&(c.debug("button pressed"),this.ctrl.handleClick())}onKeydown(o){this.ctrl.onKeydown(o)}componentWillLoad(){this.ctrl.componentWillLoad({name:this._name}),this.ctrl.setOnLoadedCallback(o=>{this.loaded.emit(o)})}componentDidLoad(){requestAnimationFrame(()=>{this.rendered.emit()})}disconnectedCallback(){this.ctrl.destroy()}render(){return n(f,{key:"ff0f258279d6e18440f82f7fb4de42ed9bf4eaac"},n(N,{key:"2a07e293ba5934de959d7099f927db80ad396c68",count:this.count,label:this.label,name:this.ctrl.getRenderProp("name"),handleClick:()=>this.ctrl.handleClick(),onLoaded:this.loaded,onRendered:this.rendered,show:this.show,refButton:o=>this.ctrl.setButtonRef(o)}))}static get watchers(){return{_name:["watchName"]}}};export{x as kol_skeleton};
//# sourceMappingURL=kol-skeleton.entry-D6FZ7DEN.js.map
