@zeyos/zx 4.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.
- package/CHANGELOG.md +44 -0
- package/DESIGN-SYSTEM.md +59 -3
- package/dist/types/components/app-icon/app-icon.d.ts +88 -0
- package/dist/types/components/filter/filter-model.d.ts +87 -0
- package/dist/types/components/filter/filter.d.ts +331 -0
- package/dist/types/components/select/select.d.ts +46 -4
- package/dist/types/components/table/table.d.ts +103 -0
- package/dist/types/components/tag-picker/tag-picker.d.ts +16 -0
- package/dist/types/core/dom.d.ts +1 -1
- package/dist/types/core/util.d.ts +9 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/types/zeyos/icons.d.ts +19 -2
- package/dist/types/zeyos/index.d.ts +1 -1
- package/dist/types/zeyos/select.d.ts +2 -0
- package/dist/zx-zeyos.esm.js +702 -75
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +415 -4
- package/dist/zx.esm.js +1568 -115
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +1568 -115
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +379 -0
- package/docs/llms.md +93 -16
- package/docs/llms.txt +11 -9
- package/package.json +1 -1
- package/src/components/app-icon/app-icon.css +105 -0
- package/src/components/app-icon/app-icon.js +134 -0
- package/src/components/filter/filter-model.js +226 -0
- package/src/components/filter/filter.css +147 -0
- package/src/components/filter/filter.js +554 -0
- package/src/components/grid/grid.css +1 -1
- package/src/components/grid/grid.js +4 -1
- package/src/components/message/message.css +36 -3
- package/src/components/select/select.css +17 -0
- package/src/components/select/select.js +105 -24
- package/src/components/table/table.css +85 -0
- package/src/components/table/table.js +418 -24
- package/src/components/tag-picker/tag-picker.css +19 -0
- package/src/components/tag-picker/tag-picker.js +42 -5
- package/src/core/dom.js +1 -1
- package/src/core/util.js +20 -0
- package/src/index.js +7 -1
- package/src/zeyos/icons.js +34 -21
- package/src/zeyos/index.js +1 -1
- package/src/zeyos/select.js +6 -5
- package/styles/tokens/semantic.css +9 -0
- package/styles/tokens/themes.css +2 -2
- package/styles/zx.css +2 -0
package/dist/zx-zeyos.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function Z(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let t=i.getTime();if(!Number.isFinite(t))throw new RangeError("Invalid Date");return Math.floor(t/1e3)}function pt(i){if(i==null)return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");return new Date(t*1e3)}function ri(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(e=>{if(!e||typeof e!="object")return[];let s=e.rawField??e.field??e.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${e.dir==="desc"?"-":"+"}${n}`]})}function pn(i,t=[]){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let e=mn(i,t),s={},n=0;for(let r of e){if(!r.id||!Object.prototype.hasOwnProperty.call(i,r.id))continue;let o=i[r.id];if(o===void 0||o===null&&r.includeNull!==!0||typeof o=="string"&&o.trim()===""&&r.includeEmpty!==!0)continue;if(typeof r.toFilter=="function"){let h=r.toFilter(o,i);h&&typeof h=="object"&&!Array.isArray(h)&&Object.assign(s,h);continue}let a=typeof r.transform=="function"?r.transform(o,i):_n(o,r);if(a===void 0)continue;r.operator&&(a={[r.operator]:a});let c=Array.isArray(r.fields)?r.fields.filter(h=>typeof h=="string"&&h):[];if(c.length>1){for(;Object.prototype.hasOwnProperty.call(s,String(n));)n+=1;s[String(n)]=["OR",...c.map(h=>({[h]:a}))],n+=1;continue}let u=c[0]??r.rawField??r.field??r.id;typeof u=="string"&&u&&(s[u]=a)}return s}function ot(i={}){let{fields:t,sort:e,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:c=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(t)?u.fields=[...t]:t&&typeof t=="object"&&(u.fields={...t});let h={...s},f=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(f||!Object.prototype.hasOwnProperty.call(h,"visibility"))&&(h.visibility=a),Object.keys(h).length&&(u.filters=h);let p=gn(e,t),d=ri(p);return d.length&&(u.sort=d),n!=null&&String(n).trim()&&(u.query=String(n).trim()),r!=null&&(u.limit=r),o!=null&&(u.offset=o),c&&(u.count=!0),u}function mn(i,t){return Array.isArray(t)&&t.length?t.map(e=>({...e})):t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length?Object.entries(t).map(([e,s])=>typeof s=="string"?{id:e,field:s}:{...s,id:e}):Object.keys(i).map(e=>({id:e,field:e}))}function _n(i,t){let e=String(t.format??t.type??"").toLowerCase();return i instanceof Date&&["date","datetime","date-time"].includes(e)?Z(i):Array.isArray(i)&&["date","datetime","date-time"].includes(e)?i.map(s=>s instanceof Date?Z(s):s):i}function gn(i,t){if(!i||!t||Array.isArray(t)||typeof t!="object")return i;let e=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(t,n)?s:{...s,rawField:t[n]}};return Array.isArray(i)?i.map(e):e(i)}var Tt=Object.create(null),oi=new Set;function C(i,t){let e=Mt(i);if(!e)throw new TypeError("ZeyOS field type must not be empty");if(!t||typeof t!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=t[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Tt[e]=t,t}function Et(i){let t=hi(i),e=ui(t),s=di(e.field,t),n={id:t.id,type:"text",label:fi(t),...s};return t.description!=null&&(n.description=String(t.description)),(t.required===!0||t.nullable===!1)&&(n.required=!0),Mn(t)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function me(i){let t=hi(i),e=ui(t);return{id:t.id,label:fi(t),sortable:t.sortable!==!1,...di(e.column,t)}}function mt(i,t,e={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(t),r=ai(n?.fields),o=ai(s.fields(t)),a=new Map;for(let[p,d]of o)a.set(p,{...d,...r.get(p)??{}});for(let[p,d]of r)a.has(p)||a.set(p,{...d});let c=Array.isArray(e.fields)?e.fields.map(String):[...a.keys()],u=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),h=e.labels&&typeof e.labels=="object"?e.labels:{},f=[];for(let p of c){if(u.has(p)||!a.has(p))continue;let d=a.get(p)??{},m={...d,id:p,name:p,resource:String(t)},g=d.enums??d.enum??En(s,t,p);g!=null&&(m.enums=g,m.enum==null&&(m.enum=g)),Object.prototype.hasOwnProperty.call(h,p)&&(m.label=String(h[p])),f.push(m)}return f}var li={field:{type:"text"},column:{}},bn={field:{type:"int"},column:{align:"right"}},yn={field:{type:"float"},column:i=>({align:"right",render:gi(i)})},xn={field:{type:"float"},column:i=>({align:"right",render:gi(i,!0)})},vn={field:i=>({type:"zxselect",props:{entity:pi(i)}}),column:i=>({render:t=>jn(P(t,i),t,i)})},wn={field:{type:"toggle"},column:i=>({align:"center",render:t=>P(t,i)?"\u2713":"",sortValue:t=>+!!P(t,i)})},kn={field:i=>({type:Nn(i),options:_e(i)}),column:i=>({render:_i(i)})},Sn={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:_i(i,Fn())})},An={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:t=>Ln(P(t,i)),sortValue:t=>Nt(P(t,i))})},zn=ci("date"),Dn=ci("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])C(i,li);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])C(i,bn);for(let i of["number","numeric","decimal","real","double","double precision","float"])C(i,yn);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])C(i,xn);for(let i of["entity","t_entity"])C(i,vn);for(let i of["boolean","checked"])C(i,wn);for(let i of["list","enum"])C(i,kn);for(let i of["progress","percent"])C(i,An);for(let i of["date"])C(i,zn);for(let i of["datetime","date-time"])C(i,Dn);C("priority",Sn);C("text[]",{field:{type:"valuelist"},column:{}});C("json",{field:{type:"textarea"},column:{}});C("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])C(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function ci(i){return{field:{type:i},column:t=>({render:e=>On(P(e,t),i==="datetime"),sortValue:e=>Rn(P(e,t))})}}function ui(i){let t=Cn(i),e=Tt[t];return e||(oi.has(t)||(oi.add(t),console.warn(`[zx.zeyos] Unknown field type or format "${t||"unknown"}" for "${i.id}"; using text.`)),li)}function Cn(i){let t=Mt(i.format??i.semanticFormat??i.semanticType??i.widget);if(t&&Tt[t])return t;if(pi(i)||Mt(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let e=Mt(i.type);if(e==="bigint"||e==="int64"){let s=String(i.id).toLowerCase();if(s==="date"&&i.indexed)return"date";if(/(?:date|time)$/.test(s))return"datetime"}return Tn(i,e)?"longtext":e&&Tt[e]?e:e.endsWith("[]")?"text[]":e==="json"||e==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(e)?"character varying":e||t}function hi(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let t=i.id??i.name??i.field??i.identifier??i.reference;if(t==null||String(t).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(t)}}function di(i,t){let e=typeof i=="function"?i(t):i;return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function Mt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function fi(i){let t=i.label??i.title??i.displayName;return t==null||t===""?In(i.id):String(t)}function In(i){let t=String(i??"").split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Mn(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Tn(i,t){if(i.long===!0||i.multiline===!0)return!0;let e=Number(i.maxLength??t.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(e)&&e>255}function pi(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function ai(i){let t=new Map;if(Array.isArray(i)){for(let e of i)if(typeof e=="string")t.set(e,{});else if(e&&typeof e=="object"){let s=e.id??e.name??e.field;s!=null&&t.set(String(s),{...e})}}else if(i&&typeof i=="object")for(let[e,s]of Object.entries(i))t.set(e,s&&typeof s=="object"?{...s}:{});return t}function En(i,t,e){if(typeof i.enums!="function")return null;let s=i.enums(t,e);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,e)?s[e]:s??null}function _e(i){return mi(i.enums??i.enum??i.options)}function mi(i){if(typeof i=="string")try{return mi(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((t,e)=>{if(Array.isArray(t)){let[s=e,n=s]=t;return[String(s),String(n)]}if(t&&typeof t=="object"){let s=t.value??t.id??e;return[String(s),String(t.label??t.name??s)]}return[String(e),String(t)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([t,e])=>[t,String(e)])):{}}function Nn(i){return Object.keys(_e(i)).length<=5?"optionlist":"select"}function Fn(){return{0:"LOWEST",1:"LOW",2:"MEDIUM",3:"HIGH",4:"HIGHEST"}}function _i(i,t={}){let e={...t,..._e(i)};return s=>{let n=P(s,i);return n==null?"":e[String(n)]??String(n)}}function gi(i,t=!1){let e;try{e=new Intl.NumberFormat(i.locale,t&&i.currency?{style:"currency",currency:String(i.currency)}:{})}catch{e=new Intl.NumberFormat}return s=>{let n=Nt(P(s,i));return n==null?"":e.format(n)}}function Nt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?t:null}function Ln(i){let t=Nt(i);return t==null?"":`${new Intl.NumberFormat().format(t)}%`}function On(i,t){if(i==null||i==="")return"";try{let e=i instanceof Date?i:pt(i);return!e||!Number.isFinite(e.getTime())?"":new Intl.DateTimeFormat(void 0,t?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(e)}catch{return""}}function Rn(i){return i instanceof Date?Z(i):Nt(i)}function P(i,t){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,t.id))return i[t.id];let e=String(t.path??t.field??t.id).split("."),s=i;for(let n of e){if(!s||typeof s!="object")return;s=s[n]}return s}function jn(i,t,e){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=e.labelField;if(typeof s=="string"&&t[s]!=null)return String(t[s]);for(let n of[`${e.id}.name`,`${e.id}_label`,`${e.id}Label`])if(t[n]!=null)return String(t[n]);return i==null?"":String(i)}var bi=0;function v(i="zx"){return bi+=1,`${i}-${Date.now().toString(36)}-${bi.toString(36)}`}function Lt(i,t){let e=_t(i)?yi(i):{};if(!_t(t))return Ft(t);for(let[s,n]of Object.entries(t))_t(n)&&_t(e[s])?e[s]=Lt(e[s],n):e[s]=Ft(n);return e}function I(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function gt(i,t,e){return Math.min(e,Math.max(t,i))}function ge(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _t(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function yi(i){let t={};for(let[e,s]of Object.entries(i))t[e]=Ft(s);return t}function Ft(i){return _t(i)?yi(i):Array.isArray(i)?i.map(Ft):i}var bt=null;function be(i){if(typeof i!="string")return null;let t=i.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function l(i,t,...e){let s=document.createElement(i),n=t;qn(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Vn(s,r,o);return Bn(s,e),s}l.scope=function(t,e){let s=bt;bt=t;try{return e()}finally{bt=s}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function O(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function R(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 ye(i){if(i==null)return null;if(I(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return I(t)?t:null}return null}function qn(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 Vn(i,t,e){if(t==="ref"){bt&&typeof e=="string"&&(bt[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[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Pn(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 Pn(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Bn(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 n=s;if(typeof n.nodeType=="number")e.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}var xi=null,vi="en";function xe(i){vi=String(i||"en")}function B(){return vi}function j(i,t){let e=xi?xi(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,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),s}var Ot=new WeakMap,y=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let n=ye(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Hn(s,e),o=[];for(let[u,h]of Object.entries(r))/^on[a-z]/.test(u)&&typeof h=="function"&&(o.push([u.slice(2),h]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,h]of o)this.on(u,h);let a;try{a=l.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=I(a)?a:this.el;if(!I(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!I(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Ot.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=wi(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(wi(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,s,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,n=this.options.lang??this.options.language??B(),r=s?.[n]?.[t];if(r!=null)return F(String(r),e);let o=s?.[t];return o!=null?F(String(o),e):j(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Ot.get(this.el)===this&&Ot.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Ot.get(t)??null}};function Hn(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 n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=Lt(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=Lt(r,t.msg)),o&&(n.msg=r),n}function wi(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 x=class i extends y{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=Un(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):v("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,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"}),u=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),h=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),f=l("div",{class:"zx-field__body"},c,u,h);this._ownedNodes.push(a,f),t.append(a,f);let p=i.#t.get(e);if(p)try{this.adapter=Yn(p(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${g}`),this.adapter=Si(g,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=Si(m,this.controlId)}let d=this.adapter.el;return d.id||(d.id=this.controlId),a.htmlFor=d.id,Kn(d)||d.setAttribute("aria-labelledby",n),this._baseDescribedBy=d.getAttribute("aria-describedby")??"",c.append(d),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=h,this._syncDescription(),this.initialValue=$n(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(d,"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 y))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();Wn(this.el,this._rootAttributes??new Map),super.destroy()}};function ve(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=zi(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function we(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=zi(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function zi(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 n=[...s.matchAll(/\./g)].map(c=>c.index),r=[...s.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",u=c==="."?",":".",h=s.lastIndexOf(c),f=s.slice(0,h),p=s.slice(h+1);if(!/^\d+$/.test(p)||!ki(f,u))return null;o=f.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!ki(s,c))return null;o=s.split(c).join("")}else r.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 ki(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 $n(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function Yn(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 Si(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 Kn(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Un(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Wn(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function yt(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 Rt(i,t){return(e,s)=>{let n=l(i,yt(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return ke(n)}}function ke(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function Di(i){return(t,e)=>{let s=i==="int"?ve:we,n=l("input",yt(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...ke(n),get:()=>s(n.value).value}}}var Qn=(i,t)=>{let e=l("input",yt(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}}},Zn=(i,t)=>{let e=l("select",yt(t,{required:t.required,disabled:t.disabled}));for(let[s,n]of Ci(t.options))e.append(l("option",{value:s},n));return ke(e)},Gn=(i,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):v("zx-option-list"),n=Ci(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:s,value:r,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:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},Xn=(i,t)=>{let e=l("div",yt(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:r=>{Ai(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>Ai(s)}};function Ai(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var Jn=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function Ci(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)]):[]}x.register("text",Rt("input","text"));x.register("password",Rt("input","password"));x.register("textarea",Rt("textarea","text"));x.register("checkbox",Qn);x.register("int",Di("int"));x.register("float",Di("float"));x.register("select",Zn);x.register("optionlist",Gn);x.register("hidden",Rt("input","hidden"));x.register("html",Xn);x.register("custom",Jn);function K(i,t,e){let s=Ii(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=tr(n,e).map(Ii);return s.every(o=>r.some(a=>a.includes(o)))})}function tr(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 Ii(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var jt=class extends y{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=v("zx-checklist-label"),s=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=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}),r=l("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"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 u=this._itemValue(c);a.checked?this._checked.add(u):this._checked.delete(u),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(n=>this._itemValue(n)).filter(n=>e.has(n)));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=K(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=K(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let n=v("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return l("label",{class:"zx-checklist__item",for:n},r,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){er(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 er(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function Mi(){x.register("checklist",(i,t)=>{let e=i.own(new jt(null,{...t.props??{}})),s=!1,n=!1,r=()=>{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=>{n||i.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,r()}}})}var Ti=["January","February","March","April","May","June","July","August","September","October","November","December"],Ei=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Li=/%[demYyHMSaAbBs]/g;function w(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Li,e=>{switch(e){case"%d":return at(i.getDate());case"%e":return String(i.getDate());case"%m":return at(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return at(i.getFullYear()%100);case"%H":return at(i.getHours());case"%M":return at(i.getMinutes());case"%S":return at(i.getSeconds());case"%a":return Ni("weekday",i.getDay(),Ei[i.getDay()]);case"%A":return Se("weekday",i.getDay(),Ei[i.getDay()]);case"%b":return Ni("month",i.getMonth(),Ti[i.getMonth()]);case"%B":return Se("month",i.getMonth(),Ti[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function q(i,t){let e=[],s="^",n=0;for(let m of String(t).matchAll(Li)){s+=Fi(String(t).slice(n,m.index));let g=m[0],b=ir(g);if(b===null)return null;s+=`(${b})`,e.push(g),n=m.index+g.length}s+=Fi(String(t).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(e.forEach((m,g)=>{o[m]=Number(r[g+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,g=new Date(m);return Number.isNaN(g.getTime())?null:g}let a=o["%Y"]??sr(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,h=o["%H"]??0,f=o["%M"]??0,p=o["%S"]??0,d=new Date(0);return d.setHours(0,0,0,0),d.setFullYear(a,c,u),d.setHours(h,f,p,0),Number.isNaN(d.getTime())||o["%Y"]!==void 0&&d.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&d.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&d.getMonth()!==c||o["%d"]!==void 0&&d.getDate()!==u||o["%e"]!==void 0&&d.getDate()!==u||o["%H"]!==void 0&&d.getHours()!==h||o["%M"]!==void 0&&d.getMinutes()!==f||o["%S"]!==void 0&&d.getSeconds()!==p?null:d}function Oi(i,t,e){let s=i.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function D(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function S(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function G(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,n)),e}function qt(i=B()){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 at(i){return String(i).padStart(2,"0")}function Se(i,t,e){let s=`date.${i}.${t}`,n=j(s);return n===s?e:n}function Ni(i,t,e){let s=`date.${i}.short.${t}`,n=j(s);return n!==s?n:Se(i,t,e).slice(0,3)}function ir(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 sr(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Fi(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ri=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),nr=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),ji=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"}),rr=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"}),Ae=new Map;function qi(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(),n=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(ji,s))return{provider:"fa",name:n,style:ji[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function ze(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(i).replace(/^fa-/,""),a=r?rr[o]??o:o,c=[],u=nr[s];return u&&c.push(u),c.push(Ri[e]??Ri.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function De(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 Vi(i){let t=De(i),e=Ae.get(t);if(e)return e;let s=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Ae.delete(t),r(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 Ae.set(t,s),s}var Pi="http://www.w3.org/2000/svg",Hi=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"]}),or=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),ar=Object.create(null),H={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ie(){return{...H}}function Me(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(H[t]=i[t]);return Ie()}function $i(i={}){return Me({...i,provider:"fontawesome"})}async function Te(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Me({...n,kit:De(e)}),await Vi(e),s?$i():Ie()}function _(i,t={}){let e=qi(i);if(e.classes)return Ce(e.classes,t);let s=or[e.name]??e.name;return e.provider==="builtin"?Bi(s,t):e.provider==="fa"?Ce(ze(s,{style:e.style??t.style??H.style,family:t.family??H.family,fixedWidth:t.fixedWidth??H.fixedWidth}),t):H.provider==="fontawesome"?Ce(ze(s,{style:t.style??H.style,family:t.family??H.family,fixedWidth:t.fixedWidth??H.fixedWidth}),t):Bi(s,t)}function Bi(i,t){let e=ar[i]??Hi[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,n]=e,{size:r=16}=t,o=document.createElementNS(Pi,"svg"),a=document.createElementNS(Pi,"path");return o.setAttribute("class",Ki("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(r)),o.setAttribute("height",String(r)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Yi(o,t.label??null),a.setAttribute("d",n),o.append(a),o}function Ce(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=Ki("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),Yi(s,t.label??null),s}function Yi(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function Ki(...i){return i.flat().filter(Boolean).join(" ")}var lr=5,Vt=class extends y{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=Ui(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 n=v("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:n},_("clock",{size:15}))),this._clock=this._buildClock(n),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=Ui(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,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?dr(this.options.step):1,o=lt(t.currentTarget.value,0,s),a=s+1,c=(o+n*r+a*r)%a;t.currentTarget.value=X(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=X(lt(t.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;t[n]=lt(s.value,0,r)}let e=!this._value||!fr(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=X(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 n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.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"),n=e.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+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=X(this._display.h),this.refs.headMinute.textContent=X(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?cr():ur(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)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(n[c],a,e));let r=t&&!hr(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,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 n=e.value===s;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}};function cr(){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:X(e),angle:t*30,ring:"inner"})}return i}function ur(){let i=[];for(let t=0;t<60;t+=lr)i.push({value:t,label:X(t),angle:t*6,ring:"outer"});return i}function hr(i){return i>=1&&i<=12}function Ui(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:lt(i.h,0,23),m:lt(i.m,0,59),s:lt(i.s,0,59)}}function lt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function dr(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function X(i){return String(i).padStart(2,"0")}function fr(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var ct=class extends y{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=L(Pt(this.options.min)),this._max=L(Pt(this.options.max)),this._value=this._normalizeValue(Pt(this.options.value)),this._focused=L(this._value)??this._clampFocus(L(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=pr(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 Vt(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Ee(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(Pt(t));return this._value=s,s&&(this._focused=L(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ee(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=L(e);return this._min&&s<this._min&&Wi(e,this._min),this._max&&s>this._max&&Wi(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 n=S(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:w(n,"%A")},w(n,"%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=S(t,-e);this.refs.heading.textContent=w(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${w(t,"%B %Y")}`);let n=[];for(let r=0;r<6;r+=1){let o=S(s,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Qi(o)}`},String(Qi(o))));for(let c=0;c<7;c+=1){let u=S(o,c),h=!!(this._value&&D(u,this._value)),f=!this._inRange(u),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:D(u,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(f),ariaCurrent:D(u,new Date)?"date":null,ariaLabel:`${w(u,"%e")} ${w(u,"%B %Y")}`,dataset:{date:w(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},w(u,"%e"));a.append(l("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=q(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=q(e.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(t.key==="ArrowLeft")n=S(s,-1);else if(t.key==="ArrowRight")n=S(s,1);else if(t.key==="ArrowUp")n=S(s,-7);else if(t.key==="ArrowDown")n=S(s,7);else if(t.key==="PageUp")n=G(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=G(s,t.shiftKey?12:1);else if(t.key==="Home")n=S(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=S(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=L(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 n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=L(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Ee(e)})}_pageMonth(t){this._closeQuickPick();let e=G(this._focused,t);this._focused=L(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}},w(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),n=null;if(t.key==="ArrowLeft")n=s-1;else if(t.key==="ArrowRight")n=s+1;else if(t.key==="ArrowUp")n=s-3;else if(t.key==="ArrowDown")n=s+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=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(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.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=L(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=L(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${w(t,"%Y-%m-%d")}"]`)}};function Pt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function L(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Ee(i){return i?new Date(i.getTime()):null}function Wi(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function pr(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:qt()}function Qi(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 $t=class extends ct{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=Ht(Bt(this.options.min)),this._max=Ht(Bt(this.options.max)),this._value=this._normalizeMonth(Bt(this.options.value));let e=this._value??Ht(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",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(Bt(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=Ht(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),n=!!(this._value&&mr(s,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:w(s,"%B %Y"),dataset:{month:e}},w(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),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(s%3);else if(t.key==="End")n=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(n===null)return;t.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%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 Bt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Ht(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function mr(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function Zi(){x.register("month",(i,t)=>{let e=i.own(new $t(null,{...t.props??{},value:t.value})),s=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let r of e.el.querySelectorAll("button"))r.disabled=s};return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>i.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{s=!!r,n()}}})}var _r=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function U(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=_r.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=i.getAttribute("style"),c=t.getAttribute("style"),u=t.getAttribute("popover"),h=!1,f=null,p=()=>{},d=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let g=`--${v("zx-a")}`;i.style.setProperty("anchor-name",g),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",g);let b=gr(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",b),t.style.setProperty("inset-area",b),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let k=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(k,`${n}px`),p=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(f=new ResizeObserver(p),f.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",p=()=>br(i,t,{placement:s,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(f=new ResizeObserver(p),f.observe(i)),d=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return yr(t),p(),{update(){h||p()},destroy(){h||(h=!0,f?.disconnect(),d(),xr(t),Ne(i,"style",a),Ne(t,"style",c),Ne(t,"popover",u))}}}function gr(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 br(i,t,{placement:e,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,h=e,f=Gi(e),p=o.bottom+s,d=o.top-s-a.height,m=o.right+s,g=o.left-s-a.width;n&&(f==="bottom"&&p+a.height>u&&d>=0?h=Yt(e,"bottom","top"):f==="top"&&d<0&&p+a.height<=u?h=Yt(e,"top","bottom"):f==="right"&&m+a.width>c&&g>=0?h=Yt(e,"right","left"):f==="left"&&g<0&&m+a.width<=c&&(h=Yt(e,"left","right")));let b=Gi(h),k,T;if(b==="bottom"||b==="top"){let A=getComputedStyle(i).direction==="rtl";h.endsWith("-end")?k=A?o.left:o.right-a.width:h.endsWith("-start")?k=A?o.right-a.width:o.left:k=o.left+(o.width-a.width)/2,T=b==="bottom"?p:d}else k=b==="right"?m:g,h.endsWith("-end")?T=o.bottom-a.height:h.endsWith("-start")?T=o.top:T=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(gt(k,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(gt(T,0,Math.max(0,u-a.height)))}px`}function Gi(i){return i.split("-")[0]}function Yt(i,t,e){return i.replace(t,e)}function yr(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function xr(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Ne(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var vr=6,ss=864e5;function xt(i,t){let e=E(J(i)),s=E(J(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function Kt(i,t){let e=xt(i,t);return!e.start||!e.end?0:Math.round((ts(e.end)-ts(e.start))/ss)}function wr(i,t,e){let s=E(J(i));if(!s)return null;let n=xt(t,e);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:D(s,n.start)?"start":D(s,n.end)?"end":"middle":D(s,n.end)?"end":null:D(s,n.start)?"start":null}function Ut(i,t={}){let e=E(J(t.min)),s=E(J(t.max)),n=Qt(t.minNights)??0,r=Qt(t.maxNights),{start:o,end:a}=xt(i?.start,i?.end);return o&&(o=Le(o,e,s)),a&&(a=Le(a,e,s)),!o||!a?{start:o,end:a}:(r!==null&&Kt(o,a)>r&&(a=S(o,r)),n>0&&Kt(o,a)<n&&(a=S(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=S(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Wt=class extends y{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=Ir(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=E(J(this.options.min)),this._max=E(J(this.options.max)),this._minNights=Qt(this.options.minNights)??0,this._maxNights=Qt(this.options.maxNights),this._weekStart=zr(this.options.weekStart),this._monthCount=Dr(this.options.months),this._presets=Ar(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Ut({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=W(this._start)??this._clampFocus(E(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",z("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:z("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],t.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:W(this._start),end:W(this._end)}}set(t={},{silent:e=!1}={}){let s=Ut({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=W(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=[],Mr(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=E(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=Kt(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=E(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?W(this._start):null,this._committedEnd=t?W(this._end):null}_abandon(){return this._picking?(this._start=W(this._committedStart),this._end=W(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Le(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=es(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let n=s<0?s:s-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.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=es(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=E(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(r=>r.name===e.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.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 n=this._cellFor(e);n&&this._choose(n.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?E(t):null;!e&&!this._hover||e&&this._hover&&D(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,n=null;if(t.key==="ArrowLeft")n=S(s,-1);else if(t.key==="ArrowRight")n=S(s,1);else if(t.key==="ArrowUp")n=S(s,-7);else if(t.key==="ArrowDown")n=S(s,7);else if(t.key==="PageUp")n=G(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=G(s,t.shiftKey?12:1);else if(t.key==="Home")n=S(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=S(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}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_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=w(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,n=S(t,-s),r=[];for(let o=0;o<vr;o+=1){let a=S(n,o*7),c=l("tr"),u=Cr(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?z("daterange.week","Week %1",[is(a)]):null},u?String(is(a)):""));for(let h=0;h<7;h+=1){let f=S(a,h),p=l("td",{role:"presentation"});if(f.getMonth()===t.getMonth()&&f.getFullYear()===t.getFullYear()){let d=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:w(f,"%Y-%m-%d")}},w(f,"%e"));p.append(d),this._dayCells.push({date:f,cell:p,button:d})}c.append(p)}r.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:z("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:z("daterange.nextMonth","Next month")},_("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:z("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=S(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:w(n,"%A")},w(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)D(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);Fe(r,"range",a.range),Fe(r,"rangeEdge",a.edge),Fe(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(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),D(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=wr(t,this._start,this._end);if(!s)return{range:null,edge:null};let n=D(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return D(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:D(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=E(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=w(t,"%A, %e %B %Y");return e==="start"?`${s}, ${z("daterange.day.start","range start")}`:e==="end"?`${s}, ${z("daterange.day.end","range end")}`:e==="middle"?`${s}, ${z("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 z("daterange.status.empty","No date range selected");if(!this._end)return z("daterange.status.start","%1 selected, choose an end date",[w(this._start,"%e %B %Y")]);let t=Kt(this._start,this._end),e=t===1?z("daterange.night","1 night"):z("daterange.nights","%1 nights",[t]);return`${Sr(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=>D(e.date,t))?.button??null}};function kr(){return[{name:"today",label:z("daterange.preset.today","Today"),range:()=>Xi(V())},{name:"yesterday",label:z("daterange.preset.yesterday","Yesterday"),range:()=>Xi(S(V(),-1))},{name:"last7",label:z("daterange.preset.last7","Last 7 days"),range:()=>({start:S(V(),-6),end:V()})},{name:"last30",label:z("daterange.preset.last30","Last 30 days"),range:()=>({start:S(V(),-29),end:V()})},{name:"thisMonth",label:z("daterange.preset.thisMonth","This month"),range:()=>Ji(V(),0)},{name:"lastMonth",label:z("daterange.preset.lastMonth","Last month"),range:()=>Ji(V(),-1)},{name:"thisQuarter",label:z("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=V(),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:z("daterange.preset.thisYear","This year"),range:()=>{let i=V();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function z(i,t,e){let s=j(i);return F(s===i?t:s,e)}function Sr(i,t){if(D(i,t))return w(i,"%e %B %Y");let e=w(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${w(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${w(i,"%e %B")} \u2013 ${e}`:`${w(i,"%e")} \u2013 ${e}`}function Ar(i){return i===!0?kr():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 V(){return E(new Date)}function Xi(i){return{start:i,end:new Date(i.getTime())}}function Ji(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function J(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function E(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function W(i){return i?new Date(i.getTime()):null}function Le(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 ts(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function es(i){return i.getFullYear()*12+i.getMonth()}function Qt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function zr(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:qt()}function Dr(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function Cr(i,t){for(let e=0;e<7;e+=1){let s=S(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function is(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())/ss+1)/7)}function Fe(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function Ir(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Mr(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var Tr={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ns(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",u=r===""?[s]:s.split(new RegExp(`${a}${ge(r)}${c}`));if(u.length>2)return null;let h=q(u[0].trim(),t);if(!h)return null;if(u.length===1)return{start:h,end:new Date(h.getTime())};if(u[1].trim()==="")return{start:h,end:null};let f=q(u[1].trim(),t);return f?xt(h,f):null}function Er(i,t,e){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${w(s,t)}${e}${w(n,t)}`:w(n,t):w(s,t)}var Zt=class extends y{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=v("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:rs("daterange.clear","Clear date range")},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:rs("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 Wt(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",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.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=U(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(),Oe(this.el,"data-state",this._originalState),Oe(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=ns(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(ns(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()!==""?q(t.trim(),this._format):null}_clamp(t){return Ut(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=>Tr[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Er(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"&&Oe(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 rs(i,t,e){let s=j(i);return F(s===i?t:s,e)}function Oe(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function os(){x.register("daterange",(i,t)=>{let e=i.own(new Zt(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 tt=class extends y{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=Nr(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=as(this.options.min),this._max=as(this.options.max),this._value=this._normalizeValue(this.options.value);let e=v("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??Fr(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 ct(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",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.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=U(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=q(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=q(t,this._format)),!e||Number.isNaN(e.getTime())?null:Oi(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?w(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}},ls=function(t,e={}){return new tt(t,{...e,time:!0})};function as(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Nr(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Fr(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 us(){cs("date",i=>new tt(null,i)),cs("datetime",i=>ls(null,i))}function cs(i,t){x.register(i,(e,s)=>{let n=e.own(t({...s.props??{},value:s.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Gt=class extends y{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=v("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"},Lr(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 n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),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 n=s.find(o=>!Rr(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.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[n,r]of Object.entries(this.options.headers??{}))s.setRequestHeader(n,String(r));this.listen(s.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(qr(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(Vr())),s.send(jr(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 Lr(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${Or(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function Or(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function Rr(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 jr(i,t,e){let s=new FormData;for(let n of i)s.append(t,n);for(let[n,r]of Object.entries(e??{}))hs(s,n,r);return s}function hs(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)hs(i,t,n);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function qr(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function Vr(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function ds(){x.register("upload",(i,t)=>{let e=i.own(new Gt(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 fs=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ps=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Xt=class extends y{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 fs[this.options.reorder]??fs.both}_renderRows(t=-1,e="value"){let s=ms(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((u,h)=>{let f=!n||s.some(([d])=>d===u)?s:[[u,u],...s],p=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${h+1}`,dataset:{index:h}},f.map(([d,m])=>l("option",{value:d,selected:d===u},m))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${h+1}`,dataset:{index:h}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:h}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${h+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:h}},_("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===0),ariaLabel:`Move value ${h+1} up`,dataset:{action:"up",index:h}},_("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===a),ariaLabel:`Move value ${h+1} down`,dataset:{action:"down",index:h}},_("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${h+1}`,dataset:{action:"remove",index:h}},_("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ps[e]??ps.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,n=Number(e.dataset.index);if(s==="add"){let r=ms(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(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),n=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(s,n,"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,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!s&&n===t?o.dataset.drop="before":!s&&t===e.length&&n===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 n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),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 ms(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 _s(){x.register("multivalueeditor",(i,t)=>{let e=i.own(new Xt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(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}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var ut=class extends y{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:O(this.el);let t=this.el??l("div");this.el=t;let e=Pr(this.options.step);this._step=e,this._precision=this.options.precision===null?Br(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=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,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||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),n=s!==this._value;return this._value=s,this._syncInput(),n&&!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=Re(t,this.options.group?this._separators():null);return e===null?null:je(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,r=Re(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=gs(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=Re(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)),n={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];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_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,n=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}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&&R(t,this._snapshot)}};function Re(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 r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function je(i,{min:t,max:e,step:s,precision:n}){let r=i;if(s>0){let o=t??0;r=o+Math.round((i-o)/s)*s}return r=gs(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function Pr(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Br(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 gs(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function bs(){x.register("number",(i,t)=>{let e=i.own(new ut(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",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var Jt=class extends y{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:O(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=v("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 n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},_(this.options.icon,{size:vt[this.options.size]??vt.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},_(this.options.icon,{size:vt[this.options.size]??vt.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=vt[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),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!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",n=>{this._choose(t,n.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 n=this.msg(t,...s);return n===t?F(e,s):n}_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,n)=>{let r=Math.min(1,Math.max(0,t-n));s.style.setProperty("--zx-rating-fill",`${r*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(Hr(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&&R(t,this._snapshot)}},vt={sm:14,md:18,lg:24};function Hr(i,t){return t<1?i.toFixed(1):String(i)}function ys(){x.register("rating",(i,t)=>{let e=i.own(new Jt(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var Vc=["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 xs(i,t){let e="",s=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(u=>u===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let a=i(),c=a.findIndex(u=>$r(u).startsWith(e));c>=0&&t(a[c],c)}}function $r(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 Yr=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],vs=["Lowest","Low","Medium","High","Highest"],Kr=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),M=class i extends y{static cssName="select";static defaults={items:[],fixedItems:[],valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],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._actions=[],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=v("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}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),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})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},_("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),u=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return t.replaceChildren(c,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._actions=ws(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=xs(()=>this._optionEntries.filter(f=>!f.clear&&!f.action).map(f=>f.element),(f,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",f=>this._onKeydown(f)),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",f=>f.preventDefault()),this.listen(h,"click",f=>this._onOptionClick(f)),this.listen(document,"pointerdown",f=>{this._open&&!t.contains(f.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,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(s,r)&&this.emit("change",{value:r,item:n}),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}setActions(t){return this._actions=ws(t),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=U(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,n=new i(t,{...e,value:null,items:[],renderItem(r){return Wr(r,!0)},renderValueAdornment(r){return Ss(r.level)}});return n.setItems(Yr.map((r,o)=>{let a=o===2?n.msg("priority.medium"):r;return(a==="priority.medium"||o!==2)&&(a=n._message(r,vs[o])),{ID:o,name:a,level:o}})),n.set(s,{silent:!0}),n}static status(t,e={}){let{items:s=null,value:n=null,...r}=e,o=new i(t,{...r,value:null,items:[],renderItem(c){return Zr(c)},renderValueAdornment(c){return As(c)}}),a=Array.isArray(s)?s.map(Qr).filter(Boolean):Kr.map(([c,u,h,f,p],d)=>({ID:c,name:o._message(u,h),indicator:f,tone:p,shortcut:String(d+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static permission(t,e={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,u=typeof s=="function"?s:null,h=u?[]:s,f=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(t,{filter:u??a,...c,value:null,items:h,fixedItems:[],valueKey:d=>f.includes(d)?d.ID:Ve(d,r),labelKey:d=>f.includes(d)?d.name:String(Ve(d,o)??"")});return f[0].name=p._message("permission.private","Private"),f[1].name=p._message("permission.public","Public"),p.setFixedItems(f),p.set(n,{silent:!0}),p}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(this._open&&ks(t)){let e=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}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&&ks(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=K(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){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}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,n)=>{n===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.noneLabel??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 n=this._read(s,this.options.groupKey);Object.is(n,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(n??""))),e=n)}this._appendOption(s,!1)}if(this._actions.length>0){(this._visibleFixed.length>0||this._visibleItems.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let s=Symbol("initial-action-group");for(let n of this._actions)n.group&&n.group!==s&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},n.group)),s=n.group),this._appendAction(n)}this._visibleItems.length===0&&this._visibleFixed.length===0&&this._actions.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 n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?qe(this.options.renderNone(String(s??""))):e?String(s??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:v("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(_("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,s=Ur(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:v("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},s?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return qe(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._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=qe(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_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(r=>r===t);if(s!==void 0)return s;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??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 Ve(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return K(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 qe(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function ws(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),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function Ur(i){return typeof i=="string"?_(i):i instanceof Node?i.cloneNode(!0):null}function Wr(i,t){return l("span",{class:"zx-select__priority"},Ss(i.level),t?l("span",{},String(i.name)):null)}function Ss(i){let t=Math.max(0,Math.min(4,Math.trunc(Number(i)||0)));return l("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,s)=>l("span",{dataset:{filled:String(s<=t)}})))}function Qr(i){if(!i||typeof i!="object"||i.ID==null||i.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...i,name:String(i.name),indicator:t.includes(String(i.indicator))?String(i.indicator):"ring",tone:e.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function Zr(i){return l("span",{class:"zx-select__status"},As(i),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(i.name)),i.description?l("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?l("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function As(i){let t=String(i.indicator??"ring"),e=l("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(i.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(_("check",{size:8})),t==="canceled"&&e.append(_("x",{size:7})),e}function Ve(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function ks(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function zs(){x.register("zxselect",(i,t)=>{let e=t.props??{},s=e.preset,n={...e,value:t.value};delete n.preset;let r=i.own(s==="priority"?M.priority(null,n):s==="status"?M.status(null,n):new M(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var te=class extends y{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:O(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=v("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()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.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"})),n),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",r=>{this._readonly&&Gr.has(r.key)&&r.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),n=s!==this._value;return this._value=s,this._paint(),n&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,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 n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(n)*100}%`}},r))}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)?je(e,{min:this._min,max:this._max,step:this._step,precision:Xr(this._step)}):this._min}_ratio(t){return gt((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Jr(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&R(t,this._snapshot)}},Gr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Xr(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Jr(i){return String(Number(i.toFixed(6)))}function Ds(){x.register("slider",(i,t)=>{let e=i.own(new te(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ee=class extends y{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:O(this.el);let t=this.el??l("div");this.el=t;let e=v("zx-tag-picker-list"),s=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=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??"")}),r=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,n,r),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",u=>{let h=u.target;h.closest(".zx-tag-picker__remove")||h.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",u=>{let h=u.target.closest(".zx-tag-picker__remove");if(!h||this._disabled||this._readonly)return;u.stopPropagation();let f=[...s.children].indexOf(h.closest(".zx-tag-picker__tag")),p=this._selected[f];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.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:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(u=>this._sameValue(u,c))&&r.push(c)}let o=!to(r,this._selected,a=>this._valueOf(a));return this._selected=r,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(n=>this._sameValue(n,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),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),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=U(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&&R(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),n=this.options.renderTag?this.options.renderTag(e):s,r=l("span",{class:"zx-tag-picker__tag"},l("span",{class:"zx-tag-picker__tag-label"},n));return!this._readonly&&!this._disabled&&r.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},_("x",{size:11}))),r});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 r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:v("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(r):this._labelOf(r)));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=l("div",{class:"zx-tag-picker__option",id:v("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:r,create:!0}),e.push(r)}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 n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n: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(n=>n.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}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 n=e===t;s.element.toggleAttribute("data-active",n),n&&(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=K(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(n=>Cs(this._labelOf(n))===Cs(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(r=>Object.is(this._valueOf(r),e));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n: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 n=this.msg(t,...s);return n!==t?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Cs(i){return String(i??"").trim().toLocaleLowerCase()}function to(i,t,e){return i.length!==t.length?!1:i.every((s,n)=>Object.is(e(s),e(t[n])))}function Is(){x.register("tagpicker",(i,t)=>{let e=i.own(new ee(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{s=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function eo(i,t="minutes"){let e=Math.round(Math.abs(Ms(et(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:et(i)<0}}function io(i,t="minutes"){wt(t);let e=Math.abs(Math.trunc(et(i?.hours))),s=Math.abs(Math.trunc(et(i?.minutes))),n=Math.abs(Math.trunc(et(i?.seconds))),r=i?.negative?-1:1;return Ts(r*(e*3600+s*60+n),t)}var ie=class extends y{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){wt(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 io(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),wt(e);let n=et(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Ts(Math.round(Ms(n,e)/60)*60,e)),this._parts=eo(n,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,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(n,Math.trunc(et(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]):so(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 et(i){let t=Number(i);return Number.isFinite(t)?t:0}function Ms(i,t){return wt(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function Ts(i,t){return wt(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function wt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function so(i){return String(i).padStart(2,"0")}function Es(){x.register("time",(i,t)=>{let e=i.own(new ie(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 ht=class extends y{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:no(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&&ro(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function no(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ro(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 Ns(){x.register("toggle",(i,t)=>{let e=i.own(new ht(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 se=class extends y{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=Fs(this.options.values,!!this.options.unique);let e=v("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=Fs(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,n)=>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:n}},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 n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&n&&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[n]=this._values.splice(t,1);this._values.splice(e,0,n),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 Fs(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function Ls(){x.register("valuelist",(i,t)=>{let e=i.own(new se(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 ne=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),oo=["xl","lg","md","sm"];function Os(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of oo)if(t>=ne[e])return e;return"xs"}function Rs(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!I(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=I(e)?e:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let f=a();if(s&&f===0)return;let p=Os(f);p!==n&&(n=p,i(n,f))};c();let u=0,h=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(h),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??Os(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var ao=0,lo=20,co=3;var js=new Map;function re(i,t={}){let e=He(i);if(e===null)return"";let{locale:s=B(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Pe(s,Be({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function Vs(i,t,e={}){let s=He(i);if(s===null)return"";let{locale:n=B(),decimals:r}=e,o=ho(t);if(o===null)return re(s,{locale:n,decimals:r});let a=Be({decimals:r,group:!0});return Pe(n,{...a,style:"currency",currency:o},s)}function Ps(i,t={}){let e=He(i);if(e===null)return"";let{locale:s=B(),decimals:n=0}=t;return Pe(s,{...Be({decimals:n,group:!0}),style:"percent"},e)}function Pe(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,n=js.get(s);return n===void 0&&(n=uo(i,t),js.set(s,n)),n.format(e)}function uo(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Be({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let n={useGrouping:s!==!1},r=qs(t??i),o=qs(e??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,co)),n}function qs(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(lo,Math.max(ao,Math.round(t))):null}function He(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function ho(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function fo(i,t){return String(i).localeCompare(String(t))}function po(i,t){return i-t}function mo(i,t){return i.getTime()-t.getTime()}function _o(i,t,e="asc"){let s=i==null,n=t==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&t instanceof Date?r=mo(i,t):typeof i=="number"&&typeof t=="number"?r=po(i,t):r=fo(i,t),e==="desc"?-r:r}function go(i,t="asc"){return(e,s)=>_o(i(e),i(s),t)}function $e(i,t,e="asc"){let s=go(t,e);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var bo=new Set(["text","number","select","date","checkbox","textarea"]),yo='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',St=class extends y{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===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:O(e),this._columns=Array.isArray(this.options.columns)?this.options.columns.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=Eo(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Mo(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Lo(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Co(this.options.hierarchy,this._columns),this._expanded=Io(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of oe(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);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?e.replaceChildren(this._scroll):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:v("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(this._scroll,this._editMessage)),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleEditFocusIn(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),e}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),$s(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 $s(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(r=>Object.is(this._idFor(r),t));if(s<0)return this;let n=this._selected.delete(t);return this._data[s]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),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 r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:r}),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(n=>this._idFor(n))),s=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return Fo(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=oe(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!t.silent)for(let n of s)this._emitRowToggle(n,!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(h=>h.id===e);if(!s)return this;let n=this._data.find(h=>Object.is(this._idFor(h),t));if(n===void 0||kt(s,n)===!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 r=this._data.findIndex(h=>Object.is(this._idFor(h),t));if(r<0)return this;let o=this._data[r],a=this._rowElements.get(t)?.[0];if(!a)return this;let c=this._editMode==="row"?this._columns.filter(h=>kt(h,o)!==!1):[s],u=new Map;for(let h of c){let f=Hs(a,h.id);if(!f)continue;let p=this._createEditor(f,h,o,r);p&&u.set(h.id,p)}return u.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:u,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[f,p]of t.cells)s[f]=p.read();let n=this._columns.filter(f=>t.cells.has(f.id)),r=Do(s,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(f=>f.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=zo(e,s),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(f=>f.id===a)??null,columnId:a,value:s[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let u=this._editHasFocus(),h={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,h),u&&this._focusCell(this._idFor(h),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?vo(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,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),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 n=this.msg(t,...s);return n===t?F(e,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ne)||(this._width=Rs((e,s)=>this._setStacked(s>0&&s<ne[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,n]of e)s&&(t?s.setAttribute("role",n):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(R(this.el,this._original),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(n=>No(n.width)),s=e.reduce((n,r)=>n+r,0);this._table.dataset.layout=s>0?"fixed":"auto",this._columns.forEach((n,r)=>{let o=l("col");e[r]>0?o.style.width=`${e[r]/s*100}%`:n.width&&n.width!=="auto"&&(o.style.width=String(n.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"}),n=e.align??(Ye(e)?"end":null);if(n&&(s.dataset.align=n),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let r=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(r)}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,n)=>{t.append(this._createRow(s.row,s.index,{...s,visibleIndex:n}))}),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 n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:s.visibleIndex});let a=this._rowElements.get(n)??[];if(a.push(r),this._rowElements.set(n,a),this.options.selectable==="multi"){let c=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},c))}return this._columns.forEach(c=>{let u=l("td"),h=c.align??(Ye(c)?"end":null);h&&(u.dataset.align=h),u.dataset.label=c.label,c.popin===!1&&(u.dataset.popin="false"),this._editMode!==!1&&(u.dataset.column=c.id,kt(c,t)!==!1&&(u.dataset.editable="true",u.tabIndex=-1,this._offerRovingCell(u,n,c.id))),this._renderCellContent(u,c,t,e,s),r.append(u)}),r}_renderCellContent(t,e,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=xo(e,s,n),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||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let u=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(u),ariaLabel:`${u?"Collapse":"Expand"} row ${n+1}`},_(u?"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&&ae(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.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&&ae(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n){if(this._editMode!==!1){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,s,n){let r=kt(e,s);if(r===!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 u=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,u),t.dataset.editing="true";let h={column:e,type:r,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){h.custom=o,h.read=()=>it(e,h.custom,s);let d={value:o,row:s,column:e,commit:g=>{h.custom=g,this.commitEdit()},cancel:()=>this.cancelEdit()},m=e.editor(s,d);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(h.component=m),u.append(m.toElement())):m&&u.append(m),h.control=u.querySelector(yo)??u,h}if(r==="number"){let d=st(e.locale,s),m=Ys(e,s),g=e.type==="currency"?st(e.currency,s):e.type==="unit"?st(e.unit,s):null,b={...d!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:d}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:m}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(g)}:{}},k=new ut(null,{...b,...a,value:o??null});return u.append(k.el),h.component=k,h.control=k.getInput(),h.read=()=>(k.set(k.getInput().value,{silent:!0}),it(e,k.get(),s)),h}if(r==="select"){let d=ko(e.options,s),m=d.find(b=>Object.is(b.value,o))??d.find(b=>String(b.value)===String(o??"")),g=new M(null,{...a,items:d,valueKey:"value",labelKey:"label",value:m?m.value:null});return u.append(g.el),h.component=g,h.control=g.refs.input,h.read=()=>it(e,g.value,s),h}if(r==="date"){let d=new tt(null,{...a,value:o??null});u.append(d.el),h.component=d;let m=d.refs.input;return h.control=m,h.read=()=>{let g=String(m.value??"").trim(),b=d.get();return g===""?it(e,null,s):(d.set(g,{silent:!0}),d.get()===null&&d.set(b,{silent:!0}),it(e,d.get(),s))},h}if(r==="checkbox"){let d=new ht(null,{...a,checked:!!o});return u.append(d.el),h.component=d,h.control=d.el,h.read=()=>it(e,d.get(),s),h}let f=r==="textarea",p=l(f?"textarea":"input",{...a,class:f?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...f?{}:{type:"text"},ariaLabel:a.ariaLabel??`${e.label} row ${n+1}`,value:So(e,o,s)});return u.append(p),h.control=p,h.read=()=>it(e,p.value,s),h}_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?Hs(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),s=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.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(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,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&&ae(e)){if(To(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 n=this._rowMeta.get(s.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,s);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,s){let n=this._columns.length;if(t<0||n===0)return null;let r=this._visibleData(),o=this._idFor(this._data[t]),a=r.findIndex(h=>Object.is(this._idFor(h),o));if(a<0)return null;let c=this._columns.findIndex(h=>h.id===e),u=r.length*n+n;for(let h=0;h<u;h+=1){if(c+=s,c>=n?(a+=1,c=0):c<0&&(a-=1,c=n-1),a<0||a>=r.length)return null;let f=r[a],p=this._columns[c];if(kt(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}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 n=this._rowMeta.get(s.parentElement);n&&this._setRovingCell(s,n.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&ae(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_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 n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=t.visibleIndex??n.findIndex(u=>Object.is(this._idFor(u),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let u=a;u<=c;u+=1){let h=this._idFor(n[u]);e?this._selected.add(h):this._selected.delete(h)}}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 n of e){n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),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?wo(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):$e(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?oe(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,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=oe(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 xo(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=st(i.locale,t),o=Ys(i,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return re(s,a);if(n==="currency"){let c=st(i.currency,t);return Vs(s,c==null?null:String(c),a)}if(n==="percent")return Ps(s,a);if(n==="unit"){let c=re(s,a),u=st(i.unit,t);return c&&u!=null&&String(u)!==""?`${c}\xA0${u}`:c}return s}function vo(i,t,e,s=[]){let n=Ke(i,t,e),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:u}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:u,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let h=c.children.length-1;h>=0;h-=1)a.push({node:c.children[h],depth:u+1})}return o}function wo(i,t,e,s,n){let r=Ke(i,t,e),o=u=>$e(u,h=>s(h.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let u=c.pop();a.push(u.row);let h=o(u.children);for(let f=h.length-1;f>=0;f-=1)c.push(h[f])}return a}function kt(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?Ye(i)?"number":"text":typeof e=="string"&&bo.has(e)?e:!1}function ko(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,n])=>({value:s,label:String(n??"")})):[]}function So(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 it(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Ao(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function zo(i,t){let e={};for(let[s,n]of Object.entries(t??{}))Ao(i?.[s],n)||(e[s]=n);return e}function Do(i,t,e,s="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function st(i,t){return typeof i=="function"?i(t):i}function Ys(i,t){let e=st(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Ye(i){return["number","currency","percent","unit"].includes(i?.type)}function Ke(i,t,e){let s=(Array.isArray(i)?i:[]).map((a,c)=>({row:a,id:Bs(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let c=n.get(Bs(e,a.row))??null;r.set(a,c===a?null:c)}for(let a of s){let c=new Set([a]),u=r.get(a)??null;for(;u;){if(c.has(u)){r.set(u,null);break}c.add(u),u=r.get(u)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function oe(i,t,e){return Ke(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function Bs(i,t){return typeof i=="function"?i(t):t?.[i]}function Co(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,n=t.some(r=>r.id===s)?s:t[0]?.id;return n?{...i,parentId:e,column:n}:null}function Io(i){return new Set(Array.isArray(i)?i:[])}function Mo(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function ae(i){return!!i?.closest?.(".zx-table__editor")}function To(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Hs(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function Eo(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 No(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 $s(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Fo(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Lo(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ue=class extends y{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",closeLabel:"Close launcher",resultsLabel:"Launcher results",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k",hints:{move:"Move",open:"Open",close:"Close"}};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,u=>[u.name,u.value]),children:Array.from(t.childNodes)},this._items=Ue(this.options.items),this._sources=Ws(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=v("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}),n=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel},_("x")),r=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:this.options.resultsLabel}),a=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Oo()):null,c=Ro(this.options.hints);return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:a?"true":"false"}},_("search"),s,a,n),r,o,c)),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",u=>this._onKeydown(u)),this.listen(n,"click",()=>this.close()),this.listen(o,"click",u=>{let h=u.target?.closest?.("[data-launcher-index]");!h||!o.contains(h)||this._activate(Number(h.getAttribute("data-launcher-index")),u)}),this.listen(o,"pointermove",u=>{let h=u.target?.closest?.("[data-launcher-index]");if(!h||!o.contains(h))return;let f=Number(h.getAttribute("data-launcher-index"));!Number.isInteger(f)||this._results[f]?.disabled||f===this._active||(this._active=f,this._syncActive())}),this.listen(t,"cancel",u=>{u.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",u=>this._onDocumentKeydown(u)),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=Ue(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(s=>({...s,current:e!==null&&String(s.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=Ws(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(r=>le(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let s=new AbortController,n=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:s.signal});if(s.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,Ue(o).map((a,c)=>({...a,_source:r.id,_sourceOrder:r.order==="source",group:a.group??r.label??"",itemOrder:a.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(s.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(s.signal.aborted||n!==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=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,s=this._query.trim(),n=this._items.filter(d=>le(d.when,s)),r=Ks(n,s,this.options.maxResults),o=this._sources.flatMap(d=>{let m=this._sourceItems.get(String(d.id))??[];return d.order==="source"?m.filter(g=>le(g.when,s)):Ks(m.filter(g=>le(g.when,s)),s,this.options.maxResults)}),a=new Set,c=[...r.map(d=>({...d,_source:null})),...o].filter(d=>{let m=String(d.id);return a.has(m)?!1:(a.add(m),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),u=new Map;for(let d of c){let m=String(d.group??"");u.has(m)||u.set(m,[]),u.get(m).push(d)}this._results=[...u.values()].flat(),this._renderedQuery=t;let h=e===null?-1:this._results.findIndex(d=>!d.disabled&&String(d.id)===e);this._active=h>=0?h:this._results.findIndex(d=>!d.disabled);let f=[],p=0;for(let[d,m]of u){let g=m.map(b=>this._option(b,p++));d?f.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:d,dataset:{layout:m.every(b=>b.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},d),g)):f.push(...g)}this.refs.results.replaceChildren(...f),this._syncActive(),this._renderStatus()}_option(t,e){let s=be(t.href),n=s?"a":"button",r=[],o=jo(t);return o&&r.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),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(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:s,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:v("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:qo(t.kind)}},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 n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}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((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")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"})}_spatialIndex(t,e){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=Vo(n,s,t);return r?Number(r.getAttribute("data-launcher-index")):null}_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"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function Oo(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function Ro(i){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??"Move"),l("span",{},l("kbd",{},"\u21B5"),t.open??"Open"),l("span",{},l("kbd",{},"Esc"),t.close??"Close"))}function jo(i){let t=i.icon;if(typeof t=="function"&&(t=t(i)),typeof t=="string")return _(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function qo(i){return i==="application"||i==="record"?i:"action"}function le(i,t){return i==="empty"?t==="":i==="query"?t!=="":!0}function Vo(i,t,e){let s=t.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let c of i){if(c===t)continue;let u=c.getBoundingClientRect(),h=u.left+u.width/2-n,f=u.top+u.height/2-r,p=!1,d=1/0;e==="ArrowLeft"?(p=h<-2&&Math.abs(f)<Math.max(s.height,u.height)/2,d=Math.abs(h)+Math.abs(f)*4):e==="ArrowRight"?(p=h>2&&Math.abs(f)<Math.max(s.height,u.height)/2,d=Math.abs(h)+Math.abs(f)*4):e==="ArrowUp"?(p=f<-2,d=Math.abs(f)*10+Math.abs(h)):e==="ArrowDown"&&(p=f>2,d=Math.abs(f)*10+Math.abs(h)),p&&d<a&&(o=c,a=d)}return o}function Ks(i,t,e=100){let s=dt(t).trim(),n=i.map((o,a)=>({item:o,order:a,score:Po(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=ce(o.item.groupOrder),u=ce(a.item.groupOrder);if(c!==u)return c-u;if(s===""){let h=Us(o.item.pinned,o.order),f=Us(a.item.pinned,a.order);if(h!==f)return h-f}return o.score-a.score||ce(o.item.itemOrder)-ce(a.item.itemOrder)||Bo(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function Po(i,t){if(!t)return i.pinned?-1:0;let e=dt(i.label),s=dt(i.id),n=dt(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)||n.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 Us(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function ce(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function dt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Bo(i,t){let e=dt(i),s=dt(t);if(e<s)return-1;if(e>s)return 1;let n=String(i??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function Ue(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>Ho(t)):[]}function Ho(i){let t={...i,label:String(i.label)};if(i.href==null)return t;let e=be(i.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function Ws(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)})):[]}var Qe=class{#t;#e=[];#i=[];#s;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.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},nt=class i extends y{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:Zo(e),this._entries=new Set,this._queue=new Qe(Ko(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:$o(e.kind??this.options.kind),timeout:Yo(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,s);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}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)We(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Go(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 n=!1;return{update:(r,o)=>{n||s.closed||(e.pct=Wo(r),o!==void 0&&(e.text=String(o)),he(s,e))},done:()=>{n||s.closed||(n=!0,e.pct=100,he(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(e.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(_("error",{size:18})),he(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},_(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Uo(t)?r.append(t):r.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"}},n,r),a={node:o,content:r,iconHost:n,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"}),u=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);r.append(u),a.progressBar=u,a.progressFill=c,he(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,We(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Qo()){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)&&(We(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 $o(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Yo(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Ko(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function Uo(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Wo(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function he(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 We(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Qo(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Zo(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Go(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 At=class extends y{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 n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}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[n,r]of Object.entries(s))this.addField(n,r);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(e instanceof x)n=e;else if(I(e)||e instanceof y){let o=e;n=new x(null,{id:s,type:"custom",label:s,value:Jo(o),disabled:ta(o),adapter:()=>Xo(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new x(null,{...o,id:o.id??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}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,n]of Object.entries(t))this._fields.get(s)?.setValue(n,{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[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),s+=1):r.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 Xo(i){let t=I(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="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 n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function Jo(i){let t=I(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function ta(i){let t=I(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var zt=class extends y{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 At),s=e?new At(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",n=>{let r=n.target,o=r instanceof Element?r.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 n=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:!n&&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,n?l("span",{class:"zx-btn__label"},n):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,n)=>s+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Ze(a))c=this.msg("form.required");else if(!Ze(a)&&o.options.type==="int"){let u=ve(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!Ze(a)&&o.options.type==="float"){let u=we(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=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)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(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 Ze(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function ea(){zs(),Mi(),us(),Zi(),os(),Es(),Ls(),_s(),ds(),Ns(),bs(),ys(),Is(),Ds()}ea();function Q(i,{onError:t,locale:e}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(t!=null&&typeof t!="function")throw new TypeError("onError must be a function");let s=e??ia(i);s&&xe(String(s));let n=(o,a)=>t?t(o,a):nt.error(na(o)),r=async(o,a,c)=>{let u=sa(i,o,a);try{return await i.api[u](c)}catch(h){try{n(h,{operation:u,resource:a})}catch{}throw h}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,c={})=>r("get",o,Qs(a)?a:{ID:a,...c}),create:(o,a)=>r("create",o,a),update:(o,a,c)=>r("update",o,c===void 0&&Qs(a)?a:{ID:a,body:c??{}}),reportError:n}}function ia(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function sa(i,t,e){let s=String(e??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(d=>typeof d=="string"&&d.toLowerCase().startsWith(t)).sort((d,m)=>d.length-m.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(t))return s;let o=Zs(s),a=Gs(o),c=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(t))return!1;let d=Zs(p.slice(t.length));return d===o||d===a||Gs(d)===a});if(c.length)return c.sort((p,d)=>p.length-d.length)[0];let u=t==="list"?[`list${Ge(s)}`]:[`${t}${Ge(ra(s))}`,`${t}${Ge(s)}`],h=new Set(Object.keys(i.api)),f=u.find(p=>h.has(p));if(f)return f;throw new RangeError(`No ${t} operation found for ZeyOS resource "${s}"`)}function Qs(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function na(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function Zs(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Gs(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function ra(i){let t=String(i);return/ies$/i.test(t)?`${t.slice(0,-3)}y`:/s$/i.test(t)&&!/ss$/i.test(t)?t.slice(0,-1):t}function Ge(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var rt=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),Js=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),Dt=Object.freeze({light:"#ffffff",dark:"#141414"}),Ct=Object.create(null);function de(i){let t=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!t)return"default";if(Object.hasOwn(Ct,t)||Object.hasOwn(rt,t))return t;let e=Js[t];return e||"default"}function $(i){let t=de(i);return Ct[t]??rt[t]??rt.default}function oa(i){return $(i).color}function aa(i,{standard:t=!1}={}){let e=$(i);return t?e.fa:e.icon}function la(){return[...new Set([...Object.keys(rt),...Object.keys(Ct)])].sort()}function ca(i){for(let[t,e]of Object.entries(i)){let s=String(t).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof e=="string"?{color:e}:e,r=Ct[s]??rt[s]??rt.default;Ct[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function Je(i){let t=Xe(i);if(t===null)return Dt.light;let e=Xs(t,Xe(Dt.light)??1),s=Xs(t,Xe(Dt.dark)??0);return e>=s?Dt.light:Dt.dark}function Xe(i){let t=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!t)return null;let e=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(e.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function Xs(i,t){return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)}var tn="https://kit.fontawesome.com/ae8320b210.js";function ua(i={}){return Te({kit:tn,...i})}function en(i,t={}){let{standard:e=!1,...s}=t,n=$(i);return _(e?`fa:${n.fa}`:`kit:${n.icon}`,s)}function ft(i,t={}){let{size:e=24,iconSize:s="1em",label:n=null,title:r=!1,standard:o=!1,color:a=null}=t,c=de(i),u=$(i),h=a||u.color,f=l("span",{class:["zx-module-icon",t.class].flat().filter(Boolean),dataset:{module:c},style:{"--zx-module-color":h,"--zx-module-glyph":Je(h),"--zx-module-icon-size":typeof e=="number"?`${e}px`:String(e)},title:r?u.label:null},en(i,{size:s,standard:o}));return n===null?f.setAttribute("aria-hidden","true"):(f.setAttribute("role","img"),f.setAttribute("aria-label",n)),f}var ha=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function sn(i={},t={}){let{standardIcons:e=!1,items:s=[],sources:n=[],...r}=t,o=ei(i.labels),a={standardIcons:e,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},c=nn(i,a),u=typeof i.loadRecent=="function"?[]:fe(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e}),h=[];return typeof i.loadRecent=="function"&&h.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(f,p)=>fe(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),typeof i.search=="function"&&h.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(f,p)=>fe(await i.search(f,p),{query:f,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),h.push(...n),{...r,items:[...c,...u,...s],sources:h,hints:t.hints??{move:o.move,open:o.open,close:o.close}}}function da(i={},t={}){return new ue(null,sn(i,t))}function nn(i={},t={}){let e=ei(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,c=null,u=null)=>{let h=pa(a,c,u);if(!h||n.has(h.identifier)||h.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(h.module))return;n.add(h.identifier);let f=rn(h.raw,i.resolveApplication),p=s.indexOf(h.identifier),d=()=>(typeof t.renderApplicationIcon=="function"?t.renderApplicationIcon(h.raw,h):h.type==="weblet"&&typeof t.renderWebletIcon=="function"?t.renderWebletIcon(h.raw,h):null)??ft(h.module,{size:36,standard:!!t.standardIcons,color:h.color});r.push({id:h.identifier,label:h.label,keywords:[h.identifier,h.module],group:e.applications,groupOrder:0,kind:"application",icon:d,pinned:p>=0?p:void 0,current:h.identifier===i.activeIdentifier,disabled:!f.href&&typeof f.invoke!="function",...f,_zeyos:h})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,$(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,c]of Object.entries(i.modules??{}))o([a,c]);return r}function fe(i,t={}){let e=String(t.query??""),s=ei(t.labels),n=ma(i,e),r=new Map;return n.flatMap(({raw:o,group:a},c)=>{let u=_a(o,a,e);if(!u)return[];let h=e===""?s.recent:u.group===""?s.results:s.entities[u.group]??u.group;r.has(h)||r.set(h,r.size+1);let f=rn(u.raw,t.resolveRecord);return[{id:`record:${u.entity}:${u.fork??""}:${u.ID}`,label:u.name,description:u.sec,keywords:[u.entity,u.ID,u.fork??""],group:h,groupOrder:r.get(h),itemOrder:c,kind:"record",when:e===""?"empty":"query",icon:()=>(typeof t.renderRecordIcon=="function"?t.renderRecordIcon(u.raw,u):null)??ft(u.entity,{size:28,standard:!!t.standardIcons}),disabled:!f.href&&typeof f.invoke!="function",...f,_zeyos:u}]})}function fa(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function pa(i,t,e){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:ti(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:ti(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??t??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??e??$(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:ti(i.color)}}function ma(i,t){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let e=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){e.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};e.push({raw:o,group:s})}return e}function _a(i,t,e){return Array.isArray(i)?e===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??t??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??t??"")}}function rn(i,t){let e=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof t=="function"?t(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??e[r];return o===void 0?[]:[[r,o]]}))}function ti(i){let t=String(i??"").trim();if(!t)return null;let e=t.startsWith("#")?t:`#${t}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(e)?e:null}function ei(i){let t=i&&typeof i=="object"?i:{};return{applications:String(t.applications??"Applications"),recent:String(t.recent??"Recent"),results:String(t.results??"Top results"),entities:t.entities&&typeof t.entities=="object"?t.entities:{},move:String(t.move??"Move"),open:String(t.open??"Open"),close:String(t.close??"Close")}}function It(i,t,e={}){let{fields:s,labelKey:n=un(i,t),valueKey:r="ID",searchFields:o=hn(i,t),limit:a=50,filters:c={},value:u=null,...h}=e,f=Q(i),p=s??cn(r,n,o);return{...h,valueKey:r,labelKey:n,value:u,filter:async d=>{let m=await f.list(t,ot({search:d,filters:c,fields:p,searchFields:o,limit:a}));return ii(i,m).data}}}function ga(i,t,e={}){let s=It(i,t,e),n=e.value??null,r=new M(null,s);return r.ready=ln(r,i,t,n),r}function an(i,t,e={}){let{fields:s,labelKey:n=un(i,t),valueKey:r="ID",searchFields:o=hn(i,t),subtitleKey:a=null,moduleKey:c=()=>t,groupKey:u=null,none:h=!0,create:f=!1,renderIcon:p=xa,renderItem:d,renderValueAdornment:m,...g}=e,b=s??cn(r,n,[...o,...[a,c,u].filter(A=>typeof A=="string")]),k=It(i,t,{...g,fields:b,labelKey:n,valueKey:r,searchFields:o,groupKey:u,clearable:h===!1?!!g.clearable:!0}),T=(A,N=!1)=>{if(p===null)return null;let Y=pe(A,c)??t;return p(A,{resource:t,module:String(Y),selected:N})};if(k.renderItem=d??(A=>{let N=T(A);return l("span",{class:"zx-select__entity"},N?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},N):null,l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(pe(A,n)??"")),a&&pe(A,a)!=null?l("span",{class:"zx-select__entity-subtitle"},String(pe(A,a))):null))}),k.renderValueAdornment=m??(A=>T(A,!0)),h!==!1&&(k.noneLabel=typeof h=="string"?h:g.noneLabel??"No selection",k.renderNone=g.renderNone??(A=>l("span",{class:"zx-select__entity-none"},l("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),l("span",{},A)))),f){let A=f===!0?{}:f,N=typeof A.oninvoke=="function"?A.oninvoke:null;k.actions=[...Array.isArray(k.actions)?k.actions:[],{id:A.id??"create",label:A.label??"Create new\u2026",group:A.group??"New",icon:A.icon??"plus",invoke:Y=>N?.({...Y,resource:t})}]}return k}function ba(i,t,e={}){let s=an(i,t,e),n=e.value??null,r=new M(null,s);return r.ready=ln(r,i,t,n),r}function ii(i,t){return typeof i?.normalizeListResult=="function"?on(i.normalizeListResult(t)):on(t)}function on(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let t=Array.isArray(i.data)?i.data:[],e=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(e)?{data:t,count:e}:{data:t}}async function ln(i,t,e,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await Q(t).get(e,s),r=ya(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function ya(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS get operation did not return a record")}function pe(i,t){return typeof t=="function"?t(i):i&&typeof i=="object"&&typeof t=="string"?i[t]:null}function xa(i,t){let e=ft(String(t.module??"default"),{size:20});return e.replaceChildren(_("square",{size:10})),e}function cn(i,t,e){let s=[i,t,...e].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function un(i,t){let e=va(i,t);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(e.includes(s))return s;return e[0]??"ID"}function hn(i,t){let e=i?.schema?.describe?.(t)?.fields;return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function va(i,t){let e=i?.schema?.fields?.(t);if(Array.isArray(e))return e.map(String);if(e&&typeof e=="object")return Object.keys(e);let s=i?.schema?.describe?.(t)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function wa(i,t,e={}){let s=mt(i,t,e),n={},r=[];for(let o of s){let a=Et(o),c=a.type==="zxselect"&&typeof a.props?.entity=="string"?a.props.entity:null;c&&(r.push({id:String(o.id),resource:c}),a.props={...It(i,c,{clearable:!a.required,placeholder:`Select ${String(a.label).toLowerCase()}`})}),n[String(o.id)]=a}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(e.title??""),columns:Ca(e.columns),fields:n}]},mapFromRecord:o=>Sa(o,s),mapToRecord:o=>Aa(o,s)}}function ka(i,t,e={}){if(e.onSaved!=null&&typeof e.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=wa(i,t,e),n=Q(i),r=new zt(null,s.formOptions),o=e.value?.ID??e.id??null,a=!1,c=null,u=async d=>{if(!d||typeof d!="object"||Array.isArray(d))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(s.entityFields.map(async({id:m,resource:g})=>{let b=d[m];if(b==null)return;let k=b&&typeof b=="object"?b:si(await n.get(g,b)),T=M.from(r.getField(m)?.getInput());T instanceof M&&T.setItems([k])})),a||r.setValues(s.mapFromRecord(d),{silent:!0}),d},h=async d=>{if(d==null||d==="")throw new TypeError("zeyosForm.load() requires an id");let m=si(await n.get(t,d));return o=m.ID??d,await u(m),m},f=()=>a?Promise.reject(new Error("Cannot save a destroyed ZeyOS form")):c||(r.submit()?(c=(async()=>{let d;try{d=s.mapToRecord(r.getValues()),delete d.ID}catch(b){throw n.reportError(b,{operation:"serialize",resource:t}),b}let m=o==null?await n.create(t,d):await n.update(t,{ID:o,...d}),g=si(m);if(o=g.ID??o,e.onSaved)try{await e.onSaved(g)}catch(b){throw n.reportError(b,{operation:"onSaved",resource:t}),b}return nt.success(`${Ia(g,t)} saved successfully.`),g})().finally(()=>{c=null}),c):Promise.resolve(null)),p=Object.prototype.hasOwnProperty.call(e,"id")?h(e.id):e.value?u(e.value):Promise.resolve(null);return{form:r,ready:p,load:h,save:f,getForm:()=>r,destroy(){a||(a=!0,r.destroy())}}}function Sa(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];e[n]=dn(s)&&r!=null&&r!==""?pt(r):r}return e}function Aa(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];if(dn(s))r=r==null||r===""?null:Z(r);else if(za(s)&&Da(s.type)&&r!==""&&r!=null){let o=Number(r);Number.isFinite(o)&&(r=o)}e[n]=r}return e}function dn(i){let t=Et(i);return t.type==="date"||t.type==="datetime"}function za(i){return i.enums!=null||i.enum!=null}function Da(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Ca(i){let t=Number(i??2);return[1,2,3].includes(t)?t:2}function si(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS operation did not return a record")}function Ia(i,t){for(let e of["transactionnum","name","lastname","customernum","number","ID"])if(i[e]!=null&&i[e]!=="")return String(i[e]);return String(t)}function Ma(i,t,e={}){let s=mt(i,t,{fields:e.fields,labels:e.labels}),n={},r=s.map(a=>{let c={...a},u=Ea(c);if(u){let p=Na(i,u);c.labelField=`${c.id}_label`,n[c.labelField]=`${c.id}.${p}`}n[c.id]=c.id;let h=Fa(c),f=me(h?{...c,format:"money"}:c);return h&&(f.render=p=>La(p?.[c.id],p?.currency),Oa(i,t,"currency")&&(n.currency="currency")),f}),o=e.rowId??"ID";return typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o),{fieldMeta:s,columns:r,projection:n,tableOptions:{columns:r,data:[],rowId:o,sort:e.sort??null,sortMode:"server",selectable:e.selectable??!1,height:e.height??null,onrowclick:typeof e.onRowClick=="function"?a=>e.onRowClick(a.detail.row,a):void 0}}}function Ta(i,t,e={}){let s=Ma(i,t,e),n=Q(i),r=new St(null,s.tableOptions),o=Ra(e.pageSize),a=e.sort??null,c=fn(e.filters??{}),u=String(e.search??""),h=0,f=null,p=!1,d=0,m=async(b={})=>{Object.prototype.hasOwnProperty.call(b,"search")&&(u=String(b.search??"")),Object.prototype.hasOwnProperty.call(b,"filters")&&(c=fn(b.filters??{}));let k=ja(b.page??0),T=ot({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:k*o,count:!0}),A=++d;r.setLoading(!0);try{let N=ii(i,await n.list(t,T)),Y=N.count??null,ni=Y==null?N.data.length===o:k*o+N.data.length<Y;return A===d&&(h=k,f=Y,p=ni,k===0?r.setData(N.data):r.addData(N.data)),{data:N.data,count:Y,page:k,hasMore:ni,query:T}}finally{A===d&&r.setLoading(!1)}},g={table:r,load:m,setSearch:b=>m({search:b,page:0}),setFilters:b=>m({filters:b,page:0}),loadMore:()=>p?m({page:h+1}):Promise.resolve({data:[],count:f,page:h,hasMore:!1,query:ot({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:h*o,count:!0})}),get count(){return f},get page(){return h},get hasMore(){return p},destroy:()=>r.destroy()};return r.on("sort",b=>{a={id:String(b.detail.id),dir:b.detail.dir==="desc"?"desc":"asc"},m({page:0}).catch(()=>{})}),g}function Ea(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Na(i,t){let e=i?.schema?.fields?.(t),s=Array.isArray(e)?e.map(String):Object.keys(e??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Fa(i){let t=String(i.format??"").toLowerCase();return/money|currency|price/.test(t)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function La(i,t){if(i==null||i==="")return"";let e=Number(i);if(!Number.isFinite(e))return"";let s=typeof t=="string"&&/^[A-Z]{3}$/.test(t)?t:null;try{return new Intl.NumberFormat(void 0,s?{style:"currency",currency:s}:{}).format(e)}catch{return new Intl.NumberFormat().format(e)}}function Oa(i,t,e){let s=i?.schema?.fields?.(t);return Array.isArray(s)?s.includes(e):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,e))}function Ra(i){let t=Number(i??50);return Number.isInteger(t)&&t>0?t:50}function ja(i){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError("ZeyOS table page must be a non-negative integer");return t}function fn(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS table filters must be an object");return{...i}}export{tn as ZEYOS_ICON_KIT,ha as ZEYOS_LAUNCHER_APPLICATIONS,ot as buildListQuery,an as buildZeyosEntitySelectConfig,sn as buildZeyosLauncherConfig,It as buildZeyosSelectConfig,Q as connect,pn as dataFilterStateToFilters,Z as dateToUnixSeconds,me as fieldToZxColumn,Et as fieldToZxField,Js as moduleAliases,ft as moduleChip,oa as moduleColor,Je as moduleGlyphColor,en as moduleIcon,aa as moduleIconName,$ as moduleInfo,la as moduleKeys,de as normalizeModuleName,nn as normalizeZeyosLauncherApplications,fe as normalizeZeyosLauncherRecords,C as registerFieldType,ca as registerModules,mt as resolveFields,ri as tableSortToQuery,pt as unixSecondsToDate,ua as useZeyosIcons,fa as zeyosActiveIdentifier,ba as zeyosEntitySelect,ka as zeyosForm,da as zeyosLauncher,rt as zeyosModules,ga as zeyosSelect,Ta as zeyosTable};
|
|
1
|
+
function J(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let t=i.getTime();if(!Number.isFinite(t))throw new RangeError("Invalid Date");return Math.floor(t/1e3)}function yt(i){if(i==null)return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");return new Date(t*1e3)}function fi(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(e=>{if(!e||typeof e!="object")return[];let s=e.rawField??e.field??e.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${e.dir==="desc"?"-":"+"}${n}`]})}function An(i,t=[]){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let e=zn(i,t),s={},n=0;for(let r of e){if(!r.id||!Object.prototype.hasOwnProperty.call(i,r.id))continue;let o=i[r.id];if(o===void 0||o===null&&r.includeNull!==!0||typeof o=="string"&&o.trim()===""&&r.includeEmpty!==!0)continue;if(typeof r.toFilter=="function"){let h=r.toFilter(o,i);h&&typeof h=="object"&&!Array.isArray(h)&&Object.assign(s,h);continue}let a=typeof r.transform=="function"?r.transform(o,i):Cn(o,r);if(a===void 0)continue;r.operator&&(a={[r.operator]:a});let c=Array.isArray(r.fields)?r.fields.filter(h=>typeof h=="string"&&h):[];if(c.length>1){for(;Object.prototype.hasOwnProperty.call(s,String(n));)n+=1;s[String(n)]=["OR",...c.map(h=>({[h]:a}))],n+=1;continue}let u=c[0]??r.rawField??r.field??r.id;typeof u=="string"&&u&&(s[u]=a)}return s}function ut(i={}){let{fields:t,sort:e,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:c=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(t)?u.fields=[...t]:t&&typeof t=="object"&&(u.fields={...t});let h={...s},d=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(d||!Object.prototype.hasOwnProperty.call(h,"visibility"))&&(h.visibility=a),Object.keys(h).length&&(u.filters=h);let p=Dn(e,t),f=fi(p);return f.length&&(u.sort=f),n!=null&&String(n).trim()&&(u.query=String(n).trim()),r!=null&&(u.limit=r),o!=null&&(u.offset=o),c&&(u.count=!0),u}function zn(i,t){return Array.isArray(t)&&t.length?t.map(e=>({...e})):t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length?Object.entries(t).map(([e,s])=>typeof s=="string"?{id:e,field:s}:{...s,id:e}):Object.keys(i).map(e=>({id:e,field:e}))}function Cn(i,t){let e=String(t.format??t.type??"").toLowerCase();return i instanceof Date&&["date","datetime","date-time"].includes(e)?J(i):Array.isArray(i)&&["date","datetime","date-time"].includes(e)?i.map(s=>s instanceof Date?J(s):s):i}function Dn(i,t){if(!i||!t||Array.isArray(t)||typeof t!="object")return i;let e=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(t,n)?s:{...s,rawField:t[n]}};return Array.isArray(i)?i.map(e):e(i)}var Lt=Object.create(null),pi=new Set;function E(i,t){let e=Ft(i);if(!e)throw new TypeError("ZeyOS field type must not be empty");if(!t||typeof t!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=t[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Lt[e]=t,t}function Ot(i){let t=yi(i),e=bi(t),s=xi(e.field,t),n={id:t.id,type:"text",label:vi(t),...s};return t.description!=null&&(n.description=String(t.description)),(t.required===!0||t.nullable===!1)&&(n.required=!0),Pn(t)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function Se(i){let t=yi(i),e=bi(t);return{id:t.id,label:vi(t),sortable:t.sortable!==!1,...xi(e.column,t)}}function xt(i,t,e={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(t),r=mi(n?.fields),o=mi(s.fields(t)),a=new Map;for(let[p,f]of o)a.set(p,{...f,...r.get(p)??{}});for(let[p,f]of r)a.has(p)||a.set(p,{...f});let c=Array.isArray(e.fields)?e.fields.map(String):[...a.keys()],u=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),h=e.labels&&typeof e.labels=="object"?e.labels:{},d=[];for(let p of c){if(u.has(p)||!a.has(p))continue;let f=a.get(p)??{},m={...f,id:p,name:p,resource:String(t)},g=f.enums??f.enum??Bn(s,t,p);g!=null&&(m.enums=g,m.enum==null&&(m.enum=g)),Object.prototype.hasOwnProperty.call(h,p)&&(m.label=String(h[p])),d.push(m)}return d}var _i={field:{type:"text"},column:{}},In={field:{type:"int"},column:{align:"right"}},Mn={field:{type:"float"},column:i=>({align:"right",render:Ai(i)})},Tn={field:{type:"float"},column:i=>({align:"right",render:Ai(i,!0)})},En={field:i=>({type:"zxselect",props:{entity:wi(i)}}),column:i=>({render:t=>Qn($(t,i),t,i)})},Nn={field:{type:"toggle"},column:i=>({align:"center",render:t=>$(t,i)?"\u2713":"",sortValue:t=>+!!$(t,i)})},Fn={field:i=>({type:$n(i),options:Ae(i)}),column:i=>({render:Si(i)})},Ln={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:Si(i,Kn())})},On={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:t=>Yn($(t,i)),sortValue:t=>Rt($(t,i))})},Rn=gi("date"),jn=gi("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])E(i,_i);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])E(i,In);for(let i of["number","numeric","decimal","real","double","double precision","float"])E(i,Mn);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])E(i,Tn);for(let i of["entity","t_entity"])E(i,En);for(let i of["boolean","checked"])E(i,Nn);for(let i of["list","enum"])E(i,Fn);for(let i of["progress","percent"])E(i,On);for(let i of["date"])E(i,Rn);for(let i of["datetime","date-time"])E(i,jn);E("priority",Ln);E("text[]",{field:{type:"valuelist"},column:{}});E("json",{field:{type:"textarea"},column:{}});E("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])E(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function gi(i){return{field:{type:i},column:t=>({render:e=>Un($(e,t),i==="datetime"),sortValue:e=>Wn($(e,t))})}}function bi(i){let t=qn(i),e=Lt[t];return e||(pi.has(t)||(pi.add(t),console.warn(`[zx.zeyos] Unknown field type or format "${t||"unknown"}" for "${i.id}"; using text.`)),_i)}function qn(i){let t=Ft(i.format??i.semanticFormat??i.semanticType??i.widget);if(t&&Lt[t])return t;if(wi(i)||Ft(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let e=Ft(i.type);if(e==="bigint"||e==="int64"){let s=String(i.id).toLowerCase();if(s==="date"&&i.indexed)return"date";if(/(?:date|time)$/.test(s))return"datetime"}return Hn(i,e)?"longtext":e&&Lt[e]?e:e.endsWith("[]")?"text[]":e==="json"||e==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(e)?"character varying":e||t}function yi(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let t=i.id??i.name??i.field??i.identifier??i.reference;if(t==null||String(t).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(t)}}function xi(i,t){let e=typeof i=="function"?i(t):i;return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function Ft(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function vi(i){let t=i.label??i.title??i.displayName;return t==null||t===""?Vn(i.id):String(t)}function Vn(i){let t=String(i??"").split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Pn(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Hn(i,t){if(i.long===!0||i.multiline===!0)return!0;let e=Number(i.maxLength??t.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(e)&&e>255}function wi(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function mi(i){let t=new Map;if(Array.isArray(i)){for(let e of i)if(typeof e=="string")t.set(e,{});else if(e&&typeof e=="object"){let s=e.id??e.name??e.field;s!=null&&t.set(String(s),{...e})}}else if(i&&typeof i=="object")for(let[e,s]of Object.entries(i))t.set(e,s&&typeof s=="object"?{...s}:{});return t}function Bn(i,t,e){if(typeof i.enums!="function")return null;let s=i.enums(t,e);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,e)?s[e]:s??null}function Ae(i){return ki(i.enums??i.enum??i.options)}function ki(i){if(typeof i=="string")try{return ki(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((t,e)=>{if(Array.isArray(t)){let[s=e,n=s]=t;return[String(s),String(n)]}if(t&&typeof t=="object"){let s=t.value??t.id??e;return[String(s),String(t.label??t.name??s)]}return[String(e),String(t)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([t,e])=>[t,String(e)])):{}}function $n(i){return Object.keys(Ae(i)).length<=5?"optionlist":"select"}function Kn(){return{0:"LOWEST",1:"LOW",2:"MEDIUM",3:"HIGH",4:"HIGHEST"}}function Si(i,t={}){let e={...t,...Ae(i)};return s=>{let n=$(s,i);return n==null?"":e[String(n)]??String(n)}}function Ai(i,t=!1){let e;try{e=new Intl.NumberFormat(i.locale,t&&i.currency?{style:"currency",currency:String(i.currency)}:{})}catch{e=new Intl.NumberFormat}return s=>{let n=Rt($(s,i));return n==null?"":e.format(n)}}function Rt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?t:null}function Yn(i){let t=Rt(i);return t==null?"":`${new Intl.NumberFormat().format(t)}%`}function Un(i,t){if(i==null||i==="")return"";try{let e=i instanceof Date?i:yt(i);return!e||!Number.isFinite(e.getTime())?"":new Intl.DateTimeFormat(void 0,t?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(e)}catch{return""}}function Wn(i){return i instanceof Date?J(i):Rt(i)}function $(i,t){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,t.id))return i[t.id];let e=String(t.path??t.field??t.id).split("."),s=i;for(let n of e){if(!s||typeof s!="object")return;s=s[n]}return s}function Qn(i,t,e){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=e.labelField;if(typeof s=="string"&&t[s]!=null)return String(t[s]);for(let n of[`${e.id}.name`,`${e.id}_label`,`${e.id}Label`])if(t[n]!=null)return String(t[n]);return i==null?"":String(i)}var zi=0;function w(i="zx"){return zi+=1,`${i}-${Date.now().toString(36)}-${zi.toString(36)}`}function qt(i,t){let e=vt(i)?Ci(i):{};if(!vt(t))return jt(t);for(let[s,n]of Object.entries(t))vt(n)&&vt(e[s])?e[s]=qt(e[s],n):e[s]=jt(n);return e}function N(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function W(i){if(typeof i!="string")return!1;let t=i.trim();if(!t||t.length>256||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(t))return!1;let e=globalThis.CSS?.supports;if(typeof e=="function")try{return e.call(globalThis.CSS,"color",t)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(t)}function wt(i,t,e){return Math.min(e,Math.max(t,i))}function ze(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vt(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function Ci(i){let t={};for(let[e,s]of Object.entries(i))t[e]=jt(s);return t}function jt(i){return vt(i)?Ci(i):Array.isArray(i)?i.map(jt):i}var kt=null;function Ce(i){if(typeof i!="string")return null;let t=i.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function l(i,t,...e){let s=document.createElement(i),n=t;Zn(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Gn(s,r,o);return Jn(s,e),s}l.scope=function(t,e){let s=kt;kt=t;try{return e()}finally{kt=s}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function L(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function O(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 De(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 Zn(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 Gn(i,t,e){if(t==="ref"){kt&&typeof e=="string"&&(kt[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[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Xn(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 Xn(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Jn(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 n=s;if(typeof n.nodeType=="number")e.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}var Di=null,Ii="en";function Ie(i){Ii=String(i||"en")}function K(){return Ii}function P(i,t){let e=Di?Di(i):i;return j(e==null?i:String(e),t)}function j(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,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),s}var Vt=new WeakMap,y=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let n=De(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=tr(s,e),o=[];for(let[u,h]of Object.entries(r))/^on[a-z]/.test(u)&&typeof h=="function"&&(o.push([u.slice(2),h]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,h]of o)this.on(u,h);let a;try{a=l.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=N(a)?a:this.el;if(!N(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}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 u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Vt.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=Mi(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(Mi(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,s,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,n=this.options.lang??this.options.language??K(),r=s?.[n]?.[t];if(r!=null)return j(String(r),e);let o=s?.[t];return o!=null?j(String(o),e):P(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Vt.get(this.el)===this&&Vt.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Vt.get(t)??null}};function tr(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 n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=qt(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=qt(r,t.msg)),o&&(n.msg=r),n}function Mi(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 x=class i extends y{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=nr(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):w("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,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"}),u=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),h=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=l("div",{class:"zx-field__body"},c,u,h);this._ownedNodes.push(a,d),t.append(a,d);let p=i.#t.get(e);if(p)try{this.adapter=ir(p(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${g}`),this.adapter=Ei(g,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=Ei(m,this.controlId)}let f=this.adapter.el;return f.id||(f.id=this.controlId),a.htmlFor=f.id,sr(f)||f.setAttribute("aria-labelledby",n),this._baseDescribedBy=f.getAttribute("aria-describedby")??"",c.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=h,this._syncDescription(),this.initialValue=er(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 y))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();rr(this.el,this._rootAttributes??new Map),super.destroy()}};function Me(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=Fi(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Te(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=Fi(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function Fi(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 n=[...s.matchAll(/\./g)].map(c=>c.index),r=[...s.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",u=c==="."?",":".",h=s.lastIndexOf(c),d=s.slice(0,h),p=s.slice(h+1);if(!/^\d+$/.test(p)||!Ti(d,u))return null;o=d.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!Ti(s,c))return null;o=s.split(c).join("")}else r.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 Ti(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 er(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function ir(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 Ei(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 sr(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function nr(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function rr(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function St(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 Pt(i,t){return(e,s)=>{let n=l(i,St(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return Ee(n)}}function Ee(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function Li(i){return(t,e)=>{let s=i==="int"?Me:Te,n=l("input",St(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...Ee(n),get:()=>s(n.value).value}}}var or=(i,t)=>{let e=l("input",St(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}}},ar=(i,t)=>{let e=l("select",St(t,{required:t.required,disabled:t.disabled}));for(let[s,n]of Oi(t.options))e.append(l("option",{value:s},n));return Ee(e)},lr=(i,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):w("zx-option-list"),n=Oi(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:s,value:r,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:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},cr=(i,t)=>{let e=l("div",St(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:r=>{Ni(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>Ni(s)}};function Ni(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var ur=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function Oi(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)]):[]}x.register("text",Pt("input","text"));x.register("password",Pt("input","password"));x.register("textarea",Pt("textarea","text"));x.register("checkbox",or);x.register("int",Li("int"));x.register("float",Li("float"));x.register("select",ar);x.register("optionlist",lr);x.register("hidden",Pt("input","hidden"));x.register("html",cr);x.register("custom",ur);function Q(i,t,e){let s=Ri(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=hr(n,e).map(Ri);return s.every(o=>r.some(a=>a.includes(o)))})}function hr(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 Ri(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Ht=class extends y{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=w("zx-checklist-label"),s=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=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}),r=l("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"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 u=this._itemValue(c);a.checked?this._checked.add(u):this._checked.delete(u),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(n=>this._itemValue(n)).filter(n=>e.has(n)));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=Q(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=Q(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let n=w("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return l("label",{class:"zx-checklist__item",for:n},r,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){dr(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 dr(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function ji(){x.register("checklist",(i,t)=>{let e=i.own(new Ht(null,{...t.props??{}})),s=!1,n=!1,r=()=>{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=>{n||i.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,r()}}})}var qi=["January","February","March","April","May","June","July","August","September","October","November","December"],Vi=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Bi=/%[demYyHMSaAbBs]/g;function S(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Bi,e=>{switch(e){case"%d":return ht(i.getDate());case"%e":return String(i.getDate());case"%m":return ht(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return ht(i.getFullYear()%100);case"%H":return ht(i.getHours());case"%M":return ht(i.getMinutes());case"%S":return ht(i.getSeconds());case"%a":return Pi("weekday",i.getDay(),Vi[i.getDay()]);case"%A":return Ne("weekday",i.getDay(),Vi[i.getDay()]);case"%b":return Pi("month",i.getMonth(),qi[i.getMonth()]);case"%B":return Ne("month",i.getMonth(),qi[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function H(i,t){let e=[],s="^",n=0;for(let m of String(t).matchAll(Bi)){s+=Hi(String(t).slice(n,m.index));let g=m[0],b=fr(g);if(b===null)return null;s+=`(${b})`,e.push(g),n=m.index+g.length}s+=Hi(String(t).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(e.forEach((m,g)=>{o[m]=Number(r[g+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,g=new Date(m);return Number.isNaN(g.getTime())?null:g}let a=o["%Y"]??pr(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,h=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,u),f.setHours(h,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()!==u||o["%e"]!==void 0&&f.getDate()!==u||o["%H"]!==void 0&&f.getHours()!==h||o["%M"]!==void 0&&f.getMinutes()!==d||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function $i(i,t,e){let s=i.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function M(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function C(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function tt(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,n)),e}function Bt(i=K()){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 ht(i){return String(i).padStart(2,"0")}function Ne(i,t,e){let s=`date.${i}.${t}`,n=P(s);return n===s?e:n}function Pi(i,t,e){let s=`date.${i}.short.${t}`,n=P(s);return n!==s?n:Ne(i,t,e).slice(0,3)}function fr(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 pr(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Hi(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ki=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),mr=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Yi=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"}),_r=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"}),Fe=new Map;function Ui(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(),n=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Yi,s))return{provider:"fa",name:n,style:Yi[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Le(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(i).replace(/^fa-/,""),a=r?_r[o]??o:o,c=[],u=mr[s];return u&&c.push(u),c.push(Ki[e]??Ki.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Oe(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 Wi(i){let t=Oe(i),e=Fe.get(t);if(e)return e;let s=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Fe.delete(t),r(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 Fe.set(t,s),s}var Qi="http://www.w3.org/2000/svg",Gi=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"]}),gr=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),br=Object.create(null),Y={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function je(){return{...Y}}function qe(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(Y[t]=i[t]);return je()}function Xi(i={}){return qe({...i,provider:"fontawesome"})}async function Ve(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return qe({...n,kit:Oe(e)}),await Wi(e),s?Xi():je()}function _(i,t={}){let e=Ui(i);if(e.classes)return Re(e.classes,t);let s=gr[e.name]??e.name;return e.provider==="builtin"?Zi(s,t):e.provider==="fa"?Re(Le(s,{style:e.style??t.style??Y.style,family:t.family??Y.family,fixedWidth:t.fixedWidth??Y.fixedWidth}),t):Y.provider==="fontawesome"?Re(Le(s,{style:t.style??Y.style,family:t.family??Y.family,fixedWidth:t.fixedWidth??Y.fixedWidth}),t):Zi(s,t)}function Zi(i,t){let e=br[i]??Gi[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,n]=e,{size:r=16}=t,o=document.createElementNS(Qi,"svg"),a=document.createElementNS(Qi,"path");return o.setAttribute("class",ts("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(r)),o.setAttribute("height",String(r)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Ji(o,t.label??null),a.setAttribute("d",n),o.append(a),o}function Re(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=ts("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),Ji(s,t.label??null),s}function Ji(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function ts(...i){return i.flat().filter(Boolean).join(" ")}var yr=5,$t=class extends y{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=es(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 n=w("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:n},_("clock",{size:15}))),this._clock=this._buildClock(n),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=es(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,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?kr(this.options.step):1,o=dt(t.currentTarget.value,0,s),a=s+1,c=(o+n*r+a*r)%a;t.currentTarget.value=et(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=et(dt(t.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;t[n]=dt(s.value,0,r)}let e=!this._value||!Sr(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=et(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 n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.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"),n=e.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+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=et(this._display.h),this.refs.headMinute.textContent=et(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?xr():vr(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)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(n[c],a,e));let r=t&&!wr(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,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 n=e.value===s;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}};function xr(){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:et(e),angle:t*30,ring:"inner"})}return i}function vr(){let i=[];for(let t=0;t<60;t+=yr)i.push({value:t,label:et(t),angle:t*6,ring:"outer"});return i}function wr(i){return i>=1&&i<=12}function es(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:dt(i.h,0,23),m:dt(i.m,0,59),s:dt(i.s,0,59)}}function dt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function kr(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function et(i){return String(i).padStart(2,"0")}function Sr(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var ft=class extends y{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=q(Kt(this.options.min)),this._max=q(Kt(this.options.max)),this._value=this._normalizeValue(Kt(this.options.value)),this._focused=q(this._value)??this._clampFocus(q(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Ar(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 $t(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Pe(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(Kt(t));return this._value=s,s&&(this._focused=q(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Pe(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=q(e);return this._min&&s<this._min&&is(e,this._min),this._max&&s>this._max&&is(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 n=C(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:S(n,"%A")},S(n,"%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=C(t,-e);this.refs.heading.textContent=S(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${S(t,"%B %Y")}`);let n=[];for(let r=0;r<6;r+=1){let o=C(s,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${ss(o)}`},String(ss(o))));for(let c=0;c<7;c+=1){let u=C(o,c),h=!!(this._value&&M(u,this._value)),d=!this._inRange(u),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:M(u,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(d),ariaCurrent:M(u,new Date)?"date":null,ariaLabel:`${S(u,"%e")} ${S(u,"%B %Y")}`,dataset:{date:S(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},S(u,"%e"));a.append(l("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=H(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=H(e.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(t.key==="ArrowLeft")n=C(s,-1);else if(t.key==="ArrowRight")n=C(s,1);else if(t.key==="ArrowUp")n=C(s,-7);else if(t.key==="ArrowDown")n=C(s,7);else if(t.key==="PageUp")n=tt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=tt(s,t.shiftKey?12:1);else if(t.key==="Home")n=C(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=C(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=q(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 n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=q(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Pe(e)})}_pageMonth(t){this._closeQuickPick();let e=tt(this._focused,t);this._focused=q(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}},S(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),n=null;if(t.key==="ArrowLeft")n=s-1;else if(t.key==="ArrowRight")n=s+1;else if(t.key==="ArrowUp")n=s-3;else if(t.key==="ArrowDown")n=s+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=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(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.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=q(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=q(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${S(t,"%Y-%m-%d")}"]`)}};function Kt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function q(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Pe(i){return i?new Date(i.getTime()):null}function is(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function Ar(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Bt()}function ss(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 Wt=class extends ft{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=Ut(Yt(this.options.min)),this._max=Ut(Yt(this.options.max)),this._value=this._normalizeMonth(Yt(this.options.value));let e=this._value??Ut(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",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(Yt(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=Ut(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),n=!!(this._value&&zr(s,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:S(s,"%B %Y"),dataset:{month:e}},S(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),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(s%3);else if(t.key==="End")n=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(n===null)return;t.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%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 Yt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Ut(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function zr(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function ns(){x.register("month",(i,t)=>{let e=i.own(new Wt(null,{...t.props??{},value:t.value})),s=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let r of e.el.querySelectorAll("button"))r.disabled=s};return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>i.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{s=!!r,n()}}})}var Cr=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function Z(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Cr.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=i.getAttribute("style"),c=t.getAttribute("style"),u=t.getAttribute("popover"),h=!1,d=null,p=()=>{},f=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let g=`--${w("zx-a")}`;i.style.setProperty("anchor-name",g),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",g);let b=Dr(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",b),t.style.setProperty("inset-area",b),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let z=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(z,`${n}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=()=>Ir(i,t,{placement:s,offset:n,flip:r,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 Mr(t),p(),{update(){h||p()},destroy(){h||(h=!0,d?.disconnect(),f(),Tr(t),He(i,"style",a),He(t,"style",c),He(t,"popover",u))}}}function Dr(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 Ir(i,t,{placement:e,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,h=e,d=rs(e),p=o.bottom+s,f=o.top-s-a.height,m=o.right+s,g=o.left-s-a.width;n&&(d==="bottom"&&p+a.height>u&&f>=0?h=Qt(e,"bottom","top"):d==="top"&&f<0&&p+a.height<=u?h=Qt(e,"top","bottom"):d==="right"&&m+a.width>c&&g>=0?h=Qt(e,"right","left"):d==="left"&&g<0&&m+a.width<=c&&(h=Qt(e,"left","right")));let b=rs(h),z,k;if(b==="bottom"||b==="top"){let T=getComputedStyle(i).direction==="rtl";h.endsWith("-end")?z=T?o.left:o.right-a.width:h.endsWith("-start")?z=T?o.right-a.width:o.left:z=o.left+(o.width-a.width)/2,k=b==="bottom"?p:f}else z=b==="right"?m:g,h.endsWith("-end")?k=o.bottom-a.height:h.endsWith("-start")?k=o.top:k=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(wt(z,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(wt(k,0,Math.max(0,u-a.height)))}px`}function rs(i){return i.split("-")[0]}function Qt(i,t,e){return i.replace(t,e)}function Mr(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Tr(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function He(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Er=6,hs=864e5;function At(i,t){let e=R(it(i)),s=R(it(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function Zt(i,t){let e=At(i,t);return!e.start||!e.end?0:Math.round((ls(e.end)-ls(e.start))/hs)}function Nr(i,t,e){let s=R(it(i));if(!s)return null;let n=At(t,e);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:M(s,n.start)?"start":M(s,n.end)?"end":"middle":M(s,n.end)?"end":null:M(s,n.start)?"start":null}function Gt(i,t={}){let e=R(it(t.min)),s=R(it(t.max)),n=Jt(t.minNights)??0,r=Jt(t.maxNights),{start:o,end:a}=At(i?.start,i?.end);return o&&(o=$e(o,e,s)),a&&(a=$e(a,e,s)),!o||!a?{start:o,end:a}:(r!==null&&Zt(o,a)>r&&(a=C(o,r)),n>0&&Zt(o,a)<n&&(a=C(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=C(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Xt=class extends y{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=Vr(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=R(it(this.options.min)),this._max=R(it(this.options.max)),this._minNights=Jt(this.options.minNights)??0,this._maxNights=Jt(this.options.maxNights),this._weekStart=Rr(this.options.weekStart),this._monthCount=jr(this.options.months),this._presets=Or(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Gt({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=G(this._start)??this._clampFocus(R(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",D("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:D("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],t.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:G(this._start),end:G(this._end)}}set(t={},{silent:e=!1}={}){let s=Gt({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=G(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=[],Pr(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=R(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=Zt(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=R(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?G(this._start):null,this._committedEnd=t?G(this._end):null}_abandon(){return this._picking?(this._start=G(this._committedStart),this._end=G(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return $e(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=cs(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let n=s<0?s:s-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.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=cs(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=R(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(r=>r.name===e.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.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 n=this._cellFor(e);n&&this._choose(n.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?R(t):null;!e&&!this._hover||e&&this._hover&&M(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,n=null;if(t.key==="ArrowLeft")n=C(s,-1);else if(t.key==="ArrowRight")n=C(s,1);else if(t.key==="ArrowUp")n=C(s,-7);else if(t.key==="ArrowDown")n=C(s,7);else if(t.key==="PageUp")n=tt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=tt(s,t.shiftKey?12:1);else if(t.key==="Home")n=C(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=C(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}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_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=S(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,n=C(t,-s),r=[];for(let o=0;o<Er;o+=1){let a=C(n,o*7),c=l("tr"),u=qr(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?D("daterange.week","Week %1",[us(a)]):null},u?String(us(a)):""));for(let h=0;h<7;h+=1){let d=C(a,h),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:S(d,"%Y-%m-%d")}},S(d,"%e"));p.append(f),this._dayCells.push({date:d,cell:p,button:f})}c.append(p)}r.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:D("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:D("daterange.nextMonth","Next month")},_("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:D("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=C(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:S(n,"%A")},S(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)M(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);Be(r,"range",a.range),Be(r,"rangeEdge",a.edge),Be(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(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),M(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=Nr(t,this._start,this._end);if(!s)return{range:null,edge:null};let n=M(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return M(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:M(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=R(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=S(t,"%A, %e %B %Y");return e==="start"?`${s}, ${D("daterange.day.start","range start")}`:e==="end"?`${s}, ${D("daterange.day.end","range end")}`:e==="middle"?`${s}, ${D("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 D("daterange.status.empty","No date range selected");if(!this._end)return D("daterange.status.start","%1 selected, choose an end date",[S(this._start,"%e %B %Y")]);let t=Zt(this._start,this._end),e=t===1?D("daterange.night","1 night"):D("daterange.nights","%1 nights",[t]);return`${Lr(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=>M(e.date,t))?.button??null}};function Fr(){return[{name:"today",label:D("daterange.preset.today","Today"),range:()=>os(B())},{name:"yesterday",label:D("daterange.preset.yesterday","Yesterday"),range:()=>os(C(B(),-1))},{name:"last7",label:D("daterange.preset.last7","Last 7 days"),range:()=>({start:C(B(),-6),end:B()})},{name:"last30",label:D("daterange.preset.last30","Last 30 days"),range:()=>({start:C(B(),-29),end:B()})},{name:"thisMonth",label:D("daterange.preset.thisMonth","This month"),range:()=>as(B(),0)},{name:"lastMonth",label:D("daterange.preset.lastMonth","Last month"),range:()=>as(B(),-1)},{name:"thisQuarter",label:D("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=B(),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:D("daterange.preset.thisYear","This year"),range:()=>{let i=B();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function D(i,t,e){let s=P(i);return j(s===i?t:s,e)}function Lr(i,t){if(M(i,t))return S(i,"%e %B %Y");let e=S(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${S(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${S(i,"%e %B")} \u2013 ${e}`:`${S(i,"%e")} \u2013 ${e}`}function Or(i){return i===!0?Fr():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 B(){return R(new Date)}function os(i){return{start:i,end:new Date(i.getTime())}}function as(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function it(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function R(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function G(i){return i?new Date(i.getTime()):null}function $e(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 ls(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function cs(i){return i.getFullYear()*12+i.getMonth()}function Jt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Rr(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Bt()}function jr(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function qr(i,t){for(let e=0;e<7;e+=1){let s=C(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function us(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())/hs+1)/7)}function Be(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function Vr(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Pr(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var Hr={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ds(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",u=r===""?[s]:s.split(new RegExp(`${a}${ze(r)}${c}`));if(u.length>2)return null;let h=H(u[0].trim(),t);if(!h)return null;if(u.length===1)return{start:h,end:new Date(h.getTime())};if(u[1].trim()==="")return{start:h,end:null};let d=H(u[1].trim(),t);return d?At(h,d):null}function Br(i,t,e){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${S(s,t)}${e}${S(n,t)}`:S(n,t):S(s,t)}var te=class extends y{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=w("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:fs("daterange.clear","Clear date range")},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:fs("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 Xt(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",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.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=Z(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(),Ke(this.el,"data-state",this._originalState),Ke(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=ds(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(ds(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()!==""?H(t.trim(),this._format):null}_clamp(t){return Gt(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=>Hr[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Br(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"&&Ke(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 fs(i,t,e){let s=P(i);return j(s===i?t:s,e)}function Ke(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function ps(){x.register("daterange",(i,t)=>{let e=i.own(new te(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 st=class extends y{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=$r(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=ms(this.options.min),this._max=ms(this.options.max),this._value=this._normalizeValue(this.options.value);let e=w("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??Kr(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 ft(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",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.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=Z(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=H(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=H(t,this._format)),!e||Number.isNaN(e.getTime())?null:$i(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?S(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}},_s=function(t,e={}){return new st(t,{...e,time:!0})};function ms(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function $r(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Kr(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 bs(){gs("date",i=>new st(null,i)),gs("datetime",i=>_s(null,i))}function gs(i,t){x.register(i,(e,s)=>{let n=e.own(t({...s.props??{},value:s.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var ee=class extends y{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=w("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"},Yr(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 n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),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 n=s.find(o=>!Wr(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.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[n,r]of Object.entries(this.options.headers??{}))s.setRequestHeader(n,String(r));this.listen(s.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(Zr(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(Gr())),s.send(Qr(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 Yr(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${Ur(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function Ur(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function Wr(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 Qr(i,t,e){let s=new FormData;for(let n of i)s.append(t,n);for(let[n,r]of Object.entries(e??{}))ys(s,n,r);return s}function ys(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)ys(i,t,n);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Zr(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function Gr(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function xs(){x.register("upload",(i,t)=>{let e=i.own(new ee(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 vs=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ws=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ie=class extends y{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 vs[this.options.reorder]??vs.both}_renderRows(t=-1,e="value"){let s=ks(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((u,h)=>{let d=!n||s.some(([f])=>f===u)?s:[[u,u],...s],p=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${h+1}`,dataset:{index:h}},d.map(([f,m])=>l("option",{value:f,selected:f===u},m))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${h+1}`,dataset:{index:h}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:h}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${h+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:h}},_("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===0),ariaLabel:`Move value ${h+1} up`,dataset:{action:"up",index:h}},_("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===a),ariaLabel:`Move value ${h+1} down`,dataset:{action:"down",index:h}},_("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${h+1}`,dataset:{action:"remove",index:h}},_("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ws[e]??ws.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,n=Number(e.dataset.index);if(s==="add"){let r=ks(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(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),n=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(s,n,"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,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!s&&n===t?o.dataset.drop="before":!s&&t===e.length&&n===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 n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),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 ks(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 Ss(){x.register("multivalueeditor",(i,t)=>{let e=i.own(new ie(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(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}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var pt=class extends y{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:L(this.el);let t=this.el??l("div");this.el=t;let e=Xr(this.options.step);this._step=e,this._precision=this.options.precision===null?Jr(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=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,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||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),n=s!==this._value;return this._value=s,this._syncInput(),n&&!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=Ye(t,this.options.group?this._separators():null);return e===null?null:Ue(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,r=Ye(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=As(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=Ye(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)),n={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];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_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,n=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}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&&O(t,this._snapshot)}};function Ye(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 r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function Ue(i,{min:t,max:e,step:s,precision:n}){let r=i;if(s>0){let o=t??0;r=o+Math.round((i-o)/s)*s}return r=As(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function Xr(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Jr(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 As(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function zs(){x.register("number",(i,t)=>{let e=i.own(new pt(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",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var se=class extends y{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:L(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=w("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 n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},_(this.options.icon,{size:zt[this.options.size]??zt.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},_(this.options.icon,{size:zt[this.options.size]??zt.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=zt[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),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!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",n=>{this._choose(t,n.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 n=this.msg(t,...s);return n===t?j(e,s):n}_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,n)=>{let r=Math.min(1,Math.max(0,t-n));s.style.setProperty("--zx-rating-fill",`${r*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(to(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&&O(t,this._snapshot)}},zt={sm:14,md:18,lg:24};function to(i,t){return t<1?i.toFixed(1):String(i)}function Cs(){x.register("rating",(i,t)=>{let e=i.own(new se(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var eu=["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 Ds(i,t){let e="",s=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(u=>u===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let a=i(),c=a.findIndex(u=>eo(u).startsWith(e));c>=0&&t(a[c],c)}}function eo(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 io=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Is=["Lowest","Low","Medium","High","Highest"],so=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),F=class i extends y{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],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._actions=[],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._snapshot=null,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:L(t);let e=w("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}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),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})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},_("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),u=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return t.replaceChildren(c,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._actions=Ms(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=Ds(()=>this._optionEntries.filter(d=>!d.clear&&!d.action).map(d=>d.element),(d,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",d=>this._onKeydown(d)),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",d=>d.preventDefault()),this.listen(h,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._open&&!t.contains(d.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,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(s,r)&&this.emit("change",{value:r,item:n}),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}setActions(t){return this._actions=Ms(t),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=Z(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,n=new i(t,{...e,value:null,items:[],renderItem(r){return oo(r,!0)},renderValueAdornment(r){return Es(r.level)}});return n.setItems(io.map((r,o)=>{let a=o===2?n.msg("priority.medium"):r;return(a==="priority.medium"||o!==2)&&(a=n._message(r,Is[o])),{ID:o,name:a,level:o}})),n.set(s,{silent:!0}),n}static status(t,e={}){let{items:s=null,value:n=null,...r}=e,o=new i(t,{...r,value:null,items:[],renderItem(c){return lo(c)},renderValueAdornment(c){return Ns(c)}}),a=Array.isArray(s)?s.map(ao).filter(Boolean):so.map(([c,u,h,d,p],f)=>({ID:c,name:o._message(u,h),indicator:d,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:s=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:u=null,fixedItems:h=[],actions:d=[],renderItem:p=null,renderValueAdornment:f=null,...m}=e,g=(k,T=!1)=>{if(typeof u=="function")return u(k,{selected:T});let v=ne(k,o);if(v&&typeof v=="object"&&typeof v.nodeType=="number")return v.cloneNode(!0);if(typeof v!="string"||!v)return null;let A=ne(k,a);return l("span",{class:"zx-select__entity-glyph",style:W(A)?{"--zx-select-entity-color":String(A)}:null,ariaHidden:"true"},_(v,{size:14}))},b=r?no(r):null,z=new i(t,{...m,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(h)?h:[]],fixedLabel:Array.isArray(s)&&s.length?n:m.fixedLabel??null,actions:[...Array.isArray(d)?d:[],...b?[b]:[]],renderItem:p??(k=>{let T=g(k,!1),v=ne(k,c),A=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(ne(k,m.labelKey??"name")??"")),v==null||v===""?null:l("span",{class:"zx-select__entity-subtitle"},String(v)));return l("span",{class:"zx-select__entity"},T?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},T):null,A)}),renderValueAdornment:f??(k=>g(k,!0))});return z.el.dataset.preset="entity",z}static permission(t,e={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,u=typeof s=="function"?s:null,h=u?[]:s,d=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(t,{filter:u??a,...c,value:null,items:h,fixedItems:[],valueKey:f=>d.includes(f)?f.ID:Qe(f,r),labelKey:f=>d.includes(f)?f.name:String(Qe(f,o)??"")});return d[0].name=p._message("permission.private","Private"),d[1].name=p._message("permission.public","Public"),p.setFixedItems(d),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&O(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&Ts(t)){let e=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}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&&Ts(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=Q(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){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}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,n)=>{n===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"),s=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,s);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),s.length>0&&this.options.fixedLabel&&t.append(l("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of s)this._appendOption(r,!1);s.length>0&&n.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&s.length===0&&this._actions.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 n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?We(this.options.renderNone(String(s??""))):e?String(s??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:w("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(_("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,s=ro(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:w("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},s?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return We(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._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=We(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_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(r=>r===t);if(s!==void 0)return s;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??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 Qe(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return Q(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let s=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return s.some(o=>Object.is(o,r))?!1:(s.push(r),!0)})}_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)}_message(t,e){let s=this.msg(t);return s===t?e:s}};function ne(i,t){return typeof t=="function"?t(i):i!==null&&typeof i=="object"&&typeof t=="string"?i[t]:null}function no(i){let t=i===!0?{}:i;return{id:t.id??"create",label:t.label??"Create new\u2026",description:t.description,group:t.group??"New",icon:t.icon??"plus",invoke:t.invoke}}function We(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function Ms(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),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function ro(i){return typeof i=="string"?_(i):i instanceof Node?i.cloneNode(!0):null}function oo(i,t){return l("span",{class:"zx-select__priority"},Es(i.level),t?l("span",{},String(i.name)):null)}function Es(i){let t=Math.max(0,Math.min(4,Math.trunc(Number(i)||0)));return l("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,s)=>l("span",{dataset:{filled:String(s<=t)}})))}function ao(i){if(!i||typeof i!="object"||i.ID==null||i.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...i,name:String(i.name),indicator:t.includes(String(i.indicator))?String(i.indicator):"ring",tone:e.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function lo(i){return l("span",{class:"zx-select__status"},Ns(i),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(i.name)),i.description?l("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?l("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function Ns(i){let t=String(i.indicator??"ring"),e=l("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(i.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(_("check",{size:8})),t==="canceled"&&e.append(_("x",{size:7})),e}function Qe(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function Ts(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function Fs(){x.register("zxselect",(i,t)=>{let e=t.props??{},s=e.preset,n={...e,value:t.value};delete n.preset;let r=i.own(s==="priority"?F.priority(null,n):s==="status"?F.status(null,n):new F(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var re=class extends y{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:L(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=w("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()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.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"})),n),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",r=>{this._readonly&&co.has(r.key)&&r.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),n=s!==this._value;return this._value=s,this._paint(),n&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,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 n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(n)*100}%`}},r))}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)?Ue(e,{min:this._min,max:this._max,step:this._step,precision:uo(this._step)}):this._min}_ratio(t){return wt((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${ho(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&O(t,this._snapshot)}},co=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function uo(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function ho(i){return String(Number(i.toFixed(6)))}function Ls(){x.register("slider",(i,t)=>{let e=i.own(new re(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var oe=class extends y{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",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:L(this.el);let t=this.el??l("div");this.el=t;let e=w("zx-tag-picker-list"),s=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=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??"")}),r=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,n,r),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",u=>{let h=u.target;h.closest(".zx-tag-picker__remove")||h.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",u=>{let h=u.target.closest(".zx-tag-picker__remove");if(!h||this._disabled||this._readonly)return;u.stopPropagation();let d=[...s.children].indexOf(h.closest(".zx-tag-picker__tag")),p=this._selected[d];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.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:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(u=>this._sameValue(u,c))&&r.push(c)}let o=!fo(r,this._selected,a=>this._valueOf(a));return this._selected=r,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(n=>this._sameValue(n,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),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),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=Z(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&&O(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),n=this._colorOf(e),r=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},s)],o=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!n)},style:n?{"--zx-tag-color":n}:null},r);return!this._readonly&&!this._disabled&&o.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},_("x",{size:11}))),o});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 r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:w("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(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=l("div",{class:"zx-tag-picker__option",id:w("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:r,create:!0}),e.push(r)}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 n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n: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(n=>n.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}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 n=e===t;s.element.toggleAttribute("data-active",n),n&&(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=Q(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(n=>Os(this._labelOf(n))===Os(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(r=>Object.is(this._valueOf(r),e));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n: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??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),s=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?_(e,{size:12}):null;return s?l("span",{class:"zx-tag-picker__visual",style:this._colorOf(t)?{"--zx-tag-color":this._colorOf(t)}:null,ariaHidden:"true"},s):null}_colorOf(t){let e=this._readItem(t,this.options.colorKey);return W(e)?e:null}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_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 n=this.msg(t,...s);return n!==t?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Os(i){return String(i??"").trim().toLocaleLowerCase()}function fo(i,t,e){return i.length!==t.length?!1:i.every((s,n)=>Object.is(e(s),e(t[n])))}function Rs(){x.register("tagpicker",(i,t)=>{let e=i.own(new oe(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{s=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function po(i,t="minutes"){let e=Math.round(Math.abs(js(nt(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:nt(i)<0}}function mo(i,t="minutes"){Ct(t);let e=Math.abs(Math.trunc(nt(i?.hours))),s=Math.abs(Math.trunc(nt(i?.minutes))),n=Math.abs(Math.trunc(nt(i?.seconds))),r=i?.negative?-1:1;return qs(r*(e*3600+s*60+n),t)}var ae=class extends y{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){Ct(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 mo(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),Ct(e);let n=nt(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=qs(Math.round(js(n,e)/60)*60,e)),this._parts=po(n,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,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(n,Math.trunc(nt(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]):_o(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 nt(i){let t=Number(i);return Number.isFinite(t)?t:0}function js(i,t){return Ct(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function qs(i,t){return Ct(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function Ct(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function _o(i){return String(i).padStart(2,"0")}function Vs(){x.register("time",(i,t)=>{let e=i.own(new ae(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 mt=class extends y{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:go(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&&bo(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function go(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function bo(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 Ps(){x.register("toggle",(i,t)=>{let e=i.own(new mt(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 le=class extends y{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=Hs(this.options.values,!!this.options.unique);let e=w("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=Hs(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,n)=>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:n}},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 n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&n&&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[n]=this._values.splice(t,1);this._values.splice(e,0,n),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 Hs(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function Bs(){x.register("valuelist",(i,t)=>{let e=i.own(new le(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 ce=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),yo=["xl","lg","md","sm"];function $s(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of yo)if(t>=ce[e])return e;return"xs"}function Ks(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,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let d=a();if(s&&d===0)return;let p=$s(d);p!==n&&(n=p,i(n,d))};c();let u=0,h=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(h),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??$s(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var xo=0,vo=20,wo=3;var Ys=new Map;function ue(i,t={}){let e=Xe(i);if(e===null)return"";let{locale:s=K(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Ze(s,Ge({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function Ws(i,t,e={}){let s=Xe(i);if(s===null)return"";let{locale:n=K(),decimals:r}=e,o=So(t);if(o===null)return ue(s,{locale:n,decimals:r});let a=Ge({decimals:r,group:!0});return Ze(n,{...a,style:"currency",currency:o},s)}function Qs(i,t={}){let e=Xe(i);if(e===null)return"";let{locale:s=K(),decimals:n=0}=t;return Ze(s,{...Ge({decimals:n,group:!0}),style:"percent"},e)}function Ze(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,n=Ys.get(s);return n===void 0&&(n=ko(i,t),Ys.set(s,n)),n.format(e)}function ko(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Ge({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let n={useGrouping:s!==!1},r=Us(t??i),o=Us(e??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,wo)),n}function Us(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(vo,Math.max(xo,Math.round(t))):null}function Xe(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function So(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Ao(i,t){return String(i).localeCompare(String(t))}function zo(i,t){return i-t}function Co(i,t){return i.getTime()-t.getTime()}function Do(i,t,e="asc"){let s=i==null,n=t==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&t instanceof Date?r=Co(i,t):typeof i=="number"&&typeof t=="number"?r=zo(i,t):r=Ao(i,t),e==="desc"?-r:r}function Io(i,t="asc"){return(e,s)=>Do(i(e),i(s),t)}function Je(i,t,e="asc"){let s=Io(t,e);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Mo=new Set(["text","number","select","date","checkbox","textarea"]),To='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Dt=class extends y{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,editTrigger:"double",hierarchy:!1,rowReorder:!1,columnVisibility:!1,hiddenColumns:[]};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:L(e),this._columns=Array.isArray(this.options.columns)?this.options.columns.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=$o(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Ho(this.options.editMode),this._editTrigger=this.options.editTrigger==="single"?"single":"double",this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Uo(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Vo(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(s=>this._columns.some(n=>n.id===s))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._expanded=Po(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of he(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);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._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:w("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",s=>this._handleRowDragStart(s)),this.listen(this._tbody,"dragover",s=>this._handleRowDragOver(s)),this.listen(this._tbody,"drop",s=>this._handleRowDrop(s)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",s=>this._handleRowHandleKeydown(s))),this._columnControls&&this.listen(this._columnControls,"change",s=>{let n=s.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleEditFocusIn(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),e}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),Xs(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 Xs(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(r=>Object.is(this._idFor(r),t));if(s<0)return this;let n=this._selected.delete(t);return this._data[s]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),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]}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,s={}){if(!this._columns.find(c=>c.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=document.activeElement,o=r?.classList.contains("zx-table__column-toggle")&&this._columnList?.contains(r)?r.value:null;if(!e&&!this._hiddenColumns.has(t)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(t):!this._hiddenColumns.has(t);return!e&&a&&this._hiddenColumns.add(t),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(t),e)}moveRow(t,e,s="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(t),r=this.getRow(e);if(!n||!r||Object.is(t,e))return this;let o=Js(this._data,this.options.rowId,t,e,s,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:s}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),u=c.findIndex(h=>Object.is(h,t));this._rowMoveMessage.textContent=`Moved row to position ${u+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}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 r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:r}),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(n=>this._idFor(n))),s=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return Yo(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=he(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!t.silent)for(let n of s)this._emitRowToggle(n,!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(p=>p.id===e);if(!s)return this;let n=this._data.find(p=>Object.is(this._idFor(p),t));if(n===void 0)return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(p=>_t(p,n)!==!1)??null:s;if(!r||_t(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),t));if(a<0)return this;let c=this._data[a],u=this._rowElements.get(t)?.[0];if(!u)return this;let h=this._editMode==="row"?this._visibleColumns().filter(p=>_t(p,c)!==!1):[r],d=new Map;for(let p of h){let f=Gs(u,p.id);if(!f)continue;let m=this._createEditor(f,p,c,a);m&&d.set(p.id,m)}return d.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:d,tr:u},u.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),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 n=this._columns.filter(d=>t.cells.has(d.id)),r=qo(s,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(d=>d.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=jo(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 u=this._editHasFocus(),h={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,h),u&&this._focusCell(this._idFor(h),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?No(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,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),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 n=this.msg(t,...s);return n===t?j(e,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ce)||(this._width=Ks((e,s)=>this._setStacked(s>0&&s<ce[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,n]of e)s&&(t?s.setAttribute("role",n):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(O(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t;let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-button zx-button--sm"},_("fields",{size:13}),"Columns"),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),s=[...this._columnList.querySelectorAll(".zx-table__column-toggle")];if(s.length===this._columns.length&&s.every((r,o)=>r.value===this._columns[o].id)){s.forEach((r,o)=>{let a=r,c=!this._hiddenColumns.has(this._columns[o].id);a.checked=c,a.disabled=c&&e.length===1});return}if(this._columnList.replaceChildren(...this._columns.map(r=>{let o=!this._hiddenColumns.has(r.id);return l("label",{class:"zx-table__column-option"},l("input",{class:"zx-table__column-toggle",type:"checkbox",value:r.id,checked:o,disabled:o&&e.length===1}),l("span",{},r.label))})),t!==null){let r=[...this._columnList.querySelectorAll(".zx-table__column-toggle")].find(o=>o.value===t);queueMicrotask(()=>{r?.isConnected&&r.focus()})}}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),s=e?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,s.dataset.dragging="true",t.dataTransfer?.setData("text/plain","zx-table-row"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleRowDragOver(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),s=e?this._rowMeta.get(e):null;if(!s||Object.is(s.id,this._dragId)||!this._canMoveTogether(this._dragId,s.id))return;t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=e.getBoundingClientRect();e.dataset.drop=t.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),s=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";s&&this._canMoveTogether(this._dragId,s.id)&&(t.preventDefault(),this.moveRow(this._dragId,s.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),s=e?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!e||!n)return;if(t.key===" "||t.key==="Enter"){t.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,e.setAttribute("aria-pressed",String(this._grabbedId!=null));let c=this._rowMoveMessage??this._editMessage;c&&(c.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(t.key==="Escape"&&this._grabbedId!=null){t.preventDefault(),this._grabbedId=null,e.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(c=>Object.is(c,n.id)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let s=this._hierarchy?V(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||ei(V(this._hierarchy.parentId,n),s)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let s=this.getRow(t),n=this.getRow(e);return!!(s&&n&&ei(V(this._hierarchy.parentId,s),V(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),s=e.map(r=>Ko(r.width)),n=s.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");s[o]>0?a.style.width=`${s[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),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._visibleColumns()){let s=l("th",{scope:"col"}),n=e.align??(ti(e)?"end":null);if(n&&(s.dataset.align=n),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let r=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(r)}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._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0)},this._emptyContent()))):this._visibleEntries().forEach((s,n)=>{t.append(this._createRow(s.row,s.index,{...s,visibleIndex:n}))}),this._tbody.replaceChildren(t),this._table.setAttribute("aria-colcount",String(this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0))),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 n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:s.visibleIndex});let a=this._rowElements.get(n)??[];if(a.push(r),this._rowElements.set(n,a),this.options.rowReorder){let c=l("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaLabel:`Move row ${e+1}`,ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?"Clear sorting to reorder rows":null},_("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},c))}if(this.options.selectable==="multi"){let c=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},c))}return this._visibleColumns().forEach(c=>{let u=l("td"),h=c.align??(ti(c)?"end":null);h&&(u.dataset.align=h),u.dataset.label=c.label,c.popin===!1&&(u.dataset.popin="false"),this._editMode!==!1&&(u.dataset.column=c.id,_t(c,t)!==!1&&(u.dataset.editable="true",u.tabIndex=-1,this._offerRovingCell(u,n,c.id))),this._renderCellContent(u,c,t,e,s),r.append(u)}),r}_renderCellContent(t,e,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=Eo(e,s,n),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._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let u=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(u),ariaLabel:`${u?"Collapse":"Expand"} row ${n+1}`},_(u?"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&&de(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||e.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}if(!Zs(e)){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.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&&de(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!Zs(e)){if(this._editMode!==!1&&this._editTrigger==="double"){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,s,n){let r=_t(e,s);if(r===!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 u=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,u),t.dataset.editing="true";let h={column:e,type:r,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){h.custom=o,h.read=()=>rt(e,h.custom,s);let f={value:o,row:s,column:e,commit:g=>{h.custom=g,this.commitEdit()},cancel:()=>this.cancelEdit()},m=e.editor(s,f);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(h.component=m),u.append(m.toElement())):m&&u.append(m),h.control=u.querySelector(To)??u,h}if(r==="number"){let f=ot(e.locale,s),m=tn(e,s),g=e.type==="currency"?ot(e.currency,s):e.type==="unit"?ot(e.unit,s):null,b={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:m}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(g)}:{}},z=new pt(null,{...b,...a,value:o??null});return u.append(z.el),h.component=z,h.control=z.getInput(),h.read=()=>(z.set(z.getInput().value,{silent:!0}),rt(e,z.get(),s)),h}if(r==="select"){let f=Lo(e.options,s),m=f.find(b=>Object.is(b.value,o))??f.find(b=>String(b.value)===String(o??"")),g=new F(null,{...a,items:f,valueKey:"value",labelKey:"label",value:m?m.value:null});return u.append(g.el),h.component=g,h.control=g.refs.input,h.read=()=>rt(e,g.value,s),h}if(r==="date"){let f=new st(null,{...a,value:o??null});u.append(f.el),h.component=f;let m=f.refs.input;return h.control=m,h.read=()=>{let g=String(m.value??"").trim(),b=f.get();return g===""?rt(e,null,s):(f.set(g,{silent:!0}),f.get()===null&&f.set(b,{silent:!0}),rt(e,f.get(),s))},h}if(r==="checkbox"){let f=new mt(null,{...a,checked:!!o});return u.append(f.el),h.component=f,h.control=f.el,h.read=()=>rt(e,f.get(),s),h}let d=r==="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 ${n+1}`,value:Oo(e,o,s)});return u.append(p),h.control=p,h.read=()=>rt(e,p.value,s),h}_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?Gs(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),s=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.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(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,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&&de(e)){if(Bo(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 n=this._rowMeta.get(s.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,s);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,s){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[t]),c=o.findIndex(d=>Object.is(this._idFor(d),a));if(c<0)return null;let u=n.findIndex(d=>d.id===e),h=o.length*r+r;for(let d=0;d<h;d+=1){if(u+=s,u>=r?(c+=1,u=0):u<0&&(c-=1,u=r-1),c<0||c>=o.length)return null;let p=o[c],f=n[u];if(_t(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}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 n=this._rowMeta.get(s.parentElement);n&&this._setRovingCell(s,n.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&de(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_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 n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=t.visibleIndex??n.findIndex(u=>Object.is(this._idFor(u),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let u=a;u<=c;u+=1){let h=this._idFor(n[u]);e?this._selected.add(h):this._selected.delete(h)}}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 n of e){n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),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?Fo(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):Je(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?he(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,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=he(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 Eo(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=ot(i.locale,t),o=tn(i,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return ue(s,a);if(n==="currency"){let c=ot(i.currency,t);return Ws(s,c==null?null:String(c),a)}if(n==="percent")return Qs(s,a);if(n==="unit"){let c=ue(s,a),u=ot(i.unit,t);return c&&u!=null&&String(u)!==""?`${c}\xA0${u}`:c}return s}function No(i,t,e,s=[]){let n=fe(i,t,e),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:u}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:u,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let h=c.children.length-1;h>=0;h-=1)a.push({node:c.children[h],depth:u+1})}return o}function Fo(i,t,e,s,n){let r=fe(i,t,e),o=u=>Je(u,h=>s(h.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let u=c.pop();a.push(u.row);let h=o(u.children);for(let d=h.length-1;d>=0;d-=1)c.push(h[d])}return a}function Js(i,t,e,s,n="before",r=null){if(!Array.isArray(i)||Object.is(e,s))return null;let o=i.findIndex(d=>Object.is(V(t,d),e)),a=i.findIndex(d=>Object.is(V(t,d),s));if(o<0||a<0||r&&!ei(V(r,i[o]),V(r,i[a])))return null;if(r){let d=fe(i,t,r),p=d.nodes[o],f=d.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let m=A=>{let I=[],bt=[A];for(;bt.length;){let we=bt.pop();I.push(we);for(let ke=we.children.length-1;ke>=0;ke-=1)bt.push(we.children[ke])}return I},g=new Set(m(p).map(A=>A.index)),b=new Set(m(f).map(A=>A.index)),z=i.filter((A,I)=>g.has(I)),k=i.filter((A,I)=>!g.has(I)),T=i.map((A,I)=>I).filter(A=>!g.has(A)),v=T.findIndex(A=>A===a);if(n==="after"){let A=T.map((I,bt)=>b.has(I)?bt:-1).filter(I=>I>=0);v=Math.max(...A)+1}return v<0?null:(k.splice(v,0,...z),k)}let c=[...i],[u]=c.splice(o,1),h=c.findIndex(d=>Object.is(V(t,d),s));return c.splice(h+(n==="after"?1:0),0,u),c}function _t(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?ti(i)?"number":"text":typeof e=="string"&&Mo.has(e)?e:!1}function Lo(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,n])=>({value:s,label:String(n??"")})):[]}function Oo(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 rt(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Ro(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function jo(i,t){let e={};for(let[s,n]of Object.entries(t??{}))Ro(i?.[s],n)||(e[s]=n);return e}function qo(i,t,e,s="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function ot(i,t){return typeof i=="function"?i(t):i}function tn(i,t){let e=ot(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function ti(i){return["number","currency","percent","unit"].includes(i?.type)}function fe(i,t,e){let s=(Array.isArray(i)?i:[]).map((a,c)=>({row:a,id:V(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let c=V(e,a.row),u=c==null?null:n.get(c)??null;r.set(a,u===a?null:u)}for(let a of s){let c=new Set([a]),u=r.get(a)??null;for(;u;){if(c.has(u)){r.set(u,null);break}c.add(u),u=r.get(u)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function he(i,t,e){return fe(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function V(i,t){return typeof i=="function"?i(t):t?.[i]}function ei(i,t){return i==null&&t==null||Object.is(i,t)}function Vo(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,n=t.some(r=>r.id===s)?s:t[0]?.id;return n?{...i,parentId:e,column:n}:null}function Po(i){return new Set(Array.isArray(i)?i:[])}function Ho(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function de(i){return!!i?.closest?.(".zx-table__editor")}function Zs(i){let t=i?.closest?.("td[data-column]"),e=i?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(t&&e&&e!==t&&t.contains(e))}function Bo(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Gs(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function $o(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 Ko(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 Xs(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Yo(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Uo(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ii=class extends y{static cssName="app-icon";static defaults={icon:null,color:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:L(t),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&O(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(a=>String(a??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=en(t.size,"36px"),s=en(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",s),W(t.color)?this.el.style.setProperty("--zx-app-icon-color",String(t.color)):this.el.style.removeProperty("--zx-app-icon-color"),this.el.dataset.glass=Qo(t.glass),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=Wo(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge));this.el.replaceChildren(l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r),o)}};function sn(i={}){return new ii(null,i).toElement()}function Wo(i){let t=typeof i=="function"?i():i;return typeof t=="string"?_(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function en(i,t){if(typeof i=="number"&&Number.isFinite(i))return`${Math.max(1,i)}px`;let e=String(i??"").trim();return e&&!/[;{}]/.test(e)?e:t}function Qo(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}var _e=class extends y{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",closeLabel:"Close launcher",resultsLabel:"Launcher results",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k",hints:{move:"Move",open:"Open",close:"Close"}};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,u=>[u.name,u.value]),children:Array.from(t.childNodes)},this._items=si(this.options.items),this._sources=on(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=w("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}),n=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel},_("x")),r=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:this.options.resultsLabel}),a=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Zo()):null,c=Go(this.options.hints);return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:a?"true":"false"}},_("search"),s,a,n),r,o,c)),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",u=>this._onKeydown(u)),this.listen(n,"click",()=>this.close()),this.listen(o,"click",u=>{let h=u.target?.closest?.("[data-launcher-index]");!h||!o.contains(h)||this._activate(Number(h.getAttribute("data-launcher-index")),u)}),this.listen(o,"pointermove",u=>{let h=u.target?.closest?.("[data-launcher-index]");if(!h||!o.contains(h))return;let d=Number(h.getAttribute("data-launcher-index"));!Number.isInteger(d)||this._results[d]?.disabled||d===this._active||(this._active=d,this._syncActive())}),this.listen(t,"cancel",u=>{u.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",u=>this._onDocumentKeydown(u)),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=si(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(s=>({...s,current:e!==null&&String(s.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=on(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(r=>pe(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let s=new AbortController,n=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:s.signal});if(s.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,si(o).map((a,c)=>({...a,_source:r.id,_sourceOrder:r.order==="source",group:a.group??r.label??"",itemOrder:a.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(s.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(s.signal.aborted||n!==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=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,s=this._query.trim(),n=this._items.filter(f=>pe(f.when,s)),r=nn(n,s,this.options.maxResults),o=this._sources.flatMap(f=>{let m=this._sourceItems.get(String(f.id))??[];return f.order==="source"?m.filter(g=>pe(g.when,s)):nn(m.filter(g=>pe(g.when,s)),s,this.options.maxResults)}),a=new Set,c=[...r.map(f=>({...f,_source:null})),...o].filter(f=>{let m=String(f.id);return a.has(m)?!1:(a.add(m),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),u=new Map;for(let f of c){let m=String(f.group??"");u.has(m)||u.set(m,[]),u.get(m).push(f)}this._results=[...u.values()].flat(),this._renderedQuery=t;let h=e===null?-1:this._results.findIndex(f=>!f.disabled&&String(f.id)===e);this._active=h>=0?h:this._results.findIndex(f=>!f.disabled);let d=[],p=0;for(let[f,m]of u){let g=m.map(b=>this._option(b,p++));f?d.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:f,dataset:{layout:m.every(b=>b.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},f),g)):d.push(...g)}this.refs.results.replaceChildren(...d),this._syncActive(),this._renderStatus()}_option(t,e){let s=Ce(t.href),n=s?"a":"button",r=[],o=Xo(t);return o&&r.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),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(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:s,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:w("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:Jo(t.kind)}},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 n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}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((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")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"})}_spatialIndex(t,e){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=ta(n,s,t);return r?Number(r.getAttribute("data-launcher-index")):null}_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"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function Zo(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function Go(i){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??"Move"),l("span",{},l("kbd",{},"\u21B5"),t.open??"Open"),l("span",{},l("kbd",{},"Esc"),t.close??"Close"))}function Xo(i){let t=i.icon;if(typeof t=="function"&&(t=t(i)),typeof t=="string")return _(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function Jo(i){return i==="application"||i==="record"?i:"action"}function pe(i,t){return i==="empty"?t==="":i==="query"?t!=="":!0}function ta(i,t,e){let s=t.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let c of i){if(c===t)continue;let u=c.getBoundingClientRect(),h=u.left+u.width/2-n,d=u.top+u.height/2-r,p=!1,f=1/0;e==="ArrowLeft"?(p=h<-2&&Math.abs(d)<Math.max(s.height,u.height)/2,f=Math.abs(h)+Math.abs(d)*4):e==="ArrowRight"?(p=h>2&&Math.abs(d)<Math.max(s.height,u.height)/2,f=Math.abs(h)+Math.abs(d)*4):e==="ArrowUp"?(p=d<-2,f=Math.abs(d)*10+Math.abs(h)):e==="ArrowDown"&&(p=d>2,f=Math.abs(d)*10+Math.abs(h)),p&&f<a&&(o=c,a=f)}return o}function nn(i,t,e=100){let s=gt(t).trim(),n=i.map((o,a)=>({item:o,order:a,score:ea(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=me(o.item.groupOrder),u=me(a.item.groupOrder);if(c!==u)return c-u;if(s===""){let h=rn(o.item.pinned,o.order),d=rn(a.item.pinned,a.order);if(h!==d)return h-d}return o.score-a.score||me(o.item.itemOrder)-me(a.item.itemOrder)||ia(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function ea(i,t){if(!t)return i.pinned?-1:0;let e=gt(i.label),s=gt(i.id),n=gt(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)||n.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 rn(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function me(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function gt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function ia(i,t){let e=gt(i),s=gt(t);if(e<s)return-1;if(e>s)return 1;let n=String(i??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function si(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>sa(t)):[]}function sa(i){let t={...i,label:String(i.label)};if(i.href==null)return t;let e=Ce(i.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function on(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)})):[]}var ri=class{#t;#e=[];#i=[];#s;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.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},at=class i extends y{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:ua(e),this._entries=new Set,this._queue=new ri(oa(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:na(e.kind??this.options.kind),timeout:ra(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,s);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}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)ni(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&ha(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 n=!1;return{update:(r,o)=>{n||s.closed||(e.pct=la(r),o!==void 0&&(e.text=String(o)),ge(s,e))},done:()=>{n||s.closed||(n=!0,e.pct=100,ge(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(e.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(_("error",{size:18})),ge(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},_(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});aa(t)?r.append(t):r.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"}},n,r),a={node:o,content:r,iconHost:n,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"}),u=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);r.append(u),a.progressBar=u,a.progressFill=c,ge(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,ni(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!ca()){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)&&(ni(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 na(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function ra(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function oa(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function aa(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function la(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ge(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 ni(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function ca(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function ua(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ha(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 It=class extends y{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 n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}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[n,r]of Object.entries(s))this.addField(n,r);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(e instanceof x)n=e;else if(N(e)||e instanceof y){let o=e;n=new x(null,{id:s,type:"custom",label:s,value:fa(o),disabled:pa(o),adapter:()=>da(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new x(null,{...o,id:o.id??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}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,n]of Object.entries(t))this._fields.get(s)?.setValue(n,{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[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),s+=1):r.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 da(i){let t=N(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="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 n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function fa(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 pa(i){let t=N(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Mt=class extends y{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 It),s=e?new It(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",n=>{let r=n.target,o=r instanceof Element?r.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 n=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:!n&&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,n?l("span",{class:"zx-btn__label"},n):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,n)=>s+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&oi(a))c=this.msg("form.required");else if(!oi(a)&&o.options.type==="int"){let u=Me(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!oi(a)&&o.options.type==="float"){let u=Te(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=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)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(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 oi(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function ma(){Fs(),ji(),bs(),ns(),ps(),Vs(),Bs(),Ss(),xs(),Ps(),zs(),Cs(),Rs(),Ls()}ma();function X(i,{onError:t,locale:e}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(t!=null&&typeof t!="function")throw new TypeError("onError must be a function");let s=e??_a(i);s&&Ie(String(s));let n=(o,a)=>t?t(o,a):at.error(ba(o)),r=async(o,a,c)=>{let u=ga(i,o,a);try{return await i.api[u](c)}catch(h){try{n(h,{operation:u,resource:a})}catch{}throw h}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,c={})=>r("get",o,an(a)?a:{ID:a,...c}),create:(o,a)=>r("create",o,a),update:(o,a,c)=>r("update",o,c===void 0&&an(a)?a:{ID:a,body:c??{}}),reportError:n}}function _a(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function ga(i,t,e){let s=String(e??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(f=>typeof f=="string"&&f.toLowerCase().startsWith(t)).sort((f,m)=>f.length-m.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(t))return s;let o=ln(s),a=cn(o),c=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(t))return!1;let f=ln(p.slice(t.length));return f===o||f===a||cn(f)===a});if(c.length)return c.sort((p,f)=>p.length-f.length)[0];let u=t==="list"?[`list${ai(s)}`]:[`${t}${ai(ya(s))}`,`${t}${ai(s)}`],h=new Set(Object.keys(i.api)),d=u.find(p=>h.has(p));if(d)return d;throw new RangeError(`No ${t} operation found for ZeyOS resource "${s}"`)}function an(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function ba(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function ln(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function cn(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function ya(i){let t=String(i);return/ies$/i.test(t)?`${t.slice(0,-3)}y`:/s$/i.test(t)&&!/ss$/i.test(t)?t.slice(0,-1):t}function ai(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var lt=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),hn=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),Tt=Object.freeze({light:"#ffffff",dark:"#141414"}),Et=Object.create(null);function be(i){let t=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!t)return"default";if(Object.hasOwn(Et,t)||Object.hasOwn(lt,t))return t;let e=hn[t];return e||"default"}function U(i){let t=be(i);return Et[t]??lt[t]??lt.default}function xa(i){return U(i).color}function va(i,{standard:t=!1}={}){let e=U(i);return t?e.fa:e.icon}function wa(){return[...new Set([...Object.keys(lt),...Object.keys(Et)])].sort()}function ka(i){for(let[t,e]of Object.entries(i)){let s=String(t).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof e=="string"?{color:e}:e,r=Et[s]??lt[s]??lt.default;Et[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function ye(i){let t=li(i);if(t===null)return Tt.light;let e=un(t,li(Tt.light)??1),s=un(t,li(Tt.dark)??0);return e>=s?Tt.light:Tt.dark}function li(i){let t=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!t)return null;let e=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(e.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function un(i,t){return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)}var dn="https://kit.fontawesome.com/ae8320b210.js";function Sa(i={}){return Ve({kit:dn,...i})}function fn(i,t={}){let{standard:e=!1,...s}=t,n=U(i);return _(e?`fa:${n.fa}`:`kit:${n.icon}`,s)}function ct(i,t={}){let{size:e=24,iconSize:s="52%",label:n=null,title:r=!1,standard:o=!1,color:a=null}=t,c=be(i),u=U(i),h=W(a)?a:u.color,d=sn({icon:t.icon??fn(i,{size:"1em",standard:o}),size:e,iconSize:s,color:h,label:n,glass:t.glass??"subtle",class:["zx-module-icon",t.class].flat().filter(Boolean)});return d.dataset.module=c,d.style.setProperty("--zx-module-color",h),d.style.setProperty("--zx-module-glyph",ye(h)),d.style.setProperty("--zx-app-icon-glyph",ye(h)),r&&(d.title=u.label),d}function Aa(i,t={}){return ct(i,t)}var za=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function pn(i={},t={}){let{standardIcons:e=!1,items:s=[],sources:n=[],...r}=t,o=ui(i.labels),a={standardIcons:e,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},c=mn(i,a),u=typeof i.loadRecent=="function"?[]:xe(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e}),h=[];return typeof i.loadRecent=="function"&&h.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(d,p)=>xe(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),typeof i.search=="function"&&h.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(d,p)=>xe(await i.search(d,p),{query:d,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),h.push(...n),{...r,items:[...c,...u,...s],sources:h,hints:t.hints??{move:o.move,open:o.open,close:o.close}}}function Ca(i={},t={}){return new _e(null,pn(i,t))}function mn(i={},t={}){let e=ui(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,c=null,u=null)=>{let h=Ia(a,c,u);if(!h||n.has(h.identifier)||h.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(h.module))return;n.add(h.identifier);let d=_n(h.raw,i.resolveApplication),p=s.indexOf(h.identifier),f=()=>(typeof t.renderApplicationIcon=="function"?t.renderApplicationIcon(h.raw,h):h.type==="weblet"&&typeof t.renderWebletIcon=="function"?t.renderWebletIcon(h.raw,h):null)??ct(h.module,{size:36,standard:!!t.standardIcons,color:h.color});r.push({id:h.identifier,label:h.label,keywords:[h.identifier,h.module],group:e.applications,groupOrder:0,kind:"application",icon:f,pinned:p>=0?p:void 0,current:h.identifier===i.activeIdentifier,disabled:!d.href&&typeof d.invoke!="function",...d,_zeyos:h})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,U(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,c]of Object.entries(i.modules??{}))o([a,c]);return r}function xe(i,t={}){let e=String(t.query??""),s=ui(t.labels),n=Ma(i,e),r=new Map;return n.flatMap(({raw:o,group:a},c)=>{let u=Ta(o,a,e);if(!u)return[];let h=e===""?s.recent:u.group===""?s.results:s.entities[u.group]??u.group;r.has(h)||r.set(h,r.size+1);let d=_n(u.raw,t.resolveRecord);return[{id:`record:${u.entity}:${u.fork??""}:${u.ID}`,label:u.name,description:u.sec,keywords:[u.entity,u.ID,u.fork??""],group:h,groupOrder:r.get(h),itemOrder:c,kind:"record",when:e===""?"empty":"query",icon:()=>(typeof t.renderRecordIcon=="function"?t.renderRecordIcon(u.raw,u):null)??ct(u.entity,{size:28,standard:!!t.standardIcons}),disabled:!d.href&&typeof d.invoke!="function",...d,_zeyos:u}]})}function Da(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function Ia(i,t,e){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:ci(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:ci(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??t??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??e??U(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:ci(i.color)}}function Ma(i,t){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let e=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){e.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};e.push({raw:o,group:s})}return e}function Ta(i,t,e){return Array.isArray(i)?e===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??t??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??t??"")}}function _n(i,t){let e=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof t=="function"?t(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??e[r];return o===void 0?[]:[[r,o]]}))}function ci(i){let t=String(i??"").trim();if(!t)return null;let e=t.startsWith("#")?t:`#${t}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(e)?e:null}function ui(i){let t=i&&typeof i=="object"?i:{};return{applications:String(t.applications??"Applications"),recent:String(t.recent??"Recent"),results:String(t.results??"Top results"),entities:t.entities&&typeof t.entities=="object"?t.entities:{},move:String(t.move??"Move"),open:String(t.open??"Open"),close:String(t.close??"Close")}}function Nt(i,t,e={}){let{fields:s,labelKey:n=vn(i,t),valueKey:r="ID",searchFields:o=wn(i,t),limit:a=50,filters:c={},value:u=null,...h}=e,d=X(i),p=s??xn(r,n,o);return{...h,valueKey:r,labelKey:n,value:u,filter:async f=>{let m=await d.list(t,ut({search:f,filters:c,fields:p,searchFields:o,limit:a}));return hi(i,m).data}}}function Ea(i,t,e={}){let s=Nt(i,t,e),n=e.value??null,r=new F(null,s);return r.ready=yn(r,i,t,n),r}function bn(i,t,e={}){let{fields:s,labelKey:n=vn(i,t),valueKey:r="ID",searchFields:o=wn(i,t),subtitleKey:a=null,moduleKey:c=()=>t,groupKey:u=null,none:h=!0,recent:d=[],create:p=!1,renderIcon:f=La,renderItem:m,renderValueAdornment:g,...b}=e,z=s??xn(r,n,[...o,...[a,c,u].filter(v=>typeof v=="string")]),k=Nt(i,t,{...b,fields:z,labelKey:n,valueKey:r,searchFields:o,groupKey:u,clearable:h===!1?!!b.clearable:!0});k.recent=Array.isArray(d)?d:[];let T=(v,A=!1)=>{if(f===null)return null;let I=ve(v,c)??t;return f(v,{resource:t,module:String(I),selected:A})};if(k.renderItem=m??(v=>{let A=T(v);return l("span",{class:"zx-select__entity"},A?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(ve(v,n)??"")),a&&ve(v,a)!=null?l("span",{class:"zx-select__entity-subtitle"},String(ve(v,a))):null))}),k.renderValueAdornment=g??(v=>T(v,!0)),h!==!1&&(k.noneLabel=typeof h=="string"?h:b.noneLabel??"No selection",k.renderNone=b.renderNone??(v=>l("span",{class:"zx-select__entity-none"},l("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),l("span",{},v)))),p){let v=p===!0?{}:p,A=typeof v.oninvoke=="function"?v.oninvoke:null;k.actions=[...Array.isArray(k.actions)?k.actions:[],{id:v.id??"create",label:v.label??"Create new\u2026",group:v.group??"New",icon:v.icon??"plus",invoke:I=>A?.({...I,resource:t})}]}return k}function Na(i,t,e={}){let s=bn(i,t,e),n=e.value??null,r=F.entity(null,s);return r.ready=yn(r,i,t,n),r}function hi(i,t){return typeof i?.normalizeListResult=="function"?gn(i.normalizeListResult(t)):gn(t)}function gn(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let t=Array.isArray(i.data)?i.data:[],e=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(e)?{data:t,count:e}:{data:t}}async function yn(i,t,e,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await X(t).get(e,s),r=Fa(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function Fa(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS get operation did not return a record")}function ve(i,t){return typeof t=="function"?t(i):i&&typeof i=="object"&&typeof t=="string"?i[t]:null}function La(i,t){return ct(String(t.module??"default"),{size:20})}function xn(i,t,e){let s=[i,t,...e].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function vn(i,t){let e=Oa(i,t);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(e.includes(s))return s;return e[0]??"ID"}function wn(i,t){let e=i?.schema?.describe?.(t)?.fields;return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function Oa(i,t){let e=i?.schema?.fields?.(t);if(Array.isArray(e))return e.map(String);if(e&&typeof e=="object")return Object.keys(e);let s=i?.schema?.describe?.(t)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function Ra(i,t,e={}){let s=xt(i,t,e),n={},r=[];for(let o of s){let a=Ot(o),c=a.type==="zxselect"&&typeof a.props?.entity=="string"?a.props.entity:null;c&&(r.push({id:String(o.id),resource:c}),a.props={...Nt(i,c,{clearable:!a.required,placeholder:`Select ${String(a.label).toLowerCase()}`})}),n[String(o.id)]=a}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(e.title??""),columns:Ba(e.columns),fields:n}]},mapFromRecord:o=>qa(o,s),mapToRecord:o=>Va(o,s)}}function ja(i,t,e={}){if(e.onSaved!=null&&typeof e.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=Ra(i,t,e),n=X(i),r=new Mt(null,s.formOptions),o=e.value?.ID??e.id??null,a=!1,c=null,u=async f=>{if(!f||typeof f!="object"||Array.isArray(f))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(s.entityFields.map(async({id:m,resource:g})=>{let b=f[m];if(b==null)return;let z=b&&typeof b=="object"?b:di(await n.get(g,b)),k=F.from(r.getField(m)?.getInput());k instanceof F&&k.setItems([z])})),a||r.setValues(s.mapFromRecord(f),{silent:!0}),f},h=async f=>{if(f==null||f==="")throw new TypeError("zeyosForm.load() requires an id");let m=di(await n.get(t,f));return o=m.ID??f,await u(m),m},d=()=>a?Promise.reject(new Error("Cannot save a destroyed ZeyOS form")):c||(r.submit()?(c=(async()=>{let f;try{f=s.mapToRecord(r.getValues()),delete f.ID}catch(b){throw n.reportError(b,{operation:"serialize",resource:t}),b}let m=o==null?await n.create(t,f):await n.update(t,{ID:o,...f}),g=di(m);if(o=g.ID??o,e.onSaved)try{await e.onSaved(g)}catch(b){throw n.reportError(b,{operation:"onSaved",resource:t}),b}return at.success(`${$a(g,t)} saved successfully.`),g})().finally(()=>{c=null}),c):Promise.resolve(null)),p=Object.prototype.hasOwnProperty.call(e,"id")?h(e.id):e.value?u(e.value):Promise.resolve(null);return{form:r,ready:p,load:h,save:d,getForm:()=>r,destroy(){a||(a=!0,r.destroy())}}}function qa(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];e[n]=kn(s)&&r!=null&&r!==""?yt(r):r}return e}function Va(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];if(kn(s))r=r==null||r===""?null:J(r);else if(Pa(s)&&Ha(s.type)&&r!==""&&r!=null){let o=Number(r);Number.isFinite(o)&&(r=o)}e[n]=r}return e}function kn(i){let t=Ot(i);return t.type==="date"||t.type==="datetime"}function Pa(i){return i.enums!=null||i.enum!=null}function Ha(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Ba(i){let t=Number(i??2);return[1,2,3].includes(t)?t:2}function di(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS operation did not return a record")}function $a(i,t){for(let e of["transactionnum","name","lastname","customernum","number","ID"])if(i[e]!=null&&i[e]!=="")return String(i[e]);return String(t)}function Ka(i,t,e={}){let s=xt(i,t,{fields:e.fields,labels:e.labels}),n={},r=s.map(a=>{let c={...a},u=Ua(c);if(u){let p=Wa(i,u);c.labelField=`${c.id}_label`,n[c.labelField]=`${c.id}.${p}`}n[c.id]=c.id;let h=Qa(c),d=Se(h?{...c,format:"money"}:c);return h&&(d.render=p=>Za(p?.[c.id],p?.currency),Ga(i,t,"currency")&&(n.currency="currency")),d}),o=e.rowId??"ID";return typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o),{fieldMeta:s,columns:r,projection:n,tableOptions:{columns:r,data:[],rowId:o,sort:e.sort??null,sortMode:"server",selectable:e.selectable??!1,height:e.height??null,onrowclick:typeof e.onRowClick=="function"?a=>e.onRowClick(a.detail.row,a):void 0}}}function Ya(i,t,e={}){let s=Ka(i,t,e),n=X(i),r=new Dt(null,s.tableOptions),o=Xa(e.pageSize),a=e.sort??null,c=Sn(e.filters??{}),u=String(e.search??""),h=0,d=null,p=!1,f=0,m=async(b={})=>{Object.prototype.hasOwnProperty.call(b,"search")&&(u=String(b.search??"")),Object.prototype.hasOwnProperty.call(b,"filters")&&(c=Sn(b.filters??{}));let z=Ja(b.page??0),k=ut({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:z*o,count:!0}),T=++f;r.setLoading(!0);try{let v=hi(i,await n.list(t,k)),A=v.count??null,I=A==null?v.data.length===o:z*o+v.data.length<A;return T===f&&(h=z,d=A,p=I,z===0?r.setData(v.data):r.addData(v.data)),{data:v.data,count:A,page:z,hasMore:I,query:k}}finally{T===f&&r.setLoading(!1)}},g={table:r,load:m,setSearch:b=>m({search:b,page:0}),setFilters:b=>m({filters:b,page:0}),loadMore:()=>p?m({page:h+1}):Promise.resolve({data:[],count:d,page:h,hasMore:!1,query:ut({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:h*o,count:!0})}),get count(){return d},get page(){return h},get hasMore(){return p},destroy:()=>r.destroy()};return r.on("sort",b=>{a={id:String(b.detail.id),dir:b.detail.dir==="desc"?"desc":"asc"},m({page:0}).catch(()=>{})}),g}function Ua(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Wa(i,t){let e=i?.schema?.fields?.(t),s=Array.isArray(e)?e.map(String):Object.keys(e??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Qa(i){let t=String(i.format??"").toLowerCase();return/money|currency|price/.test(t)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Za(i,t){if(i==null||i==="")return"";let e=Number(i);if(!Number.isFinite(e))return"";let s=typeof t=="string"&&/^[A-Z]{3}$/.test(t)?t:null;try{return new Intl.NumberFormat(void 0,s?{style:"currency",currency:s}:{}).format(e)}catch{return new Intl.NumberFormat().format(e)}}function Ga(i,t,e){let s=i?.schema?.fields?.(t);return Array.isArray(s)?s.includes(e):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,e))}function Xa(i){let t=Number(i??50);return Number.isInteger(t)&&t>0?t:50}function Ja(i){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError("ZeyOS table page must be a non-negative integer");return t}function Sn(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS table filters must be an object");return{...i}}export{dn as ZEYOS_ICON_KIT,za as ZEYOS_LAUNCHER_APPLICATIONS,ut as buildListQuery,bn as buildZeyosEntitySelectConfig,pn as buildZeyosLauncherConfig,Nt as buildZeyosSelectConfig,X as connect,An as dataFilterStateToFilters,J as dateToUnixSeconds,Se as fieldToZxColumn,Ot as fieldToZxField,hn as moduleAliases,ct as moduleChip,xa as moduleColor,ye as moduleGlyphColor,fn as moduleIcon,va as moduleIconName,U as moduleInfo,wa as moduleKeys,be as normalizeModuleName,mn as normalizeZeyosLauncherApplications,xe as normalizeZeyosLauncherRecords,E as registerFieldType,ka as registerModules,xt as resolveFields,fi as tableSortToQuery,yt as unixSecondsToDate,Sa as useZeyosIcons,Da as zeyosActiveIdentifier,Aa as zeyosAppIcon,Na as zeyosEntitySelect,ja as zeyosForm,Ca as zeyosLauncher,lt as zeyosModules,Ea as zeyosSelect,Ya as zeyosTable};
|