@livenetworks/ashlar 2.0.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/components/ln-accordion/ln-accordion.js +1 -1
  2. package/components/ln-ajax/ln-ajax.js +1 -1
  3. package/components/ln-ajax/src/ln-ajax.js +15 -26
  4. package/components/ln-api-connector/ln-api-connector.js +1 -1
  5. package/components/ln-api-queue/ln-api-queue.js +1 -1
  6. package/components/ln-autoresize/ln-autoresize.js +1 -1
  7. package/components/ln-autosave/ln-autosave.js +1 -1
  8. package/components/ln-chart/ln-chart.js +1 -1
  9. package/components/ln-circular-progress/ln-circular-progress.js +1 -1
  10. package/components/ln-confirm/ln-confirm.js +1 -1
  11. package/components/ln-core/helpers.js +1 -1
  12. package/components/ln-core/index.js +1 -1
  13. package/components/ln-core/lifecycle.js +98 -41
  14. package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
  15. package/components/ln-data-coordinator/ln-data-coordinator.js +1 -1
  16. package/components/ln-data-store/ln-data-store.js +1 -1
  17. package/components/ln-date/ln-date.js +1 -1
  18. package/components/ln-debug/ln-debug.js +1 -1
  19. package/components/ln-debug/src/generated-attributes.js +1 -0
  20. package/components/ln-dropdown/ln-dropdown.js +1 -1
  21. package/components/ln-editor/ln-editor.js +1 -1
  22. package/components/ln-external-links/ln-external-links.js +1 -1
  23. package/components/ln-external-links/src/ln-external-links.js +9 -21
  24. package/components/ln-filter/ln-filter.js +1 -1
  25. package/components/ln-filter/ln-filter.schema.json +161 -153
  26. package/components/ln-filter/src/ln-filter.js +77 -5
  27. package/components/ln-form/ln-form.js +1 -1
  28. package/components/ln-icon/ln-icon.js +1 -1
  29. package/components/ln-icon/src/ln-icon.js +14 -16
  30. package/components/ln-include/ln-include.js +1 -1
  31. package/components/ln-key/ln-key.js +1 -1
  32. package/components/ln-link/ln-link.js +1 -1
  33. package/components/ln-link/src/ln-link.js +16 -26
  34. package/components/ln-list/ln-list.js +1 -1
  35. package/components/ln-modal/ln-modal.js +1 -1
  36. package/components/ln-nav/ln-nav.js +1 -1
  37. package/components/ln-nav/src/ln-nav.js +5 -4
  38. package/components/ln-number/ln-number.js +1 -1
  39. package/components/ln-obfuscator/ln-obfuscator.js +1 -1
  40. package/components/ln-options/ln-options.js +1 -1
  41. package/components/ln-persist/ln-persist.js +1 -1
  42. package/components/ln-picklist/ln-picklist.js +1 -1
  43. package/components/ln-popover/ln-popover.js +1 -1
  44. package/components/ln-progress/ln-progress.js +1 -1
  45. package/components/ln-progress/src/ln-progress.js +9 -21
  46. package/components/ln-router/ln-router.js +1 -1
  47. package/components/ln-scroll/ln-scroll.js +1 -1
  48. package/components/ln-search/ln-search.js +1 -1
  49. package/components/ln-search/src/ln-search.js +17 -1
  50. package/components/ln-slug/ln-slug.js +1 -1
  51. package/components/ln-sort/ln-sort.js +1 -1
  52. package/components/ln-sortable/ln-sortable.js +1 -1
  53. package/components/ln-stat/ln-stat.js +1 -1
  54. package/components/ln-table/ln-table.js +1 -1
  55. package/components/ln-table-coordinator/ln-table-coordinator.js +1 -1
  56. package/components/ln-tabs/ln-tabs.js +1 -1
  57. package/components/ln-time/ln-time.js +1 -1
  58. package/components/ln-toast/ln-toast.js +1 -1
  59. package/components/ln-toggle/ln-toggle.js +1 -1
  60. package/components/ln-tooltip/ln-tooltip.js +1 -1
  61. package/components/ln-translations/ln-translations.js +1 -1
  62. package/components/ln-ui-coordinator/ln-ui-coordinator.js +1 -1
  63. package/components/ln-upload/ln-upload.js +1 -1
  64. package/components/ln-validate/ln-validate.js +1 -1
  65. package/components/ln-websocket-connector/ln-websocket-connector.js +1 -1
  66. package/ln-ashlar.html-data.json +5 -0
  67. package/package.json +1 -1
  68. package/web-types.json +8 -1
