@zeyos/zx 3.0.0 → 4.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 (106) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/DESIGN-SYSTEM.md +87 -71
  3. package/README.md +16 -37
  4. package/dist/types/components/app-icon/app-icon.d.ts +88 -0
  5. package/dist/types/components/app-sidebar/app-sidebar.d.ts +106 -32
  6. package/dist/types/components/card/card.d.ts +128 -0
  7. package/dist/types/components/chart/chart.d.ts +1 -0
  8. package/dist/types/components/filter/filter-model.d.ts +87 -0
  9. package/dist/types/components/filter/filter.d.ts +331 -0
  10. package/dist/types/components/launcher/launcher.d.ts +65 -6
  11. package/dist/types/components/select/select.d.ts +97 -4
  12. package/dist/types/components/table/table.d.ts +107 -3
  13. package/dist/types/components/tag-picker/tag-picker.d.ts +16 -0
  14. package/dist/types/core/dom.d.ts +9 -1
  15. package/dist/types/core/util.d.ts +9 -0
  16. package/dist/types/index.d.ts +6 -2
  17. package/dist/types/{components/app-rail → internal}/app-rail.d.ts +34 -19
  18. package/dist/types/zeyos/icons.d.ts +24 -2
  19. package/dist/types/zeyos/index.d.ts +3 -2
  20. package/dist/types/zeyos/launcher.d.ts +147 -0
  21. package/dist/types/zeyos/select.d.ts +41 -0
  22. package/dist/zx-zeyos.esm.js +2018 -113
  23. package/dist/zx-zeyos.esm.min.js +1 -1
  24. package/dist/zx.css +815 -16
  25. package/dist/zx.esm.js +2661 -338
  26. package/dist/zx.esm.min.js +3 -3
  27. package/dist/zx.global.js +2661 -338
  28. package/dist/zx.global.min.js +3 -3
  29. package/dist/zx.min.css +1 -1
  30. package/docs/api.json +602 -110
  31. package/docs/llms.md +181 -123
  32. package/docs/llms.txt +24 -21
  33. package/package.json +8 -17
  34. package/src/components/app-icon/app-icon.css +105 -0
  35. package/src/components/app-icon/app-icon.js +134 -0
  36. package/src/components/app-sidebar/app-sidebar.css +12 -0
  37. package/src/components/app-sidebar/app-sidebar.js +310 -110
  38. package/src/components/card/card.css +149 -0
  39. package/src/components/card/card.js +285 -0
  40. package/src/components/chart/chart.js +8 -3
  41. package/src/components/filter/filter-model.js +226 -0
  42. package/src/components/filter/filter.css +147 -0
  43. package/src/components/filter/filter.js +554 -0
  44. package/src/components/grid/grid.css +1 -1
  45. package/src/components/grid/grid.js +14 -4
  46. package/src/components/launcher/launcher.css +113 -3
  47. package/src/components/launcher/launcher.js +234 -26
  48. package/src/components/message/message.css +36 -3
  49. package/src/components/select/field-adapter.js +9 -4
  50. package/src/components/select/select.css +161 -10
  51. package/src/components/select/select.js +361 -48
  52. package/src/components/table/table.css +85 -0
  53. package/src/components/table/table.js +426 -31
  54. package/src/components/tag-picker/tag-picker.css +19 -0
  55. package/src/components/tag-picker/tag-picker.js +42 -5
  56. package/src/core/dom.js +21 -1
  57. package/src/core/util.js +20 -0
  58. package/src/index.js +9 -2
  59. package/src/{components/app-rail → internal}/app-rail.js +80 -30
  60. package/src/zeyos/icons.js +38 -20
  61. package/src/zeyos/index.js +8 -2
  62. package/src/zeyos/launcher.js +338 -0
  63. package/src/zeyos/modules.js +1 -0
  64. package/src/zeyos/select.js +116 -1
  65. package/styles/tokens/global.css +1 -1
  66. package/styles/tokens/modules.css +1 -0
  67. package/styles/tokens/semantic.css +9 -0
  68. package/styles/tokens/themes.css +2 -2
  69. package/styles/zx.css +3 -0
  70. package/MIGRATION.md +0 -749
  71. package/dist/types/compat/base.d.ts +0 -156
  72. package/dist/types/compat/globals.d.ts +0 -20
  73. package/dist/types/compat/index.d.ts +0 -128
  74. package/dist/types/compat/map/basic.d.ts +0 -175
  75. package/dist/types/compat/map/data.d.ts +0 -103
  76. package/dist/types/compat/map/date-time.d.ts +0 -80
  77. package/dist/types/compat/map/factory.d.ts +0 -9
  78. package/dist/types/compat/map/form.d.ts +0 -98
  79. package/dist/types/compat/map/helpers.d.ts +0 -12
  80. package/dist/types/compat/map/http.d.ts +0 -36
  81. package/dist/types/compat/map/layout.d.ts +0 -106
  82. package/dist/types/compat/map/options.d.ts +0 -80
  83. package/dist/types/compat/map/select.d.ts +0 -95
  84. package/dist/types/compat/map/stubs.d.ts +0 -32
  85. package/dist/types/compat/map/utilities.d.ts +0 -37
  86. package/dist/types/compat-entry.d.ts +0 -5
  87. package/dist/zx-compat.esm.js +0 -17848
  88. package/dist/zx-compat.esm.min.js +0 -1
  89. package/dist/zx-compat.global.js +0 -29008
  90. package/dist/zx-compat.global.min.js +0 -3
  91. package/src/compat/base.js +0 -291
  92. package/src/compat/globals.js +0 -167
  93. package/src/compat/index.js +0 -84
  94. package/src/compat/map/basic.js +0 -464
  95. package/src/compat/map/data.js +0 -254
  96. package/src/compat/map/date-time.js +0 -177
  97. package/src/compat/map/factory.js +0 -45
  98. package/src/compat/map/form.js +0 -330
  99. package/src/compat/map/helpers.js +0 -46
  100. package/src/compat/map/http.js +0 -117
  101. package/src/compat/map/layout.js +0 -256
  102. package/src/compat/map/options.js +0 -267
  103. package/src/compat/map/select.js +0 -198
  104. package/src/compat/map/stubs.js +0 -26
  105. package/src/compat/map/utilities.js +0 -113
  106. package/src/compat-entry.js +0 -11
@@ -1,3 +0,0 @@
1
- (()=>{var zc=Object.defineProperty;var kc=(i,t)=>{for(var e in t)zc(i,e,{get:t[e],enumerable:!0})};var En={};kc(En,{AccountMenu:()=>ti,AppRail:()=>Se,AppSidebar:()=>si,Avatar:()=>we,Breadcrumb:()=>Gs,Chart:()=>ci,ChartJsAdapter:()=>hi,CheckButton:()=>at,Checklist:()=>Q,Component:()=>m,ContextMenu:()=>ai,CopyInput:()=>Ps,DataFilter:()=>ze,DatePicker:()=>J,DateRangeBox:()=>ae,DateRangePicker:()=>oe,DateTimeBox:()=>xs,Datebox:()=>q,Dialog:()=>et,Dock:()=>Ks,Dropdown:()=>st,Field:()=>S,FieldUpload:()=>Et,Fieldset:()=>St,Finder:()=>pi,Form:()=>ke,Grid:()=>li,Groupbox:()=>_t,Http:()=>ot,InlineLoading:()=>Fs,Launcher:()=>Xs,MasterPanel:()=>be,MenuButton:()=>K,Message:()=>wt,Modal:()=>fe,MonthPicker:()=>Ct,MultiValueEditor:()=>Dt,NavigationBar:()=>xe,NumberField:()=>Nt,Pagination:()=>Js,Panel:()=>ge,ProgressBar:()=>_e,Questionnaire:()=>gi,Rating:()=>le,Search:()=>Ot,Select:()=>R,Sheet:()=>ri,SheetStack:()=>ni,Slider:()=>ce,SplitView:()=>$s,Stepper:()=>Ws,Tabbox:()=>Ft,Table:()=>lt,TagPicker:()=>he,TimePicker:()=>rt,Timebox:()=>tt,Toggle:()=>H,Toolbar:()=>qs,Tooltip:()=>Lt,TreeView:()=>fi,ValueList:()=>It,__:()=>Zn,addDays:()=>E,addMonths:()=>bt,appendCompact:()=>Xn,appendCompactChild:()=>to,appendContent:()=>Jn,applyCompactProperties:()=>vr,aspect:()=>Xa,avatarInitials:()=>dn,badge:()=>$a,badgeGroup:()=>Ka,billingColumns:()=>yn,breakpointOf:()=>ws,breakpoints:()=>Kt,button:()=>j,buttonGroup:()=>Ms,chartSummaryTable:()=>vn,clamp:()=>M,clampDate:()=>cs,clampRange:()=>ne,clampSize:()=>vt,cloneChartValue:()=>ut,compactElement:()=>Oe,configureIcons:()=>Pe,copyButton:()=>Rs,copyToClipboard:()=>Ts,debounce:()=>Kn,deepMerge:()=>Jt,defaultDateRangePresets:()=>Br,defineElements:()=>ja,describe:()=>Al,downloadBlob:()=>Da,emptyState:()=>Ua,escapeRegExp:()=>Xt,faFamilies:()=>Er,faIconClasses:()=>Le,faNames:()=>Dr,faStyles:()=>hs,fireCompactEvent:()=>oo,focusTrap:()=>vs,formatCurrency:()=>zs,formatDate:()=>z,formatFileSize:()=>Aa,formatNumber:()=>Mt,formatPercent:()=>ks,formatRangeText:()=>jr,formatRelativeTime:()=>za,fragment:()=>eo,getIconConfig:()=>fs,getLanguage:()=>Z,getWeekStart:()=>ee,grid:()=>Ja,groupBy:()=>Yn,h:()=>l,highlightMatch:()=>so,htmlEscape:()=>os,icon:()=>_,iconNames:()=>Io,icons:()=>se,isBillingLine:()=>Ge,isElement:()=>N,isEmptyChartData:()=>ui,isSameDay:()=>L,isTruncated:()=>sn,joinTime:()=>Kr,kitUrl:()=>Re,loadFontAwesome:()=>Do,loadFontAwesomeKit:()=>ds,matchBreakpoint:()=>Ss,normalizeAppItems:()=>Rt,normalizeRange:()=>Ht,offCompactEvent:()=>no,onBreakpoint:()=>ue,onCompactEvent:()=>wr,paginationRange:()=>cn,parseCompactTag:()=>xr,parseDate:()=>$,parseIconSpec:()=>us,parseNumber:()=>Be,parseRangeText:()=>ys,parseResult:()=>As,position:()=>Y,printf:()=>F,rangeNights:()=>re,rangeStateOf:()=>Pr,rankLauncherItems:()=>un,registerFieldAdapters:()=>Wl,registerIcons:()=>No,resolveElement:()=>V,resolveSize:()=>it,rovingTabindex:()=>mt,setLanguage:()=>ho,setTranslator:()=>co,skeleton:()=>Ls,skeletonTable:()=>Qa,skeletonText:()=>Ga,snapNumber:()=>qe,snapSize:()=>rn,sortBy:()=>Wn,spinner:()=>Os,splitTime:()=>$r,stack:()=>Za,stepPrecision:()=>Hr,storage:()=>de,throttle:()=>Un,toArray:()=>Ne,toCsv:()=>Ea,tooltip:()=>Sl,translate:()=>G,truncate:()=>sl,typeahead:()=>X,uid:()=>y,uniqueBy:()=>Gn,useBuiltinIcons:()=>Eo,useFontAwesome:()=>Mr,zeyosService:()=>Ut});function Kn(i,t){let e=null;return function(...r){let n=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i.apply(n,r)},t)}}function Un(i,t,{leading:e=!0,trailing:s=!0}={}){let r=Math.max(0,Number(t)||0),n=null,o=0,a=null,c=null,h=()=>{n=null,o=e?Date.now():0;let u=a,d=c;a=null,c=null,u!==null&&i.apply(d,u)};return function(...d){let p=Date.now();o===0&&!e&&(o=p);let f=r-(p-o);if(f<=0||f>r){n!==null&&(clearTimeout(n),n=null),o=p,a=null,c=null,i.apply(this,d);return}s&&(a=d,c=this,n===null&&(n=setTimeout(h,f)))}}var Vn=0;function y(i="zx"){return Vn+=1,`${i}-${Date.now().toString(36)}-${Vn.toString(36)}`}function Jt(i,t){let e=De(i)?Qn(i):{};if(!De(t))return ns(t);for(let[s,r]of Object.entries(t))De(r)&&De(e[s])?e[s]=Jt(e[s],r):e[s]=ns(r);return e}function N(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function M(i,t,e){return Math.min(e,Math.max(t,i))}function Ne(i){if(i==null)return[];if(Array.isArray(i))return i.slice();let t=i;return typeof i!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof i!="string"&&typeof t?.length=="number"?Array.from(t):[i]}function Yn(i,t){let e=rs(t),s=new Map;for(let r of Ne(i)){let n=String(e(r)),o=s.get(n);o===void 0?s.set(n,[r]):o.push(r)}return Object.fromEntries(s)}function Wn(i,...t){let e=Ne(i),s=t.map(Cc);return s.length===0?e:e.sort((r,n)=>{for(let o of s){let a=o(r,n);if(a!==0)return a}return 0})}function Gn(i,t){let e=t==null?n=>n:rs(t),s=new Set,r=[];for(let n of Ne(i)){let o=e(n);s.has(o)||(s.add(o),r.push(n))}return r}function Xt(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rs(i){if(typeof i=="function")return i;let t=String(i);return e=>e?.[t]}function Cc(i){let t,e=1;if(typeof i=="function")t=i;else if(i!==null&&typeof i=="object")t=rs(i.key),String(i.dir).toLowerCase()==="desc"&&(e=-1);else{let s=String(i);s.startsWith("-")?(e=-1,s=s.slice(1)):s.startsWith("+")&&(s=s.slice(1)),t=rs(s)}return(s,r)=>{let n=t(s),o=t(r),a=Hn(n),c=Hn(o);return a||c?a&&c?0:a?1:-1:e*Tc(n,o)}}function Hn(i){return i==null||typeof i=="number"&&Number.isNaN(i)}function Tc(i,t){return i instanceof Date||t instanceof Date?yr($n(i)-$n(t)):typeof i=="boolean"||typeof t=="boolean"?yr(Number(i)-Number(t)):typeof i=="number"&&typeof t=="number"?yr(i-t):String(i).localeCompare(String(t),void 0,{numeric:!0})}function $n(i){if(i instanceof Date)return i.getTime();let t=Number(i);return Number.isFinite(t)?t:0}function yr(i){return Number.isNaN(i)?0:i<0?-1:i>0?1:0}function De(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function Qn(i){let t={};for(let[e,s]of Object.entries(i))t[e]=ns(s);return t}function ns(i){return De(i)?Qn(i):Array.isArray(i)?i.map(ns):i}var Ie=null,Ec=new Set(["href","id","lang","name","rel","src","target","title","value"]),Me=new WeakMap;function xr(i){if(typeof i!="string")throw new TypeError("DOM builder tag must be a string");let t=i,e="",s="",r=t.indexOf(".");return r!==-1&&(e=t.slice(r+1),t=t.slice(0,r)),r=t.indexOf("#"),r!==-1&&(s=t.slice(r+1),t=t.slice(0,r)),{tag:t||"div",id:s,className:e}}function Oe(i,t=null,e=null){let s=xr(i),r=document.createElement(s.tag);if(s.id&&(r.id=s.id),s.className&&(r.className=s.className),s.tag==="a"){let n=r;n.rel="noopener",n.tabIndex=-1}else if(s.tag==="button")r.type="button";else if(s.tag==="input"||s.tag==="textarea"){let n=r;n.autocapitalize="none",n.autocomplete="off",n.autocorrect="off",n.spellcheck=!1}return t&&vr(r,t),Mc(r,e),r}var Zn=Oe;function vr(i,t){for(let e in t??{}){let s=t[e];if(s!=null)if(e[0]==="D")i.setAttribute(`data-${e.slice(1)}`,String(s));else if(e[0]==="S")i.style[e.slice(1)]=s;else if(e.startsWith("on")){if(typeof s!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);wr(i,e.slice(2),s)}else typeof s=="boolean"||Ec.has(e)?i[e]=s:i.setAttribute(e,String(s))}return i}function Jn(i,t){if(t==null)return i;let e=ro(t);return e==null||(typeof e=="object"?i.appendChild(e):i.appendChild(document.createTextNode(String(e)))),i}function Xn(i,t,e=null,s=null){return i.appendChild(Oe(t,e,s)),i}function to(i,t,e=null,s=null){let r=Oe(t,e,s);return i.appendChild(r),r}function eo(...i){let t=document.createDocumentFragment();return io(t,i),t}function l(i,t,...e){let s=document.createElement(i),r=t;Dc(r)||(e.unshift(r),r={});for(let[n,o]of Object.entries(r))Nc(s,n,o);return io(s,e),s}l.scope=function(t,e){let s=Ie;Ie=t;try{return e()}finally{Ie=s}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function k(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function C(i,t){if(t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}}function os(i){return String(i).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function so(i,t,e={}){let{className:s="zx-mark"}=e,r=i==null?"":String(i),n=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(n===""||r==="")return o.append(document.createTextNode(r)),o;let a=new RegExp(Xt(n),"gi"),c=0;for(let h of r.matchAll(a)){h.index>c&&o.append(document.createTextNode(r.slice(c,h.index)));let u=document.createElement("mark");s&&(u.className=String(s)),u.append(document.createTextNode(h[0])),o.append(u),c=h.index+h[0].length}return c<r.length&&o.append(document.createTextNode(r.slice(c))),o}function V(i){if(i==null)return null;if(N(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return N(t)?t:null}return null}function Dc(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let t=i;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Nc(i,t,e){if(t==="ref"){Ie&&typeof e=="string"&&(Ie[e]=i);return}if(t==="class"){i.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")i.style.cssText=e;else if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))r.startsWith("--")||r.includes("-")?i.style.setProperty(r,String(n)):i.style[r]=n;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[r,n]of Object.entries(e))n==null?delete i.dataset[r]:i.dataset[r]=String(n);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Ic(t);if(s!==null)i.setAttribute(s,String(e));else if(t in i)try{i[t]=e}catch{i.setAttribute(t,String(e))}else typeof e=="boolean"?e?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,String(e))}function Ic(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function io(i,t){let e=i;for(let s of t.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){e.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let r=s;if(typeof r.nodeType=="number")e.append(s);else if(typeof r.toElement=="function"){let n=r.toElement();n&&e.append(n)}}}function Mc(i,t){if(t==null)return;let e=ro(t);e!=null&&(typeof e=="object"?i.appendChild(e):i.textContent=String(e))}function ro(i){if(i&&typeof i=="object"){if(typeof i.nodeType=="number")return i;if(typeof i.toElement=="function")return i.toElement()}return i}function wr(i,t,e,s=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let r=String(t),n=Me.get(i);n||(n=new Map,Me.set(i,n));let o=n.get(r);if(o)return o.handlers.push(e),i;let a=[e],c=h=>ao(i,a,h);n.set(r,{handlers:a,listener:c});try{i.addEventListener(r,c,{passive:s})}catch{i.addEventListener(r,c)}return i}function no(i,t,e){let s=String(t),r=Me.get(i),n=r?.get(s);if(!n)return i;let o=n.handlers.indexOf(e);return o===-1||(n.handlers.splice(o,1),n.handlers.length===0&&(i.removeEventListener(s,n.listener),r.delete(s),r.size===0&&Me.delete(i))),i}function oo(i,t,e=null){let s=String(t),r=Me.get(i);if(!r?.has(s))return i;let n=e??Oc(i,s),o=r.get(String(n.type));return o&&ao(i,o.handlers,n),i}function ao(i,t,e){let s=e,r=String(s.type).startsWith("key")?s.which:s.target;for(let n=t.length-1;n>=0;n-=1)t[n].call(i,e,r)===!1&&s.preventDefault()}function Oc(i,t){let e={target:i,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var Sr=null,lo="en";function co(i){if(i!==null&&typeof i!="function")throw new TypeError("Translator must be a function or null");Sr=i}function ho(i){lo=String(i||"en")}function Z(){return lo}function G(i,t){let e=Sr?Sr(i):i;return F(e==null?i:String(e),t)}function F(i,t){if(t==null)return String(i);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],s=String(i).replace(/%(\d+)/g,(n,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?n:String(c)}),r=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(n,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?n:String(a)}if(e&&r<e.length){let a=e[r];return r+=1,a==null?n:String(a)}return n}),s}var as=new WeakMap,m=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#s=!1;#i=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let r=V(t);if(t!==null&&!r)throw new TypeError("Component target could not be resolved");this.el=r,this.refs={};let n=Fc(s,e),o=[];for(let[h,u]of Object.entries(n))/^on[a-z]/.test(h)&&typeof u=="function"&&(o.push([h.slice(2),u]),delete n[h]);n.msg&&typeof n.msg=="object"&&Object.freeze(n.msg),this.options=Object.freeze(n);for(let[h,u]of o)this.on(h,u);let a;try{a=l.scope(this.refs,()=>this.render())}catch(h){throw this.#t.abort(),h}if(this.#e){let h=N(a)?a:this.el;if(!N(h))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=h}if(!N(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let h=`zx-${c}`;this.#i=!this.el.classList.contains(h),this.el.classList.add(h)}as.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let s=uo(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(uo(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,r={}){let n=typeof r=="boolean"?{capture:r}:{...r};return t.addEventListener(e,s,{...n,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,r=this.options.lang??this.options.language??Z(),n=s?.[r]?.[t];if(n!=null)return F(String(n),e);let o=s?.[t];return o!=null?F(String(o),e):G(t,e)}destroy(){if(this.#s)return;this.#s=!0,this.#t.abort(),as.get(this.el)===this&&as.delete(this.el);let t=this.constructor.cssName;this.#i&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return as.get(t)??null}};function Fc(i,t){let e=[],s=i;for(;s&&s!==Function.prototype;)Object.prototype.hasOwnProperty.call(s,"defaults")&&e.unshift(s.defaults),s=Object.getPrototypeOf(s);let r={},n={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(r,a),a.msg&&typeof a.msg=="object"&&(o=!0,n=Jt(n,a.msg)));return Object.assign(r,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,n=Jt(n,t.msg)),o&&(r.msg=n),r}function uo(i,t,e){if(typeof CustomEvent=="function")return new CustomEvent(i,{...e,detail:t});let s=new Event(i,e);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:t}),s}var S=class i extends m{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let s=String(t).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return i.#t.set(s,e),this}static has(t){return i.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=Bc(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=s,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):y("zx-field");let r=`${this.controlId}-label`,n=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:r,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),h=l("div",{class:"zx-field__description",id:n},String(this.options.description??"")),u=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=l("div",{class:"zx-field__body"},c,h,u);this._ownedNodes.push(a,d),t.append(a,d);let p=i.#t.get(e);if(p)try{this.adapter=Rc(p(this,this.options))}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`[zx.Field] Adapter "${e}" failed: ${x}`),this.adapter=po(x,this.controlId)}else{let g=this.msg("field.unknown",e);console.warn(`[zx.Field] ${g}`),this.adapter=po(g,this.controlId)}let f=this.adapter.el;return f.id||(f.id=this.controlId),a.htmlFor=f.id,Pc(f)||f.setAttribute("aria-labelledby",r),this._baseDescribedBy=f.getAttribute("aria-describedby")??"",c.append(f),this._descriptionId=String(this.options.description??"")?n:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=Lc(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let s=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,s==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof m))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();qc(this.el,this._rootAttributes??new Map),super.destroy()}};function Ar(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=_o(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function zr(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=_o(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function _o(i){let t=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",s=e?t.slice(1):t;if(!/\d/.test(s))return null;let r=[...s.matchAll(/\./g)].map(c=>c.index),n=[...s.matchAll(/,/g)].map(c=>c.index),o;if(r.length&&n.length){let c=r.at(-1)>n.at(-1)?".":",",h=c==="."?",":".",u=s.lastIndexOf(c),d=s.slice(0,u),p=s.slice(u+1);if(!/^\d+$/.test(p)||!fo(d,h))return null;o=d.split(h).join("")+"."+p}else if(n.length>1||r.length>1){let c=n.length?",":".";if(!fo(s,c))return null;o=s.split(c).join("")}else n.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function fo(i,t){let e=i.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(s=>/^\d{3}$/.test(s))}function Lc(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function Rc(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof i[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return i}function po(i,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},i);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Pc(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Bc(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function qc(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function Fe(i,t){let e={...i.props??{}};for(let s of Object.keys(e))(/^on[a-z]/i.test(s)||s==="content")&&delete e[s];return{...e,...t}}function ls(i,t){return(e,s)=>{let r=l(i,Fe(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return kr(r)}}function kr(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function go(i){return(t,e)=>{let s=i==="int"?Ar:zr,r=l("input",Fe(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(r,"blur",()=>{let n=s(r.value);if(!n.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}n.value!==""&&(r.value=String(n.value)),t.clearHighlight()}),{...kr(r),get:()=>s(r.value).value}}}var jc=(i,t)=>{let e=l("input",Fe(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:s=>{e.checked=!!s},focus:()=>e.focus(),setDisabled:s=>{e.disabled=s}}},Vc=(i,t)=>{let e=l("select",Fe(t,{required:t.required,disabled:t.disabled}));for(let[s,r]of bo(t.options))e.append(l("option",{value:s},r));return kr(e)},Hc=(i,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):y("zx-option-list"),r=bo(t.options).map(([n,o],a)=>{let c=l("input",{type:"radio",name:s,value:n,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>r.find(n=>n.checked)?.value??"",set:n=>{for(let o of r)o.checked=String(n??"")===o.value},focus:()=>(r.find(n=>n.checked)??r[0])?.focus(),setDisabled:n=>{for(let o of r)o.disabled=n;e.setAttribute("aria-disabled",String(n))}}},$c=(i,t)=>{let e=l("div",Fe(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:n=>{mo(s),s=null,n&&typeof n=="object"&&typeof n.nodeType=="number"?(s={node:n,parent:n.parentNode,next:n.nextSibling},e.replaceChildren(n)):e.textContent=n==null?"":String(n)},focus:()=>{},setDisabled:n=>{e.setAttribute("aria-disabled",String(n))},destroy:()=>mo(s)}};function mo(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var Kc=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function bo(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}S.register("text",ls("input","text"));S.register("password",ls("input","password"));S.register("textarea",ls("textarea","text"));S.register("checkbox",jc);S.register("int",go("int"));S.register("float",go("float"));S.register("select",Vc);S.register("optionlist",Hc);S.register("hidden",ls("input","hidden"));S.register("html",$c);S.register("custom",Kc);function kt(i,t,e){let s=yo(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(r=>{let n=Uc(r,e).map(yo);return s.every(o=>n.some(a=>a.includes(o)))})}function Uc(i,t){return i===null||typeof i!="object"?[i]:!Array.isArray(t)||t.length===0?[i]:t.map(e=>typeof e=="function"?e(i):i[e])}function yo(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Q=class extends m{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=y("zx-checklist-label"),s=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),r=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),n=l("div",{ref:"list",class:"zx-checklist__list"});return n.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,r,n),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(n,"change",o=>{let a=o.target;if(!a?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(a.dataset.index)];if(c===void 0)return;let h=this._itemValue(c);a.checked?this._checked.add(h):this._checked.delete(h),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),s=new Set(this._items.map(r=>this._itemValue(r)).filter(r=>e.has(r)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=kt(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=kt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let r=y("zx-checklist-item"),n=l("input",{type:"checkbox",id:r,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return l("label",{class:"zx-checklist__item",for:r},n,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){Yc(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Yc(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function xo(){S.register("checklist",(i,t)=>{let e=i.own(new Q(null,{...t.props??{}})),s=!1,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=s};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{r||i.emit("change",{value:o.detail.values})}),e.on("loaded",n),{el:e.el,get:()=>e.getValues(),set:o=>{r=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{r=!1}n()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,n()}}})}var vo=["January","February","March","April","May","June","July","August","September","October","November","December"],wo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],zo=/%[demYyHMSaAbBs]/g;function z(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(zo,e=>{switch(e){case"%d":return te(i.getDate());case"%e":return String(i.getDate());case"%m":return te(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return te(i.getFullYear()%100);case"%H":return te(i.getHours());case"%M":return te(i.getMinutes());case"%S":return te(i.getSeconds());case"%a":return So("weekday",i.getDay(),wo[i.getDay()]);case"%A":return Cr("weekday",i.getDay(),wo[i.getDay()]);case"%b":return So("month",i.getMonth(),vo[i.getMonth()]);case"%B":return Cr("month",i.getMonth(),vo[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function $(i,t){let e=[],s="^",r=0;for(let g of String(t).matchAll(zo)){s+=Ao(String(t).slice(r,g.index));let x=g[0],v=Wc(x);if(v===null)return null;s+=`(${v})`,e.push(x),r=g.index+x.length}s+=Ao(String(t).slice(r))+"$";let n=new RegExp(s).exec(String(i));if(!n)return null;let o=Object.create(null);if(e.forEach((g,x)=>{o[g]=Number(n[x+1])}),o["%s"]!==void 0){let g=o["%s"]*1e3,x=new Date(g);return Number.isNaN(x.getTime())?null:x}let a=o["%Y"]??Gc(o["%y"])??1970,c=(o["%m"]??1)-1,h=o["%d"]??o["%e"]??1,u=o["%H"]??0,d=o["%M"]??0,p=o["%S"]??0,f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,c,h),f.setHours(u,d,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==c||o["%d"]!==void 0&&f.getDate()!==h||o["%e"]!==void 0&&f.getDate()!==h||o["%H"]!==void 0&&f.getHours()!==u||o["%M"]!==void 0&&f.getMinutes()!==d||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function cs(i,t,e){let s=i.getTime(),r=t instanceof Date?t.getTime():-1/0,n=e instanceof Date?e.getTime():1/0;return new Date(Math.min(n,Math.max(r,s)))}function L(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function E(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function bt(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let r=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,r)),e}function ee(i=Z()){if(!i||i.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(i),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function te(i){return String(i).padStart(2,"0")}function Cr(i,t,e){let s=`date.${i}.${t}`,r=G(s);return r===s?e:r}function So(i,t,e){let s=`date.${i}.short.${t}`,r=G(s);return r!==s?r:Cr(i,t,e).slice(0,3)}function Wc(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function Gc(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Ao(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var hs=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Er=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),ko=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),Dr=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical"}),Tr=new Map;function us(i){let t=String(i).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let s=t.slice(0,e).toLowerCase(),r=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:r,style:null,classes:null};if(Object.hasOwn(ko,s))return{provider:"fa",name:r,style:ko[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Le(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:r=!1,translate:n=!0}=t,o=String(i).replace(/^fa-/,""),a=n?Dr[o]??o:o,c=[],h=Er[s];return h&&c.push(h),c.push(hs[e]??hs.solid,`fa-${a}`),r&&c.push("fa-fw"),c}function Re(i){let t=String(i).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${t}.js`}function ds(i){let t=Re(i),e=Tr.get(t);if(e)return e;let s=new Promise((r,n)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(h=>h.src===o);if(a&&globalThis.FontAwesomeKitConfig){r();return}let c=a??document.createElement("script");c.addEventListener("load",()=>r(),{once:!0}),c.addEventListener("error",()=>{Tr.delete(t),n(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Tr.set(t,s),s}var Co="http://www.w3.org/2000/svg",se=Object.freeze({"chevron-down":["0 0 512 512","M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"],"chevron-up":["0 0 512 512","M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"],"chevron-left":["0 0 320 512","M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"],"chevron-right":["0 0 320 512","M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"],check:["0 0 448 512","M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"],x:["0 0 384 512","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"],plus:["0 0 448 512","M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z"],minus:["0 0 448 512","M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"],search:["0 0 512 512","M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"],calendar:["0 0 448 512","M128 0c17.7 0 32 14.3 32 32V64H288V32c0-17.7 14.3-32 32-32s32 14.3 32 32V64h48c26.5 0 48 21.5 48 48v48H0V112C0 85.5 21.5 64 48 64H96V32c0-17.7 14.3-32 32-32zM0 192H448V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V192z"],clock:["0 0 512 512","M256 0a256 256 0 1 1 0 512A256 256 0 1 1 256 0zM232 120V256c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z"],trash:["0 0 448 512","M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"],gear:["0 0 512 512","M481.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"],eye:["0 0 576 512","M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z"],lock:["0 0 448 512","M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"],reload:["0 0 512 512","M386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H464c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"],list:["0 0 512 512","M40 48C26.7 48 16 58.7 16 72v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24H40zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM16 232v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V232c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V392c0-13.3-10.7-24-24-24H40z"],filter:["0 0 512 512","M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"],dots:["0 0 448 512","M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1-112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"],info:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],warning:["0 0 512 512","M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0-64 0 32 32 0 1 0 64 0z"],error:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1-64 0z"],success:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"],upload:["0 0 512 512","M288 109.3V352c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352H192c0 35.3 28.7 64 64 64s64-28.7 64-64H448c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V416c0-35.3 28.7-64 64-64z"],drag:["0 0 320 512","M40 352l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 176l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 0L88 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40L40 128C17.9 128 0 110.1 0 88L0 40C0 17.9 17.9 0 40 0zM232 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40z"],star:["0 0 576 512","M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0z"],heart:["0 0 512 512","M47.6 300.4L228.3 469.1c7.5 7 17.4 10.9 27.7 10.9s20.2-3.9 27.7-10.9L464.4 300.4c30.4-28.3 47.6-68 47.6-109.5v-5.8c0-69.9-50.5-129.5-119.4-141C347 36.5 300.6 51.4 268 84L256 96 244 84c-32.6-32.6-79-47.5-124.6-39.9C50.5 55.6 0 115.2 0 185.1v5.8c0 41.5 17.2 81.2 47.6 109.5z"],tag:["0 0 448 512","M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],folder:["0 0 512 512","M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H298.5c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"],"folder-open":["0 0 576 512","M88.7 223.8L0 375.8V96C0 60.7 28.7 32 64 32H181.5c17 0 33.3 6.7 45.3 18.7l26.5 26.5c12 12 28.3 18.7 45.3 18.7H416c35.3 0 64 28.7 64 64v32H144c-22.8 0-43.8 12.1-55.3 31.8zm27.6 16.1C122.1 230 132.6 224 144 224H544c11.5 0 22 6.1 27.7 16.1s5.7 22.2-.1 32.1l-112 192C453.9 474 443.4 480 432 480H32c-11.5 0-22-6.1-27.7-16.1s-5.7-22.2 .1-32.1l112-192z"],file:["0 0 384 512","M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128z"],copy:["0 0 448 512","M208 0L332.1 0c12.7 0 24.9 5.1 33.9 14.1l67.9 67.9c9 9 14.1 21.2 14.1 33.9L448 336c0 26.5-21.5 48-48 48l-192 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48zM48 128l80 0 0 64-64 0 0 256 192 0 0-32 64 0 0 48c0 26.5-21.5 48-48 48L48 512c-26.5 0-48-21.5-48-48L0 176c0-26.5 21.5-48 48-48z"],square:["0 0 448 512","M384 80c8.8 0 16 7.2 16 16V416c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V96c0-8.8 7.2-16 16-16H384zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"],code:["0 0 640 512","M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"],book:["0 0 448 512","M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"]}),Qc=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),Ir=Object.create(null),yt={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function fs(){return{...yt}}function Pe(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(yt[t]=i[t]);return fs()}function Mr(i={}){return Pe({...i,provider:"fontawesome"})}function Eo(){return Pe({provider:"builtin"})}async function Do(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...r}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Pe({...r,kit:Re(e)}),await ds(e),s?Mr():fs()}function No(i){for(let[t,e]of Object.entries(i)){if(!Array.isArray(e)||e.length!==2)throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair`);Ir[t]=[String(e[0]),String(e[1])]}}function Io(){return[...new Set([...Object.keys(se),...Object.keys(Ir)])].sort()}function _(i,t={}){let e=us(i);if(e.classes)return Nr(e.classes,t);let s=Qc[e.name]??e.name;return e.provider==="builtin"?To(s,t):e.provider==="fa"?Nr(Le(s,{style:e.style??t.style??yt.style,family:t.family??yt.family,fixedWidth:t.fixedWidth??yt.fixedWidth}),t):yt.provider==="fontawesome"?Nr(Le(s,{style:t.style??yt.style,family:t.family??yt.family,fixedWidth:t.fixedWidth??yt.fixedWidth}),t):To(s,t)}function To(i,t){let e=Ir[i]??se[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,r]=e,{size:n=16}=t,o=document.createElementNS(Co,"svg"),a=document.createElementNS(Co,"path");return o.setAttribute("class",Oo("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(n)),o.setAttribute("height",String(n)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Mo(o,t.label??null),a.setAttribute("d",r),o.append(a),o}function Nr(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=Oo("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),Mo(s,t.label??null),s}function Mo(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function Oo(...i){return i.flat().filter(Boolean).join(" ")}var Zc=5,rt=class extends m{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Fo(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=s,this._addSpin(s,"h","Hour",23),s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m","Minute",59),this.options.seconds&&(s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s","Second",59)),t.append(s),this.options.clock){let r=y("zx-time-picker-clock");s.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls:r},_("clock",{size:15}))),this._clock=this._buildClock(r),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let s=Fo(t);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!e&&s&&this.emit("change",{time:{...s}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,s,r){let n=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(r),dataset:{segment:e}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"keydown",o=>this._onKeydown(o,e,r)),this.listen(n,"input",()=>this._onInput(n,e,r)),this.listen(n,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let r=t.key==="ArrowUp"?1:-1,n=e==="m"?eh(this.options.step):1,o=ie(t.currentTarget.value,0,s),a=s+1,c=(o+r*n+a*n)%a;t.currentTarget.value=jt(c),this._commitFromInputs()}_onInput(t,e,s){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=jt(ie(t.value,0,s)),this._commitFromInputs();let r=this._inputs.indexOf(t);this._inputs[r+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let r=s.dataset.segment,n=r==="h"?23:59;t[r]=ie(s.value,0,n)}let e=!this._value||!sh(this._value,t);this._value=t,this._display=t,this._writeInputs(),e&&this.emit("change",{time:{...t}})}_writeInputs(){for(let t of this._inputs){let e=t.dataset.segment;t.value=jt(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let r=s.target.closest?.(".zx-time-picker__mark");r&&this._pick(Number(r.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},s=this._clockUnit==="h";this.set(e),s&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=t.target.closest?.(".zx-time-picker__mark"),r=e.indexOf(s);if(r<0)return;let n={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;n!==void 0?o=(r+n+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=jt(this._display.h),this.refs.headMinute.textContent=jt(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,s=t?Jc():Xc(),r=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(r.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of r)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(a=>this._buildMark(a,e)))}else s.forEach((a,c)=>this._syncMark(r[c],a,e));let n=t&&!th(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=n,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let s=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return s.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(s,t,e),s}_syncMark(t,e,s){let r=e.value===s;t.setAttribute("aria-checked",String(r)),t.tabIndex=r?0:-1}};function Jc(){let i=[];for(let t=1;t<=12;t+=1)i.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;i.push({value:e,label:jt(e),angle:t*30,ring:"inner"})}return i}function Xc(){let i=[];for(let t=0;t<60;t+=Zc)i.push({value:t,label:jt(t),angle:t*6,ring:"outer"});return i}function th(i){return i>=1&&i<=12}function Fo(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:ie(i.h,0,23),m:ie(i.m,0,59),s:ie(i.s,0,59)}}function ie(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function eh(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function jt(i){return String(i).padStart(2,"0")}function sh(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var J=class extends m{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=nt(ps(this.options.min)),this._max=nt(ps(this.options.max)),this._value=this._normalizeValue(ps(this.options.value)),this._focused=nt(this._value)??this._clampFocus(nt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=ih(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},_("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},_("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},_("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},_("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new rt(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let r=s.detail.time,n=this._value??this._focused,o=new Date(n.getTime());o.setHours(r.h,r.m,r.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Or(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(ps(t));return this._value=s,s&&(this._focused=nt(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Or(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),s=nt(e);return this._min&&s<this._min&&Lo(e,this._min),this._max&&s>this._max&&Lo(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let r=E(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:z(r,"%A")},z(r,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,s=E(t,-e);this.refs.heading.textContent=z(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${z(t,"%B %Y")}`);let r=[];for(let n=0;n<6;n+=1){let o=E(s,n*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Ro(o)}`},String(Ro(o))));for(let c=0;c<7;c+=1){let h=E(o,c),u=!!(this._value&&L(h,this._value)),d=!this._inRange(h),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:L(h,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(d),ariaCurrent:L(h,new Date)?"date":null,ariaLabel:`${z(h,"%e")} ${z(h,"%B %Y")}`,dataset:{date:z(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},z(h,"%e"));a.append(l("td",{role:"presentation"},p))}r.push(a)}this.refs.days.replaceChildren(...r),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=$(e.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=$(e.dataset.date,"%Y-%m-%d");if(!s)return;let r=null;if(t.key==="ArrowLeft")r=E(s,-1);else if(t.key==="ArrowRight")r=E(s,1);else if(t.key==="ArrowUp")r=E(s,-7);else if(t.key==="ArrowDown")r=E(s,7);else if(t.key==="PageUp")r=bt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=bt(s,t.shiftKey?12:1);else if(t.key==="Home")r=E(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=E(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}r&&(t.preventDefault(),this._moveFocus(r))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=nt(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),s=this._timePicker?.get();s?e.setHours(s.h,s.m,s.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let r=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=nt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),r&&this._emitMonthChange(),this.emit("change",{date:Or(e)})}_pageMonth(t){this._closeQuickPick();let e=bt(this._focused,t);this._focused=nt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},z(s,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let s=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=s-1;else if(t.key==="ArrowRight")r=s+1;else if(t.key==="ArrowUp")r=s-3;else if(t.key==="ArrowDown")r=s+3;else if(t.key==="Home")r=0;else if(t.key==="End")r=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(s);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(r===null)return;t.preventDefault(),r=Math.max(0,Math.min(11,r));let n=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of n)o.tabIndex=Number(o.dataset.month)===r?0:-1;n[r]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=nt(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=nt(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${z(t,"%Y-%m-%d")}"]`)}};function ps(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function nt(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Or(i){return i?new Date(i.getTime()):null}function Lo(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function ih(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:ee()}function Ro(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/864e5+1)/7)}var Ct=class extends J{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=_s(ms(this.options.min)),this._max=_s(ms(this.options.max)),this._value=this._normalizeMonth(ms(this.options.value));let e=this._value??_s(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},_("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},_("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=s,t.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",r=>this._onMonthClick(r)),this.listen(this.refs.grid,"keydown",r=>this._onMonthKeydown(r)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(ms(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=_s(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._year,e,1),r=!!(this._value&&rh(s,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(r),ariaDisabled:String(!this._inRange(s)),ariaLabel:z(s,"%B %Y"),dataset:{month:e}},z(s,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let s=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")r=-3;else if(t.key==="ArrowDown")r=3;else if(t.key==="Home")r=-(s%3);else if(t.key==="End")r=2-s%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(s);return}if(r===null)return;t.preventDefault();let n=this._year*12+s+r;this._year=Math.floor(n/12),this._focusedMonth=(n%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function ms(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function _s(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function rh(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function Po(){S.register("month",(i,t)=>{let e=i.own(new Ct(null,{...t.props??{},value:t.value})),s=!1,r=()=>{e.el.setAttribute("aria-disabled",String(s));for(let n of e.el.querySelectorAll("button"))n.disabled=s};return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>i.emit("change",{value:n.detail.date})),{el:e.el,get:()=>e.get(),set:n=>{e.set(n instanceof Date?n:null,{silent:!0}),r()},focus:()=>e.focus(),setDisabled:n=>{s=!!n,r()}}})}var nh=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function Y(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=nh.has(e.placement)?e.placement:"bottom-start",r=Number(e.offset??4),n=e.flip??!0,o=e.matchWidth??!1,a=i.getAttribute("style"),c=t.getAttribute("style"),h=t.getAttribute("popover"),u=!1,d=null,p=()=>{},f=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let x=`--${y("zx-a")}`;i.style.setProperty("anchor-name",x),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",x);let v=oh(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",v),t.style.setProperty("inset-area",v),t.style.setProperty("position-try-fallbacks",n?"flip-block, flip-inline, flip-block flip-inline":"none");let b=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(b,`${r}px`),p=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(p),d.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",p=()=>ah(i,t,{placement:s,offset:r,flip:n,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(d=new ResizeObserver(p),d.observe(i)),f=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return lh(t),p(),{update(){u||p()},destroy(){u||(u=!0,d?.disconnect(),f(),ch(t),Fr(i,"style",a),Fr(t,"style",c),Fr(t,"popover",h))}}}function oh(i,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function ah(i,t,{placement:e,offset:s,flip:r,matchWidth:n}){let o=i.getBoundingClientRect();n&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,h=document.documentElement.clientHeight||window.innerHeight,u=e,d=Bo(e),p=o.bottom+s,f=o.top-s-a.height,g=o.right+s,x=o.left-s-a.width;r&&(d==="bottom"&&p+a.height>h&&f>=0?u=gs(e,"bottom","top"):d==="top"&&f<0&&p+a.height<=h?u=gs(e,"top","bottom"):d==="right"&&g+a.width>c&&x>=0?u=gs(e,"right","left"):d==="left"&&x<0&&g+a.width<=c&&(u=gs(e,"left","right")));let v=Bo(u),b,w;if(v==="bottom"||v==="top"){let D=getComputedStyle(i).direction==="rtl";u.endsWith("-end")?b=D?o.left:o.right-a.width:u.endsWith("-start")?b=D?o.right-a.width:o.left:b=o.left+(o.width-a.width)/2,w=v==="bottom"?p:f}else b=v==="right"?g:x,u.endsWith("-end")?w=o.bottom-a.height:u.endsWith("-start")?w=o.top:w=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(M(b,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(M(w,0,Math.max(0,h-a.height)))}px`}function Bo(i){return i.split("-")[0]}function gs(i,t,e){return i.replace(t,e)}function lh(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function ch(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Fr(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var hh=6,Ko=864e5;function Ht(i,t){let e=W(Vt(i)),s=W(Vt(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function re(i,t){let e=Ht(i,t);return!e.start||!e.end?0:Math.round((Vo(e.end)-Vo(e.start))/Ko)}function Pr(i,t,e){let s=W(Vt(i));if(!s)return null;let r=Ht(t,e);return!r.start&&!r.end?null:r.end?r.start?s.getTime()<r.start.getTime()||s.getTime()>r.end.getTime()?null:L(s,r.start)?"start":L(s,r.end)?"end":"middle":L(s,r.end)?"end":null:L(s,r.start)?"start":null}function ne(i,t={}){let e=W(Vt(t.min)),s=W(Vt(t.max)),r=bs(t.minNights)??0,n=bs(t.maxNights),{start:o,end:a}=Ht(i?.start,i?.end);return o&&(o=Rr(o,e,s)),a&&(a=Rr(a,e,s)),!o||!a?{start:o,end:a}:(n!==null&&re(o,a)>n&&(a=E(o,n)),r>0&&re(o,a)<r&&(a=E(o,r),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=E(a,-r),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var oe=class extends m{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=_h(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=W(Vt(this.options.min)),this._max=W(Vt(this.options.max)),this._minNights=bs(this.options.minNights)??0,this._maxNights=bs(this.options.maxNights),this._weekStart=fh(this.options.weekStart),this._monthCount=ph(this.options.months),this._presets=dh(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=ne({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=Tt(this._start)??this._clampFocus(W(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",O("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let s=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:O("daterange.presets","Date range presets")},this._presets.map(n=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:n.name}},n.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),r=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,r],t.append(s,r),this.refs.presets&&this.listen(this.refs.presets,"click",n=>this._onPresetClick(n)),this.listen(this.refs.calendars,"click",n=>this._onCalendarClick(n)),this.listen(this.refs.calendars,"keydown",n=>this._onDayKeydown(n)),this.listen(this.refs.calendars,"mouseover",n=>this._onDayHover(n)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:Tt(this._start),end:Tt(this._end)}}set(t={},{silent:e=!1}={}){let s=ne({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=Tt(s.start),this._setView(s.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],gh(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(t){let e=W(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let s=re(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=W(t);if(this._disabled||!e||!this._selectable(e))return;this._picking&&this._start&&e.getTime()>this._start.getTime()?(this._end=e,this._picking=!1,this._remember()):(this._start=e,this._end=null,this._picking=!0),this._focused=e,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let t=!!(this._start&&this._end);this._committedStart=t?Tt(this._start):null,this._committedEnd=t?Tt(this._end):null}_abandon(){return this._picking?(this._start=Tt(this._committedStart),this._end=Tt(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Rr(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let s of t)s.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),s=Ho(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let r=s<0?s:s-(e-1),n=new Date(this._viewYear,this._viewMonth+r,1);return this._viewYear=n.getFullYear(),this._viewMonth=n.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),s=Ho(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let r=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),r))}_moveFocus(t){let e=W(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let s=this._presets.find(n=>n.name===e.dataset.preset);if(!s)return;let r=s.range();this.set({start:r?.start??null,end:r?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,s=e?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let r=this._cellFor(e);r&&this._choose(r.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?W(t):null;!e&&!this._hover||e&&this._hover&&L(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,r=null;if(t.key==="ArrowLeft")r=E(s,-1);else if(t.key==="ArrowRight")r=E(s,1);else if(t.key==="ArrowUp")r=E(s,-7);else if(t.key==="ArrowDown")r=E(s,7);else if(t.key==="PageUp")r=bt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=bt(s,t.shiftKey?12:1);else if(t.key==="Home")r=E(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=E(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(s);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!r||this._disabled||(t.preventDefault(),this._moveFocus(r))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=z(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,r=E(t,-s),n=[];for(let o=0;o<hh;o+=1){let a=E(r,o*7),c=l("tr"),h=mh(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:h?O("daterange.week","Week %1",[$o(a)]):null},h?String($o(a)):""));for(let u=0;u<7;u+=1){let d=E(a,u),p=l("td",{role:"presentation"});if(d.getMonth()===t.getMonth()&&d.getFullYear()===t.getFullYear()){let f=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:z(d,"%Y-%m-%d")}},z(d,"%e"));p.append(f),this._dayCells.push({date:d,cell:p,button:f})}c.append(p)}n.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:O("daterange.previousMonth","Previous month")},_("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:O("daterange.nextMonth","Next month")},_("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...n)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:O("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let r=E(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:z(r,"%A")},z(r,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)L(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:r,cell:n,button:o}=s,a=this._dayState(r);Lr(n,"range",a.range),Lr(n,"rangeEdge",a.edge),Lr(o,"range",a.range),o.tabIndex=s===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(r))),o.setAttribute("aria-label",this._dayLabel(r,a.range)),L(r,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=Pr(t,this._start,this._end);if(!s)return{range:null,edge:null};let r=L(this._start,this._end);return s==="start"?{range:s,edge:r?"both":"start"}:s==="end"?{range:s,edge:r?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return L(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:L(t,e)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let t=this._hover??this._focused;if(!t)return null;let e=W(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=z(t,"%A, %e %B %Y");return e==="start"?`${s}, ${O("daterange.day.start","range start")}`:e==="end"?`${s}, ${O("daterange.day.end","range end")}`:e==="middle"?`${s}, ${O("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return O("daterange.status.empty","No date range selected");if(!this._end)return O("daterange.status.start","%1 selected, choose an end date",[z(this._start,"%e %B %Y")]);let t=re(this._start,this._end),e=t===1?O("daterange.night","1 night"):O("daterange.nights","%1 nights",[t]);return`${uh(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(s=>s.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>L(e.date,t))?.button??null}};function Br(){return[{name:"today",label:O("daterange.preset.today","Today"),range:()=>qo(pt())},{name:"yesterday",label:O("daterange.preset.yesterday","Yesterday"),range:()=>qo(E(pt(),-1))},{name:"last7",label:O("daterange.preset.last7","Last 7 days"),range:()=>({start:E(pt(),-6),end:pt()})},{name:"last30",label:O("daterange.preset.last30","Last 30 days"),range:()=>({start:E(pt(),-29),end:pt()})},{name:"thisMonth",label:O("daterange.preset.thisMonth","This month"),range:()=>jo(pt(),0)},{name:"lastMonth",label:O("daterange.preset.lastMonth","Last month"),range:()=>jo(pt(),-1)},{name:"thisQuarter",label:O("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=pt(),t=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),t,1),end:new Date(i.getFullYear(),t+3,0)}}},{name:"thisYear",label:O("daterange.preset.thisYear","This year"),range:()=>{let i=pt();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function O(i,t,e){let s=G(i);return F(s===i?t:s,e)}function uh(i,t){if(L(i,t))return z(i,"%e %B %Y");let e=z(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${z(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${z(i,"%e %B")} \u2013 ${e}`:`${z(i,"%e")} \u2013 ${e}`}function dh(i){return i===!0?Br():Array.isArray(i)?i.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function pt(){return W(new Date)}function qo(i){return{start:i,end:new Date(i.getTime())}}function jo(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function Vt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function W(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function Tt(i){return i?new Date(i.getTime()):null}function Rr(i,t,e){return t&&i.getTime()<t.getTime()?new Date(t.getTime()):e&&i.getTime()>e.getTime()?new Date(e.getTime()):new Date(i.getTime())}function Vo(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function Ho(i){return i.getFullYear()*12+i.getMonth()}function bs(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function fh(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:ee()}function ph(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function mh(i,t){for(let e=0;e<7;e+=1){let s=E(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function $o(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/Ko+1)/7)}function Lr(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function _h(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function gh(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var bh={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ys(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let r=String(e??" \u2013 "),n=r.trim(),o=n!==""&&String(t).includes(n)&&/^\s|\s$/.test(r),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",h=n===""?[s]:s.split(new RegExp(`${a}${Xt(n)}${c}`));if(h.length>2)return null;let u=$(h[0].trim(),t);if(!u)return null;if(h.length===1)return{start:u,end:new Date(u.getTime())};if(h[1].trim()==="")return{start:u,end:null};let d=$(h[1].trim(),t);return d?Ht(u,d):null}function jr(i,t,e){let s=i?.start??null,r=i?.end??null;return!s&&!r?"":r?s?`${z(s,t)}${e}${z(r,t)}`:z(r,t):z(s,t)}var ae=class extends m{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=y("zx-date-range-box-popover"),s=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:Uo("daterange.clear","Clear date range")},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Uo("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},_("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new oe(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",r=>{this._range={start:r.detail.start,end:r.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",r=>{this._apply({start:r.detail.start,end:r.detail.end},{push:!1}),r.detail.start&&r.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=Y(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),qr(this.el,"data-state",this._originalState),qr(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:s=!0}={}){this._range=t,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=ys(t,this._format,this._separator);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this._apply(this._clamp(e))}_coerce(t){return t==null?{start:null,end:null}:typeof t=="string"?this._clamp(ys(t,this._format,this._separator)??{start:null,end:null}):Array.isArray(t)?this._clamp({start:this._toDate(t[0]),end:this._toDate(t[1])}):typeof t!="object"?{start:null,end:null}:this._clamp({start:this._toDate(t.start),end:this._toDate(t.end)})}_toDate(t){return t instanceof Date?Number.isNaN(t.getTime())?null:new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?new Date(t*1e3):typeof t=="string"&&t.trim()!==""?$(t.trim(),this._format):null}_clamp(t){return ne(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>bh[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=jr(this._range,this._format,this._separator),this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&qr(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}};function Uo(i,t,e){let s=G(i);return F(s===i?t:s,e)}function qr(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function Yo(){S.register("daterange",(i,t)=>{let e=i.own(new ae(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:e.el,get:()=>e.get(),set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var q=class extends m{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=yh(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Wo(this.options.min),this._max=Wo(this.options.max),this._value=this._normalizeValue(this.options.value);let e=y("zx-datebox-popover"),s=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??xh(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},_("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new J(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=Y(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=$(t,this._format);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this.set(e)}_normalizeValue(t){let e=null;return t instanceof Date&&!Number.isNaN(t.getTime())?e=new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?e=new Date(t*1e3):typeof t=="string"&&(e=$(t,this._format)),!e||Number.isNaN(e.getTime())?null:cs(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?z(this._value,this._format):"",this.refs.clear.hidden=!this.options.clearable||!this._value}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled))}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},xs=function(t,e={}){return new q(t,{...e,time:!0})};function Wo(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function yh(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function xh(i){return i.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function Qo(){Go("date",i=>new q(null,i)),Go("datetime",i=>xs(null,i))}function Go(i,t){S.register(i,(e,s)=>{let r=e.own(t({...s.props??{},value:s.value}));return e.listen(r.el,"change",n=>n.stopImmediatePropagation()),r.on("change",n=>e.emit("change",{value:n.detail.date})),{el:r.el,get:()=>r.get(),set:n=>r.set(n,{silent:!0}),focus:()=>r.focus(),setDisabled:n=>n?r.disable():r.enable()}})}var Et=class extends m{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=y("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},vh(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:s}),s)}catch(s){if(e!==this._runId)return null;let r=s instanceof Error?s:new Error(String(s));return r.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=r.message,this.emit("error",{error:r}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let r=s.find(o=>!Sh(o,this.options.accept));if(r)return this._selectionError(new Error(`${r.name} is not an accepted file type.`)),!1;let n=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return n?(this._selectionError(new Error(`${n.name} exceeds the maximum file size.`)),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:s=>this._setProgress(s)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let s=new XMLHttpRequest;this._xhr=s,s.open("POST",String(this.options.url));for(let[r,n]of Object.entries(this.options.headers??{}))s.setRequestHeader(r,String(n));this.listen(s.upload,"progress",r=>{r.lengthComputable&&this._setProgress(r.loaded/r.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(zh(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(kh())),s.send(Ah(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function vh(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${wh(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function wh(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function Sh(i,t){if(!t)return!0;let e=String(i.type??"").toLowerCase();return String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?e.startsWith(s.slice(0,-1)):e===s)}function Ah(i,t,e){let s=new FormData;for(let r of i)s.append(t,r);for(let[r,n]of Object.entries(e??{}))Zo(s,r,n);return s}function Zo(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let r of e)Zo(i,t,r);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function zh(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function kh(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function Jo(){S.register("upload",(i,t)=>{let e=i.own(new Et(null,{...t.props??{}}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("select",()=>i.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>e.setDisabled(s)}})}var Xo=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ta=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Dt=class extends m{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return Xo[this.options.reorder]??Xo.both}_renderRows(t=-1,e="value"){let s=ea(this.options.options),r=this.options.options!==null,{drag:n,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((h,u)=>{let d=!r||s.some(([f])=>f===h)?s:[[h,h],...s],p=r?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},d.map(([f,g])=>l("option",{value:f,selected:f===h},g))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:h,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},n?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},_("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},_("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===a),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},_("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},_("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ta[e]??ta.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let s=e.dataset.action,r=Number(e.dataset.index);if(s==="add"){let n=ea(this.options.options);this._values.push(this.options.options===null?"":n[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(r)?(this._values.splice(r,1),this._renderRows(Math.min(r,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(r)&&this._move(r,r+(s==="up"?-1:1),s)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let s=Number(e.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let s=Number(e.dataset.index),r=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;r<0||r>=this._values.length||(t.preventDefault(),this._move(s,r,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let s=e.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,s=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,s>e?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[s,r]of e.entries()){let n=r.getBoundingClientRect();if(t<n.top+n.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[r,n]of e.entries()){let o=n;!s&&r===t?o.dataset.drop="before":!s&&t===e.length&&r===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,s){let r=this._values.length;if(t===e||t<0||e<0||t>=r||e>=r)return!1;let[n]=this._values.splice(t,1);return this._values.splice(e,0,n),this._renderRows(e,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function ea(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}function sa(){S.register("multivalueeditor",(i,t)=>{let e=i.own(new Dt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(r));for(let o of e.el.querySelectorAll("input, button, select, textarea"))r?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>i.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),n()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{r=!!o,n()}}})}var Nt=class extends m{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t;let e=Ch(this.options.step);this._step=e,this._precision=this.options.precision===null?Th(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),r=this._stepButton("up","plus"),n=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[s,n];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(r),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",a=>this._onKeydown(a)),this.listen(n,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(n,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(r,"click",()=>this._stepBy(1)),this.listen(n,"wheel",a=>{document.activeElement!==n||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._coerce(t),r=s!==this._value;return this._value=s,this._syncInput(),r&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},_(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=Be(t,this.options.group?this._separators():null);return e===null?null:qe(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,s=this._rangeMax,n=Be(this.refs.input.value)??this._value,o=n===null?e??0:n,a=n===null&&t>0&&e!==null?e-this._step*t:o,c=ia(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&s!==null&&(c>s?c=e:c<e&&(c=s)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=Be(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),r={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];r&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),r()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,s=this._rangeMin,r=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),r===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(r)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let n=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${n}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let s=this.msg(t);return s===t?e:s}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};function Be(i,t=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let e=String(i).trim();if(e==="")return null;let s;if(t)s=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let n=e.replace(/[^\d,.\-+eE]/g,""),o=n.lastIndexOf(","),a=n.lastIndexOf(".");s=n,o>=0&&o>a?s=n.replace(/\./g,"").replace(",","."):o>=0&&(s=n.replace(/,/g,""))}if(!/\d/.test(s))return null;let r=Number(s);return Number.isFinite(r)?r:null}function qe(i,{min:t,max:e,step:s,precision:r}){let n=i;if(s>0){let o=t??0;n=o+Math.round((i-o)/s)*s}return n=ia(n,r),t!==null&&n<t?t:e!==null&&n>e?e:n}function Ch(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Th(i){let t=String(i),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let s=t.split(".")[1];return s?s.length:0}function ia(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function ra(){S.register("number",(i,t)=>{let e=i.own(new Nt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),s=!1;return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(r===""||r===null||r===void 0?null:r,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var le=class extends m{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=y("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let s=1;s<=this._max;s+=1){let r=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},_(this.options.icon,{size:je[this.options.size]??je.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},_(this.options.icon,{size:je[this.options.size]??je.md})));this.options.allowHalf?r.append(this._radio(s-.5,"half"),this._radio(s,"full")):r.append(this._radio(s,"full")),e.append(r)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=je[this.options.size]?this.options.size:"md",this.listen(e,"keydown",s=>this._onKeydown(s)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._clamp(t),r=s!==this._value;return this._value=s,this._preview=null,this._sync(),r&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let s=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(s,"click",r=>{this._choose(t,r.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(t)),this.listen(s,"focus",()=>this._setPreview(t)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let s=Math.round(t/this._step)-1;if(e[s]!=null)return String(e[s])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,s){let r=this.msg(t,...s);return r===t?F(e,s):r}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let s=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let e of this._radios){let s=Number(e.dataset.value);e.setAttribute("aria-checked",String(s===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,r)=>{let n=Math.min(1,Math.max(0,t-r));s.style.setProperty("--zx-rating-fill",`${n*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(Eh(this._value,this._step)),e!=null&&s.push(this._message("rating.count","%1 ratings",[e])),t.textContent=s.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}},je={sm:14,md:18,lg:24};function Eh(i,t){return t<1?i.toFixed(1):String(i)}function na(){S.register("rating",(i,t)=>{let e=i.own(new le(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get()||null,set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Dh=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function vs(i){let t=!1,e=null;function s(r){if(r.key!=="Tab")return;let n=oa(i);if(n.length===0){r.preventDefault();return}let o=n[0],a=n[n.length-1];r.shiftKey&&(document.activeElement===o||!i.contains(document.activeElement))?(r.preventDefault(),a.focus()):!r.shiftKey&&(document.activeElement===a||!i.contains(document.activeElement))&&(r.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",s),oa(i)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",s),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function mt(i,t,{orientation:e="vertical",wrap:s=!0}={}){let r=new AbortController,n=new Map,o=!1;function a(){return Array.from(i.querySelectorAll(t)).filter(f=>(c(f),aa(f)))}function c(f){n.has(f)||n.set(f,f.getAttribute("tabindex"))}function h(f=null){let g=a(),x=f&&g.includes(f)?f:g.find(v=>v.tabIndex===0)??g[0];for(let v of g){let b=v===x?0:-1;v.tabIndex!==b&&(v.tabIndex=b)}}function u(f){let g=a(),x=f.target?.closest?.(t)??null,v=g.indexOf(x);if(v<0)return;let b=e==="horizontal"?"ArrowLeft":"ArrowUp",w=e==="horizontal"?"ArrowRight":"ArrowDown",D=null;f.key==="Home"?D=0:f.key==="End"?D=g.length-1:f.key===b?D=v-1:f.key===w&&(D=v+1),!(D===null||g.length===0)&&(s?D=(D+g.length)%g.length:D=Math.max(0,Math.min(g.length-1,D)),f.preventDefault(),h(g[D]),g[D].focus())}function d(f){let g=f.target?.closest?.(t)??null;g&&i.contains(g)&&h(g)}i.addEventListener("keydown",u,{signal:r.signal}),i.addEventListener("focusin",d,{signal:r.signal});let p=typeof MutationObserver=="function"?new MutationObserver(()=>h()):null;return p?.observe(i,{childList:!0,subtree:!0,attributes:!0}),h(),{focusFirst(){let f=a()[0];f&&(h(f),f.focus())},focusLast(){let f=a(),g=f[f.length-1];g&&(h(g),g.focus())},destroy(){if(!o){o=!0,r.abort(),p?.disconnect();for(let[f,g]of n)g===null?f.removeAttribute("tabindex"):f.setAttribute("tabindex",g);n.clear()}}}}function X(i,t){let e="",s=null;return function(n){let o=typeof n=="string"?n:n.key;if(typeof n!="string"&&(n.ctrlKey||n.metaKey||n.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(h=>h===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let a=i(),c=a.findIndex(h=>Nh(h).startsWith(e));c>=0&&t(a[c],c)}}function oa(i){return Array.from(i.querySelectorAll(Dh)).filter(t=>aa(t)&&t.getClientRects().length>0)}function aa(i){return!(!(i instanceof HTMLElement)||i.hidden||i.getAttribute("aria-hidden")==="true"||i.matches(":disabled"))}function Nh(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let t=i,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var Ih=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Mh=["Lowest","Low","Normal","High","Highest"],R=class i extends m{static cssName="select";static defaults={items:[],fixedItems:[],valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,value:null,disabled:!1,placeholder:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes)),this._rememberAttribute(t,"data-state"),this._rememberAttribute(t,"data-loading"),this._rememberAttribute(t,"aria-disabled");let e=y("zx-select-list"),s=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},_("x",{size:13})),n=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),o=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},_("chevron-down",{size:16})),a=l("div",{ref:"control",class:"zx-select__control"},s,r,n,o),c=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});c.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},c);return t.replaceChildren(a,h),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._disabled=!!this.options.disabled,this._handleTypeahead=X(()=>this._optionEntries.filter(u=>!u.clear).map(u=>u.element),(u,d)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(d))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",u=>this._onKeydown(u)),this.listen(o,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",u=>u.preventDefault()),this.listen(h,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let s=this.value,r=t==null?null:this._findItem(t);this._selected=r,this._syncInputValue(),this._renderOptions();let n=this.value;return!e&&!Object.is(s,n)&&this.emit("change",{value:n,item:r}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=Y(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let s=e.value??null,r=new i(t,{...e,value:null,items:[],renderItem(n){return l("span",{class:"zx-select__priority"},l("span",{class:"zx-select__priority-icon",dataset:{level:n.level},ariaHidden:"true"}),l("span",{},String(n.name)))}});return r.setItems(Ih.map((n,o)=>({ID:o,name:r._message(n,Mh[o]),level:o}))),r.set(s,{silent:!0}),r}static permission(t,e={}){let{groups:s=[],value:r=!0,valueKey:n="ID",labelKey:o="name",...a}=e,c=typeof s=="function"?s:null,h=c?[]:s,u=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],d=new i(t,{filter:c??"local",...a,value:null,items:h,fixedItems:[],valueKey:p=>u.includes(p)?p.ID:Vr(p,n),labelKey:p=>u.includes(p)?p.name:String(Vr(p,o)??"")});return u[0].name=d._message("permission.private","Private"),u[1].name=d._message("permission.public","Public"),d.setFixedItems(u),d.set(r,{silent:!0}),d}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_onKeydown(t){if(!this._disabled){if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&Oh(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=kt(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){t&&(this.set(t.clear?null:t.item),this.close(),this.focus())}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((s,r)=>{r===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group");this.options.clearable&&this._appendOption(null,!0,this.options.placeholder||this._message("select.none","No selection"));for(let s of this._visibleFixed)this._appendOption(s,!1);this._visibleFixed.length>0&&this._visibleItems.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let s of this._visibleItems){if(this.options.groupKey){let r=this._read(s,this.options.groupKey);Object.is(r,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(r??""))),e=r)}this._appendOption(s,!1)}this._visibleItems.length===0&&this._visibleFixed.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,s){let r=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),n=this._optionEntries.length,o=e?String(s??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:y("zx-select-option"),role:"option",ariaSelected:String(r),dataset:{index:n}},l("span",{class:"zx-select__option-content"},o));r&&a.append(_("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,element:a})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return e&&typeof e=="object"&&"nodeType"in e?e:String(e??"")}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},s)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,s=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=e.find(n=>n===t);if(s!==void 0)return s;let r=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(n=>Object.is(this._itemValue(n),r))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return Vr(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return kt(this._fixedItems,t,this._searchKeys())}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_rememberAttribute(t,e){this._originalAttributes.set(e,t.getAttribute(e))}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Vr(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function Oh(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function la(){S.register("zxselect",(i,t)=>{let e=i.own(new R(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.value,set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var ce=class extends m{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=y("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=l("div",{class:"zx-slider__track"},e,this._marks()),r=l("div",{class:"zx-slider__control"});return this.options.showBounds&&r.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),r.append(s),this.options.showBounds&&r.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&r.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),r),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",n=>{this._readonly&&Fh.has(n.key)&&n.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._snap(t),r=s!==this._value;return this._value=s,this._paint(),r&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let r=Number(t),n=Number(e);if(!Number.isFinite(r)||!Number.isFinite(n)||n<=r)throw new RangeError("Slider range requires min < max");this._min=r,this._max=n,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of t){let r=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(r))continue;let n=typeof s=="number"?this._format(r):String(s.label??this._format(r));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(r)*100}%`}},n))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?qe(e,{min:this._min,max:this._max,step:this._step,precision:Hr(this._step)}):this._min}_ratio(t){return M((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Lh(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}},Fh=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Hr(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Lh(i){return String(Number(i.toFixed(6)))}function ca(){S.register("slider",(i,t)=>{let e=i.own(new ce(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var he=class extends m{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t;let e=y("zx-tag-picker-list"),s=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),r=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),n=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},_("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},s,r,n),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",h=>{let u=h.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(h.target!==r&&(h.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",h=>{let u=h.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;h.stopPropagation();let d=[...s.children].indexOf(u.closest(".zx-tag-picker__tag")),p=this._selected[d];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",h=>this._onKeydown(h)),this.listen(r,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(r,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(n,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",h=>h.preventDefault()),this.listen(c,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._open&&!t.contains(h.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let s=Array.isArray(t)?t:[],r=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),n=[];for(let a of s){if(n.length>=r)break;let c=this._resolve(a);c!==null&&!n.some(h=>this._sameValue(h,c))&&n.push(c)}let o=!Rh(n,this._selected,a=>this._valueOf(a));return this._selected=n,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let s=this._resolve(t);return s===null?this:this._selected.some(r=>this._sameValue(r,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let s=this._valueOf(this._resolve(t)??t),r=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(r<0)return this;let[n]=this._selected.splice(r,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(n),item:n}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=Y(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),r=this.options.renderTag?this.options.renderTag(e):s,n=l("span",{class:"zx-tag-picker__tag"},l("span",{class:"zx-tag-picker__tag-label"},r));return!this._readonly&&!this._disabled&&n.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},_("x",{size:11}))),n});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let n of this._visible){let o=this._valueOf(n),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?_("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(n):this._labelOf(n)));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:n,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let n=l("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},_("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:n,create:!0}),e.push(n)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let r=this._entries.findIndex(n=>this._entryId(n)===this._activeId);this._setActive(r>=0?r:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let s=this._entries.find(r=>r.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),r=this._createItem(s);this._items=this._items.concat([r]),this.addValue(r),this.emit("create",{value:this._valueOf(r),item:r})}else{let s=this._valueOf(t.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,s]of this._entries.entries()){let r=e===t;s.element.toggleAttribute("data-active",r),r&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=kt(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},s)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=s=>s.some(r=>ha(this._labelOf(r))===ha(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),s=this._items.find(n=>Object.is(this._valueOf(n),e));if(s!==void 0)return s;let r=this._selected.find(n=>Object.is(this._valueOf(n),e));return r!==void 0?r:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,s=[]){let r=this.msg(t,...s);return r!==t?r:s.reduce((n,o,a)=>n.replaceAll(`%${a+1}`,String(o)),e)}};function ha(i){return String(i??"").trim().toLocaleLowerCase()}function Rh(i,t,e){return i.length!==t.length?!1:i.every((s,r)=>Object.is(e(s),e(t[r])))}function ua(){S.register("tagpicker",(i,t)=>{let e=i.own(new he(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.values})}),{el:e.el,get:()=>e.getValues(),set:r=>{s=!0;try{e.setValues(Array.isArray(r)?r:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}function $r(i,t="minutes"){let e=Math.round(Math.abs(da($t(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:$t(i)<0}}function Kr(i,t="minutes"){Ve(t);let e=Math.abs(Math.trunc($t(i?.hours))),s=Math.abs(Math.trunc($t(i?.minutes))),r=Math.abs(Math.trunc($t(i?.seconds))),n=i?.negative?-1:1;return fa(n*(e*3600+s*60+r),t)}var tt=class extends m{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){Ve(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return Kr(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),Ve(e);let r=$t(t);return!this.options.signed&&r<0&&(r=0),this.options.seconds||(r=fa(Math.round(da(r,e)/60)*60,e)),this._parts=$r(r,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,s,r){let n=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:r?2:null,dataset:{segment:e,bounded:String(r)}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"input",()=>{e==="hours"&&this.options.signed&&n.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=n.value.replace(/\D/g,"");n.value=r?o.slice(0,2):o}),this.listen(n,"change",()=>this._commitSegments()),this.listen(n,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),n.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,r=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(r,Math.trunc($t(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):Ph(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}};function $t(i){let t=Number(i);return Number.isFinite(t)?t:0}function da(i,t){return Ve(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function fa(i,t){return Ve(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function Ve(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function Ph(i){return String(i).padStart(2,"0")}function pa(){S.register("time",(i,t)=>{let e=i.own(new tt(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.get(),set:s=>e.set(Number(s)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var H=class extends m{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:Bh(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&qh(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Bh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function qh(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function ma(){S.register("toggle",(i,t)=>{let e=i.own(new H(null,{...t.props??{},checked:!!t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.getValue(),set:s=>e.set(!!s,{silent:!0}),focus:()=>e.el.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var It=class extends m{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=_a(this.options.values,!!this.options.unique);let e=y("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",s=>{s.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=_a(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(e);if(s!==!0)return this._showError(typeof s=="string"?s:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((s,r)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${s}. Press Delete to remove.`:s,dataset:{index:r}},l("span",{class:"zx-value-list__value"},s),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let s=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let r=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=r||n;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&r&&this.options.sortable?this._move(s,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,s=e?.closest("[data-index]");!s||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,s=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,s){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[r]=this._values.splice(t,1);this._values.splice(e,0,r),this._renderChips(s?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[s]=this._values.splice(t,1);s!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function _a(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function ga(){S.register("valuelist",(i,t)=>{let e=i.own(new It(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.values})),{el:e.el,get:()=>e.getValues(),set:s=>e.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var Kt=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),jh=["xl","lg","md","sm"];function ws(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of jh)if(t>=Kt[e])return e;return"xs"}function Ss(i,t){if(i==="xs")return!0;let e=Kt[i];if(e===void 0)throw new RangeError(`Unknown breakpoint "${i}"`);return Number(t)>=e}function ue(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!N(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=N(e)?e:null,r=null,n=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(n)return;let d=a();if(s&&d===0)return;let p=ws(d);p!==r&&(r=p,i(r,d))};c();let h=0,u=()=>{h||n||(h=requestAnimationFrame(()=>{h=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>r??ws(a()),destroy:()=>{n||(n=!0,h&&cancelAnimationFrame(h),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var ot=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:s=null,timeout:r=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=s,this.timeout=Number(r)}async request(t,e={}){let{method:s="GET",data:r=null,files:n=null,query:o=null,headers:a={}}=e,c=new AbortController,h=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[f,g]of Object.entries(a))u.set(f,g);u.set("Accept",u.get("Accept")??"application/json");let d;n!==null?(d=Hh(r,n),u.delete("Content-Type")):r!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(d=JSON.stringify(r),u.set("Content-Type",u.get("Content-Type")??"application/json"));let p=Vh(this.base+t,o);try{let f=await fetch(p,{method:s.toUpperCase(),headers:u,body:d,signal:c.signal}),g=await f.text(),x=null;if(g!=="")try{x=JSON.parse(g)}catch(v){let b=new Error("Invalid JSON response",{cause:v});throw b.response=f,b}if(!f.ok){try{As(x)}catch(b){throw b.response=f,b}let v=new Error(`HTTP ${f.status} ${f.statusText}`.trim());throw v.response=f,v}return As(x)}catch(f){let g=f instanceof Error?f:new Error(String(f));if(this.onError)try{this.onError(g,{path:t,options:e})}catch{}throw g}finally{h!==null&&clearTimeout(h)}}get(t,e=null){return this.request(t,{method:"GET",query:e})}post(t,e=null){return this.request(t,{method:"POST",data:e})}put(t,e=null){return this.request(t,{method:"PUT",data:e})}delete(t,e=null){return this.request(t,{method:"DELETE",data:e})}};function Ut(i,t="",e={}){let{apiBase:s="../remotecall/",...r}=e,n=`${s}${i}${t?`:${t}`:""}/`;return new ot({...r,base:n})}function As(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null){let t=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function Vh(i,t){if(t==null)return i;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let s=new URLSearchParams;for(let[r,n]of Object.entries(t))ba(s,r,n);e=s.toString()}return e?i+(i.includes("?")?"&":"?")+e:i}function ba(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)ba(i,t,s);else i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Hh(i,t){let e=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[r,n]of Object.entries(i))ya(e,r,n);else i!=null&&e.append("data",typeof i=="string"?i:JSON.stringify(i));let s=$h(t)||Array.isArray(t)?Array.from(t):[t];for(let r of s)e.append("files",r);return e}function ya(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)ya(i,t,s);else{let s=typeof Blob=="function"&&e instanceof Blob;i.append(t,typeof e=="object"&&!s?JSON.stringify(e):e)}}function $h(i){return typeof FileList=="function"&&i instanceof FileList}var Kh=0,Uh=20,Yh=3,Wh=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Gh=["B","kB","MB","GB","TB","PB","EB"],Ur=[{unit:"second",ms:1e3,limit:45},{unit:"minute",ms:6e4,limit:45},{unit:"hour",ms:36e5,limit:22},{unit:"day",ms:864e5,limit:6},{unit:"week",ms:6048e5,limit:4},{unit:"month",ms:26298e5,limit:11},{unit:"year",ms:315576e5,limit:1/0}],xa=new Map,va=new Map;function Mt(i,t={}){let e=Cs(i);if(e===null)return"";let{locale:s=Z(),decimals:r,minDecimals:n,maxDecimals:o,group:a=!0}=t;return Yr(s,Wr({decimals:r,minDecimals:n,maxDecimals:o,group:a}),e)}function zs(i,t,e={}){let s=Cs(i);if(s===null)return"";let{locale:r=Z(),decimals:n}=e,o=Jh(t);if(o===null)return Mt(s,{locale:r,decimals:n});let a=Wr({decimals:n,group:!0});return Yr(r,{...a,style:"currency",currency:o},s)}function ks(i,t={}){let e=Cs(i);if(e===null)return"";let{locale:s=Z(),decimals:r=0}=t;return Yr(s,{...Wr({decimals:r,group:!0}),style:"percent"},e)}function Aa(i,t={}){let e=Cs(i);if(e===null)return"";let{locale:s=Z(),decimals:r=1,standard:n="iec"}=t;if(e===0)return`${Mt(0,{locale:s,decimals:0})} B`;let o=n==="si"?Gh:Wh,a=n==="si"?1e3:1024,c=Math.abs(e),h=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),u=c/a**h;Xh(u,h===0?0:r)>=a&&h<o.length-1&&(h+=1,u=c/a**h);let d=e<0?-u:u;return`${Mt(d,{locale:s,minDecimals:0,maxDecimals:h===0?0:r})} ${o[h]}`}function za(i,t={}){let e=Sa(i);if(e===null)return"";let{now:s=new Date,locale:r=Z(),numeric:n="auto"}=t,o=Sa(s);if(o===null)return"";let a=e.getTime()-o.getTime(),c=Ur.find(({ms:u,limit:d})=>Math.abs(a)/u<d)??Ur[Ur.length-1],h=Math.round(a/c.ms);return Zh(r,n).format(h,c.unit)}function Yr(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,r=xa.get(s);return r===void 0&&(r=Qh(i,t),xa.set(s,r)),r.format(e)}function Qh(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Zh(i,t){let e=`${i}\0${t}`,s=va.get(e);if(s===void 0){try{s=new Intl.RelativeTimeFormat(i,{numeric:t})}catch{s=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}va.set(e,s)}return s}function Wr({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let r={useGrouping:s!==!1},n=wa(t??i),o=wa(e??i);return n!==null&&(r.minimumFractionDigits=n),o!==null?(r.maximumFractionDigits=o,n!==null&&n>o&&(r.minimumFractionDigits=o)):n!==null&&(r.maximumFractionDigits=Math.max(n,Yh)),r}function wa(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(Uh,Math.max(Kh,Math.round(t))):null}function Cs(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function Jh(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Sa(i){if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isFinite(i)?new Date(i*1e3):null;if(typeof i=="string"){let t=i.trim();if(t==="")return null;let e=/^-?\d+$/.test(t)?new Date(Number(t)*1e3):new Date(t);return Number.isNaN(e.getTime())?null:e}return null}function Xh(i,t){let e=10**t;return Math.round(i*e)/e}var ka="zx:__probe__";function de(i,t={}){let{area:e="local"}=t,s=`zx:${String(i??"")}:`,r=new Map,n=tu(e),o=u=>{if(n!==null)try{return n.getItem(u)}catch{n=null}return r.has(u)?r.get(u):null},a=(u,d)=>{if(n!==null)try{n.setItem(u,d);return}catch{n=null}r.set(u,d)},c=u=>{if(n!==null)try{n.removeItem(u)}catch{n=null}r.delete(u)},h=()=>{if(n!==null)try{let u=[];for(let d=0;d<n.length;d+=1){let p=n.key(d);typeof p=="string"&&p.startsWith(s)&&u.push(p)}return u}catch{n=null}return[...r.keys()].filter(u=>u.startsWith(s))};return{get(u,d){let p=o(s+u);if(p==null)return d;try{return JSON.parse(p)}catch{return d}},set(u,d){let p;try{p=JSON.stringify(d)}catch{p=void 0}p===void 0?c(s+u):a(s+u,p)},remove(u){c(s+u)},keys(){return h().map(u=>u.slice(s.length))},clear(){for(let u of h())c(u)}}}function tu(i){let t=i==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(ka,"1"),e.removeItem(ka),e)}catch{return null}}var eu=["=","+","-","@"];function Ea(i,t,e={}){let{delimiter:s=",",header:r=!0,newline:n=`\r
2
- `}=e,o=iu(t),a=[];r&&a.push(o.map(c=>Ta(c.label,s,Ca(c.label))).join(s));for(let c of i??[]){let h=o.map(u=>{let d=typeof u.value=="function"?u.value(c):ru(c,u.id);return Ta(nu(d),s,Ca(d))});a.push(h.join(s))}return a.join(n)}function Da(i,t,e={}){let{type:s="text/plain;charset=utf-8"}=e,r=ou(t,s),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=String(i??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function Ts(i){let t=String(i??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return su(t)}function su(i){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=i,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:-1000px;opacity:0;pointer-events:none",document.body.append(e);let s=!1;try{e.select(),e.setSelectionRange(0,i.length),s=document.execCommand?.("copy")===!0}catch{s=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return s}function iu(i){return(i??[]).map(t=>{if(typeof t=="string")return{id:t,label:t};let e=String(t?.id??"");return{id:e,label:String(t?.label??e),value:t?.value}})}function ru(i,t){return i?.[t]}function nu(i){if(i==null)return"";if(i instanceof Date)return Number.isNaN(i.getTime())?"":i.toISOString();if(typeof i=="number")return Number.isFinite(i)?String(i):"";if(typeof i=="boolean")return i?"true":"false";if(typeof i=="object")try{return JSON.stringify(i)}catch{return String(i)}return String(i)}function Ca(i){return typeof i!="string"?!1:eu.includes(i.charAt(0))}function Ta(i,t,e=!1){let s=e?` ${i}`:i;return s.includes(t)||s.includes('"')||s.includes(`
3
- `)||s.includes("\r")?`"${s.replaceAll('"','""')}"`:s}function ou(i,t){if(typeof Blob=="function"&&i instanceof Blob)return i;let e=typeof i=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",i]:[i];return new Blob(e,{type:t})}var at=class extends m{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:au(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=Na(this.options.label),e.type="button";let s=[];return this.options.icon&&s.push(l("span",{class:"zx-check-button__icon",ariaHidden:"true"},l("span",{class:"zx-check-button__off"},_("square",{size:15})),l("span",{class:"zx-check-button__on"},_("check",{size:15})))),s.push(l("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=Na(t),this._sync(),this}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&lu(this.el,this._original))}_sync(){this.el.setAttribute("aria-pressed",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled),this.refs.label.textContent=this._checked?this._labels.on:this._labels.off}};function Na(i){return Array.isArray(i)?{on:String(i[0]??""),off:String(i[1]??"")}:{on:String(i??""),off:String(i??"")}}function au(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function lu(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var fe=class extends m{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1};#t;#e=!1;#s=!1;constructor(t=null,e={}){super(null,e),this.#i(this.options.width),Ia(this.refs.content,this.options.content),this.listen(this.el,"cancel",s=>{let r=this.emit("cancel");(!this.options.closable||r.defaultPrevented)&&s.preventDefault()}),this.listen(this.el,"close",()=>{if(!this._isRealClose())return;this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let s=this.#e?this.#t:this.el.returnValue||void 0;this.#t=void 0,this.#e=!1,this.emit("close",{result:s}),this.options.destroyOnClose&&!this.#s&&this.destroy()}),this.listen(this.el,"click",s=>{!this.options.lightDismiss||s.target!==this.el||!cu(this.el,s)||this.close()})}mountTarget(){return document.body}_show(){this.el.showModal()}_isRealClose(){return!0}render(){let t=l("dialog",{class:"zx-modal"},l("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this.mountTarget().append(t),t}open(){if(this.isOpen())return this;this.el.dataset.zxOverlayOrder=String(hu()),this.el.returnValue="";try{this._show()}catch(t){throw delete this.el.dataset.zxOverlayOrder,t}return this.el.dataset.state="open",this.emit("open"),this}close(t){return this.isOpen()?(this.#t=t,this.#e=!0,this.el.close(typeof t=="string"?t:""),this):this}setContent(t){return Ia(this.refs.content,t),this}isOpen(){return this.el.open}destroy(){this.#s||(this.#s=!0,this.isOpen()&&this.el.close(),super.destroy())}#i(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function Ia(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function cu(i,t){let e=i.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function hu(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}var uu=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),et=class i extends fe{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#s=[];#i="";#n=null;constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#i=String(this.options.title??""),this.#o(this.#i),this.#s=Es(this.options.buttons),this.#a(this.#s),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",s=>{let r=s.target.closest?.("[data-dialog-button]");if(!r||!this.refs.footer.contains(r))return;let n=this.#r[Number(r.dataset.dialogButton)];n&&this.#l(n)}),this.on("close",()=>this.#c())}#r=[];render(){let t=y("zx-dialog-title"),e=l("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},l("header",{class:"zx-dialog__header"},l("h2",{class:"zx-dialog__title",id:t,ref:"title"}),l("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:"Close",title:"Close"},"\xD7")),l("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),l("footer",{class:"zx-dialog__footer",ref:"footer"}));return e.dataset.state="closed",this.mountTarget().append(e),e}open(){return this.isOpen()?this:(this.#n=document.activeElement instanceof Element?document.activeElement:null,super.open(),queueMicrotask(()=>{if(!this.isOpen())return;let e=this.el.querySelector("[autofocus]:not([disabled])")??this.el.querySelector(uu);e instanceof HTMLElement&&e.focus()}),this)}setTitle(t){return this.#i=String(t??""),this.#o(this.#i),this}setContent(t){return this.#t.clear(),this.#e=null,du(this.refs.content,t),this}setButtons(t){return this.#s=Es(t),this.#a(this.#s),this}addView(t,e){let s=String(t);this.#t.get(s)?.content.remove();let n=l("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});Ma(n,e?.content??null);let o={key:s,content:n,buttons:e&&Object.hasOwn(e,"buttons")?Es(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(s,o),this.#t.size===1||this.#e?.key===s?this.showView(s):this.refs.content.append(n),o}showView(t){let e=this.#t.get(String(t));if(!e)throw new RangeError(`Unknown dialog view: ${t}`);this.#e||this.refs.content.replaceChildren();for(let s of this.#t.values()){s.content.isConnected||this.refs.content.append(s.content);let r=s===e;s.content.hidden=!r,s.content.setAttribute("aria-hidden",String(!r))}return this.#e=e,this.#o(e.title??this.#i),this.#a(e.buttons??this.#s),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:s="OK"}={}){return new Promise(r=>{let n=!1,o=()=>{n||(n=!0,a.close(),r())},a=new i(null,{title:t,content:e,buttons:[{label:s,kind:"primary",action:o,autofocus:!0}]});a.once("close",()=>{n||(n=!0,r()),a.destroy()}),a.open()})}static confirm({title:t="",message:e="",okLabel:s="OK",cancelLabel:r="Cancel",danger:n=!1}={}){return new Promise(o=>{let a=!1,c=u=>{a||(a=!0,h.close(u),o(u))},h=new i(null,{title:t,content:e,buttons:[{label:r,action:()=>c(!1)},{label:s,kind:n?"danger":"primary",action:()=>c(!0),autofocus:!0}]});h.once("close",()=>{a||(a=!0,o(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:s="",placeholder:r=""}={}){return new Promise(n=>{let o=!1,a=l("input",{class:"zx-dialog__prompt-input",value:String(s),placeholder:String(r),autofocus:!0,ariaLabel:String(t||"Prompt value")}),c=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),a),h=d=>{o||(o=!0,u.close(d),n(d))},u=new i(null,{title:t,content:c,buttons:[{label:"Cancel",action:()=>h(null)},{label:"OK",kind:"primary",action:()=>h(a.value)}]});u.listen(a,"keydown",d=>{d.key==="Enter"&&(d.preventDefault(),h(a.value))}),u.once("close",()=>{o||(o=!0,n(null)),u.destroy()}),u.open()})}_applySize(t){let e={sm:400,md:600,lg:840},s=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,s)}px`}#o(t){this.refs.title.textContent=t}#a(t){this.#r=Es(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#r.length===0,this.#r.forEach((e,s)=>{this.refs.footer.append(l("button",{class:"zx-btn",type:"button","data-kind":e.kind??"default","data-size":"md","data-dialog-button":String(s),autofocus:!!e.autofocus},l("span",{class:"zx-btn__label"},e.label)))})}#l(t){let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}#c(){this.#n?.isConnected&&typeof this.#n.focus=="function"&&this.#n.focus(),this.#n=null}};function Es(i){return Array.isArray(i)?i.map(t=>({...t,label:String(t.label??"")})):[]}function du(i,t){i.replaceChildren(),Ma(i,t)}function Ma(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}var _t=class extends m{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let s=t,r=null;if(t!==null){let n=V(t);if(n&&n.localName!=="details"){let o=document.createElement("details"),a=Array.from(n.childNodes),c=n.parentNode,h=n.nextSibling;c&&c.insertBefore(o,n),o.append(...a),n.remove(),r={original:n,details:o,children:a,parent:c,next:h},s=o}}try{super(s,e)}catch(n){throw r&&Oa(r),n}this._adoption=r}render(){let t=!this.el,e=this.el??l("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:fu(e);let s=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),r=l("summary",{class:"zx-groupbox__summary",ref:"summary"},l("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},_("chevron-right",{size:16})),l("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),n=l("div",{class:"zx-groupbox__content",ref:"content"},s);return e.replaceChildren(r,n),e.open=!!this.options.open,this._lastOpen=e.open,this.listen(e,"toggle",()=>{let o=e.open;o!==this._lastOpen&&(this._lastOpen=o,this.emit(o?"open":"close"))}),e}open(){return this.el.setAttribute("open",""),this}close(){return this.el.removeAttribute("open"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.el.open}setTitle(t){return this.refs.title.textContent=String(t),this}setContent(t){let e=t instanceof m?t.toElement():t;if(this.refs.content.replaceChildren(),typeof e=="string")this.refs.content.append(document.createTextNode(e));else if(e&&typeof e.nodeType=="number")this.refs.content.append(e);else throw new TypeError("Groupbox content must be a string, Node, or Component");return this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._adoption?Oa(this._adoption):!this._createdRoot&&this._original&&pu(this.el,this._original))}};function fu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function pu(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Oa(i){if(i.original.replaceChildren(...i.children),i.details.parentNode)i.details.replaceWith(i.original);else if(i.parent){let t=i.next?.parentNode===i.parent?i.next:null;i.parent.insertBefore(i.original,t)}}var Ot=class extends m{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??l("form");this._createdRoot=t,this._original=t?null:mu(e),this._inputTimer=null,e.setAttribute("role","search");let s=l("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||"Search")}),r=this.options.clearable?l("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:"Clear search",title:"Clear search"},_("x",{size:15})):null,n=l("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:"Submit search",title:"Search"},_("search",{size:16}));return e.replaceChildren(...[s,r,n].filter(Boolean)),this._syncClear(),this.listen(s,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",o=>{o.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(s,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(n,"click",()=>this.emit("submit",{value:this.get()}))),r&&this.listen(r,"click",()=>this.clear()),e}get(){return this.refs.input.value}set(t,{silent:e=!1}={}){return this._inputTimer!==null&&(clearTimeout(this._inputTimer),this._inputTimer=null),this.refs.input.value=String(t),this._syncClear(),e||this._scheduleInput(),this}focus(){return this.refs.input.focus(),this}clear(){return this.set(""),this.emit("clear"),this.focus(),this}destroy(){this._cleaned||(this._cleaned=!0,this._inputTimer!==null&&clearTimeout(this._inputTimer),super.destroy(),!this._createdRoot&&this._original&&_u(this.el,this._original))}_scheduleInput(){this._inputTimer!==null&&clearTimeout(this._inputTimer);let t=Math.max(0,Number(this.options.debounce)||0);this._inputTimer=setTimeout(()=>{this._inputTimer=null,this.emit("input",{value:this.get()})},t)}_syncClear(){this.refs.clear&&(this.refs.clear.hidden=this.get()==="")}};function mu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function _u(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var gu=new Set(["divided","bracket","line","segmented"]),Ft=class extends m{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");if(this.el=e,this._createdRoot=t,this._original=t?null:yu(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!gu.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let s=l("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),r=l("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(s,r),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let a of this.options.tabs)this.addTab(a);this._initializing=!1;let n=this.options.active===null?null:this._find(this.options.active),o=n&&!n.definition.disabled?n:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(s,"click",a=>{let c=a.target.closest?.('[role="tab"]');if(!c||!s.contains(c))return;let h=this._recordForTab(c);if(!(!h||h.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(h);return}this._setFocused(h),this.openTab(h.definition.name)}}),this.listen(s,"keydown",a=>this._onKeydown(a)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!bu(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let s={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},r=y("zx-tab"),n=y("zx-tabpanel"),o=l("span",{class:"zx-tabbox__title"},s.title),a=l("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];s.icon&&c.push(l("span",{class:"zx-tabbox__icon",ariaHidden:"true"},_(s.icon,{size:16}))),c.push(o,a),s.closable&&c.push(l("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:"Close"},_("x",{size:14})));let h=l("button",{class:"zx-tabbox__tab",type:"button",id:r,role:"tab",tabindex:"-1",ariaControls:n,ariaSelected:"false",ariaDisabled:s.disabled?"true":null,dataset:{closable:s.closable?"true":null}},c),u=l("div",{class:"zx-tabbox__panel",id:n,role:"tabpanel",tabindex:"0",ariaLabelledby:r,hidden:!0}),d={definition:s,tab:h,title:o,badge:a,panel:u,built:!1},p=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,f=Math.max(0,Math.min(this._tabs.length,p)),g=this._tabs[f]??null;return this._tabs.splice(f,0,d),this.refs.tablist.insertBefore(h,g?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,g?.panel??null),!this._initializing&&!this._active&&!s.disabled&&this._applyActive(d),this}removeTab(t){return this._removeTab(t,!1),this}openTab(t){let e=this._find(t);if(!e||e.definition.disabled||e===this._active)return this;let s=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:s}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let s=this._require(t);return s.definition.title=String(e??""),s.title.textContent=s.definition.title,this}setBadge(t,e){let s=this._require(t);return s.badge.textContent=e===null?"":String(e),s.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let s=this._enabledTabs().find(r=>r!==e)??null;if(s){if(this.openTab(s.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&xu(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let s=this._recordForTab(e);if(!s)return;let r=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),a=r[(o+n+r.length)%r.length];a&&this._setFocused(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._setFocused(n);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(s.definition.name);return}t.key==="Delete"&&s.definition.closable&&(t.preventDefault(),this._closeTab(s))}_closeTab(t){let e=this._tabs.indexOf(t),s=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let r=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],n=r&&!r.definition.disabled?r:this._active;n&&this._setFocused(n,s)}_removeTab(t,e){let s=this._find(t);if(!s)return!1;let r=this._tabs.indexOf(s),o=this._tabs.filter(c=>c!==s).filter(c=>!c.definition.disabled),a=o.find(c=>this._tabs.indexOf(c)>r)??o.at(-1)??null;return s===this._active&&a&&this.emit("change",{name:a.definition.name,previous:s.definition.name}).defaultPrevented?!1:(this._tabs.splice(r,1),s.tab.remove(),s.panel.remove(),s===this._active&&(this._active=null,a&&this._applyActive(a)),e&&this.emit("close",{name:s.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,s=e instanceof m?e.toElement():e;if(!s||typeof s.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(s),t.built=!0}_setFocused(t,e=!0){for(let s of this._tabs)s.tab.tabIndex=s===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}};function bu(i){return typeof i=="function"||i instanceof m?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function yu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function xu(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function vu(i,t){return String(i).localeCompare(String(t))}function wu(i,t){return i-t}function Su(i,t){return i.getTime()-t.getTime()}function Au(i,t,e="asc"){let s=i==null,r=t==null;if(s||r)return s&&r?0:s?1:-1;let n;return i instanceof Date&&t instanceof Date?n=Su(i,t):typeof i=="number"&&typeof t=="number"?n=wu(i,t):n=vu(i,t),e==="desc"?-n:n}function zu(i,t="asc"){return(e,s)=>Au(i(e),i(s),t)}function Gr(i,t,e="asc"){let s=zu(t,e);return i.map((r,n)=>({row:r,index:n})).sort((r,n)=>s(r.row,n.row)||r.index-n.index).map(({row:r})=>r)}var ku=new Set(["text","number","select","date","checkbox","textarea"]),Cu='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',lt=class extends m{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,zebra:!0,editMode:!1,hierarchy:!1};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");if(this.el=t,this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._columns=Array.isArray(this.options.columns)?this.options.columns.map(e=>({...e})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=qu(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Pu(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Hu(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Lu(this.options.hierarchy,this._columns),this._expanded=Ru(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let e of Ds(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(e);return this._reconcileExpanded(),this._table=l("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._editMode===!1?t.replaceChildren(this._scroll):(t.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:y("zx-table-message"),role:"status",ariaLive:"polite"}),t.replaceChildren(this._scroll,this._editMessage)),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",e=>this._handleBodyClick(e)),this.listen(this._tbody,"dblclick",e=>this._handleBodyDoubleClick(e)),this._editMode!==!1&&(this.listen(this._tbody,"keydown",e=>this._handleEditKeydown(e)),this.listen(this._tbody,"focusin",e=>this._handleEditFocusIn(e)),this.listen(document,"pointerdown",e=>this._handleDocumentPointerDown(e),{capture:!0})),t}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Ra(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return Ra(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let s=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(s<0)return this;let r=this._selected.delete(t);return this._data[s]=e,r&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),r&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let s=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,s={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let n=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(n!=="asc"&&n!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:n},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:n}),this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(r=>this._idFor(r))),s=new Set;if(this.options.selectable!==!1){for(let r of t)if(e.has(r)&&s.add(r),this.options.selectable==="single"&&s.size>0)break}return Vu(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let s=Ds(this._data,this.options.rowId,this._hierarchy.parentId).filter(r=>!this._expanded.has(r));for(let r of s)this._expanded.add(r);if(s.length&&this._renderBody(),!t.silent)for(let r of s)this._emitRowToggle(r,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let s of e)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let s=this._columns.find(u=>u.id===e);if(!s)return this;let r=this._data.find(u=>Object.is(this._idFor(u),t));if(r===void 0||He(s,r)===!1)return this;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(e))return this._edit.columnId=e,this._focusEditor(e),this;if(this.commitEdit(),this._edit)return this}let n=this._data.findIndex(u=>Object.is(this._idFor(u),t));if(n<0)return this;let o=this._data[n],a=this._rowElements.get(t)?.[0];if(!a)return this;let c=this._editMode==="row"?this._columns.filter(u=>He(u,o)!==!1):[s],h=new Map;for(let u of c){let d=La(a,u.id);if(!d)continue;let p=this._createEditor(d,u,o,n);p&&h.set(u.id,p)}return h.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:h,tr:a},a.dataset.editing="true",this.emit("editstart",{row:o,id:t,column:s,columnId:e,value:o?.[e]}),this._focusEditor(e),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,s={};for(let[d,p]of t.cells)s[d]=p.read();let r=this._columns.filter(d=>t.cells.has(d.id)),n=Fu(s,r,e,this._msgOr("table.invalid","Invalid value"));if(n)return this._markInvalid(n.columnId,n.message),t.columnId=n.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(d=>d.id===n.columnId)??null,columnId:n.columnId,value:s[n.columnId],message:n.message}),this._focusEditor(n.columnId),this;this._clearInvalid();let o=Ou(e,s),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(d=>d.id===a)??null,columnId:a,value:s[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let h=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),h&&this._focusCell(this._idFor(u),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?Eu(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,s=this._rendered,r=this._projectedData().length;return this._rendered=Math.min(r,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:r}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,s){let r=this.msg(t,...s);return r===t?F(e,s):r}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in Kt)||(this._width=ue((e,s)=>this._setStacked(s>0&&s<Kt[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[s,r]of e)s&&(t?s.setAttribute("role",r):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,r]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let n of this._table.querySelectorAll(s))t?n.setAttribute("role",r):n.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,this.el&&delete this.el.dataset.editMode,!this._restored&&this._originalChildren&&(this.el.replaceChildren(...this._originalChildren),this._restored=!0),super.destroy()}_renderColumns(){let t=document.createDocumentFragment();this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._columns.map(r=>ju(r.width)),s=e.reduce((r,n)=>r+n,0);this._table.dataset.layout=s>0?"fixed":"auto",this._columns.forEach((r,n)=>{let o=l("col");e[n]>0?o.style.width=`${e[n]/s*100}%`:r.width&&r.width!=="auto"&&(o.style.width=String(r.width)),t.append(o)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._visibleData())this._selected.add(this._idFor(s));else for(let s of this._visibleData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._columns){let s=l("th",{scope:"col"}),r=e.align??(Qr(e)?"end":null);if(r&&(s.dataset.align=r),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let n=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(n,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(n)}else s.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,s),t.append(s)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(s=>[s.id,s])),this._data.length===0?t.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._columns.length+(this.options.selectable==="multi"?1:0)},this._emptyContent()))):this._visibleEntries().forEach((s,r)=>{t.append(this._createRow(s.row,s.index,{...s,visibleIndex:r}))}),this._tbody.replaceChildren(t),this._growStep&&this._table.setAttribute("aria-rowcount",String(e.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,s){let r=this._idFor(t),n=l("tr",{dataset:{row:""}});this._growStep&&n.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&n.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&n.setAttribute("aria-selected",String(this._selected.has(r))),this._hierarchy&&(n.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&n.setAttribute("aria-expanded",String(this._expanded.has(r)))),this._rowMeta.set(n,{row:t,id:r,index:e,visibleIndex:s.visibleIndex});let a=this._rowElements.get(r)??[];if(a.push(n),this._rowElements.set(r,a),this.options.selectable==="multi"){let c=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(r),ariaLabel:`Select row ${e+1}`});n.append(l("td",{class:"zx-table__selection-cell"},c))}return this._columns.forEach(c=>{let h=l("td"),u=c.align??(Qr(c)?"end":null);u&&(h.dataset.align=u),h.dataset.label=c.label,c.popin===!1&&(h.dataset.popin="false"),this._editMode!==!1&&(h.dataset.column=c.id,He(c,t)!==!1&&(h.dataset.editable="true",h.tabIndex=-1,this._offerRovingCell(h,r,c.id))),this._renderCellContent(h,c,t,e,s),n.append(h)}),n}_renderCellContent(t,e,s,r,n=this._hierarchyMeta?.get(this._idFor(s))){let o=Tu(e,s,r),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchy.column||!n){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(n.depth)),n.hasChildren){let h=this._expanded.has(n.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(h),ariaLabel:`${h?"Collapse":"Expand"} row ${r+1}`},_(h?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&Ns(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);if(!r||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(r.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(r,o.checked,t.shiftKey);return}this.emit("rowclick",{...r,event:t}),this.options.selectable==="single"&&!this._selected.has(r.id)&&(this._selected=new Set([r.id]),this._selectionAnchorId=r.id,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&Ns(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);if(r){if(this._editMode!==!1){let n=e?.closest('td[data-editable="true"]');if(n&&this._tbody.contains(n)){this.startEdit(r.id,String(n.dataset.column));return}}this.emit("rowdblclick",{...r,event:t})}}_createEditor(t,e,s,r){let n=He(e,s);if(n===!1)return null;let o=s?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let h=l("div",{class:"zx-table__editor",dataset:{editor:n}});t.replaceChildren(c,h),t.dataset.editing="true";let u={column:e,type:n,td:t,host:h,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(n==="custom"){u.custom=o,u.read=()=>Yt(e,u.custom,s);let f={value:o,row:s,column:e,commit:x=>{u.custom=x,this.commitEdit()},cancel:()=>this.cancelEdit()},g=e.editor(s,f);return g&&typeof g.toElement=="function"?(typeof g.destroy=="function"&&(u.component=g),h.append(g.toElement())):g&&h.append(g),u.control=h.querySelector(Cu)??h,u}if(n==="number"){let f=Wt(e.locale,s),g=Pa(e,s),x=e.type==="currency"?Wt(e.currency,s):e.type==="unit"?Wt(e.unit,s):null,v={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:g}:{},...x!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(x)}:{}},b=new Nt(null,{...v,...a,value:o??null});return h.append(b.el),u.component=b,u.control=b.getInput(),u.read=()=>(b.set(b.getInput().value,{silent:!0}),Yt(e,b.get(),s)),u}if(n==="select"){let f=Nu(e.options,s),g=f.find(v=>Object.is(v.value,o))??f.find(v=>String(v.value)===String(o??"")),x=new R(null,{...a,items:f,valueKey:"value",labelKey:"label",value:g?g.value:null});return h.append(x.el),u.component=x,u.control=x.refs.input,u.read=()=>Yt(e,x.value,s),u}if(n==="date"){let f=new q(null,{...a,value:o??null});h.append(f.el),u.component=f;let g=f.refs.input;return u.control=g,u.read=()=>{let x=String(g.value??"").trim(),v=f.get();return x===""?Yt(e,null,s):(f.set(x,{silent:!0}),f.get()===null&&f.set(v,{silent:!0}),Yt(e,f.get(),s))},u}if(n==="checkbox"){let f=new H(null,{...a,checked:!!o});return h.append(f.el),u.component=f,u.control=f.el,u.read=()=>Yt(e,f.get(),s),u}let d=n==="textarea",p=l(d?"textarea":"input",{...a,class:d?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...d?{}:{type:"text"},ariaLabel:a.ariaLabel??`${e.label} row ${r+1}`,value:Iu(e,o,s)});return h.append(p),u.control=p,u.read=()=>Yt(e,p.value,s),u}_focusEditor(t){let e=this._edit?.cells.get(t),s=e?.control;!s||typeof s.focus!="function"||(s.focus(),e.type==="text"&&typeof s.select=="function"&&s.select())}_focusCell(t,e){let s=this._rowElements.get(t)?.[0];(s?La(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(r=>Object.is(this._idFor(r),t.id)),s=e<0?t.row:this._data[e];for(let r of t.cells.values())r.destroy(),delete r.td.dataset.editing,delete r.td.dataset.invalid,this._renderCellContent(r.td,r.column,s,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let s=t&&this._editHasFocus(),r=this.getRow(e.id)??e.row,n=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:r,id:e.id,column:n,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let s=this._edit?.cells.get(t);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&Ns(e)){if(Bu(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let s=e.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s.parentElement);r&&(t.preventDefault(),this.startEdit(r.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,r=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),n=this._nextEditableCell(r,e.columnId,s);if(n&&Object.is(n.id,e.id)&&e.cells.has(n.columnId)){t.preventDefault(),e.columnId=n.columnId,this._focusEditor(n.columnId);return}if(!n){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(n.id,n.columnId)}_nextEditableCell(t,e,s){let r=this._columns.length;if(t<0||r===0)return null;let n=this._visibleData(),o=this._idFor(this._data[t]),a=n.findIndex(u=>Object.is(this._idFor(u),o));if(a<0)return null;let c=this._columns.findIndex(u=>u.id===e),h=n.length*r+r;for(let u=0;u<h;u+=1){if(c+=s,c>=r?(a+=1,c=0):c<0&&(a-=1,c=r-1),a<0||a>=n.length)return null;let d=n[a],p=this._columns[c];if(He(p,d)!==!1)return{id:this._idFor(d),columnId:p.id,index:this._data.indexOf(d)}}return null}_handleEditFocusIn(t){let s=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s.parentElement);r&&this._setRovingCell(s,r.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&Ns(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let r=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!r&&this._rovingCell||(r&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=r)}_setRovingCell(t,e,s){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:s}}_msgOr(t,e){let s=this.msg(t);return s===t?e:s}_toggleMultiSelection(t,e,s){let r=this._visibleData(),n=r.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&n>=0){let o=t.visibleIndex??r.findIndex(h=>Object.is(this._idFor(h),t.id)),a=Math.min(n,o),c=Math.max(n,o);for(let h=a;h<=c;h+=1){let u=this._idFor(r[h]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let s=this._selected.has(t);for(let r of e){r.setAttribute("aria-selected",String(s));let n=r.querySelector(".zx-table__row-checkbox");n&&(n.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,r)=>s+Number(this._selected.has(this._idFor(r))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(s=>s.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:s=>s?.[t.id];this._data=this._hierarchy?Du(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):Gr(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?Ds(this._data,this.options.rowId,this._hierarchy.parentId).some(n=>Object.is(n,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),s.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let s=this.getRow(t);s&&this.emit("rowtoggle",{row:s,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=Ds(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let s of this._expanded)e.has(s)||this._expanded.delete(s)}_pruneSelection(){let t=new Set(this._data.map(s=>this._idFor(s))),e=this._selected.size;for(let s of this._selected)t.has(s)||this._selected.delete(s);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Tu(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],r=i?.type??"text";if(r==="text")return s;let n=Wt(i.locale,t),o=Pa(i,t),a={...n!=null?{locale:String(n)}:{},...o!=null?{decimals:o}:{}};if(r==="number")return Mt(s,a);if(r==="currency"){let c=Wt(i.currency,t);return zs(s,c==null?null:String(c),a)}if(r==="percent")return ks(s,a);if(r==="unit"){let c=Mt(s,a),h=Wt(i.unit,t);return c&&h!=null&&String(h)!==""?`${c}\xA0${h}`:c}return s}function Eu(i,t,e,s=[]){let r=Zr(i,t,e),n=s instanceof Set?s:new Set(s),o=[],a=r.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:h}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:h,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!n.has(c.id))for(let u=c.children.length-1;u>=0;u-=1)a.push({node:c.children[u],depth:h+1})}return o}function Du(i,t,e,s,r){let n=Zr(i,t,e),o=h=>Gr(h,u=>s(u.row),r),a=[],c=o(n.roots).reverse();for(;c.length;){let h=c.pop();a.push(h.row);let u=o(h.children);for(let d=u.length-1;d>=0;d-=1)c.push(u[d])}return a}function He(i,t){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(t)===!1?!1:"custom";let e=typeof i.editable=="function"?i.editable(t):i.editable;return e===!0?Qr(i)?"number":"text":typeof e=="string"&&ku.has(e)?e:!1}function Nu(i,t){let e=typeof i=="function"?i(t):i;return Array.isArray(e)?e.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([s,r])=>({value:s,label:String(r??"")})):[]}function Iu(i,t,e){if(typeof i?.format=="function"){let s=i.format(t,e);return s==null?"":String(s)}return t==null?"":String(t)}function Yt(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Mu(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function Ou(i,t){let e={};for(let[s,r]of Object.entries(t??{}))Mu(i?.[s],r)||(e[s]=r);return e}function Fu(i,t,e,s="Invalid value"){for(let r of t??[]){if(typeof r?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},r.id))continue;let n=r.validate(i[r.id],e);if(typeof n=="string")return{columnId:r.id,message:n};if(n===!1)return{columnId:r.id,message:s}}return null}function Wt(i,t){return typeof i=="function"?i(t):i}function Pa(i,t){let e=Wt(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Qr(i){return["number","currency","percent","unit"].includes(i?.type)}function Zr(i,t,e){let s=(Array.isArray(i)?i:[]).map((a,c)=>({row:a,id:Fa(t,a),index:c,parent:null,children:[]})),r=new Map;for(let a of s)r.has(a.id)||r.set(a.id,a);let n=new Map;for(let a of s){let c=r.get(Fa(e,a.row))??null;n.set(a,c===a?null:c)}for(let a of s){let c=new Set([a]),h=n.get(a)??null;for(;h;){if(c.has(h)){n.set(h,null);break}c.add(h),h=n.get(h)??null}}let o=[];for(let a of s)a.parent=n.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function Ds(i,t,e){return Zr(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function Fa(i,t){return typeof i=="function"?i(t):t?.[i]}function Lu(i,t){if(!i||typeof i!="object")return null;let e=i.parentId;if(typeof e!="string"&&typeof e!="function")return null;let s=typeof i.column=="string"?i.column:null,r=t.some(n=>n.id===s)?s:t[0]?.id;return r?{...i,parentId:e,column:r}:null}function Ru(i){return new Set(Array.isArray(i)?i:[])}function Pu(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function Ns(i){return!!i?.closest?.(".zx-table__editor")}function Bu(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function La(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function qu(i,t){return!i||typeof i!="object"||!t.some(e=>e.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function ju(i){if(typeof i!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(i.trim());return t?Math.max(0,Number(t[1])):0}function Ra(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Vu(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Hu(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ct=Symbol("invalid attribute");function pe(i,t="string",e=console.warn){if(Ba(t),t==="boolean")return i!==null;if(i!==null){if(t==="string")return i;if(t==="number"){let s=Number(i);return Number.isFinite(s)?s:(e(`Ignoring invalid number attribute: ${JSON.stringify(i)}`),ct)}try{return JSON.parse(i)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(i)}`),ct}}}function Jr(i,t="string",e=console.warn){if(Ba(t),t==="boolean")return i?"":null;if(i==null)return null;if(t==="number"){let s=Number(i);return Number.isFinite(s)?String(s):(e(`Ignoring invalid number property: ${String(i)}`),ct)}if(t==="json"){try{let s=JSON.stringify(i);if(s!==void 0)return s}catch{}return e("Ignoring property that cannot be serialized as JSON"),ct}return String(i)}function Ba(i){if(!["string","number","boolean","json"].includes(String(i)))throw new TypeError(`Unknown reflected attribute type: ${String(i)}`)}var $u=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),Ku=ht({checked:I({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:T({default:!0}),label:T({default:null,rebuild:!0}),disabled:I({always:!0,set:$e})}),Uu=ht({checked:I({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:T({option:null,default:"on"}),label:T({default:"",set:(i,t)=>i.setLabel(t)}),icon:I({rebuild:!0}),disabled:I({always:!0,set:$e})}),Yu=ht({items:xt({default:[],set:(i,t)=>i.setItems(t)}),value:T({default:null,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.value}),"value-key":T({property:"valueKey",default:"ID",rebuild:!0}),"label-key":T({property:"labelKey",default:"name",rebuild:!0}),placeholder:T({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:I({default:!1,rebuild:!0}),filter:T({default:!1,normalize:od,rebuild:!0}),"search-keys":xt({property:"searchKeys",default:null,rebuild:!0}),"min-query":me({property:"minQuery",default:0,rebuild:!0}),debounce:me({default:200,rebuild:!0}),"list-height":me({property:"listHeight",default:280,rebuild:!0}),disabled:I({always:!0,set:$e}),required:I({option:null,always:!0}),name:T({option:null,default:""})}),Wu=ht({items:xt({default:[],set:(i,t)=>i.setItems(t)}),value:xt({option:null,default:[],set:(i,t)=>i.setValues(t),get:i=>i.getValues()}),"value-key":T({property:"valueKey",default:"ID",rebuild:!0}),"label-key":T({property:"labelKey",default:"name",rebuild:!0}),"checked-key":T({property:"checkedKey",default:"on",rebuild:!0}),search:I({rebuild:!0}),height:me({default:280,rebuild:!0}),"default-checked":I({property:"defaultChecked",default:!1,rebuild:!0}),disabled:I({option:null,always:!0,set:nd}),name:T({option:null,default:""})}),Gu=ht({format:T({default:"%d.%m.%Y",rebuild:!0}),time:I({always:!0,rebuild:!0}),value:T({option:null,default:null,normalize:hd,set:(i,t)=>i.set(t,{silent:!0}),get:(i,t)=>tn(i.get(),!!t.time),serialize:ud}),placeholder:T({default:null,rebuild:!0}),clearable:I({rebuild:!0}),disabled:I({always:!0,set:$e}),required:I({option:null,always:!0}),name:T({option:null,default:""})}),Qu=ht({value:me({default:0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),unit:T({default:"minutes",rebuild:!0}),seconds:I({always:!0,rebuild:!0}),signed:I({always:!0,rebuild:!0}),disabled:I({always:!0,set:$e}),name:T({option:null,default:""})}),Zu=ht({value:T({default:"",set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),placeholder:T({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:I({rebuild:!0}),debounce:me({default:250,rebuild:!0})}),Ju=ht({title:T({default:"",set:(i,t)=>i.setTitle(t)}),open:I({default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),Xu=ht({tabs:xt({default:[],normalize:ld,rebuild:!0}),active:T({default:null,set:(i,t)=>{t!==null&&i.openTab(t)},get:i=>i.getActive()}),variant:T({default:"divided",rebuild:!0}),"keep-alive":I({property:"keepAlive",rebuild:!0})}),td=ht({columns:xt({default:[],rebuild:!0}),data:xt({default:[],set:(i,t)=>i.setData(t),get:i=>i.getData()}),"row-id":T({property:"rowId",default:"ID",rebuild:!0}),sort:xt({default:null,rebuild:!0}),"sort-mode":T({property:"sortMode",default:"local",rebuild:!0}),selectable:T({default:!1,normalize:ad,rebuild:!0}),"sticky-header":I({property:"stickyHeader",rebuild:!0}),height:T({default:null,normalize:Ha,rebuild:!0}),"empty-text":T({property:"emptyText",default:null,rebuild:!0}),zebra:I({rebuild:!0})}),ed=ht({title:T({default:"",set:(i,t)=>i.setTitle(t)}),size:T({default:"md",normalize:Ha,rebuild:!0}),buttons:xt({default:[],set:(i,t)=>i.setButtons(t)}),closable:I({rebuild:!0}),open:I({option:null,default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),sd=Object.freeze([["toggle",H,{formAssociated:!0,attrs:Ku}],["check-button",at,{formAssociated:!0,attrs:Uu}],["select",R,{formAssociated:!0,attrs:Yu}],["checklist",Q,{formAssociated:!0,attrs:Wu}],["datebox",q,{formAssociated:!0,attrs:Gu}],["timebox",tt,{formAssociated:!0,attrs:Qu}],["search",Ot,{formAssociated:!1,attrs:Zu}],["groupbox",_t,{formAssociated:!1,attrs:Ju}],["tabbox",Ft,{formAssociated:!1,attrs:Xu}],["table",lt,{formAssociated:!1,attrs:td}],["dialog",et,{formAssociated:!1,attrs:ed}]]);function id(i,{formAssociated:t=!1,attrs:e={}}={}){let s=Va(e),r=Object.freeze(Object.keys(s)),n=i===_t||i===et;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return r}constructor(){super(),this._component=null,this._bridgeAbort=null,this._reflecting=new Set,this._propertyValues=new Map,this._defaults=null,this._contentNodes=null,this._disabledByForm=!1,this._applying=!1,this._internals=t&&typeof this.attachInternals=="function"?this.attachInternals():null}connectedCallback(){this._component||(this._upgradeProperties(s),n&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(s),this._createComponent(i,s,n))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,h,u){if(this._reflecting.has(c))return;let d=s[c];if(!d)return;let p=pe(u,d.type);if(p===ct)return;this._propertyValues.delete(d.property);let f=p===void 0?Is(d.default):p;this._applyValue(c,d,f)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(s),this._syncFormState(i)}formResetCallback(){if(!this._defaults)return;let c=Xr(i);!c||!this._defaults.has(c)||this._applyControlValue(s,c,Is(this._defaults.get(c)))}formStateRestoreCallback(c,h){if(typeof c!="string")return;let u=fd(i,c);if(u===ct)return;let d=Xr(i);d&&this._applyControlValue(s,d,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let h of Object.values(c)){let u=h.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let d=this[u];delete this[u],this[u]=d}}_captureDefaults(c){this._defaults=new Map;let h=Xr(i);if(h){let u=Object.values(c).find(d=>d.property===h);u&&this._defaults.set(h,Is(this._readProperty(u)))}}_createComponent(c,h,u){let d={};for(let[g,x]of Object.entries(h)){if(!(this._propertyValues.has(x.property)||this.hasAttribute(g)||x.always)||x.option===null)continue;let b=this._currentValue(g,x);b===ct||b===void 0||(d[x.option]=qa(x,b,this))}let p=null;u&&(p=document.createDocumentFragment(),p.append(...this._contentNodes),d.content=p);let f=new c(null,d);this._component=f,i===_t&&p&&f.setContent(p),this.append(f.el),this._bridgeEvents(f,i);for(let[g,x]of Object.entries(h)){if(x.option!==null||!x.set||!(this._propertyValues.has(x.property)||this.hasAttribute(g)||x.always))continue;let b=this._currentValue(g,x);b!==ct&&b!==void 0&&this._applyValue(g,x,b,!0)}this._syncEffectiveDisabled(h),this._syncFormState(i)}_bridgeEvents(c,h){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of $u)c.on(u,d=>{if(this._applying)return;this._syncFormState(h);let p=new CustomEvent(`zx-${u}`,{detail:d.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(p),p.defaultPrevented&&d.preventDefault()}),c.el.addEventListener(`zx-${u}`,d=>d.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,h=n){this._component&&(h&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(i,c,h))}_applyValue(c,h,u,d=!1){if(this._component){if(h.rebuild&&!d){this._rebuildComponent(s);return}if(!h.set){this._syncFormState(i);return}this._applying=!0;try{h.set(this._component,qa(h,u,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(s),this._syncFormState(i)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:h,state:u,empty:d}=dd(c,this._component,this);if(this._internals.setFormValue(h,u),(c===R||c===q)&&this.hasAttribute("required")&&d){let p=c===q?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},p,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,h,u){let d=Object.entries(c).find(([,p])=>p.property===h);d&&this._applyValue(d[0],d[1],u)}_currentValue(c,h){if(this._propertyValues.has(h.property))return this._propertyValues.get(h.property);let u=pe(this.getAttribute(c),h.type);return u===void 0?h.default:u}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let h=pe(this.getAttribute(c.attribute),c.type);return h===ct||h===void 0?Is(c.default):h}_writeProperty(c,h){this._propertyValues.set(c.property,h);let u=c.serialize?c.serialize(h,this):Jr(h,c.type);if(u!==ct){this._reflecting.add(c.attribute);try{u===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,u)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,h)}}for(let a of Object.values(s))Object.prototype.hasOwnProperty.call(o.prototype,a.property)||Object.defineProperty(o.prototype,a.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(a)},set(c){this._writeProperty(a,c)}});return o}function ja(i="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(i).trim();for(let[e,s,r]of sd){let n=`${t}-${e}`;customElements.get(n)||customElements.define(n,id(s,r))}}function Va(i){let t={};for(let[e,s]of Object.entries(i)){let r=typeof s=="string"?{type:s}:{...s},n=r.property??rd(e);t[e]=Object.freeze({type:r.type??"string",option:Object.prototype.hasOwnProperty.call(r,"option")?r.option:n,property:n,default:r.default,always:!!r.always,rebuild:!!r.rebuild,normalize:r.normalize,serialize:r.serialize,set:r.set,get:r.get,attribute:e})}return Object.freeze(t)}function ht(i){return Va(i)}function T(i={}){return{type:"string",...i}}function me(i={}){return{type:"number",...i}}function I(i={}){return{type:"boolean",default:!1,always:!0,...i}}function xt(i={}){return{type:"json",...i}}function rd(i){return i.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function qa(i,t,e){return i.normalize?i.normalize(t,e):t}function $e(i,t){t?i.disable():i.enable()}function nd(i,t){i.el.setAttribute("aria-disabled",String(t)),i.refs.search&&(i.refs.search.disabled=t);for(let e of i.refs.list?.querySelectorAll("input")??[])e.disabled=t}function od(i){return i===""||i==="true"?"local":i==="false"?!1:i}function ad(i){return i===""||i==="true"?"single":i==="false"?!1:i}function Ha(i){if(typeof i!="string"||i.trim()==="")return i;let t=Number(i);return Number.isFinite(t)?t:i}function ld(i){return Array.isArray(i)?i.map(t=>!t||typeof t!="object"||cd(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):i}function cd(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function hd(i){return typeof i!="string"?i:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(i)?$(i,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(i)?$(i,"%Y-%m-%d"):i}function ud(i,t){return i instanceof Date?tn(i,!!t.time):Jr(i,"string")}function tn(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":z(i,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function Xr(i){return i===H||i===at?"checked":[R,Q,q,tt].includes(i)?"value":null}function dd(i,t,e){if(i===H||i===at){let r=t.get(),n=i===H?!0:"on";return e._propertyValues.has("value")?n=e._propertyValues.get("value"):e.hasAttribute("value")&&(n=e.getAttribute("value")),{formValue:r?String(n):null,state:String(r),empty:!r}}if(i===R){let r=t.value;return{formValue:r===null?null:String(r),state:JSON.stringify(r),empty:r===null||r===""}}if(i===Q){let r=JSON.stringify(t.getValues());return{formValue:r,state:r,empty:r==="[]"}}if(i===q){let r=tn(t.get(),!!e.time);return{formValue:r||null,state:r,empty:r===""}}let s=String(t.get());return{formValue:s,state:s,empty:!1}}function fd(i,t){return i===H||i===at?t==="true":i===R||i===Q?pe(t,"json"):i===tt?pe(t,"number"):t}function Is(i){return Array.isArray(i)?i.slice():i instanceof Date?new Date(i.getTime()):i}var pd=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function j(i={}){let t={...pd,...i},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title,dataset:{kind:md(t.kind),size:_d(t.size)}});return t.icon&&e.append(_(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-btn__label"},String(t.label))),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),e}function Ms(i){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...i),t}function md(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function _d(i){return i==="sm"?"sm":"md"}var gd=Object.freeze(["neutral","accent","success","warning","danger","info"]),bd=Object.freeze(["soft","solid","outline"]),yd=Object.freeze({label:"",icon:null,kind:"neutral",variant:"soft",size:"md",dot:!1});function $a(i={}){let t={...yd,...i},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:xd(t.kind),variant:vd(t.variant),size:wd(t.size)}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(_(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(l("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function Ka(i){let t=l("span",{class:"zx-badge-group"});return t.append(...i),t}function xd(i){return gd.includes(i)?i:"neutral"}function vd(i){return bd.includes(i)?i:"soft"}function wd(i){return i==="sm"?"sm":"md"}var Sd=Object.freeze({md:40,sm:28}),Ad=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function Ua(i={}){let t={...Ad,...i},e=kd(t.size),s=l("div",{class:"zx-empty-state",dataset:{size:e,align:Cd(t.align)}});t.icon&&s.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},_(t.icon,{size:Sd[e]}))),t.title&&s.append(l("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&s.append(l("p",{class:"zx-empty-state__description"},String(t.description)));let r=zd(t.actions);return r.length>0&&s.append(l("div",{class:"zx-empty-state__actions"},r)),s}function zd(i){if(!Array.isArray(i))throw new TypeError("emptyState actions must be an array");return i.map(t=>{if(N(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return j(t)})}function kd(i){return i==="sm"?"sm":"md"}function Cd(i){return i==="start"?"start":"center"}var Td=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Ed=Object.freeze({sm:!0,md:!0,lg:!0});function Os(i={}){let t={...Td,...i},e=String(t.label??""),s=l("span",{class:"zx-spinner",dataset:{size:Ed[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(s.setAttribute("role","status"),s.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):s.setAttribute("aria-hidden","true"),s}var _e=class extends m{static cssName="progress-bar";static defaults={value:0,max:100,label:"",helperText:"",status:"active",indeterminate:!1,size:"md",hideLabel:!1,showValue:!0,formatValue:null};render(){this._value=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=Ya(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=y("zx-progress-label");let e=l("div",{ref:"head",class:"zx-progress-bar__head"},l("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),l("span",{ref:"value",class:"zx-progress-bar__value"})),s=l("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},l("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,s,l("p",{ref:"helper",class:"zx-progress-bar__helper"},String(this.options.helperText??""))),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.set(this.options.value,{silent:!0}),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=Number(t),r=M(Number.isFinite(s)?s:0,0,this._max),n=r!==this._value,o=n&&r>=this._max;return this._value=r,this._sync(),!e&&n&&this.emit("change",{value:r,percent:this.percent()}),!e&&o&&this.emit("complete",{value:r}),this}percent(){return this._value/this._max*100}setMax(t){return this._max=Math.max(1,Number(t)||1),this.refs.track.setAttribute("aria-valuemax",String(this._max)),this.set(this._value,{silent:!0})}setStatus(t,e){return this._status=Ya(t),e!==void 0&&this.setHelperText(e),this._sync(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}setHelperText(t){return this.refs.helper.textContent=String(t??""),this}setIndeterminate(t=!0){return this._indeterminate=!!t,this._sync(),this}_sync(){let{track:t,fill:e,value:s}=this.refs;if(this.el.dataset.status=this._status,this.el.toggleAttribute("data-indeterminate",this._indeterminate),this._indeterminate){t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuetext"),e.style.removeProperty("--zx-progress-fill"),s.textContent="";return}let r=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",r),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),s.replaceChildren(...this._readout(r))}_format(){let t=this.options.formatValue;return typeof t=="function"?String(t(this._value,this._max)):`${Math.round(this.percent())}%`}_readout(t){if(!this.options.showValue)return[];let e=[];return this._status!=="active"&&e.push(_(this._status==="success"?"success":"error",{size:14})),e.push(l("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};function Ya(i){return i==="success"||i==="error"?i:"active"}var Dd=new Set(["inactive","active","success","error"]),Fs=class extends m{static cssName="inline-loading";static defaults={status:"active",description:"",size:"sm",live:!0};render(){this._status="inactive",this._description="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("span");return this.el=t,t.replaceChildren(l("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),l("span",{ref:"description",class:"zx-inline-loading__description"})),t.dataset.size=this.options.size==="md"?"md":"sm",this.options.live!==!1&&(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),this.set(this.options.status,this.options.description,{silent:!0}),t}get(){return this._status}getDescription(){return this._description}set(t,e,{silent:s=!1}={}){let r=Dd.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let n=r!==this._status;return this._status=r,this._sync(),n&&!s&&this.emit("statuschange",{status:this._status,description:this._description}),this}setDescription(t){return this._description=String(t??""),this.refs.description.textContent=this._description,this}_sync(){this.el.dataset.status=this._status,this.refs.description.textContent=this._description,this.refs.indicator.replaceChildren(...this._indicator())}_indicator(){let t=this.el.dataset.size==="md"?18:16;return this._status==="active"?[Os({size:"sm",kind:"current"})]:this._status==="success"?[_("success",{size:t})]:this._status==="error"?[_("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};function Ls(i={}){let t={width:"100%",height:"1rem",radius:"sm",...i};return l("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Nd.has(t.radius)?t.radius:"sm"},style:{"inline-size":en(t.width),"block-size":en(t.height)}})}function Ga(i={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...i},e=M(Math.trunc(Number(t.lines)||0),1,20),s=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":en(t.width)}});for(let r=0;r<e;r+=1){let n=t.heading&&r===0,o=r===e-1&&e>1;s.append(Ls({width:o?t.lastLineWidth:"100%",height:n?"1.5rem":"0.75rem"}))}return s}function Qa(i={}){let t={rows:5,columns:4,header:!0,...i},e=M(Math.trunc(Number(t.rows)||0),1,50),s=M(Math.trunc(Number(t.columns)||0),1,20),r=l("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(s)}});t.header!==!1&&r.append(Wa(s,"header"));for(let n=0;n<e;n+=1)r.append(Wa(s,"body"));return r}var Nd=new Set(["sm","md","full"]);function Wa(i,t){let e=l("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let s=0;s<i;s+=1)e.append(l("span",{class:"zx-skeleton-table__cell"},Ls({width:Id(s,i),height:"0.75rem"})));return e}function Id(i,t){return i===t-1?"55%":i%2===0?"80%":"65%"}function en(i){return typeof i=="number"?`${i}px`:String(i??"")}function Za(i={},...t){return l("div",{class:["zx-stack",i.class??""],dataset:{direction:i.direction==="row"?"row":null,align:tl.has(i.align)?i.align:null,justify:Md.has(i.justify)?i.justify:null,wrap:i.wrap?"true":null,inline:i.inline?"true":null},style:el("--zx-stack-gap",i.gap)},t)}function Ja(i={},...t){let e=Number(i.columns),s={...el("--zx-grid-gap",i.gap),"--zx-grid-min":Fd(i.min??"16rem")};return Number.isFinite(e)&&e>=1&&(s["--zx-grid-columns"]=String(Math.trunc(e))),l("div",{class:["zx-grid",i.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:tl.has(i.align)?i.align:null},style:s},t)}function Xa(i={},...t){return l("div",{class:["zx-aspect",i.class??""],style:{"--zx-aspect-ratio":String(i.ratio??"16 / 9"),"--zx-aspect-fit":Od.has(i.fit)?i.fit:"cover"}},t)}var tl=new Set(["start","center","end","stretch","baseline"]),Md=new Set(["start","center","end","between","around"]),Od=new Set(["cover","contain","fill"]);function el(i,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[i]:`var(--zx-space-${e})`}:{[i]:String(t)}}function Fd(i){return typeof i=="number"?`${i}px`:String(i)}function sl(i,t={}){let e=V(i);if(!e)throw new TypeError("truncate() target could not be resolved");let s=M(Math.trunc(Number(t.lines)||1),1,10),r=t.title!==!1,n=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),a=!1,c=null;e.classList.add("zx-truncate"),s>1&&(e.dataset.lines=String(s),e.style.setProperty("--zx-truncate-lines",String(s)));let h=()=>(a=sn(e),r&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return h(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(h),c.observe(e)),{update:h,isTruncated:()=>a,destroy:()=>{c?.disconnect(),c=null,n||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),r&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function sn(i){return i.scrollWidth-i.clientWidth>1||i.scrollHeight-i.clientHeight>1}var Ld=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Rs(i={}){let t={...Ld,...i},e=!t.label,s=l("button",{class:["zx-copy-button",e?"zx-icon-btn":"zx-btn"],type:"button",dataset:{size:t.size==="sm"?"sm":"md",kind:e?null:t.kind},title:e?String(t.title):null,ariaLabel:e?String(t.title):null}),r=l("span",{class:"zx-copy-button__icon",ariaHidden:"true"},_("copy",{size:t.size==="sm"?12:14})),n=l("span",{class:"zx-copy-button__status",role:"status"});s.append(r),e||s.append(l("span",{class:"zx-copy-button__label"},String(t.label))),s.append(n);let o=0;return s.addEventListener("click",async()=>{let a=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await Ts(a);t.oncopy?.(a,c),c&&(clearTimeout(o),s.dataset.copied="true",r.replaceChildren(_("check",{size:t.size==="sm"?12:14})),n.textContent=String(t.feedback),o=setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,r.replaceChildren(_("copy",{size:t.size==="sm"?12:14})),n.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),s}var Ps=class extends m{static cssName="copy-input";static defaults={value:"",label:"",hideLabel:!1,feedback:"Copied",buttonTitle:"Copy",size:"md"};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t;let e=y("zx-copy-input"),s=l("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),r=Rs({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(n,o)=>this.emit("copy",{value:n,copied:o})});return t.replaceChildren(l("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),l("div",{class:"zx-copy-input__box"},s,r)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(s,"focus",()=>s.select()),t}get(){return this.refs.input.value}set(t){return this.refs.input.value=String(t??""),this}focus(){return this.refs.input.focus(),this.refs.input.select(),this}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};var rl=Symbol("zxDropdownPointerDismiss"),nl=Symbol("zxDropdownEscapeDismiss"),st=class extends m{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1};#t;#e=null;#s=new Map;#i=!1;constructor(t,e={}){let s=V(t);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=s,this.#n("aria-expanded"),this.#n("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()})}render(){let t=l("div",{id:y("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}open(){return this.isOpen()||this.#i?this:(this.#e=Y(this.#t,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.el.dataset.zxOverlayOrder=String(Pd()),this.#t.setAttribute("aria-expanded","true"),Bd(),this.emit("open"),this)}close(){return this.isOpen()?(this.#e?.destroy(),this.#e=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder,this.#t.setAttribute("aria-expanded","false"),this.emit("close"),qd(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return Rd(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#i){this.#i=!0,this.close();for(let[t,e]of this.#s)jd(this.#t,t,e);super.destroy()}}[rl](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[nl](t){if(t.key!=="Escape"||!this.isOpen())return;t.preventDefault();let e=this.el.contains(document.activeElement);this.close(),e&&this.#t instanceof HTMLElement&&this.#t.focus()}#n(t){this.#s.set(t,this.#t.getAttribute(t))}},Ke=class extends m{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=il();e instanceof st&&e[rl](t)}),this.listen(document,"keydown",t=>{if(t.key!=="Escape")return;let e=il();e instanceof st&&e[nl](t)})}render(){let t=l("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function Rd(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function il(){let i=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let s=Number(e.getAttribute("data-zx-overlay-order"))||0;s>t&&(t=s,i=e)}return i?m.from(i):null}function Pd(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function Bd(){let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?m.from(i):null;return t instanceof Ke?t:new Ke}function qd(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?m.from(i):null;t instanceof Ke&&t.destroy()}function jd(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Bs='[role="menuitem"]',K=class extends m{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#s;#i;#n=[];#r=null;#o=!1;#a=!1;constructor(t=null,e={}){let s=t===null?null:V(t);if(t!==null&&(!s||s.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let r=s?{attributes:Array.from(s.attributes,o=>[o.name,o.value]),children:Array.from(s.childNodes)}:null,n=Object.hasOwn(e,"label");super(t,e),this.#o=s===null,this.#r=r,this.el.classList.add("zx-btn"),this.el.setAttribute("type","button"),this.el.setAttribute("data-kind",String(this.options.kind)),this.el.setAttribute("data-size","md"),this.#t=new st(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.setAttribute("aria-haspopup","menu"),s&&n&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#s=mt(this.#e,Bs),this.#i=X(()=>this.#u(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>this.emit("close")),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#s.focusFirst())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(Bs);a&&this.#e.contains(a)&&this.#h(a)}),this.listen(this.#e,"keydown",o=>this.#c(o))}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},ol(this.options.label,this.options.icon))}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(),this.#n.forEach((e,s)=>{if(e==="-"){this.#e.append(l("div",{class:"zx-menu-button__separator",role:"separator"}));return}let r=[];e.icon&&r.push(l("span",{class:"zx-menu-button__icon"},_(e.icon))),r.push(l("span",{class:"zx-menu-button__label"},e.label)),this.#e.append(l("button",{class:"zx-menu-button__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},r))}),this}open(){return this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(){return this.open(),this.#s.focusFirst(),this}focusLast(){return this.open(),this.#s.focusLast(),this}setLabel(t){return this.el.replaceChildren(...ol(t,this.options.icon)),this}destroy(){if(!this.#a&&(this.#a=!0,this.#s.destroy(),this.#t.destroy(),super.destroy(),!this.#o&&this.#r)){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,e]of this.#r.attributes)this.el.setAttribute(t,e);this.el.replaceChildren(...this.#r.children)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#s.focusLast():this.#s.focusFirst())}#c(t){if(t.key==="Escape"){t.preventDefault(),this.close(),this.el.focus();return}if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(Bs);if(!e||!this.#e.contains(e))return;t.preventDefault(),this.#h(e);return}this.#i(t)}#h(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#n[e];if(!(!s||s==="-"||s.disabled||this.emit("select",{value:s.value,item:s}).defaultPrevented))try{s.onselect?.(s.value,s,this)}finally{this.close()}}#u(){return Array.from(this.#e.querySelectorAll(Bs))}};function ol(i,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},_(t))),e.push(l("span",{class:"zx-btn__label"},String(i??""))),e}var Vd=["button","a[href]","input","select","textarea","[tabindex]"],Hd=Vd.flatMap(i=>[`.zx-toolbar > ${i}`,`.zx-toolbar > [role="group"] > ${i}`]).join(","),qs=class extends m{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#s=null;#i=!1;#n=-1;#r=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new K(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let s=this.#e.toElement();s.classList.add("zx-toolbar__overflow"),s.setAttribute("aria-label",String(this.options.overflowLabel)),s.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&s.setAttribute("data-size","sm"),s.hidden=!0}this.#t=mt(this.el,Hd,{orientation:"horizontal"}),this.listen(this.el,"click",s=>this.#c(s)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#s=new ResizeObserver(()=>this.#u()),this.#s.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:k(t);let e=this.options.items;return this._initialItems=Array.isArray(e)&&e.length===0?Array.from(t.children):e,t.setAttribute("role","toolbar"),t.setAttribute("aria-label",String(this.options.label)),t.dataset.align=Kd(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let s of this._records)s.type==="element"&&(s.element.hidden=s.userHidden);this._records=$d(t).map(s=>this.#l(s)),this._named=new Map;for(let s of this._records)s.name!==null&&!this._named.has(s.name)&&this._named.set(s.name,s);let e=this._records.map(s=>s.element);if(this.#e){this.#e.setItems([]);let s=this.#e.toElement();s.hidden=!0,e.push(s)}return this.el.replaceChildren(...e),this.#n=-1,this.#r=-1,this.#d(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#h(t,!1)}disable(t){return this.#h(t,!0)}setActive(t,e=!0){let s=this._named.get(String(t));return s&&s.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#s?.disconnect(),this.#s=null,this.#o!==0&&cancelAnimationFrame(this.#o),this.#o=0,this.#t.destroy(),this.#e?.destroy(),this.#e=null;for(let t of this._records)t.type==="element"&&(t.element.hidden=t.userHidden);super.destroy(),this._createdRoot||C(this.el,this._snapshot)}}#l(t){if(t.type==="separator")return{type:"separator",element:l("span",{class:"zx-toolbar__separator",role:"separator",ariaOrientation:"vertical",dataset:{separator:"true"}}),name:null,label:"",icon:null,onclick:null,userHidden:!1};if(t.type==="element"){let a=t.element;return{type:"element",element:a,name:a.dataset?.name??null,label:ll(a),icon:null,onclick:null,userHidden:!!a.hidden}}let{name:e=null,active:s,onclick:r,...n}=t.descriptor,o=j({size:this.options.dense?"sm":"md",...n});return s!==void 0&&o.setAttribute("aria-pressed",s?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(n.label??n.title??""),icon:n.icon??null,onclick:typeof r=="function"?r:null,userHidden:!1}}#c(t){let e=t.target;if(!e)return;let s=this._records.find(r=>r.type==="descriptor"&&r.element.contains(e));s&&(this.emit("action",{name:s.name,item:s.element}),s.onclick?.(t))}#h(t,e){let s=this._named.get(String(t));if(!s)return this;let r=s.element;return"disabled"in r?r.disabled=e:e?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"),this.#f(),this}#u(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#d();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#d()})}}#d(){if(this.#i||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),s=parseFloat(e.columnGap)||0,r=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),n=t.clientWidth-r,o=t.clientHeight;if(!(!(n>0)||n===this.#n&&o===this.#r)){this.#i=!0;try{let a=this.#e.toElement(),c=this._records.filter(g=>!g.userHidden);for(let g of c)g.element.hidden=!1;a.hidden=!1;let h=c.map(g=>g.element.getBoundingClientRect().width),u=h.reduce((g,x)=>g+x,0)+s*Math.max(0,h.length-1),d=a.getBoundingClientRect().width,p=[];if(u>n){let g=n-d-s,x=0,v=!1;for(c.forEach((b,w)=>{let D=x+h[w]+(x>0?s:0);if(!v&&D<=g){x=D;return}v=!0,b.element.hidden=!0,p.push(b)});c.length>p.length;){let b=c[c.length-p.length-1];if(b.type!=="separator")break;b.element.hidden=!0,p.unshift(b)}}let f=al(p);this.#e.setItems(f),a.hidden=f.length===0,this.#n=n,this.#r=t.clientHeight}finally{this.#i=!1}}}#f(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(al(t))}};function $d(i){if(i!=null&&!Array.isArray(i))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of i??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(N(e)){t.push({type:"element",element:e});continue}if(typeof e!="object"||Array.isArray(e))throw new TypeError('Toolbar items must be Elements, item descriptors, or "-"');t.push({type:"descriptor",descriptor:{...e}})}for(;t.length>0&&t[t.length-1].type==="separator";)t.pop();return t}function al(i){let t=[];for(let e of i){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let s=e.element;t.push({label:e.label||ll(s)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!s.disabled||s.getAttribute("aria-disabled")==="true",onselect:()=>s.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function ll(i){return(i.getAttribute("aria-label")??i.getAttribute("title")??i.textContent??"").trim()}function Kd(i){return["end","between"].includes(i)?i:"start"}var ge=class extends m{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Ud(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let s=t?[]:Array.from(e.childNodes),r=y("zx-panel-body"),n=l("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(l("span",{class:"zx-panel__chevron",ariaHidden:"true"},_("chevron-right",{size:16}))),o.push(n);let a=this._collapsible?l("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:r,ariaExpanded:String(this._open)},o):l("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=l("div",{class:"zx-panel__header",ref:"header"},a,l("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),h=l("div",{class:"zx-panel__content",ref:"content"}),u=l("div",{class:"zx-panel__body",ref:"body",id:r},h),d=l("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},l("div",{class:"zx-panel__footer-content",ref:"footerContent"}),l("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:"Panel footer actions"}));return e.replaceChildren(c,u,d),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):h.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(a,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return cl(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return cl(this.refs.footerContent,t,"Panel footer"),this._hasFooterContent=t!==null,this._syncFooter(),this}setFooterButtons(t){return this.refs.footerButtons.replaceChildren(...this._buildButtons(t,"Panel footer buttons")),this._syncFooter(),this}open(){return this._open?this:(this._open=!0,this._syncOpenState(),this.emit("open"),this)}close(){return this._open?(this._open=!1,this._syncOpenState(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this._open}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Yd(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(s=>{if(N(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError(`${e} must be Elements or button descriptors`);let r={...s},n=r.onclick;delete r.onclick;let o=j(r);return typeof n=="function"&&this.listen(o,"click",n),o})}};function Ud(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Yd(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function cl(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof m?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Wd=Object.freeze(["default","settings","accounts","billing","calendar","campaigns","clocking","collection","contacts","contracts","enhancements","inventory","links","mailinglists","messages","notes","opportunities","pricelists","procurement","projects","tasks","tickets","pwd","system","usermgmt","usersettings","users","groups"]),be=class extends m{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Gd(e),this._cleaned=!1;let s=t?[]:Array.from(e.childNodes),r=l("header",{class:"zx-master-panel__header"},l("h1",{class:"zx-master-panel__title",ref:"title"}),l("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),n=l("div",{class:"zx-master-panel__content",ref:"content"}),o=l("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(r,n,o);let a=Zd(this.options.module);return e.dataset.module=a,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${a})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):n.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return hl(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(s=>{if(N(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=j(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return hl(this.refs.footer,t,"MasterPanel footer"),this.refs.footer.hidden=t===null,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Qd(this.el,this._original))}};function Gd(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Qd(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function hl(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof m?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Zd(i){let t=String(i??"default").toLowerCase();return Wd.includes(t)?t:"default"}function ye(i,t){if(!i)throw new TypeError("dragAxis requires a handle element");if(typeof t?.onMove!="function")throw new TypeError("dragAxis requires an onMove callback");let e=t.orientation==="vertical",s=new AbortController,{signal:r}=s,n=!1,o=null,a=0,c=0,h=!1,u=0,d=b=>e?b.clientY:b.clientX,p=()=>!!t.disabled?.(),f=()=>{let b=o;if(o=null,b!==null)try{i.releasePointerCapture(b)}catch{}},g=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},x=()=>{n=!1,h=!1,g(),f()};i.addEventListener("pointerdown",b=>{let w=b;if(!(p()||n||w.button!==0)&&t.onStart?.(w)!==!1){n=!0,o=w.pointerId,a=d(w),c=a,h=!1;try{i.setPointerCapture(w.pointerId)}catch{}}},{signal:r}),i.addEventListener("pointermove",b=>{let w=b;!n||w.pointerId!==o||(c=d(w),c!==a&&(h=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,n&&t.onMove(c-a)})))},{signal:r});let v=b=>{let w=b;if(!n||w.pointerId!==o)return;g(),c=d(w);let D=h,U=c-a;x(),t.onEnd?.(U,D)};return i.addEventListener("pointerup",v,{signal:r}),i.addEventListener("pointercancel",v,{signal:r}),i.addEventListener("keydown",b=>{let w=b;if(p())return;if((w.key==="Enter"||w.key===" ")&&t.onActivate){w.preventDefault(),t.onActivate();return}if(w.key==="Home"||w.key==="End"){if(!t.onJump)return;w.preventDefault(),t.onJump(w.key==="Home"?"min":"max");return}let D=e?"ArrowUp":"ArrowLeft",U=e?"ArrowDown":"ArrowRight";w.key!==D&&w.key!==U||t.onStep&&(w.preventDefault(),t.onStep(w.key===U?1:-1,w.shiftKey))},{signal:r}),{isDragging:()=>n,cancel(){n&&x()},destroy(){x(),s.abort()}}}function it(i,t){if(typeof i=="number")return Number.isFinite(i)?i:Number.NaN;if(typeof i!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(i.trim());if(!e)return Number.NaN;let s=Number(e[1]);if(!Number.isFinite(s))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return s;let r=Number(t);return Number.isFinite(r)?s/100*r:Number.NaN}var Jd="split-view",$s=class extends m{static cssName="split-view";static defaults={orientation:"horizontal",start:null,end:null,size:"38%",min:160,max:null,collapsible:!1,collapsed:!1,snap:0,storageKey:null,disabled:!1,label:"Resize panes"};#t=null;#e=null;#s=null;constructor(t=null,e={}){super(t,e);let s=this.options.storageKey;if(s!=null&&s!==""){this.#e=de(Jd);let o=this.#e.get(String(s));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let r=this.options.collapsed;r==="start"||r==="end"?this.#o(r,!1):r===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let n=this.refs.divider;this.#s=ye(n,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,a)=>{a&&this.#a(o,!0),delete this.el.dataset.dragging,a&&(this.#m(),this.#p())},onStep:(o,a)=>this.#l(o*(a?64:16)),onJump:o=>this.#c(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(n,"dblclick",()=>this.#d()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#f()),this.#t.observe(this.el)),this.#r()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=it(t.size,Number.NaN);this._size=Number.isFinite(e)?Math.max(0,e):null,this._collapsed=null,this._disabled=!!t.disabled,this._destroyed=!1,this._startSize=0,this._lastTotal=-1,this._createdRoot=!this.el;let s=this.el??l("div");this.el=s,this._snapshot=this._createdRoot?null:k(s);let r=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(s.children),n=y("zx-split-start"),o=l("div",{class:"zx-split-view__pane",id:n,ref:"start",dataset:{pane:"start"}}),a=l("div",{class:"zx-split-view__divider",ref:"divider",role:"separator",tabindex:this._disabled?-1:0,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(t.label??"Resize panes"),ariaControls:n}),c=l("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return s.replaceChildren(o,a,c),s.dataset.orientation=this._orientation,this._disabled&&a.setAttribute("aria-disabled","true"),s.style.setProperty("--zx-split-size",js(t.size)),t.start!=null?Vs(o,t.start,"SplitView start"):r[0]&&o.append(r[0]),t.end!=null?Vs(c,t.end,"SplitView end"):r[1]&&c.append(...r.slice(1)),s}setSize(t){let{total:e,divider:s,min:r,max:n}=this.#i(),o=it(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#n(vt({size:o,min:r,max:n,total:e,divider:s})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",js(t)),this.#r(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#i();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let s=ul(this.refs.start,this._orientation);if(s>0)return s;let r=it(this.options.size,t);return Number.isFinite(r)?Math.max(0,r):0}getRatio(){let{total:t}=this.#i();return t>0?this.getSize()/t:0}setStart(t){return Vs(this.refs.start,t,"SplitView start"),this}setEnd(t){return Vs(this.refs.end,t,"SplitView end"),this}collapse(t){let e=this.options.collapsible==="end"?"end":"start";return this.#o(t==="end"?"end":t==="start"?"start":e,!0)}expand(){return this._collapsed===null?this:(this._collapsed=null,delete this.el.dataset.collapsed,this.#r(),this.emit("expand"),this)}isCollapsed(){return this._collapsed??!1}enable(){return this._disabled=!1,this.refs.divider.removeAttribute("aria-disabled"),this.refs.divider.setAttribute("tabindex","0"),this}disable(){return this._disabled=!0,this.#s?.cancel(),delete this.el.dataset.dragging,this.refs.divider.setAttribute("aria-disabled","true"),this.refs.divider.setAttribute("tabindex","-1"),this}isDisabled(){return this._disabled}destroy(){this._destroyed||(this._destroyed=!0,this.#s?.destroy(),this.#s=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&C(this.el,this._snapshot))}#i(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,s=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:ul(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(s)?s:null}}#n(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#r()}#r(){let{total:t,divider:e,min:s,max:r}=this.#i(),n=Hs({min:s,max:r,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(n.min))),o.setAttribute("aria-valuemax",String(Math.round(n.max))),o.setAttribute("aria-valuenow",String(Math.round(this.getSize())))}#o(t,e){return this._collapsed===t?this:(this._collapsed=t,this.el.dataset.collapsed=t,this.#r(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:s,divider:r,min:n,max:o}=this.#i();if(s<=0)return;this._collapsed!==null&&this.expand();let a=vt({size:this._startSize+t,min:n,max:o,total:s,divider:r});e&&(a=vt({size:rn(a,this.#u(s,r),Number(this.options.snap)),min:n,max:o,total:s,divider:r})),a!==this._size&&(this.#n(a),this.emit("resize",{size:a,ratio:a/s}))}#l(t){let{total:e,divider:s,min:r,max:n}=this.#i();e<=0||(this._collapsed!==null&&this.expand(),this.#h(vt({size:this.getSize()+t,min:r,max:n,total:e,divider:s}),e))}#c(t){let{total:e,divider:s,min:r,max:n}=this.#i();if(e<=0)return;this._collapsed!==null&&this.expand();let o=Hs({min:r,max:n,total:e,divider:s});this.#h(vt({size:o[t],min:r,max:n,total:e,divider:s}),e)}#h(t,e){t!==this._size&&(this.#n(t),this.emit("resize",{size:t,ratio:t/e}),this.#m(),this.#p())}#u(t,e){let{min:s,max:r}=this.#i(),n=Hs({min:s,max:r,total:t,divider:e}),o=[n.min,n.max],a=it(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#d(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=it(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",js(this.options.size)),this._lastTotal=-1,this.#f());let{total:e}=this.#i(),s=this.getSize();this.emit("resize",{size:s,ratio:e>0?s/e:0}),this.#m(),this.#p()}#f(){if(this._destroyed||this.#s?.isDragging())return;let{total:t,divider:e,min:s,max:r}=this.#i();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=it(this.options.size,t);if(Number.isFinite(o)){let a=vt({size:o,min:s,max:r,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:js(this.options.size))}this.#r();return}let n=vt({size:this._size,min:s,max:r,total:t,divider:e});if(n===this._size){this.#r();return}this.#n(n),this.emit("resize",{size:n,ratio:n/t})}#m(){let t=this.options.storageKey;!this.#e||t==null||t===""||(this._size===null?this.#e.remove(String(t)):this.#e.set(String(t),Math.round(this._size)))}#p(){let{total:t}=this.#i(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function vt({size:i,min:t=0,max:e=null,total:s=0,divider:r=0}){let n=Number(i),o=Hs({min:t,max:e,total:s,divider:r});return Math.max(0,(Number(s)||0)-Math.max(0,Number(r)||0))>0?Number.isFinite(n)?Math.min(o.max,Math.max(o.min,n)):o.min:Number.isFinite(n)?Math.max(0,n):o.min}function rn(i,t,e){let s=Number(i),r=Number(e);if(!Number.isFinite(s)||!Number.isFinite(r)||r<=0)return s;let n=Array.isArray(t)?t:t==null?[]:[t],o=s,a=Number.POSITIVE_INFINITY;for(let c of n){let h=Number(c);if(!Number.isFinite(h))continue;let u=Math.abs(h-s);u<=r&&u<a&&(a=u,o=h)}return o}function Hs({min:i=0,max:t=null,total:e=0,divider:s=0}){let r=Math.max(0,(Number(e)||0)-Math.max(0,Number(s)||0)),n=t==null||!Number.isFinite(Number(t))?r:Math.min(r,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(i)||0),n),max:n}}function ul(i,t){let e=i.getBoundingClientRect(),s=t==="vertical"?e.height:e.width;return Number.isFinite(s)&&s>0?s:0}function js(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function Vs(i,t,e){if(i.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){i.append(document.createTextNode(String(t)));return}let s=t instanceof m?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Xd="dock",Ks=class extends m{static cssName="dock";static defaults={orientation:"vertical",content:null,panes:[],resizable:!0,collapsible:!0,lazy:!0,storageKey:null,label:"Resize panes"};constructor(t=null,e={}){super(t,e);let s=this.options.storageKey;if(s!=null&&s!==""){this._store=de(Xd);let r=this._store.get(String(s));r&&typeof r=="object"&&this.setState(r)}this._syncGrow(),this._syncDividers()}render(){let t=this.options;this._orientation=t.orientation==="horizontal"?"horizontal":"vertical",this._resizable=t.resizable!==!1,this._lazy=t.lazy!==!1,this._destroyed=!1,this._panes=new Map,this._store=null,this._drag=null,this._dividerDrags=[],this._createdRoot=!this.el;let e=this.el??l("div");this.el=e,this._snapshot=this._createdRoot?null:k(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&on(this._content,t.content,!1);for(let s of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(s.name),this._buildPane(s));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let s=String(t?.name??"");if(!s)throw new TypeError("Dock pane requires a name");this._panes.has(s)&&this.remove(s);let r=this._buildPane(t),n=[...this._panes.entries()],o=Number.isInteger(e.index)?M(Number(e.index),0,n.length):n.length;return n.splice(o,0,[s,r]),this._panes=new Map(n),this._layout(),this._syncGrow(),this._syncDividers(),r}remove(t){let e=this._panes.get(String(t));return e?e.kind==="sheet"?this.release(e.sheet):(e.roving?.destroy(),e.element.remove(),this._panes.delete(String(t)),this._layout(),this._syncGrow(),this._syncDividers(),this):this}collapse(t){let e=this._panes.get(String(t));return!e||!e.collapsible||e.collapsed?this:(e.collapsed=!0,this._syncPaneState(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("collapse",{name:e.name}),this)}expand(t){let e=this._panes.get(String(t));return!e||!e.collapsed?this:(e.collapsed=!1,this._syncPaneState(e),this._materialize(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("expand",{name:e.name}),this)}toggle(t){let e=this._panes.get(String(t));return e?e.collapsed?this.expand(t):this.collapse(t):this}isCollapsed(t){return!!this._panes.get(String(t))?.collapsed}reveal(t){let e=String(t),s=this._panes.get(e);if(s)this.expand(e);else for(let r of this._panes.values())if(r.tabs?.has(e)){s=r,this.expand(r.name),this.activate(r.name,e);break}return s?(s.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:s.name}),this):this}setSize(t,e){let s=this._panes.get(String(t));if(!s)return this;let r=nn(e);return r===null?s.element.style.removeProperty("--zx-pane-size"):s.element.style.setProperty("--zx-pane-size",r),this._syncDividers(),this._persist(),this}getSize(t){let e=this._panes.get(String(t));return e?this._axisSize(e.element):0}activate(t,e){let s=this._panes.get(String(t)),r=s?.tabs?.get(String(e));if(!r||s.active===r.name)return this;let n=s.active;s.active=r.name;for(let o of s.tabs.values()){let a=o===r;o.tab.setAttribute("aria-selected",String(a)),o.tab.tabIndex=a?0:-1,o.panel.hidden=!a}return this._materialize(s),this._persist(),this.emit("tabchange",{pane:s.name,tab:r.name,previous:n}),this}getActive(t){return this._panes.get(String(t))?.active??null}state(){let t={sizes:{},collapsed:[],active:{}};for(let e of this._panes.values())if(e.kind!=="sheet"){if(e.collapsed)t.collapsed.push(e.name);else if(!e.grow){let s=this._axisSize(e.element);s>0&&(t.sizes[e.name]=s)}e.active&&(t.active[e.name]=e.active)}return t}setState(t){if(!t||typeof t!="object")return this;let e=new Set(Array.isArray(t.collapsed)?t.collapsed.map(String):[]);for(let s of this._panes.values()){if(s.kind==="sheet")continue;let r=t.sizes?.[s.name];typeof r=="number"&&Number.isFinite(r)&&r>0&&s.element.style.setProperty("--zx-pane-size",`${r}px`);let n=t.active?.[s.name];n&&s.tabs?.has(String(n))&&this.activate(s.name,String(n));let o=e.has(s.name);o!==s.collapsed&&s.collapsible&&(s.collapsed=o,this._syncPaneState(s))}return this._syncGrow(),this._syncDividers(),this}destroy(){if(!this._destroyed){this._destroyed=!0;for(let t of this._dividerDrags)t.destroy();this._dividerDrags=[];for(let t of this._panes.values())t.roving?.destroy(),t.breakpoint?.destroy(),t.kind==="sheet"&&t.sheet._setDock(null);super.destroy(),!this._createdRoot&&this._snapshot&&C(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),s=String(t.title??""),r=t.collapsible??this.options.collapsible!==!1,n=y("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,a=l("span",{class:"zx-dock__chevron",ariaHidden:"true"},_("chevron-right",{size:14})),c=l("button",{class:"zx-dock__toggle",type:"button",ariaControls:n,ariaExpanded:"true",ariaLabel:o?s||e:null},a,o?null:l("span",{class:"zx-dock__title"},s));r||(c.disabled=!0);let h=l("div",{class:"zx-dock__header"},c),u=l("div",{class:"zx-dock__body",id:n}),d=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},h,u),p={name:e,title:s,element:d,header:h,body:u,toggle:c,collapsible:r,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){p.tabs=new Map;let g=l("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:s||e});for(let b of t.tabs){let w=String(b.name),D=y("zx-dock-tab"),U=y("zx-dock-panel"),qn=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:D,ariaControls:U,ariaSelected:"false",tabindex:-1},String(b.title??w)),jn=l("div",{class:"zx-dock__panel",role:"tabpanel",id:U,ariaLabelledby:D,tabindex:0,hidden:!0});g.append(qn),u.append(jn),p.tabs.set(w,{name:w,tab:qn,panel:jn,content:b.content,built:!1})}h.append(g),p.roving=mt(g,".zx-dock__tab",{orientation:"horizontal"}),this.listen(g,"click",b=>{let w=b.target.closest?.(".zx-dock__tab");if(!w||!g.contains(w))return;let D=[...p.tabs.values()].find(U=>U.tab===w);D&&this.activate(p.name,D.name)});let x=String(t.active??""),v=p.tabs.has(x)?x:[...p.tabs.keys()][0];p.active=v;for(let b of p.tabs.values()){let w=b.name===v;b.tab.setAttribute("aria-selected",String(w)),b.tab.tabIndex=w?0:-1,b.panel.hidden=!w}}else p.content=l("div",{class:"zx-dock__pane-content"}),u.append(p.content),p.factory=t.content;let f=nn(t.size);return f!==null&&d.style.setProperty("--zx-pane-size",f),r&&this.listen(c,"click",()=>this.toggle(p.name)),t.collapsed&&r&&(p.collapsed=!0,this._syncPaneState(p)),(!this._lazy||!p.collapsed)&&this._materialize(p),p}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,on(e.panel,e.content,!0);return}t.built||(t.built=!0,on(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(r=>r.kind!=="sheet"||r.sheet.isDocked()),e=this._content?[...t.filter(r=>r.side==="start"),this._content,...t.filter(r=>r.side==="end")]:t;for(let r of this._dividerDrags)r.destroy();this._dividerDrags=[];let s=[];e.forEach((r,n)=>{n>0&&s.push(this._divider()),s.push(r instanceof Element?r:r.element)}),this.el.replaceChildren(...s)}_divider(){let t=l("div",{class:"zx-dock__divider",role:"separator",tabindex:this._resizable?0:-1,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(this.options.label??"Resize panes")});return this._dividerDrags.push(ye(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:s}=this._neighbours(t),r=this._resizeSubject(e,s);return r?(this._drag={subject:r,startSize:this._axisSize(r.element),oppositeStart:r.opposite?this._axisSize(r.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,s)=>{s&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,s&&this._persist()},onStep:(e,s)=>this._stepDivider(t,e*(s?64:16)),onActivate:()=>{let{before:e}=this._neighbours(t);e?.collapsible&&this.toggle(e.name)}})),t}_isHidden(t){return t.kind==="sheet"?!t.sheet.isOpen():!!t.collapsed}adopt(t,e={}){if(!t||typeof t._setDock!="function"||!t.el)throw new TypeError("Dock.adopt expects a Sheet");let s=String(e.name??t.el.id??"")||y("zx-dock-sheet"),r={kind:"sheet",name:s,sheet:t,element:t.el,side:e.side==="end"?"end":"start",min:Number.isFinite(e.min)?Math.max(0,Number(e.min)):0,grow:!1,collapsed:!1,collapsible:!1,breakpoint:null,resync:null},n=[...this._panes.entries()],o=Number.isInteger(e.index)?M(Number(e.index),0,n.length):n.length;n.splice(o,0,[s,r]),this._panes=new Map(n);let a=nn(e.size);a!==null&&t.el.style.setProperty("--zx-pane-size",a),r.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",r.resync),t.on("close",r.resync);let c=e.dockAt??null;return c?r.breakpoint=ue((h,u)=>{this._applyDockAt(r,Ss(c,u))},{target:this.el}):this._applyDockAt(r,!0),r}release(t){let e=[...this._panes.values()].find(s=>s.sheet===t);return e?(e.breakpoint?.destroy(),e.breakpoint=null,this._panes.delete(e.name),t.off("open",e.resync),t.off("close",e.resync),t.el.style.removeProperty("--zx-pane-size"),t._setDock(null),this._layout(),this._syncGrow(),this._syncDividers(),this):this}_forget(t){let e=[...this._panes.values()].find(s=>s.sheet===t);e&&(e.breakpoint?.destroy(),this._panes.delete(e.name),!this._destroyed&&(this._layout(),this._syncGrow(),this._syncDividers()))}_applyDockAt(t,e){t.sheet.isDocked()!==e&&(t.sheet._setDock(e?this:null),this._layout(),this._syncGrow(),this._syncDividers())}_syncGrow(){let t=[...this._panes.values()];for(let r of t)r.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(r=>!this._isHidden(r));if(e.length===0)return;let s=e.find(r=>r.grow);(s??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:s}=this._neighbours(t),r=this._resizeSubject(e,s),n=this._resizable&&r!==null;if(t.toggleAttribute("data-disabled",!n),t.tabIndex=n?0:-1,!n){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(r.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(r)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",r.element.id||tf(r.element))}}_syncPaneState(t){t.element.dataset.state=t.collapsed?"collapsed":"open",t.toggle.setAttribute("aria-expanded",String(!t.collapsed))}_dividers(){return[...this.el.querySelectorAll(":scope > .zx-dock__divider")]}_neighbours(t){let e=s=>{if(!s)return null;for(let r of this._panes.values())if(r.element===s)return r;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let s=r=>!!r&&!this._isHidden(r)&&r.element.dataset.grow!=="true";return s(t)?{element:t.element,record:t,sign:1,opposite:s(e)?e:null}:s(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let s=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),r=this._orientation==="vertical"?s.height:s.width;return Math.max(t.record.min,r)}_axisSize(t){let e=t.getBoundingClientRect();return this._orientation==="vertical"?e.height:e.width}_trackDelta(t){if(!this._drag||this._destroyed)return;let{subject:e,startSize:s,oppositeStart:r}=this._drag,n=this._minSize(e),o=Math.max(n,s+t*e.sign);if(e.opposite){let a=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(n,Math.min(o,s+r-a)),e.opposite.element.style.setProperty("--zx-pane-size",`${s+r-o}px`)}e.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this.emit("resize",{name:e.record.name,size:o})}_stepDivider(t,e){let{before:s,after:r}=this._neighbours(t),n=this._resizeSubject(s,r);if(!n)return;let o=Math.max(this._minSize(n),this._axisSize(n.element)+e*n.sign);n.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:n.record.name,size:o})}_persist(){let t=this.options.storageKey;!this._store||t===null||t===void 0||t===""||this._store.set(String(t),this.state())}};function tf(i){let t=y("zx-dock-pane");return i.id=t,t}function nn(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}function on(i,t,e){let s=e&&typeof t=="function"?t():t;if(s==null)return;if(typeof s=="string"||typeof s=="number"){i.append(document.createTextNode(String(s)));return}let r=s instanceof m?s.toElement():s;r&&typeof r.nodeType=="number"&&i.append(r)}var xe=class extends m{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[]};constructor(t,e={}){super(t,e),this._overflow=new K(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",s=>{let r=this._find(String(s.detail.value));!r||r.definition.disabled||(this.setActive(r.definition.name),r.definition.onselect?.(r.definition.name,r.definition,this),r.definition.href&&globalThis.location?.assign(r.definition.href))}),this._syncOverflow()}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:sf(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null;let s=l("header",{class:"zx-navigation-bar__bar"},l("div",{class:"zx-navigation-bar__brand",ref:"title"}),l("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},l("div",{class:"zx-navigation-bar__items",ref:"items"}),l("div",{class:"zx-navigation-bar__more",ref:"more"},l("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),l("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),r=l("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(s,r),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",n=>this._onTabKeydown(n)),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setItems(t){if(!Array.isArray(t))throw new TypeError("NavigationBar items must be an array");let e=this._activeName,s=new Set,r=t.map(h=>{if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("Navigation item must be an object");if(typeof h.name!="string"||h.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(s.has(h.name))throw new RangeError(`Navigation item already exists: ${h.name}`);if(s.add(h.name),Object.hasOwn(h,"content")&&!ef(h.content))throw new TypeError(`Navigation panel content for ${h.name} is invalid`);let u={name:h.name,title:String(h.title??""),badge:h.badge==null?null:String(h.badge),href:h.href==null?void 0:String(h.href),disabled:!!h.disabled,onselect:typeof h.onselect=="function"?h.onselect:void 0};return Object.hasOwn(h,"content")&&(u.content=h.content),u}),n=r.some(h=>Object.hasOwn(h,"content"));if(n&&r.some(h=>!Object.hasOwn(h,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=n,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let h of r)this._appendItem(h);let o=e??this.options.active,a=o===null?null:this._find(o),c=a&&!a.definition.disabled?a:this._enabledItems()[0];return c&&this._applyActive(c),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let s=this._require(t);return s.definition.badge=e===null?null:String(e),s.badge.textContent=s.definition.badge??"",s.badge.hidden=s.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(s=>{if(N(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=j(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&rf(this.el,this._original))}_appendItem(t){let e=y("zx-navigation-item"),s=y("zx-navigation-panel"),r=l("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),n={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=l("button",{...n,type:"button",role:"tab",tabindex:"-1",ariaControls:s,ariaSelected:"false"},l("span",{class:"zx-navigation-bar__label"},t.title),r):t.href?o=l("a",{...n,href:t.href},l("span",{class:"zx-navigation-bar__label"},t.title),r):o=l("button",{...n,type:"button"},l("span",{class:"zx-navigation-bar__label"},t.title),r);let a=null;this._tabMode&&(a=l("div",{class:"zx-navigation-bar__panel",id:s,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(a));let c={definition:t,item:o,badge:r,panel:a,built:!1};this._items.push(c),this.refs.items.append(o),this.listen(o,"click",h=>{if(c.definition.disabled){h.preventDefault();return}this.setActive(c.definition.name),c.definition.onselect?.(c.definition.name,c.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let s=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(s)),e.item.tabIndex=s?0:-1,e.panel&&(e.panel.hidden=!s)):s?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,s=typeof e=="function"?e():e,r=s instanceof m?s.toElement():s;if(!r||typeof r.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(r),t.built=!0}_onTabKeydown(t){if(!this._tabMode)return;let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.items.contains(e))return;let s=this._items.find(n=>n.item===e);if(!s)return;let r=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),a=r[(o+n+r.length)%r.length];a&&this._focusTab(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._focusTab(n);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(s.definition.name))}_syncOverflow(){this._overflow&&(this.refs.more.dataset.empty=this._items.length===0?"true":"false",this._overflow.setItems(this._items.map(t=>({label:t.definition.badge===null?t.definition.title:`${t.definition.title} (${t.definition.badge})`,value:t.definition.name,disabled:t.definition.disabled}))))}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function ef(i){return typeof i=="function"||i instanceof m?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function sf(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function rf(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function fl(i){if(!Array.isArray(i))throw new TypeError("Stepper steps must be an array");let t=new Set;return i.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Step definition must be an object");if(typeof e.name!="string"||e.name==="")throw new TypeError("Step name must be a non-empty string");if(t.has(e.name))throw new RangeError(`Step already exists: ${e.name}`);return t.add(e.name),{name:e.name,title:String(e.title??""),description:e.description==null?null:String(e.description),optional:!!e.optional,disabled:!!e.disabled}})}function Us(i,t){return t===null?-1:i.findIndex(e=>e.name===t)}function Ys(i,t,e){let s=e<0?-1:1,r=t<0?s>0?0:i.length-1:t+s;for(;r>=0&&r<i.length;){if(!i[r].disabled)return r;r+=s}return-1}function pl(i,t,e){return t<0||e<=t?[]:i.slice(t,e).map(s=>s.name)}function ml(i,t,e={}){let{activeIndex:s=-1,completed:r,errored:n}=e;return dl(n,i.name)?"error":t===s?"active":dl(r,i.name)?"complete":"upcoming"}function dl(i,t){return i?i instanceof Set?i.has(t):i.includes(t):!1}var nf=new Set(["horizontal","vertical"]),of=new Set(["completed","all",!1]),Ws=class extends m{static cssName="stepper";static defaults={steps:[],active:null,orientation:"horizontal",clickable:"completed",showNumbers:!0,counter:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!nf.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!of.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??l("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=l("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),s=l("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,s]:[s]),this.setSteps(this.options.steps),this.listen(s,"click",r=>{let n=r.target.closest?.(".zx-stepper__control");if(!n||!s.contains(n)||n.tagName!=="BUTTON")return;let o=n.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),s=fl(t),r=new Set(s.map(a=>a.name));this._steps=s,this._completed=new Set([...this._completed].filter(a=>r.has(a))),this._errored=new Set([...this._errored].filter(a=>r.has(a)));let n=e??(this.options.active===null?null:String(this.options.active)),o=n===null?-1:Us(s,n);return o>=0&&s[o].disabled&&(o=-1),o<0&&(o=Ys(s,-1,1)),this._activeIndex=o,this._records=s.map(a=>this._createRecord(a)),this.refs.list.replaceChildren(...this._records.map(a=>a.item)),this._sync(),this}goTo(t){let e=Us(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Ys(this._steps,this._activeIndex,1))}previous(){return this._activate(Ys(this._steps,this._activeIndex,-1))}getActive(){return this._activeIndex<0?null:this._steps[this._activeIndex].name}getIndex(){return this._activeIndex}complete(t){return this._require(t),this._completed.add(t),this._sync(),this}uncomplete(t){return this._require(t),this._completed.delete(t),this._sync(),this}setError(t,e=!0){return this._require(t),e?this._errored.add(t):this._errored.delete(t),this._sync(),this}setDisabled(t,e=!0){return this._require(t).disabled=!!e,this._sync(),this}getState(){return{active:this.getActive(),index:this._activeIndex,completed:this._steps.filter(t=>this._completed.has(t.name)).map(t=>t.name),errored:this._steps.filter(t=>this._errored.has(t.name)).map(t=>t.name)}}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}_activate(t){if(t<0||t>=this._steps.length||t===this._activeIndex)return this;let e=this._steps[t];if(e.disabled)return this;let s=this._activeIndex;if(this.emit("change",{name:e.name,previous:s<0?null:this._steps[s].name,index:t}).defaultPrevented)return this;for(let n of pl(this._steps,s,t))this._completed.add(n);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=l("span",{class:"zx-stepper__marker",ariaHidden:"true"}),s=l("span",{class:"zx-stepper__status"}),r=[l("span",{class:"zx-stepper__title"},t.title)];t.description&&r.push(l("span",{class:"zx-stepper__description"},t.description)),t.optional&&r.push(l("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let n=[e,l("span",{class:"zx-stepper__text"},r),s],o=this.options.clickable===!1?l("span",{class:"zx-stepper__control"},n):l("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},n);return{step:t,item:l("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:s}}_sync(){this._records.forEach((t,e)=>{let s=this._stateFor(t.step,e);t.item.dataset.state=s,e===this._activeIndex?t.item.setAttribute("aria-current","step"):t.item.removeAttribute("aria-current"),t.item.toggleAttribute("data-disabled",t.step.disabled),t.marker.replaceChildren(...this._markerContent(s,e)),t.status.textContent=this._statusText(s),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return ml(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[_("check",{size:12})]:t==="error"?[_("warning",{size:12})]:this.options.showNumbers?[String(e+1)]:[]}_statusText(t){return t==="complete"?this._message("stepper.completed","Completed"):t==="error"?this._message("stepper.error","Error"):t==="active"?this._message("stepper.current","Current step"):""}_isClickable(t){return t.disabled?!1:this.options.clickable==="all"?!0:this.options.clickable==="completed"?this._completed.has(t.name):!1}_syncCounter(){if(!this.options.counter)return;let t=this.refs.counter;t.hidden=this._activeIndex<0,t.textContent=this._activeIndex<0?"":this._message("stepper.counter","Step %1 of %2",this._activeIndex+1,this._steps.length)}_require(t){let e=Us(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...s){let r=this.msg(t,...s);return r===t?F(e,s):r}};var af=new Set(["chevron","slash"]),Gs=class extends m{static cssName="breadcrumb";static defaults={items:[],maxVisible:0,separator:"chevron",rootIcon:null};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!af.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=l("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",s=>{let r=s.target.closest?.("[data-crumb]");!r||!e.contains(r)||this._select(r.dataset.crumb)}),t}setItems(t){if(!Array.isArray(t))throw new TypeError("Breadcrumb items must be an array");let e=new Set;return this._items=t.map(s=>{if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Breadcrumb item must be an object");if(typeof s.name!="string"||s.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(s.name))throw new RangeError(`Breadcrumb item already exists: ${s.name}`);return e.add(s.name),{name:s.name,label:String(s.label??""),icon:s.icon?String(s.icon):null,href:s.href==null?null:String(s.href)}}),this._build(),this}getItems(){return this._items.map(t=>({...t}))}push(t){return this.setItems([...this._items,t])}pop(){if(this._items.length===0)return null;let t=this._items[this._items.length-1];return this.setItems(this._items.slice(0,-1)),t}truncateTo(t){let e=this._items.findIndex(s=>s.name===t);if(e<0)throw new RangeError(`Unknown breadcrumb item: ${t}`);return this.setItems(this._items.slice(0,e+1))}destroy(){if(this._destroyed)return;this._destroyed=!0,this._overflow?.destroy(),this._overflow=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:s}=this._split(),r=this._items[this._items.length-1]??null,n=[];for(let o of t)n.push(this._renderItem(o,o===r));e.length>0&&n.push(this._renderOverflow(e));for(let o of s)n.push(this._renderItem(o,o===r));this.refs.list.replaceChildren(...n.map((o,a)=>l("li",{class:"zx-breadcrumb__item"},a===0?o:[this._renderSeparator(),o]))),e.length===0&&this._overflow?.toElement().remove()}_split(){let t=this._items,e=Math.trunc(Number(this.options.maxVisible)||0);if(e<=0||t.length<=e)return{head:t,hidden:[],tail:[]};let s=Math.max(2,e);if(t.length<=s)return{head:t,hidden:[],tail:[]};let r=s-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-r),tail:t.slice(t.length-r)}}_renderItem(t,e){let s=[],r=t.icon??(t===this._items[0]?this.options.rootIcon:null);return r&&s.push(l("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},_(String(r),{size:13}))),s.push(l("span",{class:"zx-breadcrumb__label"},t.label)),e?l("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},s):t.href!==null?l("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},s):l("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},s)}_renderOverflow(t){if(!this._overflow){this._overflow=new K(null,{label:"",icon:"dots",kind:"ghost",placement:"bottom-start"});let e=this._overflow.toElement();e.classList.add("zx-breadcrumb__more"),e.setAttribute("aria-label",this._message("breadcrumb.more","Show hidden levels")),this._overflow.on("select",s=>this._select(String(s.detail.value)))}return this._overflow.setItems(t.map(e=>({label:e.label,value:e.name,icon:e.icon??void 0}))),this._overflow.toElement()}_renderSeparator(){return l("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":_("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(s=>s.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...s){let r=this.msg(t,...s);return r===t?F(e,s):r}};var Zs="\u2026",lf=new Set(["pages","loadmore"]);function cn({page:i=1,pages:t=1,siblings:e=1,boundaries:s=1}={}){let r=Gt(t);if(r<=0)return[];let n=ln(Gt(i)||1,1,r),o=Math.max(0,Gt(e)),a=Math.max(0,Gt(s)),c=a*2+o*2+3;if(r<=c)return Qs(1,r);let h=Qs(1,Math.min(a,r)),u=Qs(Math.max(r-a+1,a+1),r),d=Math.max(Math.min(n-o,r-a-o*2-1),a+2),p=Math.min(Math.max(n+o,a+o*2+2),u.length>0?u[0]-2:r-1);return[...h,...d>a+2?[Zs]:a+1<r-a?[a+1]:[],...Qs(d,p),...p<r-a-1?[Zs]:r-a>a?[r-a]:[],...u]}var Js=class extends m{static cssName="pagination";static defaults={page:1,pageSize:25,total:0,pageSizes:[25,50,100],siblings:1,boundaries:1,showPageSize:!0,showSummary:!0,mode:"pages",disabled:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el),this._destroyed=!1,this._pageSize=an(this.options.pageSize,25),this._total=Math.max(0,Gt(this.options.total)),this._page=Math.max(1,Gt(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(s=>an(s,0)).filter(s=>s>0),!lf.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=ln(this._page,1,this._pageCount());let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("pagination.label","Pagination")),t.dataset.mode=this.options.mode;let e=[];return this.options.showSummary&&e.push(l("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),e.push(l("span",{class:"zx-pagination__spacer"})),this.options.showPageSize&&e.push(this._renderPageSize()),e.push(this.options.mode==="pages"?this._renderPages():this._renderLoadMore()),t.replaceChildren(...e),this._sync(),this._wire(),t}setPage(t){return this.setState({page:t})}setTotal(t){return this.setState({total:t},{silent:!0})}setPageSize(t){return this.setState({pageSize:t,page:1})}setState(t={},{silent:e=!1}={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pagination state must be an object");let s=this._page,r=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,Gt(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=an(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let n=Math.trunc(Number(t.page));Number.isFinite(n)&&(this._page=n)}return this._page=ln(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==s||this._pageSize!==r)&&this.emit("change",this.getState()),this}getState(){let t=this._pageCount();return{page:this._page,pageSize:this._pageSize,total:this._total,pages:t,offset:(this._page-1)*this._pageSize}}enable(){return this._disabled=!1,this._sync(),this}disable(){return this._disabled=!0,this._sync(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}_pageCount(){return this._total<=0?1:Math.ceil(this._total/this._pageSize)}_renderPageSize(){let t=this._message("pagination.pageSize","Rows per page");return l("label",{class:"zx-pagination__size"},l("span",{class:"zx-pagination__size-label"},t),l("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return l("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),l("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,s){return l("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:s,dataset:{kind:"default",size:"sm"}},_(e,{size:14}))}_renderLoadMore(){return l("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},l("span",{class:"zx-btn__label"},this._message("pagination.loadMore","Load more")))}_wire(){if(this.refs.select&&this.listen(this.refs.select,"change",()=>{this.setPageSize(Number(this.refs.select.value))}),this.options.mode==="pages"){this.listen(this.refs.prev,"click",()=>this.setPage(this._page-1)),this.listen(this.refs.next,"click",()=>this.setPage(this._page+1)),this.listen(this.refs.pages,"click",t=>{let e=t.target.closest?.("[data-page]");!e||!this.refs.pages.contains(e)||this.setPage(Number(e.dataset.page))});return}this.listen(this.refs.more,"click",()=>this.setPage(this._page+1))}_sync(){let t=this._pageCount();if(this.el.dataset.disabled=this._disabled?"true":"false",this.refs.summary&&(this.refs.summary.textContent=this._summary()),this.refs.select&&this._syncPageSize(),this.options.mode==="pages"){this.refs.prev.disabled=this._disabled||this._page<=1,this.refs.next.disabled=this._disabled||this._page>=t,this._syncPages(t);return}this.refs.more.disabled=this._disabled||this._page>=t}_summary(){if(this._total<=0)return this._message("pagination.empty","0 of 0");let t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize,this._total);return this.options.mode==="loadmore"?this._message("pagination.loaded","%1 of %2",We(e),We(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",We(t+1),We(e),We(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((r,n)=>r-n),s=e.join(",");s!==this._sizeKey&&(this._sizeKey=s,t.replaceChildren(...e.map(r=>l("option",{value:String(r)},String(r))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,s=this.el.ownerDocument?.activeElement??null,r=s&&e.contains(s)?s.dataset.page??null:null,n=cn({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...n.map(a=>a===Zs?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Zs):l("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:a===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",a),dataset:{kind:"default",size:"sm",page:String(a)}},String(a)))),r===null)return;let o=e.querySelector(`[data-page="${r}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...s){let r=this.msg(t,...s);return r===t?F(e,s):r}};function Gt(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:0}function an(i,t){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:t}function ln(i,t,e){return Math.min(Math.max(i,t),e)}function Qs(i,t){return t<i?[]:Array.from({length:t-i+1},(e,s)=>i+s)}function We(i){return i.toLocaleString()}var Xs=class extends m{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k"};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,a=>[a.name,a.value]),children:Array.from(t.childNodes)},this._items=hn(this.options.items),this._sources=gl(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=y("zx-launcher-results"),s=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:this.options.label,placeholder:this.options.placeholder,value:this._query}),r=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:"Close launcher"},_("x")),n=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),o=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:"Launcher results"});return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search"},_("search"),s,r),n,o)),t.dataset.state="closed",this._createdRoot&&document.body.append(t),this.listen(s,"input",()=>{this._query=s.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(s,"keydown",a=>this._onKeydown(a)),this.listen(r,"click",()=>this.close()),this.listen(o,"click",a=>{let c=a.target?.closest?.("[data-launcher-index]");!c||!o.contains(c)||this._activate(Number(c.getAttribute("data-launcher-index")),a)}),this.listen(t,"cancel",a=>{a.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",s.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",a=>this._onDocumentKeydown(a)),this._renderResults(),t}open(){return this.isOpen()||this._destroyed?this:(this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this)}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=hn(t),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=gl(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(n=>t.length>=Math.max(Number(this.options.minQuery)||0,Number(n.minQuery)||0));if(e.length===0)return;let s=new AbortController,r=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async n=>{try{let o=await n.load(t,{signal:s.signal});if(s.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(n.id,hn(o).map(a=>({...a,_source:n.id,group:a.group??n.label??""}))),this._renderResults()}catch(o){if(s.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:n,error:o})}})),!(s.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._setBusy(!1))}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=uf(this._sources,this._sourceItems),e=new Set,s=[...this._items.map(c=>({...c,_source:null})),...t].filter(c=>{let h=String(c.id);return e.has(h)?!1:(e.add(h),!0)}),r=un(s,this._query,this.options.maxResults),n=new Map;for(let c of r){let h=String(c.group??"");n.has(h)||n.set(h,[]),n.get(h).push(c)}this._results=[...n.values()].flat(),this._active=this._results.findIndex(c=>!c.disabled);let o=[],a=0;for(let[c,h]of n){let u=h.map(d=>this._option(d,a++));c?o.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:c},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},c),u)):o.push(...u)}this.refs.results.replaceChildren(...o),this._syncActive(),this._renderStatus()}_option(t,e){let s=t.href?"a":"button",r=[];return t.icon&&r.push(l("span",{class:"zx-launcher__icon"},_(t.icon))),r.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),l(s,{class:"zx-launcher__option",type:s==="button"?"button":null,href:t.href??null,target:t.target??null,role:"option",id:y("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,dataset:{launcherIndex:e,pinned:t.pinned?"true":null}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of t){let r=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(r))}let e=t.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((r,n)=>r.disabled?-1:n).filter(r=>r>=0);if(e.length===0)return;let s=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")s=0;else if(t.key==="End"||t.key==="PageDown")s=e.length-1;else if(t.key==="ArrowDown")s=(s+1+e.length)%e.length;else if(t.key==="ArrowUp")s=(s-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[s],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_activate(t,e){let s=this._results[t];if(!s||s.disabled){e.preventDefault();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}s.href||(e.preventDefault(),s.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||!t.metaKey&&!t.ctrlKey||t.altKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function un(i,t,e=100){let s=ve(t).trim(),r=i.map((o,a)=>({item:o,order:a,score:cf(o,s)})).filter(({score:o})=>o<1/0);r.sort((o,a)=>{if(s===""){let c=_l(o.item.pinned,o.order),h=_l(a.item.pinned,a.order);if(c!==h)return c-h}return o.score-a.score||hf(o.item.label,a.item.label)||o.order-a.order});let n=Math.max(0,Number(e)||0);return r.slice(0,n||0).map(({item:o,score:a})=>({...o,_score:a}))}function cf(i,t){if(!t)return i.pinned?-1:0;let e=ve(i.label),s=ve(i.id),r=ve(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||r.includes(t)?30:s.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function _l(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function ve(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function hf(i,t){let e=ve(i),s=ve(t);if(e<s)return-1;if(e>s)return 1;let r=String(i??"").normalize("NFC"),n=String(t??"").normalize("NFC");return r<n?-1:r>n?1:0}function hn(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label)})):[]}function gl(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}function uf(i,t){return i.flatMap(e=>t.get(String(e.id))??[])}var we=class extends m{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",status:null,statusLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,n=>[n.name,n.value]),children:Array.from(t.childNodes)},this._state={src:this.options.src,name:String(this.options.name??""),initials:this.options.initials,label:this.options.label,size:this.options.size,shape:this.options.shape,status:this.options.status,statusLabel:this.options.statusLabel};let e=l("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),s=l("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),r=l("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,s,r),this.listen(e,"load",()=>{this._isCurrentImageSource()&&this._showImage(!0)}),this.listen(e,"error",()=>{this._isCurrentImageSource()&&this._showImage(!1)}),this._sync(),t}set(t={}){if(!t||typeof t!="object")return this;for(let e of["src","name","initials","label","size","shape","status","statusLabel"])Object.hasOwn(t,e)&&(this._state[e]=t[e]);return this._sync(),this}setStatus(t,e=null){return this._state.status=t,this._state.statusLabel=e,this._syncLabel(),this._syncStatus(),this}hasImage(){return!this.refs.image.hidden}destroy(){let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:s}=this._state;this.el.dataset.size=typeof t=="string"?t:"custom",this.el.dataset.shape=["circle","rounded","square"].includes(e)?e:"circle",typeof t=="number"&&Number.isFinite(t)?this.el.style.setProperty("--zx-avatar-size",`${Math.max(1,t)}px`):this.el.style.removeProperty("--zx-avatar-size"),this._syncLabel(),this.refs.fallback.textContent=String(this._state.initials||dn(this._state.name));let r=this._state.src==null?"":String(this._state.src).trim();r?(this.refs.image.setAttribute("src",r),this._showImage(this.refs.image.complete&&this.refs.image.naturalWidth>0)):(this.refs.image.removeAttribute("src"),this._showImage(!1)),this._syncStatus()}_syncLabel(){let{label:t,status:e,statusLabel:s}=this._state;if(t){let r=["online","away","busy","offline"].includes(e)?s:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,r].filter(Boolean).join(", ")),this.el.removeAttribute("aria-hidden")}else this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true")}_showImage(t){this.refs.image.hidden=!t,this.refs.fallback.hidden=t,this.el.dataset.fallback=String(!t)}_isCurrentImageSource(){let t=this.refs.image,e=t.getAttribute("src");if(!e)return!1;try{return t.currentSrc===new URL(e,document.baseURI).href}catch{return t.currentSrc===e}}_syncStatus(){let e=["online","away","busy","offline"].includes(this._state.status)?this._state.status:null;this.refs.status.hidden=e===null,e?this.refs.status.dataset.status=e:delete this.refs.status.dataset.status;let s=this._state.statusLabel;s?this.refs.status.setAttribute("title",String(s)):this.refs.status.removeAttribute("title")}};function dn(i){let t=String(i??"").trim().split(/\s+/u).filter(Boolean);if(t.length===0)return"?";let e=bl(t[0]),s=t.length>1?bl(t[t.length-1]):"";return`${e}${s}`}function bl(i){return yl(yl(i).toUpperCase())}function yl(i){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(i)[Symbol.iterator]().next().value?.segment??"":Array.from(i)[0]??""}var ti=class extends m{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let s of["select","open","close"])this.listen(this.refs.trigger,`zx-${s}`,r=>r.stopPropagation());this._avatar=new we(this.refs.avatar,vl(this._account)),this._menu=new K(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",s=>{this.emit("select",s.detail).defaultPrevented&&s.preventDefault()}),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._renderIdentity()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._account=xl(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},l("span",{ref:"avatar",class:"zx-account-menu__avatar"}),l("span",{class:"zx-account-menu__identity"},l("span",{ref:"name",class:"zx-account-menu__name"}),l("span",{ref:"secondary",class:"zx-account-menu__secondary"})),l("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},_("chevron-down")))),t}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.toggle(),this}isOpen(){return this._menu.isOpen()}setAccount(t){return this._account=xl(t),this._avatar.set(vl(this._account)),this._renderIdentity(),this}setItems(t){return this._menu.setItems(t),this._renderPanelHeader(),this}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this._original;if(this._menu.destroy(),this._avatar.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_renderIdentity(){this.refs.name.textContent=this._account.name,this.refs.secondary.textContent=this._account.secondary,this.refs.secondary.hidden=!this._account.secondary;let e=["online","away","busy","offline"].includes(this._account.status)&&this._account.statusLabel?`, ${this._account.statusLabel}`:"",s=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",s),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(l("div",{class:"zx-account-menu__panel-identity",role:"presentation"},l("strong",{},this._account.name||"Account"),this._account.secondary?l("span",{},this._account.secondary):null))}};function xl(i){let t=i&&typeof i=="object"?i:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function vl(i){return{name:i.name,src:i.src??null,initials:i.initials??null,status:i.status??null,statusLabel:i.statusLabel??null,label:null,size:"md"}}var df=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),ff=new Set(["hover","focus","both","manual"]),Lt=class extends m{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#s=null;#i=null;#n=0;#r=0;#o=!1;#a=!1;#l=!1;constructor(t,e={}){let s=V(t);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=s,this.#e=this.options.content,this.#a=!!this.options.disabled,this.#i=s.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",_f(this.options.maxWidth));let r=ff.has(this.options.trigger)?this.options.trigger:"both";r!=="manual"&&((r==="hover"||r==="both")&&(this.listen(this.#t,"pointerenter",n=>{n.pointerType!=="touch"&&this.#c(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#h(Number(this.options.hideDelay)))),(r==="focus"||r==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!gf(this.#t)||this.#c(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(document,"keydown",n=>{n.key!=="Escape"||!this.isOpen()||(n.preventDefault(),this.hide())}),this.listen(document,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()},{capture:!0}),this.listen(document,"pointerup",()=>{this.#o=!1},{capture:!0}),this.listen(document,"pointercancel",()=>{this.#o=!1},{capture:!0}),this.listen(document,"focusin",n=>{!this.isOpen()||n.composedPath().includes(this.#t)||this.hide()}))}render(){let t=l("div",{id:y("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}show(){if(this.#l||this.#a||this.isOpen())return this;this.#u();let t=wl(this.#e);return t===null?this:(this.el.replaceChildren(t),this.#s=Y(this.#t,this.el,{placement:df.has(this.options.placement)?this.options.placement:"top",offset:Number(this.options.offset),flip:!0}),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",mf(this.#i,this.el.id)),this.emit("open"),this)}hide(){return this.#u(),this.isOpen()?(this.#s?.destroy(),this.#s=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#d(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#s!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=wl(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#s?.update(),this)}enable(){return this.#a=!1,this}disable(){return this.#a=!0,this.hide()}isDisabled(){return this.#a}getAnchor(){return this.#t}destroy(){this.#l||(this.#l=!0,this.hide(),this.#d(),super.destroy())}#c(t){if(this.#u(),this.#l||this.#a||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#n=setTimeout(()=>{this.#n=0,this.show()},e)}#h(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#r=setTimeout(()=>{this.#r=0,this.hide()},e)}#u(){this.#n!==0&&clearTimeout(this.#n),this.#r!==0&&clearTimeout(this.#r),this.#n=0,this.#r=0}#d(){this.#i===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#i)}};function Sl(i,t=""){return new Lt(i,pf(t)?t:{content:t})}function Al(i,t){return new Lt(i,{content:String(t??"")})}function pf(i){return i===null||typeof i!="object"||Array.isArray(i)||typeof i.nodeType=="number"?!1:typeof i.toElement!="function"}function wl(i){let t=typeof i=="function"?i():i;if(t==null)return null;if(typeof t=="object"&&typeof t.nodeType=="number")return t;if(typeof t=="object"&&typeof t.toElement=="function")return t.toElement();let e=String(t);return e===""?null:document.createTextNode(e)}function mf(i,t){let e=String(i??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function _f(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function gf(i){try{return i.matches(":focus-visible")}catch{return!0}}var Se=class extends m{static cssName="app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160};constructor(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??l("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,n=>[n.name,n.value]),children:Array.from(t.childNodes)},this._items=Rt(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,t.setAttribute("aria-label",String(this.options.label)),t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let e=t.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];t.dataset.side=e.includes(this.options.side)?this.options.side:e[0];let s=l("div",{class:"zx-app-rail__header"}),r=l("div",{class:"zx-app-rail__footer"});return Cl(s,this.options.header),Cl(r,this.options.footer),s.hidden=!s.hasChildNodes(),r.hidden=!r.hasChildNodes(),t.replaceChildren(s,l("ul",{ref:"list",class:"zx-app-rail__list"}),r),this.listen(t,"keydown",n=>this._onRailKeydown(n)),t}setItems(t){return this._items=Rt(t),this._rebuild(),this}setActive(t){return this._active=t,this._syncActive(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}openFlyout(t,{focus:e=!1}={}){let s=this._resolveFlyout(t);if(!s)return this;let r=[s],n=s.parentKey===null?null:this._flyouts.get(s.parentKey)??null;for(;n;)r.unshift(n),n=n.parentKey===null?null:this._flyouts.get(n.parentKey)??null;if(r.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(s,!0);for(let[o,a]of this._flyouts)o!==s.key&&a.dropdown.isOpen()&&!this._isAncestor(a,s)&&this.closeFlyout(o);for(let o of r)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&kl(s.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let s of[...this._flyouts.values()].reverse())s!==e&&this._isAncestor(e,s)&&(this._cancelTimers(s.key),s.dropdown.close());return this._cancelTimers(e.key),e.dropdown.close(),this}closeAllFlyouts(){for(let t of this._flyouts.values())t.parentKey===null&&this.closeFlyout(t.key);for(let t of[...this._flyouts.values()].reverse())this._cancelTimers(t.key),t.dropdown.isOpen()&&t.dropdown.close();return this}isFlyoutOpen(t){return this._resolveFlyout(t)?.dropdown.isOpen()??!1}focus(){return kl(this.refs.list)?.focus(),this}_containsNode(t){return!!(t&&(this.el.contains(t)||[...this._flyouts.values()].some(e=>e.panel.contains(t))))}destroy(){let t=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new fn(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,s=zl(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:bf(this.el.dataset.side)}),r=l("li",{class:"zx-app-rail__row"},s);this.refs.list.append(r);let n=new Lt(s,{content:t.label,placement:wf(this.el.dataset.side),delay:450});this._tooltips.push(n),this._tooltipById.set(String(t.id),n),e?this._buildFlyout(t,s,String(t.id),null):this._interaction.listen(s,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let c of this._flyouts.values())c.parentKey===null&&c.dropdown.isOpen()&&this.closeFlyout(c.key)})}),this._interaction.listen(document,"pointerdown",t=>{let e=[...this._flyouts.values()].filter(r=>r.dropdown.isOpen());if(e.length===0)return;let s=t.composedPath();if(!e.some(r=>s.includes(r.panel)||s.includes(r.trigger)))for(let r of e)r.parentKey===null&&this.closeFlyout(r.key)}),this._syncActive()}_buildFlyout(t,e,s,r){let n=l("ul",{class:"zx-app-rail__flyout-list"});for(let u of t.children??[]){let d=`${s}/${u.id}`,p=!!u.children?.length,f=zl(u,{className:"zx-app-rail__flyout-item",index:d,iconOnly:!1,disclosure:p,disclosureIcon:yf(this.el.dataset.side)});n.append(l("li",{},f)),p?this._buildFlyout(u,f,d,s):this._interaction.listen(f,"click",g=>{this._select(u,g).defaultPrevented||this._closeFlyoutChain(s)})}let o=l("div",{class:"zx-app-rail__flyout"},l("div",{class:"zx-app-rail__flyout-title"},t.label),n),a=new st(e,{openOn:"manual",placement:r===null?xf(this.el.dataset.side):vf(this.el.dataset.side),content:o,offset:6}),c=a.getPanel();c.classList.add("zx-app-rail__popover"),c.setAttribute("role","region"),c.setAttribute("aria-label",`${t.label} sub-navigation`);let h={key:s,parentKey:r,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(s,h),a.on("open",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),a.on("close",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",u=>{u.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(s)}),this._interaction.listen(e,"focusout",u=>{c.contains(u.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(e,"click",u=>{u.preventDefault(),u instanceof MouseEvent&&u.detail===0?this.openFlyout(s,{focus:!0}):a.isOpen()?this.closeFlyout(s):this.openFlyout(s)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(h,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"focusout",u=>{u.relatedTarget!==e&&!c.contains(u.relatedTarget)&&this._scheduleFlyoutClose(h,!0)}),this._interaction.listen(c,"keydown",u=>this._onFlyoutKeydown(u,h))}_select(t,e){if(t.disabled){e.preventDefault();let r=new Event("select",{cancelable:!0});return r.preventDefault(),r}let s=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return s.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),s}_onRailKeydown(t){let e=Sf(this.refs.list),s=t.target?.closest?.("[data-app-nav-id]"),r=e.indexOf(s);if(r<0)return;let n=this.el.dataset.orientation==="horizontal",o=n?"ArrowLeft":"ArrowUp",a=n?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],h=s.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(h))){t.preventDefault(),this.openFlyout(String(h),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(r-1+e.length)%e.length;else if(t.key===a)u=(r+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let s=Tl(e.panel),r=t.target?.closest?.("a, button"),n=s.indexOf(r);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let u=[...this._flyouts.values()].find(d=>d.trigger===r&&d.dropdown.isOpen());if(u){this.closeFlyout(u.key),this._restoreFocus(u.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(u=>u.trigger===r),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===a){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if(e.parentKey!==null&&t.key===c){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(s.length===0)return;let h;if(t.key==="Home")h=0;else if(t.key==="End")h=s.length-1;else if(t.key==="ArrowDown")h=(n+1+s.length)%s.length;else if(t.key==="ArrowUp")h=(n-1+s.length)%s.length;else return;t.preventDefault(),s[h]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},s))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let s=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let r=this._flyouts.get(e);r&&(this._branchInteracting(r)||this.closeFlyout(e))},s))}_scheduleFlyoutClose(t,e){let s=t;for(;s&&(this._scheduleClose(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(s=>String(s.item.id)===e)??null}_closeFlyoutChain(t){let e=this._flyouts.get(t)??null;for(;e?.parentKey!==null;)e=this._flyouts.get(e.parentKey)??null;e&&this.closeFlyout(e.key)}_isAncestor(t,e){let s=e.parentKey;for(;s!==null;){if(s===t.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let s=t;for(;s&&(this._cancelTimers(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_branchInteracting(t){return t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(e=>this._isAncestor(t,e)&&e.dropdown.isOpen()&&(e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)))}_restoreFocus(t){this._pointerFocus.add(t),t.focus(),queueMicrotask(()=>this._pointerFocus.delete(t))}_cancelTimers(t){this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t)}_cancelTimer(t,e){let s=t.get(e);s!==void 0&&clearTimeout(s),t.delete(e)}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=t!==null&&e.getAttribute("data-app-nav-value-id")===t,r=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),n=t!==null&&r?pn(r.item.children??[],t):!1;s?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),n?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&pn(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let r of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&r.getAttribute("data-app-nav-value-id")===t?r.setAttribute("aria-current","page"):r.removeAttribute("aria-current")}}_clearArtifacts(){for(let t of this._openTimers?this._openTimers.values():[])clearTimeout(t);for(let t of this._closeTimers?this._closeTimers.values():[])clearTimeout(t);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let t of this._tooltips??[])t.destroy();this._silenceFlyoutEvents=!0;for(let t of this._flyouts?.values?.()??[])t.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}},fn=class extends m{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function Rt(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),children:Array.isArray(t.children)?Rt(t.children):[]})):[]}function zl(i,{className:t,index:e,iconOnly:s,disclosure:r,disclosureIcon:n}){let o=i.href&&!r?"a":"button";return l(o,{class:t,type:o==="button"?"button":null,href:o==="a"?i.href:null,target:o==="a"?i.target??null:null,ariaLabel:s?i.label:null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(i.id)}},i.icon?l("span",{class:`${t}-icon`,ariaHidden:"true"},_(i.icon)):null,l("span",{class:`${t}-label`},i.label),i.badge!=null?l("span",{class:`${t}-badge`},String(i.badge)):null,r?l("span",{class:`${t}-disclosure`,ariaHidden:"true"},_(n)):null)}function bf(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function yf(i){return i==="right"?"chevron-left":"chevron-right"}function xf(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function vf(i){return i==="right"?"left-start":"right-start"}function wf(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function Tl(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function kl(i){return Tl(i)[0]??null}function Sf(i){return[...i.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function pn(i,t){return i.some(e=>String(e.id)===t||pn(e.children??[],t))}function Cl(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}var si=class extends m{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,side:"left",label:"Applications",header:null,footer:null,railHeader:null,railFooter:null};constructor(t=null,e={}){super(t,e),this.listen(this.refs.rail,"zx-select",n=>n.stopPropagation());let s=l("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:"Expand application sidebar"},_(this.el.dataset.side==="right"?"chevron-left":"chevron-right"));this._railExpandButton=s;let r=l("div",{class:"zx-app-sidebar__rail-header"},s);mn(r,this.options.railHeader),this._rail=new Se(this.refs.rail,{items:this._items,active:this._active,orientation:"vertical",side:this.el.dataset.side,label:this.options.label,header:r,footer:this.options.railFooter,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()}}),this.listen(s,"click",()=>{this.expand()}),this._renderTree(),this.setCollapsed(!!this.options.collapsed,{silent:!0})}render(){this._createdRoot=this.el===null;let t=this.el??l("aside");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,a=>[a.name,a.value]),children:Array.from(t.childNodes)},this._items=Rt(this.options.items),this._active=this.options.active,this._expanded=new Set(Array.isArray(this.options.expanded)?this.options.expanded.map(String):[]),this._collapsed=!!this.options.collapsed,t.dataset.side=this.options.side==="right"?"right":"left";let e=l("div",{class:"zx-app-sidebar__header-content"});mn(e,this.options.header);let s=l("button",{ref:"collapse",class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:"Minimize application sidebar"},_(t.dataset.side==="right"?"chevron-right":"chevron-left")),r=l("footer",{class:"zx-app-sidebar__footer"});mn(r,this.options.footer),r.hidden=!r.hasChildNodes();let n=l("div",{ref:"expanded",class:"zx-app-sidebar__expanded"},l("header",{class:"zx-app-sidebar__header"},e,s),l("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},l("ul",{ref:"list",class:"zx-app-sidebar__list"})),r),o=l("div",{ref:"rail",class:"zx-app-sidebar__rail"});return t.replaceChildren(n,o),this.listen(s,"click",()=>{this.collapse()}),this.listen(this.refs.list,"click",a=>this._onTreeClick(a)),t}setItems(t){return this._items=Rt(t),this._reconcileExpanded(),this._renderTree(),this._rail.setItems(this._items),this}setActive(t){return this._active=t,this._syncActive(),this._rail.setActive(t),this}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return _n(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let s=ei(this._items,t);if(!s?.children?.length)return this;let r=String(t),n=!this._expanded.has(r);return n?this._expanded.add(r):this._expanded.delete(r),this._renderTree(),e||this.emit("branchchange",{item:s,id:s.id,expanded:n,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){let s=!!t,r=s!==this._collapsed,n=document.activeElement,o=s&&!!(n&&this.refs.expanded.contains(n)),a=!s&&this._rail?._containsNode(n);return s||this._rail?.closeAllFlyouts(),this._collapsed=s,this.el.dataset.collapsed=String(s),this.refs.expanded.hidden=s,this.refs.rail.hidden=!s,o?this._railExpandButton?.focus():a&&this.refs.collapse.focus(),r&&!e&&this.emit("collapsechange",{collapsed:s}),this}isCollapsed(){return this._collapsed}getRail(){return this._rail}destroy(){let t=this._original;if(this._rail.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_renderTree(){let t=this.refs.list.contains(document.activeElement)?document.activeElement.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id"):null;if(this.refs.list.replaceChildren(...this._items.map(e=>this._treeRow(e,1))),this._syncActive(),t!==null){let e=[...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(s=>s.getAttribute("data-app-nav-id")===t)??null;zf(e)?.focus()}}_treeRow(t,e){let s=t.children??[],r=s.length>0,n=String(t.id),o=r&&this._expanded.has(n),a=r?y("zx-app-sidebar-branch"):null,c=Af(t,r,o,a),h=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},c);return r&&h.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},s.map(u=>this._treeRow(u,e+1)))),h}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let s=ei(this._items,e.getAttribute("data-app-nav-id"));if(!s||s.disabled){t.preventDefault();return}s.children?.length?this.toggleBranch(s.id):this._select(s,t)}_select(t,e){if(t.disabled){e.preventDefault();return}this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e}).defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.())}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=ei(this._items,e.getAttribute("data-app-nav-id")),r=t!==null&&e.getAttribute("data-app-nav-id")===t,n=t!==null&&s?El(s.children??[],t):!1;r?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),n?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_reconcileExpanded(){let t=new Set;_n(this._items,e=>{e.children?.length&&t.add(String(e.id))});for(let e of this._expanded)t.has(e)||this._expanded.delete(e)}};function Af(i,t,e,s){let r=i.href&&!t?"a":"button";return l(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?i.href:null,target:r==="a"?i.target??null:null,ariaDisabled:i.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:s,dataset:{appNavId:String(i.id)}},i.icon?l("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},_(i.icon)):null,l("span",{class:"zx-app-sidebar__item-label"},i.label),i.badge!=null?l("span",{class:"zx-app-sidebar__item-badge"},String(i.badge)):null,t?l("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},_(e?"chevron-down":"chevron-right")):null)}function zf(i){let t=i;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function ei(i,t){for(let e of i){if(String(e.id)===String(t))return e;let s=ei(e.children??[],t);if(s)return s}return null}function _n(i,t){for(let e of i)t(e),_n(e.children??[],t)}function El(i,t){return i.some(e=>String(e.id)===t||El(e.children??[],t))}function mn(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}var bn=class{#t;#e=[];#s=[];#i;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#i=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#i(t),"active"):(this.#s.push(t),"pending")}remove(t){let e=this.#s.indexOf(t);if(e!==-1)return this.#s.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#s.length>0){let r=this.#s.shift();this.#e.push(r),this.#i(r)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#s.slice()};return this.#e.length=0,this.#s.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#s.length}},wt=class i extends m{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=null;render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:If(e),this._entries=new Set,this._queue=new bn(Tf(this.options.maxVisible),s=>{this._activate(s)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let s={kind:kf(e.kind??this.options.kind),timeout:Cf(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},r=this._createEntry(t,s);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e().show(t,e)}static progress(t){return this.#e()._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)gn(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Mf(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},s=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(s),this._queue.enqueue(s);let r=!1;return{update:(n,o)=>{r||s.closed||(e.pct=Df(n),o!==void 0&&(e.text=String(o)),ii(s,e))},done:()=>{r||s.closed||(r=!0,e.pct=100,ii(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:n=>{r||s.closed||(r=!0,n!==void 0&&(e.text=String(n)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(_("error",{size:18})),ii(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let r=l("span",{class:"zx-message__icon",ariaHidden:"true"},_(e.kind,{size:18})),n=l("div",{class:"zx-message__content"});Ef(t)?n.append(t):n.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},r,n),a={node:o,content:n,iconHost:r,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(s){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),h=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);n.append(h),a.progressBar=h,a.progressFill=c,ii(a,s)}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:"Close message",title:"Close"},_("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>this._pause(a)),this.listen(o,"mouseleave",()=>this._resume(a)),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,gn(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Nf()){this._finish(t);return}let e=s=>{s.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(gn(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(){if(this.#t)return this.#t;let t=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});return document.body.append(t),this.#t=new i(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function kf(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Cf(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Tf(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function Ef(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Df(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ii(i,t){i.content.firstChild.textContent=t.text,i.progressBar?.setAttribute("aria-valuenow",String(t.pct)),i.progressBar?.setAttribute("aria-label",t.text),i.progressFill&&(i.progressFill.style.inlineSize=`${t.pct}%`)}function gn(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Nf(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function If(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Mf(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var Of=new Set(["start","end","top","bottom"]),Ff=new Set(["dim","blur","none"]),Lf=Object.freeze({start:1,end:-1,top:1,bottom:-1}),ri=class extends et{static cssName="sheet";static defaults={side:"end",modal:!0,backdrop:"dim",size:null,closeButton:!0,resizable:!1,min:160,max:null,handle:"auto",snap:null,lightDismiss:!0};#t=null;#e=null;#s=0;constructor(t=null,e={}){super(null,e),this._dock=null,this._handoff=!1,this.setSide(this.options.side),this.el.dataset.backdrop=Ff.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=Bf(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.options.modal!==!0&&(this.listen(this.el,"keydown",s=>{let r=s;r.key!=="Escape"||!this.options.closable||this._dock||(r.preventDefault(),this.emit("cancel").defaultPrevented||this.close())}),this.options.lightDismiss&&this.listen(document,"pointerdown",s=>{let r=s.target;!this.isOpen()||this._dock||this.el.contains(r)||this.close()})),this.on("close",()=>this.#t?.deactivate()),this.#i()&&this.#n()}#i(){let t=this.options.handle,e=this.getSide(),s=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||s}#n(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=l("div",{class:"zx-sheet__handle",ref:"handle",role:"separator",tabindex:0,ariaOrientation:t?"horizontal":"vertical",ariaLabel:this._message("sheet.resize","Resize sheet")});this.el.append(e),this.refs.handle=e,this.#c(),this.#e=ye(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#s=this.getSize(),this.el.dataset.dragging="true"},onMove:s=>this.#r(s,!1),onEnd:(s,r)=>{delete this.el.dataset.dragging,r&&this.#r(s,!0)},onStep:(s,r)=>{this.#s=this.getSize(),this.#r(s*(r?64:16),!0)}})}#r(t,e){let s=this.#o(),{min:r,max:n}=this.#a(s),a=!!this.options.resizable||this.#l(s).length>0?n:Math.min(n,this.#s),c=M(this.#s+t*Lf[this.getSide()],0,a);if(!e){this._applySize(c),this.#c();return}if(this.options.closable&&c<r/2){this._applySize(this.#s),this.close();return}let h=this.#l(s),u=h.length>0?Pf(c,h):c;this._applySize(M(u,r,a)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:s>0?this.getSize()/s:0})}snapTo(t){let e=this.#o(),s=this.#l(e);if(s.length===0)return this;let r=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<s.length?s[t]:Dl(t,e);if(!Number.isFinite(r))return this;let{min:n,max:o}=this.#a(e);return this._applySize(M(r,n,o)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:e>0?this.getSize()/e:0}),this}getSize(){let t=this.el.getBoundingClientRect();return this.getSide()==="top"||this.getSide()==="bottom"?t.height:t.width}_message(t,e){let s=this.msg(t);return s===t?e:s}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#l(t),s=Math.max(0,Number(this.options.min)||0),r=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),n=e.length>0?Math.max(s,Math.min(...e)):s;return{min:Math.min(n,r),max:r}}#l(t){let e=this.options.snap;return Array.isArray(e)?e.map(s=>Dl(s,t)).filter(s=>Number.isFinite(s)&&s>0).sort((s,r)=>s-r):[]}#c(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:s,max:r}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(s))),t.setAttribute("aria-valuemax",String(Math.round(r)))}mountTarget(){return this._dock?.el??document.body}isDocked(){return!!this._dock}_setDock(t){this._dock!==t&&(this._dock=t??null,this.el.toggleAttribute("data-docked",!!this._dock),this._rehost(),this.emit("dockchange",{docked:!!this._dock,dock:this._dock}))}_rehost(){let t=this.isOpen();t&&(this._handoff=!0,this.el.close()),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._show(),this.el.dataset.state="open",this._dock?delete this.el.dataset.zxOverlayOrder:this.el.dataset.zxOverlayOrder=String(Rf()))}_isRealClose(){return this._handoff?(this._handoff=!1,!1):!0}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=vs(this.el),this.#t.activate()),super.open(),this.#c(),this)}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=Of.has(t)?t:"end",this}getSide(){return this.el.dataset.side}setSize(t){return this._applySize(t),this}isModal(){return this.options.modal===!0}_applySize(t){this.el.style.removeProperty("inline-size"),this.el.style.removeProperty("block-size");let e=qf(t);e===null?this.el.style.removeProperty("--zx-sheet-size"):this.el.style.setProperty("--zx-sheet-size",e)}_show(){if(this.options.modal===!0&&!this._dock){super._show();return}this.el.show()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function Rf(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function Dl(i,t){return typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=1?i*t:it(i,t)}function Pf(i,t){let e=i,s=Number.POSITIVE_INFINITY;for(let r of t){let n=Math.abs(r-i);n<s&&(s=n,e=r)}return e}function Bf(i){return i===!0?"modal":i==="trap-focus"?"trap-focus":"none"}function qf(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}var ni=class i extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#s=!1;constructor(t={}){super();let e={...i.defaults,...t&&typeof t=="object"?t:{}};for(let[s,r]of Object.entries(e))!/^on[a-z]/.test(s)||typeof r!="function"||(this.on(s.slice(2),r),delete e[s]);this.options=Object.freeze(e)}push(t){if(!t||typeof t.open!="function")throw new TypeError("SheetStack.push expects a Sheet");let e=this.#t.indexOf(t);if(e!==-1&&this.#t.splice(e,1),this.#t.push(t),!this.#e.has(t)){let s=()=>this.#i(t);this.#e.set(t,s),t.on("close",s)}return t.isOpen()||t.open(),this.#r(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#n(t),t.close(),t):null}popTo(t){let e=this.#t.indexOf(t);if(e===-1)return this;for(;this.#t.length>e+1;)this.pop();return this}clear(){for(;this.#t.length>0;)this.pop();return this}top(){return this.#t[this.#t.length-1]??null}size(){return this.#t.length}sheets(){return[...this.#t]}has(t){return this.#t.includes(t)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0}),this}destroy(){if(!this.#s){this.#s=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),Nl(t)}this.#t=[]}}#i(t){this.#t.includes(t)&&this.#n(t)}#n(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let s=this.#e.get(t);s&&t.off("close",s),this.#e.delete(t),Nl(t),this.#r(),this.#o("pop",{sheet:t})}#r(){let{layout:t,offset:e,scale:s,max:r}=this.options,n=t==="cascade",o=0;for(let a=0;a<this.#t.length;a+=1){let c=this.#t[this.#t.length-1-a],h=c.el;h.dataset.stack=n?"cascade":"stack",h.dataset.depth=String(a),h.style.setProperty("--zx-sheet-depth",String(a)),h.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),h.style.setProperty("--zx-sheet-stack-scale",String(Number(s)||0)),h.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(r)||1)),h.inert=!n&&a>0,n?(h.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):h.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function Nl(i){let t=i.el;if(t){delete t.dataset.stack,delete t.dataset.depth,t.removeAttribute("data-stack-hidden"),t.inert=!1;for(let e of["--zx-sheet-depth","--zx-sheet-stack-offset","--zx-sheet-stack-scale","--zx-sheet-depth-offset"])t.style.removeProperty(e)}}var oi='[role="menuitem"]',ai=class extends m{static defaults={items:[],selector:null};#t;#e;#s;#i;#n;#r=[];#o=null;#a=null;#l=!1;constructor(t,e={}){let s=V(t);if(!s)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=s,document.body.append(this.el),this.#e=new st(this.el,{openOn:"manual",placement:"bottom-start"}),this.#s=this.#e.getPanel(),this.#s.classList.add("zx-context-menu"),this.#s.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#i=mt(this.#s,oi),this.#n=X(()=>this.#_(),r=>r.focus()),this.#e.on("close",()=>{this.#o=null;let r=this.#a;this.#a=null,r instanceof HTMLElement&&r.isConnected&&r.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",r=>this.#u(r)),this.listen(this.#t,"keydown",r=>this.#d(r)),this.listen(this.#s,"click",r=>{let n=r.target.closest?.(oi);n&&this.#s.contains(n)&&this.#p(n)}),this.listen(this.#s,"keydown",r=>this.#m(r))}render(){return l("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#s.replaceChildren(),this.#r.forEach((e,s)=>{if(e==="-"){this.#s.append(l("div",{class:"zx-context-menu__separator",role:"separator"}));return}let r=[];e.icon&&r.push(l("span",{class:"zx-context-menu__icon"},_(e.icon))),r.push(l("span",{class:"zx-context-menu__label"},String(e.label??""))),this.#s.append(l("button",{class:"zx-context-menu__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},r))}),this}openAt(t,e,s=null){return this.#c(s)?(this.#h(t,e,s),this):this}openAtElement(t){let e=t.getBoundingClientRect();return this.openAt(e.left,e.bottom,t)}close(){return this.#e.close(),this}isOpen(){return this.#e.isOpen()}getContext(){return this.#o}destroy(){this.#l||(this.#l=!0,this.#i.destroy(),this.#e.destroy(),super.destroy())}#c(t){let e=this.options.items;if(typeof e=="function"){let s=e(t);if(!Array.isArray(s)||s.length===0)return!1;this.setItems(s)}return this.#r.length>0}#h(t,e,s){let r=this.el;r.style.left=`${t}px`,r.style.top=`${e}px`,this.#o=s,this.#a=document.activeElement,this.#e.open(),this.#i.focusFirst(),this.emit("open",{context:s})}#u(t){let e=t,s=this.#f(e.target);!s||!this.#c(s)||(t.preventDefault(),this.#h(e.clientX,e.clientY,s))}#d(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let s=this.#f(e.target);if(!s||!this.#c(s))return;t.preventDefault();let r=s.getBoundingClientRect();this.#h(r.left,r.bottom,s)}#f(t){if(!this.options.selector)return this.#t;let e=t?.closest?.(String(this.options.selector));return e&&this.#t.contains(e)?e:null}#m(t){let e=t;if(e.key==="Escape"||e.key==="Tab"){t.preventDefault(),this.close();return}if(e.key==="Enter"||e.key===" "){let s=e.target.closest?.(oi);if(!s||!this.#s.contains(s))return;t.preventDefault(),this.#p(s);return}this.#n(e)}#p(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#r[e];if(!s||s==="-"||s.disabled)return;let r=this.#o;this.emit("select",{value:s.value,item:s,context:r});try{s.onselect?.(s.value,s,this)}finally{this.close()}}#_(){return Array.from(this.#s.querySelectorAll(oi))}};var li=class i extends lt{static cssName="table";constructor(t=null,e={}){super(t,e)}static BillingItems(t,e={}){let s=new i(t,jf(e));return s.el.dataset.preset="billing-items",s}};function jf(i={}){let{fields:t={},units:e=[],currencies:s=[],currency:r="EUR",locale:n,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:h,oneditcommit:u,rowClass:d,...p}=i,f={...Ml,...t},g=typeof c=="function"?c:v=>{let b=Number(v?.[f.quantity]),w=Number(v?.[f.unitPrice]);return Number.isFinite(b)&&Number.isFinite(w)?b*w:null},x=Array.isArray(h)?h.map(v=>({...v})):yn(f,{units:e,currencies:s,currency:r,locale:n,decimals:o,columnOverrides:a});return{rowId:f.id,editMode:"cell",hierarchy:{parentId:f.parent,column:f.item,expanded:!0},responsive:"sm",...p,columns:x,rowClass(v){let b=Ge(v,f)?"":"zx-grid-billing__summary",w=typeof d=="function"?d(v):"";return[b,w].filter(Boolean).join(" ")},oneditcommit(v){let{row:b,changes:w}=v.detail;if(Ge(b,f)){let D={...b,...w},U=g(D,w);U!=null&&Number.isFinite(Number(U))&&(w[f.total]=Number(U))}u?.(v)}}}var Ml=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function Ge(i,t=Ml){let e=String(i?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function yn(i,{units:t,currencies:e,currency:s,locale:r,decimals:n,columnOverrides:o}){let a=d=>p=>Ge(p,i)?d:!1,c=d=>String(d?.[i.currency]||s),h=d=>String(d?.[i.unit]??""),u={item:{id:i.item,label:"Item",width:"2fr",sortable:!0,editable:a("text")},quantity:{id:i.quantity,label:"Quantity",width:"1fr",type:"unit",locale:r,unit:h,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:i.unit,label:"Unit",width:".8fr",editable:a(Il(t)?"select":"text"),options:t},unitPrice:{id:i.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:r,decimals:n,currency:c,editable:a("number"),editorProps:{min:0,step:.01}},currency:{id:i.currency,label:"Currency",width:".8fr",editable:a(Il(e)?"select":"text"),options:e},total:{id:i.total,label:"Line total",width:"1fr",type:"currency",locale:r,decimals:n,currency:c}};return Object.entries(u).map(([d,p])=>({...p,...o?.[d]??{}}))}function Il(i){return Array.isArray(i)?i.length>0:!!(i&&typeof i=="object"&&Object.keys(i).length)}var ci=class extends m{static cssName="chart";static defaults={adapter:null,type:"bar",data:{labels:[],datasets:[]},chartOptions:{},label:"Chart",description:"",summary:"hidden",loading:!1,emptyText:"No chart data",loadingText:"Loading chart\u2026",errorText:"Unable to render chart",aspectRatio:"16 / 9"};constructor(t=null,e={}){super(t,e),this._mountOrUpdate(!1)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,c=>[c.name,c.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=Fl(this.options.data),this._label=Vf(this.options.label),this._chartOptions=ut(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._handle=null,this._destroyed=!1;let e=y("zx-chart-description"),s=l("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),r=l("div",{ref:"viewport",class:"zx-chart__viewport"},s);r.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let n=l("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=l("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(r,n,o,a),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(r),t}setData(t){return this._data=Fl(t),this._error=null,this._loading=!1,this._renderSummary(),this._mountOrUpdate(!0),this}setType(t){return this._type=String(t||"bar"),this._mountOrUpdate(!0),this}update(t){return this._chartOptions=ut(t&&typeof t=="object"?t:{}),this._mountOrUpdate(!0),this}setAdapter(t){return this._destroyHandle(),this._adapter=t,this._mountOrUpdate(!1),this}setLoading(t=!0){return this._loading=!!t,this._loading?this._destroyHandle():this._mountOrUpdate(!1),this._syncState(),this}setError(t){return this._error=t??new Error(String(this.options.errorText)),this._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,this._mountOrUpdate(!1),this}resize(){try{this._handle?.resize?.()}catch(t){this.setError(t)}return this}refreshTheme(){return this._mountOrUpdate(!0),this}getInstance(){return this._handle?.instance??null}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._observer?.disconnect(),this._destroyHandle(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._error||ui(this._data)){this._destroyHandle();return}if(!this._adapter||typeof this._adapter.create!="function"){this._destroyHandle();return}let e=this._spec();try{if(this._handle)this._handle.update(e);else{if(this._handle=this._adapter.create(this.refs.canvas,e),!this._handle||typeof this._handle.destroy!="function")throw new TypeError("Chart adapter create() must return a lifecycle handle");this.emit("ready",{instance:this.getInstance()})}t&&this.emit("update",{data:this._data,type:this._type})}catch(s){this.setError(s)}}_spec(){return{type:this._type,data:ut(this._data),options:{...Kf(this.el),...ut(this._chartOptions)},onSelect:t=>this.emit("select",t)}}_destroyHandle(){if(!this._handle)return;let t=this._handle;this._handle=null;try{t.destroy()}catch{}}_syncState(){let t=ui(this._data),e=this._loading?"loading":this._error?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let s="";e==="loading"?s=String(this.options.loadingText):e==="error"?s=Uf(this._error,this.options.errorText):e==="empty"&&(s=String(this.options.emptyText)),this.refs.status.textContent=s,this.refs.status.hidden=!s}_renderSummary(){this.refs.summary.replaceChildren(vn(this._data,this._label))}};function Vf(i){return String(i??"").trim()||"Chart"}var hi=class{constructor(t,e={}){let s=typeof t=="function"?t:t?.Chart;if(typeof s!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=s,this.defaults=ut(e)}create(t,e){let s=this.engine,r=null,n="",o=!1,a=c=>{let h=null,u=Ol(c,this.defaults,()=>h);h=new s(t,u),r=h,n=c.type};return a(e),{get instance(){return r},update:c=>{if(o)return;if(c.type!==n){let u=r;r=null,u?.destroy?.(),a(c);return}let h=Ol(c,this.defaults,()=>r);r.data=h.data,r.options=h.options,r.update()},resize:()=>{o||r?.resize?.()},destroy:()=>{o||(o=!0,r?.destroy?.(),r=null)}}}};function Ol(i,t,e){let s=ut(i.options),r={responsive:!0,maintainAspectRatio:!1,...ut(t),...s},n=r.onClick;return r.onClick=(o,a,c)=>{typeof n=="function"&&n(o,a,c);let h=e()??c,d=(Array.isArray(a)&&a.length?a:h?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!d)return;let p=i.data.datasets?.[d.datasetIndex]??null;i.onSelect({datasetIndex:d.datasetIndex,index:d.index,dataset:p,label:i.data.labels?.[d.index],value:p?.data?.[d.index],nativeEvent:o?.native??o??null})},{type:i.type,data:ut(i.data),options:r}}function ut(i){return xn(i,new WeakMap)}function xn(i,t){if(Array.isArray(i)){if(t.has(i))return t.get(i);let e=[];return t.set(i,e),e.push(...i.map(s=>xn(s,t))),e}if(i&&typeof i=="object"&&Object.getPrototypeOf(i)===Object.prototype){if(t.has(i))return t.get(i);let e={};t.set(i,e);for(let[s,r]of Object.entries(i))e[s]=xn(r,t);return e}return i}function Fl(i){return!i||typeof i!="object"?{labels:[],datasets:[]}:ut({...i,labels:Array.isArray(i.labels)?i.labels:[],datasets:Array.isArray(i.datasets)?i.datasets:[]})}function ui(i){return!Array.isArray(i?.datasets)||!i.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function vn(i,t="Chart data"){let e=Hf(i);return l("table",{class:"zx-chart__table"},l("caption",{},t),l("thead",{},l("tr",{},l("th",{scope:"col"},"Label"),e.headers.map(r=>l("th",{scope:"col"},r)))),l("tbody",{},e.rows.map(r=>l("tr",{},l("th",{scope:"row"},r.label),r.values.map(n=>l("td",{},n))))))}function Hf(i){let t=Array.isArray(i?.datasets)?i.datasets:[],e=Array.isArray(i?.labels)?i.labels:[],s=Math.max(e.length,...t.map(r=>Array.isArray(r.data)?r.data.length:0),0);return{headers:t.map((r,n)=>String(r.label??`Series ${n+1}`)),rows:Array.from({length:s},(r,n)=>({label:String(e[n]??n+1),values:t.map(o=>$f(o.data?.[n]))}))}}function $f(i){if(i==null)return"";if(typeof i=="object"){if("y"in i)return String(i.y??"");if("r"in i)return String(i.r??"");try{return JSON.stringify(i)}catch{return String(i)}}return String(i)}function Kf(i){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(i),e=t.getPropertyValue("--zx-color-text").trim(),s=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:s||void 0}}function Uf(i,t){return i&&typeof i=="object"&&"message"in i?String(i.message):String(t)}function di({valueKey:i="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:s=>typeof i=="function"?i(s):s?.[i],label:s=>String((typeof t=="function"?t(s):s?.[t])??""),children:s=>{let r=s?.[e];return Array.isArray(r)?r:null}}}function P(i,t){if(i?.hasChildren===!0)return!0;let e=t.children(i);return Array.isArray(e)&&e.length>0}function Ae(i,t,e,{level:s=1,parent:r=null}={}){i.forEach((n,o)=>{e(n,{level:s,parent:r,index:o,siblings:i});let a=t.children(n);a&&Ae(a,t,e,{level:s+1,parent:n})})}function Ll(i,t,e){let s=null;return Ae(i,e,r=>{s===null&&Object.is(e.value(r),t)&&(s=r)}),s}function Qe(i,t,e){for(let s of i){if(Object.is(e.value(s),t))return[s];let r=e.children(s);if(!r)continue;let n=Qe(r,t,e);if(n.length>0)return[s,...n]}return[]}function Rl(i,t){let e=[],s=t.children(i);return s&&Ae(s,t,r=>e.push(r)),e}function Pl(i,t,e){let s=[],r=(n,o,a)=>{n.forEach((c,h)=>{let u=t.value(c);if(s.push({node:c,id:u,level:o,parent:a,posinset:h+1,setsize:n.length}),!e.has(u))return;let d=t.children(c);d&&d.length>0&&r(d,o+1,c)})};return r(i,1,null),s}function wn(i,t,e,s){let r=[];for(let n of i){let o=t.children(n)??[],a=wn(o,t,e,s);(e(n)||a.length>0)&&r.push(a.length>0||o.length>0?{...n,[s]:a}:n)}return r}var fi=class extends m{static cssName="tree";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",expanded:[],selection:"single",selected:[],checkboxes:!1,checked:[],icons:!0,renderLabel:null,load:null,filter:"",label:"Tree",emptyText:"Nothing to show",height:null};render(){this._items=[],this._rows=[],this._expanded=new Set,this._selected=new Set,this._checked=new Set,this._loading=new Map,this._focusId=null,this._filter="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t,this._readers=di(this.options),this._childrenKey=this.options.childrenKey??"children",t.setAttribute("role","tree"),t.setAttribute("aria-label",String(this.options.label??"Tree")),t.tabIndex=0,this.options.selection==="multi"&&t.setAttribute("aria-multiselectable","true"),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height),t.style.overflowY="auto"),this._items=Sn(this.options.items);for(let s of Ze(this.options.expanded))this._expanded.add(s);for(let s of Ze(this.options.selected))this._selected.add(s);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let s of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(s))}for(let s of Ze(this.options.checked))this._applyCheck(s,!0,{silent:!0});return this._handleTypeahead=X(()=>this._rotatedRows().map(s=>this._readers.label(s.node)),(s,r)=>this._focusNodeId(this._rotatedRows()[r]?.id)),this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"click",s=>this._onClick(s)),this.listen(t,"dblclick",s=>this._onDoubleClick(s)),this.listen(t,"focus",()=>{this._rows.length>0&&!this._rowElement(this._focusId)&&this._focusRow(0)}),String(this.options.filter??"")!==""?this.setFilter(this.options.filter):this._renderRows(),t}setItems(t){return this._items=Sn(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return Ll(this._items,t,this._readers)}getPath(t){return Qe(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())Ae([e],this._readers,s=>this._expanded.add(this._readers.value(s)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!P(e,this._readers))return this;let s=this._readers.children(e),r=!!this.options.load&&(!s||s.length===0);return this._expanded.has(t)&&!r?this:await this._ensureChildren(e,t)?(this._expanded.add(t),this._renderRows(),this.emit("expand",{node:e,id:t}),this):this}collapse(t){if(!this._expanded.delete(t))return this;let e=this.getNode(t);return this._renderRows(),e&&this.emit("collapse",{node:e,id:t}),this}async toggle(t){return this._expanded.has(t)?this.collapse(t):this.expand(t)}expandAll(){return Ae(this._items,this._readers,t=>{P(t,this._readers)&&this._expanded.add(this._readers.value(t))}),this._renderRows(),this}collapseAll(){return this._expanded.clear(),this._renderRows(),this}reveal(t){let e=this.getPath(t);for(let s of e.slice(0,-1))this._expanded.add(this._readers.value(s));return this._renderRows(),this}select(t,{silent:e=!1,additive:s=!1}={}){if(this.options.selection===!1)return this;let r=this.getNode(t);return r?(this.options.selection==="multi"&&s?this._selected.has(t)?this._selected.delete(t):this._selected.add(t):(this._selected.clear(),this._selected.add(t)),this._syncRows(),e||this.emit("select",{node:r,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let s=Ze(t);if(this._selected=new Set(this.options.selection==="multi"?s:s.slice(0,1)),this._syncRows(),!e){let[r]=this._selected;this.emit("select",{node:this.getNode(r)??null,id:r,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let s=this.getNode(e);return s!==null&&!P(s,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let s of Ze(t))this._applyCheck(s,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:s=!1}={}){let r=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!s&&r&&this.emit("check",{ids:this.getChecked(),node:r}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(s=>Object.is(s.id,t));return e>=0&&this._focusRow(e),this}_visibleItems(){if(this._filter==="")return this._items;let t=this._filter.trim().toLocaleLowerCase();return t===""?this._items:wn(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=Pl(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(l("div",{class:"zx-tree__empty"},this._message("tree.empty",this.options.emptyText)));return}this.el.replaceChildren(...this._rows.map(e=>this._renderRow(e))),this._syncRows()}_renderRow(t){let e=P(t.node,this._readers),s=e&&this._expanded.has(t.id),r=l("div",{class:"zx-tree__row",role:"treeitem",id:y("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});r.style.setProperty("--zx-tree-level",String(t.level-1));let n=l("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?_("chevron-right",{size:12}):null);if(n.dataset.action="twisty",r.append(n),this.options.checkboxes){let a=l("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});a.dataset.action="checkbox",r.append(a)}this.options.icons&&r.append(l("span",{class:"zx-tree__icon",ariaHidden:"true"},_(e?s?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return r.append(l("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&r.append(l("span",{class:"zx-tree__badge"},String(t.node.badge))),r}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(s=>Object.is(s.id,this._focusId));e<0&&(e=0),t.forEach((s,r)=>{let n=this._rows[r];if(!n)return;let o=P(n.node,this._readers),a=o&&this._expanded.has(n.id);o?s.setAttribute("aria-expanded",String(a)):s.removeAttribute("aria-expanded"),this.options.selection!==!1&&s.setAttribute("aria-selected",String(this._selected.has(n.id))),s.toggleAttribute("data-branch",o),s.toggleAttribute("data-loading",this._loading.has(n.id)),s.tabIndex=r===e?0:-1;let c=s.querySelector(".zx-tree__checkbox");if(c){let u=this._checkState(this.getNode(n.id)??n.node);c.checked=u==="checked",c.indeterminate=u==="partial",s.setAttribute("aria-checked",u==="partial"?"mixed":String(c.checked))}let h=s.querySelector(".zx-tree__icon");h&&this.options.icons&&h.replaceChildren(_(o?a?"folder-open":"folder":"file",{size:14}))}),this._focusId=this._rows[e]?.id??null,this.el.tabIndex=this._rows.length===0?0:-1}_onClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let s=this._rowIndex(e);if(s<0)return;let r=this._rows[s];this._focusRow(s);let n=t.target.closest("[data-action]");if(n?.dataset.action==="twisty"){P(r.node,this._readers)&&this.toggle(r.id).then(()=>this._focusNodeId(r.id));return}let o=this.getNode(r.id)??r.node;if(n?.dataset.action==="checkbox"){this.check(r.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(r.id,this._checkState(o)!=="checked");return}this.select(r.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let s=this._rows[this._rowIndex(e)];s&&(P(s.node,this._readers)?this.toggle(s.id).then(()=>this._focusNodeId(s.id)):this.emit("activate",{node:s.node,id:s.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let s=this._rows[e],r=P(s.node,this._readers),n=r&&this._expanded.has(s.id);switch(t.key){case"ArrowDown":t.preventDefault(),this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowUp":t.preventDefault(),this._focusRow(Math.max(0,e-1));return;case"ArrowRight":t.preventDefault(),r&&!n?this.expand(s.id).then(()=>this._focusNodeId(s.id)):n&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),n?(this.collapse(s.id),this._focusNodeId(s.id)):s.parent&&this._focusNodeId(this._readers.value(s.parent));return}case"Home":t.preventDefault(),this._focusRow(0);return;case"End":t.preventDefault(),this._focusRow(this._rows.length-1);return;case"Enter":t.preventDefault(),this.options.selection!==!1&&this.select(s.id),this.emit("activate",{node:s.node,id:s.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(s.id,this._checkState(this.getNode(s.id)??s.node)!=="checked"):this.options.selection!==!1&&this.select(s.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(s);return;default:this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),s=this._focusId;for(let r of e)P(r,this._readers)&&this._expanded.add(this._readers.value(r));this._renderRows(),this._focusNodeId(s)}async _ensureChildren(t,e){let s=this._readers.children(t);if(!this.options.load||s&&s.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let r=(async()=>{try{let o=await this.options.load(t);return t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1),!0}catch(o){return this.emit("error",{error:o,node:t,id:e}),!1}finally{this._loading.delete(e)}})();this._loading.set(e,r),this._syncRows();let n=await r;return this._syncRows(),n}_applyCheck(t,e,{silent:s}){let r=this.getNode(t);if(!r)return null;let n=[t,...Rl(r,this._readers).map(o=>this._readers.value(o))];for(let o of n)e?this._checked.add(o):this._checked.delete(o);return s||this._syncRows(),r}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let s=e.map(r=>this._checkState(r));return s.every(r=>r==="checked")?"checked":s.every(r=>r==="unchecked")?"unchecked":"partial"}_rotatedRows(){let t=this._rows.findIndex(e=>Object.is(e.id,this._focusId));return t<0?this._rows:[...this._rows.slice(t+1),...this._rows.slice(0,t+1)]}_rowIndex(t){return[...this.el.querySelectorAll(".zx-tree__row")].indexOf(t)}_rowElement(t){let e=this._rows.findIndex(s=>Object.is(s.id,t));return e<0?null:this.el.querySelectorAll(".zx-tree__row")[e]??null}_focusRow(t){let e=this._rows[t];if(!e)return;this._focusId=e.id,this._syncRows();let s=this._rowElement(e.id);s?.focus(),s?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(s=>Object.is(s.id,t));e>=0&&this._focusRow(e)}_message(t,e){let s=this.msg(t);return s===t?e:s}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};function Sn(i){return Array.isArray(i)?i.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[s,r]of Object.entries(e))Array.isArray(r)&&(e[s]=Sn(r));return e}):[]}function Ze(i){return Array.isArray(i)?i:[]}var pi=class extends m{static cssName="finder";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",path:[],load:null,preview:null,rootLabel:"",columnWidth:220,height:320,icons:!0,renderItem:null,emptyText:"Empty"};render(){this._items=[],this._path=[],this._columns=[],this._activeColumn=0,this._loading=new Map,this._pathSequence=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");return this.el=t,this._readers=di(this.options),this._childrenKey=this.options.childrenKey??"children",t.style.setProperty("--zx-finder-column",`${Number(this.options.columnWidth)||220}px`),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._handleTypeahead=X(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,s)=>this._selectAt(this._activeColumn,s,{focus:!0})),this.listen(t,"click",e=>this._onClick(e)),this.listen(t,"dblclick",e=>this._onDoubleClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this._render({}),this.setPath(this.options.path,{silent:!0}),t}getPath(){return this._path.slice()}getNodes(){let t=this._items,e=[];for(let s of this._path){let r=t.find(n=>Object.is(this._readers.value(n),s));if(!r)break;e.push(r),t=this._readers.children(r)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:s=!1}={}){let r=this._pathSequence+1;this._pathSequence=r;let n=Array.isArray(t)?t.slice():[],o=[],a=this._items;for(let c of n){let h=a.find(u=>Object.is(this._readers.value(u),c));if(!h||(o.push(c),!P(h,this._readers)))break;if(await this._ensureChildren(h),r!==this._pathSequence)return this;a=this._readers.children(h)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:s}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let s=Qe(this._items,t,this._readers);return s.length===0?this:this.setPath(s.map(r=>this._readers.value(r)),{silent:e})}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._path=[],this._render({}),this}focus(){return(this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0))?.focus(),this}_render({focus:t=!1}){let e=this.getNodes(),s=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((a,c)=>{if(!P(a,this._readers))return;let h=this._readers.children(a)??[];s.push({nodes:h,selectedId:this._path[c+1],owner:a})}),this._columns=s,this._activeColumn=Math.min(this._activeColumn,s.length-1);let r=s.map((a,c)=>this._renderColumn(a,c)),n=e[e.length-1]??null;if(this.options.preview&&n&&!P(n,this._readers)){let a=this.options.preview(n);a&&r.push(l("div",{class:"zx-finder__preview"},a))}this.el.replaceChildren(...r),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let s=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),r=l("div",{class:"zx-finder__list",role:"listbox",ariaLabel:s,dataset:{column:String(e)}});if(t.nodes.length===0){let n=t.owner!==null&&this._loading.has(this._readers.value(t.owner));r.append(l("div",{class:"zx-finder__empty"},n?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let n of t.nodes){let o=this._readers.value(n),a=P(n,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),h=l("div",{class:"zx-finder__row",id:y("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&h.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},_(a?"folder":"file",{size:14}))),h.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(n):this._readers.label(n))),a&&h.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},_("chevron-right",{size:11}))),h.toggleAttribute("data-branch",a),r.append(h)}return l("div",{class:"zx-finder__column"},r)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(s=>{s.tabIndex=-1});let e=this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0)??t[0];e&&(e.tabIndex=0)}_onClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:s,index:r}=this._locate(e);s<0||this._selectAt(s,r,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:s,index:r}=this._locate(e),n=this._columnNodes(s)[r];n&&(P(n,this._readers)?this._enter(s,r):this.emit("activate",{node:n,id:this._readers.value(n)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,s=this._columnNodes(e);if(s.length===0&&!["ArrowLeft"].includes(t.key))return;let r=Math.max(0,s.findIndex(n=>Object.is(this._readers.value(n),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(s.length-1,r+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,r-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,s.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let n=s[r];if(!n||!P(n,this._readers))return;this._enter(e,r);return}case"ArrowLeft":if(t.preventDefault(),e===0)return;this._path=this._path.slice(0,e),this._activeColumn=e-1,this._render({focus:!0}),this._emitChange();return;case"Enter":{t.preventDefault();let n=s[r];if(!n)return;P(n,this._readers)?this._enter(e,r):this.emit("activate",{node:n,id:this._readers.value(n)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:s=!1}={}){let r=this._columnNodes(t)[e];if(!r)return;let n=this._readers.value(r);if(this._path.length===t+1&&Object.is(this._path[t],n)){this._activeColumn=t,this._syncTabStop(),s&&this.focus();return}this._path=[...this._path.slice(0,t),n],this._activeColumn=t,P(r,this._readers)&&await this._ensureChildren(r),this._render({focus:s}),this._emitChange()}async _enter(t,e){if(await this._selectAt(t,e),this._columnNodes(t+1).length===0){this._activeColumn=t,this._syncTabStop(),this.focus();return}this._activeColumn=t+1,this._path.length<=t+1?await this._selectAt(t+1,0,{focus:!0}):(this._syncTabStop(),this.focus())}async _ensureChildren(t){let e=this._readers.children(t);if(!this.options.load||e&&e.length>0)return;let s=this._readers.value(t),r=this._loading.get(s);if(r)return r;let n=(async()=>{try{let o=await this.options.load(t);t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1)}catch(o){t[this._childrenKey]=[],this.emit("error",{error:o,node:t,id:s})}finally{this._loading.delete(s)}})();return this._loading.set(s,n),n}_columnNodes(t){return this._columns[t]?.nodes??[]}_locate(t){let e=t.closest(".zx-finder__list");return e?{column:Number(e.dataset.column),index:[...e.querySelectorAll(".zx-finder__row")].indexOf(t)}:{column:-1,index:-1}}_rowAt(t,e){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelectorAll(".zx-finder__row")[e]??null}_activeRow(t){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelector('[aria-selected="true"]')??null}_emitChange(){let t=this.getNodes();this.emit("change",{path:this.getPath(),nodes:t,node:t.length>0?t[t.length-1]:null})}_message(t,e){let s=this.msg(t);return s===t?e:s}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&C(t,this._snapshot)}};function Bl(i){return String(i??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function Yf(i,t){let e=Bl(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let s=Bl(i.flat(1/0).join(" "));return e.every(r=>s.includes(r))}function zn(i){return i!=null&&!(typeof i=="string"&&i.trim()==="")}function ql(i,t){if(typeof t.get=="function")return An(t.get(i));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(r=>An(typeof r=="function"?r(i):r==null?void 0:i?.[r]))}function jl(i,t){let e=[],s=new Map;for(let r of i)for(let n of ql(r,t)){let o=Vl(n);o.value==null||o.value===""||s.has(o.value)||(s.set(o.value,!0),e.push(o))}return e}function Qt(i,t,e){return i.filter(s=>t.every(r=>{let n=e?.[r.id];if(!zn(n))return!0;if(r.type==="custom")return typeof r.predicate!="function"||!!r.predicate(s,n);let o=ql(s,r);return r.type==="text"?Yf(o,n):r.type==="select"?o.some(a=>Wf(Vl(a).value,n)):!0}))}function An(i){return Array.isArray(i)?i.flat(1/0):[i]}function Vl(i){if(i&&typeof i=="object"&&!(i instanceof Date)){if(Object.prototype.hasOwnProperty.call(i,"value"))return{value:i.value,label:String(i.label??i.value??"")};if(Object.prototype.hasOwnProperty.call(i,"field"))return{value:i.field,label:String(i.label??i.field??"")}}return{value:i,label:String(i??"")}}function Wf(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}var ze=class extends m{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let s of this._filters){if(kn(s),e.has(s.id))throw new RangeError(`Duplicate filter id: ${s.id}`);e.add(s.id),s.type==="custom"&&!this._customOrigins.has(s.element)&&this._customOrigins.set(s.element,{parent:s.element.parentNode,nextSibling:s.element.nextSibling}),this._state[s.id]=s.type==="custom"?Cn(s.element):""}this._filtered=Qt(this._data,this._filters,this._state),this._controls=l("div",{class:"zx-data-filter__controls"}),this._badge=l("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=l("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let s of this._filters)this._appendFilter(s);return this._syncActiveState(),t}setData(t){Zf(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let s=this._entries.get(e.id);s&&this._populateSelect(e,s)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Qt(this._data,this._filters,this._state),this}apply(){this._filtered=Qt(this._data,this._filters,this._state);let t=[...this._filtered];return this.emit("filter",{rows:t,state:this.getState()}),t}clear(){for(let t of this._filters)this._state[t.id]="";return this._syncControls(),this._syncActiveState(),this.apply(),this}getState(){return{...this._state}}setState(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("DataFilter state must be an object");for(let e of this._filters)this._state[e.id]=Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]:"";return this._syncControls(),this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Qt(this._data,this._filters,this._state),this}addFilter(t){kn(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Cn(e.element):"",this._appendFilter(e),this._filtered=Qt(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),Jf(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(kn(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,s={element:null,options:[]};if(t.type==="select")e=l("select",{ariaLabel:t.label}),s.element=e,this._populateSelect(t,s),this.listen(e,"change",()=>{let n=Number(e.value)-1;this._state[t.id]=n>=0?s.options[n]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=l("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),s.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),s.element=e;let n=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,n,()=>{this._state[t.id]=Cn(e),this._controlChanged()})}this._entries.set(t.id,s);let r=l("label",{class:"zx-data-filter__field"},l("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(r)}_populateSelect(t,e){let s=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(Gf):jl(this._data,t);let r=l("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),n=document.createDocumentFragment();n.append(r),e.options.forEach((a,c)=>{n.append(l("option",{value:String(c+1)},a.label))}),e.element.replaceChildren(n);let o=e.options.findIndex(a=>Hl(a.value,s));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Qt(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let s=this._state[t.id];if(t.type==="select"){let r=e.options.findIndex(n=>Hl(n.value,s));e.element.value=r>=0?String(r+1):"",r<0&&(this._state[t.id]="")}else Qf(e.element,s)}}_syncActiveState(){let t=this._filters.reduce((e,s)=>e+Number(zn(this._state[s.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function kn(i){if(!i||typeof i!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(i.type))throw new TypeError(`Unknown filter type: ${i.type}`);if(typeof i.id!="string"||!i.id)throw new TypeError("Filter definition requires an id");if(i.type==="custom"){if(!i.element||i.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof i.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function Gf(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"value")?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}}function Cn(i){return"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked:"value"in i?i.value:i.getAttribute("data-value")??""}function Qf(i,t){"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked=!!t:"value"in i?i.value=t==null?"":String(t):t==null||t===""?i.removeAttribute("data-value"):i.setAttribute("data-value",String(t))}function Hl(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}function Zf(i){if(!Array.isArray(i))throw new TypeError("DataFilter data must be an array")}function Jf(i){let t=[...i];for(let e=t.length;t.length>0&&e>=0;e-=1){let s=0;for(let r=t.length-1;r>=0;r-=1){let[n,o]=t[r];if(!o.parent)n.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(n,o.nextSibling)}t.splice(r,1),s+=1}if(s===0)break}for(let[e,s]of t)s.parent?s.parent.append(e):e.remove()}var St=class extends m{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let r=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(r),t.append(r)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[r,n]of Object.entries(s))this.addField(r,n);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let r,n=!1;if(e instanceof S)r=e;else if(N(e)||e instanceof m){let o=e;r=new S(null,{id:s,type:"custom",label:s,value:tp(o),disabled:ep(o),adapter:()=>Xf(o)}),n=!0}else{let o=e&&typeof e=="object"?e:{};r=new S(null,{...o,id:o.id??s}),n=!0}return n?this._ownedFields.add(r):this._origins.set(r,{parent:r.el.parentNode,next:r.el.nextSibling}),this._fields.set(s,r),this._fieldIdAttributes.set(r,r.el.getAttribute("data-field-id")),r.el.dataset.fieldId=s,this._grid.append(r.el),r}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,s]of this._fields)t[e]=s.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,r]of Object.entries(t))this._fields.get(s)?.setValue(r,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let s=0;for(let[r,n]of this._fields){let o=t?.[r];o?(n.setHighlight(String(o),e),s+=1):n.clearHighlight()}return s}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let s=this._origins.get(t);s?.parent?s.parent.insertBefore(t.el,s.next?.parentNode===s.parent?s.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function Xf(i){let t=N(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,r=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),n="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(a,c)=>{typeof i.setValue=="function"?i.setValue(a,c):typeof i.setValues=="function"&&a&&typeof a=="object"?i.setValues(a,c):"value"in t&&(t.value=a??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:a=>{typeof i.setDisabled=="function"?i.setDisabled(a):"disabled"in t?t.disabled=a:t.setAttribute("aria-disabled",String(a))},destroy:()=>{for(let[a,c]of r)c===null?t.removeAttribute(a):t.setAttribute(a,c);n!==void 0&&(t.disabled=n),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function tp(i){let t=N(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function ep(i){let t=N(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var ke=class extends m{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(t,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of e)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof St),s=e?new St(null,t??{}):t;return this._fieldsets.includes(s)||(e?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",r=>{let n=r.target,o=n instanceof Element?n.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,s)=>{let r=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!r&&e.title?e.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?_(e.icon,{size:16}):null,r?l("span",{class:"zx-btn__label"},r):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let s of this._fieldsets)s.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((s,r)=>s+r.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let r of this._fieldsets)for(let[n,o]of Object.entries(r.getFields())){let a=o.getValue(),c="";if(o.options.required&&Tn(a))c=this.msg("form.required");else if(!Tn(a)&&o.options.type==="int"){let h=Ar(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.int")}else if(!Tn(a)&&o.options.type==="float"){let h=zr(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.float")}c?(t[n]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let s=this._actionDescriptors[Number(e.dataset.actionIndex)],r=s?.onClick??s?.onclick??s?.handler;typeof r=="function"&&r(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Tn(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}var mi="123456789abcdefghijklmnopqrstuvwxyz";function $l(i){if(!Array.isArray(i))throw new TypeError("Questionnaire items must be an array");let t=new Set;return i.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Each questionnaire item must be an object");if(typeof e.name!="string"||e.name.trim()==="")throw new TypeError("Each questionnaire item needs a non-empty string name");let s=e.name;if(t.has(s))throw new TypeError(`Item already exists: ${s}`);t.add(s);let r=sp(e.choices??[],s),n=e.field&&typeof e.field=="object"?{...e.field}:null,o=rp(e.input);if(r.length===0&&!n&&!o)throw new TypeError(`Item "${s}" needs choices, an input, or a field`);return{name:s,prompt:String(e.prompt??s),description:e.description==null||e.description===""?null:String(e.description),section:e.section==null?"":String(e.section),required:!!e.required,multiple:!!e.multiple,skippable:!!e.skippable,choices:r,input:o,field:n,when:typeof e.when=="function"?e.when:null,next:typeof e.next=="function"||typeof e.next=="string"&&e.next?e.next:null,validate:typeof e.validate=="function"?e.validate:null}})}function sp(i,t=""){if(!Array.isArray(i))throw new TypeError("Questionnaire choices must be an array");let e=new Set,s=i.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("Each questionnaire choice must be an object");if(o.value==null||o.value==="")throw new TypeError(`Each choice of "${t}" needs a value`);let a=typeof o.value=="number"?o.value:String(o.value),c=String(a);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:a,label:String(o.label??a),description:o.description==null||o.description===""?null:String(o.description),icon:o.icon==null||o.icon===""?null:String(o.icon),key:typeof o.key=="string"&&o.key?o.key.slice(0,1).toLowerCase():"",disabled:!!o.disabled,exclusive:!!o.exclusive}}),r=new Set(s.map(o=>o.key).filter(Boolean)),n=0;for(let o of s)if(!o.key){for(;n<mi.length&&r.has(mi[n]);)n+=1;if(n>=mi.length)break;o.key=mi[n],r.add(o.key),n+=1}return s}function ip(i,t){if(typeof i.when!="function")return!0;try{return i.when(t)!==!1}catch{return!0}}function At(i,t){let e={},s=[];for(let r of i)ip(r,e)&&(s.push(r),Object.prototype.hasOwnProperty.call(t,r.name)&&(e[r.name]=t[r.name]));return{answers:e,visible:s}}function _i(i,t,e){let{answers:s,visible:r}=At(i,e),n=new Set(r.map(c=>c.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let c=t.next(s[t.name],s);o=c==null||c===""?null:String(c)}let a=i.indexOf(t);if(o!==null){let c=i.findIndex(h=>h.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(n.has(o))return o;a=c}for(let c=a+1;c<i.length;c+=1)if(n.has(i[c].name))return i[c].name;return null}function Zt(i){return i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.every(t=>Zt(t)):!1}function Kl(i,t,e){return!i.required||!Zt(t)?null:e(i.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function Ul(i,t,e=null){let s=new Set(t.map(n=>String(n))),r=new Set(i.filter(n=>n.exclusive).map(n=>String(n.value)));return r.size>0&&e!==null&&s.has(String(e))&&(r.has(String(e))?s.forEach(n=>n!==String(e)&&s.delete(n)):r.forEach(n=>s.delete(n))),i.filter(n=>s.has(String(n.value))).map(n=>n.value)}function Yl(i,t,e){let{answers:s,visible:r}=At(i,t),n=new Map(r.map(f=>[f.name,f])),o=e.filter(f=>n.has(f)),a=o.length>0?n.get(o[o.length-1]):null,c=o.filter(f=>!Zt(s[f])).length,h=new Set(o),u=a?r.indexOf(a):-1,d=r.slice(u+1).filter(f=>!h.has(f.name)).length,p=o.length+d;return{index:Math.max(0,o.length-1),answered:c,total:p,percent:p===0?0:Math.round(c/p*100),section:a?.section??""}}function rp(i){if(!i)return null;let t=typeof i=="object"&&!Array.isArray(i)?i:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var np=260,gi=class extends m{static cssName="questionnaire";static defaults={items:[],answers:{},active:null,progress:!0,review:!1,advance:"manual",shortcuts:!0,allowBack:!0,msg:{"questionnaire.next":"Continue","questionnaire.previous":"Back","questionnaire.skip":"Skip","questionnaire.submit":"Submit","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.edit":"Edit","questionnaire.counter":"Question %1 of %2","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.noAnswer":"Skipped","questionnaire.empty":"There is nothing to answer."}};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el),this._destroyed=!1,this._items=[],this._selected=new Map,this._freeform=new Map,this._fields=new Map,this._path=[],this._status="asking",this._returnToReview=!1,this._busy=!1,this._error="",this._advanceTimer=0,this._uid=y("zx-questionnaire");let t=this.el??l("form");if(this.el=t,this._form=t.localName==="form"?t:l("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=l("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=l("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=l("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=l("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new _e(null,{max:100,value:0,size:"sm",showValue:!1}),this._progressHost.append(this._bar.el),this._back=this._action("previous",this.msg("questionnaire.previous"),"chevron-left","default"),this._skip=this._action("skip",this.msg("questionnaire.skip"),null,"ghost"),this._forward=this._action("next",this.msg("questionnaire.next"),"chevron-right","primary"),this._actionsHost.append(this._back,l("span",{class:"zx-questionnaire__spacer"}),this._skip,this._forward),this._form.replaceChildren(this._progressHost,this._itemHost,this._reviewHost,this._actionsHost),this._form!==t&&t.replaceChildren(this._form),this.listen(this._form,"submit",e=>{e.preventDefault(),this.next()}),this.listen(this._itemHost,"change",e=>this._onControlChange(e)),this.listen(this._itemHost,"input",e=>this._onFreeformInput(e)),this.listen(this._actionsHost,"click",e=>this._onActionClick(e)),this.listen(this._reviewHost,"click",e=>this._onReviewClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this.setItems(this.options.items),this.options.answers&&typeof this.options.answers=="object"&&this.setAnswers(this.options.answers,{silent:!0}),this.options.active!=null){let e=String(this.options.active);At(this._items,this._rawAnswers()).visible.some(r=>r.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),s=$l(t),r=new Set(s.map(a=>a.name));this._items=s;for(let a of[this._selected,this._freeform])for(let c of[...a.keys()])r.has(c)||a.delete(c);for(let[a,c]of[...this._fields])r.has(a)||(c.destroy(),this._fields.delete(a));let n=At(s,this._rawAnswers()).visible,o=this._path.filter(a=>n.some(c=>c.name===a));return e&&o[o.length-1]===e?this._path=o:this._path=n.length>0?[n[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}getItems(){return this._items.map(t=>({...t,choices:t.choices.map(e=>({...e})),input:t.input?{...t.input}:null}))}goTo(t){let e=this._items.find(n=>n.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!At(this._items,this._rawAnswers()).visible.includes(e))return!1;let r=this._returnToReview;return this._returnToReview=r||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=r,!1)}async next(){if(this._busy||this._status==="complete")return!1;if(this._status==="review")return this.submit();if(!await this._validateActive()||this._destroyed)return!1;if(this._returnToReview)return this._returnToReview=!1,this._enterReview();let t=this._activeItem(),e=t?_i(this._items,t,this._rawAnswers()):null;return e?this._navigate(e,"next"):this.options.review?this._enterReview():this.submit()}previous(){if(this._busy)return!1;if(this._status==="review"||this._status==="complete"){let r=this._path[this._path.length-1];return!r||this.emit("navigate",{from:null,to:r,reason:"previous"}).defaultPrevented?!1:(this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}if(!this.options.allowBack||this._path.length<=1)return!1;let t=this.getActive(),e=this._path[this._path.length-2];return this.emit("navigate",{from:t,to:e,reason:"previous"}).defaultPrevented?!1:(this._path.pop(),this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}async skip(){let t=this._activeItem();if(!t||!t.skippable||this._busy)return!1;if(this.setAnswer(t.name,null,{silent:!0}),this.emit("skip",{name:t.name}),this._returnToReview)return this._returnToReview=!1,this._enterReview();let e=_i(this._items,t,this._rawAnswers());return e?this._navigate(e,"skip"):this.options.review?this._enterReview():this.submit()}async submit(){if(this._busy||this._status==="complete"||this._status!=="review"&&!await this._validateActive()||this._destroyed)return!1;let t={answers:this.getAnswers(),path:this.getPath()};return this.emit("submit",t).defaultPrevented?!1:(this._status="complete",this._paint(),this.emit("complete",{answers:t.answers,path:t.path}),!0)}getAnswers(){return At(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(s=>s.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,r]of Object.entries(t))this._items.some(n=>n.name===s)&&this.setAnswer(s,r,{silent:!0});if(this._paint(),!e){let s=this.getAnswers();for(let r of Object.keys(t))r in s&&this.emit("change",{name:r,value:s[r],answers:s})}return this}setAnswer(t,e,{silent:s=!1}={}){let r=this._items.find(n=>n.name===t);if(!r)throw new RangeError(`Unknown questionnaire item: ${t}`);if(r.field)this._field(r).setValue(e===void 0?null:e,{silent:!0});else{let n=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(n.map(c=>String(c))),a=r.choices.filter(c=>o.has(String(c.value)));for(let c of a)o.delete(String(c.value));this._selected.set(t,a.map(c=>c.value)),this._freeform.set(t,r.input?[...o][0]??"":"")}return this._paint(),s||this._emitChange(r),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return Yl(this._items,this._rawAnswers(),this._path)}getState(){return{active:this.getActive(),status:this._status,answers:this.getAnswers(),path:this.getPath(),progress:this.getProgress()}}toFormData(){let t=new FormData;for(let[e,s]of Object.entries(this.getAnswers()))if(Array.isArray(s))for(let r of s)t.append(e,String(r));else s instanceof File||s instanceof Blob?t.append(e,s):t.append(e,s==null?"":String(s));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,s]of this._fields){let r=this._items.find(n=>n.name===e);s.setValue(r?.field?.value??null,{silent:!0})}let t=At(this._items,this._rawAnswers()).visible;return this._path=t.length>0?[t[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}focus(){return this._focusItem(),this}destroy(){if(!this._destroyed){this._destroyed=!0,clearTimeout(this._advanceTimer);for(let t of this._fields.values())t.destroy();this._fields.clear(),this._bar?.destroy(),super.destroy(),this._createdRoot||C(this.el,this._snapshot)}}_activeItem(){let t=this._path[this._path.length-1];return this._items.find(e=>e.name===t)??null}_rawAnswers(){let t={};for(let e of this._items){let s=this._answerOf(e);Zt(s)||(t[e.name]=s)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],s=(this._freeform.get(t.name)??"").trim();return t.multiple?s?[...e,s]:[...e]:s||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let s=t.field??{};return e=new S(null,{...s,label:s.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),s.label==null&&e.el.setAttribute("data-hide-label",""),e.on("change",()=>{this._error="",this._paintError(t),this._emitChange(t)}),this._fields.set(t.name,e),e}_navigate(t,e){let s=this.getActive();if(s===t&&this._status==="asking"||this.emit("navigate",{from:s,to:t,reason:e}).defaultPrevented)return!1;let r=this._path.indexOf(t);return r>=0?this._path=this._path.slice(0,r+1):this._path.push(t),this._status="asking",this._error="",this._paint(),this._focusItem(),!0}_enterReview(){return this.emit("navigate",{from:this.getActive(),to:null,reason:"review"}).defaultPrevented?!1:(this._status="review",this._error="",this._paint(),this._reviewHost.focus?.(),!0)}async _validateActive(){let t=this._activeItem();if(!t)return!0;let e=this._answerOf(t),s=Kl(t,e,r=>this.msg(r));if(!s&&typeof t.validate=="function"){this._setBusy(!0);try{s=await t.validate(e,this.getAnswers())}catch(r){s=r instanceof Error?r.message:String(r)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=s?String(s):"",this._paintError(t),this._error?(this.emit("invalid",{name:t.name,message:this._error}),this._focusControl(),!1):!0)}_setBusy(t){this._busy=t,t?this.el.setAttribute("aria-busy","true"):this.el.removeAttribute("aria-busy"),this._syncState(),this._paintActions()}_paint(){this._destroyed||(this._syncState(),this._paintProgress(),this._status==="review"?this._paintReview():this._paintItem(),this._itemHost.hidden=this._status==="review",this._reviewHost.hidden=this._status!=="review",this._paintActions())}_syncState(){this.el.dataset.state=this._busy?"checking":this._status}_paintProgress(){if(this._progressHost.hidden=!this.options.progress||this._items.length===0,this._progressHost.hidden)return;let t=this.getProgress(),e=this.msg("questionnaire.counter",t.index+1,Math.max(t.total,1));this._bar.setLabel(t.section?`${e} \xB7 ${t.section}`:e),this._bar.set(this._status==="asking"?t.percent:100,{silent:!0}),this._bar.setStatus(this._status==="complete"?"success":"active")}_paintItem(){let t=this._activeItem();if(this._itemHost.toggleAttribute("data-empty",!t),!t){this._itemHost.replaceChildren(l("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,s=`${this._uid}-description`,r=`${this._uid}-error`,n=[l("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&n.push(l("p",{class:"zx-questionnaire__description",id:s},t.description)),n.push(t.field?this._field(t).el:this._choices(t)),n.push(l("p",{class:"zx-questionnaire__error",id:r,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...n),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?s:"",r].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(r=>String(r))),s=l("div",{class:"zx-questionnaire__choices"});if(s.append(...t.choices.map((r,n)=>l("label",{class:"zx-questionnaire__choice",dataset:{disabled:r.disabled?"true":null}},l("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(r.value),checked:e.has(String(r.value)),disabled:r.disabled,dataset:{index:n}}),l("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),r.icon?_(r.icon,{size:16}):null,l("span",{class:"zx-questionnaire__text"},l("span",{class:"zx-questionnaire__label"},r.label),r.description?l("span",{class:"zx-questionnaire__hint"},r.description):null),r.key?l("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},r.key):null))),t.input){let r=`${this._uid}-freeform`,n=this._freeform.get(t.name)??"",o=l(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:r,name:t.choices.length>0?`${t.name}__other`:t.name,placeholder:t.input.placeholder||void 0,maxLength:t.input.maxLength>0?t.input.maxLength:void 0,rows:t.input.multiline?3:void 0,autocomplete:"off",value:n});s.append(l("div",{class:"zx-questionnaire__freeform"},l("label",{class:"zx-questionnaire__freeform-label",htmlFor:r},t.input.label),o))}return s}_paintError(t){let e=this._itemHost.querySelector(".zx-questionnaire__error");e instanceof HTMLElement&&(e.textContent=this._error,e.hidden=!this._error),this._error?this._itemHost.setAttribute("aria-invalid","true"):this._itemHost.removeAttribute("aria-invalid");let s=t?.field?this._fields.get(t.name):null;s&&(this._error?s.setHighlight(this._error,"danger"):s.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=At(this._items,this._rawAnswers()),s=this._path.map(r=>e.find(n=>n.name===r)).filter(r=>!!r).map(r=>l("div",{class:"zx-questionnaire__answer"},l("dt",{class:"zx-questionnaire__answer-prompt"},r.prompt),l("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:Zt(t[r.name])?"true":null}},this._formatAnswer(r,t[r.name])),j({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[r,n]of s.entries()){let o=n.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[r])}this._reviewHost.replaceChildren(l("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),l("dl",{class:"zx-questionnaire__answers"},...s))}_formatAnswer(t,e){if(Zt(e))return this.msg("questionnaire.noAnswer");let s=new Map(t.choices.map(n=>[String(n.value),n.label]));return(Array.isArray(e)?e:[e]).map(n=>s.get(String(n))??String(n)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",s=this._status==="complete",r=!1;try{r=!!t&&_i(this._items,t,this._rawAnswers())!==null}catch{r=!1}this._back.hidden=s||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||s||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=s,this._forward.disabled=this._busy||!t&&!e;let n=e?"submit":this._returnToReview||!r&&this.options.review?"review":r?"next":"submit";if(this._forward.dataset.role!==n){this._forward.dataset.role=n;let o=n==="next"?"chevron-right":n==="review"?"list":"check";this._forward.replaceChildren(_(o,{size:16}),l("span",{class:"zx-btn__label"},this.msg(`questionnaire.${n}`)))}}_action(t,e,s,r){let n=j({label:e,icon:s,kind:r});return n.dataset.action=t,n}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let s=this._activeItem();if(!s)return;let r=s.choices[Number(e.dataset.index)];if(r){if(s.multiple){let n=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>s.choices[Number(c.dataset.index)].value),o=Ul(s.choices,n,e.checked?r.value:null);this._selected.set(s.name,o);let a=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=a.has(c.value)}else{this._selected.set(s.name,[r.value]),this._freeform.set(s.name,"");let n=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.value="")}this._error="",this._paintError(s),this._paintProgress(),this._paintActions(),this._emitChange(s),this._maybeAutoAdvance(s)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let r=this._activeItem();if(r){if(this._freeform.set(r.name,e.value),!r.multiple&&e.value.trim()!==""){this._selected.set(r.name,[]);for(let n of this._itemHost.querySelectorAll(".zx-questionnaire__control"))n.checked=!1}this._error="",this._paintError(r),this._paintProgress(),this._paintActions(),this._emitChange(r)}}_onActionClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;!(e instanceof HTMLElement)||!this._actionsHost.contains(e)||(e.dataset.action==="previous"?this.previous():e.dataset.action==="skip"?this.skip():this.next())}_onReviewClick(t){let e=t.target instanceof Element?t.target.closest("[data-edit]"):null;e instanceof HTMLElement&&this.goTo(String(e.dataset.edit))}_onKeydown(t){if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;let e=t.target,s=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["radio","checkbox"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable;if(t.key==="Enter"){if(e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)return;t.preventDefault(),this.next();return}if(!this.options.shortcuts||s||t.key.length!==1)return;let r=this._activeItem();if(!r||this._status!=="asking")return;let n=t.key.toLowerCase(),o=r.choices.findIndex(c=>c.key===n&&!c.disabled);if(o<0)return;let a=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);a instanceof HTMLInputElement&&(t.preventDefault(),a.checked=r.multiple?!a.checked:!0,a.focus(),a.dispatchEvent(new Event("change",{bubbles:!0})))}_maybeAutoAdvance(t){this.options.advance!=="auto"||t.multiple||t.input||(clearTimeout(this._advanceTimer),this._advanceTimer=setTimeout(()=>{!this._destroyed&&this._activeItem()===t&&this.next()},np))}_emitChange(t){let e=this.getAnswers();this.emit("change",{name:t.name,value:this._answerOf(t),answers:e})}_focusItem(){this._status==="asking"&&this._itemHost.focus?.()}_focusControl(){let t=this._activeItem(),e=t?.field?this._fields.get(t.name):null;if(e){e.focus();return}let s=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");s instanceof HTMLElement?s.focus():this._focusItem()}};function Wl(){la(),xo(),Qo(),Po(),Yo(),pa(),ga(),sa(),Jo(),ma(),ra(),na(),ua(),ca()}Wl();var Je=new WeakMap;function Pt(i=globalThis){let t=i?.Element?.prototype;t&&(typeof t.store!="function"&&Object.defineProperty(t,"store",{configurable:!0,writable:!0,value:function(s,r){let n=Je.get(this);return n||(n=new Map,Je.set(this,n)),n.set(s,r),this}}),typeof t.retrieve!="function"&&Object.defineProperty(t,"retrieve",{configurable:!0,writable:!0,value:function(s,r=null){let n=Je.get(this);return n?.has(s)?n.get(s):(arguments.length>1&&(n||(n=new Map,Je.set(this,n)),n.set(s,r)),r)}}),typeof t.eliminate!="function"&&Object.defineProperty(t,"eliminate",{configurable:!0,writable:!0,value:function(s){return Je.get(this)?.delete(s),this}}))}function zt(i){if(i&&typeof i=="object"&&typeof i.toElement=="function")return i.toElement()??!1;if(i&&typeof i=="object"&&typeof i.nodeType=="number")return i;if(typeof i=="string"||typeof i=="number")return document.createTextNode(String(i));if(!i||typeof i!="object"||Array.isArray(i))return!1;let t=i,e={},s=[],r=new Set(["tag","html","styles","classes","child","children","_adopt","events"]);for(let[o,a]of Object.entries(t))r.has(o)||(/^on[A-Z]/.test(o)&&typeof a=="function"?s.push([o.slice(2).toLowerCase(),a]):o==="class"?e.class=a:o==="text"?e.textContent=a==null?"":String(a):e[o]=a);if(t.styles&&typeof t.styles=="object"&&(e.style=t.styles),t.classes!=null){let o=Array.isArray(t.classes)?t.classes:[t.classes];e.class=[e.class,...o].flat().filter(Boolean)}let n=l(String(t.tag??"div"),e);for(let[o,a]of s)n.addEventListener(o,a);if(t.events&&typeof t.events=="object")for(let[o,a]of Object.entries(t.events))typeof a=="function"&&n.addEventListener(o,a);if(t.html!=null&&n.append(l.raw(String(t.html))),Dn(n,t._adopt),Dn(n,t.child),Array.isArray(t.children))for(let o of t.children)Dn(n,o);else if(t.children&&typeof t.children=="object"){let o=[];for(let[a,c]of Object.entries(t.children)){let h=zt(c);h&&(n.append(h),n[`_${a}`]=h.retrieve?.("com")??h,o.push(a))}n.store?.("children",o)}return n}function Gl(i=globalThis){Pt(i),i.__===void 0&&(i.__=zt);let t=i.String?.prototype;t&&typeof t.htmlSpecialChars!="function"&&Object.defineProperty(t,"htmlSpecialChars",{configurable:!0,writable:!0,value:function(){return os(String(this))}});let e=i.Array?.prototype;return e&&typeof e.findBy!="function"&&Object.defineProperty(e,"findBy",{configurable:!0,writable:!0,value:function(r,n){let o=typeof r=="string"?a=>a?.[r]===n:r;if(typeof o!="function")return null;for(let a=this.length-1;a>=0;a-=1)if(o(this[a])===!0)return this[a];return null}}),i._===void 0&&(i._=(s,r)=>G(String(s),r)),i}function Dn(i,t){if(t==null)return;let e=Array.isArray(t)?t:[t];for(let s of e){let r=zt(s);r&&i.append(r)}}var A=class{static legacyName="gx.ui.Container";constructor(t={},e={}){op(this.constructor),this.gx=this.constructor.legacyName,this.options={...e,...t&&typeof t=="object"?t:{}},this._events=new Map,this._mappedListeners=[],this._domAbort=new AbortController,this._zx=null,this._ui={},this._display=this._ui,this._uiMap={},this._optionSetters={},this._destroyed=!1;for(let[s,r]of Object.entries(this.options))/^on[A-Z]/.test(s)&&typeof r=="function"&&this.addEvent(s,r)}addEvent(t,e){if(typeof e!="function")return this;let s=Nn(t),r=this._events.get(s)??new Set;return r.add(e),this._events.set(s,r),this}removeEvent(t,e){let s=Nn(t);if(e===void 0)this._events.delete(s);else{let r=this._events.get(s);r?.delete(e),r?.size===0&&this._events.delete(s)}return this}fireEvent(t,e=[]){let s=Array.isArray(e)?e:[e],r=[...this._events.get(Nn(t))??[]];for(let n of r)n.apply(this,s);return this}setOptions(t){if(!t||typeof t!="object")return this;for(let[e,s]of Object.entries(t))this.setOption(e,s);return this}setOption(t,e){let s=String(t);if(this.options[s]=e,/^on[A-Z]/.test(s)&&typeof e=="function")return this.addEvent(s,e),this;let r=this._optionSetters[s];return typeof r=="function"?r.call(this,e):typeof r=="string"&&typeof this[r]=="function"?this[r](e):ap(this.constructor,s),this}toElement(){return this._zx?.toElement?.()??this._zx?.el??null}display(t="root"){let e=t||"root";if(e==="root")return this.toElement();let s=this._uiMap[e];return typeof s=="function"?s.call(this)??this.toElement():typeof s=="string"?this._zx?.refs?.[s]??this.toElement():s?.nodeType===1?s:this._ui[e]??this.toElement()}getCoordinates(){let t=this.toElement()?.getBoundingClientRect?.();return t?{width:t.width,height:t.height,top:t.top,left:t.left}:{width:0,height:0,top:0,left:0}}setStyle(t,e){let s=this.toElement();return s?(String(t).startsWith("--")||String(t).includes("-")?s.style.setProperty(String(t),String(e)):s.style[t]=e,this):this}setCoordinates(t={}){for(let e of["width","height","top","right","bottom","left"]){if(t[e]==null)continue;let s=typeof t[e]=="number"?`${t[e]}px`:t[e];this.setStyle(e,s)}return this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._domAbort.abort();let t=this.toElement();t?.retrieve?.("com")===this&&t.eliminate("com");for(let[e,s]of this._mappedListeners)this._zx?.off?.(e,s);this._mappedListeners.length=0,this._events.clear(),this._zx?.destroy?.()}_attach(t,e={}){this._zx=t,this._uiMap={...e.ui??{}},this._optionSetters={...e.setters??{}};let s=this.toElement();if(s){Pt(globalThis),s.store?.("com",this),this._ui.root=s;for(let r of Object.keys(this._uiMap))this._ui[r]=this.display(r)}for(let[r,n]of Object.entries(e.events??{})){let o=typeof n=="string"?{type:n}:n,a=c=>{let h=c.detail??{};if(o.filter&&!o.filter.call(this,h,c))return;let u=o.args?o.args.call(this,h,c):[];this.fireEvent(r,u)};t.on?.(o.type,a),this._mappedListeners.push([o.type,a])}return this}_listen(t,e,s,r={}){return t.addEventListener(e,s,{...r,signal:this._domAbort.signal}),this}_mirrorAct(t,e){t?.classList.toggle("act",!!e)}};function op(i){Object.hasOwn(i,"_compatWarned")&&i._compatWarned||(Object.defineProperty(i,"_compatWarned",{configurable:!0,value:!0,writable:!0}),console.warn(`${i.legacyName} is running on the Zx compat layer \u2014 migrate to ${lp(i.legacyName)}`))}function ap(i,t){Object.hasOwn(i,"_compatOptionWarnings")||Object.defineProperty(i,"_compatOptionWarnings",{configurable:!0,value:new Set}),!i._compatOptionWarnings.has(t)&&(i._compatOptionWarnings.add(t),console.warn(`${i.legacyName}.setOption("${t}") cannot update the wrapped Zx component dynamically`))}function lp(i){return`zx.${i.split(".").at(-1)}`}function Nn(i){let t=String(i??"");return(/^on[A-Z]/.test(t)?t.slice(2):t).toLowerCase()}function gt(i){return i==null?null:typeof i=="string"?document.querySelector(i):i?.nodeType===1?i:null}function B(i){return i==null||typeof i=="string"||typeof i=="number"||i?.nodeType||typeof i?.toElement=="function"||typeof i=="function"?i:zt(i)||String(i)}function In(i){let t=String(i??"").toLowerCase().replace(/^s_msg_32_/,"").replace(/^icon-/,"");return t.includes("error")||t.includes("danger")||t.includes("remove")?"error":t.includes("success")||t.includes("ok")||t.includes("check")?"success":t.includes("warn")?"warning":"info"}function Xe(i,t,e){Object.hasOwn(i,"_compatWarned")||(Object.defineProperty(i,"_compatWarned",{value:!0}),console.warn(`${t} is running on the Zx compat layer \u2014 migrate to zx.${e}`))}function Ql(i,t,e){let s=`_compatMethod_${t}`;Object.hasOwn(i,s)||(Object.defineProperty(i,s,{value:!0}),console.warn(`${i.legacyName}.${t} has no direct Zx equivalent; use ${e}`))}function ts(i){return i==null?"":String(typeof i=="string"||typeof i=="number"?i:i.label??i.title??i.text??i.name??i.value??"")}var bi=class extends A{static legacyName="gx.zeyos.Toggle";constructor(t,e={}){super(e,{on:!1,value:!0});let{target:s,host:r}=Ci(t),n=new H(s,{checked:!!e.on,value:e.value??!0,label:e.label??null,disabled:!!e.disabled});r&&r.append(n.toElement()),this._attach(n,{events:{check:{type:"change",filter:o=>o.checked,args:()=>[this]},uncheck:{type:"change",filter:o=>!o.checked,args:()=>[this]},change:{type:"change",args:o=>[o.checked]}},setters:{on:o=>o?this.setChecked():this.setUnchecked(),value:o=>{n.options.value=o}}}),n.on("change",()=>this._syncAct()),this._syncAct()}getState(){return this._zx.get()}getValue(){return this._zx.getValue()}toggle(){return this._zx.toggle(),this._syncAct(),this}setChecked(t=!1){return this._zx.set(!0,{silent:!!t}),this._syncAct(),this}setUnchecked(t=!1){return this._zx.set(!1,{silent:!!t}),this._syncAct(),this}_syncAct(){this._mirrorAct(this.toElement(),this.getState())}},yi=class extends A{static legacyName="gx.zeyos.Msgbox";constructor(t={}){super(t,{closable:!0,content:!1});let e=new wt(null,{timeout:0,closable:t.closable!==!1,maxVisible:1});document.body.append(e.toElement()),this._handle=null,this._content=t.content||"",this._attach(e,{ui:{frame:"root",content:"root",img:"root"}})}setContent(t){return this._content=B(t),this}show(t,e="info"){return t!=null&&this.setContent(t),this._handle?.close(),this._handle=this._zx.show(this._content,{kind:In(e),timeout:0,closable:this.options.closable!==!1}),this._mirrorAct(this.toElement(),!0),this}hide(){return this._handle?.close(),this._handle=null,this._mirrorAct(this.toElement(),!1),this}},xi=class extends A{static legacyName="gx.bootstrap.Message";constructor(t,e={}){super(e,{duration:3e3});let s=new wt(gt(t),{timeout:Number(e.duration)||0,closable:!0,maxVisible:e.maxVisible??5});gt(t)||document.body.append(s.toElement()),this._handles=new Map,this._progress=null,this._progressValue=0,this._attach(s,{ui:{windows:"root",status:"root"}})}addMessage(t,e="info",s=!0,r=!1,n=!0){let o=document.createElement("span");o.hidden=!0;let a=this._zx.show(B(t),{kind:In(e),closable:s!==!1,timeout:n===!1?0:Number(this.options.duration)||0});return this._handles.set(o,a),o}closeMessage(t){return this._handles.get(t)?.close(),this._handles.delete(t),this}clear(){for(let t of this._handles.values())t.close();return this._handles.clear(),this}showStatus(t,e="",s=!1){return this._progress||(this._progress=wt.progress(String(e))),this._progressValue=Number(t)||0,this._progress.update(this._progressValue,String(e)),this}incProgress(t,e){return this.setProgress(this._progressValue+(Number(t)||0),e)}setProgress(t,e,s){return this._progress||(this._progress=wt.progress(String(e??""))),this._progressValue=Number(t)||0,this._progress.update(this._progressValue,e==null?void 0:String(e)),this}hideStatus(){return this._progress?.done(),this._progress=null,this._progressValue=0,this}},vi=class extends A{constructor(t={}){super(t,{width:600,closable:!0,content:null});let e=new et(null,{title:String(t.title??""),size:cp(t.width),closable:t.closable!==!1,lightDismiss:!!(t.overlayDismiss??t.clickable),content:B(t.content)});this._attach(e,{events:{show:{type:"open",args:()=>[this]},hide:{type:"close",args:s=>[s.result,this]},open:{type:"open",args:()=>[this]}},ui:{modal:"root",aside:"content",body:"content",content:"content",title:"title",footer:"footer",cross:"close"},setters:{content:"setContent",title:"setTitle",open:s=>s?this.show():this.hide()}}),this.isOpen=!1,t.footer&&e.setButtons(tc(t.footer)),t.open&&this.show()}show(t){return this.isOpen=!0,this._showArgument=t,this._zx.open(),this}hide(t){return this.isOpen=!1,this._zx.close(t),this}setContent(t){return this._zx.setContent(B(t)),this}setTitle(t){return this._zx.setTitle(t),this}getContent(){return this._zx.refs.content}setPosition(t,e){return Ql(this.constructor,"setPosition","CSS dialog positioning"),this}},wi=class extends vi{static legacyName="gx.zeyos.Popup"},Ce=class extends vi{static legacyName="gx.bootstrap.Popup"},Mn=Object.freeze({});function On(i,t,e={}){Xe(On,"gx.bootstrap.PopupAlert","Dialog.alert");let s=typeof e=="string"?{type:e}:e;return new Promise(r=>{let n=new Ce({...s,title:i,content:t,width:s.width??400});n._zx.setButtons([{label:s.okLabel??"Ok",kind:"primary",autofocus:!0,action:()=>{typeof s.onOk=="function"&&s.onOk()===!1||(n.hide(),r())}}]),n._zx.once("close",()=>n.destroy()),n.show()})}function Fn(i,t,e={}){Xe(Fn,"gx.bootstrap.PopupConfirm","Dialog.confirm");let s=typeof e=="string"?{type:e}:e;return new Promise(r=>{let n=new Ce({...s,title:i,content:t,width:s.width??400,closable:!1});n._zx.setButtons([{label:s.cancelLabel??"Cancel",action:()=>{n.hide(),r(Mn)}},{label:s.okLabel??"Ok",kind:"primary",action:()=>{typeof s.onOk=="function"&&s.onOk()===!1||(n.hide(),r())}}]),n._zx.once("close",()=>n.destroy()),n.show()})}var Si=class extends A{static legacyName="gx.zeyos.Dialog";constructor(t,e={}){super(e,{title:"",height:400});let s=new et(null,{title:String(e.title??""),content:null});this._frames={},this._current=null,this._attach(s,{ui:{title:"title",content:"content",footer:"footer"},setters:{title:"setTitle"}})}setTitle(t){return this._zx.setTitle(ts(t)),this}addFrame(t,e,s){let r=tc(e?.footer),n=this._zx.addView(String(t),{title:e?.title==null?void 0:ts(e.title),content:B(e?.content),buttons:r});return this._frames[t]={title:e?.title??null,content:n.content,footer:r,view:n},(!this._current&&s!==!1||s===!0)&&this.openFrame(t),this}openFrame(t){return this._zx.showView(String(t)),this._current=this._frames[t],this._current}getFrame(t){return this._frames[t]??null}addSubmitFrame(t,e,s,r){return this.addFrame(t,{title:this.options.title,content:Zl(e),footer:{close:{label:"Close",click:()=>this._zx.close()},ok:{label:"OK",primary:!0,click:()=>s?.()}}},r),e}addFormFrame(t,e,s,r){let n={},o=document.createElement("div");for(let[a,c]of Object.entries(e??{})){let h=document.createElement("p");h.textContent=c?.[0]==null?"":String(c[0]),o.append(h);let u=c?.[1],d=B(u);d?.nodeType?o.append(d):d?.toElement?.()&&o.append(d.toElement()),n[a]=u}return this.addSubmitFrame(t,o,s,r),n}addSuccessFrame(t,e,s,r){let n=Zl(e);if(s){let o=document.createElement("a");o.href=s,o.textContent="Open",n.append(o)}return this.addFrame(t,{title:this.options.title,content:n},r)}getFormValues(t){let e={};for(let[s,r]of Object.entries(t??{}))r?.value!=null?e[s]=r.value:typeof r?.getValue=="function"?e[s]=r.getValue():typeof r?.getValues=="function"?e[s]=r.getValues():typeof r?.getId=="function"?e[s]=r.getId():typeof r?.get=="function"&&(e[s]=r.get());return e}},Ai=class extends A{static legacyName="gx.zeyos.Dropdown";constructor(t,e={}){super(e,{items:{},label:"",resettable:!1,compact:!1,upside:!1});let{target:s,host:r}=Ci(t);this._items=Jl(e.items,e.resettable,e.emptyCaption),this._selected=null;let n=new K(s,{label:String(e.label??""),items:this._items,placement:e.upside?"top-start":"bottom-start"});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"select",args:o=>(this._selected=o.value==null?null:o.item,n.setLabel(o.value==null?String(e.label??""):String(o.item.label)),[o.value,o.item.label,this])}},ui:{frame:"root",button:"root",section:()=>document.querySelector(`[aria-labelledby="${n.el.id}"]`)},setters:{items:"setItems"}})}setItems(t){return this._items=Jl(t,this.options.resettable,this.options.emptyCaption),this._zx.setItems(this._items),this}selectItem(t,e){let s=this._items.find(r=>r!=="-"&&r.value==t);return this._selected=s??{value:t,label:e??String(t)},this._zx.setLabel(e??this._selected.label),this.fireEvent("change",[t,e??this._selected.label,this]),this._zx.close(),this}reset(){return this._selected=null,this._zx.setLabel(String(this.options.label??"")),this.fireEvent("change",[null,this.options.emptyCaption,this]),this._zx.close(),this}getSelected(){return this._selected?{value:this._selected.value,label:this._selected.label}:null}getValue(){return this._selected?.value??""}show(){return this._zx.open(),this}close(){return this._zx.close(),this}toggle(){return this._zx.isOpen()?this._zx.close():this._zx.open(),this}},zi=class extends A{static legacyName="gx.bootstrap.MenuButton";constructor(t,e={}){super(e,{entries:[],label:"",orientation:"left",direction:"down"});let{target:s,host:r}=Ci(t);this._entries=[];let n=new K(s,{label:String(e.label??""),items:[],kind:Xl(e.style),placement:`${e.direction==="up"?"top":"bottom"}-${e.orientation==="right"?"end":"start"}`});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"select",args:o=>[o.value,o.item,this]}},ui:{button:"root",frame:"root",menu:"root"}});for(let o of e.entries??[])this.add(o)}add(t,e){if(!t)return this._entries.push("-"),this._zx.setItems(this._entries),null;let s={label:String(t),icon:e,value:this._entries.length};return this._entries.push(s),this._zx.setItems(this._entries),this.toElement()}divider(){return this.add(!1),this}toggle(){return this._zx.isOpen()?this._zx.close():this._zx.open(),this}open(){return this._zx.open(),this}close(){return this._zx.close(),this}setLabel(t){return this._zx.setLabel(t),this}setStyle(t){return this.toElement().setAttribute("data-kind",Xl(t)),this}},ki=class extends A{static legacyName="gx.bootstrap.CheckButton";constructor(t,e={}){super(e,{label:"",value:!1});let{target:s,host:r}=Ci(t),n=new at(s,{label:e.label,checked:!!e.value,disabled:!!e.disabled});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"change",args:o=>[o.checked]},check:{type:"change",filter:o=>o.checked,args:()=>[]},uncheck:{type:"change",filter:o=>!o.checked,args:()=>[]}},ui:{button:"root",indicator:"root",group:"root"},setters:{value:"set",disabled:"setDisabled",label:"setLabel"}})}get(){return this._zx.get()}toggle(t=!1){return this._zx.set(!this.get(),{silent:!!t}),!1}check(t=!1){return this._zx.set(!0,{silent:!!t}),this}uncheck(t=!1){return this._zx.set(!1,{silent:!!t}),this}set(t){return t?this.check():this.uncheck()}setDisabled(t){return t?this._zx.disable():this._zx.enable(),this}setLabel(t){return this._zx.setLabel(t),this}};function Ci(i){let t=gt(i);return t?.localName==="button"?{target:t,host:null}:{target:null,host:t}}function cp(i){if(typeof i=="number"&&Number.isFinite(i))return i;let t=Number.parseFloat(String(i??""));return Number.isFinite(t)?t:"md"}function tc(i){return i?(Array.isArray(i)?i:i?.nodeType?[i]:Object.values(i)).map(e=>e?.nodeType?{label:e.textContent??"",action:()=>e.click?.()}:{label:String(e?.label??""),kind:e?.primary?"primary":"default",action:()=>e?.click?.()}):[]}function Zl(i){let t=document.createElement("div"),e=Array.isArray(i)?i:[i];for(let s of e){let r=B(s);r?.nodeType?t.append(r):r!=null&&t.append(document.createTextNode(String(r)))}return t}function Jl(i={},t=!1,e=null){let s=[];t&&s.push({label:String(e??"Empty"),value:null});for(let[r,n]of Object.entries(i??{})){let o=n&&typeof n=="object"?n:null;s.push({label:String(o?.text??o?.label??n),value:r,onselect:typeof o?.onClick=="function"?o.onClick:void 0})}return s}function Xl(i){let t=String(i??"").toLowerCase();return t.includes("danger")||t.includes("error")?"danger":t.includes("primary")||t.includes("success")?"primary":t.includes("link")||t.includes("ghost")?"ghost":"default"}var hp=Object.freeze({data:"items",elementIndex:"valueKey",elementLabel:"labelKey",elementSelect:"renderValue",allowEmpty:"clearable",resetable:"clearable",searchfields:"searchKeys",height:"listHeight"}),up=Object.freeze({data:"items",listValue:"valueKey",listFormat:"labelKey",listActive:"checkedKey",defaultState:"defaultChecked"}),CS=Object.freeze({cols:"columns"}),TS=Object.freeze({horizontal:"layout",default:"value"}),dp=Object.freeze({string:"text",integer:"int",gxselect:"zxselect",date:"date",month:"month",time:"time",optionlist:"optionlist",html:"html",multivalueeditor:"multivalueeditor",checklist:"checklist"});function ec(i,t){let e={};if(!i||typeof i!="object")return e;for(let[s,r]of Object.entries(i))/^on[A-Z]/.test(s)||(e[t[s]??s]=r);return e}function Ti(i={}){let t=ec(i,hp);return Object.hasOwn(i,"data")&&(t.items=Array.isArray(i.data)?i.data.slice():[]),(Object.hasOwn(i,"allowEmpty")||Object.hasOwn(i,"resetable"))&&(t.clearable=!!(i.allowEmpty||i.resetable)),i.msg&&typeof i.msg=="object"&&i.msg.noSelection!=null&&(t.placeholder=String(i.msg.noSelection)),Object.hasOwn(i,"height")&&(t.listHeight=rc(i.height,280)),delete t.elementDefault,delete t.parseDefault,delete t.queryParam,delete t.requestData,delete t.requestHeader,delete t.url,delete t.method,delete t.entity,delete t.limit,t}function Ei(i={}){let t=ec(i,up);return typeof i.getItemValue=="function"&&(t.valueKey=i.getItemValue),Object.hasOwn(i,"height")&&(t.height=rc(i.height,280)),delete t.url,delete t.method,delete t.requestData,delete t.decodeResponse,delete t.width,delete t.onClick,t}function Di(i){if(typeof i=="string")return i.replaceAll("&nbsp;"," ");let t=Array.isArray(i)?i:["d",".","M",".","y"],e={d:"%d",m:"%m",M:"%m",y:"%Y",h:"%H",i:"%M",s:"%S"};return t.map(s=>e[s]??String(s).replaceAll("&nbsp;"," ")).join("")}function fp(i,t){if(typeof t=="string")return t;if(typeof t!="number"||!Number.isFinite(t))return null;let e=i[Math.trunc(t)-1];return e?.name==null?null:String(e.name)}function sc(i={}){let t=Array.isArray(i.frames)?i.frames:[];return{tabs:t.map(e=>({name:String(e.name??""),title:String(e.title??""),content:e.content,closable:!!e.closable,disabled:!!e.disabled})),active:fp(t,i.show??1),height:i.height??null}}function Ln(i={},t=_p){let e=Array.isArray(i.cols)?i.cols:[],s=typeof i.structure=="function"?i.structure:c=>e.map(h=>c?.[h.id]),r=new WeakMap,n=(c,h)=>{if(c&&typeof c=="object"){let p=r.get(c);if(p?.index===h)return p.cells}let u=s(c,h),d=Array.isArray(u)?u:Array.isArray(u?.row)?u.row:[];return c&&typeof c=="object"&&r.set(c,{index:h,cells:d}),d},o=e.map((c,h)=>({id:String(c.id??h),label:String(c.label??""),width:c.width??"auto",align:pp(c.align??c["text-align"]),sortable:c.filter!=null||c.filterable!==!1,render:(u,d)=>t(n(u,d)[h])})),a=e.find(c=>c.filter!=null);return{columns:o,data:Array.isArray(i.data)?i.data.slice():[],sort:a?{id:String(a.id),dir:mp(a.mode??a.filter)}:null,sortMode:"server",selectable:i.selectable===!0?"single":["single","multi"].includes(i.selectable)?i.selectable:!1,height:i.height??null,stickyHeader:i.scroll!==!1,rowId:typeof i.rowId=="function"||typeof i.rowId=="string"?i.rowId:gp}}function ic(i={}){let t=dp[String(i.type??"text").toLowerCase()]??String(i.type??"text").toLowerCase(),e={id:i.id??null,type:t,label:i.label??"",description:i.description??"",value:Object.hasOwn(i,"value")?i.value:i.default,placeholder:i.placeholder??"",required:!!i.required,disabled:!!i.disabled,options:i.options??null,layout:i.horizontal===!1?"stack":i.horizontal?"inline":"stack",props:{}};return t==="html"&&(e.value=i.content??e.value),e}var Bt=Object.freeze({select:(i,t)=>[i.item??null,t],noselect:(i,t)=>[null,t],tableClick:i=>[i.row,i.event?.target?.closest?.("tr")??null,i.event],tableFilter:(i,t)=>[t?._legacyColumn?.(i.id)??{id:i.id},i.dir],tabChange:i=>[i.name]});function rc(i,t){let e=typeof i=="string"?Number.parseFloat(i):Number(i);return Number.isFinite(e)?Math.max(0,e):t}function pp(i){let t=String(i??"start");return["center","end","left","right"].includes(t)?t:"start"}function mp(i){return i==="desc"?"desc":"asc"}function _p(i){return i&&typeof i=="object"&&!Array.isArray(i)&&Object.hasOwn(i,"label")?i.label:i}function gp(i){return i?.ID??i?.id??i}var Ni=class extends A{static legacyName="gx.zeyos.Checklist";constructor(t,e={}){super(e,{data:[],listValue:"ID",listFormat:"name",listActive:"on"});let s=Ei(e);s.items=Array.isArray(e.data)?e.data:Array.isArray(e.items)?e.items:[],s.load=e.url?()=>this._load(e.url,e.requestData):null;let r=new Q(t,s);this._http=null,this._attach(r,{events:{complete:{type:"loaded",args:n=>[n.items]},change:{type:"change",args:n=>[n.values]}},ui:{frame:"root",table:"list",tbody:"list",search:"search"},setters:{data:"setData"}})}getValues(t){let e=this._zx.getValues();return t==null?e:e.map(s=>s?.[t]).filter(s=>s!=null)}setValues(t){return this._zx.setValues(t??[]),t}reset(){return this._zx.uncheckAll(),this}search(t){return this._zx.search(t),this}setData(t){return this._zx.setItems(Array.isArray(t)?t:[]),this}async load(t=this.options.url,e=this.options.requestData){let s=await this._load(t,e);return this._zx.setItems(s),this.fireEvent("complete",[s]),this}async loadFromURL(t,e,s){let r=await this.load(t,e);return s?.(this),r}async _load(t,e){this._http??=new ot({headers:this.options.requestHeader??{}});try{let s=String(this.options.method??"GET").toUpperCase(),r=await this._http.request(String(t??""),s==="GET"?{method:s,query:e??{}}:{method:s,data:e??{}});return typeof this.options.decodeResponse=="function"&&(r=this.options.decodeResponse(r)),Array.isArray(r)?r:[]}catch(s){throw this.fireEvent("failure",[s]),s}}},Ii=class extends Ni{static legacyName="gx.zeyos.Checklist"},Mi=class extends Ni{static legacyName="gx.bootstrap.Checklist"};function nc(i){return i===!1?"private":i===!0?"public":i}function oc(i){return i===!1||i==="private"?!1:i===!0||i==="public"?!0:i}var Oi=class extends A{static legacyName="gx.zeyos.Permission";constructor(t,e={}){super(e,{value:!0,groups:[]});let s=R.permission(t,{value:oc(e.value??!0),groups:e.groups??e.data??[],valueKey:e.groupsValueKey??e.elementIndex??"ID",labelKey:e.groupsLabelKey??e.elementLabel??"name"});this._attach(s,{events:{change:{type:"change",args:r=>[nc(r.value)]}},setters:{value:"set"}})}get(){return nc(this._zx.value)}set(t,e=!1){return this._zx.set(oc(t),{silent:e}),this}},Fi=class extends A{static legacyName="gx.zeyos.Table";constructor(t,e={}){super(e,{cols:[],data:[]});let s={...e};typeof e.structure=="function"&&(s.structure=(o,a)=>e.structure(o,a,this));let r=Ln(s,ac),n=new lt(t,r);this._cols=Array.isArray(e.cols)?e.cols.map(o=>({...o})):[],this._filter=r.sort?this._legacyColumn(r.sort.id):null,this._filter&&(this._filter.mode=r.sort.dir),this._attach(n,{events:{click:{type:"rowclick",args:o=>Bt.tableClick(o)},dblclick:{type:"rowdblclick",args:o=>Bt.tableClick(o)},filter:{type:"sort",args:o=>{let a=this._legacyColumn(o.id);return a.mode=o.dir,this._filter=a,[a,o.dir]}},complete:{type:"datachange",args:o=>[o.rows]}},ui:{table:()=>n._table,tbody:()=>n._tbody,thead:()=>n._thead,tableDiv:()=>n._scroll},setters:{data:"setData",height:"setHeight"}})}setData(t){return this._zx.setData(Array.isArray(t)?t:[]),this}addData(t){return this._zx.addData(Array.isArray(t)?t:[t]),this}empty(){return this._zx.empty(),this}setSort(t,e,s=!1){let r=String(typeof t=="object"?t.id:t);return this._zx.setSort(r,e,{silent:!!s}),this._filter=this._legacyColumn(r),this._filter.mode=this._zx._sort?.dir??e??"asc",this}getFilter(){return this._filter??!1}getData(){return this._zx.getData()}setHeight(t){let e=typeof t=="number"?`${t}px`:String(t);return this._zx._scroll.style.blockSize=e,this}_legacyColumn(t){return this._cols.find(e=>String(e.id)===String(t))??{id:t}}},Li=class extends Fi{static legacyName="gx.zeyos.Table"},Ri=class extends Fi{static legacyName="gx.bootstrap.Table"},Pi=class extends A{static legacyName="gx.ui.SimpleTable";constructor(t,e={}){t&&typeof t=="object"&&!t.nodeType&&!Array.isArray(t)&&(e=t,t=null),super(e,{cols:[],data:[]});let s={...e,rowId:n=>n};typeof e.structure=="function"&&(s.structure=(n,o)=>e.structure(n,o,this));let r=new lt(t,Ln(s,ac));this._attach(r,{events:{click:{type:"rowclick",args:n=>[n.row,n.index]}},ui:{table:()=>r._table,tbody:()=>r._tbody,thead:()=>r._thead}})}setData(t){return this._zx.setData(Array.isArray(t)?t:[]),this}addData(t){return this._zx.addData(Array.isArray(t)?t:[t]),this}createRow(t,e=this._zx.getData().length){let s=this._zx.getData();return s.splice(Math.max(0,e),0,t),this._zx.setData(s),this.display("tbody")?.querySelectorAll?.("tr[data-row]")?.[e]??null}addRow(t,e){return this.createRow(t,e)}updateRow(t,e){let s=this._zx.getData();return e>=0&&e<s.length&&(s[e]=t),this._zx.setData(s),this.display("tbody")?.querySelectorAll?.("tr[data-row]")?.[e]??null}removeRow(t){let e=this._zx.getData();return e.splice(t,1),this._zx.setData(e),this}getRows(){return this._zx.getData()}empty(){return this._zx.empty(),this}},Bi=class extends A{static legacyName="gx.bootstrap.DataFilter";constructor(t,e={}){super(e);let s=new ze(t,{data:[],filters:[],autoApply:!0});this.origin=[],this.filtered=[],this.filter=[],this._attach(s,{events:{filtered:{type:"filter",args:r=>(this.filtered=r.rows,[r.rows])}},ui:{clear:()=>s._controls,clearBtn:()=>s._clearButton}})}addSelectFilter(t,e,s,r,n){let o={type:"select",id:String(t),label:String(e),fields:Array.isArray(s)?s:[s]};return this.filter.push({identifier:t,fields:o.fields,method:n??this.selectFilter,type:"Select"}),this._zx.addFilter(o),this}addFulltextFilter(t,e,s,r,n){let o={type:"text",id:String(t),label:String(s??""),placeholder:String(s??""),fields:Array.isArray(e)?e:[e]};return this.filter.push({identifier:t,fields:o.fields,method:n??this.fulltextFilter,type:"Fulltext"}),this._zx.addFilter(o),this}addCustomElement(t){return this.toElement().insertBefore(t,this._zx._controls),this}initData(t){return this.origin=Array.isArray(t)?t:[],this._zx.setData(this.origin),this}doFilter(){return this.filtered=this._zx.apply(),this.filtered}clearFilter(){return this._zx.clear(),this}getFilter(t){return this.filter.find(e=>e.identifier==t)??null}fulltextFilter(t,e){return new RegExp(String(t),"i").test(String(e??""))}selectFilter(t,e){return t==e}};function ac(i){if(i?.nodeType||!i||typeof i!="object"||Array.isArray(i))return i;let t=document.createElement("span"),e=i.label;e?.nodeType?t.append(e):e!=null&&t.append(document.createTextNode(String(e))),i.className&&t.classList.add(...String(i.className).split(/\s+/).filter(Boolean));for(let[s,r]of Object.entries(i))["label","className","styles"].includes(s)||/^on/i.test(s)||r==null||["title","colspan","rowspan"].includes(s.toLowerCase())&&t.setAttribute(s,String(r));return t}var qi=class extends A{static legacyName="gx.zeyos.Datebox";constructor(t,e={}){super(e,{timestamp:0,unit:"milliseconds",format:["d",".","M",".","y"," ","h",":","i"]});let s=e.timestamp==null||Number(e.timestamp)===0?new Date:Te(e.timestamp,e.unit??"milliseconds"),r=Di(e.format),n=new q(t,{value:s,format:r,time:/%[HMS]/.test(r),disabled:!!e.disabled});this._attach(n,{events:{update:{type:"change",args:()=>[this.get()]}},ui:{input:"input",fieldset:"control"},setters:{timestamp:"set",disabled:o=>o?this.disable():this.enable()}})}set(t,e=this.options.unit??"milliseconds"){return this._zx.set(Te(t,e)),this}get(t=this.options.unit??"milliseconds"){let e=this._zx.get("date");return e?t==="date"?e:t==="seconds"?e.getTime()/1e3:e.getTime():null}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}},es=class extends A{static legacyName="gx.zeyos.DatePicker";static Picker=J;constructor(t,e={}){super(e,{date:!1,format:"%a %d.%m.%Y %H:%M",return_format:"%s"});let s=Te(e.date||new Date,e.unit??"milliseconds"),r=this.constructor.Picker,n=new r(t,bp(s,e,r));this._date=s,this._attach(n,{events:{select:{type:"change",args:o=>(this._date=o.date?new Date(o.date.getTime()):this._dateFromTime(o.time),[this._date])}},ui:{input:"root"},setters:{date:"set"}})}set(t){let e=Te(t,"milliseconds");return this._date=e,this.constructor.Picker===rt?this._zx.set(e):this._zx.set(e),this}get(t=this.options.return_format){let e=this._readDate();return e?t==null?e:t==="%s"||t==="seconds"?Math.floor(e.getTime()/1e3):t==="date"?e:z(e,String(t)):null}getSeconds(){let t=this._readDate();return t?t.getTime()/1e3:null}setReadOnly(t){return this.toElement().setAttribute("aria-disabled",String(!!t)),this}setFormat(t,e){return this.options.format=t,this.options.timePicker=e,this}_readDate(){if(this.constructor.Picker===rt){let t=this._zx.get();return t?this._dateFromTime(t):this._date}return this._zx.get()}_dateFromTime(t){let e=this._date?new Date(this._date.getTime()):new Date;return t&&e.setHours(Number(t.h)||0,Number(t.m)||0,Number(t.s)||0,0),e}},ji=class extends es{static legacyName="gx.zeyos.DatePicker";static Picker=J},Vi=class extends es{static legacyName="gx.zeyos.MonthPicker";static Picker=Ct},Hi=class extends es{static legacyName="gx.zeyos.TimePicker";static Picker=rt},ss=class extends A{static legacyName="gx.ui.Timebox";constructor(t,e={}){super(e,{time:0,unit:"minutes",seconds:!0,prefix:!1,disabled:!1});let s=new tt(t,{value:Number(e.time)||0,unit:Rn(e.unit),seconds:e.seconds!==!1,signed:!!e.prefix,disabled:!!(e.disabled||e.readonly)});this._attach(s,{events:{change:{type:"change",args:r=>[r.value]}},ui:{prefix:"sign"},setters:{time:"set",disabled:r=>r?this.disable():this.enable()}})}set(t,e=this.options.unit){return this._zx.set(t??0,Rn(e)),this}get(t=this.options.unit,e=0){let s=this._zx.get(Rn(t)),r=10**(Number(e)||0);return Math.round(s*r)/r}update(){return this.set(this.get())}enable(){return this.options.disabled=!1,this._zx.enable(),this.fireEvent("disabled",[!1]),this}disable(){return this.options.disabled=!0,this._zx.disable(),this.fireEvent("disabled",[!0]),this}disabled(){return!!this.options.disabled}setPrefix(t){let e=Math.abs(this.get());return this.set(t?e:-e),this}},$i=class extends ss{static legacyName="gx.ui.Timebox"},Ki=class extends ss{static legacyName="gx.zeyos.Timebox"},Ui=class extends ss{static legacyName="gx.bootstrap.Timebox"};function Te(i,t){if(i==null)return null;if(i instanceof Date)return new Date(i.getTime());if(typeof i=="number"||/^-?\d+(?:\.\d+)?$/.test(String(i))){let s=Number(i);return new Date(t==="seconds"?s*1e3:s)}let e=new Date(String(i));return Number.isNaN(e.getTime())?null:e}function bp(i,t,e){return e===rt?{value:i,seconds:/%S/.test(t.format??"")}:{value:i,min:Te(t.min??null,"milliseconds"),max:Te(t.max??null,"milliseconds"),time:e===J&&t.timePicker!==!1,showWeekNumbers:!!t.weeknumbers}}function Rn(i){return["seconds","minutes","hours"].includes(String(i))?String(i):"minutes"}var lc=Object.freeze({list:"list",plus:"plus",clock:"clock",range:"filter",reload:"reload",clear:"x",settings:"gear",eye:"eye",trash:"trash",fields:"list",search:"search",lock:"lock",checked:"check",question:"info"}),cc=Object.freeze({Icon(i){Yi();let t=lc[i]??(se[i]?i:null);if(!t)throw new RangeError(`Unsupported legacy icon: ${i}`);return _(t)},Button(i,t="",e,s={}){Yi();let r=j({label:String(i??""),icon:e?lc[e]??e:null,kind:yp(t),disabled:!!s.disabled,title:s.title,onclick:s.onclick??s.onClick});for(let n of["id","name","value"])s[n]!=null&&r.setAttribute(n,String(s[n]));return r},ButtonsGroup(i){return Yi(),Ms(Array.isArray(i)?i:[])}});function Yi(){Xe(Yi,"gx.zeyos.Factory","button/icon")}function yp(i){let t=String(i??"").toLowerCase();return t==="dark"||t==="em"?"primary":t.includes("danger")||t.includes("error")?"danger":t.includes("ghost")||t.includes("link")?"ghost":"default"}var Wi=class extends A{static legacyName="gx.bootstrap.Form";constructor(t,e={}){super(e,{fields:{},horizontal:["col-md-3","col-md-9"],columns:!1});let s=new ke(t,{fieldsets:[],actions:hc(e.actions)});this._fieldsets=[],this._attach(s,{events:{submit:{type:"submit",args:r=>[r.values,this]},change:{type:"change",args:r=>[r.id,r.value,this]},invalid:{type:"invalid",args:r=>[r.errors,this]}},ui:{body:()=>s._body,actions:()=>s._actions}}),e.fields&&typeof e.fields=="object"&&this.addFieldset({fields:e.fields,title:e.title,horizontal:e.horizontal,columns:e.columns})}addFieldset(t){let e=t instanceof Ee?t:new Ee(null,{horizontal:this.options.horizontal,columns:this.options.columns,...t});return this._fieldsets.push(e),this._zx.addFieldset(e._zx),e}addActions(t){let e=hc(t);if(e.length)this._zx.setActions(e);else{let s=Array.isArray(t)?t:[t];for(let r of s){let n=B(r);n?.nodeType===1&&this._zx._actions.prepend(n)}this._zx._actions.hidden=!1}return this}getValue(t){return this.getField(t)?.getValue()??null}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}getFieldsets(){return this._fieldsets.slice()}setValue(t,e){return this.getField(t)?.setValue(e),this}setValues(t){for(let e of this._fieldsets)e.setValues(t);return this}setHighlights(t={},e="error"){return this._fieldsets.reduce((s,r)=>s+r.setHighlights(t,e),0)}setHintHighlights(t={},e="error"){return this.setHighlights(t,e)}reset(){for(let t of this._fieldsets)t.reset().setHighlights();return this}},Ee=class extends A{static legacyName="gx.bootstrap.Fieldset";constructor(t,e={}){super(e,{fields:{},title:null,columns:1});let s=Number(e.columns)||1,r=new St(t,{title:e.title??"",columns:Math.max(1,Math.min(3,s)),fields:{}});this._fields={},this._attach(r,{ui:{columns:()=>r._grid}}),e.fields&&typeof e.fields=="object"&&this.addFields(e.fields)}addFields(t){for(let[e,s]of Object.entries(t??{}))this.addFieldItem(e,s);return this}addFieldItem(t,e){if(this.hasField(t))throw new Error(`Field "${t}" already exists.`);let s=e;return e instanceof dt||(e?.type!=null?s=new dt({...e,id:t}):e?.field!=null?s=new dt({...e,id:t,type:e.type??"custom"}):e?.nodeType||e?._zx?s=new dt({id:t,label:t,type:"custom",field:e}):s=new dt({...e??{},id:t})),this._fields[t]=s,this._zx.addField(t,s instanceof dt?s._zx:s?._zx??s),s}addField(t,e,s={}){return this.addFieldItem(t,new dt({...s,id:t,type:e}))}clear(){return this._zx.clear(),this._fields={},this}hasField(t){return Object.hasOwn(this._fields,t)}getField(t){return this._fields[t]??null}getFields(){return{...this._fields}}getValue(t){return this._fields[t]?.getValue?.()??null}getValues(){let t={};for(let[e,s]of Object.entries(this._fields))e.startsWith("__")||(t[e]=s.getValue?.());return t}setValue(t,e){return this._fields[t]?.setValue?.(e),this}setValues(t){for(let[e,s]of Object.entries(t??{}))this.setValue(e,s);return this}reset(){for(let t of Object.values(this._fields))t.reset?.();return this}focus(t){return this._fields[t]?.focus?.(),this}setHighlights(t={},e="error"){let s=0;for(let[r,n]of Object.entries(this._fields)){let o=t?.[r];o&&typeof o=="object"?(n.setHighlight(o.label,o.type??e),s+=1):o?(n.setHighlight(o,e),s+=1):n.setHighlight()}return s}setHintHighlights(t={},e="error"){return this.setHighlights(t,e)}},dt=class extends A{static legacyName="gx.bootstrap.Field";constructor(t={}){super(t,{label:"",type:"text",description:"",default:null});let e=xp(t),s=new S(null,e);this._type=e.type,this._attach(s,{events:{setValue:{type:"change",args:r=>[r.value]},change:{type:"change",args:r=>[r.value]}},ui:{label:()=>s.el.querySelector(".zx-field__label"),field:()=>s.getInput(),controlwrapper:()=>s.el.querySelector(".zx-field__control"),highlight:()=>s.el.querySelector(".zx-field__highlight"),description:()=>s.el.querySelector(".zx-field__description"),hint:()=>s.el.querySelector(".zx-field__control")},setters:{value:"setValue",default:"setValue",disabled:"setDisabled"}})}setLabel(t){let e=this.display("label");return e&&(e.textContent=ts(t)),this}setHelp(t){let e=this.display("description");return e&&(e.textContent=String(t??"")),this}getValue(){return this._zx.getValue()}setValue(t){return this._zx.setValue(t),this}setDisabled(t){return this._zx.setDisabled(t),this}setHighlight(t,e="warning"){return t?this._zx.setHighlight(String(t),wp(e)):this._zx.clearHighlight(),this}setHintHighlight(t,e="warning"){return this.setHighlight(t,e)}reset(){return this._zx.reset(),this}focus(){return this._zx.focus(),this}},Gi=class extends A{static legacyName="gx.bootstrap.ValueList";constructor(t,e={}){super(e,{deletable:!0});let s=new It(t,{values:e.values??e.default??[],deletable:e.deletable!==!1});this._attach(s,{events:{change:{type:"change",args:r=>[r.values]},click:{type:"add",args:r=>[r.value]}},ui:{textbox:()=>s._input,list:()=>s._list}})}addValue(t){return this._zx.addValue(t)}getValues(){return this._zx.getValues()}setValues(t){return this._zx.setValues(t??[]),this}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}focus(){return this._zx.focus(),this}},Qi=class extends A{static legacyName="gx.bootstrap.MultiValueEditor";constructor(t,e={}){super(e,{options:!1,default:!1});let s=uc(e.default||e.values||e.options),r=new Dt(t,{values:s,options:null});this._attach(r,{events:{change:{type:"change",args:n=>[JSON.stringify(n.values)]}},ui:{optionsbox:()=>r._rows,btnAdd:()=>r._add}})}getValue(){return JSON.stringify(this._zx.getValues())}setValue(t){return this._zx.setValues(uc(t)),this}},Zi=class extends A{static legacyName="gx.bootstrap.FieldUpload";constructor(t={}){super(t,{inputname:"upload",uploadurl:"./index.php",params:{},imageurl:""});let e=new Et(null,{url:t.uploadurl??t.url??"./index.php",paramName:t.inputname??t.paramName??"upload",params:t.params??{},accept:t.accept??null,multiple:!!t.multiple,autoUpload:t.autoUpload!==!1,http:t.http??null});this._value=null,this._attach(e,{events:{success:{type:"success",args:s=>(this._handleResponse(s.response),[s.response])},failure:{type:"error",args:s=>(t.showError?.(this,s.error),[s.error])},progress:{type:"progress",args:s=>[s.percent]}},ui:{select:()=>e._input,placeholder:()=>e._preview,progress:()=>e._progress}}),t.default&&this.setValue(t.default),t.disabled&&this.setDisabled(!0)}setValue(t){return this._value=t,this.setImage(t),this}getValue(){return null}setImage(t){if(this._zx._preview.replaceChildren(),t){let e=document.createElement("img");e.src=String(this.options.imageurl??"")+String(t),e.alt="",this._zx._preview.append(e)}return this}setDisabled(t){return this._zx.setDisabled(t),this}reset(){return this._zx.clear(),this}_handleResponse(t){typeof this.options.parseResponse=="function"&&this.options.parseResponse(this,t,e=>{e!=null&&this.setValue(e)})}};function xp(i){let t=ic(i),e=i.options&&typeof i.options=="object"&&!Array.isArray(i.options)?i.options:{};if(i.field!=null||typeof i.type!="string"&&i.type!=null){let s=i.field??i.type,r=typeof s=="function"?new s(null,Object.keys(e).length?e:i):s;return t.type="custom",t.adapter=()=>vp(r),t}if(t.type==="zxselect")t.props=Ti({...e,...i}),t.props.items=Array.isArray(i.data)?i.data:e.data??[],t.props.valueKey=i.elementIndex??e.elementIndex??"ID",t.props.labelKey=i.elementLabel??e.elementLabel??"name";else if(t.type==="checklist")t.props=Ei(Object.keys(e).length?e:i),t.props.items=e.data??i.data??[];else if(t.type==="date"||t.type==="datetime"){let s=Object.keys(e).length?e:i;t.props={format:Di(s.format??"%d.%m.%Y"),time:t.type==="datetime"},t.value=dc(t.value??s.date)}else if(t.type==="month")t.props={...e},t.value=dc(t.value??e.date??i.date);else if(t.type==="time"){let s=Object.keys(e).length?e:i;t.props={unit:s.unit??"minutes",seconds:s.seconds!==!1,signed:!!s.prefix},t.value=t.value??s.time??0}else t.type==="html"&&(t.value=B(i.content??t.value));return t}function vp(i){let t=i?._zx?.toElement?.()??i?.toElement?.()??i;if(!t?.nodeType)throw new TypeError("Custom legacy field must provide a DOM element");return{el:t,get:()=>i?.getValue?.()??i?.getValues?.()??i?.get?.()??("value"in t?t.value:null),set:e=>{typeof i?.setValue=="function"?i.setValue(e):typeof i?.setValues=="function"?i.setValues(e):typeof i?.set=="function"?i.set(e):"value"in t&&(t.value=e==null?"":String(e))},focus:()=>i?.focus?.()??t.focus?.(),setDisabled:e=>{typeof i?.setDisabled=="function"?i.setDisabled(e):e?i?.disable?.():i?.enable?.(),"disabled"in t&&(t.disabled=e)}}}function hc(i){return(Array.isArray(i)?i:i&&typeof i=="object"&&!i.nodeType?Object.values(i):[]).filter(e=>e&&typeof e=="object"&&!e.nodeType&&!e.tag).map((e,s)=>({id:e.id??String(s),label:e.label??e.text??"",icon:e.icon??null,kind:Sp(e.kind??e.type??(e.primary?"primary":"default")),type:e.submit?"submit":e.type==="reset"?"reset":"button",onClick:e.onClick??e.onclick??e.click}))}function wp(i){let t=String(i??"").toLowerCase();return t==="error"||t==="danger"?"danger":t==="success"||t==="primary"?"success":t==="warning"?"warning":"default"}function Sp(i){let t=String(i??"").toLowerCase();return t==="error"||t==="danger"?"danger":t==="primary"||t==="success"?"primary":t==="ghost"||t==="link"?"ghost":"default"}function uc(i){if(Array.isArray(i))return i;if(!i)return[];try{let t=JSON.parse(String(i));return Array.isArray(t)?t:[]}catch{return[]}}function dc(i){if(i instanceof Date||i==null)return i;if(typeof i=="number")return new Date(i*(Math.abs(i)<1e12?1e3:1));let t=new Date(String(i));return Number.isNaN(t.getTime())?null:t}var Ji=class extends A{static legacyName="gx.zeyos.Client";constructor(t={}){super(t,{url:"./remotecall.php"}),this._http=new ot({base:String(t.url??"./remotecall.php"),headers:t.headers??{},timeout:t.timeout??3e4})}post(t,e,s,r){return this.request(e,"POST",s,r,t)}get(t,e,s,r){return this.request(e,"GET",s,r,t)}async request(t,e="GET",s,r,n=""){Ap(this,s),this.fireEvent("request");try{let o=String(e).toUpperCase(),a=await this._http.request(String(n??""),o==="GET"?{method:o,query:t}:{method:o,data:t});if(r&&zp(a)!==r)throw new TypeError(`Invalid server response: expected ${r}`);return typeof s=="function"&&s.call(this,a),this.fireEvent("success",[a]),a}catch(o){throw this.fireEvent("failure",[o]),o}finally{this.fireEvent("complete")}}},Xi=class extends A{static legacyName="gx.zeyos.Request";constructor(t={}){super(t,{service:!1,accesskey:!1}),this._files=null,this.setService(t.service??"",t.accesskey??""),typeof t.showError=="function"&&(this.showError=t.showError)}setService(t,e=""){return this.options.service=t,this.options.accesskey=e,this.baseUrl=`${this.options.apiBase??"../remotecall/"}${t}${e?`:${e}`:""}/`,this._http=Ut(String(t),String(e),{apiBase:this.options.apiBase??"../remotecall/",headers:this.options.headers??{},timeout:this.options.timeout??3e4}),this}async send(t,e,s,r="GET"){this.fireEvent("request");try{let n=String(r??"GET").toUpperCase(),o={method:n};n==="GET"?o.query=e:o.data=e,this._files&&(o.files=this._files);let a=await this._http.request(String(t??""),o);return this._files=null,this.fireEvent("success",[a]),s?.call(this,a,"200 OK"),a}catch(n){this._files=null;let o=n instanceof Error?n:new Error(String(n));throw this.fireEvent("failure",[o]),this.fireEvent("error",[o.message,o.response??null,o.response?.headers??null]),this.fireEvent("exception",[o,null]),this.showError?.(o.message),o}finally{this.fireEvent("complete")}}post(t,e,s){return this.send(t,e,s,"POST")}get(t,e,s){return this.send(t,e,s,"GET")}put(t,e,s){return this.send(t,e,s,"PUT")}delete(t,e,s){return this.send(t,e,s,"DELETE")}upload(t,e,s,r){return this._files=kp(s),this.send(t,e,r,"POST")}openLink(t){return window.open(this.baseUrl+String(t??""),"_blank")}showError(t){console.error(t)}};function Ap(i,t){if(!(!t||typeof t!="object"))for(let[e,s]of Object.entries(t))i.addEvent(e,s)}function zp(i){return Array.isArray(i)?"array":i===null?"null":typeof i=="object"?"object":typeof i}function kp(i){return(i==null?[]:Array.from(i)).flatMap(e=>typeof File<"u"&&e instanceof File?[e]:e?.files?Array.from(e.files):[])}var tr=class extends A{static legacyName="gx.zeyos.Groupbox";constructor(t,e={}){super(e,{title:"",open:!0});let s=new _t(gt(t),{title:String(e.title??""),open:e.open!==!1});this._attach(s,{events:{open:{type:"open",args:()=>[this]},close:{type:"close",args:()=>[this]}},ui:{title:"summary",inner:"content"},setters:{title:"setTitle",open:r=>r?this.open():this.close()}}),Object.hasOwn(e,"content")&&s.setContent(B(e.content)),this._syncAct()}toggle(){return this._zx.toggle(),this._syncAct(),this}open(){return this._zx.open(),this._syncAct(),this}close(){return this._zx.close(),this._syncAct(),this}isOpen(){return this._zx.isOpen()}setTitle(t){return this._zx.setTitle(t),this}_syncAct(){this._mirrorAct(this.display("title"),this.isOpen())}},er=class extends A{static legacyName="gx.zeyos.Panel";constructor(t,e="",s=null,r=!0){super({title:e,content:s,open:r});let n=new ge(gt(t),{title:String(e??""),content:B(s),open:r!==!1});this._attach(n,{events:{open:"open",close:"close"},ui:{title:"toggle",header:"header",inner:"content",content:"content"},setters:{title:"setTitle",content:"setContent",open:o=>o?this.open():this.close()}})}toggle(){return this._zx.toggle(),this}open(){return this._zx.open(),this}close(){return this._zx.close(),this}isOpen(){return this._zx.isOpen()}setContent(t){return this._zx.setContent(B(t)),this}setTitle(t){return this._zx.setTitle(t),this}},sr=class extends A{static legacyName="gx.zeyos.MasterPanel";constructor(t,e="",s=null,r=[]){super({title:e,content:s,buttons:r});let n=new be(gt(t),{title:String(e??""),content:B(s),buttons:ar(r)});this._attach(n,{ui:{title:"title",inner:"content",content:"content",buttons:"buttons"},setters:{title:"setTitle",content:"setContent",buttons:o=>n.setButtons(ar(o))}})}setContent(t){return this._zx.setContent(B(t)),this}setTitle(t){return this._zx.setTitle(t),this}},is=class extends A{static legacyName="gx.zeyos.Tabbox";constructor(t,e={}){super(e,{frames:[],show:1});let s=sc(e),r=new Ft(gt(t),{tabs:s.tabs.map(or),active:s.active});this._attach(r,{events:{change:{type:"change",args:n=>Bt.tabChange(n)},close:{type:"close",args:n=>[n.name]}},ui:{tablist:"tablist",content:"panels",div:"tablist"},setters:{show:"openTab",height:n=>this.setStyle("height",n)}}),s.height!=null&&this.setStyle("height",s.height),r.on("change",()=>queueMicrotask(()=>this._syncAct())),this._syncAct()}addTab(t,e,s){let r=typeof t=="object"?t:{name:t,title:e,content:s};return this._zx.addTab(or(r)),this._syncAct(),this}closeTab(t){return this._zx.removeTab(String(t)),this._syncAct(),this}openTab(t){let e=typeof t=="number"?this._zx._tabs?.[t-1]?.definition.name:String(t);return e&&this._zx.openTab(e),this._syncAct(),this}setTabTitle(t,e){return this._zx.setTitle(String(t),e),this}setHighlight(t,e,s){return this._zx.setBadge(String(t),e==null||e===""?null:String(e)),this}getActive(){return this._zx.getActive()}_syncAct(){for(let t of this.display("tablist")?.querySelectorAll?.('[role="tab"]')??[])this._mirrorAct(t,t.getAttribute("aria-selected")==="true")}},ir=class extends is{static legacyName="gx.bootstrap.Tabbox"},rr=class extends A{static legacyName="gx.bootstrap.NavigationBar";constructor(t,e={}){super(e,{frames:[],title:"",buttons:[]});let s=Array.isArray(e.frames)?e.frames:[];this._frames=s.map(o=>({...o}));let r=typeof e.show=="number"?s[e.show-1]?.name:e.show,n=new xe(gt(t),{title:String(e.title??""),items:s.map(or),active:r==null?null:String(r),actions:ar(e.buttons??[])});this._attach(n,{events:{change:{type:"change",args:o=>[o.name]}},ui:{title:"title",tablist:"items",content:"panels",buttons:"actions"},setters:{title:"setTitle"}}),n.on("change",()=>queueMicrotask(()=>this._syncAct())),this._syncAct()}addTab(t,e,s){let r=typeof t=="object"?{...t}:{name:t,title:e,content:s};return this._frames.push(r),this._rebuild(),this}closeTab(t){return this._frames=this._frames.filter(e=>String(e.name)!==String(t)),this._rebuild(),this}openTab(t){return this._zx.setActive(String(t)),this._syncAct(),this}setTitle(t){return this._zx.setTitle(typeof t=="string"?t:t?.textContent??""),this}setTabTitle(t,e){let s=this._frames.find(r=>String(r.name)===String(t));return s&&(s.title=e),this._rebuild(),this}setNavigationButtons(t){return this._zx.setActions(ar(t)),this}setHighlight(t,e,s){return this._zx.setBadge(String(t),e==null||e===""?null:String(e)),this}_rebuild(){let t=this._zx._activeName;this._zx.setItems(this._frames.map(or)),t&&this._frames.some(e=>String(e.name)===String(t))&&this._zx.setActive(t),this._syncAct()}_syncAct(){for(let t of this.display("tablist")?.querySelectorAll?.('[role="tab"]')??[])this._mirrorAct(t,t.getAttribute("aria-selected")==="true")}},nr=class extends A{static legacyName="gx.zeyos.Search";constructor(t={}){super(t);let e=new Ot(null,{placeholder:t.placeholder??"",debounce:t.debounce??0});this._attach(e,{events:{input:{type:"input",args:(s,r)=>[this,e.refs.input,r]}},ui:{input:"input",submit:"submit",button:"submit"}}),this._listen(e.refs.input,"keydown",s=>{s.key==="Enter"&&this.fireEvent("keypress",[this,e.refs.input,s])}),this._listen(e.refs.submit,"click",s=>this.fireEvent("click",[this,e.refs.input,s]))}get(){return this._zx.get()}set(t){return this._zx.set(t),this}};function or(i){let t=B(i.content);return(typeof t=="string"||typeof t=="number"||t==null)&&(t=document.createTextNode(t==null?"":String(t))),{name:String(i.name??""),title:String(i.title??""),content:t,closable:!!i.closable,disabled:!!i.disabled}}function ar(i){return(Array.isArray(i)?i:[i]).filter(Boolean).map(t=>t?.toElement?.()??t).filter(t=>t?.nodeType===1)}var ft=class extends A{static legacyName="gx.zeyos.Select";static filterMode=!1;constructor(t,e={}){super(e,{data:[],elementIndex:"ID",elementLabel:"name",elementSelect:"name",value:null});let s=Ti(e);s.items=Cp(e),s.valueKey=Tp(e.elementIndex??"ID"),s.labelKey=Ep(e.elementLabel??"name"),s.renderItem=typeof e.elementLabel=="function"?e.elementLabel:null,s.renderValue=Dp(e.elementSelect??e.elementLabel??"name"),s.value=e.value??null,s.filter=this.constructor.filterMode==="local"?"local":["async","rest"].includes(this.constructor.filterMode)?n=>this._load(n):!1,s.debounce=e.debounce??200;let r=this.constructor.filterMode==="priority"?R.priority(t,s):new R(t,s);this._attach(r,{events:{select:{type:"change",filter:n=>n.item!=null,args:n=>Bt.select(n,this)},noselect:{type:"change",filter:n=>n.item==null,args:n=>Bt.noselect(n,this)},show:{type:"open",args:()=>[this]},hide:{type:"close",args:()=>[this]},requestSuccess:{type:"loaded",args:n=>[n.items]}},ui:{fieldset:"control",textbox:"input",dropdown:"list",icon:"toggle"},setters:{data:"setData",value:"setId",disabled:n=>n?this.disable():this.enable()}}),this._http=null,this.data=s.items}set(t,e=!1){return this._zx.set(t,{silent:!!e}),this}setId(t,e=!1){let s=this.data?.find(r=>gr(r,this.options.elementIndex??"ID")==t);return this._zx.set(s??t,{silent:!!e}),this}getId(t){return t==null?this._zx.value:gr(t,this.options.elementIndex??"ID")}getValue(){return this._zx.value}getSelected(){return this._zx.selected}setData(t){return this.data=Array.isArray(t)?t.slice():[],this._zx.setItems(this.data),this}getRows(){return Array.from(this.display("dropdown")?.querySelectorAll?.('[role="option"]')??[])}reset(t=!1){return this._zx.set(null,{silent:!!t}),this}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}show(){return this._zx.open(),this}hide(){return this._zx.close(),this}isOpen(){return this.toElement().getAttribute("data-state")==="open"}search(){return this._zx.open(),this}showLoader(){return this}hideLoader(){return this}async _load(t){try{let e=this.constructor.filterMode==="rest"?await this._loadRest(t):await this._loadUrl(t),s=Array.isArray(e)?e:[];return this.data=s,s}catch(e){throw this.fireEvent("requestFailure",[e]),e}}_loadUrl(t){this._http??=new ot({headers:this.options.requestHeader??{}});let e={...this.options.requestData??{}},s=typeof this.options.queryParam=="function"?this.options.queryParam(t,e):{...e,[this.options.queryParam??"query"]:t},r=String(this.options.method??"GET").toUpperCase();return this._http.request(String(this.options.url??"./"),r==="GET"?{method:r,query:s}:{method:r,data:s})}_loadRest(t){return this._http??=Ut(String(this.options.entity??""),String(this.options.accesskey??""),{apiBase:this.options.apiBase??"../remotecall/"}),this._http.get("",{...this.options.requestData??{},search:t,limit:this.options.limit??50})}},lr=class extends ft{static legacyName="gx.zeyos.Select"},cr=class extends ft{static legacyName="gx.zeyos.SelectFilter";static filterMode="local"},hr=class extends ft{static legacyName="gx.zeyos.SelectDyn";static filterMode="async"},ur=class extends ft{static legacyName="gx.zeyos.SelectPrio";static filterMode="priority"},dr=class extends ft{static legacyName="gx.bootstrap.Select"},fr=class extends ft{static legacyName="gx.bootstrap.SelectFilter";static filterMode="local"},pr=class extends ft{static legacyName="gx.bootstrap.SelectDyn";static filterMode="async"},mr=class extends ft{static legacyName="gx.bootstrap.SelectDynREST";static filterMode="rest";async setEntityId(t){let e=this.data?.find(s=>Object.is(gr(s,this.options.elementIndex??"ID"),t));if(e){this.set(e);return}if(!(t==null||t===""))try{this._http??=Ut(String(this.options.entity??""),String(this.options.accesskey??""),{apiBase:this.options.apiBase??"../remotecall/"});let s=await this._http.get(String(t));s&&this.set(s)}catch(s){throw this.fireEvent("requestFailure",[s]),s}}},_r=class extends ft{static legacyName="gx.bootstrap.SelectPrio";static filterMode="priority"};function Cp(i){let t=Array.isArray(i.data)?i.data.slice():[];return i.elementDefault==null?t:[i.elementDefault,...t]}function Tp(i){return typeof i=="function"?i:String(i)}function Ep(i){return typeof i!="function"?String(i):t=>fc(i(t))}function Dp(i){return t=>fc(gr(t,i))}function gr(i,t){return typeof t=="function"?t(i):i?.[t]}function fc(i){return i?.nodeType?i.textContent??"":String(i??"")}function qt(i,t){return class{constructor(){throw new Error(`${i} is not emulated by Zx; migrate to ${t}`)}}}var pc=qt("gx.core.Settings","plain option objects"),mc=qt("gx.ui.Container","zx.Component"),_c=qt("gx.ui.Collapse","CSS transitions"),gc=qt("gx.ui.Blend","CSS transitions"),bc=qt("gx.ui.Hud","zx.Dialog"),yc=qt("gx.ui.Toggling","zx.Toggle"),xc=qt("gx.ui.HGroup","CSS layout"),vc=qt("gx.ui.Templates","native template elements");var wc=Object.freeze({initValue:Np,initNum:Ip,formatTime:Mp,getMinutes:Op,formatNum:Fp,getNumber:Lp,printf:Rp,parseResult:Pp,Parse:zt,isArray:Array.isArray,isObject:i=>i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(typeof Node<"u"&&i instanceof Node)&&!(i instanceof Date),isFunction:i=>typeof i=="function",isString:i=>typeof i=="string",isNumber:i=>typeof i=="number"&&Number.isFinite(i),isElement:i=>typeof Element<"u"&&i instanceof Element,isNode:i=>typeof Node<"u"&&i instanceof Node,Console:(i,t)=>{typeof console>"u"||(t instanceof Error?console.error(i,t.stack):console.log(`${i}: ${t}`))}});function Np(i,t,e){return i?.[t]==null?e:i[t]}function Ip(i){return typeof i=="number"?i:typeof i=="string"?Number.parseFloat(i):0}function Mp(i){let t=i;if(typeof t=="string"){if(/^[0-9]+:[0-9]{2}$/.test(t))return t;if(/^[0-9]+:[0-9]{2,}$/.test(t))return t.replace(/[^0-9]/g,"").replace(/([0-9]{2})$/,":$1");t=Number.parseInt(t.replace(/[^0-9]/g,""),10)}if(t==null||Number.isNaN(Number(t)))return"0:00";let e=Number(t),s=e<0?"-":"";return e=Math.abs(e),`${s}${Math.floor(e/60)}:${Bp(e%60)}`}function Op(i){let t=String(i??"").replace(/[^0-9:]/,"").split(":");return t.length===1?Number.parseInt(t[0],10):Number.parseInt(t[0],10)*60+Number.parseInt(t[1],10)}function Fp(i,t=".",e=",",s=2){let r=i;typeof r=="string"&&(r=Number.parseFloat(r.replace(new RegExp(`[^0-9${Sc(t)}]`),"").replace(t,"."))),Number.isNaN(Number(r))&&(r=0);let n=typeof s=="number"?s:2,o=Math.round(Number(r)*10**n).toString();for(let c=o.length;c<=n;c+=1)o=`0${o}`;let a=o.length-n;n>0&&(o=`${o.slice(0,a)}${t}${o.slice(a)}`);for(let c=a-3;c>0;c-=3)o=`${o.slice(0,c)}${e}${o.slice(c)}`;return o}function Lp(i,t="."){return Number.parseFloat(String(i??"").replace(new RegExp(`[^0-9${Sc(t)}]`),"").replace(t,"."))}function Rp(i,t=[]){let e=Array.isArray(t)?t:[t],s=0;return String(i??"").replace(/%arg%/g,r=>s<e.length?String(e[s++]):r)}function Pp(i){let t=typeof i=="string"?JSON.parse(i):i;if(!t||typeof t!="object")throw new Error("Invalid server response");if(t.error)throw new Error(String(t.error.message??t.error));if(!Object.hasOwn(t,"result")||t.result==null)throw new Error("Undefined result");return t.result}function Bp(i){return String(i).padStart(2,"0")}function Sc(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var qp=Object.freeze({installGlobals:Gl,installElementStorage:Pt,parse:zt,GxWrapper:A}),br={core:{Settings:pc},ui:{Container:mc,SimpleTable:Pi,Timebox:$i,Collapse:_c,Blend:gc,Hud:bc,Toggling:yc,HGroup:xc,Templates:vc},util:wc,zeyos:{Toggle:bi,Msgbox:yi,Popup:wi,Dialog:Si,Dropdown:Ai,Select:lr,SelectFilter:cr,SelectDyn:hr,SelectPrio:ur,Checklist:Ii,Permission:Oi,Table:Li,Tabbox:is,Panel:er,MasterPanel:sr,Groupbox:tr,Search:nr,Datebox:qi,DatePicker:ji,TimePicker:Hi,MonthPicker:Vi,Timebox:Ki,Client:Ji,Request:Xi,Factory:cc},bootstrap:{Message:xi,Popup:Ce,PopupAlert:On,PopupConfirm:Fn,PopupConfirmCanceled:Mn,MenuButton:zi,CheckButton:ki,Select:dr,SelectFilter:fr,SelectDyn:pr,SelectDynREST:mr,SelectPrio:_r,Checklist:Mi,Table:Ri,Tabbox:ir,NavigationBar:rr,Timebox:Ui,Form:Wi,Fieldset:Ee,Field:dt,ValueList:Gi,MultiValueEditor:Qi,FieldUpload:Zi,DataFilter:Bi},compat:qp};function Pn(i=globalThis){return Pt(i),i.gx=br,br}br.install=Pn;var Ac=br;var Bn=typeof window>"u"?globalThis:window;Pt(Bn);Pn(Bn);Bn.zx=En;var S1=Ac;})();