solarite 0.1.0 → 0.2.0

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.
Files changed (48) hide show
  1. package/benchmarks/naive/Solarite.min.js +4 -0
  2. package/benchmarks/naive/index.html +14 -0
  3. package/benchmarks/naive/main.js +339 -0
  4. package/benchmarks/naive/package-lock.json +13 -0
  5. package/benchmarks/naive/package.json +23 -0
  6. package/benchmarks/readme.md +48 -0
  7. package/build/build.bat +3 -2
  8. package/build/build.js +1 -1
  9. package/dist/Solarite-debug.js +1941 -2791
  10. package/dist/Solarite.js +1697 -2511
  11. package/dist/Solarite.min.js +3 -3
  12. package/dist/udomdiff-license.txt +18 -0
  13. package/docs/index.md +695 -235
  14. package/docs/js/Playground.js +1 -1
  15. package/docs/js/codemirror/codemirror6.js +3683 -3206
  16. package/docs/js/codemirror/themeSolarIce.js +2 -2
  17. package/docs/js/documentation.js +2 -2
  18. package/docs/js/ui/CodeEditor.js +183 -45
  19. package/docs/js/ui/FlexResizer.js +15 -5
  20. package/docs/js/util/Errors.js +11 -0
  21. package/docs/media/documentation.css +6 -3
  22. package/index.html +462 -26
  23. package/package.json +1 -1
  24. package/readme.md +11 -1
  25. package/src/solarite/ExprPath.js +422 -135
  26. package/src/solarite/Globals.js +53 -0
  27. package/src/solarite/NodeGroup.js +300 -388
  28. package/src/solarite/Shell.js +31 -33
  29. package/src/solarite/Solarite.js +17 -2
  30. package/src/solarite/Template.js +75 -25
  31. package/src/solarite/Util.js +131 -7
  32. package/src/solarite/createSolarite.js +32 -25
  33. package/src/solarite/getArg.js +12 -12
  34. package/src/solarite/hash.js +18 -35
  35. package/src/solarite/r.js +128 -118
  36. package/src/solarite/watch3.js +98 -0
  37. package/src/{solarite → unused}/NodeGroupManager.js +86 -224
  38. package/src/unused/onConnect.js +79 -0
  39. package/src/{solarite → unused}/watch.js +2 -2
  40. package/src/{solarite → unused}/watch2.js +4 -4
  41. package/src/{solarite → util}/MultiValueMap.js +23 -12
  42. package/src/util/WeakArray.js +33 -0
  43. package/tests/Solarite.test.js +1108 -166
  44. package/tests/Testimony.js +274 -67
  45. package/tests/index.html +6 -35
  46. package/tests/run.bat +2 -0
  47. package/tests/NodeGroup.test.js +0 -115
  48. package/tests/Shell.test.js +0 -75
@@ -1,4 +1,4 @@
1
- // Version 2024.6.24.0406
1
+ // Version 2024.10.5.1955
2
2
  // License: MIT
