{
  "version": 3,
  "sources": ["../../src/lib/component.ts"],
  "sourcesContent": ["import { VanillaMachine } from \"@zag-js/vanilla\";\n\ninterface ComponentInterface<Api> {\n  el: HTMLElement;\n  machine: VanillaMachine<any>;\n  api: Api;\n\n  init(): void;\n  destroy(): void;\n  render(): void;\n}\n\nexport abstract class Component<Props, Api> implements ComponentInterface<Api> {\n  el: HTMLElement;\n  machine: VanillaMachine<any>;\n  api: Api;\n\n  constructor(el: HTMLElement | null, props: Props) {\n    if (!el) throw new Error(\"Root element not found\");\n    this.el = el;\n    this.machine = this.initMachine(props);\n    this.api = this.initApi();\n  }\n\n  abstract initMachine(props: Props): VanillaMachine<any>;\n  abstract initApi(): Api;\n  abstract render(): void;\n\n  init = () => {\n    this.render();\n    this.machine.subscribe(() => {\n      this.api = this.initApi();\n      this.render();\n    });\n    this.machine.start();\n  };\n\n  destroy = () => {\n    this.machine.stop();\n  };\n}\n"],
  "mappings": ";AAYO,IAAe,YAAf,MAAwE;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,IAAwB,OAAc;AAChD,QAAI,CAAC,GAAI,OAAM,IAAI,MAAM,wBAAwB;AACjD,SAAK,KAAK;AACV,SAAK,UAAU,KAAK,YAAY,KAAK;AACrC,SAAK,MAAM,KAAK,QAAQ;AAAA,EAC1B;AAAA,EAMA,OAAO,MAAM;AACX,SAAK,OAAO;AACZ,SAAK,QAAQ,UAAU,MAAM;AAC3B,WAAK,MAAM,KAAK,QAAQ;AACxB,WAAK,OAAO;AAAA,IACd,CAAC;AACD,SAAK,QAAQ,MAAM;AAAA,EACrB;AAAA,EAEA,UAAU,MAAM;AACd,SAAK,QAAQ,KAAK;AAAA,EACpB;AACF;",
  "names": []
}
