jails-js 6.0.1-beta.4 → 6.0.1-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,6 +10,9 @@ const rAF = (fn) => {
10
10
  const uuid = () => {
11
11
  return Math.random().toString(36).substring(2, 9);
12
12
  };
13
+ const dup = (o) => {
14
+ return JSON.parse(JSON.stringify(o));
15
+ };
13
16
  const safe = (execute, val) => {
14
17
  try {
15
18
  return execute();
@@ -787,13 +790,13 @@ const Component = ({ name, module, dependencies, node, templates: templates2, si
787
790
  const _model = module.model || {};
788
791
  const initialState = new Function(`return ${node.getAttribute("html-model") || "{}"}`)();
789
792
  const tplid = node.getAttribute("tplid");
790
- const scopeid = node.getAttribute("html-scope-id");
793
+ const scopeid = node.getAttribute("html-scopeid");
791
794
  const tpl = templates2[tplid];
792
- const data = g.scope[scopeid];
793
- const model = ((_a = module == null ? void 0 : module.model) == null ? void 0 : _a.apply) ? _model({ elm: node, initialState }) : _model;
794
- const state = Object.assign({}, data, model, initialState);
795
- const view = module.view ? module.view : (data2) => data2;
796
- let updates = [];
795
+ const scope = g.scope[scopeid];
796
+ const model = dup(((_a = module == null ? void 0 : module.model) == null ? void 0 : _a.apply) ? _model({ elm: node, initialState }) : _model);
797
+ const state = Object.assign({}, scope, model, initialState);
798
+ const view = module.view ? module.view : (data) => data;
799
+ let preserve = [];
797
800
  const base = {
798
801
  name,
799
802
  model,
@@ -809,34 +812,32 @@ const Component = ({ name, module, dependencies, node, templates: templates2, si
809
812
  * @State
810
813
  */
811
814
  state: {
812
- save(data2) {
813
- if (data2.constructor === Function) {
814
- data2(state);
815
+ protected(list) {
816
+ if (list) {
817
+ preserve = list;
818
+ } else {
819
+ return preserve;
820
+ }
821
+ },
822
+ save(data) {
823
+ if (data.constructor === Function) {
824
+ data(state);
815
825
  } else {
816
- Object.assign(state, data2);
826
+ Object.assign(state, data);
817
827
  }
818
828
  },
819
- set(data2) {
829
+ set(data) {
820
830
  if (!document.body.contains(node)) {
821
831
  return;
822
832
  }
823
- if (data2.constructor === Function) {
824
- data2(state);
833
+ if (data.constructor === Function) {
834
+ data(state);
825
835
  } else {
826
- Object.assign(state, data2);
836
+ Object.assign(state, data);
827
837
  }
828
- const newstate = Object.assign({}, state);
829
- updates.push(data2);
830
- return new Promise((resolve) => {
831
- rAF(() => {
832
- Object.assign.apply(null, [newstate, ...updates]);
833
- if (updates.length) {
834
- render(newstate);
835
- resolve(newstate);
836
- updates = [];
837
- }
838
- });
839
- });
838
+ const newstate = Object.assign({}, state, scope);
839
+ render(newstate);
840
+ return Promise.resolve(newstate);
840
841
  },
841
842
  get() {
842
843
  return Object.assign({}, state);
@@ -876,17 +877,17 @@ const Component = ({ name, module, dependencies, node, templates: templates2, si
876
877
  node.removeEventListener(ev, callback.handler);
877
878
  }
878
879
  },
879
- trigger(ev, selectorOrCallback, data2) {
880
+ trigger(ev, selectorOrCallback, data) {
880
881
  if (selectorOrCallback.constructor === String) {
881
882
  Array.from(node.querySelectorAll(selectorOrCallback)).forEach((children) => {
882
- children.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data2 } }));
883
+ children.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }));
883
884
  });
884
885
  } else {
885
- node.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data2 } }));
886
+ node.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }));
886
887
  }
887
888
  },
888
- emit(ev, data2) {
889
- node.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data2 } }));
889
+ emit(ev, data) {
890
+ node.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }));
890
891
  },