@@ -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 D(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 s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){o=t[s];break}if(!D(o))return}e.apply(console,t)}}function _(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 T(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){T(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function ne(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function oe(e,t){const n=!!(t&&t.typed),o=t&&t.exclude,s={},c=e.elements,i={};if(n)for(let a=0;a<c.length;a++){const r=c[a];r.name&&r.type==="checkbox"&&!r.disabled&&(i[r.name]=(i[r.name]||0)+1)}for(let a=0;a<c.length;a++){const r=c[a];if(!(!r.name||r.disabled||r.type==="file"||r.type==="submit"||r.type==="button")&&!(o&&r.matches&&r.matches(o)))if(r.type==="checkbox")n&&i[r.name]===1?s[r.name]=r.checked:(s[r.name]||(s[r.name]=[]),r.checked&&s[r.name].push(r.value));else if(r.type==="radio")r.checked&&(s[r.name]=r.value);else if(r.type==="select-multiple"){s[r.name]=[];for(let h=0;h<r.options.length;h++)r.options[h].selected&&s[r.name].push(r.options[h].value)}else if(n&&r.type==="hidden")s[r.name]=r.value;else if(n&&(r.type==="number"||r.type==="range")){const h=Number(r.value);s[r.name]=r.value===""||isNaN(h)?null:h}else s[r.name]=r.value}return s}function re(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ie(e,t){const n=e.elements,o=[],s={};for(let c=0;c<n.length;c++){const i=n[c];i.name&&i.type==="checkbox"&&(s[i.name]=(s[i.name]||0)+1)}for(let c=0;c<n.length;c++){const i=n[c];if(i.type==="file"||i.type==="submit"||i.type==="button")continue;const a=i.getAttribute("data-ln-fill-as")||i.name;if(!a||!(a in t))continue;const r=t[a];if(i.type==="checkbox"){if(Array.isArray(r))i.checked=r.indexOf(i.value)!==-1;else if(s[i.name]>1){const h=String(r).split(",").map(function(m){return m.trim()});i.checked=h.indexOf(i.value)!==-1}else i.checked=re(r);o.push(i)}else if(i.type==="radio")i.checked=i.value===String(r),o.push(i);else if(i.type==="select-multiple"){if(Array.isArray(r))for(let h=0;h<i.options.length;h++)i.options[h].selected=r.indexOf(i.options[h].value)!==-1;o.push(i)}else i.value=r,i.tagName==="SELECT"&&r!=null&&i.setAttribute("data-ln-value",r),o.push(i)}return o}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ie,window.lnCore.serializeForm=oe,window.lnCore.resolveFormMethod=ne);function x(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function E(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function le(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const R={};function se(e,t){R[e]=t}function ce(e){return R[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=se,window.lnCore.getDataMapper=ce);function ae(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,T(function(){new MutationObserver(function(){_(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const F={};function de(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];F[n]=t}function ue(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return F[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=de,window.lnCore.getLocaleFallback=ue,window.lnCore.ensureLocaleObserver=ae);const L={};function fe(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=L[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 i=0;i<n.length;i++){const a=n[i],r=a.getAttribute("data-ln-field");t[r]!=null&&(a.textContent=t[r])}const o=e.querySelectorAll("[data-ln-attr]");for(let i=0;i<o.length;i++){const a=o[i],r=a.getAttribute("data-ln-attr").split(",");for(let h=0;h<r.length;h++){const m=r[h].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 s=e.querySelectorAll("[data-ln-show]");for(let i=0;i<s.length;i++){const a=s[i],r=a.getAttribute("data-ln-show");r in t&&a.classList.toggle("hidden",!t[r])}const c=e.querySelectorAll("[data-ln-class]");for(let i=0;i<c.length;i++){const a=c[i],r=a.getAttribute("data-ln-class").split(",");for(let h=0;h<r.length;h++){const m=r[h].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 he(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)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 P(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(i,a){return t[a]!==void 0?t[a]:""}))}const o=function(c,i){return t[i]!==void 0?t[i]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let c=0;c<s.length;c++){const i=s[c],a=i.attributes;for(let r=0;r<a.length;r++){const h=a[r];h.value.indexOf("{{")!==-1&&i.setAttribute(h.name,h.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function we(e,t,n,o,s,c){const i={};for(let r=0;r<e.children.length;r++){const h=e.children[r],m=h.getAttribute("data-ln-render-key");m&&(i[m]=h)}const a=document.createDocumentFragment();for(let r=0;r<t.length;r++){const h=t[r],m=String(o(h));let g=i[m];if(g)s(g,h,r);else{const y=fe(n,c);if(!y||(P(y,h),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",m),s(g,h,r)}a.appendChild(g)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=P,window.lnCore.fill=M,window.lnCore.lnFill=he,window.lnCore.renderList=we);function O(e,t,n){const o=e.getAttribute(t);return o===null?n:o}function H(e,t,n){const o=parseInt(e.getAttribute(t),10);return isNaN(o)?n:o}function U(e,t,n=!1){const o=e.getAttribute(t);if(o===null)return!!n;const s=o.trim().toLowerCase();return!(s==="false"||s==="0")}function W(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const j=new Map;function J(e,t){const n=(e?e.join("|"):"")+"::"+t;if(j.has(n))return j.get(n);const o=new Set(e||[]),s=function(c,i){const a=c.getAttribute(i);return a!==null&&o.has(a)?a:t};return j.set(n,s),s}function V(e,t,n){const o=parseFloat(e.getAttribute(t));return isNaN(o)?n:o}function K(e,t,n){const o=e.getAttribute(t);if(!o)return n;try{return JSON.parse(o)}catch{return n}}function G(e,t,n,o,s){if(!e||t===null)return!0;const c=o||"ln-component",i=e.type;if(i==="trigger"||i==="marker"||i==="string"||i==="list"||!i||t===""&&e.fallback!==void 0)return!0;const a=r=>{s?console.warn(r,s):console.warn(r)};if(i==="boolean"){const r=t.trim().toLowerCase();return r!==""&&r!=="true"&&r!=="false"&&r!=="1"&&r!=="0"?(a(`[${c}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(i==="enum"){const r=e.values||[];return r.includes(t)?!0:(a(`[${c}] Invalid value "${t}" for attribute "${n}". Allowed: ${r.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(i==="integer"){if(!/^-?\d+$/.test(t))return a(`[${c}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const r=parseInt(t,10);return e.min!==void 0&&r<e.min?(a(`[${c}] Value ${r} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&r>e.max?(a(`[${c}] Value ${r} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(i==="float")return isNaN(Number(t))?(a(`[${c}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(i==="json")try{return JSON.parse(t),!0}catch(r){return a(`[${c}] Invalid JSON for attribute "${n}": ${r.message}. Fallback: ${e.fallback}.`),!1}return!0}function z(e,t,n){for(const o in n){const[s,c,i]=n[o];Object.defineProperty(e,o,{get:function(){return s(t,c,i)},enumerable:!0,configurable:!0})}return e}function Q(e){const t={};for(const n in e){const o=e[n];if(!o||!o.prop)continue;let s=o.read;if(!s&&o.type)switch(o.type){case"enum":s=J(o.values,o.fallback);break;case"integer":s=H;break;case"float":s=V;break;case"boolean":s=U;break;case"list":s=W;break;case"json":s=K;break;case"string":default:s=O;break}s||(s=O),t[o.prop]=[s,n,o.fallback]}return t}function pe(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 be(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}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=z,window.lnCore.attrSpec=Q,window.lnCore.attrStr=O,window.lnCore.attrInt=H,window.lnCore.attrBool=U,window.lnCore.attrList=W,window.lnCore.attrEnum=J,window.lnCore.attrFloat=V,window.lnCore.attrJson=K);function I(e,t,n,o){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",i=Array.from(e.querySelectorAll(c));e.matches&&e.matches(c)&&i.push(e);for(const a of i)if(!a[n]){window.lnCore._persistSink&&a.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(a,t);try{a[n]=new o(a)}catch(r){console.error("["+n+"] init failed",a,r)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function me(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ge(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 X(){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 Ce(e){const t=X(),n=e.observed||[];for(let o=0;o<n.length;o++){const s=n[o];t.byAttr.has(s)||t.byAttr.set(s,[]),t.byAttr.get(s).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 s=t.byDeclaredAttr.get(o);s.some(c=>c.componentTag===e.componentTag)||s.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=be(e);if(o===null)t.reactiveWildcard.push(e);else for(const s of o)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function Y(e,t,n,o){for(let s=0;s<e.length;s++){const c=e[s];if(!t[c.attribute])continue;const i=c.effects&&c.effects[n];i?i(t,n,o):c.onAttrChange&&(!c.declared||c.declared.has(n))&&c.onAttrChange(t,n,o)}}function ye(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=X(),s=o.byAttr.get(n);if(B()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&D(t)){const c=o.byDeclaredAttr.get(n),i=t.getAttribute(n);for(let a=0;a<c.length;a++)G(c[a].spec,i,n,c[a].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||s)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const c=o.byReactive.get(n);c&&Y(c,t,n,e.oldValue),o.reactiveWildcard.length&&Y(o.reactiveWildcard,t,n,e.oldValue)}if(s)for(let c=0;c<s.length;c++){const i=s[c];if(i.handler){i.handler(t,n,e.oldValue);continue}i.onAttributeChange&&t[i.attribute]?i.onAttributeChange(t,n):(I(t,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(t))}}function ve(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ye(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 Z(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function _e(e){const t=Z();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const s=o.query,c=e.target.nodeType===1?e.target.matches(s)?e.target:e.target.closest(s):e.target.parentElement?e.target.parentElement.closest(s):null;c&&o.onSubtreeChange(c,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s];I(o,c.selector,c.attribute,c.ComponentFn),c.onInit&&c.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s],i=c.query,a=Array.from(o.querySelectorAll(i));o.matches&&o.matches(i)&&a.push(o);for(let r=0;r<a.length;r++){const h=a[r];if(!document.contains(h)){const m=h[c.attribute];if(m&&typeof m.destroy=="function")try{m.destroy()}catch(g){console.error("["+c.attribute+"] destroy failed",h,g)}delete h[c.attribute]}}}}}}function Ae(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{_e(o)}catch(s){console.error("[ln-core] lifecycle handler failed",o.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ee(e,t,n,o,s={}){const c=s.extraAttributes||[],i=s.onAttributeChange||null,a=s.onSubtreeChange||null,r=s.onInit||null,h=s.onAttrChange||null,m=s.effects||null,g=s.attributes||null,y=g?pe(g):m,$=g?new Set(Object.keys(g)):null,l=s.persist||null;function u(p){const w=p||document.body;if(I(w,e,t,n),g&&B())for(const v in g){const N=g[v],A=Array.from(w.querySelectorAll("["+v+"]"));w.matches&&w.matches("["+v+"]")&&A.push(w);for(let S=0;S<A.length;S++){const k=A[S];D(k)&&G(N,k.getAttribute(v),v,o,k)}}r&&r(w)}const d=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let w;for(;(w=p.exec(e))!==null;)d.push(w[1])}else d.push(e);Ce({selector:e,attribute:t,componentTag:o,attributes:g,ComponentFn:n,onInit:r,observed:d.concat(c),onAttributeChange:i,onAttrChange:h,effects:y,declared:$,persist:l}),ve();const b=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";Z().push({selector:e,attribute:t,ComponentFn:n,onInit:r,onSubtreeChange:a,query:b}),Ae(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ee);function C(){me()>0?ge(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C):C(),u}function te(e){return(e||"").replace(/^#/,"")}function q(e){const t=e===void 0?location.hash:e,n={},o=te(t);if(!o)return n;const s=o.split("&");for(let c=0;c<s.length;c++){const i=s[c];if(!i)continue;const a=i.indexOf(":"),r=a>-1?i.slice(0,a):i,h=a>-1?i.slice(a+1):"";if(r)try{n[r]=decodeURIComponent(h)}catch{n[r]=h}}return n}function ke(e){if(!e)return null;const t=q();return e in t?t[e]:null}function xe(e,t){if(!e)return;const n=q();t==null?delete n[e]:n[e]=String(t);const s=Object.keys(n).map(function(c){const i=n[c];return i===""?c:c+":"+encodeURIComponent(i)}).join("&");te(location.hash)!==s&&(location.hash=s)}function Se(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Oe(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 Ee(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Te(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 De(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Le(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),s=o?o.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:n,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=q,window.lnCore.hashGet=ke,window.lnCore.hashSet=xe,window.lnCore.hashLinkClick=Se,window.lnCore.resolveHashNamespace=Oe,window.lnCore.hashSortEncode=Ee,window.lnCore.hashSortDecode=Te,window.lnCore.hashFilterEncode=De,window.lnCore.hashFilterDecode=Le);function je(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=je),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function o(l){const u=l[t];u&&u.refreshConfig()}const s={"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:O,type:"string",fallback:"",effect:o,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:O,type:"string",fallback:"",effect:o,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:O,type:"string",fallback:"",effect:o,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:o,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},c=Q(s);function i(l){const u=l&&l.content!==void 0?l.content:l,d=l&&l.message?l.message:null;return{content:u,message:d}}function a(l){return this.dom=l,z(this,l,c),l[t]=this,l[n]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,$(this),this}a.prototype.refreshConfig=function(){const l=this.dom;this.credentials="same-origin";const u=l.getAttribute("data-ln-couchdb-headers")||"";this.headers=le(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."),_(l,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function r(l,u,d){const f=Object.assign({},E(l.headers,l.auth),d||{});return u&&(f["Idempotency-Key"]=u),f}a.prototype.fetchDelta=function(l){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,f=["include_docs=true","feed=normal"];l&&f.push("since="+encodeURIComponent(l));const b=x(u.url,u.db,"_changes")+"?"+f.join("&");return window.fetch(b,{method:"GET",headers:E(u.headers,u.auth),credentials:u.credentials,signal:d}).then(C=>{if(!C.ok)throw new Error("HTTP "+C.status+": "+C.statusText);return C.json()}).then(C=>{const p=C.results||[];return{data:p.filter(w=>!w.deleted&&w.doc).map(w=>Object.assign({},w.doc,{id:w.doc._id})),deleted:p.filter(w=>w.deleted).map(w=>w.id),synced_at:C.last_seq||l||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function h(l,u,d){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(x(l.url,l.db),{method:"POST",headers:r(l,d),credentials:l.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=i(b),p=C.content;return{record:Object.assign({},f,{id:p.id,_id:p.id,_rev:p.rev}),message:C.message}})}a.prototype.create=function(l,u){return h(this,l,u).then(d=>d.record)};function m(l,u,d,f){const b=Object.assign({id:String(u),_id:String(u)},d),C=b._rev||b.rev;return(C?Promise.resolve(C):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(v=>v._rev)})).then(w=>{const v=Object.assign({},b,{_rev:w});delete v.rev;const N=r(l,f,{"If-Match":w});return window.fetch(x(l.url,l.db,null,u),{method:"PUT",headers:N,credentials:l.credentials,body:JSON.stringify(v)}).then(A=>{if(A.ok)return A.json().then(S=>{const k=i(S);return{record:Object.assign({},v,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(S=>{const k=new Error("Conflict");throw k.status=409,k.data=S,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}a.prototype.update=function(l,u,d){return m(this,l,u,d).then(f=>f.record)};function g(l,u,d,f){return(d?Promise.resolve(d):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(C=>{if(!C.ok)throw new Error("Could not retrieve document for revision delete");return C.json().then(p=>p._rev)})).then(C=>{const p=x(l.url,l.db,null,u)+"?rev="+encodeURIComponent(C);return window.fetch(p,{method:"DELETE",headers:r(l,f),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const v=i(w);return{response:v.content,message:v.message}})})}a.prototype.delete=function(l,u,d){return g(this,l,u,d).then(f=>f.response)};function y(l,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(x(l.url,l.db,"_all_docs"),{method:"POST",headers:E(l.headers,l.auth),credentials:l.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(p=>!p.error&&p.value&&p.value.rev).map(p=>({_id:p.id,_rev:p.value.rev,_deleted:!0}));return C.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(x(l.url,l.db,"_bulk_docs"),{method:"POST",headers:r(l,d),credentials:l.credentials,body:JSON.stringify({docs:C})}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const w=i(p);return{response:{ok:!0,results:w.content,deletedCount:C.length},message:w.message}})})}a.prototype.bulkDelete=function(l,u){return y(this,l,u).then(d=>d.response)};function $(l){l._handlers={sync:function(u){const d=u.detail||{};l.fetchDelta(d.since).then(function(f){_(l.dom,"ln-couchdb-connector:fetched",{data:f,since:d.since,meta:d.meta||null})}).catch(function(f){f&&f.name==="AbortError"||_(l.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};h(l,d.data,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:created",{record:f.record,tempId:d.tempId,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},f=Object.assign({},d.data);d.expected_version!==void 0&&(f._rev=d.expected_version),m(l,d.id,f,d.idempotencyKey).then(function(b){_(l.dom,"ln-couchdb-connector:updated",{record:b.record,id:d.id,message:b.message,meta:d.meta||null})}).catch(function(b){_(l.dom,"ln-couchdb-connector:error",{action:"update",error:b.message,status:b.status||0,id:d.id,data:b.status===409?b.data:null,conflictData:b.status===409?b.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};g(l,d.id,d.rev,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:deleted",{response:f.response,id:d.id,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};y(l,d.ids,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:d.ids,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:d.ids,meta:d.meta||null})})}},l.dom.addEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.addEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.addEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.addEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const l=this;l._deltaController&&(l._deltaController.abort(),l._deltaController=null),l._handlers&&(l.dom.removeEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.removeEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.removeEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.removeEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete),l._handlers=null),delete this.dom[t],delete this.dom[n]},ee(e,t,a,"ln-couchdb-connector",{attributes:s})})()})();
1
+ (function(){"use strict";function R(){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 n=null;for(let s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){n=t[s];break}if(!L(n))return}e.apply(console,t)}}function _(e,t,o){const n=o||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,n),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}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 ie(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function le(e,t){const o=!!(t&&t.typed),n=t&&t.exclude,s={},a=e.elements,i={};if(o)for(let c=0;c<a.length;c++){const r=a[c];r.name&&r.type==="checkbox"&&!r.disabled&&(i[r.name]=(i[r.name]||0)+1)}for(let c=0;c<a.length;c++){const r=a[c];if(!(!r.name||r.disabled||r.type==="file"||r.type==="submit"||r.type==="button")&&!(n&&r.matches&&r.matches(n)))if(r.type==="checkbox")o&&i[r.name]===1?s[r.name]=r.checked:(s[r.name]||(s[r.name]=[]),r.checked&&s[r.name].push(r.value));else if(r.type==="radio")r.checked&&(s[r.name]=r.value);else if(r.type==="select-multiple"){s[r.name]=[];for(let h=0;h<r.options.length;h++)r.options[h].selected&&s[r.name].push(r.options[h].value)}else if(o&&r.type==="hidden")s[r.name]=r.value;else if(o&&(r.type==="number"||r.type==="range")){const h=Number(r.value);s[r.name]=r.value===""||isNaN(h)?null:h}else s[r.name]=r.value}return s}function se(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ce(e,t){const o=e.elements,n=[],s={};for(let a=0;a<o.length;a++){const i=o[a];i.name&&i.type==="checkbox"&&(s[i.name]=(s[i.name]||0)+1)}for(let a=0;a<o.length;a++){const i=o[a];if(i.type==="file"||i.type==="submit"||i.type==="button")continue;const c=i.getAttribute("data-ln-fill-as")||i.name;if(!c||!(c in t))continue;const r=t[c];if(i.type==="checkbox"){if(Array.isArray(r))i.checked=r.indexOf(i.value)!==-1;else if(s[i.name]>1){const h=String(r).split(",").map(function(C){return C.trim()});i.checked=h.indexOf(i.value)!==-1}else i.checked=se(r);n.push(i)}else if(i.type==="radio")i.checked=i.value===String(r),n.push(i);else if(i.type==="select-multiple"){if(Array.isArray(r))for(let h=0;h<i.options.length;h++)i.options[h].selected=r.indexOf(i.options[h].value)!==-1;n.push(i)}else i.value=r,i.tagName==="SELECT"&&r!=null&&i.setAttribute("data-ln-value",r),n.push(i)}return n}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ce,window.lnCore.serializeForm=le,window.lnCore.resolveFormMethod=ie);function x(...e){return e.filter(t=>t!=null&&t!=="").map((t,o)=>o===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function O(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function ae(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(o){return console.error(`[${t}] Invalid headers JSON:`,o),{}}}const M={};function de(e,t){M[e]=t}function ue(e){return M[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=de,window.lnCore.getDataMapper=ue);function fe(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){_(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const P={};function he(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];P[o]=t}function we(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=he,window.lnCore.getLocaleFallback=we,window.lnCore.ensureLocaleObserver=fe);const j={};function be(e,t){j[e]||(j[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=j[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function H(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let i=0;i<o.length;i++){const c=o[i],r=c.getAttribute("data-ln-field");t[r]!=null&&(c.textContent=t[r])}const n=e.querySelectorAll("[data-ln-attr]");for(let i=0;i<n.length;i++){const c=n[i],r=c.getAttribute("data-ln-attr").split(",");for(let h=0;h<r.length;h++){const C=r[h].trim().split(":");if(C.length!==2)continue;const g=C[0].trim(),y=C[1].trim();t[y]!=null&&c.setAttribute(g,t[y])}}const s=e.querySelectorAll("[data-ln-show]");for(let i=0;i<s.length;i++){const c=s[i],r=c.getAttribute("data-ln-show");r in t&&c.classList.toggle("hidden",!t[r])}const a=e.querySelectorAll("[data-ln-class]");for(let i=0;i<a.length;i++){const c=a[i],r=c.getAttribute("data-ln-class").split(",");for(let h=0;h<r.length;h++){const C=r[h].trim().split(":");if(C.length!==2)continue;const g=C[0].trim(),y=C[1].trim();y in t&&c.classList.toggle(g,!!t[y])}}return e}function pe(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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let n=0;n<o.length;n++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[n],t??null),o[n].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)H(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let o=0;o<t.length;o++)t[o].textContent=""}})));function U(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const a=o.currentNode;a.textContent.indexOf("{{")!==-1&&(a.textContent=a.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(i,c){return t[c]!==void 0?t[c]:""}))}const n=function(a,i){return t[i]!==void 0?t[i]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let a=0;a<s.length;a++){const i=s[a],c=i.attributes;for(let r=0;r<c.length;r++){const h=c[r];h.value.indexOf("{{")!==-1&&i.setAttribute(h.name,h.value.replace(/\{\{\s*(\w+)\s*\}\}/g,n))}}return e}function me(e,t,o,n,s,a){const i={};for(let r=0;r<e.children.length;r++){const h=e.children[r],C=h.getAttribute("data-ln-render-key");C&&(i[C]=h)}const c=document.createDocumentFragment();for(let r=0;r<t.length;r++){const h=t[r],C=String(n(h));let g=i[C];if(g)s(g,h,r);else{const y=be(o,a);if(!y||(U(y,h),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",C),s(g,h,r)}c.appendChild(g)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=U,window.lnCore.fill=H,window.lnCore.lnFill=pe,window.lnCore.renderList=me);function E(e,t,o){const n=e.getAttribute(t);return n===null?o:n}function W(e,t,o){const n=parseInt(e.getAttribute(t),10);return isNaN(n)?o:n}function J(e,t,o=!1){const n=e.getAttribute(t);if(n===null)return!!o;const s=n.trim().toLowerCase();return!(s==="false"||s==="0")}function V(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const q=new Map;function K(e,t){const o=(e?e.join("|"):"")+"::"+t;if(q.has(o))return q.get(o);const n=new Set(e||[]),s=function(a,i){const c=a.getAttribute(i);return c!==null&&n.has(c)?c:t};return q.set(o,s),s}function G(e,t,o){const n=parseFloat(e.getAttribute(t));return isNaN(n)?o:n}function z(e,t,o){const n=e.getAttribute(t);if(!n)return o;try{return JSON.parse(n)}catch{return o}}function Q(e,t,o,n,s){if(!e||t===null)return!0;const a=n||"ln-component",i=e.type;if(i==="trigger"||i==="marker"||i==="string"||i==="list"||!i||t===""&&e.fallback!==void 0)return!0;const c=r=>{s?console.warn(r,s):console.warn(r)};if(i==="boolean"){const r=t.trim().toLowerCase();return r!==""&&r!=="true"&&r!=="false"&&r!=="1"&&r!=="0"?(c(`[${a}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(i==="enum"){const r=e.values||[];return r.includes(t)?!0:(c(`[${a}] Invalid value "${t}" for attribute "${o}". Allowed: ${r.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(i==="integer"){if(!/^-?\d+$/.test(t))return c(`[${a}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const r=parseInt(t,10);return e.min!==void 0&&r<e.min?(c(`[${a}] Value ${r} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&r>e.max?(c(`[${a}] Value ${r} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(i==="float")return isNaN(Number(t))?(c(`[${a}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(i==="json")try{return JSON.parse(t),!0}catch(r){return c(`[${a}] Invalid JSON for attribute "${o}": ${r.message}. Fallback: ${e.fallback}.`),!1}return!0}function X(e,t,o){for(const n in o){const[s,a,i]=o[n];Object.defineProperty(e,n,{get:function(){return s(t,a,i)},enumerable:!0,configurable:!0})}return e}function Y(e){const t={};for(const o in e){const n=e[o];if(!n||!n.prop)continue;let s=n.read;if(!s&&n.type)switch(n.type){case"enum":s=K(n.values,n.fallback);break;case"integer":s=W;break;case"float":s=G;break;case"boolean":s=J;break;case"list":s=V;break;case"json":s=z;break;case"string":default:s=E;break}s||(s=E),t[n.prop]=[s,o,n.fallback]}return t}function ge(e){const t={};for(const o in e){const n=e[o];n&&n.effect&&(t[o]=n.effect)}return Object.keys(t).length?t:null}function Ce(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=X,window.lnCore.attrSpec=Y,window.lnCore.attrStr=E,window.lnCore.attrInt=W,window.lnCore.attrBool=J,window.lnCore.attrList=V,window.lnCore.attrEnum=K,window.lnCore.attrFloat=G,window.lnCore.attrJson=z);function T(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(o){console.error("["+t.attribute+"] init failed",e,o)}}}function Z(e,t,o,n){if(e.nodeType!==1)return;const a=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",i={selector:t,attribute:o,ComponentFn:n};if(e.matches&&e.matches(a)&&T(e,i),e.querySelectorAll){const c=e.querySelectorAll(a);for(let r=0;r<c.length;r++)T(c[r],i)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ye(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ve(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 ee(){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 _e(e){const t=ee(),o=e.observed||[];for(let n=0;n<o.length;n++){const s=o[n];t.byAttr.has(s)||t.byAttr.set(s,[]),t.byAttr.get(s).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const n in e.attributes){t.byDeclaredAttr.has(n)||t.byDeclaredAttr.set(n,[]);const s=t.byDeclaredAttr.get(n);s.some(a=>a.componentTag===e.componentTag)||s.push({spec:e.attributes[n],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const n=Ce(e);if(n===null)t.reactiveWildcard.push(e);else for(const s of n)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function te(e,t,o,n){for(let s=0;s<e.length;s++){const a=e[s];if(!t[a.attribute])continue;const i=a.effects&&a.effects[o];i?i(t,o,n):a.onAttrChange&&(!a.declared||a.declared.has(o))&&a.onAttrChange(t,o,n)}}function Ae(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,n=ee(),s=n.byAttr.get(t),a=R()&&n.byDeclaredAttr&&n.byDeclaredAttr.has(t);if(!o&&!s&&!a)return;const i=e.target;if(e.oldValue!==i.getAttribute(t)){if(a&&L(i)){const c=n.byDeclaredAttr.get(t),r=i.getAttribute(t);for(let h=0;h<c.length;h++)Q(c[h].spec,r,t,c[h].componentTag,i)}if(window.lnCore._debugSink&&(o||s)&&window.lnCore._debugSink("attr",t,i,{oldValue:e.oldValue,newValue:i.getAttribute(t)}),o){const c=n.byReactive.get(t);c&&te(c,i,t,e.oldValue),n.reactiveWildcard.length&&te(n.reactiveWildcard,i,t,e.oldValue)}if(s)for(let c=0;c<s.length;c++){const r=s[c];if(r.handler){r.handler(i,t,e.oldValue);continue}r.onAttributeChange&&i[r.attribute]?r.onAttributeChange(i,t):(Z(i,r.selector,r.attribute,r.ComponentFn),r.onInit&&r.onInit(i))}}}function ke(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{Ae(t[o])}catch(n){console.error("[ln-core] mutation handler failed",t[o].target,n)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function I(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function $(e,t){if(!document.contains(e))if(t.attribute){const o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.destroy()}catch(n){console.error("["+t.attribute+"] destroy failed",e,n)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function xe(e){const t=I();if(t.length){if(e.target)for(let o=0;o<t.length;o++){const n=t[o];if(n.onSubtreeChange&&n.query){const s=n.query,a=e.target.nodeType===1?e.target.matches&&e.target.matches(s)?e.target:e.target.closest?e.target.closest(s):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(s):null;a&&n.onSubtreeChange(a,e)}}for(let o=0;o<e.addedNodes.length;o++){const n=e.addedNodes[o];if(n.nodeType===1){const s=!!(n.firstElementChild||n.children&&n.children.length);for(let a=0;a<t.length;a++){const i=t[a];if(i.selector&&i.attribute&&i.ComponentFn){if(!s)n.matches&&n.matches(i.query)&&T(n,i);else if(n.matches&&n.matches(i.query)&&T(n,i),n.querySelectorAll){const c=n.querySelectorAll(i.query);for(let r=0;r<c.length;r++)T(c[r],i)}}i.onInit&&i.onInit(n)}}}for(let o=0;o<e.removedNodes.length;o++){const n=e.removedNodes[o];if(n.nodeType===1){const s=!!(n.firstElementChild||n.children&&n.children.length);for(let a=0;a<t.length;a++){const i=t[a],c=i.query;if(c){if(!s)n.matches&&n.matches(c)&&$(n,i);else if(n.matches&&n.matches(c)&&$(n,i),n.querySelectorAll){const r=n.querySelectorAll(c);for(let h=0;h<r.length;h++)$(r[h],i)}}}}}}}function ne(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const n=t[o];if(n.type==="childList")try{xe(n)}catch(s){console.error("[ln-core] lifecycle handler failed",n.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Se(e){I().push(e),ne()}function oe(e,t,o,n,s={}){const a=s.extraAttributes||[],i=s.onAttributeChange||null,c=s.onSubtreeChange||null,r=s.onInit||null,h=s.onAttrChange||null,C=s.effects||null,g=s.attributes||null,y=g?ge(g):C,B=g?new Set(Object.keys(g)):null,l=s.persist||null;function u(b){const w=b||document.body;if(Z(w,e,t,o),g&&R())for(const v in g){const F=g[v],A=Array.from(w.querySelectorAll("["+v+"]"));w.matches&&w.matches("["+v+"]")&&A.push(w);for(let S=0;S<A.length;S++){const k=A[S];L(k)&&Q(F,k.getAttribute(v),v,n,k)}}r&&r(w)}const d=[];if(e.indexOf("[")!==-1){const b=/\[([\w-]+)/g;let w;for(;(w=b.exec(e))!==null;)d.push(w[1])}else d.push(e);_e({selector:e,attribute:t,componentTag:n,attributes:g,ComponentFn:o,onInit:r,observed:d.concat(a),onAttributeChange:i,onAttrChange:h,effects:y,declared:B,persist:l}),ke();const f=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,p=s.subtreeQuery||(f?e:"["+e+"]");I().push({selector:e,attribute:t,ComponentFn:o,onInit:r,onSubtreeChange:c,query:p}),ne(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=oe,window.lnCore.observeLifecycle=Se);function m(){ye()>0?ve(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m):m(),u}function re(e){return(e||"").replace(/^#/,"")}function N(e){const t=e===void 0?location.hash:e,o={},n=re(t);if(!n)return o;const s=n.split("&");for(let a=0;a<s.length;a++){const i=s[a];if(!i)continue;const c=i.indexOf(":"),r=c>-1?i.slice(0,c):i,h=c>-1?i.slice(c+1):"";if(r)try{o[r]=decodeURIComponent(h)}catch{o[r]=h}}return o}function Ee(e){if(!e)return null;const t=N();return e in t?t[e]:null}function Oe(e,t){if(!e)return;const o=N();t==null?delete o[e]:o[e]=String(t);const s=Object.keys(o).map(function(a){const i=o[a];return i===""?a:a+":"+encodeURIComponent(i)}).join("&");re(location.hash)!==s&&(location.hash=s)}function Te(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function De(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.trim();const n=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return n?t?n+"-"+t:n:t||null}function Le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function je(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 qe(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ie(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const o=e.slice(0,t),n=e.slice(t+1),s=n?n.split(",").map(function(a){try{return decodeURIComponent(a)}catch{return a}}).filter(Boolean):[];return{key:o,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=N,window.lnCore.hashGet=Ee,window.lnCore.hashSet=Oe,window.lnCore.hashLinkClick=Te,window.lnCore.resolveHashNamespace=De,window.lnCore.hashSortEncode=Le,window.lnCore.hashSortDecode=je,window.lnCore.hashFilterEncode=qe,window.lnCore.hashFilterDecode=Ie);function $e(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=$e),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",o="lnConnector";if(window[t]!==void 0)return;function n(l){const u=l[t];u&&u.refreshConfig()}const s={"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:n,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:E,type:"string",fallback:"",effect:n,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:E,type:"string",fallback:"",effect:n,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:n,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},a=Y(s);function i(l){const u=l&&l.content!==void 0?l.content:l,d=l&&l.message?l.message:null;return{content:u,message:d}}function c(l){return this.dom=l,X(this,l,a),l[t]=this,l[o]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,B(this),this}c.prototype.refreshConfig=function(){const l=this.dom;this.credentials="same-origin";const u=l.getAttribute("data-ln-couchdb-headers")||"";this.headers=ae(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."),_(l,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function r(l,u,d){const f=Object.assign({},O(l.headers,l.auth),d||{});return u&&(f["Idempotency-Key"]=u),f}c.prototype.fetchDelta=function(l){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,f=["include_docs=true","feed=normal"];l&&f.push("since="+encodeURIComponent(l));const p=x(u.url,u.db,"_changes")+"?"+f.join("&");return window.fetch(p,{method:"GET",headers:O(u.headers,u.auth),credentials:u.credentials,signal:d}).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(w=>!w.deleted&&w.doc).map(w=>Object.assign({},w.doc,{id:w.doc._id})),deleted:b.filter(w=>w.deleted).map(w=>w.id),synced_at:m.last_seq||l||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function h(l,u,d){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(x(l.url,l.db),{method:"POST",headers:r(l,d),credentials:l.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=i(p),b=m.content;return{record:Object.assign({},f,{id:b.id,_id:b.id,_rev:b.rev}),message:m.message}})}c.prototype.create=function(l,u){return h(this,l,u).then(d=>d.record)};function C(l,u,d,f){const p=Object.assign({id:String(u),_id:String(u)},d),m=p._rev||p.rev;return(m?Promise.resolve(m):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:O(l.headers,l.auth),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(v=>v._rev)})).then(w=>{const v=Object.assign({},p,{_rev:w});delete v.rev;const F=r(l,f,{"If-Match":w});return window.fetch(x(l.url,l.db,null,u),{method:"PUT",headers:F,credentials:l.credentials,body:JSON.stringify(v)}).then(A=>{if(A.ok)return A.json().then(S=>{const k=i(S);return{record:Object.assign({},v,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(S=>{const k=new Error("Conflict");throw k.status=409,k.data=S,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}c.prototype.update=function(l,u,d){return C(this,l,u,d).then(f=>f.record)};function g(l,u,d,f){return(d?Promise.resolve(d):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:O(l.headers,l.auth),credentials:l.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=x(l.url,l.db,null,u)+"?rev="+encodeURIComponent(m);return window.fetch(b,{method:"DELETE",headers:r(l,f),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const v=i(w);return{response:v.content,message:v.message}})})}c.prototype.delete=function(l,u,d){return g(this,l,u,d).then(f=>f.response)};function y(l,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(x(l.url,l.db,"_all_docs"),{method:"POST",headers:O(l.headers,l.auth),credentials:l.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(x(l.url,l.db,"_bulk_docs"),{method:"POST",headers:r(l,d),credentials:l.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 w=i(b);return{response:{ok:!0,results:w.content,deletedCount:m.length},message:w.message}})})}c.prototype.bulkDelete=function(l,u){return y(this,l,u).then(d=>d.response)};function B(l){l._handlers={sync:function(u){const d=u.detail||{};l.fetchDelta(d.since).then(function(f){_(l.dom,"ln-couchdb-connector:fetched",{data:f,since:d.since,meta:d.meta||null})}).catch(function(f){f&&f.name==="AbortError"||_(l.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};h(l,d.data,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:created",{record:f.record,tempId:d.tempId,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},f=Object.assign({},d.data);d.expected_version!==void 0&&(f._rev=d.expected_version),C(l,d.id,f,d.idempotencyKey).then(function(p){_(l.dom,"ln-couchdb-connector:updated",{record:p.record,id:d.id,message:p.message,meta:d.meta||null})}).catch(function(p){_(l.dom,"ln-couchdb-connector:error",{action:"update",error:p.message,status:p.status||0,id:d.id,data:p.status===409?p.data:null,conflictData:p.status===409?p.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};g(l,d.id,d.rev,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:deleted",{response:f.response,id:d.id,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};y(l,d.ids,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:d.ids,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:d.ids,meta:d.meta||null})})}},l.dom.addEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.addEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.addEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.addEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete)}c.prototype.destroy=function(){if(!this.dom[t])return;const l=this;l._deltaController&&(l._deltaController.abort(),l._deltaController=null),l._handlers&&(l.dom.removeEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.removeEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.removeEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.removeEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete),l._handlers=null),delete this.dom[t],delete this.dom[o]},oe(e,t,c,"ln-couchdb-connector",{attributes:s})})()})();
@@ -1 +1 @@
1
- (function(){"use strict";function N(){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 R(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 i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!R(i))return}e.apply(console,t)}}function g(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function U(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function G(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},u=e.elements,s={};if(r)for(let h=0;h<u.length;h++){const c=u[h];c.name&&c.type==="checkbox"&&!c.disabled&&(s[c.name]=(s[c.name]||0)+1)}for(let h=0;h<u.length;h++){const c=u[h];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")r&&s[c.name]===1?l[c.name]=c.checked:(l[c.name]||(l[c.name]=[]),c.checked&&l[c.name].push(c.value));else if(c.type==="radio")c.checked&&(l[c.name]=c.value);else if(c.type==="select-multiple"){l[c.name]=[];for(let b=0;b<c.options.length;b++)c.options[b].selected&&l[c.name].push(c.options[b].value)}else if(r&&c.type==="hidden")l[c.name]=c.value;else if(r&&(c.type==="number"||c.type==="range")){const b=Number(c.value);l[c.name]=c.value===""||isNaN(b)?null:b}else l[c.name]=c.value}return l}function de(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ue(e,t){const r=e.elements,i=[],l={};for(let u=0;u<r.length;u++){const s=r[u];s.name&&s.type==="checkbox"&&(l[s.name]=(l[s.name]||0)+1)}for(let u=0;u<r.length;u++){const s=r[u];if(s.type==="file"||s.type==="submit"||s.type==="button")continue;const h=s.getAttribute("data-ln-fill-as")||s.name;if(!h||!(h in t))continue;const c=t[h];if(s.type==="checkbox"){if(Array.isArray(c))s.checked=c.indexOf(s.value)!==-1;else if(l[s.name]>1){const b=String(c).split(",").map(function(E){return E.trim()});s.checked=b.indexOf(s.value)!==-1}else s.checked=de(c);i.push(s)}else if(s.type==="radio")s.checked=s.value===String(c),i.push(s);else if(s.type==="select-multiple"){if(Array.isArray(c))for(let b=0;b<s.options.length;b++)s.options[b].selected=c.indexOf(s.options[b].value)!==-1;i.push(s)}else s.value=c,s.tagName==="SELECT"&&c!=null&&s.setAttribute("data-ln-value",c),i.push(s)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ue,window.lnCore.serializeForm=G,window.lnCore.resolveFormMethod=U);const K={};function fe(e,t){K[e]=t}function pe(e){return K[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=fe,window.lnCore.getDataMapper=pe);function he(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,O(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const P={};function we(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];P[r]=t}function me(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=we,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=he);const T={};function be(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function Q(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let s=0;s<r.length;s++){const h=r[s],c=h.getAttribute("data-ln-field");t[c]!=null&&(h.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let s=0;s<i.length;s++){const h=i[s],c=h.getAttribute("data-ln-attr").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();t[C]!=null&&h.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let s=0;s<l.length;s++){const h=l[s],c=h.getAttribute("data-ln-show");c in t&&h.classList.toggle("hidden",!t[c])}const u=e.querySelectorAll("[data-ln-class]");for(let s=0;s<u.length;s++){const h=u[s],c=h.getAttribute("data-ln-class").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();C in t&&h.classList.toggle(_,!!t[C])}}return e}function ye(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 r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].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)Q(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function V(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const u=r.currentNode;u.textContent.indexOf("{{")!==-1&&(u.textContent=u.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(s,h){return t[h]!==void 0?t[h]:""}))}const i=function(u,s){return t[s]!==void 0?t[s]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let u=0;u<l.length;u++){const s=l[u],h=s.attributes;for(let c=0;c<h.length;c++){const b=h[c];b.value.indexOf("{{")!==-1&&s.setAttribute(b.name,b.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function ge(e,t,r,i,l,u){const s={};for(let c=0;c<e.children.length;c++){const b=e.children[c],E=b.getAttribute("data-ln-render-key");E&&(s[E]=b)}const h=document.createDocumentFragment();for(let c=0;c<t.length;c++){const b=t[c],E=String(i(b));let _=s[E];if(_)l(_,b,c);else{const C=be(r,u);if(!C||(V(C,b),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",E),l(_,b,c)}h.appendChild(_)}e.textContent="",e.appendChild(h)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=V,window.lnCore.fill=Q,window.lnCore.lnFill=ye,window.lnCore.renderList=ge);function L(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function z(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function H(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function J(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const F=new Map;function X(e,t){const r=(e?e.join("|"):"")+"::"+t;if(F.has(r))return F.get(r);const i=new Set(e||[]),l=function(u,s){const h=u.getAttribute(s);return h!==null&&i.has(h)?h:t};return F.set(r,l),l}function Y(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function Z(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ee(e,t,r,i,l){if(!e||t===null)return!0;const u=i||"ln-component",s=e.type;if(s==="trigger"||s==="marker"||s==="string"||s==="list"||!s||t===""&&e.fallback!==void 0)return!0;const h=c=>{l?console.warn(c,l):console.warn(c)};if(s==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(h(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(s==="enum"){const c=e.values||[];return c.includes(t)?!0:(h(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(s==="integer"){if(!/^-?\d+$/.test(t))return h(`[${u}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(h(`[${u}] Value ${c} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(h(`[${u}] Value ${c} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(s==="float")return isNaN(Number(t))?(h(`[${u}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(s==="json")try{return JSON.parse(t),!0}catch(c){return h(`[${u}] Invalid JSON for attribute "${r}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function te(e,t,r){for(const i in r){const[l,u,s]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,u,s)},enumerable:!0,configurable:!0})}return e}function ne(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=X(i.values,i.fallback);break;case"integer":l=z;break;case"float":l=Y;break;case"boolean":l=H;break;case"list":l=J;break;case"json":l=Z;break;case"string":default:l=L;break}l||(l=L),t[i.prop]=[l,r,i.fallback]}return t}function Ce(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function _e(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=te,window.lnCore.attrSpec=ne,window.lnCore.attrStr=L,window.lnCore.attrInt=z,window.lnCore.attrBool=H,window.lnCore.attrList=J,window.lnCore.attrEnum=X,window.lnCore.attrFloat=Y,window.lnCore.attrJson=Z);function j(e,t,r,i){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",s=Array.from(e.querySelectorAll(u));e.matches&&e.matches(u)&&s.push(e);for(const h of s)if(!h[r]){window.lnCore._persistSink&&h.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(h,t);try{h[r]=new i(h)}catch(c){console.error("["+r+"] init failed",h,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ae(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ve(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 re(){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 Ee(e){const t=re(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=_e(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function oe(e,t,r,i){for(let l=0;l<e.length;l++){const u=e[l];if(!t[u.attribute])continue;const s=u.effects&&u.effects[r];s?s(t,r,i):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,i)}}function qe(e){const t=e.target,r=e.attributeName;if(e.oldValue===t.getAttribute(r))return;const i=re(),l=i.byAttr.get(r);if(N()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(r)&&R(t)){const u=i.byDeclaredAttr.get(r),s=t.getAttribute(r);for(let h=0;h<u.length;h++)ee(u[h].spec,s,r,u[h].componentTag,t)}if(window.lnCore._debugSink&&(r.indexOf("data-ln-")===0||l)&&window.lnCore._debugSink("attr",r,t,{oldValue:e.oldValue,newValue:t.getAttribute(r)}),r.indexOf("data-ln-")===0){const u=i.byReactive.get(r);u&&oe(u,t,r,e.oldValue),i.reactiveWildcard.length&&oe(i.reactiveWildcard,t,r,e.oldValue)}if(l)for(let u=0;u<l.length;u++){const s=l[u];if(s.handler){s.handler(t,r,e.oldValue);continue}s.onAttributeChange&&t[s.attribute]?s.onAttributeChange(t,r):(j(t,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(t))}}function Se(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{qe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).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 xe(e){const t=ie();if(t.length){if(e.target)for(let r=0;r<t.length;r++){const i=t[r];if(i.onSubtreeChange){const l=i.query,u=e.target.nodeType===1?e.target.matches(l)?e.target:e.target.closest(l):e.target.parentElement?e.target.parentElement.closest(l):null;u&&i.onSubtreeChange(u,e)}}for(let r=0;r<e.addedNodes.length;r++){const i=e.addedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l];j(i,u.selector,u.attribute,u.ComponentFn),u.onInit&&u.onInit(i)}}for(let r=0;r<e.removedNodes.length;r++){const i=e.removedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l],s=u.query,h=Array.from(i.querySelectorAll(s));i.matches&&i.matches(s)&&h.push(i);for(let c=0;c<h.length;c++){const b=h[c];if(!document.contains(b)){const E=b[u.attribute];if(E&&typeof E.destroy=="function")try{E.destroy()}catch(_){console.error("["+u.attribute+"] destroy failed",b,_)}delete b[u.attribute]}}}}}}function ke(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{xe(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ae(e,t,r,i,l={}){const u=l.extraAttributes||[],s=l.onAttributeChange||null,h=l.onSubtreeChange||null,c=l.onInit||null,b=l.onAttrChange||null,E=l.effects||null,_=l.attributes||null,C=_?Ce(_):E,M=_?new Set(Object.keys(_)):null,B=l.persist||null;function n(y){const A=y||document.body;if(j(A,e,t,r),_&&N())for(const q in _){const d=_[q],p=Array.from(A.querySelectorAll("["+q+"]"));A.matches&&A.matches("["+q+"]")&&p.push(A);for(let m=0;m<p.length;m++){const v=p[m];R(v)&&ee(d,v.getAttribute(q),q,i,v)}}c&&c(A)}const o=[];if(e.indexOf("[")!==-1){const y=/\[([\w-]+)/g;let A;for(;(A=y.exec(e))!==null;)o.push(A[1])}else o.push(e);Ee({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:c,observed:o.concat(u),onAttributeChange:s,onAttrChange:b,effects:C,declared:M,persist:B}),Se();const f=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";ie().push({selector:e,attribute:t,ComponentFn:r,onInit:c,onSubtreeChange:h,query:f}),ke(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ae);function w(){Ae()>0?ve(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),n}function Ie(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function le(e){return(e||"").replace(/^#/,"")}function $(e){const t=e===void 0?location.hash:e,r={},i=le(t);if(!i)return r;const l=i.split("&");for(let u=0;u<l.length;u++){const s=l[u];if(!s)continue;const h=s.indexOf(":"),c=h>-1?s.slice(0,h):s,b=h>-1?s.slice(h+1):"";if(c)try{r[c]=decodeURIComponent(b)}catch{r[c]=b}}return r}function Oe(e){if(!e)return null;const t=$();return e in t?t[e]:null}function De(e,t){if(!e)return;const r=$();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(u){const s=r[u];return s===""?u:u+":"+encodeURIComponent(s)}).join("&");le(location.hash)!==l&&(location.hash=l)}function Re(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Te(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function Le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Fe(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 je(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function $e(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=$,window.lnCore.hashGet=Oe,window.lnCore.hashSet=De,window.lnCore.hashLinkClick=Re,window.lnCore.resolveHashNamespace=Te,window.lnCore.hashSortEncode=Le,window.lnCore.hashSortDecode=Fe,window.lnCore.hashFilterEncode=je,window.lnCore.hashFilterDecode=$e);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Me(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Be(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function se(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class We{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",s="data-ln-data-coordinator-sort-direction",c=ne({"data-ln-data-coordinator":{prop:"_name",type:"string",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-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",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"}}),b=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function E(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const a=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(a)return a;for(const f of n.querySelectorAll("*")){if(f.lnConnector)return f;for(const w of f.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return f}return null}function _(n){var a;if(!n)return"ln-connector";if((a=n.lnConnector)!=null&&a.namespace)return n.lnConnector.namespace;const o=n.getAttribute("data-ln-connector");if(o&&o!=="true")return o.startsWith("ln-")?o:"ln-"+o+(o.endsWith("-connector")?"":"-connector");for(const f of n.attributes)if(f.name.startsWith("data-ln-")&&f.name.endsWith("-connector"))return f.name.replace(/^data-/,"");return"ln-connector"}function C(n){const o=this;return this.dom=n,te(this,n,c),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new We,this._queueQueryRefresh=Ie(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),M(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var o;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((o=n.storeEl)!=null&&o.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var a,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((a=n.storeEl)==null?void 0:a.getAttribute("data-ln-data-store-stale"));return o==="never"||o==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(o,10)||300)},C.prototype._checkInitialSync=function(){const n=this,o=this.findChildren();o.store&&Promise.resolve(o.store.ready).then(()=>{if(n._destroyed)return;const a=n.findChildren();a.store&&a.connector&&!n._noAutosync(a)&&!a.store.isSyncing&&(!a.store.hasCache||n._isStale(a))&&a.store.forceSync()}).catch(a=>n._reportError("store-initialize",a,null))},C.prototype.refreshMapper=function(){var a,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(a=window.lnCore)==null?void 0:a.getDataMapper)==null?void 0:f.call(a,n))||null;this.mapper={ingress:(o==null?void 0:o.ingress)||(w=>w),egress:(o==null?void 0:o.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),o=E(this.dom),a=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:a,store:(n==null?void 0:n.lnDataStore)||null,connector:(o==null?void 0:o.lnConnector)||(o==null?void 0:o.lnApiConnector)||(o==null?void 0:o.lnCouchDbConnector)||(o==null?void 0:o.lnWebsocketConnector)||null,queue:(a==null?void 0:a.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,a,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",a):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,a){const f="_temp_"+k(),w=this.mapper.egress(o);n.storeEl&&g(n.storeEl,"ln-data-store:request-create",{tempId:f,data:w}),this._fanOutRemote(n,"create",{chainKey:f,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:f,action:a}},{data:w,url:a,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,a,f,w){const y=this.mapper.egress(a);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:o,data:y}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:y,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:y,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:o}})},C.prototype._fanOutDelete=function(n,o){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:o}),this._fanOutRemote(n,"delete",{chainKey:o,op:"delete",targetId:o,payload:null,expectedVersion:null,meta:{id:o}},{id:o,meta:{entryId:k(),queued:!1,op:"delete",id:o}})},C.prototype._fanOutBulkDelete=function(n,o){const a=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:a,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:a,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:a}})},C.prototype._requestStoreMutation=function(n,o,a){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const f=k(),w=this._mutationReceipts.wait(f);return g(n.storeEl,"ln-data-store:request-"+o,Object.assign({},a,{requestId:f})),w},C.prototype._reportError=function(n,o,a){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:a||null})},C.prototype._owns=function(n){var a;const o=this._name||((a=this.findChildren().storeEl)==null?void 0:a.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),o=this.dom.getAttribute(s),a=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(a.keys()))f[w]=a.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[a,f,w]of b)for(const y of this.dom.ownerDocument.querySelectorAll(a))if(this._owns(y.getAttribute(f))){if((w==="table"||w==="list")&&y.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(y,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{});continue}this._serveElement(y,w,null,n)}},C.prototype._serveElement=function(n,o,a,f){const w=this.findChildren(),y=w.store;if(!y)return;a&&this._boundQueries.set(n,a);const A=this._boundQueries.get(n)||{sort:null,filters:{},search:""},q=se(A,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const p=Be(y,w.connector);if(o==="table"||o==="list"||o==="chart")return p==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:q,meta:{targetEl:n,kind:o,offset:q.offset,limit:q.limit,queryGen:A.queryGen}})):p!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):y.getAll(q).then(m=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:m.data,total:(f==null?void 0:f.total)??m.total,filtered:(f==null?void 0:f.filtered)??m.filtered,offset:m.offset??(f==null?void 0:f.offset)??A.offset,queryGen:A.queryGen!==void 0?A.queryGen:(f==null?void 0:f.queryGen)??m.queryGen,provisional:m.provisional===!0}),d._boundDelivered.set(n,!0))});if(o==="options"){if(p==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(p==="store")return y.getAll({}).then(m=>!d._destroyed&&g(n,"ln-options:set-data",{data:m.data}))}if(o==="stat"){let m=a==null?void 0:a.filters;if(!m){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");m={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&m&&Object.keys(m).length||y.noLocalQuery)?"remote":p;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:m},meta:{targetEl:n,kind:o}});if(v==="store")return y.count(m).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(p=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",p,{targetEl:n,kind:o}))})};function M(n){const o=n._unsubs=[],a=(d,p,m)=>{d.addEventListener(p,m),o.push(()=>d.removeEventListener(p,m))};a(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const p=n.findChildren();p.store&&p.connector&&g(p.connectorEl,_(p.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),a(n.dom,"ln-data-store:request-page",d=>{const p=n.findChildren(),m=d.detail||{};if(!p.connectorEl)return;const v=se(m.query||{},n._currentQuery());g(p.connectorEl,_(p.connectorEl)+":request-query",{query:Object.assign({},v,{offset:m.offset,limit:m.limit,queryGen:m.queryGen})})}),a(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),a(n.dom,"ln-data-coordinator:request-update",d=>n._fanOutUpdate(n.findChildren(),d.detail.id,d.detail.data||{},d.detail.expected_version,d.detail.action)),a(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),a(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),a(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),a(n.dom,"ln-api-queue:failed",d=>{var p;return n._reportError("queue-failed",((p=d==null?void 0:d.detail)==null?void 0:p.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),a(n.dom,"ln-data-store:initialized",d=>{var m;const p=n.findChildren();p.store&&!p.store.initializationError&&p.connector&&!n._noAutosync(p)&&!p.store.isSyncing&&(!((m=d.detail)!=null&&m.hasCache)||n._isStale(p))&&p.store.forceSync()});const f=()=>{const d=n.findChildren();d.store&&!d.store.initializationError&&d.connector&&!n._noAutosync(d)&&d.store.isInitialized&&!d.store.isSyncing&&d.store.forceSync()};a(n.dom,"ln-websocket-connector:connected",f),a(document,"submit",d=>n._onFormSubmit(d));const w=(d,p,m)=>{var v;n._owns(d.target.getAttribute(m))&&n._serveElement(d.target,p,p==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:p==="options"?null:Me(d.detail||{}),null)};a(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),a(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),a(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),a(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),a(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};a(n.dom,"ln-data-store:ready",y),a(n.dom,"ln-data-store:created",y),a(n.dom,"ln-data-store:updated",y),a(n.dom,"ln-data-store:deleted",y),a(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),a(n.dom,"ln-data-store:synced",d=>{var p;(p=d.detail)!=null&&p.changed&&n._refreshAll(d.detail.meta,!1)}),a(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),a(n.dom,"ln-search:change",d=>{var m;d.preventDefault();const p=((m=d.detail)==null?void 0:m.term)!=null?d.detail.term:"";p!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,p)}),a(n.dom,"ln-filter:change",d=>{var ce;d.preventDefault();const p=(ce=d.detail)==null?void 0:ce.key;if(!p)return;const m=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[p];if(S?S.length===m.length&&S.every((D,W)=>D===m[W]):!m.length)return;m.length?v[p]=m:delete v[p];const x=new URLSearchParams;Object.keys(v).forEach(D=>v[D].forEach(W=>x.append(D,W)));const I=x.toString();I?n.dom.setAttribute(l,I):n.dom.removeAttribute(l)}),a(n.dom,"ln-sort:change",d=>{var x,I;d.preventDefault();const p=(x=d.detail)==null?void 0:x.field,m=(I=d.detail)==null?void 0:I.direction,v=p&&m&&m!=="none"?{field:p,direction:m}:null,S=n._currentQuery().sort;!S&&!v||S&&v&&S.field===v.field&&S.direction===v.direction||(v?(n.dom.setAttribute(u,v.field),n.dom.setAttribute(s,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(s)))});const A=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),q=n.findChildren().connectorEl;if(q){const d=_(q);A.add(d),a(n.dom,d+":connected",f)}A.forEach(d=>{a(n.dom,d+":fetched",p=>n._reconcileServerFetch(p.detail)),a(n.dom,d+":created",p=>n._reconcileServerMutation("create",p.detail)),a(n.dom,d+":updated",p=>n._reconcileServerMutation("update",p.detail)),a(n.dom,d+":deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":bulk-deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":error",p=>n._reconcileServerMutation("error",p.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const a=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:a.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:a.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:a.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(o.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var A;return g(o.connectorEl,f+":request-bulk-delete",{ids:((A=n.payload)==null?void 0:A.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:a.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const a=o.hasAttribute(r)?o.getAttribute(r):null;if(a===null||(a?!this._owns(a):o.closest("["+e+"]")!==this.dom))return;const f=U(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=G(o);delete w._method,delete w._token;const y=w.id,A=w.expected_version,q=o.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,q):this._fanOutUpdate(d,y,w,A,q)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},a=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],y=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],A=Array.isArray(f)?Math.floor(Date.now()/1e3):(f==null?void 0:f.synced_at)??(f==null?void 0:f.since)??Math.floor(Date.now()/1e3),q=w.map(d=>this.mapper.ingress(d));if(!(!a.store||a.store.initializationError)){if(!o.kind)return a.store.applySync(q,y,A,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});a.store.applyQuery(q,{total:n.total}).then(d=>{const p=o.kind;p==="table"||p==="list"||p==="chart"?(g(o.targetEl,"ln-"+p+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+p+":set-data",{data:d,total:n.total??d.length,filtered:n.filtered??d.length,offset:n.offset,queryGen:o.queryGen}),this._boundDelivered.set(o.targetEl,!0)):p==="options"?a.store.getAll({}).then(m=>g(o.targetEl,"ln-options:set-data",{data:m.data})):p==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??q.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const a=this.findChildren(),f=o.meta||{};if(n==="create"){if(!o.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const y=this.mapper.ingress(o.record);(a.storeEl?this._requestStoreMutation(a,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(A=>this._reportError("create-reconcile",A,f))}else if(n==="update"){const y=o.record?this.mapper.ingress(o.record):null;(a.storeEl&&y?this._requestStoreMutation(a,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(A=>this._reportError("update-reconcile",A,f))}else if(n==="ack")f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const y=o.status||((w=o.error)==null?void 0:w.status)||0;f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),a.storeEl&&g(a.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:y}),this._reportError("connector-error",o.error||o,f)}},C.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function B(n,o){const a=n[t];a&&(o==="data-ln-data-coordinator-mapper"?a.refreshMapper():(o===i||o===l||o===u||o===s)&&a._queueQueryRefresh())}ae(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,u,s],onAttributeChange:B}),window[t].init=window[t]})()})();
1
+ (function(){"use strict";function G(){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(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 c=1;c<t.length;c++)if(t[c]&&t[c].nodeType===1){r=t[c];break}if(!T(r))return}e.apply(console,t)}}function g(e,t,o){const r=o||{};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 K(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Q(e,t){const o=!!(t&&t.typed),r=t&&t.exclude,c={},f=e.elements,l={};if(o)for(let p=0;p<f.length;p++){const a=f[p];a.name&&a.type==="checkbox"&&!a.disabled&&(l[a.name]=(l[a.name]||0)+1)}for(let p=0;p<f.length;p++){const a=f[p];if(!(!a.name||a.disabled||a.type==="file"||a.type==="submit"||a.type==="button")&&!(r&&a.matches&&a.matches(r)))if(a.type==="checkbox")o&&l[a.name]===1?c[a.name]=a.checked:(c[a.name]||(c[a.name]=[]),a.checked&&c[a.name].push(a.value));else if(a.type==="radio")a.checked&&(c[a.name]=a.value);else if(a.type==="select-multiple"){c[a.name]=[];for(let m=0;m<a.options.length;m++)a.options[m].selected&&c[a.name].push(a.options[m].value)}else if(o&&a.type==="hidden")c[a.name]=a.value;else if(o&&(a.type==="number"||a.type==="range")){const m=Number(a.value);c[a.name]=a.value===""||isNaN(m)?null:m}else c[a.name]=a.value}return c}function pe(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function he(e,t){const o=e.elements,r=[],c={};for(let f=0;f<o.length;f++){const l=o[f];l.name&&l.type==="checkbox"&&(c[l.name]=(c[l.name]||0)+1)}for(let f=0;f<o.length;f++){const l=o[f];if(l.type==="file"||l.type==="submit"||l.type==="button")continue;const p=l.getAttribute("data-ln-fill-as")||l.name;if(!p||!(p in t))continue;const a=t[p];if(l.type==="checkbox"){if(Array.isArray(a))l.checked=a.indexOf(l.value)!==-1;else if(c[l.name]>1){const m=String(a).split(",").map(function(q){return q.trim()});l.checked=m.indexOf(l.value)!==-1}else l.checked=pe(a);r.push(l)}else if(l.type==="radio")l.checked=l.value===String(a),r.push(l);else if(l.type==="select-multiple"){if(Array.isArray(a))for(let m=0;m<l.options.length;m++)l.options[m].selected=a.indexOf(l.options[m].value)!==-1;r.push(l)}else l.value=a,l.tagName==="SELECT"&&a!=null&&l.setAttribute("data-ln-value",a),r.push(l)}return r}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=he,window.lnCore.serializeForm=Q,window.lnCore.resolveFormMethod=K);const P={};function we(e,t){P[e]=t}function me(e){return P[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=we,window.lnCore.getDataMapper=me);function be(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const V={};function ye(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];V[o]=t}function ge(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return V[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=ye,window.lnCore.getLocaleFallback=ge,window.lnCore.ensureLocaleObserver=be);const L={};function Ce(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=L[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function z(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let l=0;l<o.length;l++){const p=o[l],a=p.getAttribute("data-ln-field");t[a]!=null&&(p.textContent=t[a])}const r=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<r.length;l++){const p=r[l],a=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<a.length;m++){const q=a[m].trim().split(":");if(q.length!==2)continue;const _=q[0].trim(),C=q[1].trim();t[C]!=null&&p.setAttribute(_,t[C])}}const c=e.querySelectorAll("[data-ln-show]");for(let l=0;l<c.length;l++){const p=c[l],a=p.getAttribute("data-ln-show");a in t&&p.classList.toggle("hidden",!t[a])}const f=e.querySelectorAll("[data-ln-class]");for(let l=0;l<f.length;l++){const p=f[l],a=p.getAttribute("data-ln-class").split(",");for(let m=0;m<a.length;m++){const q=a[m].trim().split(":");if(q.length!==2)continue;const _=q[0].trim(),C=q[1].trim();C in t&&p.classList.toggle(_,!!t[C])}}return e}function _e(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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<o.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[r],t??null),o[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)z(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let o=0;o<t.length;o++)t[o].textContent=""}})));function H(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const f=o.currentNode;f.textContent.indexOf("{{")!==-1&&(f.textContent=f.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,p){return t[p]!==void 0?t[p]:""}))}const r=function(f,l){return t[l]!==void 0?t[l]:""},c=Array.from(e.querySelectorAll("*"));e.nodeType===1&&c.push(e);for(let f=0;f<c.length;f++){const l=c[f],p=l.attributes;for(let a=0;a<p.length;a++){const m=p[a];m.value.indexOf("{{")!==-1&&l.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function Ae(e,t,o,r,c,f){const l={};for(let a=0;a<e.children.length;a++){const m=e.children[a],q=m.getAttribute("data-ln-render-key");q&&(l[q]=m)}const p=document.createDocumentFragment();for(let a=0;a<t.length;a++){const m=t[a],q=String(r(m));let _=l[q];if(_)c(_,m,a);else{const C=Ce(o,f);if(!C||(H(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",q),c(_,m,a)}p.appendChild(_)}e.textContent="",e.appendChild(p)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=H,window.lnCore.fill=z,window.lnCore.lnFill=_e,window.lnCore.renderList=Ae);function F(e,t,o){const r=e.getAttribute(t);return r===null?o:r}function J(e,t,o){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?o:r}function X(e,t,o=!1){const r=e.getAttribute(t);if(r===null)return!!o;const c=r.trim().toLowerCase();return!(c==="false"||c==="0")}function Y(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const j=new Map;function Z(e,t){const o=(e?e.join("|"):"")+"::"+t;if(j.has(o))return j.get(o);const r=new Set(e||[]),c=function(f,l){const p=f.getAttribute(l);return p!==null&&r.has(p)?p:t};return j.set(o,c),c}function ee(e,t,o){const r=parseFloat(e.getAttribute(t));return isNaN(r)?o:r}function te(e,t,o){const r=e.getAttribute(t);if(!r)return o;try{return JSON.parse(r)}catch{return o}}function ne(e,t,o,r,c){if(!e||t===null)return!0;const f=r||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const p=a=>{c?console.warn(a,c):console.warn(a)};if(l==="boolean"){const a=t.trim().toLowerCase();return a!==""&&a!=="true"&&a!=="false"&&a!=="1"&&a!=="0"?(p(`[${f}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const a=e.values||[];return a.includes(t)?!0:(p(`[${f}] Invalid value "${t}" for attribute "${o}". Allowed: ${a.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return p(`[${f}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const a=parseInt(t,10);return e.min!==void 0&&a<e.min?(p(`[${f}] Value ${a} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&a>e.max?(p(`[${f}] Value ${a} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(p(`[${f}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(a){return p(`[${f}] Invalid JSON for attribute "${o}": ${a.message}. Fallback: ${e.fallback}.`),!1}return!0}function re(e,t,o){for(const r in o){const[c,f,l]=o[r];Object.defineProperty(e,r,{get:function(){return c(t,f,l)},enumerable:!0,configurable:!0})}return e}function oe(e){const t={};for(const o in e){const r=e[o];if(!r||!r.prop)continue;let c=r.read;if(!c&&r.type)switch(r.type){case"enum":c=Z(r.values,r.fallback);break;case"integer":c=J;break;case"float":c=ee;break;case"boolean":c=X;break;case"list":c=Y;break;case"json":c=te;break;case"string":default:c=F;break}c||(c=F),t[r.prop]=[c,o,r.fallback]}return t}function ve(e){const t={};for(const o in e){const r=e[o];r&&r.effect&&(t[o]=r.effect)}return Object.keys(t).length?t:null}function qe(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=re,window.lnCore.attrSpec=oe,window.lnCore.attrStr=F,window.lnCore.attrInt=J,window.lnCore.attrBool=X,window.lnCore.attrList=Y,window.lnCore.attrEnum=Z,window.lnCore.attrFloat=ee,window.lnCore.attrJson=te);function I(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(o){console.error("["+t.attribute+"] init failed",e,o)}}}function ie(e,t,o,r){if(e.nodeType!==1)return;const f=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l={selector:t,attribute:o,ComponentFn:r};if(e.matches&&e.matches(f)&&I(e,l),e.querySelectorAll){const p=e.querySelectorAll(f);for(let a=0;a<p.length;a++)I(p[a],l)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ee(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function Se(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 ae(){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 xe(e){const t=ae(),o=e.observed||[];for(let r=0;r<o.length;r++){const c=o[r];t.byAttr.has(c)||t.byAttr.set(c,[]),t.byAttr.get(c).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 c=t.byDeclaredAttr.get(r);c.some(f=>f.componentTag===e.componentTag)||c.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=qe(e);if(r===null)t.reactiveWildcard.push(e);else for(const c of r)t.byReactive.has(c)||t.byReactive.set(c,[]),t.byReactive.get(c).push(e)}e.persist&&t.persist.push(e)}function le(e,t,o,r){for(let c=0;c<e.length;c++){const f=e[c];if(!t[f.attribute])continue;const l=f.effects&&f.effects[o];l?l(t,o,r):f.onAttrChange&&(!f.declared||f.declared.has(o))&&f.onAttrChange(t,o,r)}}function ke(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,r=ae(),c=r.byAttr.get(t),f=G()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(t);if(!o&&!c&&!f)return;const l=e.target;if(e.oldValue!==l.getAttribute(t)){if(f&&T(l)){const p=r.byDeclaredAttr.get(t),a=l.getAttribute(t);for(let m=0;m<p.length;m++)ne(p[m].spec,a,t,p[m].componentTag,l)}if(window.lnCore._debugSink&&(o||c)&&window.lnCore._debugSink("attr",t,l,{oldValue:e.oldValue,newValue:l.getAttribute(t)}),o){const p=r.byReactive.get(t);p&&le(p,l,t,e.oldValue),r.reactiveWildcard.length&&le(r.reactiveWildcard,l,t,e.oldValue)}if(c)for(let p=0;p<c.length;p++){const a=c[p];if(a.handler){a.handler(l,t,e.oldValue);continue}a.onAttributeChange&&l[a.attribute]?a.onAttributeChange(l,t):(ie(l,a.selector,a.attribute,a.ComponentFn),a.onInit&&a.onInit(l))}}}function Ie(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{ke(t[o])}catch(r){console.error("[ln-core] mutation handler failed",t[o].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function M(e,t){if(!document.contains(e))if(t.attribute){const o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.destroy()}catch(r){console.error("["+t.attribute+"] destroy failed",e,r)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function Oe(e){const t=$();if(t.length){if(e.target)for(let o=0;o<t.length;o++){const r=t[o];if(r.onSubtreeChange&&r.query){const c=r.query,f=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;f&&r.onSubtreeChange(f,e)}}for(let o=0;o<e.addedNodes.length;o++){const r=e.addedNodes[o];if(r.nodeType===1){const c=!!(r.firstElementChild||r.children&&r.children.length);for(let f=0;f<t.length;f++){const l=t[f];if(l.selector&&l.attribute&&l.ComponentFn){if(!c)r.matches&&r.matches(l.query)&&I(r,l);else if(r.matches&&r.matches(l.query)&&I(r,l),r.querySelectorAll){const p=r.querySelectorAll(l.query);for(let a=0;a<p.length;a++)I(p[a],l)}}l.onInit&&l.onInit(r)}}}for(let o=0;o<e.removedNodes.length;o++){const r=e.removedNodes[o];if(r.nodeType===1){const c=!!(r.firstElementChild||r.children&&r.children.length);for(let f=0;f<t.length;f++){const l=t[f],p=l.query;if(p){if(!c)r.matches&&r.matches(p)&&M(r,l);else if(r.matches&&r.matches(p)&&M(r,l),r.querySelectorAll){const a=r.querySelectorAll(p);for(let m=0;m<a.length;m++)M(a[m],l)}}}}}}}function se(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const r=t[o];if(r.type==="childList")try{Oe(r)}catch(c){console.error("[ln-core] lifecycle handler failed",r.target,c)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function De(e){$().push(e),se()}function ce(e,t,o,r,c={}){const f=c.extraAttributes||[],l=c.onAttributeChange||null,p=c.onSubtreeChange||null,a=c.onInit||null,m=c.onAttrChange||null,q=c.effects||null,_=c.attributes||null,C=_?ve(_):q,W=_?new Set(Object.keys(_)):null,N=c.persist||null;function n(y){const A=y||document.body;if(ie(A,e,t,o),_&&G())for(const E in _){const d=_[E],h=Array.from(A.querySelectorAll("["+E+"]"));A.matches&&A.matches("["+E+"]")&&h.push(A);for(let b=0;b<h.length;b++){const v=h[b];T(v)&&ne(d,v.getAttribute(E),E,r,v)}}a&&a(A)}const i=[];if(e.indexOf("[")!==-1){const y=/\[([\w-]+)/g;let A;for(;(A=y.exec(e))!==null;)i.push(A[1])}else i.push(e);xe({selector:e,attribute:t,componentTag:r,attributes:_,ComponentFn:o,onInit:a,observed:i.concat(f),onAttributeChange:l,onAttrChange:m,effects:C,declared:W,persist:N}),Ie();const s=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,u=c.subtreeQuery||(s?e:"["+e+"]");$().push({selector:e,attribute:t,ComponentFn:o,onInit:a,onSubtreeChange:p,query:u}),se(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ce,window.lnCore.observeLifecycle=De);function w(){Ee()>0?Se(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),n}function Re(e,t){let o=!1;return function(){o||(o=!0,queueMicrotask(function(){o=!1,e()}))}}function de(e){return(e||"").replace(/^#/,"")}function B(e){const t=e===void 0?location.hash:e,o={},r=de(t);if(!r)return o;const c=r.split("&");for(let f=0;f<c.length;f++){const l=c[f];if(!l)continue;const p=l.indexOf(":"),a=p>-1?l.slice(0,p):l,m=p>-1?l.slice(p+1):"";if(a)try{o[a]=decodeURIComponent(m)}catch{o[a]=m}}return o}function Te(e){if(!e)return null;const t=B();return e in t?t[e]:null}function Le(e,t){if(!e)return;const o=B();t==null?delete o[e]:o[e]=String(t);const c=Object.keys(o).map(function(f){const l=o[f];return l===""?f:f+":"+encodeURIComponent(l)}).join("&");de(location.hash)!==c&&(location.hash=c)}function Fe(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function je(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.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 $e(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Me(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 Be(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function We(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const o=e.slice(0,t),r=e.slice(t+1),c=r?r.split(",").map(function(f){try{return decodeURIComponent(f)}catch{return f}}).filter(Boolean):[];return{key:o,values:c}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=B,window.lnCore.hashGet=Te,window.lnCore.hashSet=Le,window.lnCore.hashLinkClick=Fe,window.lnCore.resolveHashNamespace=je,window.lnCore.hashSortEncode=$e,window.lnCore.hashSortDecode=Me,window.lnCore.hashFilterEncode=Be,window.lnCore.hashFilterDecode=We);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Ne(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ue(e,t){const o=!e||!!e.initializationError,r=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(o||!e.canServe||r)?"remote":e&&!e.initializationError?"store":"none"}function ue(e,t){const o=Object.assign({},e);return t&&(o.filters=t.filters,o.search=t.search,o.sort=t.sort),o}class Ge{constructor(){this._pending=new Map}wait(t){return new Promise((o,r)=>{this._pending.set(t,{resolve:o,reject:r})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const o=t||new Error("Mutation receipt registry closed");for(const r of this._pending.values())r.reject(o);this._pending.clear()}_settle(t,o){const r=t&&t.requestId;if(!r)return!1;const c=this._pending.get(r);return c?(this._pending.delete(r),o?c.reject(t.error||new Error("Store mutation failed")):c.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",o="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const r="data-ln-data-coordinator-search",c="data-ln-data-coordinator-filters",f="data-ln-data-coordinator-sort-field",l="data-ln-data-coordinator-sort-direction",a=oe({"data-ln-data-coordinator":{prop:"_name",type:"string",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-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",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"}}),m=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function q(n){const i=n.getAttribute("data-ln-data-coordinator-connector");if(i)return n.querySelector(i)||document.querySelector(i)||document.getElementById(i);const s=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(s)return s;for(const u of n.querySelectorAll("*")){if(u.lnConnector)return u;for(const w of u.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return u}return null}function _(n){var s;if(!n)return"ln-connector";if((s=n.lnConnector)!=null&&s.namespace)return n.lnConnector.namespace;const i=n.getAttribute("data-ln-connector");if(i&&i!=="true")return i.startsWith("ln-")?i:"ln-"+i+(i.endsWith("-connector")?"":"-connector");for(const u of n.attributes)if(u.name.startsWith("data-ln-")&&u.name.endsWith("-connector"))return u.name.replace(/^data-/,"");return"ln-connector"}function C(n){const i=this;return this.dom=n,re(this,n,a),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new Ge,this._queueQueryRefresh=Re(()=>{i._destroyed||i._refreshAll(null,!0)}),this.refreshMapper(),W(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var i;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((i=n.storeEl)!=null&&i.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var s,u;const i=this.dom.getAttribute("data-ln-data-coordinator-stale")||((s=n.storeEl)==null?void 0:s.getAttribute("data-ln-data-store-stale"));return i==="never"||i==="-1"?!1:!((u=n.store)!=null&&u.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(i,10)||300)},C.prototype._checkInitialSync=function(){const n=this,i=this.findChildren();i.store&&Promise.resolve(i.store.ready).then(()=>{if(n._destroyed)return;const s=n.findChildren();s.store&&s.connector&&!n._noAutosync(s)&&!s.store.isSyncing&&(!s.store.hasCache||n._isStale(s))&&s.store.forceSync()}).catch(s=>n._reportError("store-initialize",s,null))},C.prototype.refreshMapper=function(){var s,u;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,i=n&&((u=(s=window.lnCore)==null?void 0:s.getDataMapper)==null?void 0:u.call(s,n))||null;this.mapper={ingress:(i==null?void 0:i.ingress)||(w=>w),egress:(i==null?void 0:i.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),i=q(this.dom),s=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:i,queueEl:s,store:(n==null?void 0:n.lnDataStore)||null,connector:(i==null?void 0:i.lnConnector)||(i==null?void 0:i.lnApiConnector)||(i==null?void 0:i.lnCouchDbConnector)||(i==null?void 0:i.lnWebsocketConnector)||null,queue:(s==null?void 0:s.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,i,s,u){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",s):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+i,u)},C.prototype._fanOutCreate=function(n,i,s){const u="_temp_"+k(),w=this.mapper.egress(i);n.storeEl&&g(n.storeEl,"ln-data-store:request-create",{tempId:u,data:w}),this._fanOutRemote(n,"create",{chainKey:u,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:u,action:s}},{data:w,url:s,meta:{entryId:k(),queued:!1,op:"create",tempId:u}})},C.prototype._fanOutUpdate=function(n,i,s,u,w){const y=this.mapper.egress(s);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:i,data:y}),this._fanOutRemote(n,"update",{chainKey:i,op:"update",targetId:i,payload:y,expectedVersion:u,meta:{id:i,action:w}},{id:i,data:y,expected_version:u,url:w,meta:{entryId:k(),queued:!1,op:"update",id:i}})},C.prototype._fanOutDelete=function(n,i){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:i}),this._fanOutRemote(n,"delete",{chainKey:i,op:"delete",targetId:i,payload:null,expectedVersion:null,meta:{id:i}},{id:i,meta:{entryId:k(),queued:!1,op:"delete",id:i}})},C.prototype._fanOutBulkDelete=function(n,i){const s=i.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:i}),this._fanOutRemote(n,"bulk-delete",{chainKey:s,op:"bulk-delete",targetId:null,payload:{ids:i},expectedVersion:null,meta:{bulkKey:s,ids:i}},{ids:i,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:s}})},C.prototype._requestStoreMutation=function(n,i,s){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const u=k(),w=this._mutationReceipts.wait(u);return g(n.storeEl,"ln-data-store:request-"+i,Object.assign({},s,{requestId:u})),w},C.prototype._reportError=function(n,i,s){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:i,meta:s||null})},C.prototype._owns=function(n){var s;const i=this._name||((s=this.findChildren().storeEl)==null?void 0:s.id);return!!n&&n===i},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(f),i=this.dom.getAttribute(l),s=new URLSearchParams(this.dom.getAttribute(c)||""),u={};for(const w of new Set(s.keys()))u[w]=s.getAll(w);return{search:this.dom.getAttribute(r)||"",filters:u,sort:n&&i?{field:n,direction:i}:null}},C.prototype._refreshAll=function(n,i){for(const[s,u,w]of m)for(const y of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(y.getAttribute(u))){if((w==="table"||w==="list")&&y.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(y,"ln-"+w+(i?":request-invalidate":":request-revalidate"),{});continue}this._serveElement(y,w,null,n)}},C.prototype._serveElement=function(n,i,s,u){const w=this.findChildren(),y=w.store;if(!y)return;s&&this._boundQueries.set(n,s);const A=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=ue(A,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const h=Ue(y,w.connector);if(i==="table"||i==="list"||i==="chart")return h==="remote"?(g(n,"ln-"+i+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:i,offset:E.offset,limit:E.limit,queryGen:A.queryGen}})):h!=="store"?g(n,"ln-"+i+":set-loading",{loading:!1}):y.getAll(E).then(b=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+i+":set-loading",{loading:!1}),g(n,"ln-"+i+":set-data",{data:b.data,total:(u==null?void 0:u.total)??b.total,filtered:(u==null?void 0:u.filtered)??b.filtered,offset:b.offset??(u==null?void 0:u.offset)??A.offset,queryGen:A.queryGen!==void 0?A.queryGen:(u==null?void 0:u.queryGen)??b.queryGen,provisional:b.provisional===!0}),d._boundDelivered.set(n,!0))});if(i==="options"){if(h==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:i}});if(h==="store")return y.getAll({}).then(b=>!d._destroyed&&g(n,"ln-options:set-data",{data:b.data}))}if(i==="stat"){let b=s==null?void 0:s.filters;if(!b){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");b={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&b&&Object.keys(b).length||y.noLocalQuery)?"remote":h;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:b},meta:{targetEl:n,kind:i}});if(v==="store")return y.count(b).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(h=>{d._destroyed||((i==="table"||i==="list"||i==="chart")&&g(n,"ln-"+i+":set-loading",{loading:!1}),d._reportError(i+"-query",h,{targetEl:n,kind:i}))})};function W(n){const i=n._unsubs=[],s=(d,h,b)=>{d.addEventListener(h,b),i.push(()=>d.removeEventListener(h,b))};s(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",d=>{const h=n.findChildren(),b=d.detail||{};if(!h.connectorEl)return;const v=ue(b.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},v,{offset:b.offset,limit:b.limit,queryGen:b.queryGen})})}),s(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),s(n.dom,"ln-data-coordinator:request-update",d=>n._fanOutUpdate(n.findChildren(),d.detail.id,d.detail.data||{},d.detail.expected_version,d.detail.action)),s(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),s(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),s(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),s(n.dom,"ln-api-queue:failed",d=>{var h;return n._reportError("queue-failed",((h=d==null?void 0:d.detail)==null?void 0:h.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),s(n.dom,"ln-data-store:initialized",d=>{var b;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((b=d.detail)!=null&&b.hasCache)||n._isStale(h))&&h.store.forceSync()});const u=()=>{const d=n.findChildren();d.store&&!d.store.initializationError&&d.connector&&!n._noAutosync(d)&&d.store.isInitialized&&!d.store.isSyncing&&d.store.forceSync()};s(n.dom,"ln-websocket-connector:connected",u),s(document,"submit",d=>n._onFormSubmit(d));const w=(d,h,b)=>{var v;n._owns(d.target.getAttribute(b))&&n._serveElement(d.target,h,h==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:h==="options"?null:Ne(d.detail||{}),null)};s(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),s(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),s(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),s(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),s(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",y),s(n.dom,"ln-data-store:created",y),s(n.dom,"ln-data-store:updated",y),s(n.dom,"ln-data-store:deleted",y),s(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),s(n.dom,"ln-data-store:synced",d=>{var h;(h=d.detail)!=null&&h.changed&&n._refreshAll(d.detail.meta,!1)}),s(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),s(n.dom,"ln-search:change",d=>{var b;d.preventDefault();const h=((b=d.detail)==null?void 0:b.term)!=null?d.detail.term:"";h!==(n.dom.getAttribute(r)||"")&&n.dom.setAttribute(r,h)}),s(n.dom,"ln-filter:change",d=>{var fe;d.preventDefault();const h=(fe=d.detail)==null?void 0:fe.key;if(!h)return;const b=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[h];if(S?S.length===b.length&&S.every((R,U)=>R===b[U]):!b.length)return;b.length?v[h]=b:delete v[h];const x=new URLSearchParams;Object.keys(v).forEach(R=>v[R].forEach(U=>x.append(R,U)));const O=x.toString();O?n.dom.setAttribute(c,O):n.dom.removeAttribute(c)}),s(n.dom,"ln-sort:change",d=>{var x,O;d.preventDefault();const h=(x=d.detail)==null?void 0:x.field,b=(O=d.detail)==null?void 0:O.direction,v=h&&b&&b!=="none"?{field:h,direction:b}:null,S=n._currentQuery().sort;!S&&!v||S&&v&&S.field===v.field&&S.direction===v.direction||(v?(n.dom.setAttribute(f,v.field),n.dom.setAttribute(l,v.direction)):(n.dom.removeAttribute(f),n.dom.removeAttribute(l)))});const A=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const d=_(E);A.add(d),s(n.dom,d+":connected",u)}A.forEach(d=>{s(n.dom,d+":fetched",h=>n._reconcileServerFetch(h.detail)),s(n.dom,d+":created",h=>n._reconcileServerMutation("create",h.detail)),s(n.dom,d+":updated",h=>n._reconcileServerMutation("update",h.detail)),s(n.dom,d+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":error",h=>n._reconcileServerMutation("error",h.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const i=this.findChildren();if(!i.store||!i.connector||!i.queue)return;const s=n.meta||{},u=_(i.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(i.connectorEl,u+":request-create",{data:n.payload,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:s.tempId}}),update:()=>g(i.connectorEl,u+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(i.connectorEl,u+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var A;return g(i.connectorEl,u+":request-bulk-delete",{ids:((A=n.payload)==null?void 0:A.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const i=n.target;if(n.defaultPrevented)return;const s=i.hasAttribute(o)?i.getAttribute(o):null;if(s===null||(s?!this._owns(s):i.closest("["+e+"]")!==this.dom))return;const u=K(i);if(u!=="POST"&&u!=="PUT"&&u!=="PATCH")return;n.preventDefault();const w=Q(i);delete w._method,delete w._token;const y=w.id,A=w.expected_version,E=i.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,u==="POST"?this._fanOutCreate(d,w,E):this._fanOutUpdate(d,y,w,A,E)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const i=n.meta||{},s=this.findChildren(),u=n.data;this.refreshMapper();const w=Array.isArray(u)?u:(u==null?void 0:u.data)||[],y=Array.isArray(u==null?void 0:u.deleted)?u.deleted:[],A=Array.isArray(u)?Math.floor(Date.now()/1e3):(u==null?void 0:u.synced_at)??(u==null?void 0:u.since)??Math.floor(Date.now()/1e3),E=w.map(d=>this.mapper.ingress(d));if(!(!s.store||s.store.initializationError)){if(!i.kind)return s.store.applySync(E,y,A,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:i.targetEl});s.store.applyQuery(E,{total:n.total}).then(d=>{const h=i.kind;h==="table"||h==="list"||h==="chart"?(g(i.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(i.targetEl,"ln-"+h+":set-data",{data:d,total:n.total??d.length,filtered:n.filtered??d.length,offset:n.offset,queryGen:i.queryGen}),this._boundDelivered.set(i.targetEl,!0)):h==="options"?s.store.getAll({}).then(b=>g(i.targetEl,"ln-options:set-data",{data:b.data})):h==="stat"&&g(i.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},C.prototype._reconcileServerMutation=function(n,i){var w;if(!i)return;const s=this.findChildren(),u=i.meta||{};if(n==="create"){if(!i.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),u);const y=this.mapper.ingress(i.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:u.tempId,data:y}):Promise.resolve()).then(()=>{u.queued&&s.queue&&g(s.queueEl,"ln-api-queue:resolve-create",{entryId:u.entryId,oldKey:u.tempId,newId:y.id})}).catch(A=>this._reportError("create-reconcile",A,u))}else if(n==="update"){const y=i.record?this.mapper.ingress(i.record):null;(s.storeEl&&y?this._requestStoreMutation(s,"update",{id:u.id,data:y}):Promise.resolve()).then(()=>{u.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:u.entryId})}).catch(A=>this._reportError("update-reconcile",A,u))}else if(n==="ack")u.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:u.entryId});else if(n==="error"){const y=i.status||((w=i.error)==null?void 0:w.status)||0;u.queued&&s.queue&&g(s.queueEl,"ln-api-queue:nack",{entryId:u.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),s.storeEl&&g(s.storeEl,"ln-data-store:request-sync-failed",{error:i.error||i,status:y}),this._reportError("connector-error",i.error||i,u)}},C.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function N(n,i){const s=n[t];s&&(i==="data-ln-data-coordinator-mapper"?s.refreshMapper():(i===r||i===c||i===f||i===l)&&s._queueQueryRefresh())}ce(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",r,c,f,l],onAttributeChange:N}),window[t].init=window[t]})()})();
@@ -1 +1 @@
1
- (function(){"use strict";function fe(){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 re(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 i=null;for(let a=1;a<t.length;a++)if(t[a]&&t[a].nodeType===1){i=t[a];break}if(!re(i))return}e.apply(console,t)}}function v(e,t,o){const i=o||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function Q(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){Q(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Pe(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Fe(e,t){const o=!!(t&&t.typed),i=t&&t.exclude,a={},s=e.elements,l={};if(o)for(let d=0;d<s.length;d++){const c=s[d];c.name&&c.type==="checkbox"&&!c.disabled&&(l[c.name]=(l[c.name]||0)+1)}for(let d=0;d<s.length;d++){const c=s[d];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")o&&l[c.name]===1?a[c.name]=c.checked:(a[c.name]||(a[c.name]=[]),c.checked&&a[c.name].push(c.value));else if(c.type==="radio")c.checked&&(a[c.name]=c.value);else if(c.type==="select-multiple"){a[c.name]=[];for(let w=0;w<c.options.length;w++)c.options[w].selected&&a[c.name].push(c.options[w].value)}else if(o&&c.type==="hidden")a[c.name]=c.value;else if(o&&(c.type==="number"||c.type==="range")){const w=Number(c.value);a[c.name]=c.value===""||isNaN(w)?null:w}else a[c.name]=c.value}return a}function je(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function $e(e,t){const o=e.elements,i=[],a={};for(let s=0;s<o.length;s++){const l=o[s];l.name&&l.type==="checkbox"&&(a[l.name]=(a[l.name]||0)+1)}for(let s=0;s<o.length;s++){const l=o[s];if(l.type==="file"||l.type==="submit"||l.type==="button")continue;const d=l.getAttribute("data-ln-fill-as")||l.name;if(!d||!(d in t))continue;const c=t[d];if(l.type==="checkbox"){if(Array.isArray(c))l.checked=c.indexOf(l.value)!==-1;else if(a[l.name]>1){const w=String(c).split(",").map(function(b){return b.trim()});l.checked=w.indexOf(l.value)!==-1}else l.checked=je(c);i.push(l)}else if(l.type==="radio")l.checked=l.value===String(c),i.push(l);else if(l.type==="select-multiple"){if(Array.isArray(c))for(let w=0;w<l.options.length;w++)l.options[w].selected=c.indexOf(l.options[w].value)!==-1;i.push(l)}else l.value=c,l.tagName==="SELECT"&&c!=null&&l.setAttribute("data-ln-value",c),i.push(l)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=$e,window.lnCore.serializeForm=Fe,window.lnCore.resolveFormMethod=Pe);const he={};function Ke(e,t){he[e]=t}function Ue(e){return he[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=Ke,window.lnCore.getDataMapper=Ue);function Ve(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Q(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const we={};function Ge(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];we[o]=t}function He(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return we[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ge,window.lnCore.getLocaleFallback=He,window.lnCore.ensureLocaleObserver=Ve);const oe={};function We(e,t){oe[e]||(oe[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=oe[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function ye(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let l=0;l<o.length;l++){const d=o[l],c=d.getAttribute("data-ln-field");t[c]!=null&&(d.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<i.length;l++){const d=i[l],c=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<c.length;w++){const b=c[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();t[x]!=null&&d.setAttribute(_,t[x])}}const a=e.querySelectorAll("[data-ln-show]");for(let l=0;l<a.length;l++){const d=a[l],c=d.getAttribute("data-ln-show");c in t&&d.classList.toggle("hidden",!t[c])}const s=e.querySelectorAll("[data-ln-class]");for(let l=0;l<s.length;l++){const d=s[l],c=d.getAttribute("data-ln-class").split(",");for(let w=0;w<c.length;w++){const b=c[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();x in t&&d.classList.toggle(_,!!t[x])}}return e}function Qe(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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<o.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[i],t??null),o[i].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)ye(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let o=0;o<t.length;o++)t[o].textContent=""}})));function pe(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const s=o.currentNode;s.textContent.indexOf("{{")!==-1&&(s.textContent=s.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,d){return t[d]!==void 0?t[d]:""}))}const i=function(s,l){return t[l]!==void 0?t[l]:""},a=Array.from(e.querySelectorAll("*"));e.nodeType===1&&a.push(e);for(let s=0;s<a.length;s++){const l=a[s],d=l.attributes;for(let c=0;c<d.length;c++){const w=d[c];w.value.indexOf("{{")!==-1&&l.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Je(e,t,o,i,a,s){const l={};for(let c=0;c<e.children.length;c++){const w=e.children[c],b=w.getAttribute("data-ln-render-key");b&&(l[b]=w)}const d=document.createDocumentFragment();for(let c=0;c<t.length;c++){const w=t[c],b=String(i(w));let _=l[b];if(_)a(_,w,c);else{const x=We(o,s);if(!x||(pe(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),a(_,w,c)}d.appendChild(_)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=pe,window.lnCore.fill=ye,window.lnCore.lnFill=Qe,window.lnCore.renderList=Je);function ie(e,t,o){const i=e.getAttribute(t);return i===null?o:i}function J(e,t,o){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?o:i}function ae(e,t,o=!1){const i=e.getAttribute(t);if(i===null)return!!o;const a=i.trim().toLowerCase();return!(a==="false"||a==="0")}function se(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const le=new Map;function me(e,t){const o=(e?e.join("|"):"")+"::"+t;if(le.has(o))return le.get(o);const i=new Set(e||[]),a=function(s,l){const d=s.getAttribute(l);return d!==null&&i.has(d)?d:t};return le.set(o,a),a}function ge(e,t,o){const i=parseFloat(e.getAttribute(t));return isNaN(i)?o:i}function be(e,t,o){const i=e.getAttribute(t);if(!i)return o;try{return JSON.parse(i)}catch{return o}}function _e(e,t,o,i,a){if(!e||t===null)return!0;const s=i||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const d=c=>{a?console.warn(c,a):console.warn(c)};if(l==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(d(`[${s}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const c=e.values||[];return c.includes(t)?!0:(d(`[${s}] Invalid value "${t}" for attribute "${o}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return d(`[${s}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(d(`[${s}] Value ${c} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(d(`[${s}] Value ${c} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(d(`[${s}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(c){return d(`[${s}] Invalid JSON for attribute "${o}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function Ce(e,t,o){for(const i in o){const[a,s,l]=o[i];Object.defineProperty(e,i,{get:function(){return a(t,s,l)},enumerable:!0,configurable:!0})}return e}function Se(e){const t={};for(const o in e){const i=e[o];if(!i||!i.prop)continue;let a=i.read;if(!a&&i.type)switch(i.type){case"enum":a=me(i.values,i.fallback);break;case"integer":a=J;break;case"float":a=ge;break;case"boolean":a=ae;break;case"list":a=se;break;case"json":a=be;break;case"string":default:a=ie;break}a||(a=ie),t[i.prop]=[a,o,i.fallback]}return t}function Ze(e){const t={};for(const o in e){const i=e[o];i&&i.effect&&(t[o]=i.effect)}return Object.keys(t).length?t:null}function Xe(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=Ce,window.lnCore.attrSpec=Se,window.lnCore.attrStr=ie,window.lnCore.attrInt=J,window.lnCore.attrBool=ae,window.lnCore.attrList=se,window.lnCore.attrEnum=me,window.lnCore.attrFloat=ge,window.lnCore.attrJson=be);function ce(e,t,o,i){if(e.nodeType!==1)return;const s=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&l.push(e);for(const d of l)if(!d[o]){window.lnCore._persistSink&&d.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(d,t);try{d[o]=new i(d)}catch(c){console.error("["+o+"] init failed",d,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ye(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function et(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 ve(){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 tt(e){const t=ve(),o=e.observed||[];for(let i=0;i<o.length;i++){const a=o[i];t.byAttr.has(a)||t.byAttr.set(a,[]),t.byAttr.get(a).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const a=t.byDeclaredAttr.get(i);a.some(s=>s.componentTag===e.componentTag)||a.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=Xe(e);if(i===null)t.reactiveWildcard.push(e);else for(const a of i)t.byReactive.has(a)||t.byReactive.set(a,[]),t.byReactive.get(a).push(e)}e.persist&&t.persist.push(e)}function Ae(e,t,o,i){for(let a=0;a<e.length;a++){const s=e[a];if(!t[s.attribute])continue;const l=s.effects&&s.effects[o];l?l(t,o,i):s.onAttrChange&&(!s.declared||s.declared.has(o))&&s.onAttrChange(t,o,i)}}function nt(e){const t=e.target,o=e.attributeName;if(e.oldValue===t.getAttribute(o))return;const i=ve(),a=i.byAttr.get(o);if(fe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(o)&&re(t)){const s=i.byDeclaredAttr.get(o),l=t.getAttribute(o);for(let d=0;d<s.length;d++)_e(s[d].spec,l,o,s[d].componentTag,t)}if(window.lnCore._debugSink&&(o.indexOf("data-ln-")===0||a)&&window.lnCore._debugSink("attr",o,t,{oldValue:e.oldValue,newValue:t.getAttribute(o)}),o.indexOf("data-ln-")===0){const s=i.byReactive.get(o);s&&Ae(s,t,o,e.oldValue),i.reactiveWildcard.length&&Ae(i.reactiveWildcard,t,o,e.oldValue)}if(a)for(let s=0;s<a.length;s++){const l=a[s];if(l.handler){l.handler(t,o,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,o):(ce(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function rt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{nt(t[o])}catch(i){console.error("[ln-core] mutation handler failed",t[o].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function xe(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ot(e){const t=xe();if(t.length){if(e.target)for(let o=0;o<t.length;o++){const i=t[o];if(i.onSubtreeChange){const a=i.query,s=e.target.nodeType===1?e.target.matches(a)?e.target:e.target.closest(a):e.target.parentElement?e.target.parentElement.closest(a):null;s&&i.onSubtreeChange(s,e)}}for(let o=0;o<e.addedNodes.length;o++){const i=e.addedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a];ce(i,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(i)}}for(let o=0;o<e.removedNodes.length;o++){const i=e.removedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a],l=s.query,d=Array.from(i.querySelectorAll(l));i.matches&&i.matches(l)&&d.push(i);for(let c=0;c<d.length;c++){const w=d[c];if(!document.contains(w)){const b=w[s.attribute];if(b&&typeof b.destroy=="function")try{b.destroy()}catch(_){console.error("["+s.attribute+"] destroy failed",w,_)}delete w[s.attribute]}}}}}}function it(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const i=t[o];if(i.type==="childList")try{ot(i)}catch(a){console.error("[ln-core] lifecycle handler failed",i.target,a)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ke(e,t,o,i,a={}){const s=a.extraAttributes||[],l=a.onAttributeChange||null,d=a.onSubtreeChange||null,c=a.onInit||null,w=a.onAttrChange||null,b=a.effects||null,_=a.attributes||null,x=_?Ze(_):b,P=_?new Set(Object.keys(_)):null,F=a.persist||null;function m(k){const I=k||document.body;if(ce(I,e,t,o),_&&fe())for(const j in _){const Z=_[j],G=Array.from(I.querySelectorAll("["+j+"]"));I.matches&&I.matches("["+j+"]")&&G.push(I);for(let K=0;K<G.length;K++){const B=G[K];re(B)&&_e(Z,B.getAttribute(j),j,i,B)}}c&&c(I)}const S=[];if(e.indexOf("[")!==-1){const k=/\[([\w-]+)/g;let I;for(;(I=k.exec(e))!==null;)S.push(I[1])}else S.push(e);tt({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:o,onInit:c,observed:S.concat(s),onAttributeChange:l,onAttrChange:w,effects:x,declared:P,persist:F}),rt();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";xe().push({selector:e,attribute:t,ComponentFn:o,onInit:c,onSubtreeChange:d,query:q}),it(),window[t]=m,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ke);function A(){Ye()>0?et(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A):A(),m}function at(e){let t=!1;for(let o=0;o<e.length;o++){const i=e[o];if(!(i===""||i==null)&&(t=!0,!Number.isFinite(Number(i))))return"string"}return t?"number":"string"}function st(e,t,o,i){if(o==="number"){const l=parseFloat(e),d=parseFloat(t);return(isNaN(l)?0:l)-(isNaN(d)?0:d)}const a=e!=null?String(e):"",s=t!=null?String(t):"";return i?i.compare(a,s):a<s?-1:a>s?1:0}function Ie(e){return(e||"").replace(/^#/,"")}function ue(e){const t=e===void 0?location.hash:e,o={},i=Ie(t);if(!i)return o;const a=i.split("&");for(let s=0;s<a.length;s++){const l=a[s];if(!l)continue;const d=l.indexOf(":"),c=d>-1?l.slice(0,d):l,w=d>-1?l.slice(d+1):"";if(c)try{o[c]=decodeURIComponent(w)}catch{o[c]=w}}return o}function lt(e){if(!e)return null;const t=ue();return e in t?t[e]:null}function ct(e,t){if(!e)return;const o=ue();t==null?delete o[e]:o[e]=String(t);const a=Object.keys(o).map(function(s){const l=o[s];return l===""?s:s+":"+encodeURIComponent(l)}).join("&");Ie(location.hash)!==a&&(location.hash=a)}function ut(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function dt(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function ft(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function ht(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 wt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function yt(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const o=e.slice(0,t),i=e.slice(t+1),a=i?i.split(",").map(function(s){try{return decodeURIComponent(s)}catch{return s}}).filter(Boolean):[];return{key:o,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=ue,window.lnCore.hashGet=lt,window.lnCore.hashSet=ct,window.lnCore.hashLinkClick=ut,window.lnCore.resolveHashNamespace=dt,window.lnCore.hashSortEncode=ft,window.lnCore.hashSortDecode=ht,window.lnCore.hashFilterEncode=wt,window.lnCore.hashFilterDecode=yt);let V=null;const pt="ln-ashlar:storage-salt:v1",Ee=32768;function qe(e){let t="";const o=e.byteLength;for(let i=0;i<o;i+=Ee)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Ee,o)));return btoa(t)}function Ne(e){const t=atob(e),o=t.length,i=new Uint8Array(o);for(let a=0;a<o;a++)i[a]=t.charCodeAt(a);return i}function Le(e,t){let o=V,i={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?o=e:e&&typeof e=="object"&&(i=e,typeof CryptoKey<"u"&&i.key instanceof CryptoKey&&(o=i.key)),{key:o,options:i}}async function mt(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const o=t.method||"pbkdf2",i=new TextEncoder;if(o==="sha256"){const c=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",c,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const a=t.salt||pt,s=typeof a=="string"?i.encode(a):a,l=t.iterations||1e5,d=await crypto.subtle.importKey("raw",i.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:s,iterations:l,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Te(e,t={}){if(!e){V=null;return}try{const o=t.method||"sha256";V=await mt(e,{...t,method:o})}catch(o){throw console.error("[ln-core/crypto] Key derivation failed:",o),V=null,o}}function M(){return V}async function gt(e,t,o){const{key:i}=Le(t);if(e==null)return e;if(!i)throw new Error("[ln-crypto] Encryption failed: No active cryptographic key provided");try{const a=new TextEncoder,s=crypto.getRandomValues(new Uint8Array(12)),l=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,a.encode(l));return{v:1,alg:"AES-GCM",encrypted:!0,iv:qe(s),data:qe(new Uint8Array(d))}}catch(a){throw console.error("[ln-core/crypto] Encryption failed:",a),new Error("[ln-crypto] Encryption failed: "+(a&&a.message?a.message:String(a)))}}async function bt(e,t,o){const{key:i,options:a}=Le(t),s=a.silent===!0;if(!e||!e.encrypted)return e;if(!i){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const l=new TextDecoder,d=Ne(e.iv),c=Ne(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,c),b=l.decode(w);try{return JSON.parse(b)}catch{return b}}catch(l){if(s)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",l),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(l&&l.message?l.message:String(l)))}}function _t(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=_t);function Ct(e){return String(e||"").trim().toLowerCase()}function St(e){const t=Ct(e);return t?t.split(/\s+/).filter(Boolean):[]}function vt(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const o=String(e).toLowerCase();for(let i=0;i<t.length;i++)if(o.indexOf(t[i])===-1)return!1;return!0}function At(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const o=String(e).trim().toLowerCase();for(let i=0;i<t.length;i++)if(String(t[i]).trim().toLowerCase()===o)return!0;return!1}function xt(e={}){let t=e.windowSize>0?e.windowSize:1e3,o=e.pageSize>0?e.pageSize:200,i=e.fetchDebounce!=null?e.fetchDebounce:120;const a=typeof e.requestPage=="function"?e.requestPage:()=>{},s=new Map,l=new Set;let d=0,c=0,w=0,b=!1,_=null;function x(m,S){s.delete(m),s.set(m,S)}function P(){if(s.size<=t)return[];const m=[];for(;s.size>t;){const N=s.keys().next().value;m.push(s.get(N)),s.delete(N)}const S=new Set(s.values());return m.filter(N=>!S.has(N))}function F(m,S){l.add(m),clearTimeout(_),_=setTimeout(()=>a(m,o,S),i)}return{get logicalTotal(){return d},set logicalTotal(m){d=m},get grandTotal(){return c},set grandTotal(m){c=m},get queryGen(){return w},set queryGen(m){w=m},get size(){return s.size},get hasLoaded(){return b},getId:m=>{if(!s.has(m))return;const S=s.get(m);return x(m,S),S},ensure:(m,S,N)=>{if(!b&&!l.has(0))return F(0,N);if(d<=0)return;const q=Math.max(0,m),A=Math.min(d,S);for(let k=q;k<A;k++)if(!s.has(k)){const I=Math.floor(k/o)*o;if(!l.has(I))return F(I,N)}},ingest:(m,S,N,q,A)=>{if(A!=null&&A!==w)return[];b=!0,N!=null&&(c=N),q!=null&&(d=q);for(let k=0;k<S.length;k++)x(m+k,S[k]);return l.delete(m),P()},reset:function(){w++,this.clear()},clear:()=>{b=!1,s.clear(),l.clear(),clearTimeout(_)},configure:(m={})=>{let S=[];return m.windowSize>0&&m.windowSize!==t&&(t=m.windowSize,S=P()),m.pageSize>0&&(o=m.pageSize),m.fetchDebounce>=0&&(i=m.fetchDebounce),S}}}function kt(e,t,o){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:a}=t,s=a==="desc",l=e.map(c=>c?c[i]:void 0),d=at(l);return[...e].sort((c,w)=>{const b=c?c[i]:void 0,_=w?w[i]:void 0,x=st(b,_,d,o);return s?-x:x})}function De(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const o=Object.keys(t).filter(i=>Array.isArray(t[i])&&t[i].length>0);return o.length?e.filter(i=>i?o.every(a=>At(i[a],t[a])):!1):e}function It(e,t,o){if(!Array.isArray(e)||!t||!o||!o.length)return e;const i=St(t);return i.length?e.filter(a=>a?i.every(s=>o.some(l=>{const d=a[l];return d!=null&&vt(String(d),[s])})):!1):e}function Et(e,t,o){if(!Array.isArray(e)||!e.length)return 0;if(o==="count")return e.length;const i=e.map(s=>s&&s[t]!=null?parseFloat(s[t]):NaN).filter(s=>Number.isFinite(s)),a=i.reduce((s,l)=>s+l,0);return o==="sum"?a:o==="avg"&&i.length?a/i.length:0}function qt(e,t={},o=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let s=e;t.filters&&(s=De(s,t.filters)),t.search&&(s=It(s,t.search,o));const l=s.length;if(t.sort&&(s=kt(s,t.sort,i)),t.offset||t.limit){const d=t.offset||0,c=t.limit||s.length;s=s.slice(d,d+c)}return{records:s,total:a,filtered:l}}function Nt(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(o=>{if(!o)return null;const i={...o};for(const[a,s]of Object.entries(t))if(typeof s=="function")try{i[a]=s(o)}catch{i[a]=void 0}return i})}function Lt(e,t,o,i="_meta"){if(!Array.isArray(e)||!e.includes(i))return!0;for(const a of Object.keys(t||{})){if(!e.includes(a))return!0;const s=t[a]&&t[a].indexes||[],l=o&&o[a]||[];if(s.some(d=>!l.includes(d)))return!0}return!1}function Tt(e){return{ok:!1,error:e&&e.message?e.message:String(e)}}(function(){const e="data-ln-data-store",t="lnDataStore";if(window[t]!==void 0)return;function o(n,r,u){const f=n.getAttribute(r);if(f==="never"||f==="-1")return-1;const h=parseInt(f,10);return isNaN(h)?u:h}const i={"data-ln-data-store":{type:"marker",effect:Be,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Be,description:"Comma-separated index field names for the IndexedDB store"},"data-ln-data-store-stale":{prop:"_staleThreshold",type:"integer",read:o,fallback:300,description:"Cache staleness threshold in seconds, or -1/never"},"data-ln-data-store-search-fields":{prop:"_searchFields",type:"list",read:se,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:ae,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:J,fallback:1e3,min:10,effect:Xt,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:J,fallback:200,min:5,effect:Yt,description:"Virtual scrolling slice page size"},"data-ln-data-store-frozen":{type:"marker",description:"Applied at runtime to indicate store schema is locked in IndexedDB"}},a=Se(i),s="ln_app_cache",l="_meta",d="1.0";let c=null,w=null;const b={};function _(n){n&&n.name==="QuotaExceededError"&&v(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const r of document.querySelectorAll(`[${e}]`)){const u=r.id;if(u){const f=r.getAttribute("data-ln-data-store-indexes")||"";n[u]={indexes:f.split(",").map(h=>h.trim()).filter(Boolean)}}}return n}function P(){return w||(w=new Promise(n=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB is not available in this environment"),n(null);const r=x(),u=Object.keys(r),f=indexedDB.open(s);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),g=u.filter(T=>p.includes(T));let C={};if(g.length>0){const T=y.transaction(g,"readonly");for(const D of g)C[D]=Array.from(T.objectStore(D).indexNames)}if(!Lt(p,r,C,l))return F(y),c=y,n(y);const $=y.version;y.close();const R=indexedDB.open(s,$+1);let z=!1,O=null;R.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:s}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},R.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},R.onupgradeneeded=T=>{const D=T.target.result,en=T.target.transaction;D.objectStoreNames.contains(l)||D.createObjectStore(l,{keyPath:"key"});for(const W of u)if(D.objectStoreNames.contains(W)){const ne=en.objectStore(W);for(const U of r[W].indexes)ne.indexNames.contains(U)||ne.createIndex(U,U,{unique:!1})}else{const ne=D.createObjectStore(W,{keyPath:"id"});for(const U of r[W].indexes)ne.createIndex(U,U,{unique:!1})}},R.onsuccess=T=>{if(z){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),z=!0;const D=T.target.result;F(D),c=D,n(D)}}}),w)}function F(n){n.onversionchange=()=>{n.close(),c=null,w=null}}function m(){return c?Promise.resolve(c):(w=null,P())}async function S(n){if(!M()||!n)return n;const r={...n},u=r.id,f=await gt(r);return!f||!f.encrypted?n:{...f,id:u}}async function N(n){return!n||!n.encrypted||!M()?n:bt(n,{silent:!0})}const q=(n,r)=>m().then(u=>u?u.transaction(n,r).objectStore(n):null);function A(n){return new Promise((r,u)=>{n.onsuccess=()=>r(n.result),n.onerror=()=>{_(n.error),u(n.error)}})}const k=n=>q(n,"readonly").then(r=>r?A(r.getAll()):[]).then(r=>M()?Promise.all(r.map(u=>N(u))):r),I=(n,r)=>q(n,"readonly").then(u=>u?A(u.get(r)).then(f=>f!==void 0?f:typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r))?A(u.get(Number(r))):typeof r=="number"?A(u.get(String(r))):null):null).then(u=>u?N(u):null),j=(n,r)=>m().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=r.map(p=>A(h.get(p)).then(g=>g!==void 0?g:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?A(h.get(Number(p))):typeof p=="number"?A(h.get(String(p))):null));return Promise.all(y).then(p=>M()?Promise.all(p.map(g=>g?N(g):null)):p)}),Z=(n,r)=>(M()?S(r):Promise.resolve(r)).then(f=>q(n,"readwrite").then(h=>h?A(h.put(f)):null)),G=(n,r)=>q(n,"readwrite").then(u=>u?A(u.delete(r)).then(()=>{if(typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r)))return A(u.delete(Number(r)));if(typeof r=="number")return A(u.delete(String(r)))}):null),K=n=>q(n,"readwrite").then(r=>r?A(r.clear()):null),B=n=>q(n,"readonly").then(r=>r?A(r.count()):0),Dt=n=>q(l,"readonly").then(r=>r?A(r.get(n)):null),X=(n,r)=>q(l,"readwrite").then(u=>{if(u)return r.key=n,A(u.put(r))});function L(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),Ce(this,n,a),this._handlers=null,this.isLoaded=!1,this.canServe=!1,this.isInitialized=!1,this.initializationError=null,this.hasCache=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.query={filters:{},search:"",sort:null},n.hasAttribute("data-ln-data-store-window")?this._windowIndex=xt({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(r,u,f)=>{v(this.dom,"ln-data-store:request-page",{store:this._name,offset:r,limit:u,query:f,queryGen:this._windowIndex.queryGen})}}):this._windowIndex=null,this.windowed=this._windowIndex!==null,this.totalCount=0,this.presenters=null,this._mutationChain=Promise.resolve(),b[this._name]=this,zt(this),this.ready=Ft(this),this}function zt(n){n._handlers={create:r=>Y(n,"create",r.detail,()=>Ot(n,r.detail)),update:r=>Y(n,"update",r.detail,()=>Rt(n,r.detail)),delete:r=>Y(n,"delete",r.detail,()=>Mt(n,r.detail)),"bulk-delete":r=>Y(n,"bulk-delete",r.detail,()=>Bt(n,r.detail)),"sync-failed":r=>{n.isSyncing=!1,v(n.dom,"ln-data-store:sync-error",{store:n._name,error:r.detail&&r.detail.error,status:r.detail&&r.detail.status})}};for(const[r,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${r}`,u);n._queryHandlers={"ln-search:change":r=>{r.preventDefault();const u=r.detail&&r.detail.term!=null?r.detail.term:"";u!==n.query.search&&(n.query.search=u,de(n))},"ln-filter:change":r=>{r.preventDefault();const u=r.detail&&r.detail.key;if(!u)return;const f=(r.detail.values||[]).slice(),h=n.query.filters[u];(h?h.length===f.length&&h.every((p,g)=>p===f[g]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],de(n))},"ln-sort:change":r=>{r.preventDefault();const u=r.detail&&r.detail.field,f=r.detail&&r.detail.direction,h=f&&f!=="none"?{field:u,direction:f}:null,y=n.query.sort;!y&&!h||y&&h&&y.field===h.field&&y.direction===h.direction||(n.query.sort=h,de(n))}};for(const[r,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(r,u)}function Y(n,r,u,f){const h=u&&u.requestId;return n._mutationChain=n._mutationChain.then(()=>n.ready).then(()=>{if(n.initializationError)throw n.initializationError;return f()}).catch(y=>Pt(n,r,h,y)),n._mutationChain}function ee(n,r=0){return B(n._name).then(u=>{if(n._windowIndex||n.windowed){const f=n.totalCount!=null?n.totalCount:u;n.totalCount=Math.max(0,f+r)}else n.totalCount=u;return n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,X(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Ot(n,{tempId:r,data:u={},requestId:f}={}){const h={...u,id:r};return Z(n._name,h).then(()=>ee(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:r,requestId:f})})}function Rt(n,{id:r,data:u={},requestId:f}={}){return I(n._name,r).then(h=>{if(!h)throw new Error(`Record not found: ${r}`);const y=h.id,p={...h,...u,id:y},g=u.id,C=g!==void 0&&g!==y;return(C?jt(n._name,y,{...p,id:g}):Z(n._name,p)).then(()=>ee(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:g}:p,previous:h,requestId:f})})})}function Mt(n,{id:r,requestId:u}={}){return I(n._name,r).then(f=>{if(!f){v(n.dom,"ln-data-store:deleted",{store:n._name,id:r,requestId:u,missing:!0});return}const h=f.id;return G(n._name,h).then(()=>ee(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Bt(n,{ids:r=[],requestId:u}={}){return r.length?Promise.all(r.map(f=>I(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return te(n._name,h).then(()=>ee(n,-h.length)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(v(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function Pt(n,r,u,f){console.error("[ln-data-store] "+r+" failed:",f),v(n.dom,"ln-data-store:mutation-error",{store:n._name,action:r,requestId:u,error:f})}function Ft(n){return P().then(r=>{if(!r)throw new Error("IndexedDB is unavailable");return Dt(n._name)}).then(r=>{if(n.initializationError=null,r&&r.schema_version===d)n.lastSyncedAt=r.last_synced_at||null,n.totalCount=r.record_count||0,n.hasCache=r.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,v(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(r&&r.schema_version!==d)return K(n._name).then(()=>X(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(r=>(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=r,v(n.dom,"ln-data-store:initialization-error",{store:n._name,error:r}),{ok:!1,error:r}))}function ze(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function Oe(n,r){return m().then(u=>u?(M()?Promise.all(r.map(h=>S(h))):Promise.resolve(r)).then(h=>new Promise((y,p)=>{const g=u.transaction(n,"readwrite"),C=g.objectStore(n);h.forEach(E=>C.put(E)),g.oncomplete=()=>y(),g.onerror=()=>{_(g.error),p(g.error)}})):void 0)}function te(n,r){return m().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);r.forEach(g=>{p.delete(g),typeof g=="string"&&g.trim()!==""&&!isNaN(Number(g))?p.delete(Number(g)):typeof g=="number"&&p.delete(String(g))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function jt(n,r,u){return(M()?S(u):Promise.resolve(u)).then(h=>m().then(y=>{if(y)return new Promise((p,g)=>{const C=y.transaction(n,"readwrite"),E=C.objectStore(n);E.put(h),E.delete(r),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),g(C.error)}})}))}const $t=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Kt(n){return n?Object.keys(n).filter(r=>Array.isArray(n[r])&&n[r].length>0):[]}function Ut(n,r,u){return r.every(f=>u[f].map(String).includes(String(n[f])))}function Vt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Gt(n,r,u){return r.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Ht(n,r,u){return Et(n,r,u)}function H(n,r){return Nt(r,n.presenters&&n.presenters.computed)}function Wt(n){return!n.sort&&!M()}function Qt(n,r,u){const f=Kt(r.filters),h=r.search?Vt(r.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return q(n._name,"readonly").then(g=>g?new Promise((C,E)=>{const $=[],R=g.openCursor();R.onsuccess=()=>{const z=R.result;if(!z||$.length>=u){C($);return}const O=z.value;(!f.length||Ut(O,f,r.filters))&&(!p||Gt(O,h,y))&&$.push(O),z.continue()},R.onerror=()=>E(R.error)}):[])}function Re(n,r,u){return qt(r,u,n._searchFields,$t)}function Me(n,r,u){const f=[];for(let y=r;y<r+u;y++){const p=n._windowIndex.getId(y);f.push(p)}const h=Array.from(new Set(f.filter(y=>y!==void 0)));return j(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const E=y[C];E&&p.set(String(E.id),E)}const g=[];for(let C=0;C<f.length;C++){const E=f[C];if(E===void 0)g.push(null);else{const $=p.get(String(E));g.push($||null)}}return{data:H(n,g),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:r,queryGen:n._windowIndex.queryGen}})}L.prototype.getAll=function(n={}){const r=this;if(r._windowIndex){const u=n.offset||0,f=n.limit||200;if(r._windowIndex.ensure(u,u+f,n),!r._windowIndex.hasLoaded&&!r.noLocalQuery){const h=u+f,y=p=>p.length?{data:H(r,p),offset:u,queryGen:r._windowIndex.queryGen,provisional:!0}:Me(r,u,f);return Wt(n)?Qt(r,n,h).then(p=>y(p.slice(u,h))):k(r._name).then(p=>y(Re(r,p,n).records))}return Me(r,u,f)}return k(r._name).then(u=>{const f=Re(r,u,n);return{data:H(r,f.records),total:f.total,filtered:f.filtered}})},L.prototype.getById=function(n){return I(this._name,n).then(r=>r?H(this,[r])[0]:null)},L.prototype.count=function(n){return n&&Object.keys(n).length>0?k(this._name).then(u=>De(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):B(this._name)},L.prototype.aggregate=function(n,r){return k(this._name).then(u=>Ht(u,n,r))},L.prototype.setPresenters=function(n){this.presenters=n},L.prototype.applySync=function(n,r,u,f){f=f||{};const h=this;if(h._windowIndex&&f.queryGen!=null&&f.queryGen!==h._windowIndex.queryGen)return Promise.resolve({ok:!0,stale:!0});let y=m().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>Oe(h._name,n))),r.length>0&&(y=y.then(()=>te(h._name,r))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,g=n.map(E=>E.id),C=h._windowIndex.ingest(p,g,f.total,f.filtered,f.queryGen);if(C&&C.length)return te(h._name,C)}}).then(()=>B(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,X(h._name,{schema_version:d,last_synced_at:u,has_cache:!0,record_count:h.totalCount}))).then(()=>{const p=!h.isLoaded;return h.isLoaded=!0,h.canServe=!0,h.isSyncing=!1,h.lastSyncedAt=u,p?(v(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),v(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):v(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:r.length,changed:!0,meta:f}),{ok:!0}}).catch(p=>{h.isSyncing=!1;const g=p&&p.message?p.message:String(p);return console.error("[ln-data-store] applySync failed:",p),v(h.dom,"ln-data-store:sync-error",{store:h._name,error:g}),Tt(p)})},L.prototype.applyQuery=function(n,r){r=r||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>Oe(u._name,n))),f.then(()=>B(u._name)).then(h=>(u.totalCount=r.total!==void 0?r.total:h,n.length>0&&(u.canServe=!0),H(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},L.prototype.forceSync=function(){this.isSyncing||ze(this)},L.prototype.fullReload=function(){const n=this;return K(n._name).then(()=>X(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isLoaded=!1,n.hasCache=!1,n.lastSyncedAt=null,n.totalCount=0,ze(n)})},L.prototype.destroy=function(){if(this._windowIndex&&(this._windowIndex.clear(),this._windowIndex=null,this.windowed=!1),this._handlers){for(const[n,r]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,r);this._handlers=null}if(this._queryHandlers){for(const[n,r]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,r);this._queryHandlers=null}delete b[this._name],delete this.dom[t]};function Jt(){return m().then(n=>{if(!n)return;const r=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(r,"readwrite");r.forEach(y=>h.objectStore(y).clear()),h.oncomplete=()=>u(),h.onerror=()=>f(h.error)})}).then(()=>{Object.values(b).forEach(n=>{n.isLoaded=!1,n.canServe=!1,n.isInitialized=!1,n.initializationError=null,n.hasCache=!1,n.isSyncing=!1,n.lastSyncedAt=null,n.totalCount=0})})}function de(n){n._windowIndex&&n._windowIndex.reset(),v(n.dom,"ln-data-store:query-changed",{store:n._name,query:{filters:Object.assign({},n.query.filters),search:n.query.search,sort:n.query.sort?Object.assign({},n.query.sort):null}})}const Zt="data-ln-data-store-frozen";function Be(n,r){n.setAttribute(Zt,r)}function Xt(n){const r=n[t];if(!r._windowIndex)return;const u=r._windowIndex.configure({windowSize:r._windowSize});u.length&&te(r._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function Yt(n){const r=n[t];r._windowIndex&&r._windowIndex.configure({pageSize:r._windowPageSize})}ke(e,t,L,"ln-data-store",{attributes:i}),window[t].clearAll=Jt,window[t].init=window[t],window[t].setStorageKey=Te,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Te)})()})();
1
+ (function(){"use strict";function we(){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 oe(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 s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){r=t[s];break}if(!oe(r))return}e.apply(console,t)}}function v(e,t,i){const r=i||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function J(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){J(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function $e(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Ke(e,t){const i=!!(t&&t.typed),r=t&&t.exclude,s={},c=e.elements,a={};if(i)for(let d=0;d<c.length;d++){const l=c[d];l.name&&l.type==="checkbox"&&!l.disabled&&(a[l.name]=(a[l.name]||0)+1)}for(let d=0;d<c.length;d++){const l=c[d];if(!(!l.name||l.disabled||l.type==="file"||l.type==="submit"||l.type==="button")&&!(r&&l.matches&&l.matches(r)))if(l.type==="checkbox")i&&a[l.name]===1?s[l.name]=l.checked:(s[l.name]||(s[l.name]=[]),l.checked&&s[l.name].push(l.value));else if(l.type==="radio")l.checked&&(s[l.name]=l.value);else if(l.type==="select-multiple"){s[l.name]=[];for(let w=0;w<l.options.length;w++)l.options[w].selected&&s[l.name].push(l.options[w].value)}else if(i&&l.type==="hidden")s[l.name]=l.value;else if(i&&(l.type==="number"||l.type==="range")){const w=Number(l.value);s[l.name]=l.value===""||isNaN(w)?null:w}else s[l.name]=l.value}return s}function Ue(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function Ve(e,t){const i=e.elements,r=[],s={};for(let c=0;c<i.length;c++){const a=i[c];a.name&&a.type==="checkbox"&&(s[a.name]=(s[a.name]||0)+1)}for(let c=0;c<i.length;c++){const a=i[c];if(a.type==="file"||a.type==="submit"||a.type==="button")continue;const d=a.getAttribute("data-ln-fill-as")||a.name;if(!d||!(d in t))continue;const l=t[d];if(a.type==="checkbox"){if(Array.isArray(l))a.checked=l.indexOf(a.value)!==-1;else if(s[a.name]>1){const w=String(l).split(",").map(function(b){return b.trim()});a.checked=w.indexOf(a.value)!==-1}else a.checked=Ue(l);r.push(a)}else if(a.type==="radio")a.checked=a.value===String(l),r.push(a);else if(a.type==="select-multiple"){if(Array.isArray(l))for(let w=0;w<a.options.length;w++)a.options[w].selected=l.indexOf(a.options[w].value)!==-1;r.push(a)}else a.value=l,a.tagName==="SELECT"&&l!=null&&a.setAttribute("data-ln-value",l),r.push(a)}return r}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=Ve,window.lnCore.serializeForm=Ke,window.lnCore.resolveFormMethod=$e);const ye={};function Ge(e,t){ye[e]=t}function He(e){return ye[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=Ge,window.lnCore.getDataMapper=He);function We(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,J(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const pe={};function Qe(e,t){if(!e||typeof t!="object")return;const i=e.toLowerCase().split("-")[0];pe[i]=t}function Je(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return pe[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Qe,window.lnCore.getLocaleFallback=Je,window.lnCore.ensureLocaleObserver=We);const ie={};function Ze(e,t){ie[e]||(ie[e]=document.querySelector('[data-ln-template="'+e+'"]'));const i=ie[e];return i?i.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function me(e,t){if(!e||!t)return e;const i=e.querySelectorAll("[data-ln-field]");for(let a=0;a<i.length;a++){const d=i[a],l=d.getAttribute("data-ln-field");t[l]!=null&&(d.textContent=t[l])}const r=e.querySelectorAll("[data-ln-attr]");for(let a=0;a<r.length;a++){const d=r[a],l=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<l.length;w++){const b=l[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();t[x]!=null&&d.setAttribute(_,t[x])}}const s=e.querySelectorAll("[data-ln-show]");for(let a=0;a<s.length;a++){const d=s[a],l=d.getAttribute("data-ln-show");l in t&&d.classList.toggle("hidden",!t[l])}const c=e.querySelectorAll("[data-ln-class]");for(let a=0;a<c.length;a++){const d=c[a],l=d.getAttribute("data-ln-class").split(",");for(let w=0;w<l.length;w++){const b=l[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();x in t&&d.classList.toggle(_,!!t[x])}}return e}function Xe(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 i=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<i.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",i[r],t??null),i[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)me(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let i=0;i<t.length;i++)t[i].textContent=""}})));function ge(e,t){if(!e||!t)return e;const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;i.nextNode();){const c=i.currentNode;c.textContent.indexOf("{{")!==-1&&(c.textContent=c.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(a,d){return t[d]!==void 0?t[d]:""}))}const r=function(c,a){return t[a]!==void 0?t[a]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let c=0;c<s.length;c++){const a=s[c],d=a.attributes;for(let l=0;l<d.length;l++){const w=d[l];w.value.indexOf("{{")!==-1&&a.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function Ye(e,t,i,r,s,c){const a={};for(let l=0;l<e.children.length;l++){const w=e.children[l],b=w.getAttribute("data-ln-render-key");b&&(a[b]=w)}const d=document.createDocumentFragment();for(let l=0;l<t.length;l++){const w=t[l],b=String(r(w));let _=a[b];if(_)s(_,w,l);else{const x=Ze(i,c);if(!x||(ge(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),s(_,w,l)}d.appendChild(_)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=ge,window.lnCore.fill=me,window.lnCore.lnFill=Xe,window.lnCore.renderList=Ye);function ae(e,t,i){const r=e.getAttribute(t);return r===null?i:r}function Z(e,t,i){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?i:r}function se(e,t,i=!1){const r=e.getAttribute(t);if(r===null)return!!i;const s=r.trim().toLowerCase();return!(s==="false"||s==="0")}function le(e,t){return(e.getAttribute(t)||"").split(",").map(i=>i.trim()).filter(Boolean)}const ce=new Map;function be(e,t){const i=(e?e.join("|"):"")+"::"+t;if(ce.has(i))return ce.get(i);const r=new Set(e||[]),s=function(c,a){const d=c.getAttribute(a);return d!==null&&r.has(d)?d:t};return ce.set(i,s),s}function _e(e,t,i){const r=parseFloat(e.getAttribute(t));return isNaN(r)?i:r}function Ce(e,t,i){const r=e.getAttribute(t);if(!r)return i;try{return JSON.parse(r)}catch{return i}}function Se(e,t,i,r,s){if(!e||t===null)return!0;const c=r||"ln-component",a=e.type;if(a==="trigger"||a==="marker"||a==="string"||a==="list"||!a||t===""&&e.fallback!==void 0)return!0;const d=l=>{s?console.warn(l,s):console.warn(l)};if(a==="boolean"){const l=t.trim().toLowerCase();return l!==""&&l!=="true"&&l!=="false"&&l!=="1"&&l!=="0"?(d(`[${c}] Invalid value "${t}" for boolean attribute "${i}". Allowed: "true", "false", or presence-only.`),!1):!0}if(a==="enum"){const l=e.values||[];return l.includes(t)?!0:(d(`[${c}] Invalid value "${t}" for attribute "${i}". Allowed: ${l.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(a==="integer"){if(!/^-?\d+$/.test(t))return d(`[${c}] Invalid integer "${t}" for attribute "${i}". Fallback: ${e.fallback}.`),!1;const l=parseInt(t,10);return e.min!==void 0&&l<e.min?(d(`[${c}] Value ${l} for attribute "${i}" is less than min (${e.min}).`),!1):e.max!==void 0&&l>e.max?(d(`[${c}] Value ${l} for attribute "${i}" is greater than max (${e.max}).`),!1):!0}if(a==="float")return isNaN(Number(t))?(d(`[${c}] Invalid float "${t}" for attribute "${i}". Fallback: ${e.fallback}.`),!1):!0;if(a==="json")try{return JSON.parse(t),!0}catch(l){return d(`[${c}] Invalid JSON for attribute "${i}": ${l.message}. Fallback: ${e.fallback}.`),!1}return!0}function ve(e,t,i){for(const r in i){const[s,c,a]=i[r];Object.defineProperty(e,r,{get:function(){return s(t,c,a)},enumerable:!0,configurable:!0})}return e}function Ae(e){const t={};for(const i in e){const r=e[i];if(!r||!r.prop)continue;let s=r.read;if(!s&&r.type)switch(r.type){case"enum":s=be(r.values,r.fallback);break;case"integer":s=Z;break;case"float":s=_e;break;case"boolean":s=se;break;case"list":s=le;break;case"json":s=Ce;break;case"string":default:s=ae;break}s||(s=ae),t[r.prop]=[s,i,r.fallback]}return t}function et(e){const t={};for(const i in e){const r=e[i];r&&r.effect&&(t[i]=r.effect)}return Object.keys(t).length?t:null}function tt(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const i in e.effects)t.add(i);if(e.onAttrChange&&e.declared)for(const i of e.declared)t.add(i);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=ve,window.lnCore.attrSpec=Ae,window.lnCore.attrStr=ae,window.lnCore.attrInt=Z,window.lnCore.attrBool=se,window.lnCore.attrList=le,window.lnCore.attrEnum=be,window.lnCore.attrFloat=_e,window.lnCore.attrJson=Ce);function V(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(i){console.error("["+t.attribute+"] init failed",e,i)}}}function xe(e,t,i,r){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",a={selector:t,attribute:i,ComponentFn:r};if(e.matches&&e.matches(c)&&V(e,a),e.querySelectorAll){const d=e.querySelectorAll(c);for(let l=0;l<d.length;l++)V(d[l],a)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function nt(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function rt(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 ke(){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 ot(e){const t=ke(),i=e.observed||[];for(let r=0;r<i.length;r++){const s=i[r];t.byAttr.has(s)||t.byAttr.set(s,[]),t.byAttr.get(s).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 s=t.byDeclaredAttr.get(r);s.some(c=>c.componentTag===e.componentTag)||s.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=tt(e);if(r===null)t.reactiveWildcard.push(e);else for(const s of r)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function Ie(e,t,i,r){for(let s=0;s<e.length;s++){const c=e[s];if(!t[c.attribute])continue;const a=c.effects&&c.effects[i];a?a(t,i,r):c.onAttrChange&&(!c.declared||c.declared.has(i))&&c.onAttrChange(t,i,r)}}function it(e){const t=e.attributeName,i=t.indexOf("data-ln-")===0,r=ke(),s=r.byAttr.get(t),c=we()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(t);if(!i&&!s&&!c)return;const a=e.target;if(e.oldValue!==a.getAttribute(t)){if(c&&oe(a)){const d=r.byDeclaredAttr.get(t),l=a.getAttribute(t);for(let w=0;w<d.length;w++)Se(d[w].spec,l,t,d[w].componentTag,a)}if(window.lnCore._debugSink&&(i||s)&&window.lnCore._debugSink("attr",t,a,{oldValue:e.oldValue,newValue:a.getAttribute(t)}),i){const d=r.byReactive.get(t);d&&Ie(d,a,t,e.oldValue),r.reactiveWildcard.length&&Ie(r.reactiveWildcard,a,t,e.oldValue)}if(s)for(let d=0;d<s.length;d++){const l=s[d];if(l.handler){l.handler(a,t,e.oldValue);continue}l.onAttributeChange&&a[l.attribute]?l.onAttributeChange(a,t):(xe(a,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(a))}}}function at(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,J(function(){new MutationObserver(function(t){for(let i=0;i<t.length;i++)try{it(t[i])}catch(r){console.error("[ln-core] mutation handler failed",t[i].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ue(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function de(e,t){if(!document.contains(e))if(t.attribute){const i=e[t.attribute];if(i&&typeof i.destroy=="function")try{i.destroy()}catch(r){console.error("["+t.attribute+"] destroy failed",e,r)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function st(e){const t=ue();if(t.length){if(e.target)for(let i=0;i<t.length;i++){const r=t[i];if(r.onSubtreeChange&&r.query){const s=r.query,c=e.target.nodeType===1?e.target.matches&&e.target.matches(s)?e.target:e.target.closest?e.target.closest(s):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(s):null;c&&r.onSubtreeChange(c,e)}}for(let i=0;i<e.addedNodes.length;i++){const r=e.addedNodes[i];if(r.nodeType===1){const s=!!(r.firstElementChild||r.children&&r.children.length);for(let c=0;c<t.length;c++){const a=t[c];if(a.selector&&a.attribute&&a.ComponentFn){if(!s)r.matches&&r.matches(a.query)&&V(r,a);else if(r.matches&&r.matches(a.query)&&V(r,a),r.querySelectorAll){const d=r.querySelectorAll(a.query);for(let l=0;l<d.length;l++)V(d[l],a)}}a.onInit&&a.onInit(r)}}}for(let i=0;i<e.removedNodes.length;i++){const r=e.removedNodes[i];if(r.nodeType===1){const s=!!(r.firstElementChild||r.children&&r.children.length);for(let c=0;c<t.length;c++){const a=t[c],d=a.query;if(d){if(!s)r.matches&&r.matches(d)&&de(r,a);else if(r.matches&&r.matches(d)&&de(r,a),r.querySelectorAll){const l=r.querySelectorAll(d);for(let w=0;w<l.length;w++)de(l[w],a)}}}}}}}function Ee(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,J(function(){new MutationObserver(function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.type==="childList")try{st(r)}catch(s){console.error("[ln-core] lifecycle handler failed",r.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function lt(e){ue().push(e),Ee()}function qe(e,t,i,r,s={}){const c=s.extraAttributes||[],a=s.onAttributeChange||null,d=s.onSubtreeChange||null,l=s.onInit||null,w=s.onAttrChange||null,b=s.effects||null,_=s.attributes||null,x=_?et(_):b,F=_?new Set(Object.keys(_)):null,P=s.persist||null;function m(k){const I=k||document.body;if(xe(I,e,t,i),_&&we())for(const j in _){const X=_[j],H=Array.from(I.querySelectorAll("["+j+"]"));I.matches&&I.matches("["+j+"]")&&H.push(I);for(let K=0;K<H.length;K++){const B=H[K];oe(B)&&Se(X,B.getAttribute(j),j,r,B)}}l&&l(I)}const S=[];if(e.indexOf("[")!==-1){const k=/\[([\w-]+)/g;let I;for(;(I=k.exec(e))!==null;)S.push(I[1])}else S.push(e);ot({selector:e,attribute:t,componentTag:r,attributes:_,ComponentFn:i,onInit:l,observed:S.concat(c),onAttributeChange:a,onAttrChange:w,effects:x,declared:F,persist:P}),at();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,D=s.subtreeQuery||(q?e:"["+e+"]");ue().push({selector:e,attribute:t,ComponentFn:i,onInit:l,onSubtreeChange:d,query:D}),Ee(),window[t]=m,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=qe,window.lnCore.observeLifecycle=lt);function A(){nt()>0?rt(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A):A(),m}function ct(e){let t=!1;for(let i=0;i<e.length;i++){const r=e[i];if(!(r===""||r==null)&&(t=!0,!Number.isFinite(Number(r))))return"string"}return t?"number":"string"}function ut(e,t,i,r){if(i==="number"){const a=parseFloat(e),d=parseFloat(t);return(isNaN(a)?0:a)-(isNaN(d)?0:d)}const s=e!=null?String(e):"",c=t!=null?String(t):"";return r?r.compare(s,c):s<c?-1:s>c?1:0}function De(e){return(e||"").replace(/^#/,"")}function fe(e){const t=e===void 0?location.hash:e,i={},r=De(t);if(!r)return i;const s=r.split("&");for(let c=0;c<s.length;c++){const a=s[c];if(!a)continue;const d=a.indexOf(":"),l=d>-1?a.slice(0,d):a,w=d>-1?a.slice(d+1):"";if(l)try{i[l]=decodeURIComponent(w)}catch{i[l]=w}}return i}function dt(e){if(!e)return null;const t=fe();return e in t?t[e]:null}function ft(e,t){if(!e)return;const i=fe();t==null?delete i[e]:i[e]=String(t);const s=Object.keys(i).map(function(c){const a=i[c];return a===""?c:c+":"+encodeURIComponent(a)}).join("&");De(location.hash)!==s&&(location.hash=s)}function ht(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function wt(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const i=e.getAttribute("data-ln-hash");if(i&&i.trim()!=="")return i.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 yt(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function pt(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 mt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function gt(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const i=e.slice(0,t),r=e.slice(t+1),s=r?r.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:i,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=fe,window.lnCore.hashGet=dt,window.lnCore.hashSet=ft,window.lnCore.hashLinkClick=ht,window.lnCore.resolveHashNamespace=wt,window.lnCore.hashSortEncode=yt,window.lnCore.hashSortDecode=pt,window.lnCore.hashFilterEncode=mt,window.lnCore.hashFilterDecode=gt);let G=null;const bt="ln-ashlar:storage-salt:v1",Le=32768;function Ne(e){let t="";const i=e.byteLength;for(let r=0;r<i;r+=Le)t+=String.fromCharCode.apply(null,e.subarray(r,Math.min(r+Le,i)));return btoa(t)}function Te(e){const t=atob(e),i=t.length,r=new Uint8Array(i);for(let s=0;s<i;s++)r[s]=t.charCodeAt(s);return r}function ze(e,t){let i=G,r={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?i=e:e&&typeof e=="object"&&(r=e,typeof CryptoKey<"u"&&r.key instanceof CryptoKey&&(i=r.key)),{key:i,options:r}}async function _t(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const i=t.method||"pbkdf2",r=new TextEncoder;if(i==="sha256"){const l=await crypto.subtle.digest("SHA-256",r.encode(e));return crypto.subtle.importKey("raw",l,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const s=t.salt||bt,c=typeof s=="string"?r.encode(s):s,a=t.iterations||1e5,d=await crypto.subtle.importKey("raw",r.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:c,iterations:a,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Oe(e,t={}){if(!e){G=null;return}try{const i=t.method||"sha256";G=await _t(e,{...t,method:i})}catch(i){throw console.error("[ln-core/crypto] Key derivation failed:",i),G=null,i}}function M(){return G}async function Ct(e,t,i){const{key:r}=ze(t);if(e==null)return e;if(!r)throw new Error("[ln-crypto] Encryption failed: No active cryptographic key provided");try{const s=new TextEncoder,c=crypto.getRandomValues(new Uint8Array(12)),a=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:c},r,s.encode(a));return{v:1,alg:"AES-GCM",encrypted:!0,iv:Ne(c),data:Ne(new Uint8Array(d))}}catch(s){throw console.error("[ln-core/crypto] Encryption failed:",s),new Error("[ln-crypto] Encryption failed: "+(s&&s.message?s.message:String(s)))}}async function St(e,t,i){const{key:r,options:s}=ze(t),c=s.silent===!0;if(!e||!e.encrypted)return e;if(!r){if(c)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(c)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const a=new TextDecoder,d=Te(e.iv),l=Te(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},r,l),b=a.decode(w);try{return JSON.parse(b)}catch{return b}}catch(a){if(c)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",a),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(a&&a.message?a.message:String(a)))}}function vt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=vt);function At(e){return String(e||"").trim().toLowerCase()}function xt(e){const t=At(e);return t?t.split(/\s+/).filter(Boolean):[]}function kt(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const i=String(e).toLowerCase();for(let r=0;r<t.length;r++)if(i.indexOf(t[r])===-1)return!1;return!0}function It(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const i=String(e).trim().toLowerCase();for(let r=0;r<t.length;r++)if(String(t[r]).trim().toLowerCase()===i)return!0;return!1}function Et(e={}){let t=e.windowSize>0?e.windowSize:1e3,i=e.pageSize>0?e.pageSize:200,r=e.fetchDebounce!=null?e.fetchDebounce:120;const s=typeof e.requestPage=="function"?e.requestPage:()=>{},c=new Map,a=new Set;let d=0,l=0,w=0,b=!1,_=null;function x(m,S){c.delete(m),c.set(m,S)}function F(){if(c.size<=t)return[];const m=[];for(;c.size>t;){const q=c.keys().next().value;m.push(c.get(q)),c.delete(q)}const S=new Set(c.values());return m.filter(q=>!S.has(q))}function P(m,S){a.add(m),clearTimeout(_),_=setTimeout(()=>s(m,i,S),r)}return{get logicalTotal(){return d},set logicalTotal(m){d=m},get grandTotal(){return l},set grandTotal(m){l=m},get queryGen(){return w},set queryGen(m){w=m},get size(){return c.size},get hasLoaded(){return b},getId:m=>{if(!c.has(m))return;const S=c.get(m);return x(m,S),S},ensure:(m,S,q)=>{if(!b&&!a.has(0))return P(0,q);if(d<=0)return;const D=Math.max(0,m),A=Math.min(d,S);for(let k=D;k<A;k++)if(!c.has(k)){const I=Math.floor(k/i)*i;if(!a.has(I))return P(I,q)}},ingest:(m,S,q,D,A)=>{if(A!=null&&A!==w)return[];b=!0,q!=null&&(l=q),D!=null&&(d=D);for(let k=0;k<S.length;k++)x(m+k,S[k]);return a.delete(m),F()},reset:function(){w++,this.clear()},clear:()=>{b=!1,c.clear(),a.clear(),clearTimeout(_)},configure:(m={})=>{let S=[];return m.windowSize>0&&m.windowSize!==t&&(t=m.windowSize,S=F()),m.pageSize>0&&(i=m.pageSize),m.fetchDebounce>=0&&(r=m.fetchDebounce),S}}}function qt(e,t,i){if(!Array.isArray(e)||!t||!t.field)return e;const{field:r,direction:s}=t,c=s==="desc",a=e.map(l=>l?l[r]:void 0),d=ct(a);return[...e].sort((l,w)=>{const b=l?l[r]:void 0,_=w?w[r]:void 0,x=ut(b,_,d,i);return c?-x:x})}function Re(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const i=Object.keys(t).filter(r=>Array.isArray(t[r])&&t[r].length>0);return i.length?e.filter(r=>r?i.every(s=>It(r[s],t[s])):!1):e}function Dt(e,t,i){if(!Array.isArray(e)||!t||!i||!i.length)return e;const r=xt(t);return r.length?e.filter(s=>s?r.every(c=>i.some(a=>{const d=s[a];return d!=null&&kt(String(d),[c])})):!1):e}function Lt(e,t,i){if(!Array.isArray(e)||!e.length)return 0;if(i==="count")return e.length;const r=e.map(c=>c&&c[t]!=null?parseFloat(c[t]):NaN).filter(c=>Number.isFinite(c)),s=r.reduce((c,a)=>c+a,0);return i==="sum"?s:i==="avg"&&r.length?s/r.length:0}function Nt(e,t={},i=[],r){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const s=e.length;let c=e;t.filters&&(c=Re(c,t.filters)),t.search&&(c=Dt(c,t.search,i));const a=c.length;if(t.sort&&(c=qt(c,t.sort,r)),t.offset||t.limit){const d=t.offset||0,l=t.limit||c.length;c=c.slice(d,d+l)}return{records:c,total:s,filtered:a}}function Tt(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(i=>{if(!i)return null;const r={...i};for(const[s,c]of Object.entries(t))if(typeof c=="function")try{r[s]=c(i)}catch{r[s]=void 0}return r})}function zt(e,t,i,r="_meta"){if(!Array.isArray(e)||!e.includes(r))return!0;for(const s of Object.keys(t||{})){if(!e.includes(s))return!0;const c=t[s]&&t[s].indexes||[],a=i&&i[s]||[];if(c.some(d=>!a.includes(d)))return!0}return!1}function Ot(e){return{ok:!1,error:e&&e.message?e.message:String(e)}}(function(){const e="data-ln-data-store",t="lnDataStore";if(window[t]!==void 0)return;function i(n,o,u){const f=n.getAttribute(o);if(f==="never"||f==="-1")return-1;const h=parseInt(f,10);return isNaN(h)?u:h}const r={"data-ln-data-store":{type:"marker",effect:je,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:je,description:"Comma-separated index field names for the IndexedDB store"},"data-ln-data-store-stale":{prop:"_staleThreshold",type:"integer",read:i,fallback:300,description:"Cache staleness threshold in seconds, or -1/never"},"data-ln-data-store-search-fields":{prop:"_searchFields",type:"list",read:le,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:se,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:Z,fallback:1e3,min:10,effect:tn,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:Z,fallback:200,min:5,effect:nn,description:"Virtual scrolling slice page size"},"data-ln-data-store-frozen":{type:"marker",description:"Applied at runtime to indicate store schema is locked in IndexedDB"}},s=Ae(r),c="ln_app_cache",a="_meta",d="1.0";let l=null,w=null;const b={};function _(n){n&&n.name==="QuotaExceededError"&&v(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const o of document.querySelectorAll(`[${e}]`)){const u=o.id;if(u){const f=o.getAttribute("data-ln-data-store-indexes")||"";n[u]={indexes:f.split(",").map(h=>h.trim()).filter(Boolean)}}}return n}function F(){return w||(w=new Promise(n=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB is not available in this environment"),n(null);const o=x(),u=Object.keys(o),f=indexedDB.open(c);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),g=u.filter(N=>p.includes(N));let C={};if(g.length>0){const N=y.transaction(g,"readonly");for(const T of g)C[T]=Array.from(N.objectStore(T).indexNames)}if(!zt(p,o,C,a))return P(y),l=y,n(y);const $=y.version;y.close();const R=indexedDB.open(c,$+1);let z=!1,O=null;R.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:c}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},R.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},R.onupgradeneeded=N=>{const T=N.target.result,rn=N.target.transaction;T.objectStoreNames.contains(a)||T.createObjectStore(a,{keyPath:"key"});for(const Q of u)if(T.objectStoreNames.contains(Q)){const re=rn.objectStore(Q);for(const U of o[Q].indexes)re.indexNames.contains(U)||re.createIndex(U,U,{unique:!1})}else{const re=T.createObjectStore(Q,{keyPath:"id"});for(const U of o[Q].indexes)re.createIndex(U,U,{unique:!1})}},R.onsuccess=N=>{if(z){N.target.result&&N.target.result.close();return}O&&clearTimeout(O),z=!0;const T=N.target.result;P(T),l=T,n(T)}}}),w)}function P(n){n.onversionchange=()=>{n.close(),l=null,w=null}}function m(){return l?Promise.resolve(l):(w=null,F())}async function S(n){if(!M()||!n)return n;const o={...n},u=o.id,f=await Ct(o);return!f||!f.encrypted?n:{...f,id:u}}async function q(n){return!n||!n.encrypted||!M()?n:St(n,{silent:!0})}const D=(n,o)=>m().then(u=>u?u.transaction(n,o).objectStore(n):null);function A(n){return new Promise((o,u)=>{n.onsuccess=()=>o(n.result),n.onerror=()=>{_(n.error),u(n.error)}})}const k=n=>D(n,"readonly").then(o=>o?A(o.getAll()):[]).then(o=>M()?Promise.all(o.map(u=>q(u))):o),I=(n,o)=>D(n,"readonly").then(u=>u?A(u.get(o)).then(f=>f!==void 0?f:typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o))?A(u.get(Number(o))):typeof o=="number"?A(u.get(String(o))):null):null).then(u=>u?q(u):null),j=(n,o)=>m().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=o.map(p=>A(h.get(p)).then(g=>g!==void 0?g:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?A(h.get(Number(p))):typeof p=="number"?A(h.get(String(p))):null));return Promise.all(y).then(p=>M()?Promise.all(p.map(g=>g?q(g):null)):p)}),X=(n,o)=>(M()?S(o):Promise.resolve(o)).then(f=>D(n,"readwrite").then(h=>h?A(h.put(f)):null)),H=(n,o)=>D(n,"readwrite").then(u=>u?A(u.delete(o)).then(()=>{if(typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o)))return A(u.delete(Number(o)));if(typeof o=="number")return A(u.delete(String(o)))}):null),K=n=>D(n,"readwrite").then(o=>o?A(o.clear()):null),B=n=>D(n,"readonly").then(o=>o?A(o.count()):0),Rt=n=>D(a,"readonly").then(o=>o?A(o.get(n)):null),Y=(n,o)=>D(a,"readwrite").then(u=>{if(u)return o.key=n,A(u.put(o))});function L(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),ve(this,n,s),this._handlers=null,this.isLoaded=!1,this.canServe=!1,this.isInitialized=!1,this.initializationError=null,this.hasCache=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.query={filters:{},search:"",sort:null},n.hasAttribute("data-ln-data-store-window")?this._windowIndex=Et({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(o,u,f)=>{v(this.dom,"ln-data-store:request-page",{store:this._name,offset:o,limit:u,query:f,queryGen:this._windowIndex.queryGen})}}):this._windowIndex=null,this.windowed=this._windowIndex!==null,this.totalCount=0,this.presenters=null,this._mutationChain=Promise.resolve(),b[this._name]=this,Mt(this),this.ready=Kt(this),this}function Mt(n){n._handlers={create:o=>ee(n,"create",o.detail,()=>Bt(n,o.detail)),update:o=>ee(n,"update",o.detail,()=>Ft(n,o.detail)),delete:o=>ee(n,"delete",o.detail,()=>Pt(n,o.detail)),"bulk-delete":o=>ee(n,"bulk-delete",o.detail,()=>jt(n,o.detail)),"sync-failed":o=>{n.isSyncing=!1,v(n.dom,"ln-data-store:sync-error",{store:n._name,error:o.detail&&o.detail.error,status:o.detail&&o.detail.status})}};for(const[o,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${o}`,u);n._queryHandlers={"ln-search:change":o=>{o.preventDefault();const u=o.detail&&o.detail.term!=null?o.detail.term:"";u!==n.query.search&&(n.query.search=u,he(n))},"ln-filter:change":o=>{o.preventDefault();const u=o.detail&&o.detail.key;if(!u)return;const f=(o.detail.values||[]).slice(),h=n.query.filters[u];(h?h.length===f.length&&h.every((p,g)=>p===f[g]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],he(n))},"ln-sort:change":o=>{o.preventDefault();const u=o.detail&&o.detail.field,f=o.detail&&o.detail.direction,h=f&&f!=="none"?{field:u,direction:f}:null,y=n.query.sort;!y&&!h||y&&h&&y.field===h.field&&y.direction===h.direction||(n.query.sort=h,he(n))}};for(const[o,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(o,u)}function ee(n,o,u,f){const h=u&&u.requestId;return n._mutationChain=n._mutationChain.then(()=>n.ready).then(()=>{if(n.initializationError)throw n.initializationError;return f()}).catch(y=>$t(n,o,h,y)),n._mutationChain}function te(n,o=0){return B(n._name).then(u=>{if(n._windowIndex||n.windowed){const f=n.totalCount!=null?n.totalCount:u;n.totalCount=Math.max(0,f+o)}else n.totalCount=u;return n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,Y(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Bt(n,{tempId:o,data:u={},requestId:f}={}){const h={...u,id:o};return X(n._name,h).then(()=>te(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:o,requestId:f})})}function Ft(n,{id:o,data:u={},requestId:f}={}){return I(n._name,o).then(h=>{if(!h)throw new Error(`Record not found: ${o}`);const y=h.id,p={...h,...u,id:y},g=u.id,C=g!==void 0&&g!==y;return(C?Ut(n._name,y,{...p,id:g}):X(n._name,p)).then(()=>te(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:g}:p,previous:h,requestId:f})})})}function Pt(n,{id:o,requestId:u}={}){return I(n._name,o).then(f=>{if(!f){v(n.dom,"ln-data-store:deleted",{store:n._name,id:o,requestId:u,missing:!0});return}const h=f.id;return H(n._name,h).then(()=>te(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function jt(n,{ids:o=[],requestId:u}={}){return o.length?Promise.all(o.map(f=>I(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return ne(n._name,h).then(()=>te(n,-h.length)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(v(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function $t(n,o,u,f){console.error("[ln-data-store] "+o+" failed:",f),v(n.dom,"ln-data-store:mutation-error",{store:n._name,action:o,requestId:u,error:f})}function Kt(n){return F().then(o=>{if(!o)throw new Error("IndexedDB is unavailable");return Rt(n._name)}).then(o=>{if(n.initializationError=null,o&&o.schema_version===d)n.lastSyncedAt=o.last_synced_at||null,n.totalCount=o.record_count||0,n.hasCache=o.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,v(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(o&&o.schema_version!==d)return K(n._name).then(()=>Y(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(o=>(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=o,v(n.dom,"ln-data-store:initialization-error",{store:n._name,error:o}),{ok:!1,error:o}))}function Me(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function Be(n,o){return m().then(u=>u?(M()?Promise.all(o.map(h=>S(h))):Promise.resolve(o)).then(h=>new Promise((y,p)=>{const g=u.transaction(n,"readwrite"),C=g.objectStore(n);h.forEach(E=>C.put(E)),g.oncomplete=()=>y(),g.onerror=()=>{_(g.error),p(g.error)}})):void 0)}function ne(n,o){return m().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);o.forEach(g=>{p.delete(g),typeof g=="string"&&g.trim()!==""&&!isNaN(Number(g))?p.delete(Number(g)):typeof g=="number"&&p.delete(String(g))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function Ut(n,o,u){return(M()?S(u):Promise.resolve(u)).then(h=>m().then(y=>{if(y)return new Promise((p,g)=>{const C=y.transaction(n,"readwrite"),E=C.objectStore(n);E.put(h),E.delete(o),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),g(C.error)}})}))}const Vt=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Gt(n){return n?Object.keys(n).filter(o=>Array.isArray(n[o])&&n[o].length>0):[]}function Ht(n,o,u){return o.every(f=>u[f].map(String).includes(String(n[f])))}function Wt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Qt(n,o,u){return o.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Jt(n,o,u){return Lt(n,o,u)}function W(n,o){return Tt(o,n.presenters&&n.presenters.computed)}function Zt(n){return!n.sort&&!M()}function Xt(n,o,u){const f=Gt(o.filters),h=o.search?Wt(o.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return D(n._name,"readonly").then(g=>g?new Promise((C,E)=>{const $=[],R=g.openCursor();R.onsuccess=()=>{const z=R.result;if(!z||$.length>=u){C($);return}const O=z.value;(!f.length||Ht(O,f,o.filters))&&(!p||Qt(O,h,y))&&$.push(O),z.continue()},R.onerror=()=>E(R.error)}):[])}function Fe(n,o,u){return Nt(o,u,n._searchFields,Vt)}function Pe(n,o,u){const f=[];for(let y=o;y<o+u;y++){const p=n._windowIndex.getId(y);f.push(p)}const h=Array.from(new Set(f.filter(y=>y!==void 0)));return j(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const E=y[C];E&&p.set(String(E.id),E)}const g=[];for(let C=0;C<f.length;C++){const E=f[C];if(E===void 0)g.push(null);else{const $=p.get(String(E));g.push($||null)}}return{data:W(n,g),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:o,queryGen:n._windowIndex.queryGen}})}L.prototype.getAll=function(n={}){const o=this;if(o._windowIndex){const u=n.offset||0,f=n.limit||200;if(o._windowIndex.ensure(u,u+f,n),!o._windowIndex.hasLoaded&&!o.noLocalQuery){const h=u+f,y=p=>p.length?{data:W(o,p),offset:u,queryGen:o._windowIndex.queryGen,provisional:!0}:Pe(o,u,f);return Zt(n)?Xt(o,n,h).then(p=>y(p.slice(u,h))):k(o._name).then(p=>y(Fe(o,p,n).records))}return Pe(o,u,f)}return k(o._name).then(u=>{const f=Fe(o,u,n);return{data:W(o,f.records),total:f.total,filtered:f.filtered}})},L.prototype.getById=function(n){return I(this._name,n).then(o=>o?W(this,[o])[0]:null)},L.prototype.count=function(n){return n&&Object.keys(n).length>0?k(this._name).then(u=>Re(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):B(this._name)},L.prototype.aggregate=function(n,o){return k(this._name).then(u=>Jt(u,n,o))},L.prototype.setPresenters=function(n){this.presenters=n},L.prototype.applySync=function(n,o,u,f){f=f||{};const h=this;if(h._windowIndex&&f.queryGen!=null&&f.queryGen!==h._windowIndex.queryGen)return Promise.resolve({ok:!0,stale:!0});let y=m().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>Be(h._name,n))),o.length>0&&(y=y.then(()=>ne(h._name,o))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,g=n.map(E=>E.id),C=h._windowIndex.ingest(p,g,f.total,f.filtered,f.queryGen);if(C&&C.length)return ne(h._name,C)}}).then(()=>B(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,Y(h._name,{schema_version:d,last_synced_at:u,has_cache:!0,record_count:h.totalCount}))).then(()=>{const p=!h.isLoaded;return h.isLoaded=!0,h.canServe=!0,h.isSyncing=!1,h.lastSyncedAt=u,p?(v(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),v(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):v(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:o.length,changed:!0,meta:f}),{ok:!0}}).catch(p=>{h.isSyncing=!1;const g=p&&p.message?p.message:String(p);return console.error("[ln-data-store] applySync failed:",p),v(h.dom,"ln-data-store:sync-error",{store:h._name,error:g}),Ot(p)})},L.prototype.applyQuery=function(n,o){o=o||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>Be(u._name,n))),f.then(()=>B(u._name)).then(h=>(u.totalCount=o.total!==void 0?o.total:h,n.length>0&&(u.canServe=!0),W(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},L.prototype.forceSync=function(){this.isSyncing||Me(this)},L.prototype.fullReload=function(){const n=this;return K(n._name).then(()=>Y(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isLoaded=!1,n.hasCache=!1,n.lastSyncedAt=null,n.totalCount=0,Me(n)})},L.prototype.destroy=function(){if(this._windowIndex&&(this._windowIndex.clear(),this._windowIndex=null,this.windowed=!1),this._handlers){for(const[n,o]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,o);this._handlers=null}if(this._queryHandlers){for(const[n,o]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,o);this._queryHandlers=null}delete b[this._name],delete this.dom[t]};function Yt(){return m().then(n=>{if(!n)return;const o=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(o,"readwrite");o.forEach(y=>h.objectStore(y).clear()),h.oncomplete=()=>u(),h.onerror=()=>f(h.error)})}).then(()=>{Object.values(b).forEach(n=>{n.isLoaded=!1,n.canServe=!1,n.isInitialized=!1,n.initializationError=null,n.hasCache=!1,n.isSyncing=!1,n.lastSyncedAt=null,n.totalCount=0})})}function he(n){n._windowIndex&&n._windowIndex.reset(),v(n.dom,"ln-data-store:query-changed",{store:n._name,query:{filters:Object.assign({},n.query.filters),search:n.query.search,sort:n.query.sort?Object.assign({},n.query.sort):null}})}const en="data-ln-data-store-frozen";function je(n,o){n.setAttribute(en,o)}function tn(n){const o=n[t];if(!o._windowIndex)return;const u=o._windowIndex.configure({windowSize:o._windowSize});u.length&&ne(o._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function nn(n){const o=n[t];o._windowIndex&&o._windowIndex.configure({pageSize:o._windowPageSize})}qe(e,t,L,"ln-data-store",{attributes:r}),window[t].clearAll=Yt,window[t].init=window[t],window[t].setStorageKey=Oe,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Oe)})()})();