text: import{r as t,c as i,h as s,g as e}from"./p-83ba3037.js";import"./p-c06cc5e4.js";import{j as o,k as r}from"./p-81b8808b.js";import{T as n}from"./p-34753693.js";const h=class{constructor(s){t(this,s),this.getModelEvent=i(this,"getModelEvent",7),this.condition=null,this.conditionResult=!1,this.falseSlot=null,this.trueSlot=null}componentWillLoad(){if(!this._host.isConnected)return;this.modelChain=this.condition,this.modelChain=o(this.modelChain);let t=t=>{if(t.hasExpression(this.modelChain)){let i=()=>{this.condition=t.evaluateExpression(this.modelChain)};t.onChangeExpressionChain(this.modelChain,i),i()}else{let i=()=>{this.condition=t.getChainValue(this.modelChain)};t.onChange(this.modelChain,i),i()}this.falseSlot=null;const i=Array.from(this._host.children);let s=i.filter(t=>"condition-true"===t.getAttribute("slot"));this.trueSlot=s.map(t=>t.outerHTML).join("");let e=i.filter(t=>"condition-false"===t.getAttribute("slot"));this.falseSlot=e.map(t=>t.outerHTML).join(""),0===this.trueSlot.length&&0===this.falseSlot.length&&(this.trueSlot=i.map(t=>t.outerHTML).join("")),this._host.innerHTML=""};return new Promise(i=>{this.getModelEvent.emit({callback:(s,e)=>{s&&console.log(s),t(e),this._updateConditionResult().then(()=>{i()})}})})}componentWillUpdate(){return this._updateConditionResult()}_updateConditionResult(){let t;return t=this.condition instanceof Promise?this.condition:Promise.resolve(this.condition),t.then(t=>(this.conditionResult=r(t),Promise.resolve()))}render(){return s("psk-hoc",{innerHTML:this.conditionResult?this.trueSlot:this.falseSlot})}get _host(){return e(this)}};!function(t,i,s,e){var o,r=arguments.length,n=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,i,s,e);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(n=(r<3?o(n):r>3?o(i,s,n):o(i,s))||n);r>3&&n&&Object.defineProperty(i,s,n)}([n({description:"The property value must be the name of a model property or expression. Children are rendered only if the value of the condition is evaluated to true",isMandatory:!0,propertyType:"any"})],h.prototype,"condition",void 0);export{h as psk_condition}