@livenetworks/ashlar 2.0.5 → 2.0.7

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 (38) hide show
  1. package/components/ln-accordion/ln-accordion.js +1 -1
  2. package/components/ln-accordion/src/ln-accordion.js +1 -0
  3. package/components/ln-couchdb-connector/README.md +4 -0
  4. package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
  5. package/components/ln-couchdb-connector/src/ln-couchdb-connector.js +18 -1
  6. package/components/ln-data-coordinator/ln-data-coordinator.js +1 -1
  7. package/components/ln-data-coordinator/src/ln-data-coordinator.js +15 -6
  8. package/components/ln-data-store/README.md +3 -2
  9. package/components/ln-data-store/ln-data-store.js +1 -1
  10. package/components/ln-data-store/src/data-store-model.js +29 -0
  11. package/components/ln-data-store/src/ln-data-store.js +57 -10
  12. package/components/ln-date/README.md +4 -0
  13. package/components/ln-date/ln-date.js +1 -1
  14. package/components/ln-date/src/ln-date.js +3 -3
  15. package/components/ln-fill/README.md +14 -11
  16. package/components/ln-fill/ln-fill.js +1 -1
  17. package/components/ln-fill/src/ln-fill.js +0 -6
  18. package/components/ln-list/ln-list.js +1 -1
  19. package/components/ln-list/src/ln-list.js +4 -4
  20. package/components/ln-modal/README.md +33 -14
  21. package/components/ln-modal/ln-modal.js +1 -1
  22. package/components/ln-modal/ln-modal.schema.json +8 -1
  23. package/components/ln-modal/src/ln-modal.js +39 -8
  24. package/components/ln-options/ln-options.js +1 -1
  25. package/components/ln-options/src/ln-options.js +1 -0
  26. package/components/ln-popover/README.md +4 -0
  27. package/components/ln-popover/ln-popover.js +1 -1
  28. package/components/ln-popover/src/ln-popover.js +9 -0
  29. package/components/ln-table/ln-table.js +1 -1
  30. package/components/ln-table/src/ln-table.js +2 -0
  31. package/components/ln-table-coordinator/ln-table-coordinator.js +1 -1
  32. package/components/ln-table-coordinator/src/ln-table-coordinator.js +3 -3
  33. package/components/ln-tabs/README.md +2 -2
  34. package/components/ln-tabs/ln-tabs.js +1 -1
  35. package/components/ln-tabs/src/ln-tabs.js +1 -0
  36. package/ln-ashlar.html-data.json +9 -1
  37. package/package.json +1 -1
  38. package/web-types.json +7 -3