891
892
  unmount(fn) {
892
893
  node.addEventListener(":unmount", fn);
@@ -899,23 +900,14 @@ const Component = ({ name, module, dependencies, node, templates: templates2, si
899
900
  rAF((_) => Idiomorph.morph(element, clone, IdiomorphOptions));
900
901
  }
901
902
  };
902
- const render = (data2) => {
903
- const html = tpl.render.call(view(data2), node, safe, g);
903
+ const render = (data) => {
904
+ const html = tpl.render.call(view(data), node, safe, g);
904
905
  Idiomorph.morph(node, html, IdiomorphOptions(node));
905
906
  rAF(() => {
906
907
  node.querySelectorAll("[tplid]").forEach((element) => {
907
908
  if (!element.base) return;
908
- const base2 = element.base;
909
- const props = Object.keys(base2.model).reduce((acc, key) => {
910
- if (key in data2) {
911
- if (!acc) acc = {};
912
- acc[key] = data2[key];
913
- }
914
- return acc;
915
- }, null);
916
- if (props) {
917
- base2.state.set(props);
918
- }
909
+ element.base.state.protected().forEach((key) => delete data[key]);
910
+ element.base.state.set(data);
919
911
  });
920
912
  rAF(() => g.scope = {});
921
913
  });
@@ -985,8 +977,7 @@ const template = (target, { components: components2 }) => {
985
977
  setTemplates(clone, components2);
986
978
  return templates;
987
979
  };
988
- const compile = (outerHTML) => {
989
- const html = transformAttributes(outerHTML);
980
+ const compile = (html) => {
990
981
  const parsedHtml = JSON.stringify(html);
991
982
  return new Function("$element", "safe", "$g", `
992
983
  var $data = this;
@@ -1010,7 +1001,7 @@ const tagElements = (target, keys) => {
1010
1001
  const transformAttributes = (html) => {
1011
1002
  const regexTags = new RegExp(`\\${config.tags[0]}(.+?)\\${config.tags[1]}`, "g");
1012
1003
  return html.replace(/jails___scope-id/g, "%%_=$scopeid_%%").replace(regexTags, "%%_=$1_%%").replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\"(.*?)\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`).replace(/html-(.*?)=\"(.*?)\"/g, (all, key, value) => {
1013
- if (key === "key" || key === "model" || key === "scope-id") {
1004
+ if (key === "key" || key === "model" || key === "scopeid") {
1014
1005
  return all;
1015
1006
  }
1016
1007
  if (value) {
@@ -1032,7 +1023,8 @@ const transformTemplate = (clone) => {
1032
1023
  const split = htmlFor.match(/(.*)\sin\s(.*)/) || "";
1033
1024
  const varname = split[1];
1034
1025
  const object = split[2];
1035
- const open = document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = { ${varname} :${varname}, ${object}: ${object}, $index: $index, $key: $key }; _%%`);
1026
+ const objectname = object.split(/\./).shift();
1027
+ const open = document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${objectname}: ${objectname} }, { ${varname} :${varname}, $index: $index, $key: $key }); _%%`);
1036
1028
  const close = document.createTextNode(`%%_ $index++; } })() _%%`);
1037
1029
  wrap(open, element, close);
1038
1030
  }
@@ -1059,24 +1051,13 @@ const setTemplates = (clone, components2) => {
1059
1051
  Array.from(clone.querySelectorAll("[tplid]")).reverse().forEach((node) => {
1060
1052
  const tplid = node.getAttribute("tplid");
1061
1053
  const name = node.localName;
1062
- node.setAttribute("html-scope-id", "jails___scope-id");
1054
+ node.setAttribute("html-scopeid", "jails___scope-id");
1063
1055
  if (name in components2 && components2[name].module.template) {
1064
1056
  const children = node.innerHTML;
1065
1057
  const html2 = components2[name].module.template({ elm: node, children });
1066
- if (html2.constructor === Promise) {
1067
- html2.then((htmlstring) => {
1068
- node.innerHTML = htmlstring;
1069
- const html3 = node.outerHTML;
1070
- templates[tplid] = {
1071
- template: html3,
1072
- render: compile(html3)
1073
- };
1074
- });
1075
- } else {
1076
- node.innerHTML = html2;
1077
- }
1058
+ node.innerHTML = html2;
1078
1059
  }
1079
- const html = node.outerHTML;
1060
+ const html = transformAttributes(node.outerHTML);
1080
1061
  templates[tplid] = {
1081
1062
  template: html,
1082
1063
  render: compile(html)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/index.ts","../node_modules/idiomorph/dist/idiomorph.esm.js","../src/utils/pubsub.ts","../src/component.ts","../src/element.ts","../src/template-system.ts","../src/index.ts"],"sourcesContent":["\nexport const g = {\n\tscope: {}\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn Math.random().toString(36).substring(2, 9)\n}\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\nexport const safe = (execute, val) => {\n\ttry{\n\t\treturn execute()\n\t}catch(err){\n\t\treturn val || ''\n\t}\n}\n","/**\n * @typedef {object} ConfigHead\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} [style]\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {function(Element): boolean} [shouldPreserve]\n * @property {function(Element): boolean} [shouldReAppend]\n * @property {function(Element): boolean} [shouldRemove]\n * @property {function(Element, {added: Node[], kept: Element[], removed: Element[]}): void} [afterHeadMorphed]\n */\n\n/**\n * @typedef {object} ConfigCallbacks\n *\n * @property {function(Node): boolean} [beforeNodeAdded]\n * @property {function(Node): void} [afterNodeAdded]\n * @property {function(Element, Node): boolean} [beforeNodeMorphed]\n * @property {function(Element, Node): void} [afterNodeMorphed]\n * @property {function(Element): boolean} [beforeNodeRemoved]\n * @property {function(Element): void} [afterNodeRemoved]\n * @property {function(string, Element, \"update\" | \"remove\"): boolean} [beforeAttributeUpdated]\n * @property {function(Element): boolean} [beforeNodePantried]\n */\n\n/**\n * @typedef {object} Config\n *\n * @property {'outerHTML' | 'innerHTML'} [morphStyle]\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacks} [callbacks]\n * @property {ConfigHead} [head]\n */\n\n/**\n * @typedef {function} NoOp\n *\n * @returns {void}\n */\n\n/**\n * @typedef {object} ConfigHeadInternal\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} style\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {(function(Element): boolean) | NoOp} shouldPreserve\n * @property {(function(Element): boolean) | NoOp} shouldReAppend\n * @property {(function(Element): boolean) | NoOp} shouldRemove\n * @property {(function(Element, {added: Node[], kept: Element[], removed: Element[]}): void) | NoOp} afterHeadMorphed\n */\n\n/**\n * @typedef {object} ConfigCallbacksInternal\n *\n * @property {(function(Node): boolean) | NoOp} beforeNodeAdded\n * @property {(function(Node): void) | NoOp} afterNodeAdded\n * @property {(function(Node, Node): boolean) | NoOp} beforeNodeMorphed\n * @property {(function(Node, Node): void) | NoOp} afterNodeMorphed\n * @property {(function(Node): boolean) | NoOp} beforeNodeRemoved\n * @property {(function(Node): void) | NoOp} afterNodeRemoved\n * @property {(function(string, Element, \"update\" | \"remove\"): boolean) | NoOp} beforeAttributeUpdated\n * @property {(function(Node): boolean) | NoOp} beforeNodePantried\n */\n\n/**\n * @typedef {object} ConfigInternal\n *\n * @property {'outerHTML' | 'innerHTML'} morphStyle\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacksInternal} callbacks\n * @property {ConfigHeadInternal} head\n * @property {boolean} [twoPass]\n */\n\n/**\n * @typedef {Function} Morph\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n\n// base IIFE to define idiomorph\n/**\n *\n * @type {{defaults: ConfigInternal, morph: Morph}}\n */\nvar Idiomorph = (function () {\n \"use strict\";\n\n /**\n * @typedef {object} MorphContext\n *\n * @property {Node} target\n * @property {Node} newContent\n * @property {ConfigInternal} config\n * @property {ConfigInternal['morphStyle']} morphStyle\n * @property {ConfigInternal['ignoreActive']} ignoreActive\n * @property {ConfigInternal['ignoreActiveValue']} ignoreActiveValue\n * @property {Map<Node, Set<string>>} idMap\n * @property {Set<string>} persistentIds\n * @property {Set<string>} deadIds\n * @property {ConfigInternal['callbacks']} callbacks\n * @property {ConfigInternal['head']} head\n * @property {HTMLDivElement} pantry\n */\n\n //=============================================================================\n // AND NOW IT BEGINS...\n //=============================================================================\n\n /**\n *\n * @type {Set<string>}\n */\n let EMPTY_SET = new Set();\n\n /**\n * Default configuration values, updatable by users now\n * @type {ConfigInternal}\n */\n let defaults = {\n morphStyle: \"outerHTML\",\n callbacks: {\n beforeNodeAdded: noOp,\n afterNodeAdded: noOp,\n beforeNodeMorphed: noOp,\n afterNodeMorphed: noOp,\n beforeNodeRemoved: noOp,\n afterNodeRemoved: noOp,\n beforeAttributeUpdated: noOp,\n beforeNodePantried: noOp,\n },\n head: {\n style: \"merge\",\n shouldPreserve: function (elt) {\n return elt.getAttribute(\"im-preserve\") === \"true\";\n },\n shouldReAppend: function (elt) {\n return elt.getAttribute(\"im-re-append\") === \"true\";\n },\n shouldRemove: noOp,\n afterHeadMorphed: noOp,\n },\n };\n\n /**\n * =============================================================================\n * Core Morphing Algorithm - morph, morphNormalizedContent, morphOldNodeTo, morphChildren\n * =============================================================================\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n function morph(oldNode, newContent, config = {}) {\n if (oldNode instanceof Document) {\n oldNode = oldNode.documentElement;\n }\n\n if (typeof newContent === \"string\") {\n newContent = parseContent(newContent);\n }\n\n let normalizedContent = normalizeContent(newContent);\n\n let ctx = createMorphContext(oldNode, normalizedContent, config);\n\n return morphNormalizedContent(oldNode, normalizedContent, ctx);\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} normalizedNewContent\n * @param {MorphContext} ctx\n * @returns {undefined | Node[]}\n */\n function morphNormalizedContent(oldNode, normalizedNewContent, ctx) {\n if (ctx.head.block) {\n let oldHead = oldNode.querySelector(\"head\");\n let newHead = normalizedNewContent.querySelector(\"head\");\n if (oldHead && newHead) {\n let promises = handleHeadElement(newHead, oldHead, ctx);\n // when head promises resolve, call morph again, ignoring the head tag\n Promise.all(promises).then(function () {\n morphNormalizedContent(\n oldNode,\n normalizedNewContent,\n Object.assign(ctx, {\n head: {\n block: false,\n ignore: true,\n },\n }),\n );\n });\n return;\n }\n }\n\n if (ctx.morphStyle === \"innerHTML\") {\n // innerHTML, so we are only updating the children\n morphChildren(normalizedNewContent, oldNode, ctx);\n if (ctx.config.twoPass) {\n restoreFromPantry(oldNode, ctx);\n }\n return Array.from(oldNode.children);\n } else if (ctx.morphStyle === \"outerHTML\" || ctx.morphStyle == null) {\n // otherwise find the best element match in the new content, morph that, and merge its siblings\n // into either side of the best match\n let bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);\n\n // stash the siblings that will need to be inserted on either side of the best match\n let previousSibling = bestMatch?.previousSibling ?? null;\n let nextSibling = bestMatch?.nextSibling ?? null;\n\n // morph it\n let morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);\n\n if (bestMatch) {\n // if there was a best match, merge the siblings in too and return the\n // whole bunch\n if (morphedNode) {\n const elements = insertSiblings(\n previousSibling,\n morphedNode,\n nextSibling,\n );\n if (ctx.config.twoPass) {\n restoreFromPantry(morphedNode.parentNode, ctx);\n }\n return elements;\n }\n } else {\n // otherwise nothing was added to the DOM\n return [];\n }\n } else {\n throw \"Do not understand how to morph style \" + ctx.morphStyle;\n }\n }\n\n /**\n * @param {Node} possibleActiveElement\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: ignoreActive and ignoreActiveValue are marked as optional since they are not\n // initialised in the default config object. As a result the && in the function body may\n // return undefined instead of boolean. Either expand the type of the return value to\n // include undefined or wrap the ctx.ignoreActiveValue into a Boolean()\n function ignoreValueOfActiveElement(possibleActiveElement, ctx) {\n return (\n !!ctx.ignoreActiveValue &&\n possibleActiveElement === document.activeElement &&\n possibleActiveElement !== document.body\n );\n }\n\n /**\n * @param {Node} oldNode root node to merge content into\n * @param {Node | null} newContent new content to merge\n * @param {MorphContext} ctx the merge context\n * @returns {Node | null} the element that ended up in the DOM\n */\n function morphOldNodeTo(oldNode, newContent, ctx) {\n if (ctx.ignoreActive && oldNode === document.activeElement) {\n // don't morph focused element\n } else if (newContent == null) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n\n oldNode.parentNode?.removeChild(oldNode);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return null;\n } else if (!isSoftMatch(oldNode, newContent)) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n if (ctx.callbacks.beforeNodeAdded(newContent) === false) return oldNode;\n\n oldNode.parentNode?.replaceChild(newContent, oldNode);\n ctx.callbacks.afterNodeAdded(newContent);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return newContent;\n } else {\n if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false)\n return oldNode;\n\n if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) {\n // ignore the head element\n } else if (\n oldNode instanceof HTMLHeadElement &&\n ctx.head.style !== \"morph\"\n ) {\n // ok to cast: if newContent wasn't also a <head>, it would've got caught in the `!isSoftMatch` branch above\n handleHeadElement(\n /** @type {HTMLHeadElement} */ (newContent),\n oldNode,\n ctx,\n );\n } else {\n syncNodeFrom(newContent, oldNode, ctx);\n if (!ignoreValueOfActiveElement(oldNode, ctx)) {\n morphChildren(newContent, oldNode, ctx);\n }\n }\n ctx.callbacks.afterNodeMorphed(oldNode, newContent);\n return oldNode;\n }\n return null;\n }\n\n /**\n * This is the core algorithm for matching up children. The idea is to use id sets to try to match up\n * nodes as faithfully as possible. We greedily match, which allows us to keep the algorithm fast, but\n * by using id sets, we are able to better match up with content deeper in the DOM.\n *\n * Basic algorithm is, for each node in the new content:\n *\n * - if we have reached the end of the old parent, append the new content\n * - if the new content has an id set match with the current insertion point, morph\n * - search for an id set match\n * - if id set match found, morph\n * - otherwise search for a \"soft\" match\n * - if a soft match is found, morph\n * - otherwise, prepend the new node before the current insertion point\n *\n * The two search algorithms terminate if competing node matches appear to outweigh what can be achieved\n * with the current node. See findIdSetMatch() and findSoftMatch() for details.\n *\n * @param {Node} newParent the parent element of the new content\n * @param {Node} oldParent the old content that we are merging the new content into\n * @param {MorphContext} ctx the merge context\n * @returns {void}\n */\n function morphChildren(newParent, oldParent, ctx) {\n if (\n newParent instanceof HTMLTemplateElement &&\n oldParent instanceof HTMLTemplateElement\n ) {\n newParent = newParent.content;\n oldParent = oldParent.content;\n }\n\n /**\n *\n * @type {Node | null}\n */\n let nextNewChild = newParent.firstChild;\n /**\n *\n * @type {Node | null}\n */\n let insertionPoint = oldParent.firstChild;\n let newChild;\n\n // run through all the new content\n while (nextNewChild) {\n newChild = nextNewChild;\n nextNewChild = newChild.nextSibling;\n\n // if we are at the end of the exiting parent's children, just append\n if (insertionPoint == null) {\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.appendChild(newChild);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.appendChild(newChild);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // if the current node has an id set match then morph\n if (isIdSetMatch(newChild, insertionPoint, ctx)) {\n morphOldNodeTo(insertionPoint, newChild, ctx);\n insertionPoint = insertionPoint.nextSibling;\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // otherwise search forward in the existing old children for an id set match\n let idSetMatch = findIdSetMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a potential match, remove the nodes until that point and morph\n if (idSetMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, idSetMatch, ctx);\n morphOldNodeTo(idSetMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // no id set match found, so scan forward for a soft match for the current node\n let softMatch = findSoftMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a soft match for the current node, morph\n if (softMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, softMatch, ctx);\n morphOldNodeTo(softMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // abandon all hope of morphing, just insert the new child before the insertion point\n // and move on\n\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.insertBefore(newChild, insertionPoint);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.insertBefore(newChild, insertionPoint);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n }\n\n // remove any remaining old nodes that didn't match up with new content\n while (insertionPoint !== null) {\n let tempNode = insertionPoint;\n insertionPoint = insertionPoint.nextSibling;\n removeNode(tempNode, ctx);\n }\n }\n\n //=============================================================================\n // Attribute Syncing Code\n //=============================================================================\n\n /**\n * @param {string} attr the attribute to be mutated\n * @param {Element} to the element that is going to be updated\n * @param {\"update\" | \"remove\"} updateType\n * @param {MorphContext} ctx the merge context\n * @returns {boolean} true if the attribute should be ignored, false otherwise\n */\n function ignoreAttribute(attr, to, updateType, ctx) {\n if (\n attr === \"value\" &&\n ctx.ignoreActiveValue &&\n to === document.activeElement\n ) {\n return true;\n }\n return ctx.callbacks.beforeAttributeUpdated(attr, to, updateType) === false;\n }\n\n /**\n * syncs a given node with another node, copying over all attributes and\n * inner element state from the 'from' node to the 'to' node\n *\n * @param {Node} from the element to copy attributes & state from\n * @param {Node} to the element to copy attributes & state to\n * @param {MorphContext} ctx the merge context\n */\n function syncNodeFrom(from, to, ctx) {\n let type = from.nodeType;\n\n // if is an element type, sync the attributes from the\n // new node into the new node\n if (type === 1 /* element type */) {\n const fromEl = /** @type {Element} */ (from);\n const toEl = /** @type {Element} */ (to);\n const fromAttributes = fromEl.attributes;\n const toAttributes = toEl.attributes;\n for (const fromAttribute of fromAttributes) {\n if (ignoreAttribute(fromAttribute.name, toEl, \"update\", ctx)) {\n continue;\n }\n if (toEl.getAttribute(fromAttribute.name) !== fromAttribute.value) {\n toEl.setAttribute(fromAttribute.name, fromAttribute.value);\n }\n }\n // iterate backwards to avoid skipping over items when a delete occurs\n for (let i = toAttributes.length - 1; 0 <= i; i--) {\n const toAttribute = toAttributes[i];\n\n // toAttributes is a live NamedNodeMap, so iteration+mutation is unsafe\n // e.g. custom element attribute callbacks can remove other attributes\n if (!toAttribute) continue;\n\n if (!fromEl.hasAttribute(toAttribute.name)) {\n if (ignoreAttribute(toAttribute.name, toEl, \"remove\", ctx)) {\n continue;\n }\n toEl.removeAttribute(toAttribute.name);\n }\n }\n }\n\n // sync text nodes\n if (type === 8 /* comment */ || type === 3 /* text */) {\n if (to.nodeValue !== from.nodeValue) {\n to.nodeValue = from.nodeValue;\n }\n }\n\n if (!ignoreValueOfActiveElement(to, ctx)) {\n // sync input values\n syncInputValue(from, to, ctx);\n }\n }\n\n /**\n * @param {Element} from element to sync the value from\n * @param {Element} to element to sync the value to\n * @param {string} attributeName the attribute name\n * @param {MorphContext} ctx the merge context\n */\n function syncBooleanAttribute(from, to, attributeName, ctx) {\n // TODO: prefer set/getAttribute here\n if (!(from instanceof Element && to instanceof Element)) return;\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n const fromLiveValue = from[attributeName],\n toLiveValue = to[attributeName];\n if (fromLiveValue !== toLiveValue) {\n let ignoreUpdate = ignoreAttribute(attributeName, to, \"update\", ctx);\n if (!ignoreUpdate) {\n // update attribute's associated DOM property\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n to[attributeName] = from[attributeName];\n }\n if (fromLiveValue) {\n if (!ignoreUpdate) {\n // TODO: do we really want this? tests say so but it feels wrong\n to.setAttribute(attributeName, fromLiveValue);\n }\n } else {\n if (!ignoreAttribute(attributeName, to, \"remove\", ctx)) {\n to.removeAttribute(attributeName);\n }\n }\n }\n }\n\n /**\n * NB: many bothans died to bring us information:\n *\n * https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js\n * https://github.com/choojs/nanomorph/blob/master/lib/morph.jsL113\n *\n * @param {Node} from the element to sync the input value from\n * @param {Node} to the element to sync the input value to\n * @param {MorphContext} ctx the merge context\n */\n function syncInputValue(from, to, ctx) {\n if (\n from instanceof HTMLInputElement &&\n to instanceof HTMLInputElement &&\n from.type !== \"file\"\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n\n // sync boolean attributes\n syncBooleanAttribute(from, to, \"checked\", ctx);\n syncBooleanAttribute(from, to, \"disabled\", ctx);\n\n if (!from.hasAttribute(\"value\")) {\n if (!ignoreAttribute(\"value\", to, \"remove\", ctx)) {\n to.value = \"\";\n to.removeAttribute(\"value\");\n }\n } else if (fromValue !== toValue) {\n if (!ignoreAttribute(\"value\", to, \"update\", ctx)) {\n to.setAttribute(\"value\", fromValue);\n to.value = fromValue;\n }\n }\n // TODO: QUESTION(1cg): this used to only check `from` unlike the other branches -- why?\n // did I break something?\n } else if (\n from instanceof HTMLOptionElement &&\n to instanceof HTMLOptionElement\n ) {\n syncBooleanAttribute(from, to, \"selected\", ctx);\n } else if (\n from instanceof HTMLTextAreaElement &&\n to instanceof HTMLTextAreaElement\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n if (ignoreAttribute(\"value\", to, \"update\", ctx)) {\n return;\n }\n if (fromValue !== toValue) {\n to.value = fromValue;\n }\n if (to.firstChild && to.firstChild.nodeValue !== fromValue) {\n to.firstChild.nodeValue = fromValue;\n }\n }\n }\n\n /**\n * =============================================================================\n * The HEAD tag can be handled specially, either w/ a 'merge' or 'append' style\n * =============================================================================\n * @param {Element} newHeadTag\n * @param {Element} currentHead\n * @param {MorphContext} ctx\n * @returns {Promise<void>[]}\n */\n function handleHeadElement(newHeadTag, currentHead, ctx) {\n /**\n * @type {Node[]}\n */\n let added = [];\n /**\n * @type {Element[]}\n */\n let removed = [];\n /**\n * @type {Element[]}\n */\n let preserved = [];\n /**\n * @type {Element[]}\n */\n let nodesToAppend = [];\n\n let headMergeStyle = ctx.head.style;\n\n // put all new head elements into a Map, by their outerHTML\n let srcToNewHeadNodes = new Map();\n for (const newHeadChild of newHeadTag.children) {\n srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);\n }\n\n // for each elt in the current head\n for (const currentHeadElt of currentHead.children) {\n // If the current head element is in the map\n let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);\n let isReAppended = ctx.head.shouldReAppend(currentHeadElt);\n let isPreserved = ctx.head.shouldPreserve(currentHeadElt);\n if (inNewContent || isPreserved) {\n if (isReAppended) {\n // remove the current version and let the new version replace it and re-execute\n removed.push(currentHeadElt);\n } else {\n // this element already exists and should not be re-appended, so remove it from\n // the new content map, preserving it in the DOM\n srcToNewHeadNodes.delete(currentHeadElt.outerHTML);\n preserved.push(currentHeadElt);\n }\n } else {\n if (headMergeStyle === \"append\") {\n // we are appending and this existing element is not new content\n // so if and only if it is marked for re-append do we do anything\n if (isReAppended) {\n removed.push(currentHeadElt);\n nodesToAppend.push(currentHeadElt);\n }\n } else {\n // if this is a merge, we remove this content since it is not in the new head\n if (ctx.head.shouldRemove(currentHeadElt) !== false) {\n removed.push(currentHeadElt);\n }\n }\n }\n }\n\n // Push the remaining new head elements in the Map into the\n // nodes to append to the head tag\n nodesToAppend.push(...srcToNewHeadNodes.values());\n log(\"to append: \", nodesToAppend);\n\n let promises = [];\n for (const newNode of nodesToAppend) {\n log(\"adding: \", newNode);\n // TODO: This could theoretically be null, based on type\n let newElt = /** @type {ChildNode} */ (\n document.createRange().createContextualFragment(newNode.outerHTML)\n .firstChild\n );\n log(newElt);\n if (ctx.callbacks.beforeNodeAdded(newElt) !== false) {\n if (\n (\"href\" in newElt && newElt.href) ||\n (\"src\" in newElt && newElt.src)\n ) {\n /** @type {(result?: any) => void} */ let resolve;\n let promise = new Promise(function (_resolve) {\n resolve = _resolve;\n });\n newElt.addEventListener(\"load\", function () {\n resolve();\n });\n promises.push(promise);\n }\n currentHead.appendChild(newElt);\n ctx.callbacks.afterNodeAdded(newElt);\n added.push(newElt);\n }\n }\n\n // remove all removed elements, after we have appended the new elements to avoid\n // additional network requests for things like style sheets\n for (const removedElement of removed) {\n if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {\n currentHead.removeChild(removedElement);\n ctx.callbacks.afterNodeRemoved(removedElement);\n }\n }\n\n ctx.head.afterHeadMorphed(currentHead, {\n added: added,\n kept: preserved,\n removed: removed,\n });\n return promises;\n }\n\n //=============================================================================\n // Misc\n //=============================================================================\n\n /**\n * @param {any[]} _args\n */\n function log(..._args) {\n //console.log(args);\n }\n\n function noOp() {}\n\n /**\n * Deep merges the config object and the Idiomoroph.defaults object to\n * produce a final configuration object\n * @param {Config} config\n * @returns {ConfigInternal}\n */\n function mergeDefaults(config) {\n /**\n * @type {ConfigInternal}\n */\n let finalConfig = Object.assign({}, defaults);\n\n // copy top level stuff into final config\n Object.assign(finalConfig, config);\n\n // copy callbacks into final config (do this to deep merge the callbacks)\n finalConfig.callbacks = Object.assign(\n {},\n defaults.callbacks,\n config.callbacks,\n );\n\n // copy head config into final config (do this to deep merge the head)\n finalConfig.head = Object.assign({}, defaults.head, config.head);\n\n return finalConfig;\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} newContent\n * @param {Config} config\n * @returns {MorphContext}\n */\n function createMorphContext(oldNode, newContent, config) {\n const mergedConfig = mergeDefaults(config);\n return {\n target: oldNode,\n newContent: newContent,\n config: mergedConfig,\n morphStyle: mergedConfig.morphStyle,\n ignoreActive: mergedConfig.ignoreActive,\n ignoreActiveValue: mergedConfig.ignoreActiveValue,\n idMap: createIdMap(oldNode, newContent),\n deadIds: new Set(),\n persistentIds: mergedConfig.twoPass\n ? createPersistentIds(oldNode, newContent)\n : new Set(),\n pantry: mergedConfig.twoPass\n ? createPantry()\n : document.createElement(\"div\"),\n callbacks: mergedConfig.callbacks,\n head: mergedConfig.head,\n };\n }\n\n function createPantry() {\n const pantry = document.createElement(\"div\");\n pantry.hidden = true;\n document.body.insertAdjacentElement(\"afterend\", pantry);\n return pantry;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Node | null} node2\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: The function handles this as if it's Element or null, but the function is called in\n // places where the arguments may be just a Node, not an Element\n function isIdSetMatch(node1, node2, ctx) {\n if (node1 == null || node2 == null) {\n return false;\n }\n if (\n node1 instanceof Element &&\n node2 instanceof Element &&\n node1.tagName === node2.tagName\n ) {\n if (node1.id !== \"\" && node1.id === node2.id) {\n return true;\n } else {\n return getIdIntersectionCount(ctx, node1, node2) > 0;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {Node | null} oldNode\n * @param {Node | null} newNode\n * @returns {boolean}\n */\n function isSoftMatch(oldNode, newNode) {\n if (oldNode == null || newNode == null) {\n return false;\n }\n // ok to cast: if one is not element, `id` or `tagName` will be undefined and we'll compare that\n // If oldNode has an `id` with possible state and it doesn't match newNode.id then avoid morphing\n if (\n /** @type {Element} */ (oldNode).id &&\n /** @type {Element} */ (oldNode).id !==\n /** @type {Element} */ (newNode).id\n ) {\n return false;\n }\n return (\n oldNode.nodeType === newNode.nodeType &&\n /** @type {Element} */ (oldNode).tagName ===\n /** @type {Element} */ (newNode).tagName\n );\n }\n\n /**\n *\n * @param {Node} startInclusive\n * @param {Node} endExclusive\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function removeNodesBetween(startInclusive, endExclusive, ctx) {\n /** @type {Node | null} */ let cursor = startInclusive;\n while (cursor !== endExclusive) {\n let tempNode = /** @type {Node} */ (cursor);\n // TODO: Prefer assigning to a new variable here or expand the type of startInclusive\n // to be Node | null\n cursor = tempNode.nextSibling;\n removeNode(tempNode, ctx);\n }\n removeIdsFromConsideration(ctx, endExclusive);\n return endExclusive.nextSibling;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential id match\n * for the newChild. We stop if we find a potential id match for the new child OR\n * if the number of potential id matches we are discarding is greater than the\n * potential id matches for the new child\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findIdSetMatch(\n newContent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n ) {\n // max id matches we are willing to discard in our search\n let newChildPotentialIdCount = getIdIntersectionCount(\n ctx,\n newChild,\n oldParent,\n );\n\n /**\n * @type {Node | null}\n */\n let potentialMatch = null;\n\n // only search forward if there is a possibility of an id match\n if (newChildPotentialIdCount > 0) {\n // TODO: This is ghosting the potentialMatch variable outside of this block.\n // Probably an error\n potentialMatch = insertionPoint;\n // if there is a possibility of an id match, scan forward\n // keep track of the potential id match count we are discarding (the\n // newChildPotentialIdCount must be greater than this to make it likely\n // worth it)\n let otherMatchCount = 0;\n while (potentialMatch != null) {\n // If we have an id match, return the current potential match\n if (isIdSetMatch(newChild, potentialMatch, ctx)) {\n return potentialMatch;\n }\n\n // computer the other potential matches of this new content\n otherMatchCount += getIdIntersectionCount(\n ctx,\n potentialMatch,\n newContent,\n );\n if (otherMatchCount > newChildPotentialIdCount) {\n // if we have more potential id matches in _other_ content, we\n // do not have a good candidate for an id match, so return null\n return null;\n }\n\n // advanced to the next old content child\n potentialMatch = potentialMatch.nextSibling;\n }\n }\n return potentialMatch;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential soft match\n * for the newChild. We stop if we find a potential soft match for the new child OR\n * if we find a potential id match in the old parents children OR if we find two\n * potential soft matches for the next two pieces of new content\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findSoftMatch(newContent, oldParent, newChild, insertionPoint, ctx) {\n /**\n * @type {Node | null}\n */\n let potentialSoftMatch = insertionPoint;\n /**\n * @type {Node | null}\n */\n let nextSibling = newChild.nextSibling;\n let siblingSoftMatchCount = 0;\n\n while (potentialSoftMatch != null) {\n if (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) {\n // the current potential soft match has a potential id set match with the remaining new\n // content so bail out of looking\n return null;\n }\n\n // if we have a soft match with the current node, return it\n if (isSoftMatch(potentialSoftMatch, newChild)) {\n return potentialSoftMatch;\n }\n\n if (isSoftMatch(potentialSoftMatch, nextSibling)) {\n // the next new node has a soft match with this node, so\n // increment the count of future soft matches\n siblingSoftMatchCount++;\n // ok to cast: if it was null it couldn't be a soft match\n nextSibling = /** @type {Node} */ (nextSibling).nextSibling;\n\n // If there are two future soft matches, bail to allow the siblings to soft match\n // so that we don't consume future soft matches for the sake of the current node\n if (siblingSoftMatchCount >= 2) {\n return null;\n }\n }\n\n // advanced to the next old content child\n potentialSoftMatch = potentialSoftMatch.nextSibling;\n }\n\n return potentialSoftMatch;\n }\n\n /** @type {WeakSet<Node>} */\n const generatedByIdiomorph = new WeakSet();\n\n /**\n *\n * @param {string} newContent\n * @returns {Node | null | DocumentFragment}\n */\n function parseContent(newContent) {\n let parser = new DOMParser();\n\n // remove svgs to avoid false-positive matches on head, etc.\n let contentWithSvgsRemoved = newContent.replace(\n /<svg(\\s[^>]*>|>)([\\s\\S]*?)<\\/svg>/gim,\n \"\",\n );\n\n // if the newContent contains a html, head or body tag, we can simply parse it w/o wrapping\n if (\n contentWithSvgsRemoved.match(/<\\/html>/) ||\n contentWithSvgsRemoved.match(/<\\/head>/) ||\n contentWithSvgsRemoved.match(/<\\/body>/)\n ) {\n let content = parser.parseFromString(newContent, \"text/html\");\n // if it is a full HTML document, return the document itself as the parent container\n if (contentWithSvgsRemoved.match(/<\\/html>/)) {\n generatedByIdiomorph.add(content);\n return content;\n } else {\n // otherwise return the html element as the parent container\n let htmlElement = content.firstChild;\n if (htmlElement) {\n generatedByIdiomorph.add(htmlElement);\n return htmlElement;\n } else {\n return null;\n }\n }\n } else {\n // if it is partial HTML, wrap it in a template tag to provide a parent element and also to help\n // deal with touchy tags like tr, tbody, etc.\n let responseDoc = parser.parseFromString(\n \"<body><template>\" + newContent + \"</template></body>\",\n \"text/html\",\n );\n let content = /** @type {HTMLTemplateElement} */ (\n responseDoc.body.querySelector(\"template\")\n ).content;\n generatedByIdiomorph.add(content);\n return content;\n }\n }\n\n /**\n *\n * @param {null | Node | HTMLCollection | Node[] | Document & {generatedByIdiomorph:boolean}} newContent\n * @returns {Element}\n */\n function normalizeContent(newContent) {\n if (newContent == null) {\n // noinspection UnnecessaryLocalVariableJS\n const dummyParent = document.createElement(\"div\");\n return dummyParent;\n } else if (generatedByIdiomorph.has(/** @type {Element} */ (newContent))) {\n // the template tag created by idiomorph parsing can serve as a dummy parent\n return /** @type {Element} */ (newContent);\n } else if (newContent instanceof Node) {\n // a single node is added as a child to a dummy parent\n const dummyParent = document.createElement(\"div\");\n dummyParent.append(newContent);\n return dummyParent;\n } else {\n // all nodes in the array or HTMLElement collection are consolidated under\n // a single dummy parent element\n const dummyParent = document.createElement(\"div\");\n for (const elt of [...newContent]) {\n dummyParent.append(elt);\n }\n return dummyParent;\n }\n }\n\n /**\n *\n * @param {Node | null} previousSibling\n * @param {Node} morphedNode\n * @param {Node | null} nextSibling\n * @returns {Node[]}\n */\n function insertSiblings(previousSibling, morphedNode, nextSibling) {\n /**\n * @type {Node[]}\n */\n let stack = [];\n /**\n * @type {Node[]}\n */\n let added = [];\n while (previousSibling != null) {\n stack.push(previousSibling);\n previousSibling = previousSibling.previousSibling;\n }\n // Base the loop on the node variable, so that you do not need runtime checks for\n // undefined value inside the loop\n let node = stack.pop();\n while (node !== undefined) {\n added.push(node); // push added preceding siblings on in order and insert\n morphedNode.parentElement?.insertBefore(node, morphedNode);\n node = stack.pop();\n }\n added.push(morphedNode);\n while (nextSibling != null) {\n stack.push(nextSibling);\n added.push(nextSibling); // here we are going in order, so push on as we scan, rather than add\n nextSibling = nextSibling.nextSibling;\n }\n while (stack.length > 0) {\n const node = /** @type {Node} */ (stack.pop());\n morphedNode.parentElement?.insertBefore(node, morphedNode.nextSibling);\n }\n return added;\n }\n\n /**\n *\n * @param {Element} newContent\n * @param {Element} oldNode\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function findBestNodeMatch(newContent, oldNode, ctx) {\n /**\n * @type {Node | null}\n */\n let currentElement;\n currentElement = newContent.firstChild;\n /**\n * @type {Node | null}\n */\n let bestElement = currentElement;\n let score = 0;\n while (currentElement) {\n let newScore = scoreElement(currentElement, oldNode, ctx);\n if (newScore > score) {\n bestElement = currentElement;\n score = newScore;\n }\n currentElement = currentElement.nextSibling;\n }\n return bestElement;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Element} node2\n * @param {MorphContext} ctx\n * @returns {number}\n */\n // TODO: The function handles node1 and node2 as if they are Elements but the function is\n // called in places where node1 and node2 may be just Nodes, not Elements\n function scoreElement(node1, node2, ctx) {\n if (isSoftMatch(node2, node1)) {\n // ok to cast: isSoftMatch performs a null check\n return (\n 0.5 + getIdIntersectionCount(ctx, /** @type {Node} */ (node1), node2)\n );\n }\n return 0;\n }\n\n /**\n *\n * @param {Node} tempNode\n * @param {MorphContext} ctx\n */\n // TODO: The function handles tempNode as if it's Element but the function is called in\n // places where tempNode may be just a Node, not an Element\n function removeNode(tempNode, ctx) {\n removeIdsFromConsideration(ctx, tempNode);\n // skip remove callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n hasPersistentIdNodes(ctx, tempNode) &&\n tempNode instanceof Element\n ) {\n moveToPantry(tempNode, ctx);\n } else {\n if (ctx.callbacks.beforeNodeRemoved(tempNode) === false) return;\n tempNode.parentNode?.removeChild(tempNode);\n ctx.callbacks.afterNodeRemoved(tempNode);\n }\n }\n\n /**\n *\n * @param {Node} node\n * @param {MorphContext} ctx\n */\n function moveToPantry(node, ctx) {\n if (ctx.callbacks.beforeNodePantried(node) === false) return;\n\n Array.from(node.childNodes).forEach((child) => {\n moveToPantry(child, ctx);\n });\n\n // After processing children, process the current node\n if (ctx.persistentIds.has(/** @type {Element} */ (node).id)) {\n // @ts-ignore - use proposed moveBefore feature\n if (ctx.pantry.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n ctx.pantry.moveBefore(node, null);\n } else {\n ctx.pantry.insertBefore(node, null);\n }\n } else {\n if (ctx.callbacks.beforeNodeRemoved(node) === false) return;\n node.parentNode?.removeChild(node);\n ctx.callbacks.afterNodeRemoved(node);\n }\n }\n\n /**\n *\n * @param {Node | null} root\n * @param {MorphContext} ctx\n */\n function restoreFromPantry(root, ctx) {\n if (root instanceof Element) {\n Array.from(ctx.pantry.children)\n .reverse()\n .forEach((element) => {\n const matchElement = root.querySelector(`#${element.id}`);\n if (matchElement) {\n // @ts-ignore - use proposed moveBefore feature\n if (matchElement.parentElement?.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n matchElement.parentElement.moveBefore(element, matchElement);\n while (matchElement.hasChildNodes()) {\n // @ts-ignore - use proposed moveBefore feature\n element.moveBefore(matchElement.firstChild, null);\n }\n } else {\n matchElement.before(element);\n while (matchElement.firstChild) {\n element.insertBefore(matchElement.firstChild, null);\n }\n }\n if (\n ctx.callbacks.beforeNodeMorphed(element, matchElement) !== false\n ) {\n syncNodeFrom(matchElement, element, ctx);\n ctx.callbacks.afterNodeMorphed(element, matchElement);\n }\n matchElement.remove();\n }\n });\n ctx.pantry.remove();\n }\n }\n\n //=============================================================================\n // ID Set Functions\n //=============================================================================\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @returns {boolean}\n */\n function isIdInConsideration(ctx, id) {\n return !ctx.deadIds.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @param {Node} targetNode\n * @returns {boolean}\n */\n function idIsWithinNode(ctx, id, targetNode) {\n let idSet = ctx.idMap.get(targetNode) || EMPTY_SET;\n return idSet.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {void}\n */\n function removeIdsFromConsideration(ctx, node) {\n let idSet = ctx.idMap.get(node) || EMPTY_SET;\n for (const id of idSet) {\n ctx.deadIds.add(id);\n }\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {boolean}\n */\n function hasPersistentIdNodes(ctx, node) {\n for (const id of ctx.idMap.get(node) || EMPTY_SET) {\n if (ctx.persistentIds.has(id)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node1\n * @param {Node} node2\n * @returns {number}\n */\n function getIdIntersectionCount(ctx, node1, node2) {\n let sourceSet = ctx.idMap.get(node1) || EMPTY_SET;\n let matchCount = 0;\n for (const id of sourceSet) {\n // a potential match is an id in the source and potentialIdsSet, but\n // that has not already been merged into the DOM\n if (isIdInConsideration(ctx, id) && idIsWithinNode(ctx, id, node2)) {\n ++matchCount;\n }\n }\n return matchCount;\n }\n\n /**\n * @param {Element} content\n * @returns {Element[]}\n */\n function nodesWithIds(content) {\n let nodes = Array.from(content.querySelectorAll(\"[id]\"));\n if (content.id) {\n nodes.push(content);\n }\n return nodes;\n }\n\n /**\n * A bottom up algorithm that finds all elements with ids in the node\n * argument and populates id sets for those nodes and all their parents, generating\n * a set of ids contained within all nodes for the entire hierarchy in the DOM\n *\n * @param {Element} node\n * @param {Map<Node, Set<string>>} idMap\n */\n function populateIdMapForNode(node, idMap) {\n let nodeParent = node.parentElement;\n for (const elt of nodesWithIds(node)) {\n /**\n * @type {Element|null}\n */\n let current = elt;\n // walk up the parent hierarchy of that element, adding the id\n // of element to the parent's id set\n while (current !== nodeParent && current != null) {\n let idSet = idMap.get(current);\n // if the id set doesn't exist, create it and insert it in the map\n if (idSet == null) {\n idSet = new Set();\n idMap.set(current, idSet);\n }\n idSet.add(elt.id);\n current = current.parentElement;\n }\n }\n }\n\n /**\n * This function computes a map of nodes to all ids contained within that node (inclusive of the\n * node). This map can be used to ask if two nodes have intersecting sets of ids, which allows\n * for a looser definition of \"matching\" than tradition id matching, and allows child nodes\n * to contribute to a parent nodes matching.\n *\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Map<Node, Set<string>>} a map of nodes to id sets for the\n */\n function createIdMap(oldContent, newContent) {\n /**\n *\n * @type {Map<Node, Set<string>>}\n */\n let idMap = new Map();\n populateIdMapForNode(oldContent, idMap);\n populateIdMapForNode(newContent, idMap);\n return idMap;\n }\n\n /**\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Set<string>} the id set of all persistent nodes that exist in both old and new content\n */\n function createPersistentIds(oldContent, newContent) {\n const toIdTagName = (node) => node.tagName + \"#\" + node.id;\n const oldIdSet = new Set(nodesWithIds(oldContent).map(toIdTagName));\n\n let matchIdSet = new Set();\n for (const newNode of nodesWithIds(newContent)) {\n if (oldIdSet.has(toIdTagName(newNode))) {\n matchIdSet.add(newNode.id);\n }\n }\n return matchIdSet;\n }\n\n //=============================================================================\n // This is what ends up becoming the Idiomorph global object\n //=============================================================================\n return {\n morph,\n defaults,\n };\n})();\n\nexport {Idiomorph};\n","\nconst topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n","import { safe, rAF, g } from './utils'\nimport { Idiomorph } from 'idiomorph/dist/idiomorph.esm'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport const Component = ({ name, module, dependencies, node, templates, signal }) => {\n\n\tconst _model \t\t= module.model || {}\n\tconst initialState \t= (new Function( `return ${node.getAttribute('html-model') || '{}'}`))()\n\tconst tplid \t\t= node.getAttribute('tplid')\n\tconst scopeid \t\t= node.getAttribute('html-scope-id')\n\tconst tpl \t\t\t= templates[ tplid ]\n\tconst data \t\t\t= g.scope[ scopeid ]\n\tconst model \t\t= module?.model?.apply ? _model({ elm:node, initialState }) : _model\n\tconst state \t\t= Object.assign({}, data, model, initialState)\n\tconst view \t\t\t= module.view? module.view : (data) => data\n\n\tlet updates \t\t= []\n\n\tconst base = {\n\t\tname,\n\t\tmodel,\n\t\telm: node,\n\t\ttemplate: tpl.template,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\tnode.addEventListener(':mount', fn)\n\t\t},\n\n\t\t/**\n\t\t * @State\n\t\t */\n\t\tstate : {\n\n\t\t\tsave(data) {\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata( state )\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tset( data ) {\n\n\t\t\t\tif (!document.body.contains(node)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata(state)\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\n\t\t\t\tconst newstate = Object.assign({}, state)\n\n\t\t\t\tupdates.push(data)\n\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\trAF(() => {\n\t\t\t\t\t\tObject.assign.apply(null, [newstate, ...updates ])\n\t\t\t\t\t\tif( updates.length ){\n\t\t\t\t\t\t\trender(newstate)\n\t\t\t\t\t\t\tresolve(newstate)\n\t\t\t\t\t\t\tupdates = []\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t},\n\n\t\t\tget() {\n\t\t\t\treturn Object.assign({}, state)\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * @Events\n\t\t */\n\t\ton( ev, selectorOrCallback, callback ) {\n\n\t\t\tif( callback ) {\n\t\t\t\tcallback.handler = (e) => {\n\t\t\t\t\tconst detail = e.detail || {}\n\t\t\t\t\tlet parent = e.target\n\t\t\t\t\twhile (parent) {\n\t\t\t\t\t\tif (parent.matches(selectorOrCallback)) {\n\t\t\t\t\t\t\te.delegateTarget = parent\n\t\t\t\t\t\t\tcallback.apply(node, [e].concat(detail.args))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parent === node) break\n\t\t\t\t\t\tparent = parent.parentNode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, callback.handler, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tcapture: (ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave')\n\t\t\t\t})\n\n\t\t\t} else {\n\t\t\t\tselectorOrCallback.handler = (e) => {\n\t\t\t\t\te.delegateTarget = node\n\t\t\t\t\tselectorOrCallback.apply(node, [e].concat(e.detail.args))\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, selectorOrCallback.handler, { signal })\n\t\t\t}\n\t\t},\n\n\t\toff( ev, callback ) {\n\t\t\tif( callback.handler ) {\n\t\t\t\tnode.removeEventListener(ev, callback.handler)\n\t\t\t}\n\t\t},\n\n\t\ttrigger(ev, selectorOrCallback, data) {\n\t\t\tif( selectorOrCallback.constructor === String ) {\n\t\t\t\tArray\n\t\t\t\t\t.from(node.querySelectorAll(selectorOrCallback))\n\t\t\t\t\t.forEach( children => {\n\t\t\t\t\t\tchildren.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }) )\n\t\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail:{ args: data } }))\n\t\t\t}\n\t\t},\n\n\t\temit(ev, data) {\n\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }))\n\t\t},\n\n\t\tunmount( fn ) {\n\t\t\tnode.addEventListener(':unmount', fn)\n\t\t},\n\n\t\tinnerHTML ( target, html_ ) {\n\t\t\tconst element = html_? target : elm\n\t\t\tconst clone = element.cloneNode()\n\t\t\tconst html = html_? html_ : target\n\t\t\tclone.innerHTML = html\n\n\t\t\trAF( _ => Idiomorph.morph(element, clone, IdiomorphOptions) )\n\t\t}\n\t}\n\n\tconst render = ( data ) => {\n\n\t\tconst html = tpl.render.call( view(data), node, safe, g )\n\t\tIdiomorph.morph( node, html, IdiomorphOptions(node) )\n\n\t\trAF(() => {\n\t\t\tnode.querySelectorAll('[tplid]')\n\t\t\t.forEach((element) => {\n\t\t\t\tif(!element.base) return\n\t\t\t\tconst base = element.base\n\t\t\t\tconst props = Object.keys(base.model).reduce((acc, key) => {\n\t\t\t\t\tif( key in data ) {\n\t\t\t\t\t\tif( !acc ) acc = {}\n\t\t\t\t\t\tacc[key] = data[key]\n\t\t\t\t\t}\n\t\t\t\t\treturn acc\n\t\t\t\t}, null)\n\t\t\t\tif( props ) {\n\t\t\t\t\tbase.state.set( props )\n\t\t\t\t}\n\t\t\t})\n\t\t\trAF(() => g.scope = {})\n\t\t})\n\n\t}\n\n\tnode.base = base\n\treturn module.default( base )\n}\n\nconst IdiomorphOptions = ( parent ) => ({\n\tcallbacks: {\n\t\tbeforeNodeMorphed( node ) {\n\t\t\tif( node.nodeType === 1 ) {\n\t\t\t\tif( 'html-static' in node.attributes ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif( node.base && node !== parent ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n","import { Component } from './component'\n\nexport const Element = ({ component, templates, start }) => {\n\n\tconst { name, module, dependencies } = component\n\tconst abortController = new AbortController()\n\n\treturn class extends HTMLElement {\n\n\t\tconstructor() {\n\t\t\tsuper()\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tif( !this.getAttribute('tplid') ) {\n\t\t\t\tstart( this.parentNode )\n\t\t\t}\n\n\t\t\tconst rtrn = Component({\n\t\t\t\tnode:this,\n\t\t\t\tname,\n\t\t\t\tmodule,\n\t\t\t\tdependencies,\n\t\t\t\ttemplates,\n\t\t\t\tsignal: abortController.signal\n\t\t\t})\n\n\t\t\tif ( rtrn && rtrn.constructor === Promise ) {\n\t\t\t\trtrn.then(() => this.dispatchEvent( new CustomEvent(':mount') ))\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t}\n\n\t\t\tthis.base.state.set({})\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.dispatchEvent( new CustomEvent(':unmount') )\n\t\t\tabortController.abort()\n\t\t\tdelete this.base\n\t\t}\n\t}\n}\n","import { uuid } from './utils'\n\nconst templates = {}\n\nconst config = {\n\ttags: ['{{', '}}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign( config, newconfig )\n}\n\nexport const template = ( target, { components }) => {\n\n\ttagElements( target, [...Object.keys( components ), 'template'] )\n\tconst clone = target.cloneNode( true )\n\n\ttransformTemplate( clone )\n\tremoveTemplateTagsRecursively( clone )\n\tsetTemplates( clone, components )\n\n\treturn templates\n}\n\nexport const compile = ( outerHTML ) => {\n\n\tconst html = transformAttributes( outerHTML )\n\tconst parsedHtml = JSON.stringify( html )\n\n\treturn new Function('$element', 'safe', '$g',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${parsedHtml\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+ variable +';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + variable +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nconst tagElements = ( target, keys ) => {\n\ttarget\n\t\t.querySelectorAll( keys.toString() )\n\t\t.forEach((node) => {\n\t\t\tif( node.localName === 'template' ) {\n\t\t\t\treturn tagElements( node.content, keys )\n\t\t\t}\n\t\t\tnode.setAttribute('tplid', uuid())\n\t\t})\n}\n\nconst transformAttributes = ( html ) => {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\n\treturn html\n\t\t.replace(/jails___scope-id/g, '%%_=$scopeid_%%')\n\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t// Booleans\n\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t// The rest\n\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\tif (key === 'key' || key === 'model' || key === 'scope-id' ) {\n\t\t\t\treturn all\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t} else {\n\t\t\t\treturn all\n\t\t\t}\n\t\t})\n}\n\nconst transformTemplate = ( clone ) => {\n\n\tclone.querySelectorAll('template, [html-for], [html-if], [html-inner], [html-class]')\n\t\t.forEach(( element ) => {\n\n\t\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\t\tconst htmlClass = element.getAttribute('html-class')\n\n\t\t\tif ( htmlFor ) {\n\n\t\t\t\telement.removeAttribute('html-for')\n\n\t\t\t\tconst split \t= htmlFor.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\t\tconst varname \t= split[1]\n\t\t\t\tconst object \t= split[2]\n\t\t\t\tconst open \t\t= document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = { ${varname} :${varname}, ${object}: ${object}, $index: $index, $key: $key }; _%%`)\n\t\t\t\tconst close \t= document.createTextNode(`%%_ $index++; } })() _%%`)\n\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlIf) {\n\t\t\t\telement.removeAttribute('html-if')\n\t\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlInner) {\n\t\t\t\telement.removeAttribute('html-inner')\n\t\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t\t}\n\n\t\t\tif (htmlClass) {\n\t\t\t\telement.removeAttribute('html-class')\n\t\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t\t}\n\n\t\t\tif( element.localName === 'template' ) {\n\t\t\t\ttransformTemplate(element.content)\n\t\t\t}\n\t\t})\n}\n\nconst setTemplates = ( clone, components ) => {\n\n\tArray.from(clone.querySelectorAll('[tplid]'))\n\t\t.reverse()\n\t\t.forEach((node) => {\n\n\t\t\tconst tplid = node.getAttribute('tplid')\n\t\t\tconst name = node.localName\n\t\t\tnode.setAttribute('html-scope-id', 'jails___scope-id')\n\n\t\t\tif( name in components && components[name].module.template ) {\n\t\t\t\tconst children = node.innerHTML\n\t\t\t\tconst html = components[name].module.template({ elm:node, children })\n\n\t\t\t\tif( html.constructor === Promise ) {\n\t\t\t\t\thtml.then( htmlstring => {\n\t\t\t\t\t\tnode.innerHTML = htmlstring\n\t\t\t\t\t\tconst html = node.outerHTML\n\t\t\t\t\t\ttemplates[tplid] = {\n\t\t\t\t\t\t\ttemplate: html,\n\t\t\t\t\t\t\trender: compile(html)\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tnode.innerHTML = html\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst html = node.outerHTML\n\n\t\t\ttemplates[ tplid ] = {\n\t\t\t\ttemplate: html,\n\t\t\t\trender\t: compile(html)\n\t\t\t}\n\t\t})\n}\n\nconst removeTemplateTagsRecursively = (node) => {\n\n\t// Get all <template> elements within the node\n\tconst templates = node.querySelectorAll('template')\n\n\ttemplates.forEach((template) => {\n\n\t\tif( template.getAttribute('html-if') || template.getAttribute('html-inner') ) {\n\t\t\treturn\n\t\t}\n\n\t\t// Process any nested <template> tags within this <template> first\n\t\tremoveTemplateTagsRecursively(template.content)\n\n\t\t// Get the parent of the <template> tag\n\t\tconst parent = template.parentNode\n\n\t\tif (parent) {\n\t\t\t// Move all child nodes from the <template>'s content to its parent\n\t\t\tconst content = template.content\n\t\t\twhile (content.firstChild) {\n\t\t\t\tparent.insertBefore(content.firstChild, template)\n\t\t\t}\n\t\t\t// Remove the <template> tag itself\n\t\t\tparent.removeChild(template)\n\t\t}\n\t})\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","import { Element } from './element'\nimport { template, templateConfig as config } from './template-system'\n\nconst components = {}\n\nexport { publish, subscribe } from './utils/pubsub'\n\nexport const templateConfig = (options) => {\n\tconfig( options )\n}\n\nexport const register = ( name, module, dependencies ) => {\n\tcomponents[ name ] = { name, module, dependencies }\n}\n\nexport const start = ( target = document.body ) => {\n\n\tconst templates = template( target, { components } )\n\n\tObject\n\t\t.values( components )\n\t\t.forEach(({ name, module, dependencies }) => {\n\t\t\tif( !customElements.get(name) ) {\n\t\t\t\tcustomElements.define( name, Element({ component: { name, module, dependencies }, templates, start }) )\n\t\t\t}\n\t})\n}\n"],"names":["config","node","templates","data","base","Element","start","templateConfig","components","html","template"],"mappings":"AACO,MAAM,IAAI;AAAA,EAChB,OAAO,CAAA;AACR;AAEa,MAAA,MAAM,CAAC,OAAO;AACtB,MAAA;AACH,WAAO,sBAAsB,EAAE;AAAA;AAExB,WAAA,WAAW,IAAI,MAAO,EAAE;AACj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ACzB,aAAO,QAAQ,YAAY;AACnB,eAAA,aAAa,QAAQ,YAAYA,SAAQ;AAAA,MAAA;AAGjD,aAAO,YAAYA,SAAQ;AAAA,IAAA;AAAA,EAC5B,CACA;AACF;AAEA,MAAM,OAAO,CAAC,MAAM,MAAM,UAAU;AL7L7B;AK8LD,aAAA,eAAA,mBAAY,aAAa,MAAM;AACpC,aAAK,eAAL,mBAAiB,aAAa,OAAO,KAAK;AAC3C;AC9LA,MAAM,aAAa,CAAC;AAIP,MAAA,iBAAiB,CAAC,YAAY;AAC1CV,mBAAQ,OAAQ;AACjB;AAEO,MAAM,WAAW,CAAE,MAAM,QAAQ,iBAAkB;AACzD,aAAY,IAAK,IAAI,EAAE,MAAM,QAAQ,aAAa;AACnD;AAEO,MAAM,QAAQ,CAAE,SAAS,SAAS,SAAU;AAElD,QAAME,aAAY,SAAU,QAAQ,EAAE,YAAa;AAGjD,SAAA,OAAQ,UAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,QAAQ,mBAAmB;AAC5C,QAAI,CAAC,eAAe,IAAI,IAAI,GAAI;AAC/B,qBAAe,OAAQ,MAAMG,UAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,aAAa,GAAG,WAAAH,YAAW,MAAO,CAAA,CAAE;AAAA,IAAA;AAAA,EACvG,CACD;AACF;","x_google_ignoreList":[1]}
1
+ {"version":3,"file":"index.js","sources":["../src/utils/index.ts","../node_modules/idiomorph/dist/idiomorph.esm.js","../src/utils/pubsub.ts","../src/component.ts","../src/element.ts","../src/template-system.ts","../src/index.ts"],"sourcesContent":["\nexport const g = {\n\tscope: {}\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn Math.random().toString(36).substring(2, 9)\n}\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\nexport const safe = (execute, val) => {\n\ttry{\n\t\treturn execute()\n\t}catch(err){\n\t\treturn val || ''\n\t}\n}\n","/**\n * @typedef {object} ConfigHead\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} [style]\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {function(Element): boolean} [shouldPreserve]\n * @property {function(Element): boolean} [shouldReAppend]\n * @property {function(Element): boolean} [shouldRemove]\n * @property {function(Element, {added: Node[], kept: Element[], removed: Element[]}): void} [afterHeadMorphed]\n */\n\n/**\n * @typedef {object} ConfigCallbacks\n *\n * @property {function(Node): boolean} [beforeNodeAdded]\n * @property {function(Node): void} [afterNodeAdded]\n * @property {function(Element, Node): boolean} [beforeNodeMorphed]\n * @property {function(Element, Node): void} [afterNodeMorphed]\n * @property {function(Element): boolean} [beforeNodeRemoved]\n * @property {function(Element): void} [afterNodeRemoved]\n * @property {function(string, Element, \"update\" | \"remove\"): boolean} [beforeAttributeUpdated]\n * @property {function(Element): boolean} [beforeNodePantried]\n */\n\n/**\n * @typedef {object} Config\n *\n * @property {'outerHTML' | 'innerHTML'} [morphStyle]\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacks} [callbacks]\n * @property {ConfigHead} [head]\n */\n\n/**\n * @typedef {function} NoOp\n *\n * @returns {void}\n */\n\n/**\n * @typedef {object} ConfigHeadInternal\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} style\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {(function(Element): boolean) | NoOp} shouldPreserve\n * @property {(function(Element): boolean) | NoOp} shouldReAppend\n * @property {(function(Element): boolean) | NoOp} shouldRemove\n * @property {(function(Element, {added: Node[], kept: Element[], removed: Element[]}): void) | NoOp} afterHeadMorphed\n */\n\n/**\n * @typedef {object} ConfigCallbacksInternal\n *\n * @property {(function(Node): boolean) | NoOp} beforeNodeAdded\n * @property {(function(Node): void) | NoOp} afterNodeAdded\n * @property {(function(Node, Node): boolean) | NoOp} beforeNodeMorphed\n * @property {(function(Node, Node): void) | NoOp} afterNodeMorphed\n * @property {(function(Node): boolean) | NoOp} beforeNodeRemoved\n * @property {(function(Node): void) | NoOp} afterNodeRemoved\n * @property {(function(string, Element, \"update\" | \"remove\"): boolean) | NoOp} beforeAttributeUpdated\n * @property {(function(Node): boolean) | NoOp} beforeNodePantried\n */\n\n/**\n * @typedef {object} ConfigInternal\n *\n * @property {'outerHTML' | 'innerHTML'} morphStyle\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacksInternal} callbacks\n * @property {ConfigHeadInternal} head\n * @property {boolean} [twoPass]\n */\n\n/**\n * @typedef {Function} Morph\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n\n// base IIFE to define idiomorph\n/**\n *\n * @type {{defaults: ConfigInternal, morph: Morph}}\n */\nvar Idiomorph = (function () {\n \"use strict\";\n\n /**\n * @typedef {object} MorphContext\n *\n * @property {Node} target\n * @property {Node} newContent\n * @property {ConfigInternal} config\n * @property {ConfigInternal['morphStyle']} morphStyle\n * @property {ConfigInternal['ignoreActive']} ignoreActive\n * @property {ConfigInternal['ignoreActiveValue']} ignoreActiveValue\n * @property {Map<Node, Set<string>>} idMap\n * @property {Set<string>} persistentIds\n * @property {Set<string>} deadIds\n * @property {ConfigInternal['callbacks']} callbacks\n * @property {ConfigInternal['head']} head\n * @property {HTMLDivElement} pantry\n */\n\n //=============================================================================\n // AND NOW IT BEGINS...\n //=============================================================================\n\n /**\n *\n * @type {Set<string>}\n */\n let EMPTY_SET = new Set();\n\n /**\n * Default configuration values, updatable by users now\n * @type {ConfigInternal}\n */\n let defaults = {\n morphStyle: \"outerHTML\",\n callbacks: {\n beforeNodeAdded: noOp,\n afterNodeAdded: noOp,\n beforeNodeMorphed: noOp,\n afterNodeMorphed: noOp,\n beforeNodeRemoved: noOp,\n afterNodeRemoved: noOp,\n beforeAttributeUpdated: noOp,\n beforeNodePantried: noOp,\n },\n head: {\n style: \"merge\",\n shouldPreserve: function (elt) {\n return elt.getAttribute(\"im-preserve\") === \"true\";\n },\n shouldReAppend: function (elt) {\n return elt.getAttribute(\"im-re-append\") === \"true\";\n },\n shouldRemove: noOp,\n afterHeadMorphed: noOp,\n },\n };\n\n /**\n * =============================================================================\n * Core Morphing Algorithm - morph, morphNormalizedContent, morphOldNodeTo, morphChildren\n * =============================================================================\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n function morph(oldNode, newContent, config = {}) {\n if (oldNode instanceof Document) {\n oldNode = oldNode.documentElement;\n }\n\n if (typeof newContent === \"string\") {\n newContent = parseContent(newContent);\n }\n\n let normalizedContent = normalizeContent(newContent);\n\n let ctx = createMorphContext(oldNode, normalizedContent, config);\n\n return morphNormalizedContent(oldNode, normalizedContent, ctx);\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} normalizedNewContent\n * @param {MorphContext} ctx\n * @returns {undefined | Node[]}\n */\n function morphNormalizedContent(oldNode, normalizedNewContent, ctx) {\n if (ctx.head.block) {\n let oldHead = oldNode.querySelector(\"head\");\n let newHead = normalizedNewContent.querySelector(\"head\");\n if (oldHead && newHead) {\n let promises = handleHeadElement(newHead, oldHead, ctx);\n // when head promises resolve, call morph again, ignoring the head tag\n Promise.all(promises).then(function () {\n morphNormalizedContent(\n oldNode,\n normalizedNewContent,\n Object.assign(ctx, {\n head: {\n block: false,\n ignore: true,\n },\n }),\n );\n });\n return;\n }\n }\n\n if (ctx.morphStyle === \"innerHTML\") {\n // innerHTML, so we are only updating the children\n morphChildren(normalizedNewContent, oldNode, ctx);\n if (ctx.config.twoPass) {\n restoreFromPantry(oldNode, ctx);\n }\n return Array.from(oldNode.children);\n } else if (ctx.morphStyle === \"outerHTML\" || ctx.morphStyle == null) {\n // otherwise find the best element match in the new content, morph that, and merge its siblings\n // into either side of the best match\n let bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);\n\n // stash the siblings that will need to be inserted on either side of the best match\n let previousSibling = bestMatch?.previousSibling ?? null;\n let nextSibling = bestMatch?.nextSibling ?? null;\n\n // morph it\n let morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);\n\n if (bestMatch) {\n // if there was a best match, merge the siblings in too and return the\n // whole bunch\n if (morphedNode) {\n const elements = insertSiblings(\n previousSibling,\n morphedNode,\n nextSibling,\n );\n if (ctx.config.twoPass) {\n restoreFromPantry(morphedNode.parentNode, ctx);\n }\n return elements;\n }\n } else {\n // otherwise nothing was added to the DOM\n return [];\n }\n } else {\n throw \"Do not understand how to morph style \" + ctx.morphStyle;\n }\n }\n\n /**\n * @param {Node} possibleActiveElement\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: ignoreActive and ignoreActiveValue are marked as optional since they are not\n // initialised in the default config object. As a result the && in the function body may\n // return undefined instead of boolean. Either expand the type of the return value to\n // include undefined or wrap the ctx.ignoreActiveValue into a Boolean()\n function ignoreValueOfActiveElement(possibleActiveElement, ctx) {\n return (\n !!ctx.ignoreActiveValue &&\n possibleActiveElement === document.activeElement &&\n possibleActiveElement !== document.body\n );\n }\n\n /**\n * @param {Node} oldNode root node to merge content into\n * @param {Node | null} newContent new content to merge\n * @param {MorphContext} ctx the merge context\n * @returns {Node | null} the element that ended up in the DOM\n */\n function morphOldNodeTo(oldNode, newContent, ctx) {\n if (ctx.ignoreActive && oldNode === document.activeElement) {\n // don't morph focused element\n } else if (newContent == null) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n\n oldNode.parentNode?.removeChild(oldNode);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return null;\n } else if (!isSoftMatch(oldNode, newContent)) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n if (ctx.callbacks.beforeNodeAdded(newContent) === false) return oldNode;\n\n oldNode.parentNode?.replaceChild(newContent, oldNode);\n ctx.callbacks.afterNodeAdded(newContent);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return newContent;\n } else {\n if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false)\n return oldNode;\n\n if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) {\n // ignore the head element\n } else if (\n oldNode instanceof HTMLHeadElement &&\n ctx.head.style !== \"morph\"\n ) {\n // ok to cast: if newContent wasn't also a <head>, it would've got caught in the `!isSoftMatch` branch above\n handleHeadElement(\n /** @type {HTMLHeadElement} */ (newContent),\n oldNode,\n ctx,\n );\n } else {\n syncNodeFrom(newContent, oldNode, ctx);\n if (!ignoreValueOfActiveElement(oldNode, ctx)) {\n morphChildren(newContent, oldNode, ctx);\n }\n }\n ctx.callbacks.afterNodeMorphed(oldNode, newContent);\n return oldNode;\n }\n return null;\n }\n\n /**\n * This is the core algorithm for matching up children. The idea is to use id sets to try to match up\n * nodes as faithfully as possible. We greedily match, which allows us to keep the algorithm fast, but\n * by using id sets, we are able to better match up with content deeper in the DOM.\n *\n * Basic algorithm is, for each node in the new content:\n *\n * - if we have reached the end of the old parent, append the new content\n * - if the new content has an id set match with the current insertion point, morph\n * - search for an id set match\n * - if id set match found, morph\n * - otherwise search for a \"soft\" match\n * - if a soft match is found, morph\n * - otherwise, prepend the new node before the current insertion point\n *\n * The two search algorithms terminate if competing node matches appear to outweigh what can be achieved\n * with the current node. See findIdSetMatch() and findSoftMatch() for details.\n *\n * @param {Node} newParent the parent element of the new content\n * @param {Node} oldParent the old content that we are merging the new content into\n * @param {MorphContext} ctx the merge context\n * @returns {void}\n */\n function morphChildren(newParent, oldParent, ctx) {\n if (\n newParent instanceof HTMLTemplateElement &&\n oldParent instanceof HTMLTemplateElement\n ) {\n newParent = newParent.content;\n oldParent = oldParent.content;\n }\n\n /**\n *\n * @type {Node | null}\n */\n let nextNewChild = newParent.firstChild;\n /**\n *\n * @type {Node | null}\n */\n let insertionPoint = oldParent.firstChild;\n let newChild;\n\n // run through all the new content\n while (nextNewChild) {\n newChild = nextNewChild;\n nextNewChild = newChild.nextSibling;\n\n // if we are at the end of the exiting parent's children, just append\n if (insertionPoint == null) {\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.appendChild(newChild);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.appendChild(newChild);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // if the current node has an id set match then morph\n if (isIdSetMatch(newChild, insertionPoint, ctx)) {\n morphOldNodeTo(insertionPoint, newChild, ctx);\n insertionPoint = insertionPoint.nextSibling;\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // otherwise search forward in the existing old children for an id set match\n let idSetMatch = findIdSetMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a potential match, remove the nodes until that point and morph\n if (idSetMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, idSetMatch, ctx);\n morphOldNodeTo(idSetMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // no id set match found, so scan forward for a soft match for the current node\n let softMatch = findSoftMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a soft match for the current node, morph\n if (softMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, softMatch, ctx);\n morphOldNodeTo(softMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // abandon all hope of morphing, just insert the new child before the insertion point\n // and move on\n\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.insertBefore(newChild, insertionPoint);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.insertBefore(newChild, insertionPoint);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n }\n\n // remove any remaining old nodes that didn't match up with new content\n while (insertionPoint !== null) {\n let tempNode = insertionPoint;\n insertionPoint = insertionPoint.nextSibling;\n removeNode(tempNode, ctx);\n }\n }\n\n //=============================================================================\n // Attribute Syncing Code\n //=============================================================================\n\n /**\n * @param {string} attr the attribute to be mutated\n * @param {Element} to the element that is going to be updated\n * @param {\"update\" | \"remove\"} updateType\n * @param {MorphContext} ctx the merge context\n * @returns {boolean} true if the attribute should be ignored, false otherwise\n */\n function ignoreAttribute(attr, to, updateType, ctx) {\n if (\n attr === \"value\" &&\n ctx.ignoreActiveValue &&\n to === document.activeElement\n ) {\n return true;\n }\n return ctx.callbacks.beforeAttributeUpdated(attr, to, updateType) === false;\n }\n\n /**\n * syncs a given node with another node, copying over all attributes and\n * inner element state from the 'from' node to the 'to' node\n *\n * @param {Node} from the element to copy attributes & state from\n * @param {Node} to the element to copy attributes & state to\n * @param {MorphContext} ctx the merge context\n */\n function syncNodeFrom(from, to, ctx) {\n let type = from.nodeType;\n\n // if is an element type, sync the attributes from the\n // new node into the new node\n if (type === 1 /* element type */) {\n const fromEl = /** @type {Element} */ (from);\n const toEl = /** @type {Element} */ (to);\n const fromAttributes = fromEl.attributes;\n const toAttributes = toEl.attributes;\n for (const fromAttribute of fromAttributes) {\n if (ignoreAttribute(fromAttribute.name, toEl, \"update\", ctx)) {\n continue;\n }\n if (toEl.getAttribute(fromAttribute.name) !== fromAttribute.value) {\n toEl.setAttribute(fromAttribute.name, fromAttribute.value);\n }\n }\n // iterate backwards to avoid skipping over items when a delete occurs\n for (let i = toAttributes.length - 1; 0 <= i; i--) {\n const toAttribute = toAttributes[i];\n\n // toAttributes is a live NamedNodeMap, so iteration+mutation is unsafe\n // e.g. custom element attribute callbacks can remove other attributes\n if (!toAttribute) continue;\n\n if (!fromEl.hasAttribute(toAttribute.name)) {\n if (ignoreAttribute(toAttribute.name, toEl, \"remove\", ctx)) {\n continue;\n }\n toEl.removeAttribute(toAttribute.name);\n }\n }\n }\n\n // sync text nodes\n if (type === 8 /* comment */ || type === 3 /* text */) {\n if (to.nodeValue !== from.nodeValue) {\n to.nodeValue = from.nodeValue;\n }\n }\n\n if (!ignoreValueOfActiveElement(to, ctx)) {\n // sync input values\n syncInputValue(from, to, ctx);\n }\n }\n\n /**\n * @param {Element} from element to sync the value from\n * @param {Element} to element to sync the value to\n * @param {string} attributeName the attribute name\n * @param {MorphContext} ctx the merge context\n */\n function syncBooleanAttribute(from, to, attributeName, ctx) {\n // TODO: prefer set/getAttribute here\n if (!(from instanceof Element && to instanceof Element)) return;\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n const fromLiveValue = from[attributeName],\n toLiveValue = to[attributeName];\n if (fromLiveValue !== toLiveValue) {\n let ignoreUpdate = ignoreAttribute(attributeName, to, \"update\", ctx);\n if (!ignoreUpdate) {\n // update attribute's associated DOM property\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n to[attributeName] = from[attributeName];\n }\n if (fromLiveValue) {\n if (!ignoreUpdate) {\n // TODO: do we really want this? tests say so but it feels wrong\n to.setAttribute(attributeName, fromLiveValue);\n }\n } else {\n if (!ignoreAttribute(attributeName, to, \"remove\", ctx)) {\n to.removeAttribute(attributeName);\n }\n }\n }\n }\n\n /**\n * NB: many bothans died to bring us information:\n *\n * https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js\n * https://github.com/choojs/nanomorph/blob/master/lib/morph.jsL113\n *\n * @param {Node} from the element to sync the input value from\n * @param {Node} to the element to sync the input value to\n * @param {MorphContext} ctx the merge context\n */\n function syncInputValue(from, to, ctx) {\n if (\n from instanceof HTMLInputElement &&\n to instanceof HTMLInputElement &&\n from.type !== \"file\"\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n\n // sync boolean attributes\n syncBooleanAttribute(from, to, \"checked\", ctx);\n syncBooleanAttribute(from, to, \"disabled\", ctx);\n\n if (!from.hasAttribute(\"value\")) {\n if (!ignoreAttribute(\"value\", to, \"remove\", ctx)) {\n to.value = \"\";\n to.removeAttribute(\"value\");\n }\n } else if (fromValue !== toValue) {\n if (!ignoreAttribute(\"value\", to, \"update\", ctx)) {\n to.setAttribute(\"value\", fromValue);\n to.value = fromValue;\n }\n }\n // TODO: QUESTION(1cg): this used to only check `from` unlike the other branches -- why?\n // did I break something?\n } else if (\n from instanceof HTMLOptionElement &&\n to instanceof HTMLOptionElement\n ) {\n syncBooleanAttribute(from, to, \"selected\", ctx);\n } else if (\n from instanceof HTMLTextAreaElement &&\n to instanceof HTMLTextAreaElement\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n if (ignoreAttribute(\"value\", to, \"update\", ctx)) {\n return;\n }\n if (fromValue !== toValue) {\n to.value = fromValue;\n }\n if (to.firstChild && to.firstChild.nodeValue !== fromValue) {\n to.firstChild.nodeValue = fromValue;\n }\n }\n }\n\n /**\n * =============================================================================\n * The HEAD tag can be handled specially, either w/ a 'merge' or 'append' style\n * =============================================================================\n * @param {Element} newHeadTag\n * @param {Element} currentHead\n * @param {MorphContext} ctx\n * @returns {Promise<void>[]}\n */\n function handleHeadElement(newHeadTag, currentHead, ctx) {\n /**\n * @type {Node[]}\n */\n let added = [];\n /**\n * @type {Element[]}\n */\n let removed = [];\n /**\n * @type {Element[]}\n */\n let preserved = [];\n /**\n * @type {Element[]}\n */\n let nodesToAppend = [];\n\n let headMergeStyle = ctx.head.style;\n\n // put all new head elements into a Map, by their outerHTML\n let srcToNewHeadNodes = new Map();\n for (const newHeadChild of newHeadTag.children) {\n srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);\n }\n\n // for each elt in the current head\n for (const currentHeadElt of currentHead.children) {\n // If the current head element is in the map\n let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);\n let isReAppended = ctx.head.shouldReAppend(currentHeadElt);\n let isPreserved = ctx.head.shouldPreserve(currentHeadElt);\n if (inNewContent || isPreserved) {\n if (isReAppended) {\n // remove the current version and let the new version replace it and re-execute\n removed.push(currentHeadElt);\n } else {\n // this element already exists and should not be re-appended, so remove it from\n // the new content map, preserving it in the DOM\n srcToNewHeadNodes.delete(currentHeadElt.outerHTML);\n preserved.push(currentHeadElt);\n }\n } else {\n if (headMergeStyle === \"append\") {\n // we are appending and this existing element is not new content\n // so if and only if it is marked for re-append do we do anything\n if (isReAppended) {\n removed.push(currentHeadElt);\n nodesToAppend.push(currentHeadElt);\n }\n } else {\n // if this is a merge, we remove this content since it is not in the new head\n if (ctx.head.shouldRemove(currentHeadElt) !== false) {\n removed.push(currentHeadElt);\n }\n }\n }\n }\n\n // Push the remaining new head elements in the Map into the\n // nodes to append to the head tag\n nodesToAppend.push(...srcToNewHeadNodes.values());\n log(\"to append: \", nodesToAppend);\n\n let promises = [];\n for (const newNode of nodesToAppend) {\n log(\"adding: \", newNode);\n // TODO: This could theoretically be null, based on type\n let newElt = /** @type {ChildNode} */ (\n document.createRange().createContextualFragment(newNode.outerHTML)\n .firstChild\n );\n log(newElt);\n if (ctx.callbacks.beforeNodeAdded(newElt) !== false) {\n if (\n (\"href\" in newElt && newElt.href) ||\n (\"src\" in newElt && newElt.src)\n ) {\n /** @type {(result?: any) => void} */ let resolve;\n let promise = new Promise(function (_resolve) {\n resolve = _resolve;\n });\n newElt.addEventListener(\"load\", function () {\n resolve();\n });\n promises.push(promise);\n }\n currentHead.appendChild(newElt);\n ctx.callbacks.afterNodeAdded(newElt);\n added.push(newElt);\n }\n }\n\n // remove all removed elements, after we have appended the new elements to avoid\n // additional network requests for things like style sheets\n for (const removedElement of removed) {\n if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {\n currentHead.removeChild(removedElement);\n ctx.callbacks.afterNodeRemoved(removedElement);\n }\n }\n\n ctx.head.afterHeadMorphed(currentHead, {\n added: added,\n kept: preserved,\n removed: removed,\n });\n return promises;\n }\n\n //=============================================================================\n // Misc\n //=============================================================================\n\n /**\n * @param {any[]} _args\n */\n function log(..._args) {\n //console.log(args);\n }\n\n function noOp() {}\n\n /**\n * Deep merges the config object and the Idiomoroph.defaults object to\n * produce a final configuration object\n * @param {Config} config\n * @returns {ConfigInternal}\n */\n function mergeDefaults(config) {\n /**\n * @type {ConfigInternal}\n */\n let finalConfig = Object.assign({}, defaults);\n\n // copy top level stuff into final config\n Object.assign(finalConfig, config);\n\n // copy callbacks into final config (do this to deep merge the callbacks)\n finalConfig.callbacks = Object.assign(\n {},\n defaults.callbacks,\n config.callbacks,\n );\n\n // copy head config into final config (do this to deep merge the head)\n finalConfig.head = Object.assign({}, defaults.head, config.head);\n\n return finalConfig;\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} newContent\n * @param {Config} config\n * @returns {MorphContext}\n */\n function createMorphContext(oldNode, newContent, config) {\n const mergedConfig = mergeDefaults(config);\n return {\n target: oldNode,\n newContent: newContent,\n config: mergedConfig,\n morphStyle: mergedConfig.morphStyle,\n ignoreActive: mergedConfig.ignoreActive,\n ignoreActiveValue: mergedConfig.ignoreActiveValue,\n idMap: createIdMap(oldNode, newContent),\n deadIds: new Set(),\n persistentIds: mergedConfig.twoPass\n ? createPersistentIds(oldNode, newContent)\n : new Set(),\n pantry: mergedConfig.twoPass\n ? createPantry()\n : document.createElement(\"div\"),\n callbacks: mergedConfig.callbacks,\n head: mergedConfig.head,\n };\n }\n\n function createPantry() {\n const pantry = document.createElement(\"div\");\n pantry.hidden = true;\n document.body.insertAdjacentElement(\"afterend\", pantry);\n return pantry;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Node | null} node2\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: The function handles this as if it's Element or null, but the function is called in\n // places where the arguments may be just a Node, not an Element\n function isIdSetMatch(node1, node2, ctx) {\n if (node1 == null || node2 == null) {\n return false;\n }\n if (\n node1 instanceof Element &&\n node2 instanceof Element &&\n node1.tagName === node2.tagName\n ) {\n if (node1.id !== \"\" && node1.id === node2.id) {\n return true;\n } else {\n return getIdIntersectionCount(ctx, node1, node2) > 0;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {Node | null} oldNode\n * @param {Node | null} newNode\n * @returns {boolean}\n */\n function isSoftMatch(oldNode, newNode) {\n if (oldNode == null || newNode == null) {\n return false;\n }\n // ok to cast: if one is not element, `id` or `tagName` will be undefined and we'll compare that\n // If oldNode has an `id` with possible state and it doesn't match newNode.id then avoid morphing\n if (\n /** @type {Element} */ (oldNode).id &&\n /** @type {Element} */ (oldNode).id !==\n /** @type {Element} */ (newNode).id\n ) {\n return false;\n }\n return (\n oldNode.nodeType === newNode.nodeType &&\n /** @type {Element} */ (oldNode).tagName ===\n /** @type {Element} */ (newNode).tagName\n );\n }\n\n /**\n *\n * @param {Node} startInclusive\n * @param {Node} endExclusive\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function removeNodesBetween(startInclusive, endExclusive, ctx) {\n /** @type {Node | null} */ let cursor = startInclusive;\n while (cursor !== endExclusive) {\n let tempNode = /** @type {Node} */ (cursor);\n // TODO: Prefer assigning to a new variable here or expand the type of startInclusive\n // to be Node | null\n cursor = tempNode.nextSibling;\n removeNode(tempNode, ctx);\n }\n removeIdsFromConsideration(ctx, endExclusive);\n return endExclusive.nextSibling;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential id match\n * for the newChild. We stop if we find a potential id match for the new child OR\n * if the number of potential id matches we are discarding is greater than the\n * potential id matches for the new child\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findIdSetMatch(\n newContent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n ) {\n // max id matches we are willing to discard in our search\n let newChildPotentialIdCount = getIdIntersectionCount(\n ctx,\n newChild,\n oldParent,\n );\n\n /**\n * @type {Node | null}\n */\n let potentialMatch = null;\n\n // only search forward if there is a possibility of an id match\n if (newChildPotentialIdCount > 0) {\n // TODO: This is ghosting the potentialMatch variable outside of this block.\n // Probably an error\n potentialMatch = insertionPoint;\n // if there is a possibility of an id match, scan forward\n // keep track of the potential id match count we are discarding (the\n // newChildPotentialIdCount must be greater than this to make it likely\n // worth it)\n let otherMatchCount = 0;\n while (potentialMatch != null) {\n // If we have an id match, return the current potential match\n if (isIdSetMatch(newChild, potentialMatch, ctx)) {\n return potentialMatch;\n }\n\n // computer the other potential matches of this new content\n otherMatchCount += getIdIntersectionCount(\n ctx,\n potentialMatch,\n newContent,\n );\n if (otherMatchCount > newChildPotentialIdCount) {\n // if we have more potential id matches in _other_ content, we\n // do not have a good candidate for an id match, so return null\n return null;\n }\n\n // advanced to the next old content child\n potentialMatch = potentialMatch.nextSibling;\n }\n }\n return potentialMatch;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential soft match\n * for the newChild. We stop if we find a potential soft match for the new child OR\n * if we find a potential id match in the old parents children OR if we find two\n * potential soft matches for the next two pieces of new content\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findSoftMatch(newContent, oldParent, newChild, insertionPoint, ctx) {\n /**\n * @type {Node | null}\n */\n let potentialSoftMatch = insertionPoint;\n /**\n * @type {Node | null}\n */\n let nextSibling = newChild.nextSibling;\n let siblingSoftMatchCount = 0;\n\n while (potentialSoftMatch != null) {\n if (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) {\n // the current potential soft match has a potential id set match with the remaining new\n // content so bail out of looking\n return null;\n }\n\n // if we have a soft match with the current node, return it\n if (isSoftMatch(potentialSoftMatch, newChild)) {\n return potentialSoftMatch;\n }\n\n if (isSoftMatch(potentialSoftMatch, nextSibling)) {\n // the next new node has a soft match with this node, so\n // increment the count of future soft matches\n siblingSoftMatchCount++;\n // ok to cast: if it was null it couldn't be a soft match\n nextSibling = /** @type {Node} */ (nextSibling).nextSibling;\n\n // If there are two future soft matches, bail to allow the siblings to soft match\n // so that we don't consume future soft matches for the sake of the current node\n if (siblingSoftMatchCount >= 2) {\n return null;\n }\n }\n\n // advanced to the next old content child\n potentialSoftMatch = potentialSoftMatch.nextSibling;\n }\n\n return potentialSoftMatch;\n }\n\n /** @type {WeakSet<Node>} */\n const generatedByIdiomorph = new WeakSet();\n\n /**\n *\n * @param {string} newContent\n * @returns {Node | null | DocumentFragment}\n */\n function parseContent(newContent) {\n let parser = new DOMParser();\n\n // remove svgs to avoid false-positive matches on head, etc.\n let contentWithSvgsRemoved = newContent.replace(\n /<svg(\\s[^>]*>|>)([\\s\\S]*?)<\\/svg>/gim,\n \"\",\n );\n\n // if the newContent contains a html, head or body tag, we can simply parse it w/o wrapping\n if (\n contentWithSvgsRemoved.match(/<\\/html>/) ||\n contentWithSvgsRemoved.match(/<\\/head>/) ||\n contentWithSvgsRemoved.match(/<\\/body>/)\n ) {\n let content = parser.parseFromString(newContent, \"text/html\");\n // if it is a full HTML document, return the document itself as the parent container\n if (contentWithSvgsRemoved.match(/<\\/html>/)) {\n generatedByIdiomorph.add(content);\n return content;\n } else {\n // otherwise return the html element as the parent container\n let htmlElement = content.firstChild;\n if (htmlElement) {\n generatedByIdiomorph.add(htmlElement);\n return htmlElement;\n } else {\n return null;\n }\n }\n } else {\n // if it is partial HTML, wrap it in a template tag to provide a parent element and also to help\n // deal with touchy tags like tr, tbody, etc.\n let responseDoc = parser.parseFromString(\n \"<body><template>\" + newContent + \"</template></body>\",\n \"text/html\",\n );\n let content = /** @type {HTMLTemplateElement} */ (\n responseDoc.body.querySelector(\"template\")\n ).content;\n generatedByIdiomorph.add(content);\n return content;\n }\n }\n\n /**\n *\n * @param {null | Node | HTMLCollection | Node[] | Document & {generatedByIdiomorph:boolean}} newContent\n * @returns {Element}\n */\n function normalizeContent(newContent) {\n if (newContent == null) {\n // noinspection UnnecessaryLocalVariableJS\n const dummyParent = document.createElement(\"div\");\n return dummyParent;\n } else if (generatedByIdiomorph.has(/** @type {Element} */ (newContent))) {\n // the template tag created by idiomorph parsing can serve as a dummy parent\n return /** @type {Element} */ (newContent);\n } else if (newContent instanceof Node) {\n // a single node is added as a child to a dummy parent\n const dummyParent = document.createElement(\"div\");\n dummyParent.append(newContent);\n return dummyParent;\n } else {\n // all nodes in the array or HTMLElement collection are consolidated under\n // a single dummy parent element\n const dummyParent = document.createElement(\"div\");\n for (const elt of [...newContent]) {\n dummyParent.append(elt);\n }\n return dummyParent;\n }\n }\n\n /**\n *\n * @param {Node | null} previousSibling\n * @param {Node} morphedNode\n * @param {Node | null} nextSibling\n * @returns {Node[]}\n */\n function insertSiblings(previousSibling, morphedNode, nextSibling) {\n /**\n * @type {Node[]}\n */\n let stack = [];\n /**\n * @type {Node[]}\n */\n let added = [];\n while (previousSibling != null) {\n stack.push(previousSibling);\n previousSibling = previousSibling.previousSibling;\n }\n // Base the loop on the node variable, so that you do not need runtime checks for\n // undefined value inside the loop\n let node = stack.pop();\n while (node !== undefined) {\n added.push(node); // push added preceding siblings on in order and insert\n morphedNode.parentElement?.insertBefore(node, morphedNode);\n node = stack.pop();\n }\n added.push(morphedNode);\n while (nextSibling != null) {\n stack.push(nextSibling);\n added.push(nextSibling); // here we are going in order, so push on as we scan, rather than add\n nextSibling = nextSibling.nextSibling;\n }\n while (stack.length > 0) {\n const node = /** @type {Node} */ (stack.pop());\n morphedNode.parentElement?.insertBefore(node, morphedNode.nextSibling);\n }\n return added;\n }\n\n /**\n *\n * @param {Element} newContent\n * @param {Element} oldNode\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function findBestNodeMatch(newContent, oldNode, ctx) {\n /**\n * @type {Node | null}\n */\n let currentElement;\n currentElement = newContent.firstChild;\n /**\n * @type {Node | null}\n */\n let bestElement = currentElement;\n let score = 0;\n while (currentElement) {\n let newScore = scoreElement(currentElement, oldNode, ctx);\n if (newScore > score) {\n bestElement = currentElement;\n score = newScore;\n }\n currentElement = currentElement.nextSibling;\n }\n return bestElement;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Element} node2\n * @param {MorphContext} ctx\n * @returns {number}\n */\n // TODO: The function handles node1 and node2 as if they are Elements but the function is\n // called in places where node1 and node2 may be just Nodes, not Elements\n function scoreElement(node1, node2, ctx) {\n if (isSoftMatch(node2, node1)) {\n // ok to cast: isSoftMatch performs a null check\n return (\n 0.5 + getIdIntersectionCount(ctx, /** @type {Node} */ (node1), node2)\n );\n }\n return 0;\n }\n\n /**\n *\n * @param {Node} tempNode\n * @param {MorphContext} ctx\n */\n // TODO: The function handles tempNode as if it's Element but the function is called in\n // places where tempNode may be just a Node, not an Element\n function removeNode(tempNode, ctx) {\n removeIdsFromConsideration(ctx, tempNode);\n // skip remove callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n hasPersistentIdNodes(ctx, tempNode) &&\n tempNode instanceof Element\n ) {\n moveToPantry(tempNode, ctx);\n } else {\n if (ctx.callbacks.beforeNodeRemoved(tempNode) === false) return;\n tempNode.parentNode?.removeChild(tempNode);\n ctx.callbacks.afterNodeRemoved(tempNode);\n }\n }\n\n /**\n *\n * @param {Node} node\n * @param {MorphContext} ctx\n */\n function moveToPantry(node, ctx) {\n if (ctx.callbacks.beforeNodePantried(node) === false) return;\n\n Array.from(node.childNodes).forEach((child) => {\n moveToPantry(child, ctx);\n });\n\n // After processing children, process the current node\n if (ctx.persistentIds.has(/** @type {Element} */ (node).id)) {\n // @ts-ignore - use proposed moveBefore feature\n if (ctx.pantry.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n ctx.pantry.moveBefore(node, null);\n } else {\n ctx.pantry.insertBefore(node, null);\n }\n } else {\n if (ctx.callbacks.beforeNodeRemoved(node) === false) return;\n node.parentNode?.removeChild(node);\n ctx.callbacks.afterNodeRemoved(node);\n }\n }\n\n /**\n *\n * @param {Node | null} root\n * @param {MorphContext} ctx\n */\n function restoreFromPantry(root, ctx) {\n if (root instanceof Element) {\n Array.from(ctx.pantry.children)\n .reverse()\n .forEach((element) => {\n const matchElement = root.querySelector(`#${element.id}`);\n if (matchElement) {\n // @ts-ignore - use proposed moveBefore feature\n if (matchElement.parentElement?.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n matchElement.parentElement.moveBefore(element, matchElement);\n while (matchElement.hasChildNodes()) {\n // @ts-ignore - use proposed moveBefore feature\n element.moveBefore(matchElement.firstChild, null);\n }\n } else {\n matchElement.before(element);\n while (matchElement.firstChild) {\n element.insertBefore(matchElement.firstChild, null);\n }\n }\n if (\n ctx.callbacks.beforeNodeMorphed(element, matchElement) !== false\n ) {\n syncNodeFrom(matchElement, element, ctx);\n ctx.callbacks.afterNodeMorphed(element, matchElement);\n }\n matchElement.remove();\n }\n });\n ctx.pantry.remove();\n }\n }\n\n //=============================================================================\n // ID Set Functions\n //=============================================================================\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @returns {boolean}\n */\n function isIdInConsideration(ctx, id) {\n return !ctx.deadIds.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @param {Node} targetNode\n * @returns {boolean}\n */\n function idIsWithinNode(ctx, id, targetNode) {\n let idSet = ctx.idMap.get(targetNode) || EMPTY_SET;\n return idSet.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {void}\n */\n function removeIdsFromConsideration(ctx, node) {\n let idSet = ctx.idMap.get(node) || EMPTY_SET;\n for (const id of idSet) {\n ctx.deadIds.add(id);\n }\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {boolean}\n */\n function hasPersistentIdNodes(ctx, node) {\n for (const id of ctx.idMap.get(node) || EMPTY_SET) {\n if (ctx.persistentIds.has(id)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node1\n * @param {Node} node2\n * @returns {number}\n */\n function getIdIntersectionCount(ctx, node1, node2) {\n let sourceSet = ctx.idMap.get(node1) || EMPTY_SET;\n let matchCount = 0;\n for (const id of sourceSet) {\n // a potential match is an id in the source and potentialIdsSet, but\n // that has not already been merged into the DOM\n if (isIdInConsideration(ctx, id) && idIsWithinNode(ctx, id, node2)) {\n ++matchCount;\n }\n }\n return matchCount;\n }\n\n /**\n * @param {Element} content\n * @returns {Element[]}\n */\n function nodesWithIds(content) {\n let nodes = Array.from(content.querySelectorAll(\"[id]\"));\n if (content.id) {\n nodes.push(content);\n }\n return nodes;\n }\n\n /**\n * A bottom up algorithm that finds all elements with ids in the node\n * argument and populates id sets for those nodes and all their parents, generating\n * a set of ids contained within all nodes for the entire hierarchy in the DOM\n *\n * @param {Element} node\n * @param {Map<Node, Set<string>>} idMap\n */\n function populateIdMapForNode(node, idMap) {\n let nodeParent = node.parentElement;\n for (const elt of nodesWithIds(node)) {\n /**\n * @type {Element|null}\n */\n let current = elt;\n // walk up the parent hierarchy of that element, adding the id\n // of element to the parent's id set\n while (current !== nodeParent && current != null) {\n let idSet = idMap.get(current);\n // if the id set doesn't exist, create it and insert it in the map\n if (idSet == null) {\n idSet = new Set();\n idMap.set(current, idSet);\n }\n idSet.add(elt.id);\n current = current.parentElement;\n }\n }\n }\n\n /**\n * This function computes a map of nodes to all ids contained within that node (inclusive of the\n * node). This map can be used to ask if two nodes have intersecting sets of ids, which allows\n * for a looser definition of \"matching\" than tradition id matching, and allows child nodes\n * to contribute to a parent nodes matching.\n *\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Map<Node, Set<string>>} a map of nodes to id sets for the\n */\n function createIdMap(oldContent, newContent) {\n /**\n *\n * @type {Map<Node, Set<string>>}\n */\n let idMap = new Map();\n populateIdMapForNode(oldContent, idMap);\n populateIdMapForNode(newContent, idMap);\n return idMap;\n }\n\n /**\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Set<string>} the id set of all persistent nodes that exist in both old and new content\n */\n function createPersistentIds(oldContent, newContent) {\n const toIdTagName = (node) => node.tagName + \"#\" + node.id;\n const oldIdSet = new Set(nodesWithIds(oldContent).map(toIdTagName));\n\n let matchIdSet = new Set();\n for (const newNode of nodesWithIds(newContent)) {\n if (oldIdSet.has(toIdTagName(newNode))) {\n matchIdSet.add(newNode.id);\n }\n }\n return matchIdSet;\n }\n\n //=============================================================================\n // This is what ends up becoming the Idiomorph global object\n //=============================================================================\n return {\n morph,\n defaults,\n };\n})();\n\nexport {Idiomorph};\n","\nconst topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n","import { safe, rAF, g, dup } from './utils'\nimport { Idiomorph } from 'idiomorph/dist/idiomorph.esm'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport const Component = ({ name, module, dependencies, node, templates, signal }) => {\n\n\tconst _model \t\t= module.model || {}\n\tconst initialState \t= (new Function( `return ${node.getAttribute('html-model') || '{}'}`))()\n\tconst tplid \t\t= node.getAttribute('tplid')\n\tconst scopeid \t\t= node.getAttribute('html-scopeid')\n\tconst tpl \t\t\t= templates[ tplid ]\n\tconst scope \t\t= g.scope[ scopeid ]\n\tconst model \t\t= dup(module?.model?.apply ? _model({ elm:node, initialState }) : _model)\n\tconst state \t\t= Object.assign({}, scope, model, initialState)\n\tconst view \t\t\t= module.view? module.view : (data) => data\n\tlet preserve\t\t= []\n\n\tconst base = {\n\t\tname,\n\t\tmodel,\n\t\telm: node,\n\t\ttemplate: tpl.template,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\tnode.addEventListener(':mount', fn)\n\t\t},\n\n\t\t/**\n\t\t * @State\n\t\t */\n\t\tstate : {\n\n\t\t\tprotected( list ) {\n\t\t\t\tif( list ) {\n\t\t\t\t\tpreserve = list\n\t\t\t\t} else {\n\t\t\t\t\treturn preserve\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tsave(data) {\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata( state )\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tset( data ) {\n\n\t\t\t\tif (!document.body.contains(node)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata(state)\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\n\t\t\t\tconst newstate = Object.assign({}, state, scope)\n\n\t\t\t\trender(newstate)\n\n\t\t\t\treturn Promise.resolve(newstate)\n\t\t\t},\n\n\t\t\tget() {\n\t\t\t\treturn Object.assign({}, state)\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * @Events\n\t\t */\n\t\ton( ev, selectorOrCallback, callback ) {\n\n\t\t\tif( callback ) {\n\t\t\t\tcallback.handler = (e) => {\n\t\t\t\t\tconst detail = e.detail || {}\n\t\t\t\t\tlet parent = e.target\n\t\t\t\t\twhile (parent) {\n\t\t\t\t\t\tif (parent.matches(selectorOrCallback)) {\n\t\t\t\t\t\t\te.delegateTarget = parent\n\t\t\t\t\t\t\tcallback.apply(node, [e].concat(detail.args))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parent === node) break\n\t\t\t\t\t\tparent = parent.parentNode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, callback.handler, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tcapture: (ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave')\n\t\t\t\t})\n\n\t\t\t} else {\n\t\t\t\tselectorOrCallback.handler = (e) => {\n\t\t\t\t\te.delegateTarget = node\n\t\t\t\t\tselectorOrCallback.apply(node, [e].concat(e.detail.args))\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, selectorOrCallback.handler, { signal })\n\t\t\t}\n\t\t},\n\n\t\toff( ev, callback ) {\n\t\t\tif( callback.handler ) {\n\t\t\t\tnode.removeEventListener(ev, callback.handler)\n\t\t\t}\n\t\t},\n\n\t\ttrigger(ev, selectorOrCallback, data) {\n\t\t\tif( selectorOrCallback.constructor === String ) {\n\t\t\t\tArray\n\t\t\t\t\t.from(node.querySelectorAll(selectorOrCallback))\n\t\t\t\t\t.forEach( children => {\n\t\t\t\t\t\tchildren.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }) )\n\t\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail:{ args: data } }))\n\t\t\t}\n\t\t},\n\n\t\temit(ev, data) {\n\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }))\n\t\t},\n\n\t\tunmount( fn ) {\n\t\t\tnode.addEventListener(':unmount', fn)\n\t\t},\n\n\t\tinnerHTML ( target, html_ ) {\n\t\t\tconst element = html_? target : elm\n\t\t\tconst clone = element.cloneNode()\n\t\t\tconst html = html_? html_ : target\n\t\t\tclone.innerHTML = html\n\n\t\t\trAF( _ => Idiomorph.morph(element, clone, IdiomorphOptions) )\n\t\t}\n\t}\n\n\tconst render = ( data ) => {\n\n\t\tconst html = tpl.render.call( view(data), node, safe, g )\n\t\tIdiomorph.morph( node, html, IdiomorphOptions(node) )\n\n\t\trAF(() => {\n\t\t\tnode.querySelectorAll('[tplid]')\n\t\t\t\t.forEach((element) => {\n\t\t\t\t\tif(!element.base) return\n\t\t\t\t\telement.base.state.protected().forEach( key => delete data[key] )\n\t\t\t\t\telement.base.state.set(data)\n\t\t\t\t})\n\t\t\trAF(() => g.scope = {})\n\t\t})\n\n\t}\n\n\tnode.base = base\n\treturn module.default( base )\n}\n\nconst IdiomorphOptions = ( parent ) => ({\n\tcallbacks: {\n\t\tbeforeNodeMorphed( node ) {\n\t\t\tif( node.nodeType === 1 ) {\n\t\t\t\tif( 'html-static' in node.attributes ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif( node.base && node !== parent ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n","import { Component } from './component'\n\nexport const Element = ({ component, templates, start }) => {\n\n\tconst { name, module, dependencies } = component\n\tconst abortController = new AbortController()\n\n\treturn class extends HTMLElement {\n\n\t\tconstructor() {\n\t\t\tsuper()\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tif( !this.getAttribute('tplid') ) {\n\t\t\t\tstart( this.parentNode )\n\t\t\t}\n\n\t\t\tconst rtrn = Component({\n\t\t\t\tnode:this,\n\t\t\t\tname,\n\t\t\t\tmodule,\n\t\t\t\tdependencies,\n\t\t\t\ttemplates,\n\t\t\t\tsignal: abortController.signal\n\t\t\t})\n\n\t\t\tif ( rtrn && rtrn.constructor === Promise ) {\n\t\t\t\trtrn.then(() => this.dispatchEvent( new CustomEvent(':mount') ))\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t}\n\n\t\t\tthis.base.state.set({})\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.dispatchEvent( new CustomEvent(':unmount') )\n\t\t\tabortController.abort()\n\t\t\tdelete this.base\n\t\t}\n\t}\n}\n","import { uuid } from './utils'\n\nconst templates = {}\n\nconst config = {\n\ttags: ['{{', '}}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign( config, newconfig )\n}\n\nexport const template = ( target, { components }) => {\n\n\ttagElements( target, [...Object.keys( components ), 'template'] )\n\tconst clone = target.cloneNode( true )\n\n\ttransformTemplate( clone )\n\tremoveTemplateTagsRecursively( clone )\n\tsetTemplates( clone, components )\n\n\treturn templates\n}\n\nexport const compile = ( html ) => {\n\n\tconst parsedHtml = JSON.stringify( html )\n\n\treturn new Function('$element', 'safe', '$g',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${parsedHtml\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+ variable +';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + variable +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nconst tagElements = ( target, keys ) => {\n\ttarget\n\t\t.querySelectorAll( keys.toString() )\n\t\t.forEach((node) => {\n\t\t\tif( node.localName === 'template' ) {\n\t\t\t\treturn tagElements( node.content, keys )\n\t\t\t}\n\t\t\tnode.setAttribute('tplid', uuid())\n\t\t})\n}\n\nconst transformAttributes = ( html ) => {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\n\treturn html\n\t\t.replace(/jails___scope-id/g, '%%_=$scopeid_%%')\n\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t// Booleans\n\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t// The rest\n\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\tif (key === 'key' || key === 'model' || key === 'scopeid' ) {\n\t\t\t\treturn all\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t} else {\n\t\t\t\treturn all\n\t\t\t}\n\t\t})\n}\n\nconst transformTemplate = ( clone ) => {\n\n\tclone.querySelectorAll('template, [html-for], [html-if], [html-inner], [html-class]')\n\t\t.forEach(( element ) => {\n\n\t\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\t\tconst htmlClass = element.getAttribute('html-class')\n\n\t\t\tif ( htmlFor ) {\n\n\t\t\t\telement.removeAttribute('html-for')\n\n\t\t\t\tconst split \t = htmlFor.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\t\tconst varname \t = split[1]\n\t\t\t\tconst object \t = split[2]\n\t\t\t\tconst objectname = object.split(/\\./).shift()\n\t\t\t\tconst open \t\t = document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${objectname}: ${objectname} }, { ${varname} :${varname}, $index: $index, $key: $key }); _%%`)\n\t\t\t\tconst close \t = document.createTextNode(`%%_ $index++; } })() _%%`)\n\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlIf) {\n\t\t\t\telement.removeAttribute('html-if')\n\t\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlInner) {\n\t\t\t\telement.removeAttribute('html-inner')\n\t\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t\t}\n\n\t\t\tif (htmlClass) {\n\t\t\t\telement.removeAttribute('html-class')\n\t\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t\t}\n\n\t\t\tif( element.localName === 'template' ) {\n\t\t\t\ttransformTemplate(element.content)\n\t\t\t}\n\t\t})\n}\n\nconst setTemplates = ( clone, components ) => {\n\n\tArray.from(clone.querySelectorAll('[tplid]'))\n\t\t.reverse()\n\t\t.forEach((node) => {\n\n\t\t\tconst tplid = node.getAttribute('tplid')\n\t\t\tconst name = node.localName\n\t\t\tnode.setAttribute('html-scopeid', 'jails___scope-id')\n\n\t\t\tif( name in components && components[name].module.template ) {\n\t\t\t\tconst children = node.innerHTML\n\t\t\t\tconst html = components[name].module.template({ elm:node, children })\n\t\t\t\tnode.innerHTML = html\n\t\t\t}\n\n\t\t\tconst html = transformAttributes(node.outerHTML)\n\n\t\t\ttemplates[ tplid ] = {\n\t\t\t\ttemplate: html,\n\t\t\t\trender\t: compile(html)\n\t\t\t}\n\t\t})\n}\n\nconst removeTemplateTagsRecursively = (node) => {\n\n\t// Get all <template> elements within the node\n\tconst templates = node.querySelectorAll('template')\n\n\ttemplates.forEach((template) => {\n\n\t\tif( template.getAttribute('html-if') || template.getAttribute('html-inner') ) {\n\t\t\treturn\n\t\t}\n\n\t\t// Process any nested <template> tags within this <template> first\n\t\tremoveTemplateTagsRecursively(template.content)\n\n\t\t// Get the parent of the <template> tag\n\t\tconst parent = template.parentNode\n\n\t\tif (parent) {\n\t\t\t// Move all child nodes from the <template>'s content to its parent\n\t\t\tconst content = template.content\n\t\t\twhile (content.firstChild) {\n\t\t\t\tparent.insertBefore(content.firstChild, template)\n\t\t\t}\n\t\t\t// Remove the <template> tag itself\n\t\t\tparent.removeChild(template)\n\t\t}\n\t})\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","import { Element } from './element'\nimport { template, templateConfig as config } from './template-system'\n\nconst components = {}\n\nexport { publish, subscribe } from './utils/pubsub'\n\nexport const templateConfig = (options) => {\n\tconfig( options )\n}\n\nexport const register = ( name, module, dependencies ) => {\n\tcomponents[ name ] = { name, module, dependencies }\n}\n\nexport const start = ( target = document.body ) => {\n\n\tconst templates = template( target, { components } )\n\n\tObject\n\t\t.values( components )\n\t\t.forEach(({ name, module, dependencies }) => {\n\t\t\tif( !customElements.get(name) ) {\n\t\t\t\tcustomElements.define( name, Element({ component: { name, module, dependencies }, templates, start }))\n\t\t\t}\n\t})\n}\n"],"names":["config","node","templates","Element","start","templateConfig","components","html","template"],"mappings":"AACO,MAAM,IAAI;AAAA,EAChB,OAAO,CAAA;AACR;AAEa,MAAA,MAAM,CAAC,OAAO;AACtB,MAAA;AACH,WAAO,sBAAsB,EAAE;AAAA;AAExB,WAAA,WAAW,IAAI,MAAO,EAAE;AACjC;AAEO,MAAM,OAAO,MAAM;AAClB,SAAA,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACjD;AAEa,MAAA,MAAM,CAAC,MAAM;AACzB,SAAO,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC;AACpC;AAEa,MAAA,OAAO,CAAC,SAAS,QAAQ;AAClC,MAAA;AACF,WAAO,QAAQ;AAAA,WACT,KAAI;AACV,WAAO,OAAO;AAAA,EAAA;AAEhB;ACiEA,IAAI,YAAa,2BAAY;AA4B3B,MAAI,YAAY,oBAAI,IAAK;AAMzB,MAAI,WAAW;AAAA,IACb,YAAY;AAAA,IACZ,WAAW;AAAA,MACT,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,wBAAwB;AAAA,MACxB,oBAAoB;AAAA,IACrB;AAAA,IACD,MAAM;AAAA,MACJ,OAAO;AAAA,MACP,gBAAgB,SAAU,KAAK;AAC7B,eAAO,IAAI,aAAa,aAAa,MAAM;AAAA,MAC5C;AAAA,MACD,gBAAgB,SAAU,KAAK;AAC7B,eAAO,IAAI,aAAa,cAAc,MAAM;AAAA,MAC7C;AAAA,MACD,cAAc;AAAA,MACd,kBAAkB;AAAA,IACnB;AAAA,EACF;AAYD,WAAS,MAAM,SAAS,YAAYA,UAAS,CAAA,GAAI;AAC/C,QAAI,mBA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