import{aD as t,aE as s,aF as e,aG as a,aH as i,aR as c,aS as n,aT as l,aU as o}from"./p-BTBbFFOR.js";var h=function(t,s,e,a){var i,c=arguments.length,n=c<3?s:null===a?a=Object.getOwnPropertyDescriptor(s,e):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,a);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(n=(c<3?i(n):c>3?i(s,e,n):i(s,e))||n);return c>3&&n&&Object.defineProperty(s,e,n),n};class r extends e{connectedCallback(){if(this.parent=this.getParent(),!this.parent)return;const{subStates:t}=this.observerEntry;this.subStateObserver=new a(this.isAcceptableObserverPayload,(s=>{const e=t.find((t=>t.parentStateName===s.stateName));e&&this.updateState(e,s.value)})),i.register(c.getSubject(this.parent,n),this.subStateObserver),this.observerEntry.pullStatesWhenReattached&&this.host.classList.contains("hydrated")&&(this.parent=this.getParent(),this.pullStates())}disconnectedCallback(){this.parent&&i.unregister(c.getSubject(this.parent,n),this.subStateObserver)}componentWillLoad(){this.pullStates()}constructor(t){super(),this.isAcceptableObserverPayload=t=>"object"==typeof t&&!!t&&t.host===this.parent,this.observerEntry=t}getParent(){return"string"==typeof this.observerEntry.parent?l(this.host,this.observerEntry.parent):this.observerEntry.parent()}updateState(t,s){t.callback?t.callback(s):this[t.subStateName]=s}pullStates(){if(!this.parent)return;const{subStates:t}=this.observerEntry;t.forEach((t=>{i.notify(c.getSubject(this.parent,o),{host:this.parent,stateName:t.parentStateName,callback:s=>{this.updateState(t,s)}})}))}}h([t()],r.prototype,"host",void 0),h([s("connectedCallback")],r.prototype,"connectedCallback",null),h([s("disconnectedCallback")],r.prototype,"disconnectedCallback",null),h([s("componentWillLoad")],r.prototype,"componentWillLoad",null);export{r as S}