@@ -1 +1 @@
1
- (function(){"use strict";function O(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function p(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let o=null;for(let r=1;r<t.length;r++)if(t[r]&&t[r].nodeType===1){o=t[r];break}if(!p(o))return}e.apply(console,t)}}function x(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function h(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){h(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}const E={};function B(e,t){E[e]=t}function W(e){return E[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=B,window.lnCore.getDataMapper=W);function j(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,h(function(){new MutationObserver(function(){x(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const L={};function N(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];L[n]=t}function V(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return L[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=N,window.lnCore.getLocaleFallback=V,window.lnCore.ensureLocaleObserver=j);const C={};function H(e,t){C[e]||(C[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=C[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function T(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let l=0;l<n.length;l++){const c=n[l],s=c.getAttribute("data-ln-field");t[s]!=null&&(c.textContent=t[s])}const o=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<o.length;l++){const c=o[l],s=c.getAttribute("data-ln-attr").split(",");for(let d=0;d<s.length;d++){const a=s[d].trim().split(":");if(a.length!==2)continue;const u=a[0].trim(),f=a[1].trim();t[f]!=null&&c.setAttribute(u,t[f])}}const r=e.querySelectorAll("[data-ln-show]");for(let l=0;l<r.length;l++){const c=r[l],s=c.getAttribute("data-ln-show");s in t&&c.classList.toggle("hidden",!t[s])}const i=e.querySelectorAll("[data-ln-class]");for(let l=0;l<i.length;l++){const c=i[l],s=c.getAttribute("data-ln-class").split(",");for(let d=0;d<s.length;d++){const a=s[d].trim().split(":");if(a.length!==2)continue;const u=a[0].trim(),f=a[1].trim();f in t&&c.classList.toggle(u,!!t[f])}}return e}function U(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)T(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function $(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const i=n.currentNode;i.textContent.indexOf("{{")!==-1&&(i.textContent=i.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,c){return t[c]!==void 0?t[c]:""}))}const o=function(i,l){return t[l]!==void 0?t[l]:""},r=Array.from(e.querySelectorAll("*"));e.nodeType===1&&r.push(e);for(let i=0;i<r.length;i++){const l=r[i],c=l.attributes;for(let s=0;s<c.length;s++){const d=c[s];d.value.indexOf("{{")!==-1&&l.setAttribute(d.name,d.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function Q(e,t,n,o,r,i){const l={};for(let s=0;s<e.children.length;s++){const d=e.children[s],a=d.getAttribute("data-ln-render-key");a&&(l[a]=d)}const c=document.createDocumentFragment();for(let s=0;s<t.length;s++){const d=t[s],a=String(o(d));let u=l[a];if(u)r(u,d,s);else{const f=H(n,i);if(!f||($(f,d),u=f.firstElementChild,!u))continue;u.setAttribute("data-ln-render-key",a),r(u,d,s)}c.appendChild(u)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=$,window.lnCore.fill=T,window.lnCore.lnFill=U,window.lnCore.renderList=Q);function D(e,t,n,o,r){if(!e||t===null)return!0;const i=o||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const c=s=>{r?console.warn(s,r):console.warn(s)};if(l==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(c(`[${i}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const s=e.values||[];return s.includes(t)?!0:(c(`[${i}] Invalid value "${t}" for attribute "${n}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return c(`[${i}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(c(`[${i}] Value ${s} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(c(`[${i}] Value ${s} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(c(`[${i}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(s){return c(`[${i}] Invalid JSON for attribute "${n}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function K(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function G(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function y(e,t,n,o){if(e.nodeType!==1)return;const i=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(i));e.matches&&e.matches(i)&&l.push(e);for(const c of l)if(!c[n]){window.lnCore._persistSink&&c.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(c,t);try{c[n]=new o(c)}catch(s){console.error("["+n+"] init failed",c,s)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function J(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function P(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function I(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function X(e){const t=I(),n=e.observed||[];for(let o=0;o<n.length;o++){const r=n[o];t.byAttr.has(r)||t.byAttr.set(r,[]),t.byAttr.get(r).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const r=t.byDeclaredAttr.get(o);r.some(i=>i.componentTag===e.componentTag)||r.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=G(e);if(o===null)t.reactiveWildcard.push(e);else for(const r of o)t.byReactive.has(r)||t.byReactive.set(r,[]),t.byReactive.get(r).push(e)}e.persist&&t.persist.push(e)}function q(e,t,n,o){for(let r=0;r<e.length;r++){const i=e[r];if(!t[i.attribute])continue;const l=i.effects&&i.effects[n];l?l(t,n,o):i.onAttrChange&&(!i.declared||i.declared.has(n))&&i.onAttrChange(t,n,o)}}function z(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=I(),r=o.byAttr.get(n);if(O()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&p(t)){const i=o.byDeclaredAttr.get(n),l=t.getAttribute(n);for(let c=0;c<i.length;c++)D(i[c].spec,l,n,i[c].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||r)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const i=o.byReactive.get(n);i&&q(i,t,n,e.oldValue),o.reactiveWildcard.length&&q(o.reactiveWildcard,t,n,e.oldValue)}if(r)for(let i=0;i<r.length;i++){const l=r[i];if(l.handler){l.handler(t,n,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,n):(y(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function Y(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,h(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{z(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function R(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function Z(e){const t=R();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const r=o.query,i=e.target.nodeType===1?e.target.matches(r)?e.target:e.target.closest(r):e.target.parentElement?e.target.parentElement.closest(r):null;i&&o.onSubtreeChange(i,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let r=0;r<t.length;r++){const i=t[r];y(o,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let r=0;r<t.length;r++){const i=t[r],l=i.query,c=Array.from(o.querySelectorAll(l));o.matches&&o.matches(l)&&c.push(o);for(let s=0;s<c.length;s++){const d=c[s];if(!document.contains(d)){const a=d[i.attribute];if(a&&typeof a.destroy=="function")try{a.destroy()}catch(u){console.error("["+i.attribute+"] destroy failed",d,u)}delete d[i.attribute]}}}}}}function ee(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,h(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{Z(o)}catch(r){console.error("[ln-core] lifecycle handler failed",o.target,r)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function te(e,t,n,o,r={}){const i=r.extraAttributes||[],l=r.onAttributeChange||null,c=r.onSubtreeChange||null,s=r.onInit||null,d=r.onAttrChange||null,a=r.effects||null,u=r.attributes||null,f=u?K(u):a,ue=u?new Set(Object.keys(u)):null,ae=r.persist||null;function g(_){const w=_||document.body;if(y(w,e,t,n),u&&O())for(const b in u){const we=u[b],v=Array.from(w.querySelectorAll("["+b+"]"));w.matches&&w.matches("["+b+"]")&&v.push(w);for(let S=0;S<v.length;S++){const k=v[S];p(k)&&D(we,k.getAttribute(b),b,o,k)}}s&&s(w)}const A=[];if(e.indexOf("[")!==-1){const _=/\[([\w-]+)/g;let w;for(;(w=_.exec(e))!==null;)A.push(w[1])}else A.push(e);X({selector:e,attribute:t,componentTag:o,attributes:u,ComponentFn:n,onInit:s,observed:A.concat(i),onAttributeChange:l,onAttrChange:d,effects:f,declared:ue,persist:ae}),Y();const fe=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";R().push({selector:e,attribute:t,ComponentFn:n,onInit:s,onSubtreeChange:c,query:fe}),ee(),window[t]=g;function M(){J()>0?P(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M):M(),g}function F(e){return(e||"").replace(/^#/,"")}function m(e){const t=e===void 0?location.hash:e,n={},o=F(t);if(!o)return n;const r=o.split("&");for(let i=0;i<r.length;i++){const l=r[i];if(!l)continue;const c=l.indexOf(":"),s=c>-1?l.slice(0,c):l,d=c>-1?l.slice(c+1):"";if(s)try{n[s]=decodeURIComponent(d)}catch{n[s]=d}}return n}function ne(e){if(!e)return null;const t=m();return e in t?t[e]:null}function oe(e,t){if(!e)return;const n=m();t==null?delete n[e]:n[e]=String(t);const r=Object.keys(n).map(function(i){const l=n[i];return l===""?i:i+":"+encodeURIComponent(l)}).join("&");F(location.hash)!==r&&(location.hash=r)}function re(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function ie(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function se(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function ce(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function de(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),r=o?o.split(",").map(function(i){try{return decodeURIComponent(i)}catch{return i}}).filter(Boolean):[];return{key:n,values:r}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=m,window.lnCore.hashGet=ne,window.lnCore.hashSet=oe,window.lnCore.hashLinkClick=re,window.lnCore.resolveHashNamespace=ie,window.lnCore.hashSortEncode=le,window.lnCore.hashSortDecode=se,window.lnCore.hashFilterEncode=ce,window.lnCore.hashFilterDecode=de),(function(){const e="data-ln-accordion",t="lnAccordion";if(window[t]!==void 0)return;const n={"data-ln-accordion":{type:"marker",description:"Identifies container as an accordion that coordinates single-panel expansion"}};function o(r){return this.dom=r,this._onToggleOpen=function(i){if(i.detail.target.closest("[data-ln-accordion]")!==r)return;const l=r.querySelectorAll("[data-ln-toggle]");for(const c of l)c!==i.detail.target&&c.closest("[data-ln-accordion]")===r&&c.getAttribute("data-ln-toggle")==="open"&&c.setAttribute("data-ln-toggle","close");x(r,"ln-accordion:change",{target:i.detail.target})},r.addEventListener("ln-toggle:open",this._onToggleOpen),this}o.prototype.destroy=function(){this.dom[t]&&(this.dom.removeEventListener("ln-toggle:open",this._onToggleOpen),delete this.dom[t])},te(e,t,o,"ln-accordion",{attributes:n})})()})();
1
+ (function(){"use strict";function O(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function p(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let o=null;for(let i=1;i<t.length;i++)if(t[i]&&t[i].nodeType===1){o=t[i];break}if(!p(o))return}e.apply(console,t)}}function x(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function h(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){h(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}const E={};function B(e,t){E[e]=t}function W(e){return E[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=B,window.lnCore.getDataMapper=W);function j(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,h(function(){new MutationObserver(function(){x(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const L={};function N(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];L[n]=t}function V(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return L[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=N,window.lnCore.getLocaleFallback=V,window.lnCore.ensureLocaleObserver=j);const C={};function H(e,t){C[e]||(C[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=C[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function T(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let l=0;l<n.length;l++){const c=n[l],s=c.getAttribute("data-ln-field");t[s]!=null&&(c.textContent=t[s])}const o=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<o.length;l++){const c=o[l],s=c.getAttribute("data-ln-attr").split(",");for(let d=0;d<s.length;d++){const a=s[d].trim().split(":");if(a.length!==2)continue;const u=a[0].trim(),f=a[1].trim();t[f]!=null&&c.setAttribute(u,t[f])}}const i=e.querySelectorAll("[data-ln-show]");for(let l=0;l<i.length;l++){const c=i[l],s=c.getAttribute("data-ln-show");s in t&&c.classList.toggle("hidden",!t[s])}const r=e.querySelectorAll("[data-ln-class]");for(let l=0;l<r.length;l++){const c=r[l],s=c.getAttribute("data-ln-class").split(",");for(let d=0;d<s.length;d++){const a=s[d].trim().split(":");if(a.length!==2)continue;const u=a[0].trim(),f=a[1].trim();f in t&&c.classList.toggle(u,!!t[f])}}return e}function U(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)T(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function $(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const r=n.currentNode;r.textContent.indexOf("{{")!==-1&&(r.textContent=r.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,c){return t[c]!==void 0?t[c]:""}))}const o=function(r,l){return t[l]!==void 0?t[l]:""},i=Array.from(e.querySelectorAll("*"));e.nodeType===1&&i.push(e);for(let r=0;r<i.length;r++){const l=i[r],c=l.attributes;for(let s=0;s<c.length;s++){const d=c[s];d.value.indexOf("{{")!==-1&&l.setAttribute(d.name,d.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function Q(e,t,n,o,i,r){const l={};for(let s=0;s<e.children.length;s++){const d=e.children[s],a=d.getAttribute("data-ln-render-key");a&&(l[a]=d)}const c=document.createDocumentFragment();for(let s=0;s<t.length;s++){const d=t[s],a=String(o(d));let u=l[a];if(u)i(u,d,s);else{const f=H(n,r);if(!f||($(f,d),u=f.firstElementChild,!u))continue;u.setAttribute("data-ln-render-key",a),i(u,d,s)}c.appendChild(u)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=$,window.lnCore.fill=T,window.lnCore.lnFill=U,window.lnCore.renderList=Q);function D(e,t,n,o,i){if(!e||t===null)return!0;const r=o||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const c=s=>{i?console.warn(s,i):console.warn(s)};if(l==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(c(`[${r}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const s=e.values||[];return s.includes(t)?!0:(c(`[${r}] Invalid value "${t}" for attribute "${n}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return c(`[${r}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(c(`[${r}] Value ${s} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(c(`[${r}] Value ${s} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(c(`[${r}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(s){return c(`[${r}] Invalid JSON for attribute "${n}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function K(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function G(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function y(e,t,n,o){if(e.nodeType!==1)return;const r=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(r));e.matches&&e.matches(r)&&l.push(e);for(const c of l)if(!c[n]){window.lnCore._persistSink&&c.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(c,t);try{c[n]=new o(c)}catch(s){console.error("["+n+"] init failed",c,s)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function J(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function P(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function I(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function X(e){const t=I(),n=e.observed||[];for(let o=0;o<n.length;o++){const i=n[o];t.byAttr.has(i)||t.byAttr.set(i,[]),t.byAttr.get(i).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const i=t.byDeclaredAttr.get(o);i.some(r=>r.componentTag===e.componentTag)||i.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=G(e);if(o===null)t.reactiveWildcard.push(e);else for(const i of o)t.byReactive.has(i)||t.byReactive.set(i,[]),t.byReactive.get(i).push(e)}e.persist&&t.persist.push(e)}function q(e,t,n,o){for(let i=0;i<e.length;i++){const r=e[i];if(!t[r.attribute])continue;const l=r.effects&&r.effects[n];l?l(t,n,o):r.onAttrChange&&(!r.declared||r.declared.has(n))&&r.onAttrChange(t,n,o)}}function z(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=I(),i=o.byAttr.get(n);if(O()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&p(t)){const r=o.byDeclaredAttr.get(n),l=t.getAttribute(n);for(let c=0;c<r.length;c++)D(r[c].spec,l,n,r[c].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||i)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const r=o.byReactive.get(n);r&&q(r,t,n,e.oldValue),o.reactiveWildcard.length&&q(o.reactiveWildcard,t,n,e.oldValue)}if(i)for(let r=0;r<i.length;r++){const l=i[r];if(l.handler){l.handler(t,n,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,n):(y(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function Y(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,h(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{z(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function R(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function Z(e){const t=R();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const i=o.query,r=e.target.nodeType===1?e.target.matches(i)?e.target:e.target.closest(i):e.target.parentElement?e.target.parentElement.closest(i):null;r&&o.onSubtreeChange(r,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let i=0;i<t.length;i++){const r=t[i];y(o,r.selector,r.attribute,r.ComponentFn),r.onInit&&r.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let i=0;i<t.length;i++){const r=t[i],l=r.query,c=Array.from(o.querySelectorAll(l));o.matches&&o.matches(l)&&c.push(o);for(let s=0;s<c.length;s++){const d=c[s];if(!document.contains(d)){const a=d[r.attribute];if(a&&typeof a.destroy=="function")try{a.destroy()}catch(u){console.error("["+r.attribute+"] destroy failed",d,u)}delete d[r.attribute]}}}}}}function ee(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,h(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{Z(o)}catch(i){console.error("[ln-core] lifecycle handler failed",o.target,i)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function te(e,t,n,o,i={}){const r=i.extraAttributes||[],l=i.onAttributeChange||null,c=i.onSubtreeChange||null,s=i.onInit||null,d=i.onAttrChange||null,a=i.effects||null,u=i.attributes||null,f=u?K(u):a,ue=u?new Set(Object.keys(u)):null,ae=i.persist||null;function g(_){const w=_||document.body;if(y(w,e,t,n),u&&O())for(const b in u){const we=u[b],v=Array.from(w.querySelectorAll("["+b+"]"));w.matches&&w.matches("["+b+"]")&&v.push(w);for(let S=0;S<v.length;S++){const k=v[S];p(k)&&D(we,k.getAttribute(b),b,o,k)}}s&&s(w)}const A=[];if(e.indexOf("[")!==-1){const _=/\[([\w-]+)/g;let w;for(;(w=_.exec(e))!==null;)A.push(w[1])}else A.push(e);X({selector:e,attribute:t,componentTag:o,attributes:u,ComponentFn:n,onInit:s,observed:A.concat(r),onAttributeChange:l,onAttrChange:d,effects:f,declared:ue,persist:ae}),Y();const fe=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";R().push({selector:e,attribute:t,ComponentFn:n,onInit:s,onSubtreeChange:c,query:fe}),ee(),window[t]=g;function M(){J()>0?P(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M):M(),g}function F(e){return(e||"").replace(/^#/,"")}function m(e){const t=e===void 0?location.hash:e,n={},o=F(t);if(!o)return n;const i=o.split("&");for(let r=0;r<i.length;r++){const l=i[r];if(!l)continue;const c=l.indexOf(":"),s=c>-1?l.slice(0,c):l,d=c>-1?l.slice(c+1):"";if(s)try{n[s]=decodeURIComponent(d)}catch{n[s]=d}}return n}function ne(e){if(!e)return null;const t=m();return e in t?t[e]:null}function oe(e,t){if(!e)return;const n=m();t==null?delete n[e]:n[e]=String(t);const i=Object.keys(n).map(function(r){const l=n[r];return l===""?r:r+":"+encodeURIComponent(l)}).join("&");F(location.hash)!==i&&(location.hash=i)}function re(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function ie(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function se(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function ce(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function de(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),i=o?o.split(",").map(function(r){try{return decodeURIComponent(r)}catch{return r}}).filter(Boolean):[];return{key:n,values:i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=m,window.lnCore.hashGet=ne,window.lnCore.hashSet=oe,window.lnCore.hashLinkClick=re,window.lnCore.resolveHashNamespace=ie,window.lnCore.hashSortEncode=le,window.lnCore.hashSortDecode=se,window.lnCore.hashFilterEncode=ce,window.lnCore.hashFilterDecode=de),(function(){const e="data-ln-accordion",t="lnAccordion";if(window[t]!==void 0)return;const n={"data-ln-accordion":{type:"marker",description:"Identifies container as an accordion that coordinates single-panel expansion"}};function o(i){return this.dom=i,this._onToggleOpen=function(r){if(!r.detail||!r.detail.target||r.detail.target.closest("[data-ln-accordion]")!==i)return;const l=i.querySelectorAll("[data-ln-toggle]");for(const c of l)c!==r.detail.target&&c.closest("[data-ln-accordion]")===i&&c.getAttribute("data-ln-toggle")==="open"&&c.setAttribute("data-ln-toggle","close");x(i,"ln-accordion:change",{target:r.detail.target})},i.addEventListener("ln-toggle:open",this._onToggleOpen),this}o.prototype.destroy=function(){this.dom[t]&&(this.dom.removeEventListener("ln-toggle:open",this._onToggleOpen),delete this.dom[t])},te(e,t,o,"ln-accordion",{attributes:n})})()})();
@@ -17,6 +17,7 @@ import { dispatch, registerComponent } from '../../ln-core';
17
17
  this.dom = dom;
18
18
 
19
19
  this._onToggleOpen = function (e) {
20
+ if (!e.detail || !e.detail.target) return;
20
21
  if (e.detail.target.closest('[data-ln-accordion]') !== dom) return;
21
22
  const toggles = dom.querySelectorAll('[data-ln-toggle]');
22
23
  for (const el of toggles) {
@@ -177,3 +177,7 @@ Ingress: every fetched/created/updated document gets `id = _id` before reaching
177
177
  ### Envelope unwrap
178
178
 
179
179
  Same `{message, content}` presence-check as `ln-api-connector` (see its README) — `content` replaces the bare CouchDB body when present, `message` rides opaquely on the `:created`/`:updated`/`:deleted`/`:bulk-deleted` event detail. Raw CouchDB never sends this envelope, so a direct CouchDB backend never toasts; only a proxy/gateway that wraps responses can opt in.
180
+
181
+ ### Async Cancellation & Lifecycle (`destroy()`)
182
+
183
+ In `destroy()`, any in-flight delta changes feed fetch (`fetchDelta`) is aborted via an internal `AbortController` (`_deltaController`), and its aborted promise rejection is safely ignored to prevent uncaught errors or stale event dispatches after element teardown. In accordance with offline sync data integrity rules, mutation requests (POST/PUT/DELETE) are not aborted mid-flight to avoid ambiguous states where the remote database commits a write while the client treats it as aborted.
@@ -1 +1 @@
1
- (function(){"use strict";function B(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function L(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let r=null;for(let i=1;i<t.length;i++)if(t[i]&&t[i].nodeType===1){r=t[i];break}if(!L(r))return}e.apply(console,t)}}function v(e,t,n){const r=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function D(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){D(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function S(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function T(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function K(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const N={};function G(e,t){N[e]=t}function Q(e){return N[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=G,window.lnCore.getDataMapper=Q);function z(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const P={};function X(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];P[n]=t}function Y(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return P[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=X,window.lnCore.getLocaleFallback=Y,window.lnCore.ensureLocaleObserver=z);const x={};function Z(e,t){x[e]||(x[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=x[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let c=0;c<n.length;c++){const a=n[c],d=a.getAttribute("data-ln-field");t[d]!=null&&(a.textContent=t[d])}const r=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<r.length;c++){const a=r[c],d=a.getAttribute("data-ln-attr").split(",");for(let w=0;w<d.length;w++){const m=d[w].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();t[y]!=null&&a.setAttribute(g,t[y])}}const i=e.querySelectorAll("[data-ln-show]");for(let c=0;c<i.length;c++){const a=i[c],d=a.getAttribute("data-ln-show");d in t&&a.classList.toggle("hidden",!t[d])}const s=e.querySelectorAll("[data-ln-class]");for(let c=0;c<s.length;c++){const a=s[c],d=a.getAttribute("data-ln-class").split(",");for(let w=0;w<d.length;w++){const m=d[w].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();y in t&&a.classList.toggle(g,!!t[y])}}return e}function ee(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<n.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[r],t??null),n[r].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function H(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const s=n.currentNode;s.textContent.indexOf("{{")!==-1&&(s.textContent=s.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,a){return t[a]!==void 0?t[a]:""}))}const r=function(s,c){return t[c]!==void 0?t[c]:""},i=Array.from(e.querySelectorAll("*"));e.nodeType===1&&i.push(e);for(let s=0;s<i.length;s++){const c=i[s],a=c.attributes;for(let d=0;d<a.length;d++){const w=a[d];w.value.indexOf("{{")!==-1&&c.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function te(e,t,n,r,i,s){const c={};for(let d=0;d<e.children.length;d++){const w=e.children[d],m=w.getAttribute("data-ln-render-key");m&&(c[m]=w)}const a=document.createDocumentFragment();for(let d=0;d<t.length;d++){const w=t[d],m=String(r(w));let g=c[m];if(g)i(g,w,d);else{const y=Z(n,s);if(!y||(H(y,w),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",m),i(g,w,d)}a.appendChild(g)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=H,window.lnCore.fill=M,window.lnCore.lnFill=ee,window.lnCore.renderList=te);function E(e,t,n){const r=e.getAttribute(t);return r===null?n:r}function ne(e,t,n){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?n:r}function re(e,t,n=!1){const r=e.getAttribute(t);if(r===null)return!!n;const i=r.trim().toLowerCase();return!(i==="false"||i==="0")}function oe(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const j=new Map;function ie(e,t){const n=(e?e.join("|"):"")+"::"+t;if(j.has(n))return j.get(n);const r=new Set(e||[]),i=function(s,c){const a=s.getAttribute(c);return a!==null&&r.has(a)?a:t};return j.set(n,i),i}function ce(e,t,n){const r=parseFloat(e.getAttribute(t));return isNaN(r)?n:r}function se(e,t,n){const r=e.getAttribute(t);if(!r)return n;try{return JSON.parse(r)}catch{return n}}function F(e,t,n,r,i){if(!e||t===null)return!0;const s=r||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const a=d=>{i?console.warn(d,i):console.warn(d)};if(c==="boolean"){const d=t.trim().toLowerCase();return d!==""&&d!=="true"&&d!=="false"&&d!=="1"&&d!=="0"?(a(`[${s}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const d=e.values||[];return d.includes(t)?!0:(a(`[${s}] Invalid value "${t}" for attribute "${n}". Allowed: ${d.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return a(`[${s}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const d=parseInt(t,10);return e.min!==void 0&&d<e.min?(a(`[${s}] Value ${d} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&d>e.max?(a(`[${s}] Value ${d} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(a(`[${s}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(d){return a(`[${s}] Invalid JSON for attribute "${n}": ${d.message}. Fallback: ${e.fallback}.`),!1}return!0}function le(e,t,n){for(const r in n){const[i,s,c]=n[r];Object.defineProperty(e,r,{get:function(){return i(t,s,c)},enumerable:!0,configurable:!0})}return e}function ae(e){const t={};for(const n in e){const r=e[n];if(!r||!r.prop)continue;let i=r.read;if(!i&&r.type)switch(r.type){case"enum":i=ie(r.values,r.fallback);break;case"integer":i=ne;break;case"float":i=ce;break;case"boolean":i=re;break;case"list":i=oe;break;case"json":i=se;break;case"string":default:i=E;break}i||(i=E),t[r.prop]=[i,n,r.fallback]}return t}function de(e){const t={};for(const n in e){const r=e[n];r&&r.effect&&(t[n]=r.effect)}return Object.keys(t).length?t:null}function ue(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function I(e,t,n,r){if(e.nodeType!==1)return;const s=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&c.push(e);for(const a of c)if(!a[n]){window.lnCore._persistSink&&a.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(a,t);try{a[n]=new r(a)}catch(d){console.error("["+n+"] init failed",a,d)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function fe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function he(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function W(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function we(e){const t=W(),n=e.observed||[];for(let r=0;r<n.length;r++){const i=n[r];t.byAttr.has(i)||t.byAttr.set(i,[]),t.byAttr.get(i).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const r in e.attributes){t.byDeclaredAttr.has(r)||t.byDeclaredAttr.set(r,[]);const i=t.byDeclaredAttr.get(r);i.some(s=>s.componentTag===e.componentTag)||i.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=ue(e);if(r===null)t.reactiveWildcard.push(e);else for(const i of r)t.byReactive.has(i)||t.byReactive.set(i,[]),t.byReactive.get(i).push(e)}e.persist&&t.persist.push(e)}function U(e,t,n,r){for(let i=0;i<e.length;i++){const s=e[i];if(!t[s.attribute])continue;const c=s.effects&&s.effects[n];c?c(t,n,r):s.onAttrChange&&(!s.declared||s.declared.has(n))&&s.onAttrChange(t,n,r)}}function be(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const r=W(),i=r.byAttr.get(n);if(B()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(n)&&L(t)){const s=r.byDeclaredAttr.get(n),c=t.getAttribute(n);for(let a=0;a<s.length;a++)F(s[a].spec,c,n,s[a].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||i)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const s=r.byReactive.get(n);s&&U(s,t,n,e.oldValue),r.reactiveWildcard.length&&U(r.reactiveWildcard,t,n,e.oldValue)}if(i)for(let s=0;s<i.length;s++){const c=i[s];if(c.handler){c.handler(t,n,e.oldValue);continue}c.onAttributeChange&&t[c.attribute]?c.onAttributeChange(t,n):(I(t,c.selector,c.attribute,c.ComponentFn),c.onInit&&c.onInit(t))}}function pe(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{be(t[n])}catch(r){console.error("[ln-core] mutation handler failed",t[n].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function J(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ge(e){const t=J();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const r=t[n];if(r.onSubtreeChange){const i=r.query,s=e.target.nodeType===1?e.target.matches(i)?e.target:e.target.closest(i):e.target.parentElement?e.target.parentElement.closest(i):null;s&&r.onSubtreeChange(s,e)}}for(let n=0;n<e.addedNodes.length;n++){const r=e.addedNodes[n];if(r.nodeType===1)for(let i=0;i<t.length;i++){const s=t[i];I(r,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(r)}}for(let n=0;n<e.removedNodes.length;n++){const r=e.removedNodes[n];if(r.nodeType===1)for(let i=0;i<t.length;i++){const s=t[i],c=s.query,a=Array.from(r.querySelectorAll(c));r.matches&&r.matches(c)&&a.push(r);for(let d=0;d<a.length;d++){const w=a[d];if(!document.contains(w)){const m=w[s.attribute];if(m&&typeof m.destroy=="function")try{m.destroy()}catch(g){console.error("["+s.attribute+"] destroy failed",w,g)}delete w[s.attribute]}}}}}}function me(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.type==="childList")try{ge(r)}catch(i){console.error("[ln-core] lifecycle handler failed",r.target,i)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Ce(e,t,n,r,i={}){const s=i.extraAttributes||[],c=i.onAttributeChange||null,a=i.onSubtreeChange||null,d=i.onInit||null,w=i.onAttrChange||null,m=i.effects||null,g=i.attributes||null,y=g?de(g):m,$=g?new Set(Object.keys(g)):null,o=i.persist||null;function u(h){const p=h||document.body;if(I(p,e,t,n),g&&B())for(const _ in g){const R=g[_],A=Array.from(p.querySelectorAll("["+_+"]"));p.matches&&p.matches("["+_+"]")&&A.push(p);for(let O=0;O<A.length;O++){const k=A[O];L(k)&&F(R,k.getAttribute(_),_,r,k)}}d&&d(p)}const l=[];if(e.indexOf("[")!==-1){const h=/\[([\w-]+)/g;let p;for(;(p=h.exec(e))!==null;)l.push(p[1])}else l.push(e);we({selector:e,attribute:t,componentTag:r,attributes:g,ComponentFn:n,onInit:d,observed:l.concat(s),onAttributeChange:c,onAttrChange:w,effects:y,declared:$,persist:o}),pe();const b=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";J().push({selector:e,attribute:t,ComponentFn:n,onInit:d,onSubtreeChange:a,query:b}),me(),window[t]=u;function C(){fe()>0?he(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C):C(),u}function V(e){return(e||"").replace(/^#/,"")}function q(e){const t=e===void 0?location.hash:e,n={},r=V(t);if(!r)return n;const i=r.split("&");for(let s=0;s<i.length;s++){const c=i[s];if(!c)continue;const a=c.indexOf(":"),d=a>-1?c.slice(0,a):c,w=a>-1?c.slice(a+1):"";if(d)try{n[d]=decodeURIComponent(w)}catch{n[d]=w}}return n}function ye(e){if(!e)return null;const t=q();return e in t?t[e]:null}function _e(e,t){if(!e)return;const n=q();t==null?delete n[e]:n[e]=String(t);const i=Object.keys(n).map(function(s){const c=n[s];return c===""?s:s+":"+encodeURIComponent(c)}).join("&");V(location.hash)!==i&&(location.hash=i)}function ve(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Ae(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const r=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return r?t?r+"-"+t:r:t||null}function ke(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Se(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Oe(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Te(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),r=e.slice(t+1),i=r?r.split(",").map(function(s){try{return decodeURIComponent(s)}catch{return s}}).filter(Boolean):[];return{key:n,values:i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=q,window.lnCore.hashGet=ye,window.lnCore.hashSet=_e,window.lnCore.hashLinkClick=ve,window.lnCore.resolveHashNamespace=Ae,window.lnCore.hashSortEncode=ke,window.lnCore.hashSortDecode=Se,window.lnCore.hashFilterEncode=Oe,window.lnCore.hashFilterDecode=Te),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function r(o){const u=o[t];u&&u.refreshConfig()}const i={"data-ln-couchdb-connector":{type:"marker",description:"Mounts CouchDB/PouchDB connector bridging database and ln-ashlar data coordinators"},"data-ln-couchdb-url":{prop:"url",read:E,type:"string",fallback:"",effect:r,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:E,type:"string",fallback:"",effect:r,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:E,type:"string",fallback:"",effect:r,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:r,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},s=ae(i);function c(o){const u=o&&o.content!==void 0?o.content:o,l=o&&o.message?o.message:null;return{content:u,message:l}}function a(o){return this.dom=o,le(this,o,s),o[t]=this,o[n]=this,this.refreshConfig(),this._handlers=null,$(this),this}a.prototype.refreshConfig=function(){const o=this.dom;this.credentials="same-origin";const u=o.getAttribute("data-ln-couchdb-headers")||"";this.headers=K(u,"ln-couchdb-connector"),this.auth&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-auth attribute. Storing basic authentication credentials in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),u.toLowerCase().includes("authorization")&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-headers attribute. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),v(o,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function d(o,u,l){const f=Object.assign({},T(o.headers,o.auth),l||{});return u&&(f["Idempotency-Key"]=u),f}a.prototype.fetchDelta=function(o){const u=this,l=["include_docs=true","feed=normal"];o&&l.push("since="+encodeURIComponent(o));const f=S(u.url,u.db,"_changes")+"?"+l.join("&");return window.fetch(f,{method:"GET",headers:T(u.headers,u.auth),credentials:u.credentials}).then(b=>{if(!b.ok)throw new Error("HTTP "+b.status+": "+b.statusText);return b.json()}).then(b=>{const C=b.results||[];return{data:C.filter(h=>!h.deleted&&h.doc).map(h=>Object.assign({},h.doc,{id:h.doc._id})),deleted:C.filter(h=>h.deleted).map(h=>h.id),synced_at:b.last_seq||o||""}})};function w(o,u,l){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(S(o.url,o.db),{method:"POST",headers:d(o,l),credentials:o.credentials,body:JSON.stringify(f)}).then(b=>{if(!b.ok)throw new Error("HTTP "+b.status+": "+b.statusText);return b.json()}).then(b=>{const C=c(b),h=C.content;return{record:Object.assign({},f,{id:h.id,_id:h.id,_rev:h.rev}),message:C.message}})}a.prototype.create=function(o,u){return w(this,o,u).then(l=>l.record)};function m(o,u,l,f){const b=Object.assign({id:String(u),_id:String(u)},l),C=b._rev||b.rev;return(C?Promise.resolve(C):window.fetch(S(o.url,o.db,null,u),{method:"GET",headers:T(o.headers,o.auth),credentials:o.credentials}).then(p=>{if(!p.ok)throw new Error("Could not retrieve document for revision mapping");return p.json().then(_=>_._rev)})).then(p=>{const _=Object.assign({},b,{_rev:p});delete _.rev;const R=d(o,f,{"If-Match":p});return window.fetch(S(o.url,o.db,null,u),{method:"PUT",headers:R,credentials:o.credentials,body:JSON.stringify(_)}).then(A=>{if(A.ok)return A.json().then(O=>{const k=c(O);return{record:Object.assign({},_,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(O=>{const k=new Error("Conflict");throw k.status=409,k.data=O,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}a.prototype.update=function(o,u,l){return m(this,o,u,l).then(f=>f.record)};function g(o,u,l,f){return(l?Promise.resolve(l):window.fetch(S(o.url,o.db,null,u),{method:"GET",headers:T(o.headers,o.auth),credentials:o.credentials}).then(C=>{if(!C.ok)throw new Error("Could not retrieve document for revision delete");return C.json().then(h=>h._rev)})).then(C=>{const h=S(o.url,o.db,null,u)+"?rev="+encodeURIComponent(C);return window.fetch(h,{method:"DELETE",headers:d(o,f),credentials:o.credentials}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const _=c(p);return{response:_.content,message:_.message}})})}a.prototype.delete=function(o,u,l){return g(this,o,u,l).then(f=>f.response)};function y(o,u,l){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(S(o.url,o.db,"_all_docs"),{method:"POST",headers:T(o.headers,o.auth),credentials:o.credentials,body:JSON.stringify({keys:u})}).then(f=>{if(!f.ok)throw new Error("HTTP "+f.status+": "+f.statusText);return f.json()}).then(f=>{const C=(f.rows||[]).filter(h=>!h.error&&h.value&&h.value.rev).map(h=>({_id:h.id,_rev:h.value.rev,_deleted:!0}));return C.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(S(o.url,o.db,"_bulk_docs"),{method:"POST",headers:d(o,l),credentials:o.credentials,body:JSON.stringify({docs:C})}).then(h=>{if(!h.ok)throw new Error("HTTP "+h.status+": "+h.statusText);return h.json()}).then(h=>{const p=c(h);return{response:{ok:!0,results:p.content,deletedCount:C.length},message:p.message}})})}a.prototype.bulkDelete=function(o,u){return y(this,o,u).then(l=>l.response)};function $(o){o._handlers={sync:function(u){const l=u.detail||{};o.fetchDelta(l.since).then(function(f){v(o.dom,"ln-couchdb-connector:fetched",{data:f,since:l.since,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:l.since,meta:l.meta||null})})},create:function(u){const l=u.detail||{};w(o,l.data,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:created",{record:f.record,tempId:l.tempId,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:l.tempId,meta:l.meta||null})})},update:function(u){const l=u.detail||{},f=Object.assign({},l.data);l.expected_version!==void 0&&(f._rev=l.expected_version),m(o,l.id,f,l.idempotencyKey).then(function(b){v(o.dom,"ln-couchdb-connector:updated",{record:b.record,id:l.id,message:b.message,meta:l.meta||null})}).catch(function(b){v(o.dom,"ln-couchdb-connector:error",{action:"update",error:b.message,status:b.status||0,id:l.id,data:b.status===409?b.data:null,conflictData:b.status===409?b.data:null,meta:l.meta||null})})},delete:function(u){const l=u.detail||{};g(o,l.id,l.rev,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:deleted",{response:f.response,id:l.id,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:l.id,meta:l.meta||null})})},bulkDelete:function(u){const l=u.detail||{};y(o,l.ids,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:l.ids,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:l.ids,meta:l.meta||null})})}},o.dom.addEventListener("ln-couchdb-connector:request-sync",o._handlers.sync),o.dom.addEventListener("ln-couchdb-connector:request-create",o._handlers.create),o.dom.addEventListener("ln-couchdb-connector:request-update",o._handlers.update),o.dom.addEventListener("ln-couchdb-connector:request-delete",o._handlers.delete),o.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",o._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const o=this;o._handlers&&(o.dom.removeEventListener("ln-couchdb-connector:request-sync",o._handlers.sync),o.dom.removeEventListener("ln-couchdb-connector:request-create",o._handlers.create),o.dom.removeEventListener("ln-couchdb-connector:request-update",o._handlers.update),o.dom.removeEventListener("ln-couchdb-connector:request-delete",o._handlers.delete),o.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",o._handlers.bulkDelete),o._handlers=null),delete this.dom[t],delete this.dom[n]},Ce(e,t,a,"ln-couchdb-connector",{attributes:i})})()})();
1
+ (function(){"use strict";function B(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function L(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let r=null;for(let i=1;i<t.length;i++)if(t[i]&&t[i].nodeType===1){r=t[i];break}if(!L(r))return}e.apply(console,t)}}function v(e,t,n){const r=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function D(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){D(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function S(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function T(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function K(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const N={};function G(e,t){N[e]=t}function Q(e){return N[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=G,window.lnCore.getDataMapper=Q);function z(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const P={};function X(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];P[n]=t}function Y(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return P[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=X,window.lnCore.getLocaleFallback=Y,window.lnCore.ensureLocaleObserver=z);const x={};function Z(e,t){x[e]||(x[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=x[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let s=0;s<n.length;s++){const a=n[s],d=a.getAttribute("data-ln-field");t[d]!=null&&(a.textContent=t[d])}const r=e.querySelectorAll("[data-ln-attr]");for(let s=0;s<r.length;s++){const a=r[s],d=a.getAttribute("data-ln-attr").split(",");for(let w=0;w<d.length;w++){const C=d[w].trim().split(":");if(C.length!==2)continue;const g=C[0].trim(),y=C[1].trim();t[y]!=null&&a.setAttribute(g,t[y])}}const i=e.querySelectorAll("[data-ln-show]");for(let s=0;s<i.length;s++){const a=i[s],d=a.getAttribute("data-ln-show");d in t&&a.classList.toggle("hidden",!t[d])}const c=e.querySelectorAll("[data-ln-class]");for(let s=0;s<c.length;s++){const a=c[s],d=a.getAttribute("data-ln-class").split(",");for(let w=0;w<d.length;w++){const C=d[w].trim().split(":");if(C.length!==2)continue;const g=C[0].trim(),y=C[1].trim();y in t&&a.classList.toggle(g,!!t[y])}}return e}function ee(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<n.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[r],t??null),n[r].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function H(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const c=n.currentNode;c.textContent.indexOf("{{")!==-1&&(c.textContent=c.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(s,a){return t[a]!==void 0?t[a]:""}))}const r=function(c,s){return t[s]!==void 0?t[s]:""},i=Array.from(e.querySelectorAll("*"));e.nodeType===1&&i.push(e);for(let c=0;c<i.length;c++){const s=i[c],a=s.attributes;for(let d=0;d<a.length;d++){const w=a[d];w.value.indexOf("{{")!==-1&&s.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function te(e,t,n,r,i,c){const s={};for(let d=0;d<e.children.length;d++){const w=e.children[d],C=w.getAttribute("data-ln-render-key");C&&(s[C]=w)}const a=document.createDocumentFragment();for(let d=0;d<t.length;d++){const w=t[d],C=String(r(w));let g=s[C];if(g)i(g,w,d);else{const y=Z(n,c);if(!y||(H(y,w),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",C),i(g,w,d)}a.appendChild(g)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=H,window.lnCore.fill=M,window.lnCore.lnFill=ee,window.lnCore.renderList=te);function E(e,t,n){const r=e.getAttribute(t);return r===null?n:r}function ne(e,t,n){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?n:r}function re(e,t,n=!1){const r=e.getAttribute(t);if(r===null)return!!n;const i=r.trim().toLowerCase();return!(i==="false"||i==="0")}function oe(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const j=new Map;function ie(e,t){const n=(e?e.join("|"):"")+"::"+t;if(j.has(n))return j.get(n);const r=new Set(e||[]),i=function(c,s){const a=c.getAttribute(s);return a!==null&&r.has(a)?a:t};return j.set(n,i),i}function se(e,t,n){const r=parseFloat(e.getAttribute(t));return isNaN(r)?n:r}function ce(e,t,n){const r=e.getAttribute(t);if(!r)return n;try{return JSON.parse(r)}catch{return n}}function F(e,t,n,r,i){if(!e||t===null)return!0;const c=r||"ln-component",s=e.type;if(s==="trigger"||s==="marker"||s==="string"||s==="list"||!s||t===""&&e.fallback!==void 0)return!0;const a=d=>{i?console.warn(d,i):console.warn(d)};if(s==="boolean"){const d=t.trim().toLowerCase();return d!==""&&d!=="true"&&d!=="false"&&d!=="1"&&d!=="0"?(a(`[${c}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(s==="enum"){const d=e.values||[];return d.includes(t)?!0:(a(`[${c}] Invalid value "${t}" for attribute "${n}". Allowed: ${d.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(s==="integer"){if(!/^-?\d+$/.test(t))return a(`[${c}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const d=parseInt(t,10);return e.min!==void 0&&d<e.min?(a(`[${c}] Value ${d} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&d>e.max?(a(`[${c}] Value ${d} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(s==="float")return isNaN(Number(t))?(a(`[${c}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(s==="json")try{return JSON.parse(t),!0}catch(d){return a(`[${c}] Invalid JSON for attribute "${n}": ${d.message}. Fallback: ${e.fallback}.`),!1}return!0}function le(e,t,n){for(const r in n){const[i,c,s]=n[r];Object.defineProperty(e,r,{get:function(){return i(t,c,s)},enumerable:!0,configurable:!0})}return e}function ae(e){const t={};for(const n in e){const r=e[n];if(!r||!r.prop)continue;let i=r.read;if(!i&&r.type)switch(r.type){case"enum":i=ie(r.values,r.fallback);break;case"integer":i=ne;break;case"float":i=se;break;case"boolean":i=re;break;case"list":i=oe;break;case"json":i=ce;break;case"string":default:i=E;break}i||(i=E),t[r.prop]=[i,n,r.fallback]}return t}function de(e){const t={};for(const n in e){const r=e[n];r&&r.effect&&(t[n]=r.effect)}return Object.keys(t).length?t:null}function ue(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function I(e,t,n,r){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",s=Array.from(e.querySelectorAll(c));e.matches&&e.matches(c)&&s.push(e);for(const a of s)if(!a[n]){window.lnCore._persistSink&&a.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(a,t);try{a[n]=new r(a)}catch(d){console.error("["+n+"] init failed",a,d)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function fe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function he(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function W(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function we(e){const t=W(),n=e.observed||[];for(let r=0;r<n.length;r++){const i=n[r];t.byAttr.has(i)||t.byAttr.set(i,[]),t.byAttr.get(i).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const r in e.attributes){t.byDeclaredAttr.has(r)||t.byDeclaredAttr.set(r,[]);const i=t.byDeclaredAttr.get(r);i.some(c=>c.componentTag===e.componentTag)||i.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=ue(e);if(r===null)t.reactiveWildcard.push(e);else for(const i of r)t.byReactive.has(i)||t.byReactive.set(i,[]),t.byReactive.get(i).push(e)}e.persist&&t.persist.push(e)}function U(e,t,n,r){for(let i=0;i<e.length;i++){const c=e[i];if(!t[c.attribute])continue;const s=c.effects&&c.effects[n];s?s(t,n,r):c.onAttrChange&&(!c.declared||c.declared.has(n))&&c.onAttrChange(t,n,r)}}function be(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const r=W(),i=r.byAttr.get(n);if(B()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(n)&&L(t)){const c=r.byDeclaredAttr.get(n),s=t.getAttribute(n);for(let a=0;a<c.length;a++)F(c[a].spec,s,n,c[a].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||i)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const c=r.byReactive.get(n);c&&U(c,t,n,e.oldValue),r.reactiveWildcard.length&&U(r.reactiveWildcard,t,n,e.oldValue)}if(i)for(let c=0;c<i.length;c++){const s=i[c];if(s.handler){s.handler(t,n,e.oldValue);continue}s.onAttributeChange&&t[s.attribute]?s.onAttributeChange(t,n):(I(t,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(t))}}function pe(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{be(t[n])}catch(r){console.error("[ln-core] mutation handler failed",t[n].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function J(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ge(e){const t=J();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const r=t[n];if(r.onSubtreeChange){const i=r.query,c=e.target.nodeType===1?e.target.matches(i)?e.target:e.target.closest(i):e.target.parentElement?e.target.parentElement.closest(i):null;c&&r.onSubtreeChange(c,e)}}for(let n=0;n<e.addedNodes.length;n++){const r=e.addedNodes[n];if(r.nodeType===1)for(let i=0;i<t.length;i++){const c=t[i];I(r,c.selector,c.attribute,c.ComponentFn),c.onInit&&c.onInit(r)}}for(let n=0;n<e.removedNodes.length;n++){const r=e.removedNodes[n];if(r.nodeType===1)for(let i=0;i<t.length;i++){const c=t[i],s=c.query,a=Array.from(r.querySelectorAll(s));r.matches&&r.matches(s)&&a.push(r);for(let d=0;d<a.length;d++){const w=a[d];if(!document.contains(w)){const C=w[c.attribute];if(C&&typeof C.destroy=="function")try{C.destroy()}catch(g){console.error("["+c.attribute+"] destroy failed",w,g)}delete w[c.attribute]}}}}}}function me(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.type==="childList")try{ge(r)}catch(i){console.error("[ln-core] lifecycle handler failed",r.target,i)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Ce(e,t,n,r,i={}){const c=i.extraAttributes||[],s=i.onAttributeChange||null,a=i.onSubtreeChange||null,d=i.onInit||null,w=i.onAttrChange||null,C=i.effects||null,g=i.attributes||null,y=g?de(g):C,$=g?new Set(Object.keys(g)):null,o=i.persist||null;function u(b){const h=b||document.body;if(I(h,e,t,n),g&&B())for(const _ in g){const R=g[_],A=Array.from(h.querySelectorAll("["+_+"]"));h.matches&&h.matches("["+_+"]")&&A.push(h);for(let O=0;O<A.length;O++){const k=A[O];L(k)&&F(R,k.getAttribute(_),_,r,k)}}d&&d(h)}const l=[];if(e.indexOf("[")!==-1){const b=/\[([\w-]+)/g;let h;for(;(h=b.exec(e))!==null;)l.push(h[1])}else l.push(e);we({selector:e,attribute:t,componentTag:r,attributes:g,ComponentFn:n,onInit:d,observed:l.concat(c),onAttributeChange:s,onAttrChange:w,effects:y,declared:$,persist:o}),pe();const p=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";J().push({selector:e,attribute:t,ComponentFn:n,onInit:d,onSubtreeChange:a,query:p}),me(),window[t]=u;function m(){fe()>0?he(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m):m(),u}function V(e){return(e||"").replace(/^#/,"")}function q(e){const t=e===void 0?location.hash:e,n={},r=V(t);if(!r)return n;const i=r.split("&");for(let c=0;c<i.length;c++){const s=i[c];if(!s)continue;const a=s.indexOf(":"),d=a>-1?s.slice(0,a):s,w=a>-1?s.slice(a+1):"";if(d)try{n[d]=decodeURIComponent(w)}catch{n[d]=w}}return n}function ye(e){if(!e)return null;const t=q();return e in t?t[e]:null}function _e(e,t){if(!e)return;const n=q();t==null?delete n[e]:n[e]=String(t);const i=Object.keys(n).map(function(c){const s=n[c];return s===""?c:c+":"+encodeURIComponent(s)}).join("&");V(location.hash)!==i&&(location.hash=i)}function ve(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Ae(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const r=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return r?t?r+"-"+t:r:t||null}function ke(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Se(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Oe(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Te(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),r=e.slice(t+1),i=r?r.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:n,values:i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=q,window.lnCore.hashGet=ye,window.lnCore.hashSet=_e,window.lnCore.hashLinkClick=ve,window.lnCore.resolveHashNamespace=Ae,window.lnCore.hashSortEncode=ke,window.lnCore.hashSortDecode=Se,window.lnCore.hashFilterEncode=Oe,window.lnCore.hashFilterDecode=Te),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function r(o){const u=o[t];u&&u.refreshConfig()}const i={"data-ln-couchdb-connector":{type:"marker",description:"Mounts CouchDB/PouchDB connector bridging database and ln-ashlar data coordinators"},"data-ln-couchdb-url":{prop:"url",read:E,type:"string",fallback:"",effect:r,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:E,type:"string",fallback:"",effect:r,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:E,type:"string",fallback:"",effect:r,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:r,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},c=ae(i);function s(o){const u=o&&o.content!==void 0?o.content:o,l=o&&o.message?o.message:null;return{content:u,message:l}}function a(o){return this.dom=o,le(this,o,c),o[t]=this,o[n]=this,this.refreshConfig(),this._deltaController=null,this._handlers=null,$(this),this}a.prototype.refreshConfig=function(){const o=this.dom;this.credentials="same-origin";const u=o.getAttribute("data-ln-couchdb-headers")||"";this.headers=K(u,"ln-couchdb-connector"),this.auth&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-auth attribute. Storing basic authentication credentials in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),u.toLowerCase().includes("authorization")&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-headers attribute. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),v(o,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function d(o,u,l){const f=Object.assign({},T(o.headers,o.auth),l||{});return u&&(f["Idempotency-Key"]=u),f}a.prototype.fetchDelta=function(o){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const l=this._deltaController.signal,f=["include_docs=true","feed=normal"];o&&f.push("since="+encodeURIComponent(o));const p=S(u.url,u.db,"_changes")+"?"+f.join("&");return window.fetch(p,{method:"GET",headers:T(u.headers,u.auth),credentials:u.credentials,signal:l}).then(m=>{if(!m.ok)throw new Error("HTTP "+m.status+": "+m.statusText);return m.json()}).then(m=>{const b=m.results||[];return{data:b.filter(h=>!h.deleted&&h.doc).map(h=>Object.assign({},h.doc,{id:h.doc._id})),deleted:b.filter(h=>h.deleted).map(h=>h.id),synced_at:m.last_seq||o||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===l&&(u._deltaController=null)})};function w(o,u,l){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(S(o.url,o.db),{method:"POST",headers:d(o,l),credentials:o.credentials,body:JSON.stringify(f)}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const m=s(p),b=m.content;return{record:Object.assign({},f,{id:b.id,_id:b.id,_rev:b.rev}),message:m.message}})}a.prototype.create=function(o,u){return w(this,o,u).then(l=>l.record)};function C(o,u,l,f){const p=Object.assign({id:String(u),_id:String(u)},l),m=p._rev||p.rev;return(m?Promise.resolve(m):window.fetch(S(o.url,o.db,null,u),{method:"GET",headers:T(o.headers,o.auth),credentials:o.credentials}).then(h=>{if(!h.ok)throw new Error("Could not retrieve document for revision mapping");return h.json().then(_=>_._rev)})).then(h=>{const _=Object.assign({},p,{_rev:h});delete _.rev;const R=d(o,f,{"If-Match":h});return window.fetch(S(o.url,o.db,null,u),{method:"PUT",headers:R,credentials:o.credentials,body:JSON.stringify(_)}).then(A=>{if(A.ok)return A.json().then(O=>{const k=s(O);return{record:Object.assign({},_,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(O=>{const k=new Error("Conflict");throw k.status=409,k.data=O,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}a.prototype.update=function(o,u,l){return C(this,o,u,l).then(f=>f.record)};function g(o,u,l,f){return(l?Promise.resolve(l):window.fetch(S(o.url,o.db,null,u),{method:"GET",headers:T(o.headers,o.auth),credentials:o.credentials}).then(m=>{if(!m.ok)throw new Error("Could not retrieve document for revision delete");return m.json().then(b=>b._rev)})).then(m=>{const b=S(o.url,o.db,null,u)+"?rev="+encodeURIComponent(m);return window.fetch(b,{method:"DELETE",headers:d(o,f),credentials:o.credentials}).then(h=>{if(!h.ok)throw new Error("HTTP "+h.status+": "+h.statusText);return h.json()}).then(h=>{const _=s(h);return{response:_.content,message:_.message}})})}a.prototype.delete=function(o,u,l){return g(this,o,u,l).then(f=>f.response)};function y(o,u,l){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(S(o.url,o.db,"_all_docs"),{method:"POST",headers:T(o.headers,o.auth),credentials:o.credentials,body:JSON.stringify({keys:u})}).then(f=>{if(!f.ok)throw new Error("HTTP "+f.status+": "+f.statusText);return f.json()}).then(f=>{const m=(f.rows||[]).filter(b=>!b.error&&b.value&&b.value.rev).map(b=>({_id:b.id,_rev:b.value.rev,_deleted:!0}));return m.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(S(o.url,o.db,"_bulk_docs"),{method:"POST",headers:d(o,l),credentials:o.credentials,body:JSON.stringify({docs:m})}).then(b=>{if(!b.ok)throw new Error("HTTP "+b.status+": "+b.statusText);return b.json()}).then(b=>{const h=s(b);return{response:{ok:!0,results:h.content,deletedCount:m.length},message:h.message}})})}a.prototype.bulkDelete=function(o,u){return y(this,o,u).then(l=>l.response)};function $(o){o._handlers={sync:function(u){const l=u.detail||{};o.fetchDelta(l.since).then(function(f){v(o.dom,"ln-couchdb-connector:fetched",{data:f,since:l.since,meta:l.meta||null})}).catch(function(f){f&&f.name==="AbortError"||v(o.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:l.since,meta:l.meta||null})})},create:function(u){const l=u.detail||{};w(o,l.data,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:created",{record:f.record,tempId:l.tempId,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:l.tempId,meta:l.meta||null})})},update:function(u){const l=u.detail||{},f=Object.assign({},l.data);l.expected_version!==void 0&&(f._rev=l.expected_version),C(o,l.id,f,l.idempotencyKey).then(function(p){v(o.dom,"ln-couchdb-connector:updated",{record:p.record,id:l.id,message:p.message,meta:l.meta||null})}).catch(function(p){v(o.dom,"ln-couchdb-connector:error",{action:"update",error:p.message,status:p.status||0,id:l.id,data:p.status===409?p.data:null,conflictData:p.status===409?p.data:null,meta:l.meta||null})})},delete:function(u){const l=u.detail||{};g(o,l.id,l.rev,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:deleted",{response:f.response,id:l.id,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:l.id,meta:l.meta||null})})},bulkDelete:function(u){const l=u.detail||{};y(o,l.ids,l.idempotencyKey).then(function(f){v(o.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:l.ids,message:f.message,meta:l.meta||null})}).catch(function(f){v(o.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:l.ids,meta:l.meta||null})})}},o.dom.addEventListener("ln-couchdb-connector:request-sync",o._handlers.sync),o.dom.addEventListener("ln-couchdb-connector:request-create",o._handlers.create),o.dom.addEventListener("ln-couchdb-connector:request-update",o._handlers.update),o.dom.addEventListener("ln-couchdb-connector:request-delete",o._handlers.delete),o.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",o._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const o=this;o._deltaController&&(o._deltaController.abort(),o._deltaController=null),o._handlers&&(o.dom.removeEventListener("ln-couchdb-connector:request-sync",o._handlers.sync),o.dom.removeEventListener("ln-couchdb-connector:request-create",o._handlers.create),o.dom.removeEventListener("ln-couchdb-connector:request-update",o._handlers.update),o.dom.removeEventListener("ln-couchdb-connector:request-delete",o._handlers.delete),o.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",o._handlers.bulkDelete),o._handlers=null),delete this.dom[t],delete this.dom[n]},Ce(e,t,a,"ln-couchdb-connector",{attributes:i})})()})();
@@ -41,6 +41,7 @@ import { registerComponent, dispatch, buildUrl, getHeaders, parseHeaders, define
41
41
  dom[DOM_ALIAS] = this; // Alias for 3-tier compatibility
42
42
 
43
43
  this.refreshConfig();
44
+ this._deltaController = null;
44
45
  this._handlers = null;
45
46
  _bindEvents(this);
46
47
 
@@ -86,11 +87,17 @@ import { registerComponent, dispatch, buildUrl, getHeaders, parseHeaders, define
86
87
 
87
88
  _component.prototype.fetchDelta = function (since) {
88
89
  const self = this;
90
+ if (this._deltaController) {
91
+ this._deltaController.abort();
92
+ }
93
+ this._deltaController = new AbortController();
94
+ const signal = this._deltaController.signal;
95
+
89
96
  const params = ['include_docs=true', 'feed=normal'];
90
97
  if (since) params.push('since=' + encodeURIComponent(since));
91
98
  const url = buildUrl(self.url, self.db, '_changes') + '?' + params.join('&');
92
99
 
93
- return window.fetch(url, { method: 'GET', headers: getHeaders(self.headers, self.auth), credentials: self.credentials })
100
+ return window.fetch(url, { method: 'GET', headers: getHeaders(self.headers, self.auth), credentials: self.credentials, signal: signal })
94
101
  .then(res => {
95
102
  if (!res.ok) throw new Error('HTTP ' + res.status + ': ' + res.statusText);
96
103
  return res.json();
@@ -102,6 +109,11 @@ import { registerComponent, dispatch, buildUrl, getHeaders, parseHeaders, define
102
109
  deleted: results.filter(r => r.deleted).map(r => r.id),
103
110
  synced_at: data.last_seq || since || ''
104
111
  };
112
+ })
113
+ .finally(() => {
114
+ if (self._deltaController && self._deltaController.signal === signal) {
115
+ self._deltaController = null;
116
+ }
105
117
  });
106
118
  };
107
119
 
@@ -270,6 +282,7 @@ import { registerComponent, dispatch, buildUrl, getHeaders, parseHeaders, define
270
282
  dispatch(self.dom, 'ln-couchdb-connector:fetched', { data: data, since: detail.since, meta: detail.meta || null });
271
283
  })
272
284
  .catch(function (err) {
285
+ if (err && err.name === 'AbortError') return;
273
286
  dispatch(self.dom, 'ln-couchdb-connector:error', {
274
287
  action: 'sync',
275
288
  error: err.message,
@@ -365,6 +378,10 @@ import { registerComponent, dispatch, buildUrl, getHeaders, parseHeaders, define
365
378
  if (!this.dom[DOM_ATTRIBUTE]) return;
366
379
 
367
380
  const self = this;
381
+ if (self._deltaController) {
382
+ self._deltaController.abort();
383
+ self._deltaController = null;
384
+ }
368
385
  if (self._handlers) {
369
386
  self.dom.removeEventListener('ln-couchdb-connector:request-sync', self._handlers.sync);
370
387
  self.dom.removeEventListener('ln-couchdb-connector:request-create', self._handlers.create);
@@ -1 +1 @@
1
- (function(){"use strict";function J(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function $(t){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return t?window.lnCore._debugIsContained(t):window.lnCore._debugSink!==null;if(t&&t.closest){const r=t.closest("[data-ln-debug]");return!(!r||typeof document<"u"&&r===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const t=console.warn;console.warn=function(...r){if(typeof r[0]=="string"&&(r[0].startsWith("[ln-")||r[0].startsWith("[lnCore"))){let a=null;for(let d=1;d<r.length;d++)if(r[d]&&r[d].nodeType===1){a=r[d];break}if(!$(a))return}t.apply(console,r)}}function h(t,r,i){const a=i||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",r,t,a),t.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:a}))}function N(t,r){if(!document.body){document.addEventListener("DOMContentLoaded",function(){N(t,r)}),console.warn("["+r+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function le(t){const r=t.querySelector('input[name="_method"]');return((r&&r.value!==""?r.value:t.method)||"").toUpperCase()}function ce(t,r){const i={},a=t.elements;for(let d=0;d<a.length;d++){const l=a[d];if(!(!l.name||l.disabled||l.type==="file"||l.type==="submit"||l.type==="button"))if(l.type==="checkbox")i[l.name]||(i[l.name]=[]),l.checked&&i[l.name].push(l.value);else if(l.type==="radio")l.checked&&(i[l.name]=l.value);else if(l.type==="select-multiple"){i[l.name]=[];for(let u=0;u<l.options.length;u++)l.options[u].selected&&i[l.name].push(l.options[u].value)}else i[l.name]=l.value}return i}const X={};function ue(t,r){X[t]=r}function fe(t){return X[t]||{ingress:r=>r,egress:r=>r}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=ue,window.lnCore.getDataMapper=fe);function he(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,N(function(){new MutationObserver(function(){h(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const Y={};function pe(t,r){if(!t||typeof r!="object")return;const i=t.toLowerCase().split("-")[0];Y[i]=r}function me(t){if(!t)return null;const r=t.toLowerCase().split("-")[0];return Y[r]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=pe,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=he);const B={};function ye(t,r){B[t]||(B[t]=document.querySelector('[data-ln-template="'+t+'"]'));const i=B[t];return i?i.content.cloneNode(!0):(console.warn("["+(r||"ln-core")+'] Template "'+t+'" not found'),null)}function Z(t,r){if(!t||!r)return t;const i=t.querySelectorAll("[data-ln-field]");for(let u=0;u<i.length;u++){const m=i[u],p=m.getAttribute("data-ln-field");r[p]!=null&&(m.textContent=r[p])}const a=t.querySelectorAll("[data-ln-attr]");for(let u=0;u<a.length;u++){const m=a[u],p=m.getAttribute("data-ln-attr").split(",");for(let v=0;v<p.length;v++){const S=p[v].trim().split(":");if(S.length!==2)continue;const A=S[0].trim(),L=S[1].trim();r[L]!=null&&m.setAttribute(A,r[L])}}const d=t.querySelectorAll("[data-ln-show]");for(let u=0;u<d.length;u++){const m=d[u],p=m.getAttribute("data-ln-show");p in r&&m.classList.toggle("hidden",!r[p])}const l=t.querySelectorAll("[data-ln-class]");for(let u=0;u<l.length;u++){const m=l[u],p=m.getAttribute("data-ln-class").split(",");for(let v=0;v<p.length;v++){const S=p[v].trim().split(":");if(S.length!==2)continue;const A=S[0].trim(),L=S[1].trim();L in r&&m.classList.toggle(A,!!r[L])}}return t}function ge(t,r){t.matches&&t.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",t,r??null),t.dispatchEvent(new CustomEvent("ln-fill",{detail:r??null,bubbles:!0})));const i=t.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let a=0;a<i.length;a++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",i[a],r??null),i[a].dispatchEvent(new CustomEvent("ln-fill",{detail:r??null,bubbles:!0}));return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(t){if(!(!t.target.matches||!t.target.matches("[data-ln-fillable]")))if(t.detail)Z(t.target,t.detail);else{const r=t.target.querySelectorAll("[data-ln-field]");for(let i=0;i<r.length;i++)r[i].textContent=""}})));function ee(t,r){if(!t||!r)return t;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;i.nextNode();){const l=i.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(u,m){return r[m]!==void 0?r[m]:""}))}const a=function(l,u){return r[u]!==void 0?r[u]:""},d=Array.from(t.querySelectorAll("*"));t.nodeType===1&&d.push(t);for(let l=0;l<d.length;l++){const u=d[l],m=u.attributes;for(let p=0;p<m.length;p++){const v=m[p];v.value.indexOf("{{")!==-1&&u.setAttribute(v.name,v.value.replace(/\{\{\s*(\w+)\s*\}\}/g,a))}}return t}function be(t,r,i,a,d,l){const u={};for(let p=0;p<t.children.length;p++){const v=t.children[p],S=v.getAttribute("data-ln-render-key");S&&(u[S]=v)}const m=document.createDocumentFragment();for(let p=0;p<r.length;p++){const v=r[p],S=String(a(v));let A=u[S];if(A)d(A,v,p);else{const L=ye(i,l);if(!L||(ee(L,v),A=L.firstElementChild,!A))continue;A.setAttribute("data-ln-render-key",S),d(A,v,p)}m.appendChild(A)}t.textContent="",t.appendChild(m)}function we(t,r){const i={},a=t.querySelectorAll("["+r+"]");for(let d=0;d<a.length;d++)i[a[d].getAttribute(r)]=a[d].textContent,a[d].remove();return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=ee,window.lnCore.fill=Z,window.lnCore.lnFill=ge,window.lnCore.renderList=be);function te(t,r,i){const a=t.getAttribute(r);return a===null?i:a}function _e(t,r,i){const a=parseInt(t.getAttribute(r),10);return isNaN(a)?i:a}function qe(t,r,i=!1){const a=t.getAttribute(r);if(a===null)return!!i;const d=a.trim().toLowerCase();return!(d==="false"||d==="0")}function Ee(t,r){return(t.getAttribute(r)||"").split(",").map(i=>i.trim()).filter(Boolean)}const U=new Map;function ve(t,r){const i=(t?t.join("|"):"")+"::"+r;if(U.has(i))return U.get(i);const a=new Set(t||[]),d=function(l,u){const m=l.getAttribute(u);return m!==null&&a.has(m)?m:r};return U.set(i,d),d}function Ce(t,r,i){const a=parseFloat(t.getAttribute(r));return isNaN(a)?i:a}function Ae(t,r,i){const a=t.getAttribute(r);if(!a)return i;try{return JSON.parse(a)}catch{return i}}function ne(t,r,i,a,d){if(!t||r===null)return!0;const l=a||"ln-component",u=t.type;if(u==="trigger"||u==="marker"||u==="string"||u==="list"||!u||r===""&&t.fallback!==void 0)return!0;const m=p=>{d?console.warn(p,d):console.warn(p)};if(u==="boolean"){const p=r.trim().toLowerCase();return p!==""&&p!=="true"&&p!=="false"&&p!=="1"&&p!=="0"?(m(`[${l}] Invalid value "${r}" for boolean attribute "${i}". Allowed: "true", "false", or presence-only.`),!1):!0}if(u==="enum"){const p=t.values||[];return p.includes(r)?!0:(m(`[${l}] Invalid value "${r}" for attribute "${i}". Allowed: ${p.join(", ")}. Fallback: "${t.fallback}".`),!1)}if(u==="integer"){if(!/^-?\d+$/.test(r))return m(`[${l}] Invalid integer "${r}" for attribute "${i}". Fallback: ${t.fallback}.`),!1;const p=parseInt(r,10);return t.min!==void 0&&p<t.min?(m(`[${l}] Value ${p} for attribute "${i}" is less than min (${t.min}).`),!1):t.max!==void 0&&p>t.max?(m(`[${l}] Value ${p} for attribute "${i}" is greater than max (${t.max}).`),!1):!0}if(u==="float")return isNaN(Number(r))?(m(`[${l}] Invalid float "${r}" for attribute "${i}". Fallback: ${t.fallback}.`),!1):!0;if(u==="json")try{return JSON.parse(r),!0}catch(p){return m(`[${l}] Invalid JSON for attribute "${i}": ${p.message}. Fallback: ${t.fallback}.`),!1}return!0}function Se(t,r,i){for(const a in i){const[d,l,u]=i[a];Object.defineProperty(t,a,{get:function(){return d(r,l,u)},enumerable:!0,configurable:!0})}return t}function ke(t){const r={};for(const i in t){const a=t[i];if(!a||!a.prop)continue;let d=a.read;if(!d&&a.type)switch(a.type){case"enum":d=ve(a.values,a.fallback);break;case"integer":d=_e;break;case"float":d=Ce;break;case"boolean":d=qe;break;case"list":d=Ee;break;case"json":d=Ae;break;case"string":default:d=te;break}d||(d=te),r[a.prop]=[d,i,a.fallback]}return r}function Le(t){const r={};for(const i in t){const a=t[i];a&&a.effect&&(r[i]=a.effect)}return Object.keys(r).length?r:null}function xe(t){if(t.onAttrChange&&!t.declared)return null;const r=new Set;if(t.effects)for(const i in t.effects)r.add(i);if(t.onAttrChange&&t.declared)for(const i of t.declared)r.add(i);return r}function z(t,r,i,a){if(t.nodeType!==1)return;const l=r.indexOf("[")!==-1||r.indexOf(".")!==-1||r.indexOf("#")!==-1?r:"["+r+"]",u=Array.from(t.querySelectorAll(l));t.matches&&t.matches(l)&&u.push(t);for(const m of u)if(!m[i]){window.lnCore._persistSink&&m.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(m,r);try{m[i]=new a(m)}catch(p){console.error("["+i+"] init failed",m,p)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function De(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function Ie(t){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(t):setTimeout(t,0)):t()}function re(){window.lnCore=window.lnCore||{};const t=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return t.byReactive=t.byReactive||new Map,t.reactiveWildcard=t.reactiveWildcard||[],t}function Oe(t){const r=re(),i=t.observed||[];for(let a=0;a<i.length;a++){const d=i[a];r.byAttr.has(d)||r.byAttr.set(d,[]),r.byAttr.get(d).push(t)}if(r.byDeclaredAttr=r.byDeclaredAttr||new Map,t.attributes)for(const a in t.attributes){r.byDeclaredAttr.has(a)||r.byDeclaredAttr.set(a,[]);const d=r.byDeclaredAttr.get(a);d.some(l=>l.componentTag===t.componentTag)||d.push({spec:t.attributes[a],componentTag:t.componentTag})}if(t.onAttrChange||t.effects){r.reactive.push(t);const a=xe(t);if(a===null)r.reactiveWildcard.push(t);else for(const d of a)r.byReactive.has(d)||r.byReactive.set(d,[]),r.byReactive.get(d).push(t)}t.persist&&r.persist.push(t)}function oe(t,r,i,a){for(let d=0;d<t.length;d++){const l=t[d];if(!r[l.attribute])continue;const u=l.effects&&l.effects[i];u?u(r,i,a):l.onAttrChange&&(!l.declared||l.declared.has(i))&&l.onAttrChange(r,i,a)}}function Re(t){const r=t.target,i=t.attributeName;if(t.oldValue===r.getAttribute(i))return;const a=re(),d=a.byAttr.get(i);if(J()&&a.byDeclaredAttr&&a.byDeclaredAttr.has(i)&&$(r)){const l=a.byDeclaredAttr.get(i),u=r.getAttribute(i);for(let m=0;m<l.length;m++)ne(l[m].spec,u,i,l[m].componentTag,r)}if(window.lnCore._debugSink&&(i.indexOf("data-ln-")===0||d)&&window.lnCore._debugSink("attr",i,r,{oldValue:t.oldValue,newValue:r.getAttribute(i)}),i.indexOf("data-ln-")===0){const l=a.byReactive.get(i);l&&oe(l,r,i,t.oldValue),a.reactiveWildcard.length&&oe(a.reactiveWildcard,r,i,t.oldValue)}if(d)for(let l=0;l<d.length;l++){const u=d[l];if(u.handler){u.handler(r,i,t.oldValue);continue}u.onAttributeChange&&r[u.attribute]?u.onAttributeChange(r,i):(z(r,u.selector,u.attribute,u.ComponentFn),u.onInit&&u.onInit(r))}}function Ge(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,N(function(){new MutationObserver(function(r){for(let i=0;i<r.length;i++)try{Re(r[i])}catch(a){console.error("[ln-core] mutation handler failed",r[i].target,a)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ie(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function Te(t){const r=ie();if(r.length){if(t.target)for(let i=0;i<r.length;i++){const a=r[i];if(a.onSubtreeChange){const d=a.query,l=t.target.nodeType===1?t.target.matches(d)?t.target:t.target.closest(d):t.target.parentElement?t.target.parentElement.closest(d):null;l&&a.onSubtreeChange(l,t)}}for(let i=0;i<t.addedNodes.length;i++){const a=t.addedNodes[i];if(a.nodeType===1)for(let d=0;d<r.length;d++){const l=r[d];z(a,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(a)}}for(let i=0;i<t.removedNodes.length;i++){const a=t.removedNodes[i];if(a.nodeType===1)for(let d=0;d<r.length;d++){const l=r[d],u=l.query,m=Array.from(a.querySelectorAll(u));a.matches&&a.matches(u)&&m.push(a);for(let p=0;p<m.length;p++){const v=m[p];if(!document.contains(v)){const S=v[l.attribute];if(S&&typeof S.destroy=="function")try{S.destroy()}catch(A){console.error("["+l.attribute+"] destroy failed",v,A)}delete v[l.attribute]}}}}}}function Me(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,N(function(){new MutationObserver(function(r){for(let i=0;i<r.length;i++){const a=r[i];if(a.type==="childList")try{Te(a)}catch(d){console.error("[ln-core] lifecycle handler failed",a.target,d)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Fe(t,r,i,a,d={}){const l=d.extraAttributes||[],u=d.onAttributeChange||null,m=d.onSubtreeChange||null,p=d.onInit||null,v=d.onAttrChange||null,S=d.effects||null,A=d.attributes||null,L=A?Le(A):S,M=A?new Set(Object.keys(A)):null,F=d.persist||null;function O(Q){const C=Q||document.body;if(z(C,t,r,i),A&&J())for(const q in A){const V=A[q],e=Array.from(C.querySelectorAll("["+q+"]"));C.matches&&C.matches("["+q+"]")&&e.push(C);for(let n=0;n<e.length;n++){const o=e[n];$(o)&&ne(V,o.getAttribute(q),q,a,o)}}p&&p(C)}const G=[];if(t.indexOf("[")!==-1){const Q=/\[([\w-]+)/g;let C;for(;(C=Q.exec(t))!==null;)G.push(C[1])}else G.push(t);Oe({selector:t,attribute:r,componentTag:a,attributes:A,ComponentFn:i,onInit:p,observed:G.concat(l),onAttributeChange:u,onAttrChange:v,effects:L,declared:M,persist:F}),Ge();const W=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]";ie().push({selector:t,attribute:r,ComponentFn:i,onInit:p,onSubtreeChange:m,query:W}),Me(),window[r]=O;function R(){De()>0?Ie(function(){O(document.body)}):O(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",R):R(),O}function Qe(t,r){let i=!1;return function(){i||(i=!0,queueMicrotask(function(){i=!1,t()}))}}function ae(t){return(t||"").replace(/^#/,"")}function K(t){const r=t===void 0?location.hash:t,i={},a=ae(r);if(!a)return i;const d=a.split("&");for(let l=0;l<d.length;l++){const u=d[l];if(!u)continue;const m=u.indexOf(":"),p=m>-1?u.slice(0,m):u,v=m>-1?u.slice(m+1):"";if(p)try{i[p]=decodeURIComponent(v)}catch{i[p]=v}}return i}function je(t){if(!t)return null;const r=K();return t in r?r[t]:null}function Ne(t,r){if(!t)return;const i=K();r==null?delete i[t]:i[t]=String(r);const d=Object.keys(i).map(function(l){const u=i[l];return u===""?l:l+":"+encodeURIComponent(u)}).join("&");ae(location.hash)!==d&&(location.hash=d)}function Pe(t){return t.button===1||t.ctrlKey||t.metaKey||t.shiftKey?!1:(t.preventDefault(),!0)}function $e(t,r){if(!t||!t.hasAttribute("data-ln-hash"))return null;const i=t.getAttribute("data-ln-hash");if(i&&i.trim()!=="")return i.trim();const a=t.getAttribute("data-ln-sort")||t.getAttribute("data-ln-search-for")||t.getAttribute("data-ln-search")||t.getAttribute("data-ln-filter")||t.id;return a?r?a+"-"+r:a:r||null}function Be(t,r){return!r||r==="none"||t===null||t===void 0?null:String(t)+"."+r}function Ue(t){return!t||typeof t!="string"?null:t.endsWith(".asc")?{fieldOrColumn:t.slice(0,-4),direction:"asc"}:t.endsWith(".desc")?{fieldOrColumn:t.slice(0,-5),direction:"desc"}:null}function ze(t,r){return!t||!Array.isArray(r)||r.length===0?null:t+":"+r.map(encodeURIComponent).join(",")}function Ke(t){if(!t||typeof t!="string")return null;const r=t.indexOf(":");if(r===-1)return null;const i=t.slice(0,r),a=t.slice(r+1),d=a?a.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:i,values:d}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=K,window.lnCore.hashGet=je,window.lnCore.hashSet=Ne,window.lnCore.hashLinkClick=Pe,window.lnCore.resolveHashNamespace=$e,window.lnCore.hashSortEncode=Be,window.lnCore.hashSortDecode=Ue,window.lnCore.hashFilterEncode=ze,window.lnCore.hashFilterDecode=Ke);function We(t){return t=t||{},{sort:t.sort,filters:t.filters,search:t.search,offset:t.offset,limit:t.limit,queryGen:t.queryGen}}function j(t,r){const i=!t||!!t.initializationError,a=!!(t&&t.noLocalQuery&&!t.windowed);return r&&(i||!t.canServe||a)?"remote":t&&!t.initializationError?"store":"none"}function P(t,r,i){return i==="store"&&!!r&&!(t&&t.windowed)}function se(t,r){const i=Object.assign({},t);return r&&(i.filters=r.filters,i.search=r.search,i.sort=r.sort),i}class Ve{constructor(){this._pending=new Map}wait(r){return new Promise((i,a)=>{this._pending.set(r,{resolve:i,reject:a})})}resolve(r){return this._settle(r,!1)}reject(r){return this._settle(r,!0)}close(r){const i=r||new Error("Mutation receipt registry closed");for(const a of this._pending.values())a.reject(i);this._pending.clear()}_settle(r,i){const a=r&&r.requestId;if(!a)return!1;const d=this._pending.get(a);return d?(this._pending.delete(a),i?d.reject(r.error||new Error("Store mutation failed")):d.resolve(r),!0):!1}}(function(){const t="data-ln-data-coordinator",r="lnDataCoordinator",i="data-ln-data-coordinator-scope",a="data-ln-data-coordinator-search",d="data-ln-data-coordinator-filters",l="data-ln-data-coordinator-sort-field",u="data-ln-data-coordinator-sort-direction";if(window[r]!==void 0)return;function m(e){const n=e[r];n&&n.refreshMapper()}function p(e){const n=e[r];n&&n._queueQueryRefresh()}function v(e,n){return e.getAttribute(n)||e.id}const S={"data-ln-data-coordinator":{prop:"_name",type:"string",read:v,description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-mapper":{type:"string",effect:m,description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{type:"string",effect:p,description:"Active search query term"},"data-ln-data-coordinator-filters":{type:"string",effect:p,description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{type:"string",effect:p,description:"Active sort field property name"},"data-ln-data-coordinator-sort-direction":{type:"enum",values:["asc","desc"],fallback:"asc",effect:p,description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"},"data-ln-data-coordinator-dict":{type:"marker",description:"Marks dictionary container for coordinator translatable messages"}},A=ke(S),L=new Set;let M=!1,F=null,O=null,G=null;function de(){M||(M=!0,F=function(){h(document,"ln-data-coordinator:online",{}),L.forEach(function(e){e._maybeSync()})},O=function(){h(document,"ln-data-coordinator:offline",{})},G=function(){document.visibilityState==="visible"&&L.forEach(function(e){const n=e.findChildren(),o=n.store;o&&n.connector&&o.isInitialized&&!o.initializationError&&!o.isSyncing&&!e._noAutosync&&(!o.hasCache||e._isStale())&&o.forceSync()})},window.addEventListener("online",F),window.addEventListener("offline",O),document.addEventListener("visibilitychange",G))}function W(){M&&(L.size>0||(window.removeEventListener("online",F),window.removeEventListener("offline",O),document.removeEventListener("visibilitychange",G),F=null,O=null,G=null,M=!1))}function R(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})}}const Q=["ln-api-connector","ln-couchdb-connector","ln-websocket-connector"];function C(e){return e?e.hasAttribute("data-ln-couchdb-connector")?"ln-couchdb-connector":e.hasAttribute("data-ln-websocket-connector")?"ln-websocket-connector":"ln-api-connector":"ln-api-connector"}function q(e){const n=this;return this.dom=e,Se(this,e,A),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",e),e[r]=this,this._destroyed=!1,this.mapper=null,this._handlers=null,this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._queryGens=new WeakMap,this._mutationReceipts=new Ve,this._dict=we(e,"data-ln-data-coordinator-dict"),this._queueQueryRefresh=Qe(function(){n._destroyed||n._refreshAll(null,!0)}),this.refreshConfig(),V(this),L.add(this),de(),this._checkInitialSync(),this}Object.defineProperty(q.prototype,"_staleThreshold",{get:function(){const n=this.findChildren().storeEl,o=this.dom.getAttribute("data-ln-data-coordinator-stale")||(n?n.getAttribute("data-ln-data-store-stale"):null);if(o==="never"||o==="-1")return-1;const s=parseInt(o,10);return isNaN(s)?300:s}}),Object.defineProperty(q.prototype,"_noAutosync",{get:function(){const n=this.findChildren().storeEl;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||(n?n.hasAttribute("data-ln-data-store-no-autosync"):!1)}}),q.prototype.refreshConfig=function(){this.refreshMapper()},q.prototype._isStale=function(){if(this._staleThreshold===-1)return!1;const n=this.findChildren().store;return!n||!n.lastSyncedAt?!0:Date.now()/1e3-n.lastSyncedAt>this._staleThreshold},q.prototype._maybeSync=function(){const e=this.findChildren(),n=e.store;!n||n.initializationError||!e.connector||this._noAutosync||!n.isInitialized||n.isSyncing||(!n.hasCache||this._isStale())&&n.forceSync()},q.prototype._checkInitialSync=function(){const e=this,o=this.findChildren().store;o&&Promise.resolve(o.ready).then(function(){if(e._destroyed)return;const s=e.findChildren(),c=s.store;if(c&&c.initializationError){e._reportReconciliationError("store-initialize",c.initializationError,null);return}!c||!s.connector||e._noAutosync||c.isSyncing||(!c.hasCache||e._isStale())&&c.forceSync()}).catch(function(s){e._destroyed||e._reportReconciliationError("store-initialize",s,null)})},q.prototype.refreshMapper=function(){this.mapper=null,this.dom.querySelector("script[data-ln-mapper]")&&console.error("[ln-data-coordinator] Security Error: Inline script mappers using <script data-ln-mapper> are deprecated and disabled due to XSS vulnerability risks (unsafe-eval). Please register your mappers securely via window.lnCore.registerDataMapper() instead.");const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id;n&&window.lnCore&&typeof window.lnCore.getDataMapper=="function"&&(this.mapper=window.lnCore.getDataMapper(n)),this.mapper||(this.mapper={}),typeof this.mapper.ingress!="function"&&(this.mapper.ingress=function(o){return o}),typeof this.mapper.egress!="function"&&(this.mapper.egress=function(o){return o})},q.prototype.findChildren=function(){const e=this.dom.querySelector("[data-ln-data-store]"),n=this.dom.querySelector("[data-ln-api-connector], [data-ln-couchdb-connector]")||this.dom.querySelector("[data-ln-websocket-connector]"),o=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:e,connectorEl:n,queueEl:o,store:e?e.lnDataStore:null,connector:n?n.lnApiConnector||n.lnCouchDbConnector||n.lnWebsocketConnector:null,queue:o?o.lnApiQueue:null}},q.prototype._handleSubmitRecord=function(e){const n=this.findChildren();if(!n.storeEl&&!n.connectorEl){console.warn('[ln-data-coordinator] form submit claimed but neither [data-ln-data-store] nor a connector child found in "'+(this._name||"")+'"');return}const o=e.data||{},s=o.id,c=o.expected_version,f=Object.assign({},o);delete f.id,delete f.expected_version;const g=e.method.toUpperCase();g==="POST"?this._fanOutCreate(n,f,e.action):(g==="PUT"||g==="PATCH")&&this._fanOutUpdate(n,s,f,c,e.action)},q.prototype._fanOutCreate=function(e,n,o){this.refreshMapper();const s="_temp_"+R();e.storeEl&&h(e.storeEl,"ln-data-store:request-create",{tempId:s,data:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:s,op:"create",targetId:null,payload:this.mapper.egress(n),expectedVersion:null,meta:{tempId:s,action:o}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-create",{data:this.mapper.egress(n),url:o,meta:{entryId:R(),queued:!1,op:"create",tempId:s}})},q.prototype._fanOutUpdate=function(e,n,o,s,c){this.refreshMapper(),e.storeEl&&h(e.storeEl,"ln-data-store:request-update",{id:n,data:o}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:n,op:"update",targetId:n,payload:this.mapper.egress(o),expectedVersion:s,meta:{id:n,action:c}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-update",{id:n,data:this.mapper.egress(o),expected_version:s,url:c,meta:{entryId:R(),queued:!1,op:"update",id:n}})},q.prototype._fanOutDelete=function(e,n){this.refreshMapper(),e.storeEl&&h(e.storeEl,"ln-data-store:request-delete",{id:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:n,op:"delete",targetId:n,payload:null,expectedVersion:null,meta:{id:n}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-delete",{id:n,meta:{entryId:R(),queued:!1,op:"delete",id:n}})},q.prototype._fanOutBulkDelete=function(e,n){this.refreshMapper();const o=n.join(",");e.storeEl&&h(e.storeEl,"ln-data-store:request-bulk-delete",{ids:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:o,op:"bulk-delete",targetId:null,payload:{ids:n},expectedVersion:null,meta:{bulkKey:o,ids:n}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-bulk-delete",{ids:n,meta:{entryId:R(),queued:!1,op:"bulk-delete",bulkKey:o}})},q.prototype._toastFromMessage=function(e){e&&h(window,"ln-toast:enqueue",{type:e.type||"success",title:e.title||"",message:e.body||""})},q.prototype._toastFromDict=function(e){const n=this._dict[e];n&&h(window,"ln-toast:enqueue",{type:"error",title:"",message:n})},q.prototype._requestStoreMutation=function(e,n,o){const s=e.storeEl;if(!s)return Promise.reject(new Error("Store element not found"));const c=R(),f=this._mutationReceipts.wait(c);return h(s,"ln-data-store:request-"+n,Object.assign({},o,{requestId:c})),f},q.prototype._reportReconciliationError=function(e,n,o){this._destroyed||h(this.dom,"ln-data-coordinator:error",{operation:e,error:n,meta:o||null})};function V(e){e._handlers={sync:function(n){e.refreshMapper();const o=e.findChildren();if(!o.store||!o.connector){console.warn("[ln-data-coordinator] Cannot sync: store or connector not found in subtree");return}h(o.connectorEl,C(o.connectorEl)+":request-sync",{since:n.detail.since,meta:{op:"sync"}})},requestPage:function(n){const o=e.findChildren();if(!o.connectorEl)return;const s=n.detail||{};h(o.connectorEl,C(o.connectorEl)+":request-query",{query:Object.assign({},s.query,{offset:s.offset,limit:s.limit,queryGen:s.queryGen})})},reqCreate:function(n){const o=e.findChildren();e._fanOutCreate(o,n.detail.data||{},n.detail.action)},reqUpdate:function(n){const o=e.findChildren();e._fanOutUpdate(o,n.detail.id,n.detail.data||{},n.detail.expected_version,n.detail.action)},reqDelete:function(n){const o=e.findChildren();e._fanOutDelete(o,n.detail.id)},reqBulkDelete:function(n){const o=e.findChildren();e._fanOutBulkDelete(o,n.detail.ids||[])},queueFailed:function(){e._toastFromDict("network")},queueSend:function(n){e.refreshMapper();const o=e.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.detail||{},c=s.entryId,f=s.op,g=s.targetId,y=s.payload,b=s.expectedVersion,w=s.meta||{},E=w.action||null,_=s.idempotencyKey||c;f==="create"?h(o.connectorEl,C(o.connectorEl)+":request-create",{data:y,url:E,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"create",tempId:w.tempId}}):f==="update"?h(o.connectorEl,C(o.connectorEl)+":request-update",{id:g,data:y,expected_version:b,url:E,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"update",id:g}}):f==="delete"?h(o.connectorEl,C(o.connectorEl)+":request-delete",{id:g,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"delete",id:g}}):f==="bulk-delete"?h(o.connectorEl,C(o.connectorEl)+":request-bulk-delete",{ids:y&&y.ids?y.ids:[],idempotencyKey:_,meta:{entryId:c,queued:!0,op:"bulk-delete",bulkKey:w.bulkKey}}):console.warn("[ln-data-coordinator] Unknown queue op:",f)},formSubmit:function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(i)?o.getAttribute(i):null;if(s===null)return;let c;if(s?c=e._owns(s):c=o.closest("[data-ln-data-coordinator]")===e.dom,!c)return;const f=le(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const g=ce(o);delete g._method,delete g._token,e._handleSubmitRecord({data:g,method:f,action:o.getAttribute("action")||""})},connFetched:function(n){const o=n.detail.meta||{},s=e.findChildren();e.refreshMapper();const c=n.detail.data;let f=[],g=[],y=null;Array.isArray(c)?(f=c,y=Math.floor(Date.now()/1e3)):c&&(f=Array.isArray(c.data)?c.data:[],g=Array.isArray(c.deleted)?c.deleted:[],y=c.synced_at!==void 0?c.synced_at:c.since!==void 0?c.since:null);const b=f.map(w=>e.mapper.ingress(w));if(s.store&&!s.store.initializationError)o.kind?o.kind==="table"||o.kind==="list"||o.kind==="chart"?s.store.applyQuery(b,{total:n.detail.total}).then(function(w){o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen)||(h(o.targetEl,"ln-"+o.kind+":set-loading",{loading:!1}),h(o.targetEl,"ln-"+o.kind+":set-data",{data:w,total:n.detail.total!==void 0?n.detail.total:w.length,filtered:n.detail.filtered!==void 0?n.detail.filtered:w.length,offset:n.detail.offset,queryGen:n.detail.queryGen}),e._boundDelivered.set(o.targetEl,!0))}):o.kind==="options"?s.store.applyQuery(b,{total:n.detail.total}).then(function(){return s.store.getAll({})}).then(function(w){o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen)||h(o.targetEl,"ln-options:set-data",{data:w.data})}):o.kind==="stat"&&s.store.applyQuery(b,{total:n.detail.total}).then(function(){if(o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen))return;const w=n.detail.filtered!==void 0?n.detail.filtered:n.detail.total!==void 0?n.detail.total:b.length;h(o.targetEl,"ln-stat:set-count",{count:w})}):s.store.applySync(b,g,y||Math.floor(Date.now()/1e3),{total:n.detail.total,filtered:n.detail.filtered,offset:n.detail.offset,queryGen:n.detail.queryGen,targetEl:o.targetEl});else if(o.targetEl&&o.kind){if(o.kind==="table"||o.kind==="list"||o.kind==="chart")h(o.targetEl,"ln-"+o.kind+":set-loading",{loading:!1}),h(o.targetEl,"ln-"+o.kind+":set-data",{data:b,total:n.detail.total!==void 0?n.detail.total:b.length,filtered:n.detail.filtered!==void 0?n.detail.filtered:b.length,offset:n.detail.offset,queryGen:n.detail.queryGen}),e._boundDelivered.set(o.targetEl,!0);else if(o.kind==="options")h(o.targetEl,"ln-options:set-data",{data:b});else if(o.kind==="stat"){const w=n.detail.filtered!==void 0?n.detail.filtered:n.detail.total!==void 0?n.detail.total:b.length;h(o.targetEl,"ln-stat:set-count",{count:w})}}},connCreated:function(n){const o=e.findChildren(),s=n.detail.meta||{},c=e.mapper.ingress(n.detail.record);(o.storeEl?e._requestStoreMutation(o,"update",{id:s.tempId,data:c}):Promise.resolve()).then(function(){e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:resolve-create",{entryId:s.entryId,oldKey:s.tempId,newId:c.id})}).catch(function(g){e._reportReconciliationError("create-reconcile",g,s)})},connUpdated:function(n){const o=e.findChildren(),s=n.detail.meta||{},c=e.mapper.ingress(n.detail.record);(o.storeEl?e._requestStoreMutation(o,"update",{id:s.id,data:c}):Promise.resolve()).then(function(){e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:ack",{entryId:s.entryId})}).catch(function(g){e._reportReconciliationError("update-reconcile",g,s)})},connDeleted:function(n){const o=e.findChildren(),s=n.detail.meta||{};e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:ack",{entryId:s.entryId})},connBulkDeleted:function(n){const o=e.findChildren(),s=n.detail.meta||{};e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:ack",{entryId:s.entryId})},connError:function(n){const o=n.detail||{},s=o.meta||{},c=s.op||o.action,f=o.status||o.error&&o.error.status||0,g=e.findChildren();if(c==="sync"){g.storeEl&&h(g.storeEl,"ln-data-store:request-sync-failed",{error:o.error,status:f}),console.error("[ln-data-coordinator] Sync failed:",o.error);return}if(c==="query"){s.targetEl&&s.kind&&(h(s.targetEl,"ln-"+s.kind+":set-loading",{loading:!1}),(s.kind==="table"||s.kind==="list")&&h(s.targetEl,"ln-"+s.kind+":page-failed",{offset:s.offset})),e._reportReconciliationError("query",o.error||o,s);return}const y=f===401||f===419,b=f===0||f>=500,w=f===409||f===412;if(y){e._toastFromDict("auth"),s.queued&&g.queue&&h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"auth"});return}if(b){s.queued&&g.queue?h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"retry"}):e._toastFromDict("network");return}let E=Promise.resolve();if(w&&c==="update"){const _=o.data&&o.data.remote?e.mapper.ingress(o.data.remote):null;_&&g.storeEl&&(E=e._requestStoreMutation(g,"update",{id:s.id,data:_})),e._toastFromDict("conflict")}else c==="create"&&g.storeEl&&(E=e._requestStoreMutation(g,"delete",{id:s.tempId})),e._toastFromDict("rejected");s.queued&&g.queue?E.then(function(){h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"drop"})}).catch(function(_){e._reportReconciliationError("deterministic-reconcile",_,s)}):E.catch(function(_){e._reportReconciliationError("deterministic-reconcile",_,s)})},storeInitialized:function(n){const o=e.findChildren(),s=o.store;if(!s||s.initializationError||!o.connector||e._noAutosync||s.isSyncing)return;(n.detail||{}).hasCache?e._isStale()&&s.forceSync():s.forceSync()},socketConnected:function(){const n=e.findChildren(),o=n.store;!o||o.initializationError||!n.connector||e._noAutosync||!o.isInitialized||o.isSyncing||o.forceSync()},reqTableData:function(n){e._serveData(n,"table")},reqListData:function(n){e._serveData(n,"list")},reqChartData:function(n){e._serveData(n,"chart")},reqOptions:function(n){e._serveOptions(n)},reqStat:function(n){e._serveStat(n)},refreshQuery:function(){e._refreshAll(null,!0)},refresh:function(n){e._mutationReceipts.resolve(n.detail),e._refreshAll(null,!1)},mutationError:function(n){e._mutationReceipts.reject(n.detail)},refreshSynced:function(n){n.detail&&n.detail.changed&&e._refreshAll(n.detail.meta,!1)},searchChange:function(n){n.preventDefault();const o=n.detail&&n.detail.term!=null?n.detail.term:"";o!==(e.dom.getAttribute(a)||"")&&e.dom.setAttribute(a,o)},filterChange:function(n){n.preventDefault();const o=n.detail&&n.detail.key;if(!o)return;const s=(n.detail.values||[]).slice(),c=e._currentQuery().filters,f=c[o];if(f?f.length===s.length&&f.every((w,E)=>w===s[E]):!s.length)return;s.length?c[o]=s:delete c[o];const y=new URLSearchParams;Object.keys(c).forEach(function(w){c[w].forEach(function(E){y.append(w,E)})});const b=y.toString();b?e.dom.setAttribute(d,b):e.dom.removeAttribute(d)},sortChange:function(n){n.preventDefault();const o=n.detail&&n.detail.field,s=n.detail&&n.detail.direction,c=o&&s&&s!=="none"?{field:o,direction:s}:null,f=e._currentQuery().sort;!f&&!c||f&&c&&f.field===c.field&&f.direction===c.direction||(c?(e.dom.setAttribute(l,c.field),e.dom.setAttribute(u,c.direction)):(e.dom.removeAttribute(l),e.dom.removeAttribute(u)))}},e.dom.addEventListener("ln-data-store:request-remote-sync",e._handlers.sync),e.dom.addEventListener("ln-data-store:request-page",e._handlers.requestPage),e.dom.addEventListener("ln-data-coordinator:request-create",e._handlers.reqCreate),e.dom.addEventListener("ln-data-coordinator:request-update",e._handlers.reqUpdate),e.dom.addEventListener("ln-data-coordinator:request-delete",e._handlers.reqDelete),e.dom.addEventListener("ln-data-coordinator:request-bulk-delete",e._handlers.reqBulkDelete),e.dom.addEventListener("ln-api-queue:send",e._handlers.queueSend),e.dom.addEventListener("ln-api-queue:failed",e._handlers.queueFailed),e.dom.addEventListener("ln-data-store:initialized",e._handlers.storeInitialized),e.dom.addEventListener("ln-websocket-connector:connected",e._handlers.socketConnected),document.addEventListener("submit",e._handlers.formSubmit),Q.forEach(function(n){e.dom.addEventListener(n+":fetched",e._handlers.connFetched),e.dom.addEventListener(n+":created",e._handlers.connCreated),e.dom.addEventListener(n+":updated",e._handlers.connUpdated),e.dom.addEventListener(n+":deleted",e._handlers.connDeleted),e.dom.addEventListener(n+":bulk-deleted",e._handlers.connBulkDeleted),e.dom.addEventListener(n+":error",e._handlers.connError)}),document.addEventListener("ln-table:request-data",e._handlers.reqTableData),document.addEventListener("ln-list:request-data",e._handlers.reqListData),document.addEventListener("ln-chart:request-data",e._handlers.reqChartData),document.addEventListener("ln-options:request-data",e._handlers.reqOptions),document.addEventListener("ln-stat:request-count",e._handlers.reqStat),e.dom.addEventListener("ln-data-store:ready",e._handlers.refresh),e.dom.addEventListener("ln-data-store:created",e._handlers.refresh),e.dom.addEventListener("ln-data-store:updated",e._handlers.refresh),e.dom.addEventListener("ln-data-store:deleted",e._handlers.refresh),e.dom.addEventListener("ln-data-store:mutation-error",e._handlers.mutationError),e.dom.addEventListener("ln-data-store:synced",e._handlers.refreshSynced),e.dom.addEventListener("ln-data-store:query-changed",e._handlers.refreshQuery),e.dom.addEventListener("ln-search:change",e._handlers.searchChange),e.dom.addEventListener("ln-filter:change",e._handlers.filterChange),e.dom.addEventListener("ln-sort:change",e._handlers.sortChange)}q.prototype._owns=function(e){return!!e&&e===this._name},q.prototype._currentQuery=function(){const e=this.dom.getAttribute(l),n=this.dom.getAttribute(u),o=new URLSearchParams(this.dom.getAttribute(d)||""),s={};for(const c of new Set(o.keys()))s[c]=o.getAll(c);return{search:this.dom.getAttribute(a)||"",filters:s,sort:e&&n?{field:e,direction:n}:null}},q.prototype._nextQueryGen=function(e){const n=(this._queryGens.get(e)||0)+1;return this._queryGens.set(e,n),n},q.prototype._isCurrentGen=function(e,n){return this._queryGens.get(e)===n},q.prototype._serveData=function(e,n){const o=e.target,s=n==="table"?"data-ln-table-source":n==="list"?"data-ln-list-source":"data-ln-chart-source",c=o.getAttribute(s);if(!c||!this._owns(c))return;const f=e.detail||{},g=We(f);this._boundQueries.set(o,g);const y=this.findChildren(),b=this,w=y.store;return(w&&w.ready?w.ready:Promise.resolve()).then(function(){if(b._destroyed)return;const _=j(w,y.connector),k=se(g,b._currentQuery());if(_==="remote"){const I=b._nextQueryGen(o);h(o,"ln-"+n+":set-loading",{loading:!0}),h(y.connectorEl,C(y.connectorEl)+":request-query",{query:k,meta:{targetEl:o,kind:n,offset:k.offset,limit:k.limit,queryGen:I}});return}if(_!=="store"){h(o,"ln-"+n+":set-loading",{loading:!1});return}const x=P(w,y.connector,_),D=x?b._nextQueryGen(o):null;return x&&h(y.connectorEl,C(y.connectorEl)+":request-query",{query:k,meta:{targetEl:o,kind:n,offset:k.offset,limit:k.limit,queryGen:D}}),w.getAll(k).then(function(I){if(b._destroyed||!b._boundDelivered||x&&!b._isCurrentGen(o,D))return;const H={data:I.data,total:I.total,filtered:I.filtered,offset:f.offset!==void 0?f.offset:I.offset,queryGen:f.queryGen!==void 0?f.queryGen:I.queryGen,provisional:x||I.provisional===!0};h(o,"ln-"+n+":set-data",H),b._boundDelivered.set(o,!0)})}).catch(function(_){b._destroyed||(h(o,"ln-"+n+":set-loading",{loading:!1}),h(b.dom,"ln-data-coordinator:error",{operation:"query",kind:n,store:c,target:o,error:_}))})},q.prototype._serveOptions=function(e){const n=e.target,o=n.getAttribute("data-ln-options");if(!this._owns(o))return;const s=this.findChildren(),c=s.store,f=c&&c.ready?c.ready:Promise.resolve(),g=this;return f.then(function(){if(g._destroyed)return;const y=j(c,s.connector);if(y==="remote"){const E=g._nextQueryGen(n);h(s.connectorEl,C(s.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:"options",queryGen:E}});return}if(y!=="store")return;const b=P(c,s.connector,y),w=b?g._nextQueryGen(n):null;return b&&h(s.connectorEl,C(s.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:"options",queryGen:w}}),c.getAll({}).then(function(E){g._destroyed||b&&!g._isCurrentGen(n,w)||h(n,"ln-options:set-data",{data:E.data})})}).catch(function(y){g._destroyed||g._reportReconciliationError("options-query",y,{targetEl:n,kind:"options"})})},q.prototype._serveStat=function(e){const n=e.target,o=n.getAttribute("data-ln-stat");if(!this._owns(o))return;const s=e.detail&&e.detail.filters?e.detail.filters:null,c=this.findChildren(),f=c.store,g=f&&f.ready?f.ready:Promise.resolve(),y=this;return g.then(function(){if(y._destroyed)return;const b=s&&Object.keys(s).length>0,w=!!(c.connector&&f&&(f.windowed&&b||f.noLocalQuery)),E=w?"remote":j(f,c.connector);if(E==="remote"){const x=y._nextQueryGen(n);h(c.connectorEl,C(c.connectorEl)+":request-query",{query:{filters:s},meta:{targetEl:n,kind:"stat",queryGen:x}});return}if(E!=="store")return;const _=!w&&P(f,c.connector,E),k=_?y._nextQueryGen(n):null;return _&&h(c.connectorEl,C(c.connectorEl)+":request-query",{query:{filters:s},meta:{targetEl:n,kind:"stat",queryGen:k}}),f.count(s).then(function(x){y._destroyed||_&&!y._isCurrentGen(n,k)||h(n,"ln-stat:set-count",{count:x})})}).catch(function(b){y._destroyed||y._reportReconciliationError("stat-query",b,{targetEl:n,kind:"stat"})})},q.prototype._refreshAll=function(e,n){const o=this,s=document.querySelectorAll("[data-ln-table-source],[data-ln-list-source],[data-ln-chart-source],[data-ln-options],[data-ln-stat]");for(let c=0;c<s.length;c++){const f=s[c];let g,y;if(f.hasAttribute("data-ln-table-source")?(g=f.getAttribute("data-ln-table-source"),y="table"):f.hasAttribute("data-ln-list-source")?(g=f.getAttribute("data-ln-list-source"),y="list"):f.hasAttribute("data-ln-chart-source")?(g=f.getAttribute("data-ln-chart-source"),y="chart"):f.hasAttribute("data-ln-options")?(g=f.getAttribute("data-ln-options"),y="options"):f.hasAttribute("data-ln-stat")&&(g=f.getAttribute("data-ln-stat"),y="stat"),!o._owns(g))continue;const b=o.findChildren(),w=b.store;if(y==="table"||y==="list"){const E=y==="table"?"data-ln-table-window":"data-ln-list-window";if(f.hasAttribute(E)){h(f,"ln-"+y+(n?":request-invalidate":":request-revalidate"),{});continue}}if(y==="table"||y==="list"||y==="chart"){const E=o._boundQueries.get(f)||{sort:null,filters:{},search:""},_=se(E,o._currentQuery());if(j(w,b.connector)==="remote"){const D=o._nextQueryGen(f);h(f,"ln-"+y+":set-loading",{loading:!0}),h(b.connectorEl,C(b.connectorEl)+":request-query",{query:_,meta:{targetEl:f,kind:y,offset:_.offset,limit:_.limit,queryGen:D}});continue}const k=P(w,b.connector,j(w,b.connector)),x=k?o._nextQueryGen(f):null;k&&h(b.connectorEl,C(b.connectorEl)+":request-query",{query:_,meta:{targetEl:f,kind:y,offset:_.offset,limit:_.limit,queryGen:x}}),(function(D,I,H,He){w.getAll(_).then(function(T){if(o._destroyed||!o._boundDelivered||H&&!o._isCurrentGen(D,He))return;const Je={data:T.data,total:e&&e.total!==void 0?e.total:T.total,filtered:e&&e.filtered!==void 0?e.filtered:T.filtered,offset:T.offset!==void 0?T.offset:e&&e.offset!==void 0?e.offset:E.offset,queryGen:T.queryGen!==void 0?T.queryGen:e&&e.queryGen!==void 0?e.queryGen:E.queryGen};h(D,"ln-"+I+":set-loading",{loading:!1}),h(D,"ln-"+I+":set-data",Je),o._boundDelivered.set(D,!0)}).catch(function(){})})(f,y,k,x)}else if(y==="options")(function(E){w.getAll({}).then(function(_){o._destroyed||h(E,"ln-options:set-data",{data:_.data})}).catch(function(){})})(f);else if(y==="stat"){const E=f.getAttribute("data-ln-stat-filter");let _=null;if(E){const k=E.indexOf(":");if(k!==-1){const x=E.slice(0,k).trim(),D=E.slice(k+1).trim();x&&(_={},_[x]=[D])}}(function(k,x){w.count(x).then(function(D){o._destroyed||h(k,"ln-stat:set-count",{count:D})}).catch(function(){})})(f,_)}}},q.prototype.destroy=function(){if(!this.dom[r])return;this._destroyed=!0;const e=this;e._handlers&&(e.dom.removeEventListener("ln-data-store:request-remote-sync",e._handlers.sync),e.dom.removeEventListener("ln-data-store:request-page",e._handlers.requestPage),e.dom.removeEventListener("ln-data-coordinator:request-create",e._handlers.reqCreate),e.dom.removeEventListener("ln-data-coordinator:request-update",e._handlers.reqUpdate),e.dom.removeEventListener("ln-data-coordinator:request-delete",e._handlers.reqDelete),e.dom.removeEventListener("ln-data-coordinator:request-bulk-delete",e._handlers.reqBulkDelete),e.dom.removeEventListener("ln-api-queue:send",e._handlers.queueSend),e.dom.removeEventListener("ln-api-queue:failed",e._handlers.queueFailed),e.dom.removeEventListener("ln-data-store:initialized",e._handlers.storeInitialized),e.dom.removeEventListener("ln-websocket-connector:connected",e._handlers.socketConnected),document.removeEventListener("submit",e._handlers.formSubmit),Q.forEach(function(n){e.dom.removeEventListener(n+":fetched",e._handlers.connFetched),e.dom.removeEventListener(n+":created",e._handlers.connCreated),e.dom.removeEventListener(n+":updated",e._handlers.connUpdated),e.dom.removeEventListener(n+":deleted",e._handlers.connDeleted),e.dom.removeEventListener(n+":bulk-deleted",e._handlers.connBulkDeleted),e.dom.removeEventListener(n+":error",e._handlers.connError)}),document.removeEventListener("ln-table:request-data",e._handlers.reqTableData),document.removeEventListener("ln-list:request-data",e._handlers.reqListData),document.removeEventListener("ln-chart:request-data",e._handlers.reqChartData),document.removeEventListener("ln-options:request-data",e._handlers.reqOptions),document.removeEventListener("ln-stat:request-count",e._handlers.reqStat),e.dom.removeEventListener("ln-data-store:ready",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:created",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:updated",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:deleted",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:mutation-error",e._handlers.mutationError),e.dom.removeEventListener("ln-data-store:synced",e._handlers.refreshSynced),e.dom.removeEventListener("ln-data-store:query-changed",e._handlers.refreshQuery),e.dom.removeEventListener("ln-search:change",e._handlers.searchChange),e.dom.removeEventListener("ln-filter:change",e._handlers.filterChange),e.dom.removeEventListener("ln-sort:change",e._handlers.sortChange),e._handlers=null),e._boundQueries=null,e._boundDelivered=null,e._queryGens=null,e._queueQueryRefresh=null,e._mutationReceipts.close(new Error("Data coordinator destroyed")),e._mutationReceipts=null,L.delete(this),W(),delete this.dom[r]},Fe(t,r,q,"ln-data-coordinator",{attributes:S})})()})();
1
+ (function(){"use strict";function J(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function $(t){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return t?window.lnCore._debugIsContained(t):window.lnCore._debugSink!==null;if(t&&t.closest){const r=t.closest("[data-ln-debug]");return!(!r||typeof document<"u"&&r===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const t=console.warn;console.warn=function(...r){if(typeof r[0]=="string"&&(r[0].startsWith("[ln-")||r[0].startsWith("[lnCore"))){let a=null;for(let d=1;d<r.length;d++)if(r[d]&&r[d].nodeType===1){a=r[d];break}if(!$(a))return}t.apply(console,r)}}function h(t,r,i){const a=i||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",r,t,a),t.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:a}))}function N(t,r){if(!document.body){document.addEventListener("DOMContentLoaded",function(){N(t,r)}),console.warn("["+r+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function le(t){const r=t.querySelector('input[name="_method"]');return((r&&r.value!==""?r.value:t.method)||"").toUpperCase()}function ce(t,r){const i={},a=t.elements;for(let d=0;d<a.length;d++){const l=a[d];if(!(!l.name||l.disabled||l.type==="file"||l.type==="submit"||l.type==="button"))if(l.type==="checkbox")i[l.name]||(i[l.name]=[]),l.checked&&i[l.name].push(l.value);else if(l.type==="radio")l.checked&&(i[l.name]=l.value);else if(l.type==="select-multiple"){i[l.name]=[];for(let u=0;u<l.options.length;u++)l.options[u].selected&&i[l.name].push(l.options[u].value)}else i[l.name]=l.value}return i}const X={};function ue(t,r){X[t]=r}function fe(t){return X[t]||{ingress:r=>r,egress:r=>r}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=ue,window.lnCore.getDataMapper=fe);function he(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,N(function(){new MutationObserver(function(){h(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const Y={};function pe(t,r){if(!t||typeof r!="object")return;const i=t.toLowerCase().split("-")[0];Y[i]=r}function me(t){if(!t)return null;const r=t.toLowerCase().split("-")[0];return Y[r]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=pe,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=he);const B={};function ye(t,r){B[t]||(B[t]=document.querySelector('[data-ln-template="'+t+'"]'));const i=B[t];return i?i.content.cloneNode(!0):(console.warn("["+(r||"ln-core")+'] Template "'+t+'" not found'),null)}function Z(t,r){if(!t||!r)return t;const i=t.querySelectorAll("[data-ln-field]");for(let u=0;u<i.length;u++){const m=i[u],p=m.getAttribute("data-ln-field");r[p]!=null&&(m.textContent=r[p])}const a=t.querySelectorAll("[data-ln-attr]");for(let u=0;u<a.length;u++){const m=a[u],p=m.getAttribute("data-ln-attr").split(",");for(let v=0;v<p.length;v++){const S=p[v].trim().split(":");if(S.length!==2)continue;const A=S[0].trim(),L=S[1].trim();r[L]!=null&&m.setAttribute(A,r[L])}}const d=t.querySelectorAll("[data-ln-show]");for(let u=0;u<d.length;u++){const m=d[u],p=m.getAttribute("data-ln-show");p in r&&m.classList.toggle("hidden",!r[p])}const l=t.querySelectorAll("[data-ln-class]");for(let u=0;u<l.length;u++){const m=l[u],p=m.getAttribute("data-ln-class").split(",");for(let v=0;v<p.length;v++){const S=p[v].trim().split(":");if(S.length!==2)continue;const A=S[0].trim(),L=S[1].trim();L in r&&m.classList.toggle(A,!!r[L])}}return t}function ge(t,r){t.matches&&t.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",t,r??null),t.dispatchEvent(new CustomEvent("ln-fill",{detail:r??null,bubbles:!0})));const i=t.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let a=0;a<i.length;a++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",i[a],r??null),i[a].dispatchEvent(new CustomEvent("ln-fill",{detail:r??null,bubbles:!0}));return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(t){if(!(!t.target.matches||!t.target.matches("[data-ln-fillable]")))if(t.detail)Z(t.target,t.detail);else{const r=t.target.querySelectorAll("[data-ln-field]");for(let i=0;i<r.length;i++)r[i].textContent=""}})));function ee(t,r){if(!t||!r)return t;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;i.nextNode();){const l=i.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(u,m){return r[m]!==void 0?r[m]:""}))}const a=function(l,u){return r[u]!==void 0?r[u]:""},d=Array.from(t.querySelectorAll("*"));t.nodeType===1&&d.push(t);for(let l=0;l<d.length;l++){const u=d[l],m=u.attributes;for(let p=0;p<m.length;p++){const v=m[p];v.value.indexOf("{{")!==-1&&u.setAttribute(v.name,v.value.replace(/\{\{\s*(\w+)\s*\}\}/g,a))}}return t}function be(t,r,i,a,d,l){const u={};for(let p=0;p<t.children.length;p++){const v=t.children[p],S=v.getAttribute("data-ln-render-key");S&&(u[S]=v)}const m=document.createDocumentFragment();for(let p=0;p<r.length;p++){const v=r[p],S=String(a(v));let A=u[S];if(A)d(A,v,p);else{const L=ye(i,l);if(!L||(ee(L,v),A=L.firstElementChild,!A))continue;A.setAttribute("data-ln-render-key",S),d(A,v,p)}m.appendChild(A)}t.textContent="",t.appendChild(m)}function we(t,r){const i={},a=t.querySelectorAll("["+r+"]");for(let d=0;d<a.length;d++)i[a[d].getAttribute(r)]=a[d].textContent,a[d].remove();return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=ee,window.lnCore.fill=Z,window.lnCore.lnFill=ge,window.lnCore.renderList=be);function te(t,r,i){const a=t.getAttribute(r);return a===null?i:a}function _e(t,r,i){const a=parseInt(t.getAttribute(r),10);return isNaN(a)?i:a}function qe(t,r,i=!1){const a=t.getAttribute(r);if(a===null)return!!i;const d=a.trim().toLowerCase();return!(d==="false"||d==="0")}function Ee(t,r){return(t.getAttribute(r)||"").split(",").map(i=>i.trim()).filter(Boolean)}const U=new Map;function ve(t,r){const i=(t?t.join("|"):"")+"::"+r;if(U.has(i))return U.get(i);const a=new Set(t||[]),d=function(l,u){const m=l.getAttribute(u);return m!==null&&a.has(m)?m:r};return U.set(i,d),d}function Ce(t,r,i){const a=parseFloat(t.getAttribute(r));return isNaN(a)?i:a}function Ae(t,r,i){const a=t.getAttribute(r);if(!a)return i;try{return JSON.parse(a)}catch{return i}}function ne(t,r,i,a,d){if(!t||r===null)return!0;const l=a||"ln-component",u=t.type;if(u==="trigger"||u==="marker"||u==="string"||u==="list"||!u||r===""&&t.fallback!==void 0)return!0;const m=p=>{d?console.warn(p,d):console.warn(p)};if(u==="boolean"){const p=r.trim().toLowerCase();return p!==""&&p!=="true"&&p!=="false"&&p!=="1"&&p!=="0"?(m(`[${l}] Invalid value "${r}" for boolean attribute "${i}". Allowed: "true", "false", or presence-only.`),!1):!0}if(u==="enum"){const p=t.values||[];return p.includes(r)?!0:(m(`[${l}] Invalid value "${r}" for attribute "${i}". Allowed: ${p.join(", ")}. Fallback: "${t.fallback}".`),!1)}if(u==="integer"){if(!/^-?\d+$/.test(r))return m(`[${l}] Invalid integer "${r}" for attribute "${i}". Fallback: ${t.fallback}.`),!1;const p=parseInt(r,10);return t.min!==void 0&&p<t.min?(m(`[${l}] Value ${p} for attribute "${i}" is less than min (${t.min}).`),!1):t.max!==void 0&&p>t.max?(m(`[${l}] Value ${p} for attribute "${i}" is greater than max (${t.max}).`),!1):!0}if(u==="float")return isNaN(Number(r))?(m(`[${l}] Invalid float "${r}" for attribute "${i}". Fallback: ${t.fallback}.`),!1):!0;if(u==="json")try{return JSON.parse(r),!0}catch(p){return m(`[${l}] Invalid JSON for attribute "${i}": ${p.message}. Fallback: ${t.fallback}.`),!1}return!0}function Se(t,r,i){for(const a in i){const[d,l,u]=i[a];Object.defineProperty(t,a,{get:function(){return d(r,l,u)},enumerable:!0,configurable:!0})}return t}function ke(t){const r={};for(const i in t){const a=t[i];if(!a||!a.prop)continue;let d=a.read;if(!d&&a.type)switch(a.type){case"enum":d=ve(a.values,a.fallback);break;case"integer":d=_e;break;case"float":d=Ce;break;case"boolean":d=qe;break;case"list":d=Ee;break;case"json":d=Ae;break;case"string":default:d=te;break}d||(d=te),r[a.prop]=[d,i,a.fallback]}return r}function Le(t){const r={};for(const i in t){const a=t[i];a&&a.effect&&(r[i]=a.effect)}return Object.keys(r).length?r:null}function xe(t){if(t.onAttrChange&&!t.declared)return null;const r=new Set;if(t.effects)for(const i in t.effects)r.add(i);if(t.onAttrChange&&t.declared)for(const i of t.declared)r.add(i);return r}function z(t,r,i,a){if(t.nodeType!==1)return;const l=r.indexOf("[")!==-1||r.indexOf(".")!==-1||r.indexOf("#")!==-1?r:"["+r+"]",u=Array.from(t.querySelectorAll(l));t.matches&&t.matches(l)&&u.push(t);for(const m of u)if(!m[i]){window.lnCore._persistSink&&m.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(m,r);try{m[i]=new a(m)}catch(p){console.error("["+i+"] init failed",m,p)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function De(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function Ie(t){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(t):setTimeout(t,0)):t()}function re(){window.lnCore=window.lnCore||{};const t=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return t.byReactive=t.byReactive||new Map,t.reactiveWildcard=t.reactiveWildcard||[],t}function Oe(t){const r=re(),i=t.observed||[];for(let a=0;a<i.length;a++){const d=i[a];r.byAttr.has(d)||r.byAttr.set(d,[]),r.byAttr.get(d).push(t)}if(r.byDeclaredAttr=r.byDeclaredAttr||new Map,t.attributes)for(const a in t.attributes){r.byDeclaredAttr.has(a)||r.byDeclaredAttr.set(a,[]);const d=r.byDeclaredAttr.get(a);d.some(l=>l.componentTag===t.componentTag)||d.push({spec:t.attributes[a],componentTag:t.componentTag})}if(t.onAttrChange||t.effects){r.reactive.push(t);const a=xe(t);if(a===null)r.reactiveWildcard.push(t);else for(const d of a)r.byReactive.has(d)||r.byReactive.set(d,[]),r.byReactive.get(d).push(t)}t.persist&&r.persist.push(t)}function oe(t,r,i,a){for(let d=0;d<t.length;d++){const l=t[d];if(!r[l.attribute])continue;const u=l.effects&&l.effects[i];u?u(r,i,a):l.onAttrChange&&(!l.declared||l.declared.has(i))&&l.onAttrChange(r,i,a)}}function Re(t){const r=t.target,i=t.attributeName;if(t.oldValue===r.getAttribute(i))return;const a=re(),d=a.byAttr.get(i);if(J()&&a.byDeclaredAttr&&a.byDeclaredAttr.has(i)&&$(r)){const l=a.byDeclaredAttr.get(i),u=r.getAttribute(i);for(let m=0;m<l.length;m++)ne(l[m].spec,u,i,l[m].componentTag,r)}if(window.lnCore._debugSink&&(i.indexOf("data-ln-")===0||d)&&window.lnCore._debugSink("attr",i,r,{oldValue:t.oldValue,newValue:r.getAttribute(i)}),i.indexOf("data-ln-")===0){const l=a.byReactive.get(i);l&&oe(l,r,i,t.oldValue),a.reactiveWildcard.length&&oe(a.reactiveWildcard,r,i,t.oldValue)}if(d)for(let l=0;l<d.length;l++){const u=d[l];if(u.handler){u.handler(r,i,t.oldValue);continue}u.onAttributeChange&&r[u.attribute]?u.onAttributeChange(r,i):(z(r,u.selector,u.attribute,u.ComponentFn),u.onInit&&u.onInit(r))}}function Ge(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,N(function(){new MutationObserver(function(r){for(let i=0;i<r.length;i++)try{Re(r[i])}catch(a){console.error("[ln-core] mutation handler failed",r[i].target,a)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ie(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function Te(t){const r=ie();if(r.length){if(t.target)for(let i=0;i<r.length;i++){const a=r[i];if(a.onSubtreeChange){const d=a.query,l=t.target.nodeType===1?t.target.matches(d)?t.target:t.target.closest(d):t.target.parentElement?t.target.parentElement.closest(d):null;l&&a.onSubtreeChange(l,t)}}for(let i=0;i<t.addedNodes.length;i++){const a=t.addedNodes[i];if(a.nodeType===1)for(let d=0;d<r.length;d++){const l=r[d];z(a,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(a)}}for(let i=0;i<t.removedNodes.length;i++){const a=t.removedNodes[i];if(a.nodeType===1)for(let d=0;d<r.length;d++){const l=r[d],u=l.query,m=Array.from(a.querySelectorAll(u));a.matches&&a.matches(u)&&m.push(a);for(let p=0;p<m.length;p++){const v=m[p];if(!document.contains(v)){const S=v[l.attribute];if(S&&typeof S.destroy=="function")try{S.destroy()}catch(A){console.error("["+l.attribute+"] destroy failed",v,A)}delete v[l.attribute]}}}}}}function Me(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,N(function(){new MutationObserver(function(r){for(let i=0;i<r.length;i++){const a=r[i];if(a.type==="childList")try{Te(a)}catch(d){console.error("[ln-core] lifecycle handler failed",a.target,d)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Fe(t,r,i,a,d={}){const l=d.extraAttributes||[],u=d.onAttributeChange||null,m=d.onSubtreeChange||null,p=d.onInit||null,v=d.onAttrChange||null,S=d.effects||null,A=d.attributes||null,L=A?Le(A):S,M=A?new Set(Object.keys(A)):null,F=d.persist||null;function O(Q){const C=Q||document.body;if(z(C,t,r,i),A&&J())for(const q in A){const V=A[q],e=Array.from(C.querySelectorAll("["+q+"]"));C.matches&&C.matches("["+q+"]")&&e.push(C);for(let n=0;n<e.length;n++){const o=e[n];$(o)&&ne(V,o.getAttribute(q),q,a,o)}}p&&p(C)}const G=[];if(t.indexOf("[")!==-1){const Q=/\[([\w-]+)/g;let C;for(;(C=Q.exec(t))!==null;)G.push(C[1])}else G.push(t);Oe({selector:t,attribute:r,componentTag:a,attributes:A,ComponentFn:i,onInit:p,observed:G.concat(l),onAttributeChange:u,onAttrChange:v,effects:L,declared:M,persist:F}),Ge();const W=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]";ie().push({selector:t,attribute:r,ComponentFn:i,onInit:p,onSubtreeChange:m,query:W}),Me(),window[r]=O;function R(){De()>0?Ie(function(){O(document.body)}):O(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",R):R(),O}function Qe(t,r){let i=!1;return function(){i||(i=!0,queueMicrotask(function(){i=!1,t()}))}}function ae(t){return(t||"").replace(/^#/,"")}function K(t){const r=t===void 0?location.hash:t,i={},a=ae(r);if(!a)return i;const d=a.split("&");for(let l=0;l<d.length;l++){const u=d[l];if(!u)continue;const m=u.indexOf(":"),p=m>-1?u.slice(0,m):u,v=m>-1?u.slice(m+1):"";if(p)try{i[p]=decodeURIComponent(v)}catch{i[p]=v}}return i}function je(t){if(!t)return null;const r=K();return t in r?r[t]:null}function Ne(t,r){if(!t)return;const i=K();r==null?delete i[t]:i[t]=String(r);const d=Object.keys(i).map(function(l){const u=i[l];return u===""?l:l+":"+encodeURIComponent(u)}).join("&");ae(location.hash)!==d&&(location.hash=d)}function Pe(t){return t.button===1||t.ctrlKey||t.metaKey||t.shiftKey?!1:(t.preventDefault(),!0)}function $e(t,r){if(!t||!t.hasAttribute("data-ln-hash"))return null;const i=t.getAttribute("data-ln-hash");if(i&&i.trim()!=="")return i.trim();const a=t.getAttribute("data-ln-sort")||t.getAttribute("data-ln-search-for")||t.getAttribute("data-ln-search")||t.getAttribute("data-ln-filter")||t.id;return a?r?a+"-"+r:a:r||null}function Be(t,r){return!r||r==="none"||t===null||t===void 0?null:String(t)+"."+r}function Ue(t){return!t||typeof t!="string"?null:t.endsWith(".asc")?{fieldOrColumn:t.slice(0,-4),direction:"asc"}:t.endsWith(".desc")?{fieldOrColumn:t.slice(0,-5),direction:"desc"}:null}function ze(t,r){return!t||!Array.isArray(r)||r.length===0?null:t+":"+r.map(encodeURIComponent).join(",")}function Ke(t){if(!t||typeof t!="string")return null;const r=t.indexOf(":");if(r===-1)return null;const i=t.slice(0,r),a=t.slice(r+1),d=a?a.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:i,values:d}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=K,window.lnCore.hashGet=je,window.lnCore.hashSet=Ne,window.lnCore.hashLinkClick=Pe,window.lnCore.resolveHashNamespace=$e,window.lnCore.hashSortEncode=Be,window.lnCore.hashSortDecode=Ue,window.lnCore.hashFilterEncode=ze,window.lnCore.hashFilterDecode=Ke);function We(t){return t=t||{},{sort:t.sort,filters:t.filters,search:t.search,offset:t.offset,limit:t.limit,queryGen:t.queryGen}}function j(t,r){const i=!t||!!t.initializationError,a=!!(t&&t.noLocalQuery&&!t.windowed);return r&&(i||!t.canServe||a)?"remote":t&&!t.initializationError?"store":"none"}function P(t,r,i){return i==="store"&&!!r&&!(t&&t.windowed)}function se(t,r){const i=Object.assign({},t);return r&&(i.filters=r.filters,i.search=r.search,i.sort=r.sort),i}class Ve{constructor(){this._pending=new Map}wait(r){return new Promise((i,a)=>{this._pending.set(r,{resolve:i,reject:a})})}resolve(r){return this._settle(r,!1)}reject(r){return this._settle(r,!0)}close(r){const i=r||new Error("Mutation receipt registry closed");for(const a of this._pending.values())a.reject(i);this._pending.clear()}_settle(r,i){const a=r&&r.requestId;if(!a)return!1;const d=this._pending.get(a);return d?(this._pending.delete(a),i?d.reject(r.error||new Error("Store mutation failed")):d.resolve(r),!0):!1}}(function(){const t="data-ln-data-coordinator",r="lnDataCoordinator",i="data-ln-data-coordinator-scope",a="data-ln-data-coordinator-search",d="data-ln-data-coordinator-filters",l="data-ln-data-coordinator-sort-field",u="data-ln-data-coordinator-sort-direction";if(window[r]!==void 0)return;function m(e){const n=e[r];n&&n.refreshMapper()}function p(e){const n=e[r];n&&n._queueQueryRefresh()}function v(e,n){return e.getAttribute(n)||e.id}const S={"data-ln-data-coordinator":{prop:"_name",type:"string",read:v,description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-mapper":{type:"string",effect:m,description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{type:"string",effect:p,description:"Active search query term"},"data-ln-data-coordinator-filters":{type:"string",effect:p,description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{type:"string",effect:p,description:"Active sort field property name"},"data-ln-data-coordinator-sort-direction":{type:"enum",values:["asc","desc"],fallback:"asc",effect:p,description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"},"data-ln-data-coordinator-dict":{type:"marker",description:"Marks dictionary container for coordinator translatable messages"}},A=ke(S),L=new Set;let M=!1,F=null,O=null,G=null;function de(){M||(M=!0,F=function(){h(document,"ln-data-coordinator:online",{}),L.forEach(function(e){e._maybeSync()})},O=function(){h(document,"ln-data-coordinator:offline",{})},G=function(){document.visibilityState==="visible"&&L.forEach(function(e){const n=e.findChildren(),o=n.store;o&&n.connector&&o.isInitialized&&!o.initializationError&&!o.isSyncing&&!e._noAutosync&&(!o.hasCache||e._isStale())&&o.forceSync()})},window.addEventListener("online",F),window.addEventListener("offline",O),document.addEventListener("visibilitychange",G))}function W(){M&&(L.size>0||(window.removeEventListener("online",F),window.removeEventListener("offline",O),document.removeEventListener("visibilitychange",G),F=null,O=null,G=null,M=!1))}function R(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})}}const Q=["ln-api-connector","ln-couchdb-connector","ln-websocket-connector"];function C(e){return e?e.hasAttribute("data-ln-couchdb-connector")?"ln-couchdb-connector":e.hasAttribute("data-ln-websocket-connector")?"ln-websocket-connector":"ln-api-connector":"ln-api-connector"}function q(e){const n=this;return this.dom=e,Se(this,e,A),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",e),e[r]=this,this._destroyed=!1,this.mapper=null,this._handlers=null,this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._queryGens=new WeakMap,this._mutationReceipts=new Ve,this._dict=we(e,"data-ln-data-coordinator-dict"),this._queueQueryRefresh=Qe(function(){n._destroyed||n._refreshAll(null,!0)}),this.refreshConfig(),V(this),L.add(this),de(),this._checkInitialSync(),this}Object.defineProperty(q.prototype,"_staleThreshold",{get:function(){const n=this.findChildren().storeEl,o=this.dom.getAttribute("data-ln-data-coordinator-stale")||(n?n.getAttribute("data-ln-data-store-stale"):null);if(o==="never"||o==="-1")return-1;const s=parseInt(o,10);return isNaN(s)?300:s}}),Object.defineProperty(q.prototype,"_noAutosync",{get:function(){const n=this.findChildren().storeEl;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||(n?n.hasAttribute("data-ln-data-store-no-autosync"):!1)}}),q.prototype.refreshConfig=function(){this.refreshMapper()},q.prototype._isStale=function(){if(this._staleThreshold===-1)return!1;const n=this.findChildren().store;return!n||!n.lastSyncedAt?!0:Date.now()/1e3-n.lastSyncedAt>this._staleThreshold},q.prototype._maybeSync=function(){const e=this.findChildren(),n=e.store;!n||n.initializationError||!e.connector||this._noAutosync||!n.isInitialized||n.isSyncing||(!n.hasCache||this._isStale())&&n.forceSync()},q.prototype._checkInitialSync=function(){const e=this,o=this.findChildren().store;o&&Promise.resolve(o.ready).then(function(){if(e._destroyed)return;const s=e.findChildren(),c=s.store;if(c&&c.initializationError){e._reportReconciliationError("store-initialize",c.initializationError,null);return}!c||!s.connector||e._noAutosync||c.isSyncing||(!c.hasCache||e._isStale())&&c.forceSync()}).catch(function(s){e._destroyed||e._reportReconciliationError("store-initialize",s,null)})},q.prototype.refreshMapper=function(){this.mapper=null,this.dom.querySelector("script[data-ln-mapper]")&&console.error("[ln-data-coordinator] Security Error: Inline script mappers using <script data-ln-mapper> are deprecated and disabled due to XSS vulnerability risks (unsafe-eval). Please register your mappers securely via window.lnCore.registerDataMapper() instead.");const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id;n&&window.lnCore&&typeof window.lnCore.getDataMapper=="function"&&(this.mapper=window.lnCore.getDataMapper(n)),this.mapper||(this.mapper={}),typeof this.mapper.ingress!="function"&&(this.mapper.ingress=function(o){return o}),typeof this.mapper.egress!="function"&&(this.mapper.egress=function(o){return o})},q.prototype.findChildren=function(){const e=this.dom.querySelector("[data-ln-data-store]"),n=this.dom.querySelector("[data-ln-api-connector], [data-ln-couchdb-connector]")||this.dom.querySelector("[data-ln-websocket-connector]"),o=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:e,connectorEl:n,queueEl:o,store:e?e.lnDataStore:null,connector:n?n.lnApiConnector||n.lnCouchDbConnector||n.lnWebsocketConnector:null,queue:o?o.lnApiQueue:null}},q.prototype._handleSubmitRecord=function(e){const n=this.findChildren();if(!n.storeEl&&!n.connectorEl){console.warn('[ln-data-coordinator] form submit claimed but neither [data-ln-data-store] nor a connector child found in "'+(this._name||"")+'"');return}const o=e.data||{},s=o.id,c=o.expected_version,f=Object.assign({},o);delete f.id,delete f.expected_version;const g=e.method.toUpperCase();g==="POST"?this._fanOutCreate(n,f,e.action):(g==="PUT"||g==="PATCH")&&this._fanOutUpdate(n,s,f,c,e.action)},q.prototype._fanOutCreate=function(e,n,o){this.refreshMapper();const s="_temp_"+R();e.storeEl&&h(e.storeEl,"ln-data-store:request-create",{tempId:s,data:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:s,op:"create",targetId:null,payload:this.mapper.egress(n),expectedVersion:null,meta:{tempId:s,action:o}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-create",{data:this.mapper.egress(n),url:o,meta:{entryId:R(),queued:!1,op:"create",tempId:s}})},q.prototype._fanOutUpdate=function(e,n,o,s,c){this.refreshMapper(),e.storeEl&&h(e.storeEl,"ln-data-store:request-update",{id:n,data:o}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:n,op:"update",targetId:n,payload:this.mapper.egress(o),expectedVersion:s,meta:{id:n,action:c}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-update",{id:n,data:this.mapper.egress(o),expected_version:s,url:c,meta:{entryId:R(),queued:!1,op:"update",id:n}})},q.prototype._fanOutDelete=function(e,n){this.refreshMapper(),e.storeEl&&h(e.storeEl,"ln-data-store:request-delete",{id:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:n,op:"delete",targetId:n,payload:null,expectedVersion:null,meta:{id:n}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-delete",{id:n,meta:{entryId:R(),queued:!1,op:"delete",id:n}})},q.prototype._fanOutBulkDelete=function(e,n){this.refreshMapper();const o=n.join(",");e.storeEl&&h(e.storeEl,"ln-data-store:request-bulk-delete",{ids:n}),e.queue?h(e.queueEl,"ln-api-queue:request-enqueue",{chainKey:o,op:"bulk-delete",targetId:null,payload:{ids:n},expectedVersion:null,meta:{bulkKey:o,ids:n}}):e.connector&&h(e.connectorEl,C(e.connectorEl)+":request-bulk-delete",{ids:n,meta:{entryId:R(),queued:!1,op:"bulk-delete",bulkKey:o}})},q.prototype._toastFromMessage=function(e){e&&h(window,"ln-toast:enqueue",{type:e.type||"success",title:e.title||"",message:e.body||""})},q.prototype._toastFromDict=function(e){const n=this._dict[e];n&&h(window,"ln-toast:enqueue",{type:"error",title:"",message:n})},q.prototype._requestStoreMutation=function(e,n,o){const s=e.storeEl;if(!s)return Promise.reject(new Error("Store element not found"));const c=R(),f=this._mutationReceipts.wait(c);return h(s,"ln-data-store:request-"+n,Object.assign({},o,{requestId:c})),f},q.prototype._reportReconciliationError=function(e,n,o){this._destroyed||h(this.dom,"ln-data-coordinator:error",{operation:e,error:n,meta:o||null})};function V(e){e._handlers={sync:function(n){e.refreshMapper();const o=e.findChildren();if(!o.store||!o.connector){console.warn("[ln-data-coordinator] Cannot sync: store or connector not found in subtree");return}h(o.connectorEl,C(o.connectorEl)+":request-sync",{since:n.detail.since,meta:{op:"sync"}})},requestPage:function(n){const o=e.findChildren();if(!o.connectorEl)return;const s=n.detail||{};h(o.connectorEl,C(o.connectorEl)+":request-query",{query:Object.assign({},s.query,{offset:s.offset,limit:s.limit,queryGen:s.queryGen})})},reqCreate:function(n){const o=e.findChildren();e._fanOutCreate(o,n.detail.data||{},n.detail.action)},reqUpdate:function(n){const o=e.findChildren();e._fanOutUpdate(o,n.detail.id,n.detail.data||{},n.detail.expected_version,n.detail.action)},reqDelete:function(n){const o=e.findChildren();e._fanOutDelete(o,n.detail.id)},reqBulkDelete:function(n){const o=e.findChildren();e._fanOutBulkDelete(o,n.detail.ids||[])},queueFailed:function(){e._toastFromDict("network")},queueSend:function(n){e.refreshMapper();const o=e.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.detail||{},c=s.entryId,f=s.op,g=s.targetId,y=s.payload,b=s.expectedVersion,w=s.meta||{},E=w.action||null,_=s.idempotencyKey||c;f==="create"?h(o.connectorEl,C(o.connectorEl)+":request-create",{data:y,url:E,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"create",tempId:w.tempId}}):f==="update"?h(o.connectorEl,C(o.connectorEl)+":request-update",{id:g,data:y,expected_version:b,url:E,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"update",id:g}}):f==="delete"?h(o.connectorEl,C(o.connectorEl)+":request-delete",{id:g,idempotencyKey:_,meta:{entryId:c,queued:!0,op:"delete",id:g}}):f==="bulk-delete"?h(o.connectorEl,C(o.connectorEl)+":request-bulk-delete",{ids:y&&y.ids?y.ids:[],idempotencyKey:_,meta:{entryId:c,queued:!0,op:"bulk-delete",bulkKey:w.bulkKey}}):console.warn("[ln-data-coordinator] Unknown queue op:",f)},formSubmit:function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(i)?o.getAttribute(i):null;if(s===null)return;let c;if(s?c=e._owns(s):c=o.closest("[data-ln-data-coordinator]")===e.dom,!c)return;const f=le(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const g=ce(o);delete g._method,delete g._token,e._handleSubmitRecord({data:g,method:f,action:o.getAttribute("action")||""})},connFetched:function(n){if(!n.detail)return;const o=n.detail.meta||{},s=e.findChildren();e.refreshMapper();const c=n.detail.data;let f=[],g=[],y=null;Array.isArray(c)?(f=c,y=Math.floor(Date.now()/1e3)):c&&(f=Array.isArray(c.data)?c.data:[],g=Array.isArray(c.deleted)?c.deleted:[],y=c.synced_at!==void 0?c.synced_at:c.since!==void 0?c.since:null);const b=f.map(w=>e.mapper.ingress(w));if(s.store&&!s.store.initializationError)o.kind?o.kind==="table"||o.kind==="list"||o.kind==="chart"?s.store.applyQuery(b,{total:n.detail.total}).then(function(w){o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen)||(h(o.targetEl,"ln-"+o.kind+":set-loading",{loading:!1}),h(o.targetEl,"ln-"+o.kind+":set-data",{data:w,total:n.detail.total!==void 0?n.detail.total:w.length,filtered:n.detail.filtered!==void 0?n.detail.filtered:w.length,offset:n.detail.offset,queryGen:n.detail.queryGen}),e._boundDelivered.set(o.targetEl,!0))}):o.kind==="options"?s.store.applyQuery(b,{total:n.detail.total}).then(function(){return s.store.getAll({})}).then(function(w){o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen)||h(o.targetEl,"ln-options:set-data",{data:w.data})}):o.kind==="stat"&&s.store.applyQuery(b,{total:n.detail.total}).then(function(){if(o.queryGen!=null&&!e._isCurrentGen(o.targetEl,o.queryGen))return;const w=n.detail.filtered!==void 0?n.detail.filtered:n.detail.total!==void 0?n.detail.total:b.length;h(o.targetEl,"ln-stat:set-count",{count:w})}):s.store.applySync(b,g,y||Math.floor(Date.now()/1e3),{total:n.detail.total,filtered:n.detail.filtered,offset:n.detail.offset,queryGen:n.detail.queryGen,targetEl:o.targetEl});else if(o.targetEl&&o.kind){if(o.kind==="table"||o.kind==="list"||o.kind==="chart")h(o.targetEl,"ln-"+o.kind+":set-loading",{loading:!1}),h(o.targetEl,"ln-"+o.kind+":set-data",{data:b,total:n.detail.total!==void 0?n.detail.total:b.length,filtered:n.detail.filtered!==void 0?n.detail.filtered:b.length,offset:n.detail.offset,queryGen:n.detail.queryGen}),e._boundDelivered.set(o.targetEl,!0);else if(o.kind==="options")h(o.targetEl,"ln-options:set-data",{data:b});else if(o.kind==="stat"){const w=n.detail.filtered!==void 0?n.detail.filtered:n.detail.total!==void 0?n.detail.total:b.length;h(o.targetEl,"ln-stat:set-count",{count:w})}}},connCreated:function(n){if(!n.detail)return;const o=e.findChildren(),s=n.detail.meta||{};if(!n.detail.record){e._reportReconciliationError("create-empty-response",new Error("Create response missing record payload"),s);return}const c=e.mapper.ingress(n.detail.record);(o.storeEl?e._requestStoreMutation(o,"update",{id:s.tempId,data:c}):Promise.resolve()).then(function(){e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:resolve-create",{entryId:s.entryId,oldKey:s.tempId,newId:c.id})}).catch(function(g){e._reportReconciliationError("create-reconcile",g,s)})},connUpdated:function(n){if(!n.detail)return;const o=e.findChildren(),s=n.detail.meta||{},c=n.detail.record?e.mapper.ingress(n.detail.record):null;(o.storeEl&&c?e._requestStoreMutation(o,"update",{id:s.id,data:c}):Promise.resolve()).then(function(){e._toastFromMessage(n.detail.message),s.queued&&o.queue&&h(o.queueEl,"ln-api-queue:ack",{entryId:s.entryId})}).catch(function(g){e._reportReconciliationError("update-reconcile",g,s)})},connDeleted:function(n){const o=n.detail||{},s=e.findChildren(),c=o.meta||{};e._toastFromMessage(o.message),c.queued&&s.queue&&h(s.queueEl,"ln-api-queue:ack",{entryId:c.entryId})},connBulkDeleted:function(n){const o=n.detail||{},s=e.findChildren(),c=o.meta||{};e._toastFromMessage(o.message),c.queued&&s.queue&&h(s.queueEl,"ln-api-queue:ack",{entryId:c.entryId})},connError:function(n){const o=n.detail||{},s=o.meta||{},c=s.op||o.action,f=o.status||o.error&&o.error.status||0,g=e.findChildren();if(c==="sync"){g.storeEl&&h(g.storeEl,"ln-data-store:request-sync-failed",{error:o.error,status:f}),console.error("[ln-data-coordinator] Sync failed:",o.error);return}if(c==="query"){s.targetEl&&s.kind&&(h(s.targetEl,"ln-"+s.kind+":set-loading",{loading:!1}),(s.kind==="table"||s.kind==="list")&&h(s.targetEl,"ln-"+s.kind+":page-failed",{offset:s.offset})),e._reportReconciliationError("query",o.error||o,s);return}const y=f===401||f===419,b=f===0||f>=500,w=f===409||f===412;if(y){e._toastFromDict("auth"),s.queued&&g.queue&&h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"auth"});return}if(b){s.queued&&g.queue?h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"retry"}):e._toastFromDict("network");return}let E=Promise.resolve();if(w&&c==="update"){const _=o.data&&o.data.remote?e.mapper.ingress(o.data.remote):null;_&&g.storeEl&&(E=e._requestStoreMutation(g,"update",{id:s.id,data:_})),e._toastFromDict("conflict")}else c==="create"&&g.storeEl&&(E=e._requestStoreMutation(g,"delete",{id:s.tempId})),e._toastFromDict("rejected");s.queued&&g.queue?E.then(function(){h(g.queueEl,"ln-api-queue:nack",{entryId:s.entryId,reason:"drop"})}).catch(function(_){e._reportReconciliationError("deterministic-reconcile",_,s)}):E.catch(function(_){e._reportReconciliationError("deterministic-reconcile",_,s)})},storeInitialized:function(n){const o=e.findChildren(),s=o.store;if(!s||s.initializationError||!o.connector||e._noAutosync||s.isSyncing)return;(n.detail||{}).hasCache?e._isStale()&&s.forceSync():s.forceSync()},socketConnected:function(){const n=e.findChildren(),o=n.store;!o||o.initializationError||!n.connector||e._noAutosync||!o.isInitialized||o.isSyncing||o.forceSync()},reqTableData:function(n){e._serveData(n,"table")},reqListData:function(n){e._serveData(n,"list")},reqChartData:function(n){e._serveData(n,"chart")},reqOptions:function(n){e._serveOptions(n)},reqStat:function(n){e._serveStat(n)},refreshQuery:function(){e._refreshAll(null,!0)},refresh:function(n){e._mutationReceipts.resolve(n.detail),e._refreshAll(null,!1)},mutationError:function(n){e._mutationReceipts.reject(n.detail)},refreshSynced:function(n){n.detail&&n.detail.changed&&e._refreshAll(n.detail.meta,!1)},searchChange:function(n){n.preventDefault();const o=n.detail&&n.detail.term!=null?n.detail.term:"";o!==(e.dom.getAttribute(a)||"")&&e.dom.setAttribute(a,o)},filterChange:function(n){n.preventDefault();const o=n.detail&&n.detail.key;if(!o)return;const s=(n.detail.values||[]).slice(),c=e._currentQuery().filters,f=c[o];if(f?f.length===s.length&&f.every((w,E)=>w===s[E]):!s.length)return;s.length?c[o]=s:delete c[o];const y=new URLSearchParams;Object.keys(c).forEach(function(w){c[w].forEach(function(E){y.append(w,E)})});const b=y.toString();b?e.dom.setAttribute(d,b):e.dom.removeAttribute(d)},sortChange:function(n){n.preventDefault();const o=n.detail&&n.detail.field,s=n.detail&&n.detail.direction,c=o&&s&&s!=="none"?{field:o,direction:s}:null,f=e._currentQuery().sort;!f&&!c||f&&c&&f.field===c.field&&f.direction===c.direction||(c?(e.dom.setAttribute(l,c.field),e.dom.setAttribute(u,c.direction)):(e.dom.removeAttribute(l),e.dom.removeAttribute(u)))}},e.dom.addEventListener("ln-data-store:request-remote-sync",e._handlers.sync),e.dom.addEventListener("ln-data-store:request-page",e._handlers.requestPage),e.dom.addEventListener("ln-data-coordinator:request-create",e._handlers.reqCreate),e.dom.addEventListener("ln-data-coordinator:request-update",e._handlers.reqUpdate),e.dom.addEventListener("ln-data-coordinator:request-delete",e._handlers.reqDelete),e.dom.addEventListener("ln-data-coordinator:request-bulk-delete",e._handlers.reqBulkDelete),e.dom.addEventListener("ln-api-queue:send",e._handlers.queueSend),e.dom.addEventListener("ln-api-queue:failed",e._handlers.queueFailed),e.dom.addEventListener("ln-data-store:initialized",e._handlers.storeInitialized),e.dom.addEventListener("ln-websocket-connector:connected",e._handlers.socketConnected),document.addEventListener("submit",e._handlers.formSubmit),Q.forEach(function(n){e.dom.addEventListener(n+":fetched",e._handlers.connFetched),e.dom.addEventListener(n+":created",e._handlers.connCreated),e.dom.addEventListener(n+":updated",e._handlers.connUpdated),e.dom.addEventListener(n+":deleted",e._handlers.connDeleted),e.dom.addEventListener(n+":bulk-deleted",e._handlers.connBulkDeleted),e.dom.addEventListener(n+":error",e._handlers.connError)}),document.addEventListener("ln-table:request-data",e._handlers.reqTableData),document.addEventListener("ln-list:request-data",e._handlers.reqListData),document.addEventListener("ln-chart:request-data",e._handlers.reqChartData),document.addEventListener("ln-options:request-data",e._handlers.reqOptions),document.addEventListener("ln-stat:request-count",e._handlers.reqStat),e.dom.addEventListener("ln-data-store:ready",e._handlers.refresh),e.dom.addEventListener("ln-data-store:created",e._handlers.refresh),e.dom.addEventListener("ln-data-store:updated",e._handlers.refresh),e.dom.addEventListener("ln-data-store:deleted",e._handlers.refresh),e.dom.addEventListener("ln-data-store:mutation-error",e._handlers.mutationError),e.dom.addEventListener("ln-data-store:synced",e._handlers.refreshSynced),e.dom.addEventListener("ln-data-store:query-changed",e._handlers.refreshQuery),e.dom.addEventListener("ln-search:change",e._handlers.searchChange),e.dom.addEventListener("ln-filter:change",e._handlers.filterChange),e.dom.addEventListener("ln-sort:change",e._handlers.sortChange)}q.prototype._owns=function(e){return!!e&&e===this._name},q.prototype._currentQuery=function(){const e=this.dom.getAttribute(l),n=this.dom.getAttribute(u),o=new URLSearchParams(this.dom.getAttribute(d)||""),s={};for(const c of new Set(o.keys()))s[c]=o.getAll(c);return{search:this.dom.getAttribute(a)||"",filters:s,sort:e&&n?{field:e,direction:n}:null}},q.prototype._nextQueryGen=function(e){const n=(this._queryGens.get(e)||0)+1;return this._queryGens.set(e,n),n},q.prototype._isCurrentGen=function(e,n){return this._queryGens.get(e)===n},q.prototype._serveData=function(e,n){const o=e.target,s=n==="table"?"data-ln-table-source":n==="list"?"data-ln-list-source":"data-ln-chart-source",c=o.getAttribute(s);if(!c||!this._owns(c))return;const f=e.detail||{},g=We(f);this._boundQueries.set(o,g);const y=this.findChildren(),b=this,w=y.store;return(w&&w.ready?w.ready:Promise.resolve()).then(function(){if(b._destroyed)return;const _=j(w,y.connector),k=se(g,b._currentQuery());if(_==="remote"){const I=b._nextQueryGen(o);h(o,"ln-"+n+":set-loading",{loading:!0}),h(y.connectorEl,C(y.connectorEl)+":request-query",{query:k,meta:{targetEl:o,kind:n,offset:k.offset,limit:k.limit,queryGen:I}});return}if(_!=="store"){h(o,"ln-"+n+":set-loading",{loading:!1});return}const x=P(w,y.connector,_),D=x?b._nextQueryGen(o):null;return x&&h(y.connectorEl,C(y.connectorEl)+":request-query",{query:k,meta:{targetEl:o,kind:n,offset:k.offset,limit:k.limit,queryGen:D}}),w.getAll(k).then(function(I){if(b._destroyed||!b._boundDelivered||x&&!b._isCurrentGen(o,D))return;const H={data:I.data,total:I.total,filtered:I.filtered,offset:f.offset!==void 0?f.offset:I.offset,queryGen:f.queryGen!==void 0?f.queryGen:I.queryGen,provisional:x||I.provisional===!0};h(o,"ln-"+n+":set-data",H),b._boundDelivered.set(o,!0)})}).catch(function(_){b._destroyed||(h(o,"ln-"+n+":set-loading",{loading:!1}),h(b.dom,"ln-data-coordinator:error",{operation:"query",kind:n,store:c,target:o,error:_}))})},q.prototype._serveOptions=function(e){const n=e.target,o=n.getAttribute("data-ln-options");if(!this._owns(o))return;const s=this.findChildren(),c=s.store,f=c&&c.ready?c.ready:Promise.resolve(),g=this;return f.then(function(){if(g._destroyed)return;const y=j(c,s.connector);if(y==="remote"){const E=g._nextQueryGen(n);h(s.connectorEl,C(s.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:"options",queryGen:E}});return}if(y!=="store")return;const b=P(c,s.connector,y),w=b?g._nextQueryGen(n):null;return b&&h(s.connectorEl,C(s.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:"options",queryGen:w}}),c.getAll({}).then(function(E){g._destroyed||b&&!g._isCurrentGen(n,w)||h(n,"ln-options:set-data",{data:E.data})})}).catch(function(y){g._destroyed||g._reportReconciliationError("options-query",y,{targetEl:n,kind:"options"})})},q.prototype._serveStat=function(e){const n=e.target,o=n.getAttribute("data-ln-stat");if(!this._owns(o))return;const s=e.detail&&e.detail.filters?e.detail.filters:null,c=this.findChildren(),f=c.store,g=f&&f.ready?f.ready:Promise.resolve(),y=this;return g.then(function(){if(y._destroyed)return;const b=s&&Object.keys(s).length>0,w=!!(c.connector&&f&&(f.windowed&&b||f.noLocalQuery)),E=w?"remote":j(f,c.connector);if(E==="remote"){const x=y._nextQueryGen(n);h(c.connectorEl,C(c.connectorEl)+":request-query",{query:{filters:s},meta:{targetEl:n,kind:"stat",queryGen:x}});return}if(E!=="store")return;const _=!w&&P(f,c.connector,E),k=_?y._nextQueryGen(n):null;return _&&h(c.connectorEl,C(c.connectorEl)+":request-query",{query:{filters:s},meta:{targetEl:n,kind:"stat",queryGen:k}}),f.count(s).then(function(x){y._destroyed||_&&!y._isCurrentGen(n,k)||h(n,"ln-stat:set-count",{count:x})})}).catch(function(b){y._destroyed||y._reportReconciliationError("stat-query",b,{targetEl:n,kind:"stat"})})},q.prototype._refreshAll=function(e,n){const o=this,s=document.querySelectorAll("[data-ln-table-source],[data-ln-list-source],[data-ln-chart-source],[data-ln-options],[data-ln-stat]");for(let c=0;c<s.length;c++){const f=s[c];let g,y;if(f.hasAttribute("data-ln-table-source")?(g=f.getAttribute("data-ln-table-source"),y="table"):f.hasAttribute("data-ln-list-source")?(g=f.getAttribute("data-ln-list-source"),y="list"):f.hasAttribute("data-ln-chart-source")?(g=f.getAttribute("data-ln-chart-source"),y="chart"):f.hasAttribute("data-ln-options")?(g=f.getAttribute("data-ln-options"),y="options"):f.hasAttribute("data-ln-stat")&&(g=f.getAttribute("data-ln-stat"),y="stat"),!o._owns(g))continue;const b=o.findChildren(),w=b.store;if(y==="table"||y==="list"){const E=y==="table"?"data-ln-table-window":"data-ln-list-window";if(f.hasAttribute(E)){h(f,"ln-"+y+(n?":request-invalidate":":request-revalidate"),{});continue}}if(y==="table"||y==="list"||y==="chart"){const E=o._boundQueries.get(f)||{sort:null,filters:{},search:""},_=se(E,o._currentQuery());if(j(w,b.connector)==="remote"){const D=o._nextQueryGen(f);h(f,"ln-"+y+":set-loading",{loading:!0}),h(b.connectorEl,C(b.connectorEl)+":request-query",{query:_,meta:{targetEl:f,kind:y,offset:_.offset,limit:_.limit,queryGen:D}});continue}const k=P(w,b.connector,j(w,b.connector)),x=k?o._nextQueryGen(f):null;k&&h(b.connectorEl,C(b.connectorEl)+":request-query",{query:_,meta:{targetEl:f,kind:y,offset:_.offset,limit:_.limit,queryGen:x}}),(function(D,I,H,He){w.getAll(_).then(function(T){if(o._destroyed||!o._boundDelivered||H&&!o._isCurrentGen(D,He))return;const Je={data:T.data,total:e&&e.total!==void 0?e.total:T.total,filtered:e&&e.filtered!==void 0?e.filtered:T.filtered,offset:T.offset!==void 0?T.offset:e&&e.offset!==void 0?e.offset:E.offset,queryGen:T.queryGen!==void 0?T.queryGen:e&&e.queryGen!==void 0?e.queryGen:E.queryGen};h(D,"ln-"+I+":set-loading",{loading:!1}),h(D,"ln-"+I+":set-data",Je),o._boundDelivered.set(D,!0)}).catch(function(){})})(f,y,k,x)}else if(y==="options")(function(E){w.getAll({}).then(function(_){o._destroyed||h(E,"ln-options:set-data",{data:_.data})}).catch(function(){})})(f);else if(y==="stat"){const E=f.getAttribute("data-ln-stat-filter");let _=null;if(E){const k=E.indexOf(":");if(k!==-1){const x=E.slice(0,k).trim(),D=E.slice(k+1).trim();x&&(_={},_[x]=[D])}}(function(k,x){w.count(x).then(function(D){o._destroyed||h(k,"ln-stat:set-count",{count:D})}).catch(function(){})})(f,_)}}},q.prototype.destroy=function(){if(!this.dom[r])return;this._destroyed=!0;const e=this;e._handlers&&(e.dom.removeEventListener("ln-data-store:request-remote-sync",e._handlers.sync),e.dom.removeEventListener("ln-data-store:request-page",e._handlers.requestPage),e.dom.removeEventListener("ln-data-coordinator:request-create",e._handlers.reqCreate),e.dom.removeEventListener("ln-data-coordinator:request-update",e._handlers.reqUpdate),e.dom.removeEventListener("ln-data-coordinator:request-delete",e._handlers.reqDelete),e.dom.removeEventListener("ln-data-coordinator:request-bulk-delete",e._handlers.reqBulkDelete),e.dom.removeEventListener("ln-api-queue:send",e._handlers.queueSend),e.dom.removeEventListener("ln-api-queue:failed",e._handlers.queueFailed),e.dom.removeEventListener("ln-data-store:initialized",e._handlers.storeInitialized),e.dom.removeEventListener("ln-websocket-connector:connected",e._handlers.socketConnected),document.removeEventListener("submit",e._handlers.formSubmit),Q.forEach(function(n){e.dom.removeEventListener(n+":fetched",e._handlers.connFetched),e.dom.removeEventListener(n+":created",e._handlers.connCreated),e.dom.removeEventListener(n+":updated",e._handlers.connUpdated),e.dom.removeEventListener(n+":deleted",e._handlers.connDeleted),e.dom.removeEventListener(n+":bulk-deleted",e._handlers.connBulkDeleted),e.dom.removeEventListener(n+":error",e._handlers.connError)}),document.removeEventListener("ln-table:request-data",e._handlers.reqTableData),document.removeEventListener("ln-list:request-data",e._handlers.reqListData),document.removeEventListener("ln-chart:request-data",e._handlers.reqChartData),document.removeEventListener("ln-options:request-data",e._handlers.reqOptions),document.removeEventListener("ln-stat:request-count",e._handlers.reqStat),e.dom.removeEventListener("ln-data-store:ready",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:created",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:updated",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:deleted",e._handlers.refresh),e.dom.removeEventListener("ln-data-store:mutation-error",e._handlers.mutationError),e.dom.removeEventListener("ln-data-store:synced",e._handlers.refreshSynced),e.dom.removeEventListener("ln-data-store:query-changed",e._handlers.refreshQuery),e.dom.removeEventListener("ln-search:change",e._handlers.searchChange),e.dom.removeEventListener("ln-filter:change",e._handlers.filterChange),e.dom.removeEventListener("ln-sort:change",e._handlers.sortChange),e._handlers=null),e._boundQueries=null,e._boundDelivered=null,e._queryGens=null,e._queueQueryRefresh=null,e._mutationReceipts.close(new Error("Data coordinator destroyed")),e._mutationReceipts=null,L.delete(this),W(),delete this.dom[r]},Fe(t,r,q,"ln-data-coordinator",{attributes:S})})()})();