{"version":3,"file":"client.cjs","sources":["../src/InkMde.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { ink, renderToString } from 'ink-mde'\nimport type * as Ink from 'ink-mde'\nimport { type PropType, defineComponent } from 'vue'\n\nexport default defineComponent({\n  name: 'InkMde',\n  props: {\n    modelValue: {\n      type: String,\n    },\n    options: {\n      type: Object as PropType<Ink.Options>,\n    },\n  },\n  emits: ['update:modelValue'],\n  data() {\n    return {\n      html: '',\n      instance: undefined,\n    } as { html: string, instance?: Ink.Instance }\n  },\n  watch: {\n    modelValue(value) {\n      if (this.instance?.getDoc() !== value) {\n        this.instance?.update(value)\n      }\n    },\n    options: {\n      deep: true,\n      handler(newValue, _oldValue) {\n        this.instance?.reconfigure(newValue)\n      },\n    },\n  },\n  created() {\n    if (import.meta.env.VITE_SSR) {\n      this.html = renderToString(this.options)\n    }\n  },\n  mounted() {\n    this.tryInit()\n  },\n  updated() {\n    this.tryInit()\n  },\n  methods: {\n    tryInit() {\n      if (this.$refs.ink && !this.instance) {\n        this.instance = ink(this.$refs.ink as HTMLElement, {\n          ...this.options,\n          doc: this.modelValue,\n          hooks: {\n            ...this.options?.hooks,\n            afterUpdate: (doc: string) => {\n              this.$emit('update:modelValue', doc)\n\n              if (this.options?.hooks?.afterUpdate) {\n                this.options.hooks.afterUpdate(doc)\n              }\n            },\n          },\n        })\n\n        // @ts-expect-error Todo: Fix type recognition on $refs.\n        this.$refs.ink.addEventListener('input', (event: InputEvent) => {\n          event.stopPropagation()\n        })\n      }\n    },\n  },\n})\n</script>\n\n<template>\n  <div ref=\"ink\" v-html=\"html\" />\n</template>\n"],"names":["_sfc_main","defineComponent","value","_a","_b","newValue","_oldValue","define_import_meta_env_default","renderToString","ink","doc","event","_sfc_render","_ctx","_cache","$props","$setup","$data","$options","_openBlock","_createElementBlock"],"mappings":"qNAKA,MAAAA,EAAeC,kBAAgB,CAC7B,KAAM,SACN,MAAO,CACL,WAAY,CACV,KAAM,MACR,EACA,QAAS,CACP,KAAM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