import { useRef, useEvent, h } from 'atomico';
import 'funfix';
import { g as getComponentOrDefine } from './chunks/65ef80fe.js';
import './kun-icon.js';
import { e as execWithSixLoad } from './chunks/19492529.js';
import { updateMarkdown } from '@caedman/seek-api/build/api/upload-markdown';

var style = ":host {\n}\n";

const _jsxFileName = "/Users/rang/rang/frond_ng/packages/six/src/components/kun-markdown-button/kun-markdown-button.tsx";
const KunMarkdownButton = () => {
  const refLabel = useRef();

  const uploadMarkdownEvent = useEvent("MyUpload", {
    bubbles: true,
    composed: true,
  });
  const uploadFile = async (event) => {
    await execWithSixLoad(async () => {
      const file = event.target.files[0];
      const formData = new FormData();
      formData.set("file", file);
      const r = await updateMarkdown(formData );
      uploadMarkdownEvent({ content: r.record.content });
    });
  };

  return (
    h('host', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 28}}
      , h('style', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 29}}, style)
      , h('span', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 30}}
        , h('kun-icon', { iconType: "markdown", onclick: () => refLabel.current.click(), iconWidth: 24, iconHeight: 24, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 31}} )
        , h('input', { ref: refLabel, type: "file", className: "hidden", onchange: uploadFile, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 32}} )
      )
    )
  );
};

KunMarkdownButton.props = {
};

var kunMarkdownButton = getComponentOrDefine("kun-markdown-button", KunMarkdownButton);

export default kunMarkdownButton;
