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rB,CACK,GAAI,aAAgB,OAAQ,CAC7B,IAAI,EAAc,CAAC,EACnB,IAAK,MAAM,KAAO,EACd,EAAc,IAAK,EAAa,CAAC,GAAM,EAAK,IAEhD,OAAO,CACX,CAEI,MAAM,IAAI,UAAU,yGAAyG,EACjI,SAcG,MAAM,EAAI,CAAC,EAAM,EAAU,IAEvB,KACI,CACH,KAAM,EACN,WACA,mBAKL,MAAM,MAAQ,SACd,MAAM,GAAK,aACX,MAAM,KAAO,SACb,MAAM,WAAa,SACnB,MAAM,UAAY,SAClB,MAAM,aAAe,SACrB,MAAM,KAAO,SACb,MAAM,YAAc","file":"/gh/fighter178/micromarkup@master/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /gh/fighter178/micromarkup@master/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","let options = {\n    legacyMode: false,\n};\n/** Sets config options. Supply a name, and a value. Will apply to future calls for the function(s) */\nexport const setOption = (optionName, value) => {\n    options[optionName] = value;\n};\n/** Supply an entirely new options object. */\nexport const setOptions = (newOptions) => {\n    options = newOptions;\n};\n/**\n * The `mk` function creates a new HTML element with specified attributes, children, and event\n * listeners.\n * @param {mkElement[]} children - The `children` parameter is a rest parameter that allows the\n * function to accept an arbitrary number of arguments, each of which must be an instance of the\n * `mkElement` type. These arguments represent the child elements that will be appended to the newly\n * created `div` element.\n * Note, if an attribute is supplied (from the `attribute` or `a` function), it will be applied to the **first** child.\n * @returns The `mk` function returns an HTML element (`HTMLElement`).\n */\nexport const mk = (...children) => {\n    const div = !options.legacyMode ? document.createDocumentFragment() : document.createElement(\"div\");\n    children.forEach(child => {\n        if (child instanceof HTMLElement || child instanceof Text) {\n            div.append(child);\n        }\n        else if (child instanceof Function) {\n            const evt = child();\n            div.addEventListener(evt.name, evt.callback, evt.options);\n        }\n        else {\n            for (const key in child) {\n                const val = child[key];\n                if (options.legacyMode && div instanceof HTMLElement) {\n                    div.setAttribute(key, val);\n                }\n                else\n                    div.children[0].setAttribute(key, val);\n            }\n            ;\n        }\n        ;\n    });\n    options.legacyMode && div instanceof HTMLElement && div.classList.add(\"micromarkup\");\n    return div;\n};\n/**\n * This is function creates and returns a new HTML element with specified tag name,\n * attributes, and children.\n * @param tagName - a string representing the HTML tag name of the element to be created\n * @param {mkElement[]} children - an array of mkElement, which can be either HTMLElement, Text,\n * event (function), or attributes\n * @returns {mkElement} The function `n` returns an `mkElement`.\n */\nexport const n = (tagName, ...children) => {\n    const el = document.createElement(tagName);\n    children.forEach((child) => {\n        if (child instanceof HTMLElement || child instanceof Text) {\n            el.append(child);\n        }\n        else if (child instanceof Function) {\n            const evt = child();\n            el.addEventListener(evt.name, evt.callback);\n        }\n        else {\n            for (const key in child) {\n                const val = child[key];\n                if (key === \"class\") {\n                    el.classList.add(val);\n                    continue;\n                }\n                el.setAttribute(key, val);\n            }\n            ;\n        }\n        ;\n    });\n    return el;\n};\n/**\n * The function \"t\" creates a new text node with the given string as its content.\n * @param {string} text - The parameter \"text\" is a string that represents the text content that we\n * want to create a Text node for.\n * @returns {mkElement}\n */\nexport const t = (text) => {\n    return document.createTextNode(text);\n};\n/**\n * The function takes in two string parameters and returns an object with a property named after the\n * first parameter and a value of the second parameter.\n * @param {string} name - The name parameter is a string that represents the name of a property.\n * @param {string} value - The `value` parameter is a string type and represents the value that will be\n * assigned to the property.\n * @returns Returns the @see Prop , which can be used in `n`, `node`, `mk`, `microMarkup`.\n */\nexport const a = (name, value) => {\n    if (typeof name === \"string\") {\n        if (!value)\n            throw new Error(\"Micromarkup: Since you passed a string to the name parameter of the attribute function, the value must be defined. You did not define the value.\");\n        return { [name]: value };\n    }\n    else if (name instanceof Object) {\n        let returnValue = {};\n        for (const key in name) {\n            returnValue = { ...returnValue, [key]: name[key] };\n        }\n        return returnValue;\n    }\n    else {\n        throw new TypeError(`Micromarkup: Invalid type for attribute function. Expected Type: string or object, type given: ${typeof name}`);\n    }\n};\n/**\n * This function creates an event listener with a specified type, callback function, and\n * options.\n * @param {T} type - The type of event to listen for, which is a key of the `DocumentEventMap`\n * interface.\n * @param callback - The function that will be called when the event of type `T` is triggered. It takes\n * an optional parameter `e` of type `DocumentEventMap[T]`, which represents the event object\n * associated with the triggered event.\n * @param {EventListenerOptions} [options] - `options` is an optional parameter of type\n * `EventListenerOptions` that specifies options for the event listener.\n * @returns A function for use in `n` or `node`.\n */\nexport const e = (type, callback, options) => {\n    //@ts-expect-error It works.\n    return () => {\n        return {\n            name: type,\n            callback,\n            options\n        };\n    };\n};\n// Aliases. I know that `import as` exists, but this is fewer lines of code at the end if using Micromarkup for larger projects.\nexport const event = e;\nexport const on = event;\nexport const node = n;\nexport const createNode = n;\nexport const attribute = a;\nexport const setAttribute = a;\nexport const text = t;\nexport const microMarkup = mk;\n"]}