3
- // https://github.com/vorticode/Solarite
4
- var Util$1={callback(...t){var e=!1;let l=async(...t)=>{let s=[];if(!e)for(let e=0;l.length>e;e++)s.push(l[e](...t));return await Promise.all(s)};l[Symbol.iterator]=()=>{let t=0;return{next(){return l.length>t?{value:l[t++],done:!1}:{done:!0}}}};for(let t of Object.getOwnPropertyNames(Array.prototype))"length"!==t&&"constructor"!==t&&(l[t]=Array.prototype[t]);l.l=0,Object.defineProperty(l,"length",{get:()=>l.l,set(t){l.l=t}}),l.remove=t=>{let e=l.findIndex((e=>e===t));-1!==e&&l.splice(e,1)},l.pause=()=>e=!0,l.resume=()=>e=!1;for(let e of t)l.push(e);return l}};function delve(t,e,l=delveDontCreate){let s=l!==delveDontCreate,i=e.length;if(!t&&!s&&i)return;let r=0;for(let n of e){if(void 0===t[n]){if(!s)return;i-1>r&&(t[n]=(e[r+1]+"").match(/^\d+$/)?[]:{})}s&&r===i-1&&(t[n]=l),t=t[n],r++}return t}let delveDontCreate={};function getArg(el,name,val=null,type=ArgType.String){let attrVal=el.getAttribute(name);if(null!==attrVal&&(val=attrVal),Array.isArray(type))return type.includes(val)?val:void 0;if("function"==typeof type)return type(val);if(type===ArgType.Bool){let t="string"==typeof val?val.toLowerCase():val;return!["false","0",!1,0,null,void 0].includes(t)}switch(type){case ArgType.Int:return parseInt(val);case ArgType.Float:return parseFloat(val);case ArgType.String:return val||"";case ArgType.JSON:try{return JSON.parse(val)}catch(t){return val}case ArgType.Eval:try{return eval(`(${val})`)}catch(t){return val}default:return val}}var ArgType={Bool:"Bool",Int:"Int",Float:"Float",String:"String",JSON:"JSON",Eval:"Eval"};let lastObjectId=1,objectIds=new WeakMap;function getObjectId(t,e=null){e=e||"~\f";let l=objectIds.get(t);return l||(l=e+lastObjectId++,objectIds.set(t,l)),l}let isHashing=!0;function toJSON(){return isHashing?getObjectId(this):this}function getObjectHash(t){let e;Node.prototype.toJSON!==toJSON&&(Node.prototype.toJSON=toJSON,(()=>{}).toJSON!==toJSON&&(Function.prototype.toJSON=toJSON)),isHashing=!0;try{e=JSON.stringify(t)}catch(l){e=getObjectHashCircular(t)}return isHashing=!1,e}function getObjectHashCircular(t){const e=new Set;return JSON.stringify(t,((t,l)=>{if("object"==typeof l&&null!==l){if(e.has(l))return getObjectId(l);e.add(l)}return l}))}class MultiValueMap{data={};add(t,e){let l=this.data,s=l[t];s||(s=new Set,l[t]=s),s.add(e)}getAll(t){return this.data[t]||[]}delete(t,e=void 0){let l,s=this.data,i=s[t];if(i)return void 0!==e?(i.delete(e),l=e):(l=i.values().next().value,i.delete(l)),0===i.size&&delete s[t],l}hasValue(t){let e=this.data,l=[];for(let s in e)e[s].has(t)&&l.push(s);return l}}let Util={bindStyles(t,e){let l=e.getAttribute("data-style");l||(e.constructor.styleId||(e.constructor.styleId=1),l=e.constructor.styleId++,e.setAttribute("data-style",l));let s=e.tagName.toLowerCase();for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,i=t.replace(/:host(?=[^a-z0-9_])/gi,s+'[data-style="'+l+'"]');t!==i&&(e.textContent=i)}}},div=document.createElement("div"),isEvent=t=>t.startsWith("on")&&t in div;function camelToDashes(t){return(t=(t=(t=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2")).replace(/([A-Z])([A-Z][a-z])/g,"$1-$2")).replace(/([a-zA-Z])([0-9])/g,"$1-$2")).toLowerCase()}function findArrayDiff(t,e){if(t.length!==e.length)return-1;let l=t.length;for(let s=0;l>s;s++)if(t[s]!==e[s])return s;return!1}function htmlContext(t){if(null===t)return state={...defaultState},state.context;for(let e=0;t.length>e;e++){const l=t[e];switch(state.context){case htmlContext.Text:"<"===l&&t[e+1].match(/[a-z!]/i)&&(state.context=htmlContext.Tag,state.buffer="");break;case htmlContext.Tag:if(">"===l)state.context=htmlContext.Text,state.quote=null,state.buffer="";else{if(" "===l&&!state.buffer)continue;" "===l||"/"===l||"?"===l?state.buffer="":'"'===l||"'"===l||"="===l?(state.context=htmlContext.Attribute,state.quote="="===l?null:l,state.buffer=""):state.buffer+=l}break;case htmlContext.Attribute:state.quote||state.buffer.length||'"'!==l&&"'"!==l?l===state.quote||!state.quote&&state.buffer.length?(state.context=htmlContext.Tag,state.quote=null,state.buffer=""):state.quote||">"!==l?" "!==l&&(state.buffer+=l):(state.context=htmlContext.Text,state.quote=null,state.buffer=""):state.quote=l}}return state.context}htmlContext.Attribute="Attribute",htmlContext.Text="Text",htmlContext.Tag="Tag";let defaultState={context:htmlContext.Text,quote:null,buffer:"",lastChar:null},state={...defaultState};class ExprPath{type;attrName;attrValue;attrNames;nodeBefore;nodeMarker;get parentNode(){return this.nodeMarker.parentNode}parentNg;nodeGroups=[];nodesCache;nodeBeforeIndex;nodeMarkerPath;expr;constructor(t,e,l=PathType.Content,s=null,i=null){this.nodeBefore=t,this.nodeMarker=e,this.type=l,this.attrName=s,this.attrValue=i,l===PathType.Multiple&&(this.attrNames=new Set)}applyMultipleAttribs(t,e){Array.isArray(e)&&(e=e.flat().join(" "));let l=this.attrNames;if(this.attrNames=new Set,e){let l=(e+"").split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g).map((t=>t.trim())).filter((t=>t.length));for(let e of l){let[l,s]=e.split(/\s*=\s*/);s=(s||"").replace(/^(['"])(.*)\1$/,"$2"),t.setAttribute(l,s),this.attrNames.add(l)}}for(let e of l)this.attrNames.has(e)||t.removeAttribute(e)}applyEventAttrib(t,e,l){let s,i=this.attrName.slice(2),r=[];if(Array.isArray(e)){for(let t=0;e.length>t;t++)if("function"==typeof e[t]){s=e[t],r=e.slice(t+1);break}s||(s=setValue,r=[e[0],e.slice(1),t],t.value=delve(e[0],e.slice(1)))}else s=e;let n=getObjectId(t)+i,[o,h]=nodeEvents[n]||[];if(nodeEventArgs[n]=r,o!==s){o&&t.removeEventListener(i,h);let e=s,a=s=>e.call(l,...r,s,t);nodeEvents[n]=[e,a],t.addEventListener(i,a)}}applyValueAttrib(t,e,l){let s=e[l];if(this.attrValue||!1!==s&&null!=s)if(this.attrValue||!0!==s){let i=[];if(this.attrValue){for(let t=this.attrValue.length-1;t>=0;t--)if(i.unshift(this.attrValue[t]),t>0){let t=e[l];!1!==t&&null!=t&&i.unshift(t),l--}l++}else i.unshift(s);let r=i.join("");t.setAttribute(this.attrName,r),this.attrName in t&&(t[this.attrName]=r)}else t.setAttribute(this.attrName,"");else t.removeAttribute(this.attrName);return l}clone(t){let e,l,s=t,i=this.nodeMarkerPath;for(let t=i.length-1;t>0;t--)s=s.childNodes[i[t]];let r=s.childNodes;return e=r[i[0]],this.nodeBefore&&(l=r[this.nodeBeforeIndex]),new ExprPath(l,e,this.type,this.attrName,this.attrValue)}clearNodesCache(){let t=this,e=this.parentNode;for(;t&&t.parentNode===e;)t.nodesCache=null,t=t.parentNg?.parentPath;!function t(l){for(let s of l.nodeGroups)if(s)for(let l of s.paths)l.type===PathType.Content&&l.parentNode===e&&(l.nodesCache=null,t(l))}(this)}fastClear(){let t=this.nodeBefore.parentNode;if(this.nodeBefore===t.firstChild&&this.nodeMarker===t.lastChild){let e=t.parentNode;if(e&&t===e.firstChild&&t===e.lastChild&&!t.hasAttribute("id")){let e=document.createElement(t.tagName);e.append(this.nodeBefore,this.nodeMarker);for(let l of t.attributes)e.setAttribute(l.name,l.value);t.replaceWith(e)}else t.innerHTML="",t.append(this.nodeBefore,this.nodeMarker);return!0}return!1}getNodes(){let t;t=[];let e=this.nodeBefore.nextSibling,l=this.nodeMarker;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.nodesCache=t,t}getParentNode(){return this.nodeMarker.parentNode}removeNodeGroup(t){let e=this.nodeGroups.indexOf(t);this.nodeGroups.splice(e),t.parentPath=null,this.clearNodesCache()}}function setValue(t,e,l){let s=l.value;"number"===l.type&&(s=parseFloat(s)),delve(t,e,s)}const PathType={Content:"content",Multiple:"attrName",Value:"attrValue",Component:"component",Comment:"comment"};function getNodePath(t){let e=[];for(;;){let l=t.parentNode;if(!l)break;e.push([].indexOf.call(t.parentNode.childNodes,t)),t=l}return e}function resolveNodePath(t,e){for(let l=e.length-1;l>=0;l--)t=t.childNodes[e[l]];return t}let nodeEvents={},nodeEventArgs={};class Shell{fragment;paths=[];template;events=[];ids=[];scripts=[];styles=[];staticComponents=[];constructor(t=null){if(!t)return;let e=[],l="\x3c!--!✨!--\x3e",s={};htmlContext(null);for(let i=0;t.length>i;i++){let r=t[i],n=htmlContext(r);if(n===htmlContext.Attribute){let t,e;if(r.replace(/<[a-z][a-z0-9]*-[a-z0-9-]+/gi,((l,s)=>{t=s+1,e=l.slice(1)})),e){let l=e+"-redcomponent-placeholder";r=r.slice(0,t)+l+r.slice(t+e.length),s[e]=l}}e.push(r),t.length-1>i&&e.push(n===htmlContext.Text?l:String.fromCharCode(57344+i))}let i,r=document.createElement("template"),n=e.join("");for(let t in s)n=n.replaceAll(`</${t}>`,`</${s[t]}>`);n?r.innerHTML=n:r.content.append(document.createTextNode("")),this.fragment=r.content;let o=[];const h=document.createTreeWalker(r.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;i=h.nextNode();)if(o.map((t=>t.remove())),o=[],1===i.nodeType)for(let t of i.attributes){let e=t.name.match(/^[\ue000-\uf8ff]$/);if(e)this.paths.push(new ExprPath(null,i,PathType.Multiple)),i.removeAttribute(e[0]);else{let e=t.value.split(/[\ue000-\uf8ff]/g);e.length>1&&(this.paths.push(new ExprPath(null,i,PathType.Value,t.name,2!==e.length||e[0].length||e[1].length?e:null)),i.setAttribute(t.name,e.join("")))}}else if(i.nodeType===Node.COMMENT_NODE&&"!✨!"===i.nodeValue){let t,e=i.previousSibling;e||(e=document.createComment("PathStart:"+this.paths.length),i.parentNode.insertBefore(e,i)),!i.nextSibling||8===i.nextSibling.nodeType&&"!✨!"===i.nextSibling.textContent?(t=i,t.textContent="PathEnd:"+this.paths.length):(t=i.nextSibling,o.push(i));let l=new ExprPath(e,t,PathType.Content);this.paths.push(l)}else if(i.nodeType===Node.COMMENT_NODE){let t=i.textContent.split(/[\ue000-\uf8ff]/g);for(let e=0;t.length-1>e;e++){let t=new ExprPath(i.previousSibling,i);t.type=PathType.Comment,this.paths.push(t)}}else if(i.nodeType===Node.TEXT_NODE&&["SCRIPT","STYLE"].includes(i.parentNode?.nodeName)){let t=i.textContent.split(l);if(t.length>1){let e=[];for(let l=0;t.length>l;l++){let s=document.createTextNode(t[l]);i.parentNode.insertBefore(s,i),l>0&&e.push(s)}for(let t,l=0;t=e[l];l++){let e=new ExprPath(t.previousSibling,t,PathType.Content);this.paths.push(e)}o.push(i)}}o.map((t=>t.remove()));for(let t of this.fragment.querySelectorAll("[is]"))t.setAttribute("_is",t.getAttribute("is"));for(let t of this.paths)t.nodeBefore&&(t.nodeBeforeIndex=[].indexOf.call(t.nodeBefore.parentNode.childNodes,t.nodeBefore)),t.nodeMarkerPath=getNodePath(t.nodeMarker),t.type===PathType.Value&&1===t.nodeMarker.nodeType&&(t.nodeMarker.tagName.includes("-")||t.nodeMarker.hasAttribute("is"))&&(t.type=PathType.Component);this.findEmbeds()}findEmbeds(){this.scripts=[].map.call(this.fragment.querySelectorAll("scripts"),(t=>getNodePath(t))),this.styles=[].map.call(this.fragment.querySelectorAll("style"),(t=>getNodePath(t)));let t=this.fragment.querySelectorAll("[id],[data-id]");for(let e of t){let t=e.getAttribute("data-id")||e.getAttribute("id");if(div.hasOwnProperty(t))throw Error(`<${e.tagName.toLowerCase()} id="${t}"> can't override existing HTMLElement property.`)}this.ids=[].map.call(t,(t=>getNodePath(t)));for(let t of this.fragment.querySelectorAll("*")){for(let e of t.attributes)isEvent(e.name)&&this.events.push([e.name,getNodePath(t)]);(t.tagName.includes("-")||t.hasAttribute("_is"))&&(this.paths.find((e=>e.nodeMarker===t))||this.staticComponents.push(getNodePath(t)))}}static get(t){let e=shells.get(t);return e||(e=new Shell(t),shells.set(t,e)),e}}let shells=new WeakMap;class Template{exprs=[];html=[];replaceMode;hashedFields;parentPath;nodeGroup;paths=[];constructor(t,e){this.html=t,this.exprs=e}toJSON(){return this.hashedFields||(this.hashedFields=[getObjectId(this.html,"Html"),this.exprs]),this.hashedFields}toNode(){return(new NodeGroupManager).render(this)}getCloseKey(){return"@"+this.hashedFields[0]}}const udomdiff=(t,e,l,s)=>{const i=l.length;let r=e.length,n=i,o=0,h=0,a=null;for(;r>o||n>h;)if(r===o){const e=i>n?h?l[h-1].nextSibling:l[n-h]:s;for(;n>h;){let s=l[h++];t.insertBefore(s,e)}}else if(n===h)for(;r>o;){let l=e[o];a&&a.has(l)||t.removeChild(l),o++}else if(e[o]===l[h])o++,h++;else if(e[r-1]===l[n-1])r--,n--;else if(e[o]===l[n-1]&&l[h]===e[r-1]){const s=e[--r].nextSibling;let i=l[h++],a=e[o++];t.insertBefore(i,a.nextSibling);let f=l[--n];t.insertBefore(f,s),e[r]=l[n]}else{if(!a){a=new Map;let t=h;for(;n>t;)a.set(l[t],t++)}if(a.has(e[o])){const s=a.get(e[o]);if(s>h&&n>s){let i=o,f=1;for(;++i<r&&n>i&&a.get(e[i])===s+f;)f++;if(f>s-h){const i=e[o];for(;s>h;){let e=l[h++];t.insertBefore(e,i)}}else{let s=e[o++],i=l[h++];t.replaceChild(i,s)}}else o++}else{let l=e[o++];t.removeChild(l)}}return l};class TransformerInfo{constructor(t,e,l){this.path=t,this.transformer=e,this.hash=l}}let pathToTransformer=new MultiValueMap;function watchGet(...t){let e,l=t.at(-1);if("function"==typeof l)e=t.slice(0,-1);else if(1===t.length){e=[t[0].slice(0,-1)];let s=t[0].at(-1);l=(...t)=>t[0][s]}let s=[];for(let t of e){let e=delve(watchSet(t[0]),t.slice(1));s.push(e)}let i=l(...s);if(!(i instanceof Template)){let t=l;l=function(){return new Template(["",""],[t(...arguments)])},i=l(...s)}let r=getObjectHash(i);for(let t of e){let e=serializePath(t);pathToTransformer.add(e,new TransformerInfo(t,l,r))}return i}function watchSet(t){return!0===t?.$isProxy?t:new Proxy(t,new ProxyHandler$1(t))}function forEach(t,e){let l=delve(t[0],t.slice(1)),s=NodeGroupManager.get(t[0]);s.clearSubscribers&&(s.clearSubscribers=!1,s.pathToLoopInfo=new MultiValueMap);let i=[...l.map(((l,s)=>watchGet([...t,s],e)))],r=new Template(["",""],[i]),n=new LoopInfo(r,e);return s.pathToLoopInfo.add(serializePath(t),n),r}function serializePath(t){return JSON.stringify([getObjectId(t[0]),...t.slice(1).map((t=>t+""))])}class ProxyHandler$1{constructor(t,e=[]){this.root=t,this.path=e}get(t,e){if("$isProxy"===e)return!0;if("splice"===e&&Array.isArray(t))return(e,l,...s)=>{let i=NodeGroupManager.get(this.root);if(l){let t=[];for(let s=e;e+l>s;s++){let e=serializePath([this.root,...this.path,s+""]),l=delve(this.root,[...this.path,s]);for(let s of pathToTransformer.getAll(e)){let e=getObjectHash(s.transformer(l));t.push(e)}}i.changes.push(new Change("delete",this.root,[...this.path,e+""],t))}let r=t.splice(e,l);if(s.length){let l;for(let t of i.getLoopInfo([this.root,...this.path])){let r=delve(this.root,[...this.path,e]);if(r){let n=t.itemTransformer(r),o=getObjectHash(n);if(l=i.nodeGroupsAvailable.data[o],l){let r=getObjectHash(t.template),o=i.nodeGroupsAvailable.data[r]||[];for(let t of o)for(let r of l)r.startNode.parentNode===t.startNode.parentNode&&i.changes.push(new Change("insert",this.root,[...this.path,e+""],s,n))}}l||i.changes.push(new Change("insert",this.root,[...this.path,e+""],s))}t.splice(e,0,...s)}return r};let l=Reflect.get(t,e);if(l&&"object"==typeof l){let t=new ProxyHandler$1(this.root,[...this.path,e]);return new Proxy(l,t)}return l}set(t,e,l){return NodeGroupManager.get(this.root).changes.push(new Change("set",this.root,[...this.path,e],l)),Reflect.set(t,e,l)}}class Change{constructor(t,e,l,s,i=null){this.action=t,this.root=e,this.path=l,this.value=s,this.beforeTemplate=i,this.transformerInfo=[];for(let t=this.path.length;t>0;t--){let e=this.path.slice(0,t),l=getObjectHash([this.root,...e]);this.transformerInfo.push(...pathToTransformer.getAll(l))}}}let logGets=!1,gets=[],withinSet=0;function watch(t,...e){if(!e.length)return t?.$proxyHandler?t:new Proxy(t,new ProxyHandler(t));{let l={};for(let s of e)l[s]=t[s],Object.defineProperty(t,s,{get:()=>new Proxy(t,new ProxyHandler(t,[],l))[s],set(t){return watch(this)[s]=t}})}}class ProxyHandler{serializedPath;constructor(t,e=[],l=null){this.root=t,this.path=e,this.props=l}getSerializedPath(t=null){return this.serializedPath||(this.serializedPath=JSON.stringify([getObjectId(this.root),...this.path.map((t=>t+""))])),null!==t?this.serializedPath.slice(0,-1)+',"'+t+'"]':this.serializedPath}extend(t){t+="",assert(!this.root.$proxyHandler);let e=new ProxyHandler(this.root,[...this.path,t],this.props);return this.serializedPath&&(e.serializedPath=this.getSerializedPath(t)),e}get(t,e){if("$proxyHandler"===e)return this;if("$removeProxy"===e)return delve(this.props||this.root,this.path);if("map"===e&&Array.isArray(t)){let e=NodeGroupManager.get(this.root);return e.clearSubscribersIfNeeded(),l=>{let s,i=[],r=t=>{let r=[];for(let n=0;t.length>n;n++){let o=this.extend(n),h=t[n];h.$proxyHandler||(h=new Proxy(h,o));let a=l(h,n,t);r.push(a);let f=this.getSerializedPath(n),u=new Subscriber(l,a);u.parent=s,e.subscribers.add(f,u),i.push([f,u])}return new Template(["",""],[r])};withinSet||(s=new Subscriber(r,null,l));let n=r(t);return withinSet||(s.template=n,s.children=i,e.subscribers.add(this.getSerializedPath(),s)),n}}if("splice"!==e&&"fastSplice"!==e||!Array.isArray(t)){if("indexOf"===e&&Array.isArray(t))return e=>t.indexOf(e.$removeProxy||e);{let l=Reflect.get(t===this.root&&this.props?this.props:t,e);if(logGets&&gets.push([this.root,...this.path,e]),l&&"object"==typeof l){let t=this.extend(e);return new Proxy(l,t)}return l}}{let l=NodeGroupManager.get(this.root);return(s,i,...r)=>{let n=r.length-i,o=t.length;if(i)for(let t=s;s+i>t;t++){let e=this.getSerializedPath(t);for(let t of l.subscribers.data[e]||[]){let e=t.template.nodeGroup;for(let t of e.getNodes())t.remove();l.nodeGroupsAvailable.delete(e.exactKey,e)}delete l.subscribers.data[e]}if(n){let t=this.getSerializedPath(),h=[...l.subscribers.getAll(t)][0],a=t=>{let s=t+n,i=this.getSerializedPath(t),r=this.getSerializedPath(s),o=l.subscribers.data[i];if(delete l.subscribers.data[i],l.subscribers.data[r]=o,"splice"===e){let e=delve(this.root,this.path);for(let l of o){let i=l.template.nodeGroup,r=getProxy(e[t],this,this.path,s),n=h.itemTransformer(r,s).exprs;i.applyExprs(n)}}};if(n>0)for(let t=o-1;t>=s+r.length+i;t--)a(t);else for(let t=s+r.length+i;o>t;t++)a(t)}if(r.length){let t=this.getSerializedPath(),e=this.getSerializedPath(s),l=NodeGroupManager.get(this.root);for(let n of l.subscribers.getAll(t)){let t=o-i>s?[...l.subscribers.getAll(e)].map((t=>t.template.nodeGroup.startNode)):[n.template.nodeGroup.endNode];for(let e of t)for(let t=0;r.length>t;t++){let i=this.extend(s+t);assert(!r[t].$proxyHandler);let o=new Proxy(r[t],i),h=n.itemTransformer(o),a=l.getNodeGroup(h,null,!0);for(let t of a.getNodes())e.parentNode.insertBefore(t,e);let f=i.getSerializedPath(),u=new Subscriber(n.itemTransformer,h);u.parent=n,l.subscribers.add(f,u)}n.template.nodeGroup.parentPath.clearNodesCache(),n.template.nodeGroup.nodesCache=null}}return t.splice(s,i,...r)}}}set(t,e,l){withinSet++;let s=Reflect.set(t===this.root&&this.props?this.props:t,e,l),i=[...this.path,e+""];return this.notify(i),withinSet--,s}notify(t,e=new Set){let l=NodeGroupManager.get(this.root),s=getObjectId(this.root),i=t.length;for(;i>=1;){let r=t.slice(0,i),n=delve(this.root,r),o=JSON.stringify([s,...r]);for(let t of l.subscribers.getAll(o)){if(e.has(t))continue;if(t.children){for(let[e,s]of t.children)l.subscribers.delete(e,s);t.children=void 0}let s=getProxy(n,this,r),i=t.transformer(s).exprs;for(let e of t.template.nodeGroup.paths)e.clearNodesCache();t.template.nodeGroup.applyExprs(i),t.parent&&e.add(t.parent)}i--}}}function getProxy(t,e,l,s){return t}function watchFunction(t,e){e.clearSubscribersIfNeeded(),logGets=!0;let l=()=>new Template(["",""],[t()]),s=l();for(let t of gets){let i=new Subscriber(l,s);e.subscribers.add(serializePath(t),i)}return gets=[],logGets=!1,s}class Subscriber{parent;children;constructor(t,e,l=null){this.transformer=t,this.template=e,this.itemTransformer=l}}class NodeGroup{manager;parentPath;startNode;endNode;paths=[];exactKey;closeKey;inUse;nodesCache;styles;pseudoRoot;currentComponentProps={};constructor(t,e=null){this.template=t,this.manager=e,t.nodeGroup=this;let l=Shell.get(t.html),s=l.fragment.cloneNode(!0),i="boolean"==typeof t.replaceMode?t.replaceMode:1===s.children.length&&s.firstElementChild?.tagName.replace(/-REDCOMPONENT-PLACEHOLDER$/,"")===e?.rootEl?.tagName;i&&(this.pseudoRoot=s.firstElementChild);let r=i?s.firstElementChild.childNodes:s.childNodes;this.startNode=r[0],this.endNode=r[r.length-1];for(let t of l.paths){let e=t.clone(s);e.parentNg=this,this.paths.push(e)}this.activateEmbeds(s,l),this.applyExprs(t.exprs)}activateEmbeds(root,shell){for(let t of shell.staticComponents){let e=resolveNodePath(root,t);e.tagName!==this.pseudoRoot?.tagName&&this.createNewComponent(e)}if(this.manager.rootEl){if(!1!==this.manager.options.ids)for(let t of shell.ids){let e=resolveNodePath(root,t),l=e.getAttribute("data-id")||e.getAttribute("id");this.manager.rootEl[l]=e}if(!1!==this.manager.options.styles){shell.styles.length&&(this.styles=new Map);for(let t of shell.styles){let e=resolveNodePath(root,t);Util.bindStyles(e,this.manager.rootEl),this.styles.set(e,e.textContent)}}if(!1!==this.manager.options.scripts)for(let path of shell.scripts){let script=resolveNodePath(root,path);eval(script.textContent)}}}updateStyles(){if(this.styles)for(let[t,e]of this.styles)e!==t.textContent&&Util.bindStyles(t,this.manager.rootEl)}applyExprs(t){let e,l,s=t.length-1;for(let i of this.paths.toReversed()){if(e=t[s],i.type===PathType.Content)this.applyNodeExpr(i,e);else{let r=i.nodeMarker,n=this.manager.rootEl&&r===this.pseudoRoot?this.manager.rootEl:r;l&&l!==this.pseudoRoot&&l!==r&&Object.keys(this.currentComponentProps).length&&(this.applyComponentExprs(l,this.currentComponentProps),this.currentComponentProps={}),i.type===PathType.Multiple?i.applyMultipleAttribs(n,e):i.nodeMarker!==this.pseudoRoot&&i.type===PathType.Component?this.currentComponentProps[i.attrName]=e:i.type===PathType.Comment||(null===i.attrValue&&("function"==typeof e||Array.isArray(e))&&isEvent(i.attrName)?i.applyEventAttrib(n,e,this.manager.rootEl||this.startNode.parentNode):s=i.applyValueAttrib(n,t,s)),l=i.nodeMarker}s--}l&&l!==this.pseudoRoot&&Object.keys(this.currentComponentProps).length&&(this.applyComponentExprs(l,this.currentComponentProps),this.currentComponentProps={}),this.updateStyles(),this.nodesCache=null}applyNodeExpr(t,e){let l=[],s=t.nodeGroups,i=[];t.nodeGroups=[],this.applyOneExpr(e,t,l,i),this.existingTextNodes=null;let r=!1;if(i.length){for(let[e,s]of i){let i=this.manager.getNodeGroup(l[e],!1);i.parentPath=t;let n=i.getNodes();1===n.length?l[e]=n[0]:(l[e]=n,r=!0),t.nodeGroups[s]=i}r&&(l=l.flat())}let n=t.getNodes();t.nodesCache=l,!1!==findArrayDiff(n,l)&&(this.parentPath&&this.parentPath.clearNodesCache(),n.length&&!l.length&&t.fastClear(n,l)||udomdiff(t.parentNode,n,l,t.nodeMarker),this.saveOrphans(s,n))}saveOrphans(t,e){let l=new Map;for(let e of t)l.set(e.startNode,e);for(let t,s=0;t=e[s];s++){let i;if(!t.parentNode&&(i=l.get(t))){let l=document.createDocumentFragment(),r=i.endNode;for(;t!==r;)l.append(t),s++,t=e[s];l.append(r)}}}applyOneExpr(t,e,l,s){if(t instanceof Template){t.parentPath=e,t.nodegroup=this;let i=this.manager.getNodeGroup(t,!0);i?(l.push(...i.getNodes()),e.nodeGroups.push(i)):(s.push([l.length,e.nodeGroups.length]),l.push(t),e.nodeGroups.push(null))}else if(t instanceof Node)t instanceof DocumentFragment?l.push(...t.childNodes):l.push(t);else if(Array.isArray(t))for(let i of t)this.applyOneExpr(i,e,l,s);else if("function"==typeof t)t=watchFunction(t,this.manager),this.applyOneExpr(t,e,l,s);else{let s=void 0===t||!1===t||null===t?"":t+"",i=e.nodeBefore.nextSibling;if(3!==i.nodeType||i.nextSibling!==e.nodeMarker||l.includes(i)){this.existingTextNodes||(this.existingTextNodes=e.getNodes().filter((t=>3===t.nodeType)));let t=this.existingTextNodes.findIndex((t=>t.textContent===s));-1!==t?l.push(...this.existingTextNodes.splice(t,1)):l.push(e.parentNode.ownerDocument.createTextNode(s))}else i.textContent!==s&&(i.textContent=s),l.push(i)}}applyComponentExprs(t,e){let l=getObjectHash(e),s=t.tagName.endsWith("-REDCOMPONENT-PLACEHOLDER"),i=t.hasAttribute("_is");s||i?t=this.createNewComponent(t,s,e):t.render&&componentHash.get(t)!==l&&t.render(e),componentHash.set(t,l)}createNewComponent(t,e=void 0,l=void 0){void 0===e&&(e=!t.hasAttribute("_is"));let s=(e?t.tagName.endsWith("-REDCOMPONENT-PLACEHOLDER")?t.tagName.slice(0,-25):t.tagName:t.getAttribute("is")).toLowerCase(),i={...l||{}};if(t.attributes.length){l||(l={});for(let e of t.attributes)l.hasOwnProperty(e.name)||(l[e.name]=e.value)}let r=customElements.get(s);if(!r)throw Error(`The custom tag name ${s} is not registered.`);let n=[...t.childNodes];NodeGroupManager.pendingChildren.push(n);let o=new r(l,n);e||o.setAttribute("is",t.getAttribute("is").toLowerCase()),t.replaceWith(o);for(let t in l){let e=l[t];t.startsWith("on")&&"function"==typeof e&&o.addEventListener(t.slice(2),(t=>e(t,o)))}let h=t.getAttribute("data-id")||t.getAttribute("id");h&&(this.manager.rootEl[h]=o);for(let e of this.paths)e.nodeMarker===t&&(e.nodeMarker=o),e.nodeBefore===t&&(e.nodeBefore=o);this.startNode===t&&(this.startNode=o),this.endNode===t&&(this.endNode=o),o.renderFirstTime&&o.renderFirstTime();for(let e of t.attributes)"_is"!==e.name&&o.setAttribute(e.name,e.value);for(let t in i){let e=i[t];"boolean"==typeof e?!1!==e&&null!=e&&o.setAttribute(t,""):["number","bigint","string"].includes(typeof e)&&o.setAttribute(t,e)}return o}getNodes(){let t=this.nodesCache;if(t)return t;t=[];let e=this.startNode,l=this.endNode?.nextSibling;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.nodesCache=t,t}getParentNode(){return this.startNode?.parentNode}}let componentHash=new WeakMap;class NodeGroupManager{rootEl;rootNg;changes=[];nodeGroupsAvailable=new MultiValueMap;nodeGroupsInUse=[];options={};constructor(t=null){this.rootEl=t}render(t,e={}){if(this.mutationWatcherEnabled=!1,this.options=e,this.clearSubscribers=!1,!t&&""!==t)return this.rootEl.outerHTML="",this.mutationWatcherEnabled=!0,null;if(1!==t.html?.length||t.html[0]){let e,l=this.getNodeGroup(t,!0);l||(e=this.getNodeGroup(t,!1));let s=!this.rootNg;this.rootNg=l||e;let i=this.rootNg.getParentNode();if(this.rootEl){if(s){let t;if(this.rootEl.childNodes.length&&(t=document.createDocumentFragment(),t.append(...this.rootEl.childNodes)),i instanceof DocumentFragment?this.rootEl.append(i):i&&this.rootEl.append(...i.childNodes),t){for(let e of this.rootEl.querySelectorAll("slot[name]")){let l=e.getAttribute("name");l&&e.append(...t.querySelectorAll(`[slot='${l}']`))}let e=this.rootEl.querySelector("slot:not([name])");e&&e.append(t)}}}else this.rootEl=i;let r=this.rootNg;if(r.pseudoRoot&&r.pseudoRoot!==this.rootEl&&s)for(let t of r.pseudoRoot.attributes)this.rootEl.hasAttribute(t.name)||this.rootEl.setAttribute(t.name,t.value);this.reset()}else this.rootEl.innerHTML="";return this.mutationWatcherEnabled=!0,this.rootEl}findAndDeleteExact(t,e=!0,l=void 0){let s=this.nodeGroupsAvailable.delete(t,l);if(s){let t=this.nodeGroupsAvailable.delete(s.closeKey,s);if(this.nodeGroupsInUse.push(s),s.inUse=!0,t.inUse=!0,e){let t=s;for(;t=t?.parentPath?.parentNg;)if(!t.inUse){t.inUse=!0;let e=this.nodeGroupsAvailable.delete(t.exactKey,t);this.nodeGroupsAvailable.delete(t.closeKey,t),e&&this.nodeGroupsInUse.push(t)}}for(let t of s.paths)for(let e of t.nodeGroups)e.inUse||this.findAndDeleteExact(e.exactKey,!1,e),e.inUse=!0;return s}return null}findAndDeleteClose(t,e,l=!0){let s=this.nodeGroupsAvailable.delete(t);if(s){if(this.nodeGroupsAvailable.delete(s.exactKey,s),s.inUse=!0,l){let t=s;for(;t=t?.parentPath?.parentNg;)if(!t.inUse){t.inUse=!0;let e=this.nodeGroupsAvailable.delete(t.exactKey,t);e=this.nodeGroupsAvailable.delete(t.closeKey,t)}}s.exactKey=e,s.closeKey=t,this.nodeGroupsInUse.push(s)}return s}getNodeGroup(t,e=null,l=!1){let s,i=getObjectHash(t);if(!0===e){if(s=this.findAndDeleteExact(i),!s)return null}else{let e=t.getCloseKey();s=l?null:this.findAndDeleteClose(e,i),s?(window.debug&&!window.ng&&(window.ng=s),s.applyExprs(t.exprs)):(s=new NodeGroup(t,this),s.exactKey=i,s.closeKey=e,l?this.nodeGroupsAvailable.add(s.exactKey,s):this.nodeGroupsInUse.push(s))}return s.parentPath&&(s.parentPath=null),s}reset(){let t=this.nodeGroupsAvailable;for(let e of this.nodeGroupsInUse)e.inUse=!1,t.add(e.exactKey,e),t.add(e.closeKey,e);this.nodeGroupsInUse=[],this.changes=[]}clearSubscribers=!1;getLoopInfo(t){let e=serializePath(t);return[...this.pathToLoopInfo.getAll(e)]}pathToLoopInfo=new MultiValueMap;subscribers=new MultiValueMap;clearSubscribersIfNeeded(){this.clearSubscribers&&(this.pathToLoopInfo=new MultiValueMap,this.subscribers=new MultiValueMap,this.clearSubscribers=!1)}static get(t){let e=nodeGroupManagers.get(t);return e||(e=new NodeGroupManager(t),nodeGroupManagers.set(t,e)),e}}NodeGroupManager.pendingChildren=[];let nodeGroupManagers=new WeakMap;class LoopInfo{constructor(t,e){this.template=t,this.itemTransformer=e}}function r(t=void 0,...e){if(Array.isArray(t))return new Template(t,e);if(!(t instanceof Node)){if("string"==typeof t||t instanceof String){t.match(/^\s^</)&&(t=t.trim());let e=document.createElement("template");return e.innerHTML=t,1===e.content.childNodes.length?e.content.firstChild:e.content}if(void 0===t)return(t,...e)=>r(t,...e).toNode();if(t instanceof Template)return(new NodeGroupManager).render(t);if("function"==typeof t){let e=t,l=e();if("string"==typeof l)throw Error(`Please add the "r" prefix before the string "${l}"`);let s=new NodeGroupManager;l.replaceMode=!0;let i=s.render(l);return i.render=(()=>{l=e(),s.render(l)}).bind(i),i}throw Error("Unsupported arguments.")}{let l=t,s=e[0];if(e[0]instanceof Template)NodeGroupManager.get(l).render(s,e[1]),!l.childNodes.length&&this&&l.append(this.rootNg.getParentNode());else{if(!e.length||e[0]){l.shadowRoot&&(l.innerHTML="");let t=e[0];return(e,...s)=>{rendered.add(l);let i=r(e,...s);return NodeGroupManager.get(l).render(i,t)}}NodeGroupManager.get(l).render(null,e[1])}}}let rendered=new WeakSet;function defineClass(t,e,l){if(!customElements.getName(t)){(e=e||camelToDashes(t.name)).includes("-")||(e+="-element");let s=null;l&&(s={extends:l}),customElements.define(e,t,s)}}let elementClasses={},connected=new WeakSet;function createSolarite(t=null){let e=HTMLElement;t&&!t.includes("-")&&(t=t.toLowerCase(),e=elementClasses[t],e||(e=document.createElement(t).constructor,elementClasses[t]=e));let l=new Proxy(e,{construct:(e,l,s)=>(defineClass(s,null,t),Reflect.construct(e,l,s))});return class extends l{onConnect=Util$1.callback();onFirstConnect=Util$1.callback();onDisconnect=Util$1.callback();constructor(t={}){super(),!0===t.render?this.render():!1===t.render&&rendered.add(this);let e=NodeGroupManager.pendingChildren.pop();e&&(this.querySelector("slot")||this).append(...e),Object.defineProperty(this,"html",{set(e){rendered.add(this),"string"==typeof e?(console.warn("Assigning to this.html without the r template prefix."),this.innerHTML=e):this.modifications=r(this,e,t)}})}renderFirstTime(){!rendered.has(this)&&this.render&&this.render()}connectedCallback(){this.renderFirstTime(),connected.has(this)||(connected.add(this),this.onFirstConnect()),this.onConnect()}disconnectedCallback(){this.onDisconnect()}static define(e=null){defineClass(this,e,t)}renderWatched(){let t=NodeGroupManager.get(this),e=[];for(let l of t.changes)if("set"===l.action)for(let s of l.transformerInfo){let l=s.hash,i=delve(watchSet(s.path[0]),s.path.slice(1)),r=s.transformer(i),n=getObjectHash(r),o=[...t.nodeGroupsAvailable.data[l]];for(let t of o)e.push([t,l,n,r.exprs,s])}else if("delete"===l.action)for(let e of l.value){let l=[...t.nodeGroupsAvailable.getAll(e)];for(let t of l){t.parentPath&&t.parentPath.clearNodesCache();for(let e of t.getNodes())e.remove()}}else if("insert"===l.action){let e=l.beforeTemplate?t.getNodeGroup(l.beforeTemplate,!0):null,s=[l.root,...l.path];for(let i of t.getLoopInfo([l.root,...l.path.slice(0,-1)])){let r=e?.startNode||i.template.parentPath.nodeMarker,n=0;for(let o of l.value){let l=i.itemTransformer,o=watchGet([...s.slice(0,-1),1*s.at(-1)+n+""],l);n++;let h=t.getNodeGroup(o,!1,!0);h.parentPath=e?.parentPath||i.template.parentPath;for(let t of h.getNodes())r.parentNode.insertBefore(t,r);h.parentPath&&h.parentPath.clearNodesCache()}}}for(let[l,s,i,r,n]of e)l.applyExprs(r),t.nodeGroupsAvailable.data[s].delete(l),l.exactKey=n.hash=i,t.nodeGroupsAvailable.add(l.exactKey,l);return t.changes=[],[]}getArg(t,e=null,l=ArgType.String){return getArg(this,t,e,l)}}}let Solarite=new Proxy(createSolarite(),{apply:(t,e,l)=>createSolarite(...l)});export{ArgType,Solarite,forEach,getArg,r,watch,watchGet,watchSet};
3
+ // http://vorticode.github.io/solarite
4
+ var Util$1={callback(...t){var e=!1;let l=async(...t)=>{let s=[];if(!e)for(let e=0;l.length>e;e++)s.push(l[e](...t));return await Promise.all(s)};l[Symbol.iterator]=()=>{let t=0;return{next(){return l.length>t?{value:l[t++],done:!1}:{done:!0}}}};for(let t of Object.getOwnPropertyNames(Array.prototype))"length"!==t&&"constructor"!==t&&(l[t]=Array.prototype[t]);l.l=0,Object.defineProperty(l,"length",{get:()=>l.l,set(t){l.l=t}}),l.remove=t=>{let e=l.findIndex((e=>e===t));-1!==e&&l.splice(e,1)},l.pause=()=>e=!0,l.resume=()=>e=!1;for(let e of t)l.push(e);return l}};function delve(t,e,l=delveDontCreate){let s=l!==delveDontCreate,i=e.length;if(!t&&!s&&i)return;let o=0;for(let r of e){if(void 0===t[r]){if(!s)return;i-1>o&&(t[r]=(e[o+1]+"").match(/^\d+$/)?[]:{})}s&&o===i-1&&(t[r]=l),t=t[r],o++}return t}let delveDontCreate={};function getArg(el,name,val=null,type=ArgType.String){let attrVal=el.getAttribute(name);if(null!==attrVal&&(val=attrVal),Array.isArray(type))return type.includes(val)?val:void 0;if("function"==typeof type)return type(val);if(type===ArgType.Bool){let t="string"==typeof val?val.toLowerCase():val;return!["false","0",!1,0,null,void 0].includes(t)}switch(type){case ArgType.Int:return parseInt(val);case ArgType.Float:return parseFloat(val);case ArgType.String:return[void 0,null,!1].includes(val)?"":val+"";case ArgType.JSON:case ArgType.Eval:if("string"!=typeof val||!val.length)return val;try{return type===ArgType.JSON?JSON.parse(val):eval(`(${val})`)}catch(t){return val}default:return val}}var ArgType={Bool:"Bool",Int:"Int",Float:"Float",String:"String",JSON:"JSON",Eval:"Eval"};let lastObjectId=1,objectIds=new WeakMap;function getObjectId(t){let e=objectIds.get(t);return e||(e=lastObjectId++,objectIds.set(t,e)),e}let isHashing=!0;function toJSON(){return isHashing?getObjectId(this):this}function getObjectHash(t){let e;isHashing=!0;try{e=JSON.stringify(t)}catch(l){e=getObjectHashCircular(t)}return isHashing=!1,e}function getObjectHashCircular(t){const e=new Set;return JSON.stringify(t,((t,l)=>{if("object"==typeof l&&null!==l){if(e.has(l))return getObjectId(l);e.add(l)}return l}))}Node.prototype.toJSON!==toJSON&&(Node.prototype.toJSON=toJSON,(()=>{}).toJSON!==toJSON&&(Function.prototype.toJSON=toJSON));var Globals={componentHash:new WeakMap,connected:new WeakSet,rendered:new WeakSet,currentExprPath:[],elementClasses:{},nodeEvents:new WeakMap,nodeGroups:new WeakMap,objToEl:new WeakMap,pendingChildren:[],rendering:new WeakSet,shells:new WeakMap};let Util={bindStyles(t,e){let l=e.getAttribute("data-style");l||(e.constructor.styleId||(e.constructor.styleId=1),l=e.constructor.styleId++,e.setAttribute("data-style",l));let s=e.tagName.toLowerCase();for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,i=t.replace(/:host(?=[^a-z0-9_])/gi,s+'[data-style="'+l+'"]');t!==i&&(e.textContent=i)}},*flatten(t){if(Array.isArray(t))for(const e of t)yield*Util.flatten(e);else if("function"==typeof t){const e=t();yield*Util.flatten(e)}else yield t},getInputValue:t=>"checkbox"===t.type||"radio"===t.type?t.checked:"file"===t.type?[...t.files]:"number"===t.type||"range"===t.type?t.valueAsNumber:"date"===t.type||"time"===t.type||"datetime-local"===t.type?t.valueAsDate:"select-multiple"===t.type?[...t.selectedOptions].map((t=>t.value)):t.value,isPath:t=>Array.isArray(t)&&"object"==typeof t[0]&&!t.slice(1).find((t=>"string"!=typeof t&&"number"!=typeof t)),saveOrphans(t,e){let l=new Map;for(let e of t)l.set(e.startNode,e);for(let t,s=0;t=e[s];s++){let i;if(!t.parentNode&&(i=l.get(t))){let l=document.createDocumentFragment(),o=i.endNode;for(;t!==o;)l.append(t),s++,t=e[s];l.append(o)}}},trimEmptyNodes(t){const e=t=>t.nodeType!==Node.ELEMENT_NODE&&(t.nodeType!==Node.TEXT_NODE||""===t.textContent.trim()),l=[...t];for(;l.length>0&&e(l[0]);)l.shift();for(;l.length>0&&e(l[l.length-1]);)l.pop();return l}},div=document.createElement("div"),isEvent=t=>t.startsWith("on")&&t in div;function camelToDashes(t){return(t=(t=(t=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2")).replace(/([A-Z])([A-Z][a-z])/g,"$1-$2")).replace(/([a-zA-Z])([0-9])/g,"$1-$2")).toLowerCase()}function arraySame(t,e){let l=t.length;if(l!==e.length)return!1;for(let s=0;l>s;s++)if(t[s]!==e[s])return!1;return!0}function htmlContext(t){if(null===t)return state={...defaultState},state.context;for(let e=0;t.length>e;e++){const l=t[e];switch(state.context){case htmlContext.Text:"<"===l&&t[e+1].match(/[a-z!]/i)&&(state.context=htmlContext.Tag,state.buffer="");break;case htmlContext.Tag:if(">"===l)state.context=htmlContext.Text,state.quote=null,state.buffer="";else{if(" "===l&&!state.buffer)continue;" "===l||"/"===l||"?"===l?state.buffer="":'"'===l||"'"===l||"="===l?(state.context=htmlContext.Attribute,state.quote="="===l?null:l,state.buffer=""):state.buffer+=l}break;case htmlContext.Attribute:state.quote||state.buffer.length||'"'!==l&&"'"!==l?l===state.quote||!state.quote&&state.buffer.length?(state.context=htmlContext.Tag,state.quote=null,state.buffer=""):state.quote||">"!==l?" "!==l&&(state.buffer+=l):(state.context=htmlContext.Text,state.quote=null,state.buffer=""):state.quote=l}}return state.context}htmlContext.Attribute="Attribute",htmlContext.Text="Text",htmlContext.Tag="Tag";let defaultState={context:htmlContext.Text,quote:null,buffer:"",lastChar:null},state={...defaultState};class MultiValueMap{data={};add(t,e){let l=this.data,s=l[t];s||(s=new Set,l[t]=s),s.add(e)}isEmpty(){for(let t in this.data)return!0;return!1}getAll(t){return this.data[t]||[]}delete(t,e=void 0){let l,s=this.data,i=s[t];if(i)return void 0===e?([l]=i,i.delete(l)):(i.delete(e),l=e),0===i.size&&delete s[t],l}hasValue(t){let e=this.data,l=[];for(let s in e)e[s].has(t)&&l.push(s);return l}}const udomdiff=(t,e,l,s)=>{const i=l.length;let o=e.length,r=i,n=0,a=0,h=null;for(;o>n||r>a;)if(o===n){const e=i>r?a?l[a-1].nextSibling:l[r-a]:s;for(;r>a;){let s=l[a++];t.insertBefore(s,e)}}else if(r===a)for(;o>n;){let l=e[n];h&&h.has(l)||t.removeChild(l),n++}else if(e[n]===l[a])n++,a++;else if(e[o-1]===l[r-1])o--,r--;else if(e[n]===l[r-1]&&l[a]===e[o-1]){const s=e[--o].nextSibling;let i=l[a++],h=e[n++];t.insertBefore(i,h.nextSibling);let f=l[--r];t.insertBefore(f,s),e[o]=l[r]}else{if(!h){h=new Map;let t=a;for(;r>t;)h.set(l[t],t++)}if(h.has(e[n])){const s=h.get(e[n]);if(s>a&&r>s){let i=n,f=1;for(;++i<o&&r>i&&h.get(e[i])===s+f;)f++;if(f>s-a){const i=e[n];for(;s>a;){let e=l[a++];t.insertBefore(e,i)}}else{let s=e[n++],i=l[a++];t.replaceChild(i,s)}}else n++}else{let l=e[n++];t.removeChild(l)}}return l};class ExprPath{type;attrName;attrValue;attrNames;nodeBefore;nodeMarker;parentNg;nodeGroups=[];nodesCache;nodeBeforeIndex;nodeMarkerPath;constructor(t,e,l=PathType.Content,s=null,i=null){this.nodeBefore=t,this.nodeMarker=e,this.type=l,this.attrName=s,this.attrValue=i,l===PathType.Multiple&&(this.attrNames=new Set)}apply(t,e=null,l=0,s={}){switch(this.type){case 1:this.applyNodes(t);break;case 2:this.applyMultipleAttribs(this.nodeMarker,t);break;case 5:break;case 6:this.applyEventAttrib(this.nodeMarker,t,this.parentNg.rootNg.root);break;default:4===this.type&&this.nodeMarker!==this.parentNg.rootNg.root?s[this.attrName]=t:l=this.applyValueAttrib(this.nodeMarker,e||[t],l)}return l}applyNodes(t){let e=this,l=[],s=e.nodeGroups,i=[];e.nodeGroups=[],e.applyExact(t,l,i),this.existingTextNodes=null;let o=!1;if(i.length){for(let[t,s]of i){let i=e.getNodeGroup(l[t],!1),r=i.getNodes();1===r.length?l[t]=r[0]:(l[t]=r,o=!0),e.nodeGroups[s]=i}o&&(l=l.flat())}let r=e.getNodes();arraySame(r,l)||(e.nodesCache=l,this.parentNg.parentPath&&this.parentNg.parentPath.clearNodesCache(),r.length&&!l.length&&e.fastClear()||udomdiff(e.nodeMarker.parentNode,r,l,e.nodeMarker),Util.saveOrphans(s,r)),e.freeNodeGroups()}applyExact(t,e,l){if(t instanceof Template){let s=this.getNodeGroup(t,!0);s?(e.push(...s.getNodes()),this.nodeGroups.push(s)):(l.push([e.length,this.nodeGroups.length]),e.push(t),this.nodeGroups.push(null))}else if(t instanceof Node)t instanceof DocumentFragment?e.push(...t.childNodes):e.push(t);else if(Array.isArray(t))for(let s of t)this.applyExact(s,e,l);else if("function"==typeof t){Globals.currentExprPath=[this,t];let s=t();Globals.currentExprPath=null,this.applyExact(s,e,l)}else{let l=void 0===t||!1===t||null===t?"":t+"",s=this.nodeBefore.nextSibling;if(3!==s.nodeType||s.nextSibling!==this.nodeMarker||e.includes(s)){this.existingTextNodes||(this.existingTextNodes=this.getNodes().filter((t=>3===t.nodeType)));let t=this.existingTextNodes.findIndex((t=>t.textContent===l));-1!==t?e.push(...this.existingTextNodes.splice(t,1)):e.push(this.nodeMarker.ownerDocument.createTextNode(l))}else s.textContent!==l&&(s.textContent=l),e.push(s)}}applyMultipleAttribs(t,e){Array.isArray(e)&&(e=e.flat().join(" "));let l=this.attrNames;if(this.attrNames=new Set,e){let l=(e+"").split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g).map((t=>t.trim())).filter((t=>t.length));for(let e of l){let[l,s]=e.split(/\s*=\s*/);s=(s||"").replace(/^(['"])(.*)\1$/,"$2"),t.setAttribute(l,s),this.attrNames.add(l)}}for(let e of l)this.attrNames.has(e)||t.removeAttribute(e)}applyEventAttrib(t,e,l){let s,i=this.attrName.slice(2),o=[];Array.isArray(e)?"function"==typeof e[0]?(s=e[0],o=e.slice(1)):(s=setValue,o=[e[0],e.slice(1),t],t.value=delve(e[0],e.slice(1))):s=e;let r=Globals.nodeEvents.get(t);r||(r={[i]:[,,,]},Globals.nodeEvents.set(t,r));let n=r[i];if(n[0]!==s){let[e,o,r]=n;e&&t.removeEventListener(i,o);let a=s,h=e=>a.call(l,...n[2],e,t);n[0]=a,n[1]=h,t.addEventListener(i,h)}r[i][2]=o}applyValueAttrib(t,e,l){let s=e[l];if(this.attrValue||!1!==s&&null!=s)if(this.attrValue||!0!==s)if("value"!==this.attrName&&"data-value"!==this.attrName||!Util.isPath(s)){let i=[];if(this.attrValue){for(let t=this.attrValue.length-1;t>=0;t--)if(i.unshift(this.attrValue[t]),t>0){let t=e[l];!1!==t&&null!=t&&i.unshift(t),l--}l++}else i.unshift(s);let o=i.join("");("value"===this.attrName?t.value:t.getAttribute(this.attrName))!==o&&t.setAttribute(this.attrName,o),this.attrName in t&&(t[this.attrName]=o)}else{let[e,l]=[s[0],s.slice(1)];t.value=delve(e,l),t.addEventListener("input",(()=>{delve(e,l,Util.getInputValue(t))}),!0)}else t.setAttribute(this.attrName,"");else t.removeAttribute(this.attrName);return l}clone(t,e=0){let l,s,i=t,o=e?this.nodeMarkerPath.slice(0,-e):this.nodeMarkerPath;for(let t=o.length-1;t>0;t--)i=i.childNodes[o[t]];let r=i.childNodes;return l=o.length?r[o[0]]:t,this.nodeBefore&&(s=r[this.nodeBeforeIndex]),new ExprPath(s,l,this.type,this.attrName,this.attrValue)}clearNodesCache(){let t=this,e=this.nodeMarker.parentNode;for(;t&&t.nodeMarker.parentNode===e;)t.nodesCache=null,t=t.parentNg?.parentPath}fastClear(){let t=this.nodeBefore.parentNode;return this.nodeBefore===t.firstChild&&this.nodeMarker===t.lastChild&&(t.innerHTML="",t.append(this.nodeBefore,this.nodeMarker),!0)}getNodes(){let t;if(t=this.nodesCache,t)return t;t=[];let e=this.nodeBefore.nextSibling,l=this.nodeMarker;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.nodesCache=t,t}getParentNode(){return this.nodeMarker.parentNode}getNodeGroup(t,e=!0){let l;if(e){if(l=this.nodeGroupsFree.delete(t.getExactKey()),!l)return null;this.nodeGroupsFree.delete(t.getCloseKey(),l)}else l=this.nodeGroupsFree.delete(t.getCloseKey()),l&&(this.nodeGroupsFree.delete(l.exactKey,l),l.applyExprs(t.exprs),l.exactKey=t.getExactKey());return l||(l=new NodeGroup(t,this)),this.nodeGroupsInUse.push(l),l}nodeGroupsInUse=[];nodeGroupsFree=new MultiValueMap;freeNodeGroups(){let t=this.nodeGroupsFree;for(let e of this.nodeGroupsInUse)t.add(e.exactKey,e),t.add(e.closeKey,e);this.nodeGroupsInUse=[]}}function setValue(t,e,l){let s=l.value;"number"===l.type&&(s=parseFloat(s)),delve(t,e,s)}const PathType={Content:1,Multiple:2,Value:3,Component:4,Comment:5,Event:6};function getNodePath(t){let e=[];for(;;){let l=t.parentNode;if(!l)break;e.push([].indexOf.call(t.parentNode.childNodes,t)),t=l}return e}function resolveNodePath(t,e){for(let l=e.length-1;l>=0;l--)t=t.childNodes[e[l]];return t}class Shell{fragment;paths=[];events=[];ids=[];scripts=[];styles=[];staticComponents=[];constructor(t=null){if(!t)return;let e=[],l="\x3c!--!✨!--\x3e",s={};htmlContext(null);for(let i=0;t.length>i;i++){let o=t[i],r=htmlContext(o);if(r===htmlContext.Attribute){let t,e;if(o.replace(/<[a-z][a-z0-9]*-[a-z0-9-]+/gi,((l,s)=>{t=s+1,e=l.slice(1)})),e){let l=e+"-solarite-placeholder";o=o.slice(0,t)+l+o.slice(t+e.length),s[e]=l}}e.push(o),t.length-1>i&&e.push(r===htmlContext.Text?l:String.fromCharCode(57344+i))}let i,o=document.createElement("template"),r=e.join("");for(let t in s)r=r.replaceAll(`</${t}>`,`</${s[t]}>`);r?o.innerHTML=r:o.content.append(document.createTextNode("")),this.fragment=o.content;let n=[];const a=document.createTreeWalker(o.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;i=a.nextNode();)if(n.map((t=>t.remove())),n=[],1===i.nodeType)for(let t of[...i.attributes]){let e=t.name.match(/^[\ue000-\uf8ff]$/);if(e)this.paths.push(new ExprPath(null,i,PathType.Multiple)),i.removeAttribute(e[0]);else{let e=t.value.split(/[\ue000-\uf8ff]/g);if(e.length>1){let l=2!==e.length||e[0].length||e[1].length?e:null,s=isEvent(t.name)?PathType.Event:PathType.Value;this.paths.push(new ExprPath(null,i,s,t.name,l)),i.setAttribute(t.name,e.join(""))}}}else if(i.nodeType===Node.COMMENT_NODE&&"!✨!"===i.nodeValue){let t,e=i.previousSibling;e||(e=document.createComment("ExprPath:"+this.paths.length),i.parentNode.insertBefore(e,i)),!i.nextSibling||8===i.nextSibling.nodeType&&"!✨!"===i.nextSibling.textContent?(t=i,t.textContent="ExprPathEnd:"+this.paths.length):(t=i.nextSibling,n.push(i));let l=new ExprPath(e,t,PathType.Content);this.paths.push(l)}else if(i.nodeType===Node.COMMENT_NODE){let t=i.textContent.split(/[\ue000-\uf8ff]/g);for(let e=0;t.length-1>e;e++){let t=new ExprPath(i.previousSibling,i);t.type=PathType.Comment,this.paths.push(t)}}else if(i.nodeType===Node.TEXT_NODE&&["SCRIPT","STYLE"].includes(i.parentNode?.nodeName)){let t=i.textContent.split(l);if(t.length>1){let e=[];for(let l=0;t.length>l;l++){let s=document.createTextNode(t[l]);i.parentNode.insertBefore(s,i),l>0&&e.push(s)}for(let t,l=0;t=e[l];l++){let e=new ExprPath(t.previousSibling,t,PathType.Content);this.paths.push(e)}n.push(i)}}n.map((t=>t.remove()));for(let t of this.fragment.querySelectorAll("[is]"))t.setAttribute("_is",t.getAttribute("is"));for(let t of this.paths)t.nodeBefore&&(t.nodeBeforeIndex=[].indexOf.call(t.nodeBefore.parentNode.childNodes,t.nodeBefore)),t.nodeMarkerPath=getNodePath(t.nodeMarker),t.type===PathType.Value&&1===t.nodeMarker.nodeType&&(t.nodeMarker.tagName.includes("-")||t.nodeMarker.hasAttribute("is"))&&(t.type=PathType.Component);this.findEmbeds()}findEmbeds(){this.scripts=[].map.call(this.fragment.querySelectorAll("scripts"),(t=>getNodePath(t))),this.styles=[].map.call(this.fragment.querySelectorAll("style"),(t=>getNodePath(t)));let t=this.fragment.querySelectorAll("[id],[data-id]");for(let e of t){let t=e.getAttribute("data-id")||e.getAttribute("id");if(div.hasOwnProperty(t))throw Error(`<${e.tagName.toLowerCase()} id="${t}"> can't override existing HTMLElement id property.`)}this.ids=[].map.call(t,(t=>getNodePath(t)));for(let t of this.fragment.querySelectorAll("*")){for(let e of t.attributes)isEvent(e.name)&&this.events.push([e.name,getNodePath(t)]);(t.tagName.includes("-")||t.hasAttribute("_is"))&&(this.paths.find((e=>e.nodeMarker===t))||this.staticComponents.push(getNodePath(t)))}}static get(t){let e=Globals.shells.get(t);return e||(e=new Shell(t),Globals.shells.set(t,e)),e}}class NodeGroup{rootNg;parentPath;startNode;endNode;paths=[];exactKey;closeKey;nodesCache;styles;currentComponentProps={};constructor(t,e=null){if(!(this instanceof RootNodeGroup)){let[l,s]=this.init(t,e);this.updatePaths(l,s.paths),this.activateEmbeds(l,s),this.applyExprs(t.exprs)}}init(t,e=null,l=null,s=null){this.exactKey=l||t.getExactKey(),this.closeKey=s||t.getCloseKey(),this.parentPath=e,this.rootNg=e?.parentNg?.rootNg||this,this.template=t,t.nodeGroup=this;let i=Shell.get(t.html),o=i.fragment.cloneNode(!0),r=o.childNodes;return this.startNode=r[0],this.endNode=r[r.length-1],[o,i]}applyExprs(t,e=null){e=e||this.paths;let l,s,i=t.length-1;for(let o of e.toReversed())l=t[i],s&&s!==this.rootNg.root&&s!==o.nodeMarker&&Object.keys(this.currentComponentProps).length&&(this.applyComponentExprs(s,this.currentComponentProps),this.currentComponentProps={}),i=o.apply(l,t,i,this.currentComponentProps),s=o.nodeMarker,i--;s&&s!==this.rootNg.root&&Object.keys(this.currentComponentProps).length&&(this.applyComponentExprs(s,this.currentComponentProps),this.currentComponentProps={}),this.updateStyles(),this.nodesCache=null}applyComponentExprs(t,e){let l=getObjectHash(e),s=t.tagName.endsWith("-SOLARITE-PLACEHOLDER"),i=t.hasAttribute("_is");s||i?t=this.createNewComponent(t,s,e):t.render&&Globals.componentHash.get(t)!==l&&t.render(e),Globals.componentHash.set(t,l)}createNewComponent(t,e=void 0,l=void 0){void 0===e&&(e=!t.hasAttribute("_is"));let s=(e?t.tagName.endsWith("-SOLARITE-PLACEHOLDER")?t.tagName.slice(0,-21):t.tagName:t.getAttribute("is")).toLowerCase(),i={...l||{}};if(t.attributes.length){l||(l={});for(let e of t.attributes)l.hasOwnProperty(e.name)||(l[e.name]=e.value)}let o=customElements.get(s);if(!o)throw Error(`The custom tag name ${s} is not registered.`);let r=[...t.childNodes];Globals.pendingChildren.push(r);let n=new o(l,r);e||n.setAttribute("is",t.getAttribute("is").toLowerCase()),t.replaceWith(n);for(let t in l){let e=l[t];if(t.startsWith("on")&&"function"==typeof e&&n.addEventListener(t.slice(2),(t=>e(t,n))),("value"===t||"data-value"===t)&&Util.isPath(e)){let[t,l]=[e[0],e.slice(1)];n.value=delve(t,l),n.addEventListener("input",(e=>{delve(t,l,Util.getInputValue(n))}),!0)}}let a=t.getAttribute("data-id")||t.getAttribute("id");a&&delve(this.getRootNode(),a.split(/\./g),n);for(let e of this.paths)e.nodeMarker===t&&(e.nodeMarker=n),e.nodeBefore===t&&(e.nodeBefore=n);this.startNode===t&&(this.startNode=n),this.endNode===t&&(this.endNode=n),n.renderFirstTime&&n.renderFirstTime();for(let e of t.attributes)"_is"!==e.name&&n.setAttribute(e.name,e.value);for(let t in i){let e=i[t];"boolean"==typeof e?!1!==e&&null!=e&&n.setAttribute(t,""):["number","bigint","string"].includes(typeof e)&&n.setAttribute(t,e)}return n}getNodes(){let t=this.nodesCache;if(t)return t;t=[];let e=this.startNode,l=this.endNode?.nextSibling;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.nodesCache=t,t}getParentNode(){return this.startNode?.parentNode}getRootNode(){return this.rootNg.root}getRootNodeGroup(){return this.rootNg}updatePaths(t,e,l){this.paths.length=e.length;for(let s=0;e.length>s;s++){let i=e[s].clone(t,l);i.parentNg=this,this.paths[s]=i}}updateStyles(){if(this.styles)for(let[t,e]of this.styles)e!==t.textContent&&Util.bindStyles(t,this.getRootNodeGroup().root)}activateEmbeds(root,shell,pathOffset=0){for(let t of shell.staticComponents){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);root!==e&&this.createNewComponent(e)}let rootEl=this.rootNg.root;if(rootEl){if(!1!==this.options?.ids)for(let t of shell.ids){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t),l=e.getAttribute("data-id")||e.getAttribute("id");if(l){if(rootEl[l]&&!(rootEl[l]instanceof Node))throw Error(`${rootEl.constructor.name}.${l} already has a value. Can't set it as a reference to <${e.tagName.toLowerCase()} id="${l}">`);delve(rootEl,l.split(/\./g),e)}}if(!1!==this.options?.styles){shell.styles.length&&(this.styles=new Map);for(let t of shell.styles){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);Util.bindStyles(e,rootEl),this.styles.set(e,e.textContent)}}if(!1!==this.options?.scripts)for(let path of shell.scripts){pathOffset&&(path=path.slice(0,-pathOffset));let script=resolveNodePath(root,path);eval(script.textContent)}}}}class RootNodeGroup extends NodeGroup{root;constructor(t,e,l){super(t),this.options=l,this.rootNg=this;let[s,i]=this.init(t),o=0,r=s;if(e){let t;if(e.childNodes.length&&(t=document.createDocumentFragment(),t.append(...e.childNodes)),this.root=e,isReplaceEl(s,e)){e.append(...s.children[0].childNodes);for(let t of s.children[0].attributes)e.hasAttribute(t.name)||e.setAttribute(t.name,t.value);o=1}else 1===s.childNodes.length&&3===s.childNodes[0].nodeType&&""===s.childNodes[0].textContent||e.append(...s.childNodes);if(t){for(let l of e.querySelectorAll("slot[name]")){let e=l.getAttribute("name");if(e){let s=t.querySelectorAll(`[slot='${e}']`);l.append(...s)}}let l=e.querySelector("slot:not([name])");l?l.append(t):e.append(t)}r=e,this.startNode=e,this.endNode=e}else{let t=getSingleEl(s);this.root=t||s,t&&(r=t,o=1)}this.updatePaths(r,i.paths,o),this.activateEmbeds(r,i,o),this.applyExprs(t.exprs)}}function getSingleEl(t){let e=[];for(let l of t.childNodes)if(1===l.nodeType||3===l.nodeType&&l.textContent.trim().length){if(e.length)return null;e.push(l)}return e[0]}function isReplaceEl(t,e){return e.tagName.includes("-")&&1===t.children.length&&t.children[0].tagName.replace("-SOLARITE-PLACEHOLDER","")===e.tagName}class Template{exprs=[];html=[];hashedFields;parentPath;nodeGroup;paths=[];constructor(t,e){this.html=t,this.exprs=e}toJSON(){return this.hashedFields||(this.hashedFields=[getObjectId(this.html),this.exprs]),this.hashedFields}render(t=null,e={}){let l,s=!1;return t?(l=Globals.nodeGroups.get(t),l||(l=new RootNodeGroup(this,t,e),Globals.nodeGroups.set(t,l),s=!0)):(l=new RootNodeGroup(this,null,e),t=l.getRootNode(),Globals.nodeGroups.set(t,l),s=!0),s||(1!==this.html?.length||this.html[0]?l.applyExprs(this.exprs):t.innerHTML=""),t}getExactKey(){return this.exactKey||(this.exactKey=getObjectHash(this)),this.exactKey}getCloseKey(){return this.closeKey||(this.closeKey="@"+this.toJSON()[0]),this.closeKey}}function r(t=void 0,...e){if(!(t instanceof Node)){if(Array.isArray(t))return new Template(t,e);if("string"==typeof t||t instanceof String){t.match(/^\s^</)&&(t=t.trim());let e=document.createElement("template");e.innerHTML=t;let l=Util.trimEmptyNodes(e.content.childNodes);return 1===l.length?l[0]:e.content}if(void 0===t)return(t,...e)=>r(t,...e).render();if(t instanceof Template)return t.render();if("object"==typeof t){let e=t;if(Globals.objToEl.has(e))return((...t)=>{let l=r(...t).render();Globals.objToEl.set(e,l)}).bind(e);{Globals.objToEl.set(e,null),e.render();let t=Globals.objToEl.get(e);Globals.objToEl.delete(e);for(let l in e)t[l]="function"==typeof e[l]?e[l].bind(t):e[l];return t}}throw Error("Unsupported arguments.")}{let l=t,s=e[0];if(!(e[0]instanceof Template)){l.shadowRoot&&(l.innerHTML="");let t=e[0],s=(e,...s)=>(Globals.rendered.add(l),new Template(e,s).render(l,t));return s}if(!(e[0]instanceof Template))throw Error("unsupported");s.render(l,e[1]),!l.childNodes.length&&this&&l.append(this.rootNg.getParentNode())}}function defineClass(t,e,l){if(!customElements.getName(t)){(e=e||camelToDashes(t.name)).includes("-")||(e+="-element");let s=null;l&&(s={extends:l}),customElements.define(e,t,s)}}function createSolarite(t=null){let e=HTMLElement;t&&!t.includes("-")&&(t=t.toLowerCase(),e=Globals.elementClasses[t],e||(e=document.createElement(t).constructor,Globals.elementClasses[t]=e));let l=new Proxy(e,{construct:(e,l,s)=>(defineClass(s,null,t),Reflect.construct(e,l,s))});return class extends l{onConnect=Util$1.callback();onFirstConnect=Util$1.callback();onDisconnect=Util$1.callback();constructor(t={}){super(),!0===t.render?this.render():!1===t.render&&Globals.rendered.add(this);let e=Globals.pendingChildren.pop();e&&(this.querySelector("slot")||this).append(...e),Object.defineProperty(this,"html",{set(e){Globals.rendered.add(this),"string"==typeof e?(console.warn("Assigning to this.html without the r template prefix."),this.innerHTML=e):this.modifications=r(this,e,t)}})}renderFirstTime(){!Globals.rendered.has(this)&&this.render&&this.render()}connectedCallback(){this.renderFirstTime(),Globals.connected.has(this)||(Globals.connected.add(this),this.onFirstConnect()),this.onConnect()}disconnectedCallback(){this.onDisconnect()}static define(e=null){defineClass(this,e,t)}}}let Solarite=new Proxy(createSolarite(),{apply:(t,e,l)=>createSolarite(...l)}),getInputValue=Util.getInputValue;export{ArgType,Globals,Solarite,Template,delve,getArg,getInputValue,r};
@@ -0,0 +1,18 @@
1
+ The below license is for the udomdiff library, used by Solarite.js.
2
+ https://github.com/WebReflection/udomdiff/tree/main
3
+ -------------
4
+ ISC License
5
+
6
+ Copyright (c) 2020, Andrea Giammarchi, @WebReflection
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted, provided that the above
10
+ copyright notice and this permission notice appear in all copies.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.