zui.zentao.js 1016 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var Hb=(I,St,hn)=>{if(!St.has(I))throw TypeError("Cannot "+hn)};var fr=(I,St,hn)=>(Hb(I,St,"read from private field"),hn?hn.call(I):St.get(I)),Yf=(I,St,hn)=>{if(St.has(I))throw TypeError("Cannot add the same private member more than once");St instanceof WeakSet?St.add(I):St.set(I,hn)},pr=(I,St,hn,Rc)=>(Hb(I,St,"write to private field"),Rc?Rc.call(I,hn):St.set(I,hn),hn);(function(I,St){typeof exports=="object"&&typeof module<"u"?St(exports):typeof define=="function"&&define.amd?define(["exports"],St):(I=typeof globalThis<"u"?globalThis:I||self,St(I.zui={}))})(this,function(I){var Ns,Es,ab,lb;"use strict";const St="",hn="",Rc="",Z$="",Y$="",J$="",X$="",Q$="",eD="",tD="",nD="",sD="",zc="3.0.0",ip="production",rp="9f5350cb807b5a2e7f403dffd2c6fedf6518a973",Wn=document,Bo=window,op=Wn.documentElement,js=Wn.createElement.bind(Wn),ap=js("div"),Fc=js("table"),rw=js("tbody"),lp=js("tr"),{isArray:jo,prototype:cp}=Array,{concat:ow,filter:Oc,indexOf:hp,map:dp,push:aw,slice:up,some:Bc,splice:lw}=cp,cw=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,hw=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,dw=/<.+>/,uw=/^\w+$/;function jc(i,e){const t=fw(e);return!i||!t&&!Hs(e)&&!yt(e)?[]:!t&&hw.test(i)?e.getElementsByClassName(i.slice(1).replace(/\\/g,"")):!t&&uw.test(i)?e.getElementsByTagName(i):e.querySelectorAll(i)}class Ho{constructor(e,t){if(!e)return;if(Hc(e))return e;let n=e;if(Lt(e)){const s=t||Wn;if(n=cw.test(e)&&Hs(s)?s.getElementById(e.slice(1).replace(/\\/g,"")):dw.test(e)?vp(e):Hc(s)?s.find(e):Lt(s)?v(s).find(e):jc(e,s),!n)return}else if(Us(e))return this.ready(e);(n.nodeType||n===Bo)&&(n=[n]),this.length=n.length;for(let s=0,r=this.length;s<r;s++)this[s]=n[s]}init(e,t){return new Ho(e,t)}}const ce=Ho.prototype,v=ce.init;v.fn=v.prototype=ce,ce.length=0,ce.splice=lw,typeof Symbol=="function"&&(ce[Symbol.iterator]=cp[Symbol.iterator]);function Hc(i){return i instanceof Ho}function xi(i){return!!i&&i===i.window}function Hs(i){return!!i&&i.nodeType===9}function fw(i){return!!i&&i.nodeType===11}function yt(i){return!!i&&i.nodeType===1}function pw(i){return!!i&&i.nodeType===3}function mw(i){return typeof i=="boolean"}function Us(i){return typeof i=="function"}function Lt(i){return typeof i=="string"}function Vt(i){return i===void 0}function yr(i){return i===null}function fp(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Uc(i){if(typeof i!="object"||i===null)return!1;const e=Object.getPrototypeOf(i);return e===null||e===Object.prototype}v.isWindow=xi,v.isFunction=Us,v.isArray=jo,v.isNumeric=fp,v.isPlainObject=Uc;function Tt(i,e,t){if(t){let n=i.length;for(;n--;)if(e.call(i[n],n,i[n])===!1)return i}else if(Uc(i)){const n=Object.keys(i);for(let s=0,r=n.length;s<r;s++){const o=n[s];if(e.call(i[o],o,i[o])===!1)return i}}else for(let n=0,s=i.length;n<s;n++)if(e.call(i[n],n,i[n])===!1)return i;return i}v.each=Tt,ce.each=function(i){return Tt(this,i)},ce.empty=function(){return this.each((i,e)=>{for(;e.firstChild;)e.removeChild(e.firstChild)})};function Uo(...i){const e=mw(i[0])?i.shift():!1,t=i.shift(),n=i.length;if(!t)return{};if(!n)return Uo(e,v,t);for(let s=0;s<n;s++){const r=i[s];for(const o in r)e&&(jo(r[o])||Uc(r[o]))?((!t[o]||t[o].constructor!==r[o].constructor)&&(t[o]=new r[o].constructor),Uo(e,t[o],r[o])):t[o]=r[o]}return t}v.extend=Uo,ce.extend=function(i){return Uo(ce,i)};const gw=/\S+/g;function Vo(i){return Lt(i)?i.match(gw)||[]:[]}ce.toggleClass=function(i,e){const t=Vo(i),n=!Vt(e);return this.each((s,r)=>{yt(r)&&Tt(t,(o,a)=>{n?e?r.classList.add(a):r.classList.remove(a):r.classList.toggle(a)})})},ce.addClass=function(i){return this.toggleClass(i,!0)},ce.removeAttr=function(i){const e=Vo(i);return this.each((t,n)=>{yt(n)&&Tt(e,(s,r)=>{n.removeAttribute(r)})})};function yw(i,e){if(i){if(Lt(i)){if(arguments.length<2){if(!this[0]||!yt(this[0]))return;const t=this[0].getAttribute(i);return yr(t)?void 0:t}return Vt(e)?this:yr(e)?this.removeAttr(i):this.each((t,n)=>{yt(n)&&n.setAttribute(i,e)})}for(const t in i)this.attr(t,i[t]);return this}}ce.attr=yw,ce.removeClass=function(i){return arguments.length?this.toggleClass(i,!1):this.attr("class","")},ce.hasClass=function(i){return!!i&&Bc.call(this,e=>yt(e)&&e.classList.contains(i))},ce.get=function(i){return Vt(i)?up.call(this):(i=Number(i),this[i<0?i+this.length:i])},ce.eq=function(i){return v(this.get(i))},ce.first=function(){return this.eq(0)},ce.last=function(){return this.eq(-1)};function vw(i){return Vt(i)?this.get().map(e=>yt(e)||pw(e)?e.textContent:"").join(""):this.each((e,t)=>{yt(t)&&(t.textContent=i)})}ce.text=vw;function Kn(i,e,t){if(!yt(i))return;const n=Bo.getComputedStyle(i,null);return t?n.getPropertyValue(e)||void 0:n[e]||i.style[e]}function kn(i,e){return parseInt(Kn(i,e),10)||0}function pp(i,e){return kn(i,`border${e?"Left":"Top"}Width`)+kn(i,`padding${e?"Left":"Top"}`)+kn(i,`padding${e?"Right":"Bottom"}`)+kn(i,`border${e?"Right":"Bottom"}Width`)}const Vc={};function _w(i){if(Vc[i])return Vc[i];const e=js(i);Wn.body.insertBefore(e,null);const t=Kn(e,"display");return Wn.body.removeChild(e),Vc[i]=t!=="none"?t:"block"}function mp(i){return Kn(i,"display")==="none"}function gp(i,e){const t=i&&(i.matches||i.webkitMatchesSelector||i.msMatchesSelector);return!!t&&!!e&&t.call(i,e)}function Wo(i){return Lt(i)?(e,t)=>gp(t,i):Us(i)?i:Hc(i)?(e,t)=>i.is(t):i?(e,t)=>t===i:()=>!1}ce.filter=function(i){const e=Wo(i);return v(Oc.call(this,(t,n)=>e.call(t,n,t)))};function us(i,e){return e?i.filter(e):i}ce.detach=function(i){return us(this,i).each((e,t)=>{t.parentNode&&t.parentNode.removeChild(t)}),this};const bw=/^\s*<(\w+)[^>]*>/,ww=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,yp={"*":ap,tr:rw,td:lp,th:lp,thead:Fc,tbody:Fc,tfoot:Fc};function vp(i){if(!Lt(i))return[];if(ww.test(i))return[js(RegExp.$1)];const e=bw.test(i)&&RegExp.$1,t=yp[e]||yp["*"];return t.innerHTML=i,v(t.childNodes).detach().get()}v.parseHTML=vp,ce.has=function(i){const e=Lt(i)?(t,n)=>jc(i,n).length:(t,n)=>n.contains(i);return this.filter(e)},ce.not=function(i){const e=Wo(i);return this.filter((t,n)=>(!Lt(i)||yt(n))&&!e.call(n,t,n))};function qn(i,e,t,n){const s=[],r=Us(e),o=n&&Wo(n);for(let a=0,l=i.length;a<l;a++)if(r){const c=e(i[a]);c.length&&aw.apply(s,c)}else{let c=i[a][e];for(;c!=null&&!(n&&o(-1,c));)s.push(c),c=t?c[e]:null}return s}function _p(i){return i.multiple&&i.options?qn(Oc.call(i.options,e=>e.selected&&!e.disabled&&!e.parentNode.disabled),"value"):i.value||""}function Cw(i){return arguments.length?this.each((e,t)=>{const n=t.multiple&&t.options;if(n||Mp.test(t.type)){const s=jo(i)?dp.call(i,String):yr(i)?[]:[String(i)];n?Tt(t.options,(r,o)=>{o.selected=s.indexOf(o.value)>=0},!0):t.checked=s.indexOf(t.value)>=0}else t.value=Vt(i)||yr(i)?"":i}):this[0]&&_p(this[0])}ce.val=Cw,ce.is=function(i){const e=Wo(i);return Bc.call(this,(t,n)=>e.call(t,n,t))},v.guid=1;function Sn(i){return i.length>1?Oc.call(i,(e,t,n)=>hp.call(n,e)===t):i}v.unique=Sn,ce.add=function(i,e){return v(Sn(this.get().concat(v(i,e).get())))},ce.children=function(i){return us(v(Sn(qn(this,e=>e.children))),i)},ce.parent=function(i){return us(v(Sn(qn(this,"parentNode"))),i)},ce.index=function(i){const e=i?v(i)[0]:this[0],t=i?this:v(e).parent().children();return hp.call(t,e)},ce.closest=function(i){const e=this.filter(i);if(e.length)return e;const t=this.parent();return t.length?t.closest(i):e},ce.siblings=function(i){return us(v(Sn(qn(this,e=>v(e).parent().children().not(e)))),i)},ce.find=function(i){return v(Sn(qn(this,e=>jc(i,e))))};const xw=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,kw=/^$|^module$|\/(java|ecma)script/i,Sw=["type","src","nonce","noModule"];function Tw(i,e){const t=v(i);t.filter("script").add(t.find("script")).each((n,s)=>{if(kw.test(s.type)&&op.contains(s)){const r=js("script");r.text=s.textContent.replace(xw,""),Tt(Sw,(o,a)=>{s[a]&&(r[a]=s[a])}),e.head.insertBefore(r,null),e.head.removeChild(r)}})}function $w(i,e,t,n,s){n?i.insertBefore(e,t?i.firstChild:null):i.nodeName==="HTML"?i.parentNode.replaceChild(e,i):i.parentNode.insertBefore(e,t?i:i.nextSibling),s&&Tw(e,i.ownerDocument)}function fs(i,e,t,n,s,r,o,a){return Tt(i,(l,c)=>{Tt(v(c),(h,d)=>{Tt(v(e),(f,p)=>{const y=t?d:p,b=t?p:d,w=t?h:f;$w(y,w?b.cloneNode(!0):b,n,s,!w)},a)},o)},r),e}ce.after=function(){return fs(arguments,this,!1,!1,!1,!0,!0)},ce.append=function(){return fs(arguments,this,!1,!1,!0)};function Dw(i){if(!arguments.length)return this[0]&&this[0].innerHTML;if(Vt(i))return this;const e=/<script[\s>]/.test(i);return this.each((t,n)=>{yt(n)&&(e?v(n).empty().append(i):n.innerHTML=i)})}ce.html=Dw,ce.appendTo=function(i){return fs(arguments,this,!0,!1,!0)},ce.wrapInner=function(i){return this.each((e,t)=>{const n=v(t),s=n.contents();s.length?s.wrapAll(i):n.append(i)})},ce.before=function(){return fs(arguments,this,!1,!0)},ce.wrapAll=function(i){let e=v(i),t=e[0];for(;t.children.length;)t=t.firstElementChild;return this.first().before(e),this.appendTo(t)},ce.wrap=function(i){return this.each((e,t)=>{const n=v(i)[0];v(t).wrapAll(e?n.cloneNode(!0):n)})},ce.insertAfter=function(i){return fs(arguments,this,!0,!1,!1,!1,!1,!0)},ce.insertBefore=function(i){return fs(arguments,this,!0,!0)},ce.prepend=function(){return fs(arguments,this,!1,!0,!0,!0,!0)},ce.prependTo=function(i){return fs(arguments,this,!0,!0,!0,!1,!1,!0)},ce.contents=function(){return v(Sn(qn(this,i=>i.tagName==="IFRAME"?[i.contentDocument]:i.tagName==="TEMPLATE"?i.content.childNodes:i.childNodes)))},ce.next=function(i,e,t){return us(v(Sn(qn(this,"nextElementSibling",e,t))),i)},ce.nextAll=function(i){return this.next(i,!0)},ce.nextUntil=function(i,e){return this.next(e,!0,i)},ce.parents=function(i,e){return us(v(Sn(qn(this,"parentElement",!0,e))),i)},ce.parentsUntil=function(i,e){return this.parents(e,i)},ce.prev=function(i,e,t){return us(v(Sn(qn(this,"previousElementSibling",e,t))),i)},ce.prevAll=function(i){return this.prev(i,!0)},ce.prevUntil=function(i,e){return this.prev(e,!0,i)},ce.map=function(i){return v(ow.apply([],dp.call(this,(e,t)=>i.call(e,t,e))))},ce.clone=function(){return this.map((i,e)=>e.cloneNode(!0))},ce.offsetParent=function(){return this.map((i,e)=>{let t=e.offsetParent;for(;t&&Kn(t,"position")==="static";)t=t.offsetParent;return t||op})},ce.slice=function(i,e){return v(up.call(this,i,e))};const Iw=/-([a-z])/g;function Wc(i){return i.replace(Iw,(e,t)=>t.toUpperCase())}ce.ready=function(i){const e=()=>setTimeout(i,0,v);return Wn.readyState!=="loading"?e():Wn.addEventListener("DOMContentLoaded",e),this},ce.unwrap=function(){return this.parent().each((i,e)=>{if(e.tagName==="BODY")return;const t=v(e);t.replaceWith(t.children())}),this},ce.offset=function(){const i=this[0];if(!i)return;const e=i.getBoundingClientRect();return{top:e.top+Bo.pageYOffset,left:e.left+Bo.pageXOffset}},ce.position=function(){const i=this[0];if(!i)return;const e=Kn(i,"position")==="fixed",t=e?i.getBoundingClientRect():this.offset();if(!e){const n=i.ownerDocument;let s=i.offsetParent||n.documentElement;for(;(s===n.body||s===n.documentElement)&&Kn(s,"position")==="static";)s=s.parentNode;if(s!==i&&yt(s)){const r=v(s).offset();t.top-=r.top+kn(s,"borderTopWidth"),t.left-=r.left+kn(s,"borderLeftWidth")}}return{top:t.top-kn(i,"marginTop"),left:t.left-kn(i,"marginLeft")}};const bp={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};ce.prop=function(i,e){if(i){if(Lt(i))return i=bp[i]||i,arguments.length<2?this[0]&&this[0][i]:this.each((t,n)=>{n[i]=e});for(const t in i)this.prop(t,i[t]);return this}},ce.removeProp=function(i){return this.each((e,t)=>{delete t[bp[i]||i]})};const Mw=/^--/;function Kc(i){return Mw.test(i)}const qc={},{style:Nw}=ap,Ew=["webkit","moz","ms"];function Aw(i,e=Kc(i)){if(e)return i;if(!qc[i]){const t=Wc(i),n=`${t[0].toUpperCase()}${t.slice(1)}`,s=`${t} ${Ew.join(`${n} `)}${n}`.split(" ");Tt(s,(r,o)=>{if(o in Nw)return qc[i]=o,!1})}return qc[i]}const Pw={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function wp(i,e,t=Kc(i)){return!t&&!Pw[i]&&fp(e)?`${e}px`:e}function Lw(i,e){if(Lt(i)){const t=Kc(i);return i=Aw(i,t),arguments.length<2?this[0]&&Kn(this[0],i,t):i?(e=wp(i,e,t),this.each((n,s)=>{yt(s)&&(t?s.style.setProperty(i,e):s.style[i]=e)})):this}for(const t in i)this.css(t,i[t]);return this}ce.css=Lw;function Cp(i,e){try{return i(e)}catch{return e}}const Rw=/^\s+|\s+$/;function xp(i,e){const t=i.dataset[e]||i.dataset[Wc(e)];return Rw.test(t)?t:Cp(JSON.parse,t)}function zw(i,e,t){t=Cp(JSON.stringify,t),i.dataset[Wc(e)]=t}function Fw(i,e){if(!i){if(!this[0])return;const t={};for(const n in this[0].dataset)t[n]=xp(this[0],n);return t}if(Lt(i))return arguments.length<2?this[0]&&xp(this[0],i):Vt(e)?this:this.each((t,n)=>{zw(n,i,e)});for(const t in i)this.data(t,i[t]);return this}ce.data=Fw;function kp(i,e){const t=i.documentElement;return Math.max(i.body[`scroll${e}`],t[`scroll${e}`],i.body[`offset${e}`],t[`offset${e}`],t[`client${e}`])}Tt([!0,!1],(i,e)=>{Tt(["Width","Height"],(t,n)=>{const s=`${e?"outer":"inner"}${n}`;ce[s]=function(r){if(this[0])return xi(this[0])?e?this[0][`inner${n}`]:this[0].document.documentElement[`client${n}`]:Hs(this[0])?kp(this[0],n):this[0][`${e?"offset":"client"}${n}`]+(r&&e?kn(this[0],`margin${t?"Top":"Left"}`)+kn(this[0],`margin${t?"Bottom":"Right"}`):0)}})}),Tt(["Width","Height"],(i,e)=>{const t=e.toLowerCase();ce[t]=function(n){if(!this[0])return Vt(n)?void 0:this;if(!arguments.length)return xi(this[0])?this[0].document.documentElement[`client${e}`]:Hs(this[0])?kp(this[0],e):this[0].getBoundingClientRect()[t]-pp(this[0],!i);const s=parseInt(n,10);return this.each((r,o)=>{if(!yt(o))return;const a=Kn(o,"boxSizing");o.style[t]=wp(t,s+(a==="border-box"?pp(o,!i):0))})}});const Sp="___cd";ce.toggle=function(i){return this.each((e,t)=>{if(!yt(t))return;const n=mp(t);(Vt(i)?n:i)?(t.style.display=t[Sp]||"",mp(t)&&(t.style.display=_w(t.tagName))):n||(t[Sp]=Kn(t,"display"),t.style.display="none")})},ce.hide=function(){return this.toggle(!1)},ce.show=function(){return this.toggle(!0)};const Tp="___ce",Gc=".",Zc={focus:"focusin",blur:"focusout"},$p={mouseenter:"mouseover",mouseleave:"mouseout"},Ow=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Yc(i){return $p[i]||Zc[i]||i}function Jc(i){const e=i.split(Gc);return[e[0],e.slice(1).sort()]}ce.trigger=function(i,e){if(Lt(i)){const[n,s]=Jc(i),r=Yc(n);if(!r)return this;const o=Ow.test(r)?"MouseEvents":"HTMLEvents";i=Wn.createEvent(o),i.initEvent(r,!0,!0),i.namespace=s.join(Gc),i.___ot=n}i.___td=e;const t=i.___ot in Zc;return this.each((n,s)=>{t&&Us(s[i.___ot])&&(s[`___i${i.type}`]=!0,s[i.___ot](),s[`___i${i.type}`]=!1),s.dispatchEvent(i)})};function Dp(i){return i[Tp]=i[Tp]||{}}function Bw(i,e,t,n,s){const r=Dp(i);r[e]=r[e]||[],r[e].push([t,n,s]),i.addEventListener(e,s)}function Ip(i,e){return!e||!Bc.call(e,t=>i.indexOf(t)<0)}function Ko(i,e,t,n,s){const r=Dp(i);if(e)r[e]&&(r[e]=r[e].filter(([o,a,l])=>{if(s&&l.guid!==s.guid||!Ip(o,t)||n&&n!==a)return!0;i.removeEventListener(e,l)}));else for(e in r)Ko(i,e,t,n,s)}ce.off=function(i,e,t){if(Vt(i))this.each((n,s)=>{!yt(s)&&!Hs(s)&&!xi(s)||Ko(s)});else if(Lt(i))Us(e)&&(t=e,e=""),Tt(Vo(i),(n,s)=>{const[r,o]=Jc(s),a=Yc(r);this.each((l,c)=>{!yt(c)&&!Hs(c)&&!xi(c)||Ko(c,a,o,e,t)})});else for(const n in i)this.off(n,i[n]);return this},ce.remove=function(i){return us(this,i).detach().off(),this},ce.replaceWith=function(i){return this.before(i).remove()},ce.replaceAll=function(i){return v(i).replaceWith(this),this};function jw(i,e,t,n,s){if(!Lt(i)){for(const r in i)this.on(r,e,t,i[r],s);return this}return Lt(e)||(Vt(e)||yr(e)?e="":Vt(t)?(t=e,e=""):(n=t,t=e,e="")),Us(n)||(n=t,t=void 0),n?(Tt(Vo(i),(r,o)=>{const[a,l]=Jc(o),c=Yc(a),h=a in $p,d=a in Zc;c&&this.each((f,p)=>{if(!yt(p)&&!Hs(p)&&!xi(p))return;const y=function(b){if(b.target[`___i${b.type}`])return b.stopImmediatePropagation();if(b.namespace&&!Ip(l,b.namespace.split(Gc))||!e&&(d&&(b.target!==p||b.___ot===c)||h&&b.relatedTarget&&p.contains(b.relatedTarget)))return;let w=p;if(e){let T=b.target;for(;!gp(T,e);)if(T===p||(T=T.parentNode,!T))return;w=T}Object.defineProperty(b,"currentTarget",{configurable:!0,get(){return w}}),Object.defineProperty(b,"delegateTarget",{configurable:!0,get(){return p}}),Object.defineProperty(b,"data",{configurable:!0,get(){return t}});const x=n.call(w,b,b.___td);s&&Ko(p,c,l,e,y),x===!1&&(b.preventDefault(),b.stopPropagation())};y.guid=n.guid=n.guid||v.guid++,Bw(p,c,l,e,y)})}),this):this}ce.on=jw;function Hw(i,e,t,n){return this.on(i,e,t,n,!0)}ce.one=Hw;const Uw=/\r?\n/g;function Vw(i,e){return`&${encodeURIComponent(i)}=${encodeURIComponent(e.replace(Uw,`\r
  2. `))}`}const Ww=/file|reset|submit|button|image/i,Mp=/radio|checkbox/i;ce.serialize=function(){let i="";return this.each((e,t)=>{Tt(t.elements||[t],(n,s)=>{if(s.disabled||!s.name||s.tagName==="FIELDSET"||Ww.test(s.type)||Mp.test(s.type)&&!s.checked)return;const r=_p(s);if(!Vt(r)){const o=jo(r)?r:[r];Tt(o,(a,l)=>{i+=Vw(s.name,l)})}})}),i.slice(1)},window.$=v;function Np(i,e){if(i==null)return[i,void 0];typeof e=="string"&&(e=e.split("."));const t=e.join(".");let n=i;const s=[n];for(;typeof n=="object"&&n!==null&&e.length;){let r=e.shift(),o;const a=r.indexOf("[");if(a>0&&a<r.length-1&&r.endsWith("]")&&(o=r.substring(a+1,r.length-1),r=r.substring(0,a)),n=n[r],s.push(n),o!==void 0)if(typeof n=="object"&&n!==null)n instanceof Map?n=n.get(o):n=n[o],s.push(n);else throw new Error(`Cannot access property "${r}[${o}]", the full path is "${t}".`)}if(e.length)throw new Error(`Cannot access property with rest path "${e.join(".")}", the full path is "${t}".`);return s}function ki(i,e,t,n){typeof e=="string"&&(e=e.split("."));try{const s=Np(i,e),r=s.length,o=s[r-1];return n&&n(r>1?s[r-2]:i,e[e.length-1]),o===void 0?t:o}catch{return t}}function nn(i,e,t,n,s){let r;const o=ki(i,e,void 0,a=>{r=a});if(typeof o=="function")return o.apply(n??r,t);if(s)throw new Error(`Cannot call function "${Array.isArray(e)?e.join("."):e}" on object:`,i);return o}function Tn(i){return typeof i=="string"&&i!==""}function De(i,...e){if(e.length===0)return i;if(e.length===1&&typeof e[0]=="object"&&e[0]){const t=e[0];return Object.keys(t).forEach(n=>{const s=t[n]??"";i=i.replace(new RegExp(`\\{${n}\\}`,"g"),`${s}`)}),i}for(let t=0;t<e.length;t++){const n=e[t]??"";i=i.replace(new RegExp(`\\{${t}\\}`,"g"),`${n}`)}return i}var Xc=(i=>(i[i.B=1]="B",i[i.KB=1024]="KB",i[i.MB=1048576]="MB",i[i.GB=1073741824]="GB",i[i.TB=1099511627776]="TB",i))(Xc||{});function pt(i,e=2,t){return Number.isNaN(i)?"?KB":(t||(i<1024?t="B":i<1048576?t="KB":i<1073741824?t="MB":i<1099511627776?t="GB":t="TB"),(i/Xc[t]).toFixed(e)+t)}const $n=i=>{const e=/^[0-9]*(B|KB|MB|GB|TB)$/;i=i.toUpperCase(),i.endsWith("B")||(i+="B");const t=i.match(e);if(!t)return 0;const n=t[1];return i=i.replace(n,""),Number.parseInt(i,10)*Xc[n]},Gn=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),Ep=i=>{const e=encodeURIComponent(i).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(n,16)));return btoa(e)},Kw=i=>{const e=atob(i),t=Array.from(e).map(n=>`%${n.charCodeAt(0).toString(16).padStart(2,"0").toUpperCase()}`).join("");return decodeURIComponent(t)};let Qc=(document.documentElement.getAttribute("lang")||"zh_cn").toLowerCase().replace("-","_"),Zn;function Ap(){return Qc}function qw(i){Qc=i.toLowerCase().replace("-","_")}function Pp(i,e){Zn||(Zn={}),typeof i=="string"&&(i={[i]:e??{}}),v.extend(!0,Zn,i)}function be(i,e,t,n,s,r){Array.isArray(i)?Zn&&i.unshift(Zn):i=Zn?[Zn,i]:[i],typeof t=="string"&&(r=s,s=n,n=t,t=void 0);const o=s||Qc;let a;for(const l of i){if(!l)continue;const c=l[o]||l.default;if(!c)continue;const h=r&&l===Zn?`${r}.${e}`:e;if(a=ki(c,h),a!==void 0)break}return a===void 0?n:t?De(a,...Array.isArray(t)?t:[t]):a}function Gw(i,e,t,n){return be(void 0,i,e,t,n)}be.addLang=Pp,be.getLang=Gw,be.getCode=Ap,be.setCode=qw,be.map=Zn,Pp({zh_cn:{confirm:"确定",save:"保存",cancel:"取消",delete:"删除",reset:"重置",add:"添加",copy:"复制",close:"关闭",edit:"编辑",open:"打开",more:"更多",loading:"加载中..."},zh_tw:{confirm:"確定",save:"儲存",cancel:"取消",delete:"刪除",reset:"重置",add:"添加",Copy:"複製",close:"關閉",edit:"編輯",open:"打開",more:"更多",loading:"加載中..."},en:{confirm:"Confirm",save:"Save",cancel:"Cancel",delete:"Delete",reset:"Reset",add:"Add",copy:"Copy",close:"Close",edit:"Edit",open:"Open",more:"More",loading:"Loading..."}});function Vs(i,e,t){t!=null&&(Array.isArray(t)?t.forEach(n=>Vs(i,e,n)):!(t instanceof Blob)&&v.isPlainObject(t)?Object.entries(t).forEach(([n,s])=>{Vs(i,`${e}[${n}]`,s)}):i.append(e,t instanceof Blob?t:String(t)))}function vr(i,e){const t=e||new FormData;return i&&(typeof i=="string"&&(i=new URLSearchParams(i)),i instanceof URLSearchParams?i.forEach((n,s)=>{Vs(t,s,n)}):Array.isArray(i)?i.forEach(([n,s])=>{Vs(t,n,s)}):i instanceof FormData?i.forEach((n,s)=>{Vs(t,s,n)}):typeof i=="object"&&i&&Object.entries(i).forEach(([n,s])=>{Vs(t,n,s)})),t}function Xe(){return v.guid++}function _r(i,e){if(i===e)return!1;if(i&&e){const t=typeof i,n=typeof e;if(t!==n)return!0;if(t==="object"&&n==="object"){const s=Array.isArray(i),r=Array.isArray(e);if(s!==r)return!0;if(s&&r){if(i.length!==e.length)return!0;for(let l=0;l<i.length;l++)if(_r(i[l],e[l]))return!0;return!1}const o=Object.keys(i),a=Object.keys(e);if(o.length!==a.length)return!0;for(const l of o)if(_r(i[l],e[l]))return!0;return!1}if(t==="function"&&n==="function")return i.toString()!==e.toString()}return i!==e}class Ws{constructor(e,t){this._compute=e,this._dependencies=t}get value(){return this.compute()}get cache(){return this._lastDependencies?this._value:this.compute()}depends(e){return this._dependencies=e,this}forceCompute(e){return this._lastDependencies=void 0,this.compute(e)}compute(e){e!==void 0&&(this._dependencies=e),e=this._dependencies,typeof e=="function"&&(e=e());const t=this._lastDependencies;return(!t||e.some((n,s)=>n instanceof Ws?n.value!==t[s]:_r(n,t[s])))&&(this._value=this._compute(),this._lastDependencies=e.map(n=>n instanceof Ws?n.cache:n)),this._value}}function eh(...i){const e=[],t=new Map,n=(s,r)=>{if(Array.isArray(s)&&(r=s[1],s=s[0]),!s.length)return;const o=t.get(s);typeof o=="number"?e[o][1]=!!r:(t.set(s,e.length),e.push([s,!!r]))};return i.forEach(s=>{typeof s=="function"&&(s=s()),Array.isArray(s)?eh(...s).forEach(n):s&&typeof s=="object"?Object.entries(s).forEach(n):typeof s=="string"&&s.split(" ").forEach(r=>n(r,!0))}),e.sort((s,r)=>(t.get(s[0])||0)-(t.get(r[0])||0))}const U=(...i)=>eh(...i).reduce((e,[t,n])=>(n&&e.push(t),e),[]).join(" ");v.classes=U,v.fn.setClass=function(i,...e){return this.each((t,n)=>{const s=v(n);i===!0?s.attr("class",U(s.attr("class"),...e)):s.addClass(U(i,...e))})};const Si=new WeakMap;function qo(i,e,t){const n=Si.has(i),s=n?Si.get(i):{};typeof e=="string"?s[e]=t:e===null?Object.keys(s).forEach(r=>{delete s[r]}):Object.assign(s,e),Object.keys(s).forEach(r=>{s[r]===void 0&&delete s[r]}),Object.keys(s).length?(!n&&i instanceof Element&&Object.assign(s,v(i).dataset(),s),Si.set(i,s)):Si.delete(i)}function br(i,e,t){let n=Si.get(i)||{};return t&&i instanceof Element&&(n=Object.assign({},v(i).dataset(),n)),e===void 0?n:n[e]}function Zw(i){Si.delete(i)}v.fn.dataset=v.fn.data,v.fn.data=function(...i){const[e,t]=i;return!i.length||i.length===1&&typeof e=="string"?this.length?br(this[0],e,!0):void 0:this.each((n,s)=>qo(s,e,t))},v.fn.removeData=function(i=null){return this.each((e,t)=>qo(t,i))};function Yn(i,...e){return i.includes("RAWJS")&&(i=i.split('"RAWJS<').join("").split('>RAWJS"').join("").split("<RAWJS_QUOTE>").join('"').split("<RAWJS_LINE>").join(`
  3. `)),new Function(...e.map(([n])=>n),`return ${i}`)(...e.map(([,n])=>n))}function Go(i,...e){return i.includes("RAWJS")?Yn(i,...e):JSON.parse(i)}function Lp(i){return JSON.stringify(i,(e,t)=>typeof t=="function"?`RAWJS<${t.toString().split('"').join("<RAWJS_QUOTE>").split(`
  4. `).join("<RAWJS_LINE>")}>RAWJS`:t)}function Ti(i,e){const t=v(i),n=t[0];if(!n)return;const{prefix:s,getter:r,evalValue:o,json:a=!0,evalArgs:l=[["_element",n],["_$element",t]]}={prefix:"z-",...typeof e=="string"?{prefix:e}:e},c=Array.isArray(o)?new Set(o):void 0;return Array.from(n.attributes).reduce((h,d)=>{let{name:f}=d;const{value:p}=d;let y=p;if(f.startsWith(s)){if(f=f.slice(s.length).replace(/-([a-z])/g,b=>b[1].toUpperCase()),r)y=r(f,p);else try{o&&(!c||c.has(f))||o===void 0&&p.includes("RAWJS")?y=Yn(p,...l):a&&(y=JSON.parse(p))}catch{}h[f]=y}return h},{})}function th(i,e,t="z-"){const n=v(i);Object.keys(e).forEach(s=>{let r=e[s];typeof r=="function"&&(r=`RAWJS<${r}>RAWJS`),typeof r!="string"&&(r=JSON.stringify(r)),s=s.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`),n.attr(`${t}${s}`,r)})}function Yw(...i){var t;const e=i.length;if(!e)return Ti(this);if(e===1){const[n]=i;return typeof n=="string"?(t=Ti(this))==null?void 0:t[n]:(v.isPlainObject(n)&&th(this,n),this)}return th(this,{[i[0]]:i[1]}),this}v.fn.z=Yw,v.fn._attr=v.fn.attr,v.fn.extend({attr(...i){const[e,t]=i;return!i.length||i.length===1&&typeof e=="string"?this._attr.apply(this,i):typeof e=="object"?(e&&Object.keys(e).forEach(n=>{const s=e[n];s===null?this.removeAttr(n):this._attr(n,s)}),this):t===null?this.removeAttr(e):this._attr(e,t)}}),v.Event||(v.Event=(i,e)=>{const[t,...n]=i.split("."),s=new Event(t,{bubbles:!0,cancelable:!0});return s.namespace=n.join("."),s.___ot=t,s.___td=e,s});const Dn=(i,e)=>new Promise(t=>{const n=window.setTimeout(t,i);e&&e(n)}),Rp={};v.share=Rp;var Zo,tt,zp;I.isValidElement=void 0;var Ks,Fp,Op,Bp,jp,nh,sh,ih,wr={},Hp=[],Jw=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Cr=Array.isArray;function Jn(i,e){for(var t in e)i[t]=e[t];return i}function rh(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function g(i,e,t){var n,s,r,o={};for(r in e)r=="key"?n=e[r]:r=="ref"?s=e[r]:o[r]=e[r];if(arguments.length>2&&(o.children=arguments.length>3?Zo.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(r in i.defaultProps)o[r]===void 0&&(o[r]=i.defaultProps[r]);return Yo(i,o,n,s,null)}function Yo(i,e,t,n,s){var r={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++zp,__i:-1,__u:0};return s==null&&tt.vnode!=null&&tt.vnode(r),r}function pe(){return{current:null}}function ps(i){return i.children}function re(i,e){this.props=i,this.context=e}function $i(i,e){if(e==null)return i.__?$i(i.__,i.__i+1):null;for(var t;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null)return t.__e;return typeof i.type=="function"?$i(i):null}function Up(i){var e,t;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,e=0;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null){i.__e=i.__c.base=t.__e;break}return Up(i)}}function Vp(i){(!i.__d&&(i.__d=!0)&&Ks.push(i)&&!Jo.__r++||Fp!=tt.debounceRendering)&&((Fp=tt.debounceRendering)||Op)(Jo)}function Jo(){for(var i,e,t,n,s,r,o,a=1;Ks.length;)Ks.length>a&&Ks.sort(Bp),i=Ks.shift(),a=Ks.length,i.__d&&(t=void 0,n=void 0,s=(n=(e=i).__v).__e,r=[],o=[],e.__P&&((t=Jn({},n)).__v=n.__v+1,tt.vnode&&tt.vnode(t),oh(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,r,s??$i(n),!!(32&n.__u),o),t.__v=n.__v,t.__.__k[t.__i]=t,Zp(r,t,o),n.__e=n.__=null,t.__e!=s&&Up(t)));Jo.__r=0}function Wp(i,e,t,n,s,r,o,a,l,c,h){var d,f,p,y,b,w,x,T=n&&n.__k||Hp,D=e.length;for(l=Xw(t,e,T,l,D),d=0;d<D;d++)(p=t.__k[d])!=null&&(f=p.__i==-1?wr:T[p.__i]||wr,p.__i=d,w=oh(i,p,f,s,r,o,a,l,c,h),y=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&lh(f.ref,null,p),h.push(p.ref,p.__c||y,p)),b==null&&y!=null&&(b=y),(x=!!(4&p.__u))||f.__k===p.__k?l=Kp(p,l,i,x):typeof p.type=="function"&&w!==void 0?l=w:y&&(l=y.nextSibling),p.__u&=-7);return t.__e=b,l}function Xw(i,e,t,n,s){var r,o,a,l,c,h=t.length,d=h,f=0;for(i.__k=new Array(s),r=0;r<s;r++)(o=e[r])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=i.__k[r]=Yo(null,o,null,null,null):Cr(o)?o=i.__k[r]=Yo(ps,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=i.__k[r]=Yo(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[r]=o,l=r+f,o.__=i,o.__b=i.__b+1,a=null,(c=o.__i=Qw(o,t,l,d))!=-1&&(d--,(a=t[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>h?f--:s<h&&f++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?f--:c==l+1?f++:(c>l?f--:f++,o.__u|=4))):i.__k[r]=null;if(d)for(r=0;r<h;r++)(a=t[r])!=null&&!(2&a.__u)&&(a.__e==n&&(n=$i(a)),Jp(a,a));return n}function Kp(i,e,t,n){var s,r;if(typeof i.type=="function"){for(s=i.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=i,e=Kp(s[r],e,t,n));return e}i.__e!=e&&(n&&(e&&i.type&&!e.parentNode&&(e=$i(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Xo(i,e){return e=e||[],i==null||typeof i=="boolean"||(Cr(i)?i.some(function(t){Xo(t,e)}):e.push(i)),e}function Qw(i,e,t,n){var s,r,o,a=i.key,l=i.type,c=e[t],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return t;if(n>(h?1:0)){for(s=t-1,r=t+1;s>=0||r<e.length;)if((c=e[o=s>=0?s--:r++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function qp(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||Jw.test(e)?t:t+"px"}function Qo(i,e,t,n,s){var r,o;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||qp(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||qp(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(jp,"$1")),o=e.toLowerCase(),e=o in i||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+r]=t,t?n?t.u=n.u:(t.u=nh,i.addEventListener(e,r?ih:sh,r)):i.removeEventListener(e,r?ih:sh,r);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function Gp(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=nh++;else if(e.t<t.u)return;return t(tt.event?tt.event(e):e)}}}function oh(i,e,t,n,s,r,o,a,l,c){var h,d,f,p,y,b,w,x,T,D,N,A,z,O,K,Z,ye,Q=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(l=!!(32&t.__u),r=[a=e.__e=t.__e]),(h=tt.__b)&&h(e);e:if(typeof Q=="function")try{if(x=e.props,T="prototype"in Q&&Q.prototype.render,D=(h=Q.contextType)&&n[h.__c],N=h?D?D.props.value:h.__:n,t.__c?w=(d=e.__c=t.__c).__=d.__E:(T?e.__c=d=new Q(x,N):(e.__c=d=new re(x,N),d.constructor=Q,d.render=tC),D&&D.sub(d),d.state||(d.state={}),d.__n=n,f=d.__d=!0,d.__h=[],d._sb=[]),T&&d.__s==null&&(d.__s=d.state),T&&Q.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Jn({},d.__s)),Jn(d.__s,Q.getDerivedStateFromProps(x,d.__s))),p=d.props,y=d.state,d.__v=e,f)T&&Q.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),T&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(T&&Q.getDerivedStateFromProps==null&&x!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(x,N),e.__v==t.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(x,d.__s,N)===!1){for(e.__v!=t.__v&&(d.props=x,d.state=d.__s,d.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(ne){ne&&(ne.__=e)}),A=0;A<d._sb.length;A++)d.__h.push(d._sb[A]);d._sb=[],d.__h.length&&o.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(x,d.__s,N),T&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,y,b)})}if(d.context=N,d.props=x,d.__P=i,d.__e=!1,z=tt.__r,O=0,T){for(d.state=d.__s,d.__d=!1,z&&z(e),h=d.render(d.props,d.state,d.context),K=0;K<d._sb.length;K++)d.__h.push(d._sb[K]);d._sb=[]}else do d.__d=!1,z&&z(e),h=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++O<25);d.state=d.__s,d.getChildContext!=null&&(n=Jn(Jn({},n),d.getChildContext())),T&&!f&&d.getSnapshotBeforeUpdate!=null&&(b=d.getSnapshotBeforeUpdate(p,y)),Z=h,h!=null&&h.type===ps&&h.key==null&&(Z=Yp(h.props.children)),a=Wp(i,Cr(Z)?Z:[Z],e,t,n,s,r,o,a,l,c),d.base=e.__e,e.__u&=-161,d.__h.length&&o.push(d),w&&(d.__E=d.__=null)}catch(ne){if(e.__v=null,l||r!=null)if(ne.then){for(e.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;r[r.indexOf(a)]=null,e.__e=a}else{for(ye=r.length;ye--;)rh(r[ye]);ah(e)}else e.__e=t.__e,e.__k=t.__k,ne.then||ah(e);tt.__e(ne,e,t)}else r==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):a=e.__e=eC(t.__e,e,t,n,s,r,o,l,c);return(h=tt.diffed)&&h(e),128&e.__u?void 0:a}function ah(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(ah)}function Zp(i,e,t){for(var n=0;n<t.length;n++)lh(t[n],t[++n],t[++n]);tt.__c&&tt.__c(e,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(r){r.call(s)})}catch(r){tt.__e(r,s.__v)}})}function Yp(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:Cr(i)?i.map(Yp):Jn({},i)}function eC(i,e,t,n,s,r,o,a,l){var c,h,d,f,p,y,b,w=t.props||wr,x=e.props,T=e.type;if(T=="svg"?s="http://www.w3.org/2000/svg":T=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),r!=null){for(c=0;c<r.length;c++)if((p=r[c])&&"setAttribute"in p==!!T&&(T?p.localName==T:p.nodeType==3)){i=p,r[c]=null;break}}if(i==null){if(T==null)return document.createTextNode(x);i=document.createElementNS(s,T,x.is&&x),a&&(tt.__m&&tt.__m(e,r),a=!1),r=null}if(T==null)w===x||a&&i.data==x||(i.data=x);else{if(r=r&&Zo.call(i.childNodes),!a&&r!=null)for(w={},c=0;c<i.attributes.length;c++)w[(p=i.attributes[c]).name]=p.value;for(c in w)if(p=w[c],c!="children"){if(c=="dangerouslySetInnerHTML")d=p;else if(!(c in x)){if(c=="value"&&"defaultValue"in x||c=="checked"&&"defaultChecked"in x)continue;Qo(i,c,null,p,s)}}for(c in x)p=x[c],c=="children"?f=p:c=="dangerouslySetInnerHTML"?h=p:c=="value"?y=p:c=="checked"?b=p:a&&typeof p!="function"||w[c]===p||Qo(i,c,p,w[c],s);if(h)a||d&&(h.__html==d.__html||h.__html==i.innerHTML)||(i.innerHTML=h.__html),e.__k=[];else if(d&&(i.innerHTML=""),Wp(e.type=="template"?i.content:i,Cr(f)?f:[f],e,t,n,T=="foreignObject"?"http://www.w3.org/1999/xhtml":s,r,o,r?r[0]:t.__k&&$i(t,0),a,l),r!=null)for(c=r.length;c--;)rh(r[c]);a||(c="value",T=="progress"&&y==null?i.removeAttribute("value"):y!=null&&(y!==i[c]||T=="progress"&&!y||T=="option"&&y!=w[c])&&Qo(i,c,y,w[c],s),c="checked",b!=null&&b!=i[c]&&Qo(i,c,b,w[c],s))}return i}function lh(i,e,t){try{if(typeof i=="function"){var n=typeof i.__u=="function";n&&i.__u(),n&&e==null||(i.__u=i(e))}else i.current=e}catch(s){tt.__e(s,t)}}function Jp(i,e,t){var n,s;if(tt.unmount&&tt.unmount(i),(n=i.ref)&&(n.current&&n.current!=i.__e||lh(n,null,e)),(n=i.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(r){tt.__e(r,e)}n.base=n.__P=null}if(n=i.__k)for(s=0;s<n.length;s++)n[s]&&Jp(n[s],e,t||typeof i.type!="function");t||rh(i.__e),i.__c=i.__=i.__e=void 0}function tC(i,e,t){return this.constructor(i,t)}function ms(i,e,t){var n,s,r,o;e==document&&(e=document.documentElement),tt.__&&tt.__(i,e),s=(n=typeof t=="function")?null:t&&t.__k||e.__k,r=[],o=[],oh(e,i=(!n&&t||e).__k=g(ps,null,[i]),s||wr,wr,e.namespaceURI,!n&&t?[t]:s?null:e.firstChild?Zo.call(e.childNodes):null,r,!n&&t?t:s?s.__e:e.firstChild,n,o),Zp(r,i,o)}Zo=Hp.slice,tt={__e:function(i,e,t,n){for(var s,r,o;e=e.__;)if((s=e.__c)&&!s.__)try{if((r=s.constructor)&&r.getDerivedStateFromError!=null&&(s.setState(r.getDerivedStateFromError(i)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,n||{}),o=s.__d),o)return s.__E=s}catch(a){i=a}throw i}},zp=0,I.isValidElement=function(i){return i!=null&&i.constructor===void 0},re.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Jn({},this.state),typeof i=="function"&&(i=i(Jn({},t),this.props)),i&&Jn(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),Vp(this))},re.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),Vp(this))},re.prototype.render=ps,Ks=[],Op=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Bp=function(i,e){return i.__v.__b-e.__v.__b},Jo.__r=0,jp=/(PointerCapture)$|Capture$/i,nh=0,sh=Gp(!1),ih=Gp(!0);function Pe(i,...e){return e.forEach(t=>{!t||typeof t!="object"||Object.keys(t).forEach(n=>{let s=t[n];const r=i[n];s!==r&&(r!==void 0&&(n==="className"||n.endsWith("Class")?s=[r,s]:n==="children"?s=[...Xo(r),...Xo(s)]:typeof r=="object"&&(n==="style"||n.endsWith("Style")||n==="attrs"||n.endsWith("Attrs")||n==="props")&&(s=v.extend(r,s))),i[n]=s)})}),i}function ch(i){return Object.keys(i).forEach(e=>{i[e]===void 0&&delete i[e]}),i}function ea(i,e=!0){const t=v(i),n=t[0],s="zui-disable-scroll";if(e){if(t.data(s))return;if((t.css("scrollbar-gutter")||"").includes("stable")){t.data(s,{overflow:t.css("overflow")}).css("overflow","hidden");return}const r=n===document.body||t.is("html")?window.innerWidth-document.body.clientWidth:n.offsetWidth-n.clientWidth;if(!r)return;const o=t.css("paddingRight")||"0";t.data(s,{paddingRight:o,overflow:t.css("overflow")}).css({paddingRight:`${r+Number.parseInt(o,10)}px`,overflow:"hidden"})}else{const r=t.data(s);if(!r)return;t.css(r).removeData(s)}}v.fn.disableScroll=function(i=!0){return this.each((e,t)=>{ea(t,i)})},v.fn.enableScroll=function(i=!0){return this.disableScroll(!i)};function hh(i,e,t){if(!(t.on||"click").split(" ").includes(e.type))return;const n=t.selector?v(e.target).closest(t.selector):i;if(!n.length)return;const s=c=>c===""?!0:c,r=c=>{if(typeof c=="string")try{c=JSON.parse(c)}catch{}return c};if(s(t.once)){if(t.onceCalled)return;i.dataset("once-called",!0)}if(s(t.prevent)&&e.preventDefault(),s(t.stop)&&e.stopPropagation(),s(t.self)&&e.currentTarget!==e.target)return;const o=[["$element",i],["event",e],["options",t],["$target",n]],a=c=>typeof c=="function"?c(...o):v.runJS(c,...o);if(t.if!==void 0&&!a(t.if))return;const l=t.call;if(l){let c;if(typeof l=="string"?c=/^[$A-Z_][0-9A-Z_$.]*$/i.test(l)?ki(window,l):a(l):c=l,typeof c=="function"){const h=[],d=t.params;t.params=h,typeof d=="string"&&d.length?d[0]==="["?h.push(...r(d)):h.push(...d.split(", ").map(f=>(f=f.trim(),f==="$element"?i:f==="event"?e:f==="options"?t:f.startsWith("$element.")||f.startsWith("event.")||f.startsWith("options.")?a(f):r(f)))):Array.isArray(d)?h.push(...d):h.push(d),c(...h)}}t.do&&a(t.do)}function nC(i){const e=v(this),t=i.type,n=e.attr("zui-on");if(n){const[o,a]=n.split("~").map(l=>l.trim());o&&o.split(" ").includes(t)&&hh(e,i,v.extend({on:o},a?a.startsWith("{")?Yn(a):{do:a}:Ti(e,{prefix:"data-",evalValue:["call","if","do"]})))}const s=e.attr(`zui-on-${t}`);s&&hh(e,i,v.extend({on:t},s.startsWith("{")?Yn(s):{do:s}));const r=e.attr("data-on");r&&r.split(" ").includes(t)&&hh(e,i,Ti(e,{prefix:"data-",evalValue:["call","if","do"]}))}function Xp(i){v(document).off(".zui.global").on(i.map(e=>`${e}.zui.global`).join(" "),`[zui-on],${i.map(e=>`[zui-on-${e}]`)},[data-on]`,nC)}v(()=>{Xp(["click","change","inited"])});function In(i,e){if(typeof i=="function")return In(i(...e||[]));if(typeof i=="number")return[i];let t=i.match(/(\d+)(%|px)?/);return t?[parseInt(t[1]),t[2]]:(t=i.match(/(\d+)\/(\d+)/),t?[100*parseInt(t[1])/parseInt(t[2]),"%"]:[NaN])}function Be(i,e){if(i==null)return null;const[t,n="px"]=In(i,e);return Number.isNaN(t)?typeof i=="string"?i:null:`${t}${n}`}async function Xn(i,e){var n,s,r;if(i instanceof Blob){const o=document.createElement("a");return o.href=window.URL.createObjectURL(i),e&&(o.download=decodeURIComponent(e)),o.click(),o.remove(),i}if(i instanceof Response){const o=await i.blob();return e=e||((r=(s=(n=i.headers.get("Content-Disposition"))==null?void 0:n.split(";")[1])==null?void 0:s.split("=")[1])==null?void 0:r.replace(/"/g,"")),Xn(o,e)}const t=await fetch(i);return Xn(t)}class Qp{constructor(e){this._$target=v(e)}on(...e){return this._$target.on(...e),this}one(...e){return this._$target.one(...e),this}off(...e){return this._$target.off(...e),this}trigger(...e){return this._$target.trigger(...e),this}}const Mn=new Qp(document);v.bus=Mn,v.on=Mn.on.bind(Mn),v.one=Mn.one.bind(Mn),v.off=Mn.off.bind(Mn),v.trigger=Mn.trigger.bind(Mn);var sC=["Shift","Meta","Alt","Control"],em=typeof navigator=="object"?navigator.platform:"",tm=/Mac|iPod|iPhone|iPad/.test(em),iC=tm?"Meta":"Control",rC=em==="Win32"?["Control","Alt"]:tm?["Alt"]:[];function dh(i,e){return typeof i.getModifierState=="function"&&(i.getModifierState(e)||rC.includes(e)&&i.getModifierState("AltGraph"))}function oC(i){return i.trim().split(" ").map(function(e){var t=e.split(/\b\+/),n=t.pop();return[t=t.map(function(s){return s==="$mod"?iC:s}),n]})}function nm(i,e){var t;e===void 0&&(e={});var n=(t=e.timeout)!=null?t:1e3,s=Object.keys(i).map(function(a){return[oC(a),i[a]]}),r=new Map,o=null;return function(a){a instanceof KeyboardEvent&&(s.forEach(function(l){var c=l[0],h=l[1],d=r.get(c)||c;(function(f,p){return!(p[1].toUpperCase()!==f.key.toUpperCase()&&p[1]!==f.code||p[0].find(function(y){return!dh(f,y)})||sC.find(function(y){return!p[0].includes(y)&&p[1]!==y&&dh(f,y)}))})(a,d[0])?d.length>1?r.set(c,d.slice(1)):(r.delete(c),h(a)):dh(a,a.key)||r.delete(c)}),o&&clearTimeout(o),o=setTimeout(r.clear.bind(r),n))}}function aC(i,e,t){var n;t===void 0&&(t={});var s=(n=t.event)!=null?n:"keydown",r=nm(e,t);return i.addEventListener(s,r),function(){i.removeEventListener(s,r)}}function uh(i,e={}){if(!i)return;const t=Object.keys(e).reduce((n,s)=>(e[s].optional||(n[s]={...e[s]}),n),{});return Object.keys(i).forEach(n=>{const s=i[n];s?s===!0?e[n]&&(t[n]={...e[n]}):t[n]=s:delete t[n]}),Object.keys(t).reduce((n,s)=>{const{keys:r,handler:o}=t[s];return typeof r=="string"?n[r]=o:r.forEach(a=>{n[a]=o}),n},{})}function fh(i,e,t){const{timeout:n,event:s="keydown",scope:r,when:o}=t||{},a=nm(e,{timeout:n}),l=`.zui.hotkeys${r?`.${r}`:""}`,c="zui-hotkeys-composing";return v(i).on(`${s}${l}`,function(h){o&&o(h)===!1||v(h.target).data(c)||a(h)}).on(`compositionstart${l}`,h=>{v(h.target).data(c,!0)}).on(`compositionend${l}`,h=>{v(h.target).removeData(c)})}function ph(i,e){return v(i).off(`.zui.hotkeys${e?`.${e}`:""}`)}const lC=aC;v.fn.hotkeys=function(i,e){return fh(this,i,e)},v.fn.unbindHotkeys=function(i){return ph(this,i)},v.hotkeys=function(i,e){fh(window,i,e)},v.unbindHotkeys=function(i){ph(window,i)};function ta(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement}async function sm(i){(typeof i=="string"||i instanceof Element||i instanceof v)&&(i={target:i});const{target:e,onError:t,onSuccess:n,afterExit:s,afterEnter:r}=i,o=v(e),a=o[0];if(!a)return;const l=a.requestFullscreen||a.webkitRequestFullscreen||a.mozRequestFullScreen;if(!l){t==null||t.call(a,new Error("[ZUI] The browser does not support full screen feature."));return}try{await l.call(a),n==null||n.call(a),v(a).off(".zui.fullscreen"),s&&o.on("exitFullscreen.zui.fullscreen",s),r&&o.on("enterFullscreen.zui.fullscreen",r)}catch(c){t==null||t.call(a,c)}document.zuiBindFullscreenChange||(document.zuiBindFullscreenChange=!0,v(document).on("fullscreenchange.zui webkitfullscreenchange.zui mozfullscreenchange.zui",c=>{const h=ta();let d=h;h?v(h).addClass("is-in-fullscreen"):(d=v(document).find(".is-in-fullscreen")[0]||document,v(d).removeClass("is-in-fullscreen")),v("body").toggleClass("has-in-fullscreen",!!h);const f={event:c,target:d,fullscreenElement:h};v(d).trigger(h?"enterFullscreen":"exitFullscreen",f).trigger("toggleFullscreen",f)}))}async function na(i){const e=ta();return i===!1&&!!e===i?i:e?(document.exitFullscreen(),!1):(await sm(i),!0)}v.fn.fullscreen=function(i){return na({target:this,...i})},v.getFullscreenElement=ta,v.toggleFullscreen=na;const Qn=24*60*60*1e3,Ye=(i,e)=>i===void 0?new Date:i instanceof Date?e?new Date(i.getTime()):i:(typeof i=="string"&&(i=i.trim(),/^\d+$/.test(i)&&(i=Number.parseInt(i,10))),typeof i=="number"&&i<1e10&&(i*=1e3),i=new Date(i),i),dn=i=>Ye(i).getTime(),sa=(i,e,t="day")=>{if(typeof e=="string"){const n=Number.parseInt(e,10);t=e.replace(n.toString(),""),e=n}return i=new Date(dn(i)),t==="month"?i.setMonth(i.getMonth()+e):t==="year"?i.setFullYear(i.getFullYear()+e):t==="week"?i.setDate(i.getDate()+e*7):t==="hour"?i.setHours(i.getHours()+e):t==="minute"?i.setMinutes(i.getMinutes()+e):t==="second"?i.setSeconds(i.getSeconds()+e):i.setDate(i.getDate()+e),i},Nn=(i,e=new Date)=>Ye(i).toDateString()===Ye(e).toDateString(),xr=(i,e=new Date)=>Ye(i).getFullYear()===Ye(e).getFullYear(),kr=(i,e=new Date)=>(i=Ye(i),e=Ye(e),i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()),cC=(i,e=new Date)=>{const n=Math.floor(dn(i)/864e5),s=Math.floor(dn(e)/864e5);return Math.floor((n+4)/7)===Math.floor((s+4)/7)},im=(i,e)=>Nn(Ye(e),i),rm=(i,e)=>Nn(dn(e)-Qn,i),hC=(i,e)=>Nn(dn(e)+Qn,i),Sr=i=>i!=null&&!isNaN(dn(i)),Ze=(i,e="yyyy-MM-dd hh:mm",t="")=>{if(i=Ye(i),!Sr(i))return t;if(typeof e=="function")return e(i);const n={"M+":i.getMonth()+1,"d+":i.getDate(),"h+":i.getHours(),"H+":i.getHours()%12,"m+":i.getMinutes(),"s+":i.getSeconds(),"S+":i.getMilliseconds()};return/(y+)/i.test(e)&&(e.includes("[yyyy-]")&&(e=e.replace("[yyyy-]",xr(i)?"":"yyyy-")),e=e.replace(RegExp.$1,`${i.getFullYear()}`.substring(4-RegExp.$1.length))),Object.keys(n).forEach(s=>{if(new RegExp(`(${s})`).test(e)){const r=`${n[s]}`;e=e.replace(RegExp.$1,RegExp.$1.length===1?r:`00${r}`.substring(r.length))}}),e},dC=(i,e,t)=>{const n={full:"yyyy-M-d",month:"M-d",day:"d",str:"{0} ~ {1}",...t},s=Ze(i,xr(i)?n.month:n.full);if(Nn(i,e))return s;const r=Ze(e,xr(i,e)?kr(i,e)?n.day:n.month:n.full);return n.str.replace("{0}",s).replace("{1}",r)};function mh(i){let e=0;if(typeof i!="string"&&(i=String(i)),i&&i.length)for(let t=0;t<i.length;++t)e+=(t+1)*i.charCodeAt(t);return e}function En(i){return!i||i.parentNode===document?!1:i.parentNode?En(i.parentNode):!0}v.isDetached=En,v.fn.isDetached=function(){const i=this[0];return!i||En(i)};const qs=class Ub{constructor(e,t){var y,b;this._inited=!1,this._autoDestory=0,this._destroyed=!1;const{KEY:n,DATA_KEY:s,MULTI_INSTANCE:r,NAME:o,ATTR_KEY:a,ALL:l,TYPED_ALL:c}=this.constructor;if(!o)throw new Error('[ZUI] The component must have a "NAME" static property.');const h=v(e);if(h.data(n)&&!r)throw new Error(`[ZUI] The component "${o}" has been initialized on element.`);const d=h[0];if(!d)throw new Error(`[ZUI] Invalid selector "${e}" for component "${o}", can not find the element matched.`);const f=Xe();this._gid=f,this._element=d,this.resetOptions(t),this._key=this.options.key??`__${f}`;let p=l.get(d);if(p?p.add(this):(p=new Set([this]),l.set(d,p)),c.has(o)?(y=c.get(o))==null||y.add(this):c.set(o,new Set([this])),h.data(n,this).attr(a,"").attr(s,`${f}`).attr("z-use",[...new Set([...p||[]].map(w=>w.constructor.NAME))].join(",")),r){const w=`${n}:ALL`;let x=h.data(w);x||(x=new Map,h.data(w,x)),x.set(this._key,this)}this.init(),(b=this.options.$onCreate)==null||b.call(this),requestAnimationFrame(async()=>{var x;const{$fetcher:w}=this.options;if(w){const T=await Ne(w,[d,this.options,this],{dataType:"js"});if(this.destroyed)return;T&&this.setOptions(T)}this._inited=!0,await this.afterInit(),this.emit("inited",this.options),(x=this.options.$onInited)==null||x.call(this)})}static get ZUI(){return this.NAME.replace(/(^[A-Z]+)/,e=>e.toLowerCase())}static get KEY(){return`zui.${this.NAME}`}static get NAMESPACE(){return`.zui.${this.ZUI}`}static get DATA_KEY(){return`data-zui-${this.NAME}`}static get ATTR_KEY(){return`z-use-${this.NAME}`}static get SELECTOR(){return`[${this.DATA_KEY}]`}get inited(){return this._inited}get destroyed(){return this._destroyed}get element(){if(!this._element)throw new Error("[ZUI] Component element is not available.");return this._element}get key(){return this._key}get options(){if(!this._options)throw new Error("[ZUI] Component options are not available.");return this._options}get gid(){return this._gid}get $element(){return v(this.element)}get $emitter(){return this.$element}get i18nData(){return[this.options.i18n,this.constructor.i18n]}init(){}afterInit(){}render(e,t){this._options=this.setOptions(e,t);const{$class:n,$style:s}=this.options;n&&this.$element.setClass(n),s&&this.$element.css(s)}destroy(){var p;const{KEY:e,DATA_KEY:t,ALL:n,TYPED_ALL:s,NAME:r,MULTI_INSTANCE:o,ATTR_KEY:a}=this.constructor,{$element:l,element:c}=this;if(this.emit("destroyed"),this._destroyed=!0,l.off(this.namespace).removeData(e).removeAttr(a).removeAttr(t),o){const y=this.$element.data(`${e}:ALL`);if(y)if(y.delete(this._key),y.size===0)this.$element.removeData(`${e}:ALL`);else{const b=y.values().next().value;l.data(e,b).attr(t,String(b==null?void 0:b.gid))}}const h=n.get(c);h&&(h.delete(this),h.size===0&&n.delete(c));const d=s.get(r);d&&(d.delete(this),d.size===0&&s.delete(r));const f=n.get(c);f!=null&&f.size?l.attr("z-use",[...new Set([...f].map(y=>y.constructor.NAME))].join(",")):l.removeAttr("z-use"),(p=this.options.$onDestroy)==null||p.call(this)}autoDestroy(e=100){this._autoDestory&&clearTimeout(this._autoDestory),this._autoDestory=window.setTimeout(()=>{this._autoDestory=0,En(this.element)&&this.destroy()},e)}setOptions(e,t){if(t){const n={...this.constructor.DEFAULT,...(e==null?void 0:e.$optionsFromDataset)!==!1?this.$element.dataset():{},...e},{$options:s}=n;if(s){const r=typeof s=="function"?s.call(this,this.element,n):s;r&&v.extend(n,r),delete n.$options}this._options=n}else e&&v.extend(this._options,e);if(!this._options)throw new Error("[ZUI] Component options are not available.");return this._options}resetOptions(e){return this.setOptions(e,!0)}emit(e,...t){const n=v.Event(e);return n.__src=this,this.$emitter.trigger(n,[this,...t]),n}on(e,t,n){const s=this;this.$element[n!=null&&n.once?"one":"on"](this._wrapEvent(e),function(r,o){(!r.__src||r.__src===s)&&t.call(this,r,o)})}one(e,t){this.on(e,t,{once:!0})}off(e){this.$element.off(this._wrapEvent(e))}i18n(e,t,n){const{i18nData:s}=this;return be(s,e,t,n,this.options.lang,this.constructor.NAME)??be(s,e,t,n,this.options.lang)??`{i18n:${e}}`}executeCommand(e,t){return nn(this,e,t)}get namespace(){return`${this.constructor.NAMESPACE}.${this._key}`}_wrapEvent(e){return e.split(" ").map(t=>t.includes(".")?t:`${t}${this.namespace}`).join(" ")}static get(e,t){const n=v(e);if(this.MULTI_INSTANCE&&t!==void 0){const s=n.data(`${this.KEY}:ALL`);return s?s.get(t):void 0}return n.data(this.KEY)}static isValid(e){return!0}static ensure(e,t){const n=this.get(e,t==null?void 0:t.key);if(n){if(this.isValid(n))return t&&n.setOptions(t),n;n.destroy()}return new this(e,t)}static getAll(e,t){var l;const{SELECTOR:n,ALL:s,TYPED_ALL:r}=this,o=[],a=c=>{c instanceof this&&(!t||t(c)!==!1)&&o.push(c)};return e?v(e).find(n).each((c,h)=>{var d;(d=s.get(h))==null||d.forEach(a)}):this!==Ub?(l=r.get(this.NAME))==null||l.forEach(a):s.forEach(c=>{c.forEach(a)}),o.sort((c,h)=>c.gid-h.gid)}static query(e,t,n){return e===void 0?this.getAll(void 0,n).pop():this.get(v(e).closest(this.SELECTOR),t)}static defineFn(e){let t=e||this.ZUI;v.fn[t]&&(t=`zui${this.NAME}`);const n=this;v.fn.extend({[t](s,...r){const o=typeof s=="object"?s:void 0,a=typeof s=="string"?s:void 0;let l;return this.each((c,h)=>{let d=n.get(h);if(d)o&&d.render(o);else{if(a)return;d=new n(h,o)}if(a){let f=d[a],p=d;f===void 0&&(p=d.$,f=p[a]),typeof f=="function"?l=f.call(p,...r):l=f}}),l!==void 0?l:this}})}static register(e,t){var s,r;e=e||this,t=(t??e.NAME).toLowerCase(),this.map.set(t,e);const n=(r=(s=e.toggle)==null?void 0:s.name)==null?void 0:r.toLowerCase();n&&n!==t&&this.toggleMap.set(n,e)}};qs.DEFAULT={},qs.MULTI_INSTANCE=!1,qs.ALL=new Map,qs.TYPED_ALL=new Map,qs.map=new Map,qs.toggleMap=new Map;let qe=qs;function Tr(i){return qe.map.get(i.toLowerCase())}function ia(i,e,t={}){let n=typeof i=="function"?i:Tr(i);if(n||(n=gh(i)),!n)return null;const{$update:s,...r}=t;if(!n.MULTI_INSTANCE){const o=n.get(e);if(o)return s&&o.render(r,s==="reset"),o}return new n(e,r)}function om(i,e,t={}){requestAnimationFrame(()=>ia(i,e,t))}function am(i,e){qe.register(i,e)}function gh(i){const{zui:e}=window;if(e){i=i==null?void 0:i.toLowerCase();for(const t in e){const n=t.toLowerCase()===i;if(i&&!n)continue;const s=e[t];if(!(typeof s!="function"||!s.NAME||!s.ZUI)&&(qe.map.has(t.toLowerCase())||am(s),n))return s}}}function uC(i){var e;i?(e=Tr(i))==null||e.defineFn():window._zuiDefined||(gh(),qe.map.forEach(t=>{t.defineFn()}),Object.assign(window,{_zuiDefined:!0}))}function fC(i,e={}){const t=v(i);let n=t.attr("zui-create");const{update:s,onCreate:r}=e,o=(a,l)=>{if(l={$update:s,$optionsFromDataset:!1,...l},r){const h=r(a,l);if(h===!1)return;h&&(l=h)}const c=l.$lib;if(c){delete l.$lib,v.getLib(c).then(()=>om(a,i,l));return}om(a,i,l)};if(typeof n=="string"){n=n.trim();const a=n.length?n.split(",").map(h=>h.trim()):[],l=Ti(i,{prefix:"zui-create-",evalValue:!0})||{},c=Object.keys(l);if(!c.length&&a.length===1)o(a[0],t.dataset());else{const h=new Set;[...a,...c].forEach(d=>{if(h.has(d))return;const f=l[d];o(d,f),delete l[d],h.add(d)})}}else{const a=t.dataset(),l=a==null?void 0:a.zui;if(!l)return;console.warn("[ZUI] create component instance with [data-zui] is deprecated, use [zui-create] instead.",{element:i,options:e}),a==null||delete a.zui,o(l,a)}}function pC(){v(document).on("click.zui.toggle mouseenter.zui.toggle","[data-toggle],[zui-toggle]",function(i){const e=v(this),t=e.dataset("toggle")||e.attr("zui-toggle");if(!t)return;const n=qe.toggleMap.get(t)||Tr(t),s=n==null?void 0:n.toggle;if(!s)return;const{trigger:r="click",skip:o="[disabled],.disabled",check:a}=s,l=i.type==="mouseover"?"hover":"click";if(!r.includes(l)||a&&!a.call(n,this,l,i)||o&&e.is(o))return;const{onGet:c,onCreate:h,setOptions:d=!0,getOptions:f,prevent:p=!0,handler:y,onToggle:b,convertHref:w}=s;let x=e.dataset();const T=e.attr(`zui-toggle-${t}`);if(T&&(x=v.extend(x,Yn(T,["_element",this],["_$element",e]))),w&&e.is("a")){const N=e.attr("href");if(N){const A=w===!0?{selector:"target",url:"url"}:w;"#.".includes(N[0])?A.selector&&x[A.selector]===void 0&&(x[A.selector]=N):A.url&&x[A.url]===void 0&&(x[A.url]=N)}}if(f&&(x=f.call(n,this,x,i)),y){y.call(n,this,x,l,i),p&&i.preventDefault();return}let D=c?c.call(n,this):n.get(this);if(D)d&&D.setOptions(x);else{const N=h?h.call(n,this,i,x):new n(this,x);if(!N)return;D=N}if(b){if(b.call(n,D,this,i)===!1)return}else{const{shown:N,show:A,hide:z,toggle:O}=D;let K;if(O?K=O:A&&z?N?K=z:K=A:A&&(K=A),K)K.call(D);else return}p&&i.preventDefault()})}function mC(i,e){const t=br(i),n=[];return Object.keys(t).forEach(s=>{if(!s.startsWith("zui."))return;const r=t[s];(e==null?void 0:e(r,s))!==!1&&n.push(t[s])}),n}let ra=0;function lm(i=100){if(ra&&clearTimeout(ra),i){ra=window.setTimeout(()=>lm(0),i);return}ra=0,qe.ALL.forEach(e=>{e.forEach(t=>!t.options.$notDestroyOnDetach&&t.autoDestroy())})}function gC(){if(!document.body||br(document.body,"_autoDestoryMob"))return;const i=new MutationObserver(e=>{let t=!1;for(const n of e)if(n.removedNodes.length){t=!0;break}t&&lm()});i.observe(document.body,{childList:!0,subtree:!0}),qo(document.body,"_autoDestoryMob",i)}function yh(i,e){const t=v(i);t.find("[zui-create],[data-zui]").each(function(){var n;((n=e==null?void 0:e.beforeCreate)==null?void 0:n.call(e,this))!==!1&&fC(this,e)}),t.find("[zui-init]").each(function(){if(this.hasAttribute("z-zui-inited"))return;this.setAttribute("z-zui-inited","");const n=this.getAttribute("zui-init");n&&v.runJS(n,["$element",v(this)])}),t.find(".hide-before-init").removeClass("invisible hidden opacity-0"),t.find(".scroll-into-view").scrollIntoView(),t.find('[data-on="inited"],[zui-on-inited]').each((n,s)=>{const r=v(s);r.zui()||r.trigger("inited")}),e!=null&&e.runJS&&t.runJS()}v.fn.zuiInit=function(i){return yh(this,i),this},v.fn.zui=function(i,e){const t=this[0];if(!t)return;if(typeof i!="string"){const s={};let r;return mC(t,(o,a)=>{s[a]=o,(!r||r.gid<o.gid)&&(r=s[a])}),i===!0?s:r}const n=Tr(i);return n?e===!0?n.getAll(t):n.query(t,e):v(t).data(`zui.${i}`)},v.fn.zuiCall=function(i,e=[]){return this.each(function(){const t=i.split("."),n=t.length>1?t[0]:void 0,s=t[t.length>1?1:0],r=v(this).zui(n),o=r==null?void 0:r[s];typeof o=="function"&&o.apply(r,e)}),this},v(()=>{v("body").zuiInit({update:!0}),pC(),gC()});class oa extends qe{get $targets(){const{$element:e}=this,{targets:t}=this.options;return t?e.find(t):e}_handleScroll(e,t,n){const{offset:s=1}=this.options,r=this.$targets,o=e.getBoundingClientRect(),{scrollTop:a,scrollLeft:l}=e;r.each((c,h)=>{const d=h.getBoundingClientRect(),f=t==="top"&&a>0&&d.top<=o.top+s||t==="bottom"&&d.bottom>=o.bottom-s||t==="left"&&l>0&&d.left<=o.left+s||t==="right"&&l<e.scrollWidth-e.clientWidth;h.classList.toggle(n,f)})}init(){const{offset:e=1,side:t="top",zIndex:n,pinnedClass:s="is-pinned",scrollContainer:r}=this.options,{$element:o,$targets:a}=this;if(a.css({position:"sticky",zIndex:n,[t]:0}),r){const l=o.closest(r)[0]||o.find(r)[0];if(l){const c=()=>{this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=0,this._handleScroll(l,t,s)})};this._scrollListener=c,l.addEventListener("scroll",c)}this._container=l,requestAnimationFrame(()=>{this._handleScroll(l,t,s)})}else this._ob=new IntersectionObserver(l=>{l.forEach(c=>{c.target.classList.toggle(s,c.intersectionRatio<e)})},{threshold:[1]}),a.css("side",-e).each((l,c)=>this._ob.observe(c))}destroy(){var e;(e=this._ob)==null||e.disconnect(),this._container&&(this._container.removeEventListener("scroll",this._scrollListener),this._raf&&cancelAnimationFrame(this._raf))}}oa.NAME="Sticky";function aa(i){if(!i)return;if(typeof i=="object")return i;if(i=i.replace(/^#/,""),!i.length)return;i.startsWith("/")||(i=`/${i}`);const e=new URL(window.location.origin+i),[,t="",...n]=e.pathname.split("/");let s=t.trim();if(!s.length)return;let r="";return s.includes("~")&&([r,s]=s.split("~")),{name:s,scope:r,options:Object.fromEntries([...e.searchParams.entries()].map(([o,a])=>{try{a.includes("%")&&(a=decodeURIComponent(a)),a=JSON.parse(a)}catch{}return[o,a]})),params:n.map(o=>{if(o!=="undefined"){if(o==="null")return null;try{return o.includes("%")&&(o=decodeURIComponent(o)),JSON.parse(o)}catch{return o}}})}}function cm(i){if(Array.isArray(i))return{commands:i.map(aa).filter(Boolean)};if(typeof i=="object")return i;i=i.replace(/^#!?/,"");const e=i.includes(">"),t=i.split(e?">":"|").map(aa);return{async:e,commands:t.filter(Boolean)}}function vh(i,e,t){if(typeof i=="string"&&(i=aa(i)),!i)return;const{execute:n,event:s,scope:r}=e;if(!(r&&i.scope&&i.scope!==r))return n({name:i.name,options:{...e.options,...i.options},event:s,scope:i.scope,prevResult:t},i.params)}async function _h(i,e){const{async:t,commands:n}=cm(i);if(!n.length)return[];const{signal:s}=e;if(t){const o=[];let a;for(const l of n){if(!(s!=null&&s.aborted))break;a=await vh(l,e,a),s!=null&&s.aborted&&(a=void 0),o.push(a)}return o}return await Promise.all(n.map(o=>{if(!(s!=null&&s.aborted))return vh(o,e)}))}const Di="zui.commands",Ii="z-commands",bh="zui-commands-proxy",hm="zui-command",la={};function dm(i,e){typeof i=="string"&&e?la[i]=e:typeof i=="object"&&Object.assign(la,i)}function Mi(i,e){typeof e=="string"?e={scope:e}:typeof e=="function"&&(e={onCommand:e});const{scope:t="",events:n="click"}=e??{},s=v(i),r=(s.attr(Ii)||"").split(",");t&&!r.includes(t)&&r.push(t),s.attr(Ii,r.join(",")).data(Di,{[t]:{...e,scope:t,events:n,gid:Xe()},...s.data(Di)})}function $r(i,e=!0){const t=v(i);if(e===!0)t.removeAttr(Ii),t.removeData(Di);else if(e.length){const n=t.data(Di)||{};e.split(",").forEach(r=>{delete n[r]});const s=Object.keys(n);s.length?t.attr(Ii,s.join(",")).data(Di,Mi):$r(t,!0)}}function um(i,e){let t=i.closest(`[${Ii}],[${bh}]`).first();if(t.attr(bh)!==void 0&&(t=v(t.data("zui.commandProxy")||t.attr(bh)).closest(`[${Ii}]`)),!t.length)return;const n=t.data(Di)||{},s=Object.values(n).sort((o,a)=>a.gid-o.gid);let r;return e!=null&&e.length?(r=s.find(o=>o.scope===e),r||(r=s.find(o=>{var a;return!((a=o.scope)!=null&&a.length)&&!o.scoped})),r):(r=s.find(o=>{var a;return!((a=o.scope)!=null&&a.length)&&!o.scoped}),r||(r=s.find(o=>!o.scoped)),r?r.element=t[0]:r=um(i.parent(),e),r)}function yC(i){if(!i.currentTarget)return;const e=v(i.currentTarget);if(e.closest(".disabled,[disabled]").length)return;const t=e.attr(hm)||(e.is('a[href^="#!"]')?e.attr("href"):"");if(!t)return;const n=new AbortController,s=()=>n.abort();_h(t,{signal:n.signal,execute:(r,o)=>{const{scope:a,name:l}=r,c={...r,abort:s};o=o.map(p=>typeof p=="string"&&p.startsWith("$.")?ki(c,p.substring(2)):p);let h;const d=um(e,a);if(d){c.element=d.element;const p=(d.commands?d.commands[`${a}~${l}`]||d.commands[l]:null)||d.onCommand;if(p&&(h=p(c,o),i.commandHandled))return h}const f=[c,o];if(e.trigger("command",f).trigger(`command:${a?`${l}.${a}`:l}`,f),a&&e.trigger(`command:.${a}`,f),i.commandHandled)return h;if(a==="event"){l==="stop"?i.stopPropagation():l==="prevent"?i.preventDefault():nn(i,l,o);return}if(a!=null&&a.startsWith(".")){let p;if(a===".")p=e.closest("[z-use]").zui();else{const y=a.substring(1);p=e.closest(`[z-use-${y}]`).zui(y)}if(p)return p.executeCommand(l,o);console.warn(`[ZUI] Command "${l}" not found in scope "${a}".`);return}return a==="window"?nn(window,l,o):a==="zui"?nn(window.zui,l,o):a==="target"?nn(e[0],l,o):a==="$target"?nn(e,l,o):a==="$"?nn(v,l,o):a===""&&la[l]!==void 0?la[l](c,o):h},event:i})}v.fn.command=function(i,e){return this.on(`command:${i}`,e)},v.fn.offCommand=function(i,e){return this.off(`command:${i}`,e)},v.fn.commands=function(i){return this.each((e,t)=>Mi(t,i)),this},v.fn.unbindCommands=function(i){return this.each((e,t)=>$r(t,i)),this},v(()=>{v(document).on("click.zui.command",`[${hm}],a[href^="#!"]`,yC)});function Dr(i,e,t=!1){var s;const n=v(i);if(e!==void 0){if(typeof e=="string"&&e.length){const r=`zui-runjs-${Xe()}`;n.append(`<script id="${r}">${e}<\/script>`),t&&n.find(`#${r}`).remove()}return}if(n.is("script")){const r=(s=n[0])==null?void 0:s.textContent;r&&Dr(n.parent(),r);return}n.find("script").each((r,o)=>{Dr(n,o.textContent),o.remove()})}v.runJS=(i,...e)=>(i=i.trim(),!i.startsWith("return ")&&!i.endsWith(";")&&(i=`return ${i}`),new Function(...e.map(([n])=>n),i)(...e.map(([,n])=>n))),v.fn.runJS=function(i){return this.each((e,t)=>{Dr(t,i)})};function wh(i){return new Promise(e=>{typeof i=="string"&&(i={accept:i});const t=document.createElement("input");t.type="file",t.accept=(i==null?void 0:i.accept)||"*/*",t.multiple=(i==null?void 0:i.multiple)||!1,t.onchange=()=>{t.files?e(t.multiple?t.files:t.files[0]):e(null),t.remove()},t.click()})}function vC(i){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=s=>{t(s)},n.readAsText(i)})}function ca(i,e){const t=typeof e=="number"?{delay:e}:e,{delay:n=0,immediate:s=!1}=t??{};let r=null;const o=function(...a){const l=s&&!r;if(r&&clearTimeout(r),r=window.setTimeout(()=>{r=null,s||i.apply(this,a)},n),l)return i.apply(this,a)};return o.cancel=function(){r&&(clearTimeout(r),r=null)},o}function fm(i,e){v.libRoot=i,e&&(v.libVersion=e)}function Ch(i,e){v.libMap||(v.libMap={}),!e.name&&e.id&&(e.id=`zui-lib-${i}`),v.libMap[i]=e}v.setLibRoot=fm,v.registerLib=Ch,v.libVersion=1776236333698 .toString(36);function pm(i){return new Promise((e,t)=>{typeof i=="string"&&(i={src:i});const{src:n,id:s,version:r}=i;if(v(s?`#${s}`:`link[href^="${n}"]`).length){e();return}const a=document.createElement("link");a.onload=()=>{e()},a.onerror=()=>{t(new Error(`[ZUI] Failed to load CSS from: ${n}`))},a.rel="stylesheet",a.href=`${n}${r?`${n.includes("?")?"&":"?"}v=${r}`:""}`,s&&(a.id=s),v("head").append(a)})}function mm(i){return new Promise((e,t)=>{typeof i=="string"&&(i={src:i});const{src:n,id:s,version:r}=i,o=v(s?`#${s}`:`script[src^="${n}"]`);if(o.length){if(o.dataset("loaded"))e();else{const p=o.data("loadCalls")||[];p.push(e),o.data("loadCalls",p)}return}const{async:a=!0,defer:l=!1,noModule:c=!1,type:h,integrity:d}=i,f=document.createElement("script");f.async=a,f.defer=l,f.noModule=c,h&&(f.type=h),d&&(f.integrity=d),f.onload=()=>{e(),(v(f).dataset("loaded",!0).data("loadCalls")||[]).forEach(y=>y()),v(f).removeData("loadCalls")},f.onerror=p=>{t(new Error(`[ZUI] Failed to load JS from: ${n}`,{cause:p}))},v("head").append(f),f.src=`${n}${r?`${n.includes("?")?"&":"?"}v=${r}`:""}`})}function gm(i){return new Promise(e=>{typeof i=="string"&&(i={type:"module",src:i});const{src:t,imports:n,srcList:s=[],id:r}=i;t&&s.unshift({src:t,imports:n});const o=s.map(x=>x.src).join(","),a=v(r?`#${r}`:`script[data-src-list="${o}"]`);if(a.length){const x=a.data("module");if(x)e(x);else{const T=a.data("resolves")||[];T.push(e),a.data("resolves",T)}return}const{async:l=!0,defer:c=!1,integrity:h,globalVar:d,resolve:f}=i,p=document.createElement("script"),y=`zui-module-resolve-${v.guid++}`,b=v(p);Object.assign(window,{[y]:x=>{(b.data("module",x).data("resolves")||[]).forEach(D=>D(x)),b.removeData("resolves"),f==null||f(x),e(x),delete window[y]}}),p.async=l,p.defer=c,p.type="module",b.attr("data-src-list",o).attr("data-resolve-id",y);const w=[];p.text=[...s.map(({src:x,imports:T})=>{if(n){if(typeof T=="string")return w.push(T),`import * as ${T} from '${x}';`;if(T)return w.push(...Object.values(T)),`import {${Object.entries(T).map(([D,N])=>`${D} as ${N}`).join(",")}} from '${x}';`}return`import '${x}';`}),`const zuiImportResult = {${w.map(x=>`${x}: ${x},`)}};`,d?`Object.assign(window, ${d===!0?"zuiImportResult":`{${d}: zuiImportResult}`});`:"",`if(window['${y}']) window['${y}'](zuiImportResult);`].join(`
  5. `),h&&(p.integrity=h),v("head").append(p)})}async function xh(i,e,t){var b;typeof i=="string"&&(i=((b=v.libMap)==null?void 0:b[i])||{src:i});let n=Array.isArray(i)?{src:i}:v.extend({},i);typeof e=="function"?n.success=e:e&&v.extend(n,e),t&&(n.success=t);let{src:s}=n;const{name:r,success:o}=n,a=v.libMap&&r?v.libMap[r]:null;if(a&&(n=v.extend({},a,n),s=a.src||n.src),typeof s=="string"&&(s=[s]),!s||!s.length)throw new Error("[ZUI] No src provided for $.getLib.");let{check:l=!0}=n;l===!0&&r&&(l=r);const c=typeof l=="string"?l:r;let h;const d=()=>{let w;if(c&&(w=window[c]||h),!(w instanceof Element))return w};typeof l=="string"&&(l=()=>!!d());const f=()=>(o==null||o(),d());if(typeof l=="function"&&await l())return f();const{root:p=v.libRoot,version:y=v.libVersion}=n;for(let w of s){typeof w=="string"&&(w={src:w});let{src:x}=w;p&&!/https?:\/\//.test(x)&&(x=`${p}${p.endsWith("/")||x.startsWith("/")?"":"/"}${x}`);const T={...n,...w,version:y,src:x};if(w.type==="css"||!w.type&&x.endsWith(".css")){await pm(T);continue}if(T.type==="module"){h=await gm(T);continue}await mm(T)}return f()}v.getLib=xh,v.getScript=v.getLib;class Ni{constructor(e,t){this._name=e,t&&this.register(t)}get Module(){if(!this._module)throw new Error("[ZUI] LibLoader.Module is not loaded.");return this._module}register(e){Ch(this._name,e)}async load(e){const{throwError:t,noCache:n}=e||{};if(!n){if(this._module!==void 0)return this._module;if(this._error)return}try{this._module=await xh(this._name)}catch(s){if(this._error=s,t)throw s}return this._module}}function ym(i,e,t){try{return i(...e)}catch(n){t==null||t(n)}}function vm(i){const e=document.createElement("textarea");e.value=i,e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}async function kh(i){typeof i=="string"&&(i={text:i});const e=!navigator.clipboard||!document.hasFocus();let t="";if(Array.isArray(i))if(e){for(const n of i)if(n.types.includes("text/plain")){t=await(await n.getType("text/plain")).text();break}}else{await navigator.clipboard.write(i);return}else{const n={};for(const[s,r]of Object.entries(i)){if(r===void 0)continue;let o=s;if(o==="text"?o="text/plain":o==="html"&&(o="text/html"),e&&o==="text/plain"){t=typeof r=="string"?r:await r.text();break}n[o]=r}e||(i=[new ClipboardItem(n)])}if(e)return vm(t);await navigator.clipboard.write(i)}function _m(i,e){return new Promise(t=>{const{interval:n=100,timeout:s=6e4,timerRef:r,timeoutValue:o,abortSignal:a}=typeof e=="number"?{timeout:e}:e||{};let l=0,c=!1,h,d=!1;const f=y=>{d=!0,h=y},p=window.setInterval(async()=>{if(l++,c)return;if(a!=null&&a.aborted){clearInterval(p),t(void 0);return}c=!0;const y=await i(f,l);if(y)clearInterval(p),t(d?h:y);else if(l*n>=s){const b=o?await o(l):void 0;clearInterval(p),t(b)}c=!1},n);r&&(r.current=p)})}var bm;function wm(i,e,t){i instanceof Headers?i.set(e,t):Array.isArray(i)?i.push([e,t]):i[e]=t}function _C(i,e){if(i){const t={text:"text/plain",html:"text/html",json:"application/json",...e};for(const[n,s]of Object.entries(t))if(s.split(",").map(r=>r.trim()).includes(i))return n}return"text"}class Ir{constructor(e){this[bm]="Ajax",this.setting=e,this._controller=new AbortController,this._callbacks={success:[],error:[],complete:[]}}get completed(){return this.data!==void 0||this.error!==void 0}on(e,t){return this._callbacks[e].push(t),this}success(e){return this.on("success",e)}done(e){return this.success(e)}fail(e){return this.on("error",e)}complete(e){return this.on("complete",e)}always(e){return this.complete(e)}then(e,t){return this.completed?t&&this.error?t(this.error):e(this.data):(this.success(n=>e(n)),t&&this.fail(t)),this}catch(e){return this.error?(e(this.error),this):this.on("error",t=>e(t))}finally(e){return this.completed?(e(),this):this.complete(()=>e())}abort(e){return this.completed?!1:(this._abortError=e,this._controller.abort(),!0)}getResponseHeader(e){var t;return(t=this.response)==null?void 0:t.headers.get(e)}_init(){if(this.completed)return;const{url:e,type:t,data:n,processData:s=!0,contentType:r,crossDomain:o,accepts:a,dataType:l,timeout:c,dataFilter:h,beforeSend:d,success:f,error:p,complete:y,...b}=this.setting;t&&(b.method=t);let w=n;w&&(s&&(w=vr(w)),b.body=w),o&&(b.mode="cors");const x=b.headers||{};wm(x,"X-Requested-With","XMLHttpRequest"),r&&wm(x,"Content-Type",r),b.headers=x,b.signal&&b.signal.addEventListener("abort",()=>{this.abort()});const T=[...this.constructor.globalBeforeSends,d];for(const D of T){if(!D)continue;const N=D.call(this,b);if(N===!1)return;N&&Object.assign(b,N)}f&&this.success(f),p&&this.fail(p),y&&this.complete(y),b.signal=this._controller.signal,this.url=e,this.request=b}_emit(e,...t){this._callbacks[e].forEach(n=>{n.call(this,...t)})}async send(){var d;if(this.completed)return[];this._init();const{timeout:e,dataType:t,accepts:n,dataFilter:s,throws:r,jsonParser:o,convert:a}=this.setting;e&&(this._timeoutID=window.setTimeout(()=>{this.abort(new Error("timeout"))},e));let l,c,h;try{l=await fetch(this.url,this.request),this.response=l;const{statusText:f}=l;if(l.ok){const p=(d=l.headers.get("Content-Disposition"))==null?void 0:d.startsWith("attachment"),y=p?"blob":t||_C(l.headers.get("Content-Type"),n);p||y==="blob"||y==="file"?h=await l.blob():y==="json"?typeof o=="function"?(h=await l.text(),h=o(h)):h=await l.json():y==="js"?(h=await l.text(),h=Go(h)):h=await l.text(),a&&(h=await a(h,y)),this.data=h;const b=(s==null?void 0:s(h,y))??h;this._emit("success",b,f,l)}else throw this.data=await l.text(),new Error(f)}catch(f){this.data===void 0&&h!==void 0&&(this.data=h),c=f;let p=!1;c.name==="AbortError"&&(this._abortError?c=this._abortError:p=!0),this.error=c,p||this._emit("error",c,l==null?void 0:l.statusText,c.message)}if(this._timeoutID&&clearTimeout(this._timeoutID),this._emit("complete",l,l==null?void 0:l.statusText),c&&r)throw c;return[h,c,l]}}bm=Symbol.toStringTag,Ir.globalBeforeSends=[],v.ajax=(i,e)=>{e=e||{},typeof i=="string"?e.url=i:v.extend(e,i);const t=new Ir(e);return t.send(),t},v.getJSON=(i,e,t)=>(typeof e=="function"&&(t=e,e=void 0),v.ajax({url:i,data:e,success:t,dataType:"json"})),v.get=(i,e,t,n,s="GET")=>{let r,o;return typeof e=="function"?(r=e,o=void 0):o=e,typeof t=="function"?(r=t,n=void 0):n=t,v.ajax({method:s,url:i,data:o,success:r,dataType:n})},v.post=(i,e,t,n)=>v.get(i,e,t,n,"POST"),v.fn.load=function(i,e,t){typeof e=="function"&&(t=e,e=void 0);const[n,s]=i.split(" ");return v.get(n,e,(r,o,a)=>{s&&(r=v(r).find(s).html()),v(this).html(r).zuiInit(),t==null||t.call(this,r,o,a)},"html"),this};async function Ne(i,e=[],t,n,s){const r={throws:!0,dataType:"json"};if(typeof i=="string")r.url=i;else if(typeof i=="object")v.extend(r,i);else if(typeof i=="function"){const l=i.call(n,...e);return l instanceof Promise?await l:l}t&&v.extend(r,typeof t=="function"?t(r):t),r.url&&(r.url=De(r.url,...e));const o=new Ir(r);s==null||s(o);const[a]=await o.send();return a}function Sh(i){return!!(i&&(typeof i=="string"||typeof i=="object"&&i.url||typeof i=="function"))}v.fetch=Ne;function Mr(i,e={}){const t=v(i)[0];if(!t)return!1;let{viewport:n}=e;const{left:s,top:r,width:o,height:a}=t.getBoundingClientRect();if(e.checkZeroSize&&!(o*a))return!1;if(!n)if(e.container)n=v(t).closest(e.container)[0].getBoundingClientRect();else{const{innerHeight:y,innerWidth:b}=window,{clientHeight:w,clientWidth:x}=document.documentElement;n={left:0,top:0,width:b||x,height:y||w}}const{left:l,top:c,width:h,height:d}=n;if(e.fullyCheck)return s>=l&&r>=c&&s+o<=h+l&&r+a<=d+c;const f=s<=l+h&&s+o>=l;return r<=c+d&&r+a>=c&&f}v.fn.isVisible=function(i){return Mr(this,i)};function bC(i,e="both"){return(e==="vert"||e==="both")&&i.clientHeight<i.scrollHeight||(e==="horz"||e==="both")&&i.clientWidth<i.scrollWidth}function Cm(i,e){const t=v(i),{ifNeeded:n=!0,container:s,...r}=e||{};return t.each((o,a)=>{if(s){const l=v(a).closest(s);if(!l.length||!bC(l[0]))return}if(n){if(a.scrollIntoViewIfNeeded)return a.scrollIntoViewIfNeeded(r);if(Mr(a,{viewport:a.getBoundingClientRect()}))return}a.scrollIntoView(r)}),t}v.fn.scrollIntoView=function(i){return this.each((e,t)=>{Cm(t,i)})};function Th(i,e){const t=v(i),n=new ResizeObserver(e);return t.each((s,r)=>{n.observe(r)}),n}v.fn.resize=function(i){return Th(this,i)};function ha(i){const e=v(i);e.css({minHeight:0});const t=+(e.css("max-height")||"").replace("px","");let n=Math.max(32,e[0].scrollHeight);return t&&n>t&&(n=t),e.css({minHeight:n})}v.fn.autoHeight=function(i){return this.each(function(){const e=v(this);e.data("auto-height")||e.on("input paste change",function(){ha(this)}).data("auto-height",!0),i!=null&&i.fast||ha(e),setTimeout(()=>ha(e),100)})},v.autoHeight=ha;const wC=Object.freeze(Object.defineProperty({__proto__:null,isElementDetached:En,isVisible:Mr,listenResize:Th,scrollIntoView:Cm},Symbol.toStringTag,{value:"Module"}));var $h,Wt,Dh,xm,km=0,Sm=[],mt=tt,Tm=mt.__b,$m=mt.__r,Dm=mt.diffed,Im=mt.__c,Mm=mt.unmount,Nm=mt.__;function CC(i,e){mt.__h&&mt.__h(Wt,i,km||e),km=0;var t=Wt.__H||(Wt.__H={__:[],__h:[]});return i>=t.__.length&&t.__.push({}),t.__[i]}function Em(i,e){var t=CC($h++,7);return SC(t.__H,e)&&(t.__=i(),t.__H=e,t.__h=i),t.__}function xC(){for(var i;i=Sm.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(da),i.__H.__h.forEach(Ih),i.__H.__h=[]}catch(e){i.__H.__h=[],mt.__e(e,i.__v)}}mt.__b=function(i){Wt=null,Tm&&Tm(i)},mt.__=function(i,e){i&&e.__k&&e.__k.__m&&(i.__m=e.__k.__m),Nm&&Nm(i,e)},mt.__r=function(i){$m&&$m(i),$h=0;var e=(Wt=i.__c).__H;e&&(Dh===Wt?(e.__h=[],Wt.__h=[],e.__.forEach(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.forEach(da),e.__h.forEach(Ih),e.__h=[],$h=0)),Dh=Wt},mt.diffed=function(i){Dm&&Dm(i);var e=i.__c;e&&e.__H&&(e.__H.__h.length&&(Sm.push(e)!==1&&xm===mt.requestAnimationFrame||((xm=mt.requestAnimationFrame)||kC)(xC)),e.__H.__.forEach(function(t){t.u&&(t.__H=t.u),t.u=void 0})),Dh=Wt=null},mt.__c=function(i,e){e.some(function(t){try{t.__h.forEach(da),t.__h=t.__h.filter(function(n){return!n.__||Ih(n)})}catch(n){e.some(function(s){s.__h&&(s.__h=[])}),e=[],mt.__e(n,t.__v)}}),Im&&Im(i,e)},mt.unmount=function(i){Mm&&Mm(i);var e,t=i.__c;t&&t.__H&&(t.__H.__.forEach(function(n){try{da(n)}catch(s){e=s}}),t.__H=void 0,e&&mt.__e(e,t.__v))};var Am=typeof requestAnimationFrame=="function";function kC(i){var e,t=function(){clearTimeout(n),Am&&cancelAnimationFrame(e),setTimeout(i)},n=setTimeout(t,35);Am&&(e=requestAnimationFrame(t))}function da(i){var e=Wt,t=i.__c;typeof t=="function"&&(i.__c=void 0,t()),Wt=e}function Ih(i){var e=Wt;i.__c=i.__(),Wt=e}function SC(i,e){return!i||i.length!==e.length||e.some(function(t,n){return t!==i[n]})}var TC=Symbol.for("preact-signals");function ua(){if(ys>1)ys--;else{for(var i,e=!1;Nr!==void 0;){var t=Nr;for(Nr=void 0,Nh++;t!==void 0;){var n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Lm(t))try{t.c()}catch(s){e||(i=s,e=!0)}t=n}}if(Nh=0,ys--,e)throw i}}function gs(i){if(ys>0)return i();ys++;try{return i()}finally{ua()}}var Qe=void 0;function Mh(i){var e=Qe;Qe=void 0;try{return i()}finally{Qe=e}}var Nr=void 0,ys=0,Nh=0,fa=0;function Pm(i){if(Qe!==void 0){var e=i.n;if(e===void 0||e.t!==Qe)return e={i:0,S:i,p:Qe.s,n:void 0,t:Qe,e:void 0,x:void 0,r:e},Qe.s!==void 0&&(Qe.s.n=e),Qe.s=e,i.n=e,32&Qe.f&&i.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Qe.s,e.n=void 0,Qe.s.n=e,Qe.s=e),e}}function vt(i,e){this.v=i,this.i=0,this.n=void 0,this.t=void 0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}vt.prototype.brand=TC,vt.prototype.h=function(){return!0},vt.prototype.S=function(i){var e=this,t=this.t;t!==i&&i.e===void 0&&(i.x=t,this.t=i,t!==void 0?t.e=i:Mh(function(){var n;(n=e.W)==null||n.call(e)}))},vt.prototype.U=function(i){var e=this;if(this.t!==void 0){var t=i.e,n=i.x;t!==void 0&&(t.x=n,i.e=void 0),n!==void 0&&(n.e=t,i.x=void 0),i===this.t&&(this.t=n,n===void 0&&Mh(function(){var s;(s=e.Z)==null||s.call(e)}))}},vt.prototype.subscribe=function(i){var e=this;return _t(function(){var t=e.value,n=Qe;Qe=void 0;try{i(t)}finally{Qe=n}},{name:"sub"})},vt.prototype.valueOf=function(){return this.value},vt.prototype.toString=function(){return this.value+""},vt.prototype.toJSON=function(){return this.value},vt.prototype.peek=function(){var i=Qe;Qe=void 0;try{return this.value}finally{Qe=i}},Object.defineProperty(vt.prototype,"value",{get:function(){var i=Pm(this);return i!==void 0&&(i.i=this.i),this.v},set:function(i){if(i!==this.v){if(Nh>100)throw new Error("Cycle detected");this.v=i,this.i++,fa++,ys++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ua()}}}});function fe(i,e){return new vt(i,e)}function Lm(i){for(var e=i.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Rm(i){for(var e=i.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){i.s=e;break}}}function zm(i){for(var e=i.s,t=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}i.s=t}function Gs(i,e){vt.call(this,void 0),this.x=i,this.s=void 0,this.g=fa-1,this.f=4,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}Gs.prototype=new vt,Gs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fa))return!0;if(this.g=fa,this.f|=1,this.i>0&&!Lm(this))return this.f&=-2,!0;var i=Qe;try{Rm(this),Qe=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Qe=i,zm(this),this.f&=-2,!0},Gs.prototype.S=function(i){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}vt.prototype.S.call(this,i)},Gs.prototype.U=function(i){if(this.t!==void 0&&(vt.prototype.U.call(this,i),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},Gs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;i!==void 0;i=i.x)i.t.N()}},Object.defineProperty(Gs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=Pm(this);if(this.h(),i!==void 0&&(i.i=this.i),16&this.f)throw this.v;return this.v}});function Ce(i,e){return new Gs(i,e)}function Fm(i){var e=i.u;if(i.u=void 0,typeof e=="function"){ys++;var t=Qe;Qe=void 0;try{e()}catch(n){throw i.f&=-2,i.f|=8,Eh(i),n}finally{Qe=t,ua()}}}function Eh(i){for(var e=i.s;e!==void 0;e=e.n)e.S.U(e);i.x=void 0,i.s=void 0,Fm(i)}function $C(i){if(Qe!==this)throw new Error("Out-of-order effect");zm(this),Qe=i,this.f&=-2,8&this.f&&Eh(this),ua()}function Ei(i,e){this.x=i,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e==null?void 0:e.name}Ei.prototype.c=function(){var i=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{i()}},Ei.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fm(this),Rm(this),ys++;var i=Qe;return Qe=this,$C.bind(this,i)},Ei.prototype.N=function(){2&this.f||(this.f|=2,this.o=Nr,Nr=this)},Ei.prototype.d=function(){this.f|=8,1&this.f||Eh(this)},Ei.prototype.dispose=function(){this.d()};function _t(i,e){var t=new Ei(i,e);try{t.c()}catch(s){throw t.d(),s}var n=t.d.bind(t);return n[Symbol.dispose]=n,n}var Ah;function Ai(i,e){tt[i]=e.bind(null,tt[i]||function(){})}function pa(i){Ah&&Ah(),Ah=i&&i.S()}function Om(i){var e=this,t=i.data,n=IC(t);n.value=t;var s=Em(function(){for(var r=e.__v;r=r.__;)if(r.__c){r.__c.__$f|=4;break}return e.__$u.c=function(){var o,a=e.__$u.S(),l=s.value;a(),I.isValidElement(l)||((o=e.base)==null?void 0:o.nodeType)!==3?(e.__$f|=1,e.setState({})):e.base.data=l},Ce(function(){var o=n.value.value;return o===0?0:o===!0?"":o||""})},[]);return s.value}Om.displayName="_st",Object.defineProperties(vt.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Om},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ai("__b",function(i,e){if(typeof e.type=="string"){var t,n=e.props;for(var s in n)if(s!=="children"){var r=n[s];r instanceof vt&&(t||(e.__np=t={}),t[s]=r,n[s]=r.peek())}}i(e)}),Ai("__r",function(i,e){pa();var t,n=e.__c;n&&(n.__$f&=-2,(t=n.__$u)===void 0&&(n.__$u=t=function(s){var r;return _t(function(){r=this}),r.c=function(){n.__$f|=1,n.setState({})},r}())),pa(t),i(e)}),Ai("__e",function(i,e,t,n){pa(),i(e,t,n)}),Ai("diffed",function(i,e){pa();var t;if(typeof e.type=="string"&&(t=e.__e)){var n=e.__np,s=e.props;if(n){var r=t.U;if(r)for(var o in r){var a=r[o];a!==void 0&&!(o in n)&&(a.d(),r[o]=void 0)}else t.U=r={};for(var l in n){var c=r[l],h=n[l];c===void 0?(c=DC(t,l,h,s),r[l]=c):c.o(h,s)}}}i(e)});function DC(i,e,t,n){var s=e in i&&i.ownerSVGElement===void 0,r=fe(t);return{o:function(o,a){r.value=o,n=a},d:_t(function(){var o=r.value.value;n[e]!==o&&(n[e]=o,s?i[e]=o:o?i.setAttribute(e,o):i.removeAttribute(e))})}}Ai("unmount",function(i,e){if(typeof e.type=="string"){var t=e.__e;if(t){var n=t.U;if(n){t.U=void 0;for(var s in n){var r=n[s];r&&r.d()}}}}else{var o=e.__c;if(o){var a=o.__$u;a&&(o.__$u=void 0,a.d())}}i(e)}),Ai("__h",function(i,e,t,n){(n<3||n===9)&&(e.__$f|=2),i(e,t,n)}),re.prototype.shouldComponentUpdate=function(i,e){var t=this.__$u,n=t&&t.s!==void 0;for(var s in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){if(!(n||2&this.__$f||4&this.__$f)||1&this.__$f)return!0}else if(!(n||4&this.__$f)||3&this.__$f)return!0;for(var r in i)if(r!=="__source"&&i[r]!==this.props[r])return!0;for(var o in this.props)if(!(o in i))return!0;return!1};function IC(i){return Em(function(){return fe(i)},[])}const Ph=new Map,Bm={};function st(i,e){typeof i=="object"?Object.keys(i).forEach(t=>{st(t,i[t])}):e&&(Bm[i]=e,Ph.set(i.toLowerCase(),e))}function jm(i){return Ph.get(i.toLowerCase())}class Ve extends re{constructor(e){super(e),this._gid=Xe(),this.state=this.getDefaultState(e)}get gid(){return this._gid}get element(){return document.querySelector(`[z-gid-${this._gid}]`)}get i18nData(){return[this.props.i18n,this.constructor.i18n]}get commandScope(){return this.constructor.NAME}getDefaultState(e){return{}}resetState(e,t){const n=this.getDefaultState(e);t?this.state=n:this.changeState(n)}i18n(e,t,n){const{i18nData:s}=this;return be(s,e,t,n,this.props.lang,this.constructor.NAME)??be(s,e,t,n,this.props.lang)??`{i18n:${e}}`}changeState(e,t){return new Promise(n=>{this.setState(e,()=>{t==null||t(),n(this.state)})})}executeCommand(e,t=[]){const{onCommand:n,commands:s}=this.props;let r;typeof e=="string"&&(e={name:e});const{scope:o,name:a}=e,l=s?s[`${o}~${a}`]||s[a]:null;return l?l.call(this,e,t):((!e.scope||e.scope===this.commandScope)&&(r=nn(this,e.name,t)),n&&(r=n.call(this,e,t)),r)}_getClassName(e){return e.className}_getProps(e){const{className:t,attrs:n,props:s,data:r,forwardRef:o,children:a,component:l,style:c,class:h,commands:d,onCommand:f,...p}=e,y=new Set(this.constructor.customProps),b="dangerouslySetInnerHTML",w=Object.keys(p).reduce((x,T)=>{if(!y.has(T)&&(T===b||/^(on[A-Z]|data-|zui-|z-)[a-zA-Z-]+/.test(T))){const D=p[T];x[T]=T!==b&&D&&typeof D=="object"?JSON.stringify(D):D}return x},{});return{ref:o,className:U(this._getClassName(e),h),style:c,[`z-gid-${this._gid}`]:"",...w,...n,...s}}_getComponent(e){const{component:t="div"}=e;return(typeof t=="string"?jm(t):t)||t}_getChildren(e){return e.children}_beforeRender(e){return e}_onRender(e,t,n,s){return[e,t,n]}componentDidMount(){const{commands:e,onCommand:t}=this.props;(e||t)&&Mi(this.element,{commands:e,scope:this.commandScope,onCommand:this.executeCommand.bind(this)})}componentWillUnmount(){const{commands:e,onCommand:t}=this.props;(e||t)&&$r(this.element,this.commandScope)}render(e){e=this._beforeRender(e)||e;let t=this._getComponent(e),n=this._getChildren(e),s=this._getProps(e);const r=this._onRender(t,s,n,e);return r&&([t,s,n]=r),g(t,s,n)}}Ve.HElement=!0,Ve.customProps=[];class Er extends Ve{constructor(e){super(e),this.signals={};const{state:t}=this;this.changeState(t),this.state={}}changeState(e,t){return new Promise(n=>{gs(()=>{typeof e=="function"&&(e=e(this.state));for(const s in e){const r=this.signals[s];r?r.value=e[s]:this.signals[s]=fe(e[s])}n(this.state),t==null||t()})})}resetState(e){this.changeState(this.getDefaultState(e))}}Er.HElementSignals=!0;var MC=0;function k(i,e,t,n,s,r){e||(e={});var o,a,l=e;if("ref"in l)for(a in l={},e)a=="ref"?o=e[a]:l[a]=e[a];var c={type:i,props:l,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--MC,__i:-1,__u:0,__source:s,__self:r};if(typeof i=="function"&&(o=i.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return tt.vnode&&tt.vnode(c),c}class An extends re{constructor(){super(...arguments),this._ref=pe()}_runJS(){this.props.executeScript&&v(this._ref.current).runJS().zuiInit()}componentDidMount(){this._runJS()}componentDidUpdate(e){this.props.html!==e.html&&this._runJS()}render(e){const{executeScript:t,html:n,...s}=e;return k(Ve,{forwardRef:this._ref,dangerouslySetInnerHTML:{__html:n},...s})}}function Hm(i){const{tag:e,className:t,style:n,renders:s,generateArgs:r=[],generatorThis:o,generators:a,onGenerate:l,onRenderItem:c,...h}=i,d=[t],f={...n},p=[],y=[];return s.forEach(b=>{const w=[];if(typeof b=="string"&&a&&a[b]&&(b=a[b]),typeof b=="function")if(l)w.push(...l.call(o,b,p,...r));else{const x=b.call(o,p,...r);x&&(Array.isArray(x)?w.push(...x):w.push(x))}else w.push(b);w.forEach(x=>{x!=null&&(typeof x=="object"&&!I.isValidElement(x)&&("html"in x||"__html"in x||"className"in x||"style"in x||"attrs"in x||"children"in x)?x.html?p.push(k("div",{className:U(x.className),style:x.style,dangerouslySetInnerHTML:{__html:x.html},...x.attrs??{}})):x.__html?y.push(x.__html):(x.style&&Object.assign(f,x.style),x.className&&d.push(x.className),x.children&&p.push(x.children),x.attrs&&Object.assign(h,x.attrs)):p.push(x))})}),y.length&&Object.assign(h,{dangerouslySetInnerHTML:{__html:y}}),[{className:U(d),style:f,...h},p]}function Lh({tag:i="div",...e}){const[t,n]=Hm(e);return g(i,t,...n)}class ma extends re{constructor(){super(...arguments),this.state={},this._ref=pe()}async load(e){const{props:t}=this,{fetcher:n,type:s,fetcherArgs:r,fetcherThis:o=this,clearBeforeLoad:a}=t;this.setState({loading:!0,error:void 0,...a?{content:void 0}:{}});try{const l=await Ne(e||n,r,{throws:!0,dataType:s==="custom"?"json":"text"},o,c=>{this._ajax=c});this.setState({content:l,loading:!1})}catch(l){this.setState({error:l,loading:!1})}this._ajax=void 0}componentDidMount(){this.load(),v(this._ref.current).on("loadContent.zui",(e,t)=>{e.stopPropagation(),this.load(t)})}componentDidUpdate(e){(this.props.fetcher!==e.fetcher||this.props.fetcherArgs!==e.fetcherArgs||this.props.fetcherThis!==e.fetcherThis)&&this.load()}componentWillUnmount(){var e;(e=this._ajax)==null||e.abort(),v(this._ref.current).off(".zui")}_renderContent(e,t){const{loading:n,error:s,content:r=""}=this.state,{loadingContent:o,errorText:a,type:l,clearBeforeLoad:c,...h}=t;return n&&c?o:s?a??s.message:l==="html"?k(An,{html:r,executeScript:!0,...h}):l==="text"?r:k(de,{content:r,...h})}render(e){const{loading:t}=this.state,{id:n,loadingClass:s,loadingIndicator:r,className:o,style:a,attrs:l,loadingText:c,...h}=e;return k("div",{id:n,ref:this._ref,className:U("lazy-content",o,t?s:"",r?"load-indicator":""),"data-loading":c,style:a,...l,children:this._renderContent(e,h)})}}ma.defaultProps={type:"html",loadingIndicator:!0,loadingClass:"loading",clearBeforeLoad:!0};function ga(i){const{content:e,generatorArgs:t,generatorThis:n,...s}=i;let r=e;if(typeof r=="function"&&(r=r.call(n,...t||[])),Array.isArray(r))return r.map(o=>ga({...s,content:o,generatorThis:n,generatorArgs:t}));if(typeof r=="string"||typeof r=="number")return Object.keys(s).length?k("div",{...s,children:r}):r;if(r&&typeof r=="object"&&(typeof r.html=="string"||r.component||r.fetcher)){if(r.fetcher)return k(ma,{...Pe(s,r)});if(r.html)return k(An,{...Pe(s,r)});const{children:o,...a}=r;return o&&(r=Pe({children:(Array.isArray(o)?o:[o]).map(l=>ga({...s,content:l,generatorThis:n,generatorArgs:t}))},a)),k(Ve,{...Pe(s,r)})}return I.isValidElement(r)?r:(r&&(console.groupCollapsed("[ZUI] CustomContent format error"),console.trace("content:",r),console.log("props:",i),console.groupEnd()),null)}function de(i){const e=ga(i);return e==null||typeof e=="boolean"?null:I.isValidElement(e)?e:k(ps,{children:e})}class Um extends re{render(e){return de(e)}}const Vm=i=>i.startsWith("icon-")?i:`icon-${i}`;function $e(i){const{icon:e,className:t,...n}=i;if(!e)return null;if(I.isValidElement(e))return e;const s=["icon",t];if(typeof e=="string")s.push(Vm(e));else if(typeof e=="object"){const{className:r,icon:o,...a}=e;s.push(r,o?Vm(o):""),Object.assign(n,a)}return k("i",{className:U(s),...n})}function NC(i){return this.getChildContext=()=>i.context,i.children}function Rh(i){const e=this,t=i._container;e.componentWillUnmount=function(){ms(null,e._temp),e._temp=null,e._container=null},e._container&&e._container!==t&&e.componentWillUnmount(),i._vnode?(e._temp||(e._container=t,e._temp={nodeType:1,parentNode:t,childNodes:[],appendChild(n){this.childNodes.push(n),e._container.appendChild(n)},insertBefore(n,s){this.childNodes.push(n),e._container.appendChild(n)},removeChild(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e._container.removeChild(n)}}),ms(g(NC,{context:e.context},i._vnode),e._temp)):e._temp&&e.componentWillUnmount()}function Wm(i,e){const t=g(Rh,{_vnode:i,_container:e});return t.containerInfo=e,t}class ya extends re{constructor(){super(...arguments),this._ref=pe(),this._eleRef=pe()}get $(){return this._ref.current}initZuiComponent(){this._ref.current&&this._ref.current.destroy();const{$tagName:e,$rootAttrs:t,$forceUpdate:n,$use:s,$options:r,...o}=this.props;this._ref.current=ia(s,this._eleRef.current,{...r,...o})}updateZuiComponent(){var a;const{$tagName:e,$rootAttrs:t,$forceUpdate:n,$use:s,$options:r,...o}=this.props;(a=this._ref.current)==null||a.render({...r,...o})}componentDidMount(){this.initZuiComponent()}componentDidUpdate(e){e.$forceUpdate!==this.props.$forceUpdate||e.$use!==this.props.$use||e.$tagName!==this.props.$tagName?this.initZuiComponent():this.updateZuiComponent()}componentWillUnmount(){var e;(e=this._ref.current)==null||e.destroy()}render(e){const{$tagName:t="div",$rootAttrs:n}=e;return k(t,{ref:this._eleRef,...n})}}st({HElement:Ve,element:Ve,HtmlContent:An,html:An,CustomContent:de,LazyContent:ma,custom:de,lazy:ma,Icon:$e,Portal:Rh,ZUI:ya});class ve extends qe{constructor(){super(...arguments),this._ref=pe()}get $(){return this._ref.current}get i18nData(){const{i18n:e,i18nData:t}=this.constructor.Component;return t?[...t,this.constructor.i18n]:[e,...super.i18nData]}afterInit(){this.render()}destroy(){var e,t;(t=(e=this.$)==null?void 0:e.componentWillUnmount)==null||t.call(e),this.element&&(this.element.innerHTML=""),super.destroy()}_getRenderProps(e){return{ref:this._ref,...e}}render(e,t){var p;const{element:n,$:s}=this,{Component:r,replace:o}=this.constructor;super.render(e,t);const{$replace:a=o,$optionsFromDataset:l,$class:c,$style:h,...d}=this.options,f=this._getRenderProps(d);if(t&&((p=s==null?void 0:s.resetState)==null||p.call(s,f)),a&&r.HElement&&(n.tagName.toLowerCase()===a||a===!0)){const y=Array.from(n.attributes).reduce((b,w)=>{const{name:x,value:T}=w;return b[x==="class"?"className":x]=T,b},{});ms(g(r,Pe({component:n.tagName.toLowerCase(),attrs:y},f)),n.parentElement,n)}else ms(g(r,f),n)}executeCommand(e,t){try{return nn(this.$,e,t,this.$,!0)}catch{return super.executeCommand(e,t)}}static renderHTML(e){const t=document.createElement("div");return ms(g(this.Component,e),t),t.innerHTML}}ve.replace=!1;class va extends ve{}va.NAME="Custom",va.Component=Um,va.register();var Km=function(i,e,t,n){var s;e[0]=0;for(var r=1;r<e.length;r++){var o=e[r++],a=e[r]?(e[0]|=o?1:2,t[e[r++]]):e[++r];o===3?n[0]=a:o===4?n[1]=Object.assign(n[1]||{},a):o===5?(n[1]=n[1]||{})[e[++r]]=a:o===6?n[1][e[++r]]+=a+"":o?(s=i.apply(a,Km(i,a,t,["",null])),n.push(s),a[0]?e[0]|=2:(e[r-2]=0,e[r]=s)):n.push(a)}return n},qm=new Map;function zh(i){var e=qm.get(this);return e||(e=new Map,qm.set(this,e)),(e=Km(this,e.get(i)||(e.set(i,e=function(t){for(var n,s,r=1,o="",a="",l=[0],c=function(f){r===1&&(f||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,f,o):r===3&&(f||o)?(l.push(3,f,o),r=2):r===2&&o==="..."&&f?l.push(4,f,0):r===2&&o&&!f?l.push(5,0,!0,o):r>=5&&((o||!f&&r===5)&&(l.push(r,0,o,s),r=6),f&&(l.push(r,f,0,s),r=6)),o=""},h=0;h<t.length;h++){h&&(r===1&&c(),c(h));for(var d=0;d<t[h].length;d++)n=t[h][d],r===1?n==="<"?(c(),l=[l],r=3):o+=n:r===4?o==="--"&&n===">"?(r=1,o=""):o=n+o[0]:a?n===a?a="":o+=n:n==='"'||n==="'"?a=n:n===">"?(c(),r=1):r&&(n==="="?(r=5,s=o,o=""):n==="/"&&(r<5||t[h][d+1]===">")?(c(),r===3&&(l=l[0]),r=l,(l=l[0]).push(2,0,r),r=0):n===" "||n===" "||n===`
  6. `||n==="\r"?(c(),r=2):o+=n),r===3&&o==="!--"&&(r=4,l=l[0])}return c(),l}(i)),e),arguments,[])).length>1?e:e[0]}const EC=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];let Fh=i=>String(i).replace(/[&<>"']/g,e=>`&${AC[e]};`),AC={"&":"amp","<":"lt",">":"gt",'"':"quot","'":"apos"},Oh="dangerouslySetInnerHTML",Gm={className:"class",htmlFor:"for"},Zm={};function Ym(i,e){let t=[],n="";e=e||{};for(let s=arguments.length;s-- >2;)t.push(arguments[s]);if(typeof i=="function")return e.children=t.reverse(),i(e);if(i){if(n+="<"+i,e)for(let s in e)e[s]!==!1&&e[s]!=null&&s!==Oh&&(n+=` ${Gm[s]?Gm[s]:Fh(s)}="${Fh(e[s])}"`);n+=">"}if(EC.indexOf(i)===-1){if(e[Oh])n+=e[Oh].__html;else for(;t.length;){let s=t.pop();if(s)if(s.pop)for(let r=s.length;r--;)t.push(s[r]);else n+=Zm[s]===!0?s:Fh(s)}n+=i?`</${i}>`:""}return Zm[n]=!0,n}const PC=zh.bind(g),Jm=zh.bind(Ym);class we extends Ve{_beforeRender(e){const{text:t,loading:n,loadingText:s,caret:r,icon:o,trailingIcon:a,children:l}=e;this._isEmptyText=t==null||typeof t=="string"&&!t.length||n&&!s,this._onlyCaret=r&&this._isEmptyText&&!o&&!a&&!l&&!n}_getChildren(e){const{loading:t,loadingIcon:n,loadingText:s,icon:r,iconClass:o,text:a,textClass:l,children:c,trailingIcon:h,trailingIconClass:d,caret:f}=e;return[t?k($e,{icon:n||"icon-spinner-snake",className:"spin"}):k($e,{icon:r,className:o}),a==null?null:k("span",{className:U("text",l),children:t?s:a}),t?null:c,t?null:k($e,{icon:h,className:d}),t?null:f?k("span",{className:typeof f=="string"?`caret-${f}`:"caret"}):null]}_getClassName(e){const{type:t,className:n,disabled:s,loading:r,active:o,children:a,square:l,size:c,rounded:h}=e;return["btn",t,n,{"btn-caret":this._onlyCaret,disabled:s||r,active:o,loading:r,square:l===void 0?!this._onlyCaret&&!a&&this._isEmptyText:l},c?`size-${c}`:"",typeof h=="string"?`rounded-${h}`:{rounded:h}]}_getComponent(e){return e.component||(e.url?"a":"button")}_getProps(e){const t=this._getComponent(e),{url:n,target:s,disabled:r,btnType:o="button",size:a,hint:l,command:c}=e,h=t==="a",d={...super._getProps(e),type:h?void 0:"button",disabled:!h&&r?"":void 0,title:l};return o&&(["button","reset","submit"].includes(o)?t==="button"&&(d.type=o):d.className=U([d.className,o])),r||(n!==void 0&&(d[h?"href":"data-url"]=n),s!==void 0&&(d[h?"target":"data-target"]=s),c&&(d["zui-command"]=c)),a&&typeof a=="number"&&Pe(d,{style:{"--btn-height":`${a}px`}}),d}}st(Object.freeze(Object.defineProperty({__proto__:null,Button:we},Symbol.toStringTag,{value:"Module"})));const oD="",aD="",lD="",cD="";let es=class extends Ve{constructor(e){super(e),this._handleChange=t=>{const{onChange:n}=this.props,s=t.target.indeterminate?"indeterminate":t.target.checked;this._controlled||this.setState({checked:s}),n&&n.call(this,t,s)},this.state={checked:e.checked??e.defaultChecked??!1},this._controlled=e.checked!==void 0}get checked(){return this._controlled?this.props.checked:this.state.checked}_getClassName(e){const{disabled:t,type:n="checkbox"}=e,{checked:s}=this;return[e.className,n==="switch"?n:`${n}-primary`,{disabled:t,checked:s===!0,indeterminate:s==="indeterminate"}]}_getChildren(e){const{name:t,type:n,value:s,id:r,label:o}=e,{checked:a}=this;return[t!==!1?k("input",{type:n==="radio"?n:"checkbox",name:t,id:r,value:s,onChange:this._handleChange,indeterminate:a==="indeterminate",checked:typeof a=="boolean"?a:void 0},"input"):null,k("label",{htmlFor:r,children:k(de,{content:o})},"label")]}};class LC extends es{}LC.defaultProps={type:"radio"};class RC extends es{}RC.defaultProps={type:"switch"};class zC extends Ve{constructor(e){super(e),this._defaultID=`_check-list-${this._gid}`,this._handleChange=t=>{var l;const n=t.target.checked,{checked:s,isRadio:r}=this;if(r&&!n)return;const o=t.target.value;let a;r?a=o:a=n?s.includes(o)?s:[...s,o]:s.filter(c=>c!==o),a!==s&&(this._controlled||this.setState({checked:a}),t.stopPropagation(),(l=this.props.onChange)==null||l.call(this,a,t))},this.state={checked:e.checked??e.defaultChecked??(e.type==="radio"?"":[]),items:Array.isArray(e.items)?e.items:void 0},this._controlled=e.checked!==void 0}get isRadio(){return this.props.type==="radio"}get checked(){return this._controlled?this.props.checked??(this.isRadio?"":[]):this.state.checked}async load(){const{items:e}=this.props;if(!e||Array.isArray(e)){this.state.items!==e&&this.setState({items:Array.isArray(e)?e:[]});return}const t=await Ne(e);e===this.props.items&&this.setState({items:t})}componentDidUpdate(e){const{items:t}=this.props;t&&!Array.isArray(t)&&_r(t,e.items)&&this.load()}_getClassName(e){const{disabled:t,inline:n,type:s="checkbox"}=e,{checked:r}=this;return[e.className,n?"check-list-inline":"check-list",`is-type-${s}`,{disabled:t,loading:this.state.items===void 0,"has-checked":r.length}]}_getProps(e){return Pe(super._getProps(e),{id:this._defaultID})}_getChildren(e){const{name:t,id:n=this._defaultID,disabled:s,type:r="checkbox"}=e,{items:o,checked:a}=this.state;return o==null?void 0:o.map(l=>k(es,{name:t,id:`${n}_${l.value}`,label:l.label??l.text,type:r,value:l.value,checked:a.includes(l.value),onChange:this._handleChange,disabled:s},l.value))}}class _a extends ve{}_a.NAME="Checkbox",_a.Component=es,_a.register();const hD="";let $t=class extends Ve{constructor(e){super(e),this._forceUpdateKeyPrefix=0,this._handleClick=this._handleClick.bind(this)}get name(){return this.props.name||this.constructor.NAME}get itemName(){return this.props.itemName||this.constructor.ITEM_NAME}resetState(e,t){this._forceUpdateKeyPrefix++,super.resetState(e,t)}getItems(){return this._items}getRenderedItem(e){return this._renderedItems.find(t=>t.key===e)}getItem(e){return this._items[this.getItemIndex(e)]}getItemIndex(e){return this._renderedItems.findIndex(t=>t.key===e)}getItemByIndex(e){return this._items[e]}getKey(e){var t,n;return(n=(t=this._renderedItems)==null?void 0:t[e])==null?void 0:n.key}_getItemFromEvent(e,t){var l;const n=(t||e.target).closest("[z-item]");if(!n||!((l=n.parentElement)!=null&&l.hasAttribute(`z-gid-${this._gid}`)))return;const s=+n.getAttribute("z-item"),r=this._items[s];if(!r)return;const o=this.getKey(s);if(o===void 0)return;const a=this._renderedItems[s];return{index:s,item:r,element:n,event:e,key:o,renderedItem:a,relativeTarget:this.props.relativeTarget}}_handleClick(e){var n,s;const t=this._getItemFromEvent(e);if(t)return(n=this.props.onClickItem)==null||n.call(this,t),(s=t.item.onClick)==null||s.call(this,e,t),t}_renderItem(e,t,n){const{beforeRenderItem:s}=e;if(s){const h=s.call(this,t,n);h!==void 0&&(t=h)}const{type:r}=t,o=`${this._forceUpdateKeyPrefix}:${t.key}`;let{itemRender:a}=e;if(a&&typeof a=="object"&&(a=a[r]),a){const h=a.call(this,t,n);if(h!==void 0)return k(de,{"z-key":t.key,"z-item":n,"z-type":r,content:h},o)}const{ItemComponents:l}=this.constructor;let c=l[r];if(!c&&t.component)return k(de,{"z-key":t.key,"z-item":n,"z-type":r,content:{...t}},o);if(c=c||l.default||Ve,Array.isArray(c)){let h=c[1];typeof h=="function"&&(h=h.call(this,t,e)),t=Pe({},h,t),c=c[0]}return k(c,{"z-key":t.key,"z-item":n,"z-type":r,...t},o)}_getItem(e,t,n){if(!t)return!1;const{itemProps:s,itemPropsMap:r={},getItem:o,itemKey:a}=e,{type:l=this.constructor.defaultItemType}=t,{name:c,itemName:h}=this,{defaultItemProps:d={},defaultItemPropsMap:f={}}=this.constructor;if(t=Pe({type:l},d,f[l],s,r[l],{className:[c?`${c}-${l}`:"",h]},t,{_item:t,_index:n,key:String((a?t[a]:t.key)??t.key??n),onClick:void 0}),o){const p=o.call(this,t,n);if(p!==void 0)return p}return t}_getProps(e){const t=super._getProps(e);return{onClick:this._handleClick,...t}}_getClassName(e){return[this.name,e.className]}_getItems(e){let{items:t=[]}=e;typeof t=="function"?t=t.call(this):Array.isArray(t)||(t=[]);const{getItems:n}=e;if(n){const s=n.call(this,t);if(s!==void 0)return s}return t}_renderItems(e,t){return this._renderedItems=t.map((n,s)=>{const r=this._getItem(e,n,s);return r||void 0}),this._renderedItems.reduce((n,s,r)=>(s&&n.push(this._renderItem(e,s,r)),n),[])}_getChildren(e){const t=this._getItems(e);this._items=t;const n=this._renderItems(e,t);return e.children&&n.push(e.children),n}_getComponent(e){return e.component||this.constructor.TAG}};$t.NAME="CommonList",$t.ITEM_NAME="item",$t.TAG="ul",$t.ItemComponents={default:Ve,text:[Ve,i=>{const{text:e}=i;return{children:k("span",{className:"text",children:e})}}],divider:[Ve,{className:"divider"}],space:[Ve,i=>{const{space:e,flex:t,style:n}=i;return{style:{width:e,height:e,flex:t,...n}}}]},$t.defaultItemProps={component:"li"},$t.defaultItemPropsMap={},$t.defaultItemType="item",$t.defaultProps={itemKey:"id"};const FC=Object.freeze(Object.defineProperty({__proto__:null,CommonList:$t},Symbol.toStringTag,{value:"Module"}));let un=class extends $t{_isBtnType({type:e}){return e==="item"||e==="dropdown"}_getItem(e,t,n){if(!t)return!1;t.type||(t=v.extend({type:t.dropdown||t.items?"dropdown":"item"},t));let s=super._getItem(e,t,n);return s&&(this._isBtnType(s)&&(s=Pe({},this._shareBtnProps,s)),s)}_beforeRender(e){const{btnProps:t,btnType:n,size:s}=e;this._shareBtnProps=Pe({},t,ch({btnType:n,size:s}))}};un.NAME="btn-group",un.TAG="nav",un.ItemComponents={...$t.ItemComponents,default:we},un.defaultItemProps={component:void 0};const dD="",ba=class Vb extends un{_getProps(e){const{gap:t}=e,n=super._getProps(e);return t&&(typeof t=="number"?n.className=U(n.className,`gap-${t}`):n.style=v.extend(n.style||{},{gap:t})),n}_getItem(e,t,n){const s=super._getItem(e,t,n);if(!s)return s;const{type:r}=s,o=r==="btn-group"||r==="btnGroup";return o&&(s.btnProps=Pe({},this._shareBtnProps,s.btnProps)),(o||r==="dropdown")&&!s.relativeTarget&&(s.relativeTarget=e.relativeTarget),s}static render(e,t,n,s){let r=typeof e=="function"?e.call(s??this,...t):e;if(r)return Array.isArray(r)&&(r={items:r}),n&&(r=Pe(n,r)),k(Vb,{...r})}};ba.NAME="toolbar",ba.defaultProps={btnProps:{btnType:"ghost"}},ba.ItemComponents={...un.ItemComponents,btnGroup:un,angle:[Ve,{className:"angle chevron-right opacity-50 text-xs"}],"btn-group":un};let Fe=ba;const OC=Object.freeze(Object.defineProperty({__proto__:null,Toolbar:Fe},Symbol.toStringTag,{value:"Module"}));let Ar=class extends Ve{constructor(e){super(e),this._handleClickHeader=t=>{const n=t.target;(n.closest(".collapsible-toggle-btn")||this.props.toggleOnClickHeader&&!n.closest("a,button"))&&this.toggle()},this.state={collapsed:e.collapsed??e.defaultCollapsed??!1}}get collapsed(){return this.props.collapsed??this.state.collapsed}toggle(e){const{collapsed:t,onChange:n}=this.props;if(t===void 0){let s;this.setState(r=>(e=e??!r.collapsed,e!==r.collapsed?(s=e,{collapsed:e}):null),()=>{n&&typeof s=="boolean"&&n.call(this,s)})}else e=e??!t,t!==e&&(n==null||n.call(this,e))}_getClassName(e){const{disabled:t,header:n,bordered:s,title:r,actions:o}=e,{collapsed:a}=this;return[e.className,"collapsible",{disabled:t,bordered:s,"no-header":n===void 0&&r===void 0&&o===void 0,"is-collapsed":a}]}_renderHeader(e){const{header:t,headerClass:n,collapsedIcon:s,expandedIcon:r,toggleButton:o,title:a,actions:l,caption:c}=e,{collapsed:h}=this,d=h?s:r;return k("div",{className:U("collapsible-header",n),onClick:this._handleClickHeader,children:[k(we,{className:"collapsible-toggle-btn",size:"sm",type:"ghost",icon:d,square:!0,...o,children:d?null:k("span",{class:`text-xs ${h?"chevron-right":"chevron-down"}`})}),a?k(de,{className:"collapsible-header-title",content:a}):null,c?k(de,{className:"collapsible-header-caption",content:c}):null,t?k(de,{content:t}):null,l?k("div",{className:"flex-1"}):null,l?Fe.render(l,[],{key:"actions",className:"collapsible-header-actions",relativeTarget:e,size:"sm"},this):null]},"header")}_renderBody(e){const{content:t,contentClass:n,children:s,onlyHideOnCollapsed:r}=e;return!r&&this.collapsed?null:k("div",{className:U("collapsible-body",n),children:[k(de,{content:t}),s]},"content")}_getChildren(e){return[this._renderHeader(e),this._renderBody(e)]}};Ar.defaultProps={toggleOnClickHeader:!0,onlyHideOnCollapsed:!0};class wa extends ve{}wa.NAME="Collapsible",wa.Component=Ar,wa.replace=!0;const uD="";class Pr extends ve{}Pr.NAME="CommonList",Pr.Component=$t,Pr.replace=$t.TAG,Pr.register(),st(FC);const fD="",pD="",mD="",gD="",yD="",vD="";function BC(i){if(i.indexOf("#")===0&&(i=i.slice(1)),i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),i.length!==6)throw new Error(`Invalid HEX color "${i}".`);return[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16)]}function jC(i){const[e,t,n]=typeof i=="string"?BC(i):i;return e*.299+t*.587+n*.114>186}function Xm(i,e){return jC(i)?(e==null?void 0:e.dark)??"#333333":(e==null?void 0:e.light)??"#ffffff"}function Qm(i,e=255){return Math.min(Math.max(i,0),e)}function HC(i,e,t){i=i%360/360,e=Qm(e),t=Qm(t);const n=t<=.5?t*(e+1):t+e-t*e,s=t*2-n,r=o=>(o=o<0?o+1:o>1?o-1:o,o*6<1?s+(n-s)*o*6:o*2<1?n:o*3<2?s+(n-s)*(2/3-o)*6:s);return[r(i+1/3)*255,r(i)*255,r(i-1/3)*255]}function UC(i,e){return/^[\u4e00-\u9fa5\s]+$/.test(i)?i.length<=e?i:i.substring(i.length-e):/^[A-Za-z\d\s]+$/.test(i)?i[0].toUpperCase():i.length<=e?i:i.substring(0,e)}let ts=class extends re{render(){const{className:e,style:t,size:n="",circle:s,rounded:r,background:o,foreColor:a,icon:l,text:c,code:h,displayText:d,maxTextLength:f=2,src:p,hueDistance:y=43,saturation:b=.4,lightness:w=.6,children:x,...T}=this.props,D=["avatar",e],N={...t,background:o,color:a};let A=32;n&&(typeof n=="number"?(N.width=`${n}px`,N.height=`${n}px`,N.fontSize=`${Math.max(12,Math.round(n/2))}px`,A=n):(D.push(`size-${n}`),A={xs:20,sm:24,lg:48,xl:80}[n])),s?D.push("circle"):r&&(typeof r=="number"?N.borderRadius=`${r}px`:D.push(`rounded-${r}`));let z;if(p)D.push("has-img"),z=k("img",{className:"avatar-img",src:p,alt:c});else if(l)D.push("has-icon"),z=k($e,{icon:l});else if(c!=null&&c.length||d!=null&&d.length){const O=d??UC(c||"",f),K=O.length;D.push("has-text",`has-text-${K}`);let Z;A&&A<16*K&&(Z={transform:`scale(${A/(16*K)})`,whiteSpace:"nowrap"}),z=k("div",{"data-actualSize":A,className:"avatar-text",style:Z,children:O})}if(!p)if(o===void 0){const O=(h??c??d)||"",K=(typeof O=="number"?O:mh(O))*y%360;if(N.background=`hsl(${K},${b*100}%,${w*100}%)`,!a){const Z=HC(K,b,w);N.color=Xm(Z)}}else!a&&o&&/#?[0-9a-fA-F]{6}/.test(o)&&(N.color=Xm(o));return k("div",{className:U(D),style:N,...T,children:[z,x]})}};const VC=Object.freeze(Object.defineProperty({__proto__:null,Avatar:ts},Symbol.toStringTag,{value:"Module"}));class Pn extends Ve{_renderLeading(e){const{icon:t,iconClass:n,avatar:s,toggleIcon:r,leading:o,leadingClass:a,checked:l,checkbox:c,multiline:h}=e,d=[];if(r&&d.push(k(de,{content:r},"toggleIcon")),l!==void 0&&d.push(k(es,{className:"item-checkbox",checked:l,...c},"checkbox")),t&&d.push(k($e,{className:U("item-icon",n),icon:t},"icon")),s){const p=typeof s=="function"?s.call(this,e):s;p&&(p.className=U("item-avatar",p.className),d.push(k(ts,{...p},"avatar")))}const f=o?k(de,{content:o},"leading"):null;return f&&d.push(f),h?d.length?[k("div",{className:U("item-leading",a),children:d},"leading")]:[]:d}_renderContent(e,t){const{textClass:n,titleClass:s,titleAttrs:r,subtitle:o,subtitleClass:a,url:l,target:c,content:h,contentClass:d,contentAttrs:f}=e,p=l&&!t,y=p?"a":"div";let{title:b,text:w}=e;return b===void 0&&(b=w,w=null),[k("div",{className:U("item-content",d),...f,children:[b?k(y,{className:U("item-title",s),href:p?l:void 0,target:p?c:void 0,...r,children:k(de,{content:b})},"title"):null,o?k("div",{className:U("item-subtitle",a),children:k(de,{content:o})},"subtitle"):null,w?k("div",{className:U("item-text text",n),children:w},"text"):null,h?k(de,{content:h},"extraContent"):null]},"content")]}_renderTrailing(e){const{multiline:t,trailing:n,trailingClass:s,trailingIcon:r,trailingIconClass:o,actions:a}=e,l=[];r&&l.push(k($e,{className:U("item-trailing-icon",o),icon:r},"trailing-icon")),a&&l.push(Fe.render(a,[e],{key:"actions",className:"item-actions",relativeTarget:e,size:"sm"},this));const c=n?k(de,{content:n},"trailing"):null;return c&&l.push(c),t?l.length?[k("div",{className:U("item-trailing",s),children:[l,c]},"trailing")]:[]:l}_render(e,t){const{innerComponent:n,innerClass:s,innerAttrs:r,url:o,actions:a,target:l,active:c,disabled:h,divider:d,checked:f,multiline:p,title:y,subtitle:b,hint:w,selected:x,command:T,hover:D}=e,N=n||(o&&!a?"a":"div"),A=N==="a",z=Pe({key:"item",title:w,className:U("listitem",s,{active:c,disabled:h,"has-divider":d,"no-hover":D===!1,selected:x,checked:f,multiline:p??!!(y&&b),state:A&&!h})},T?{"zui-command":T}:null,A?{href:o||"javascript:;",target:l}:null,t,r);return k(N,{...z,children:[this._renderLeading(e),this._renderContent(e,A),this._renderTrailing(e)]})}_onRender(e,t,n,s){const r=Object.keys(t).reduce((o,a)=>(a.startsWith("data-")&&(o[a]=t[a],delete t[a]),o),{});return[e,t,[this._render(s,r),...Xo(n)]]}}let ht=class extends $t{constructor(e){super(e),this._activeSet=new Ws(()=>{const t=new Set,{active:n}=this.props;Array.isArray(n)?n.forEach(r=>t.add(r)):typeof n=="string"?t.add(n):n&&Object.keys(n).forEach(r=>n[r]&&t.add(r));const{activeMap:s}=this.state;return Object.keys(s).forEach(r=>s[r]?t.add(r):t.delete(r)),t},()=>[this.state.activeMap,this.props.active]),this.state={checked:{},activeMap:{}}}get namespace(){return`.zui.${this.constructor.NAME}.list_${this.gid}`}get isLazyItems(){const{items:e}=this.props;return e&&!Array.isArray(e)}componentDidMount(){this._afterRender(!0),this.tryLoad(),this.props.activeOnHover&&!this.props.multipleActive&&v(this.element).on(`mouseenter${this.namespace}`,"[z-item]",e=>{const t=this._getItemFromEvent(e);t&&t.renderedItem.type==="item"&&!t.renderedItem.disabled&&t.renderedItem.hover!==!1&&!this.isActive(t.key)&&this.toggleActive(t.key,!0)})}componentDidUpdate(){this._afterRender(!1),this.tryLoad()}componentWillUnmount(){var e;v(this.element).off(this.namespace),(e=this.props.beforeDestroy)==null||e.call(this)}setItems(e,t){const{onLoadFail:n}=this.props;return this.changeState({loading:!1,items:e||[],loadFailed:t?(typeof n=="function"?n.call(this,t):n)||String(t):void 0})}load(){const{items:e,onLoad:t}=this.props;this._loadedSetting=e,this.setState({loading:!0,items:[]},async()=>{try{const n=await Ne(e,[this],{throws:!0});this.setItems((t==null?void 0:t.call(this,n))||n)}catch(n){this.setItems(void 0,n)}})}tryLoad(){const{loading:e}=this.state,{items:t}=this.props;return e||!t||Array.isArray(t)||t===this._loadedSetting?!1:(this.load(),!0)}isChecked(e,t,n=!1){const s=(typeof t=="number"?this._items[t]:this.getItem(e))||{};return this.state.checked[e]??s.checked??n}isAllChecked(){return this._renderedItems.every(({key:e},t)=>this.isChecked(e,t)===!0)}toggleAllChecked(e){return e===void 0&&(e=!this.isAllChecked()),this.toggleChecked(this._renderedItems.map(t=>t.key),e)}async toggleChecked(e,t){let n;if(Array.isArray(e)){if(!e.length)return;t===void 0&&(t=!this.isChecked(e[0])),n=e.reduce((s,r)=>(s[r]=t,s),{})}else if(typeof e=="object")n=e;else{const s=this.isChecked(e);t===void 0&&(t=!s),n={[e]:t}}Object.keys(n).length&&await this.changeState(s=>({checked:{...s.checked,...n}}),()=>{var r;const s=this.state.checked;(r=this.props.onCheck)==null||r.call(this,n,Object.keys(s).filter(o=>s[o]===!0))})}getChecks(){return this._renderedItems.reduce((e,{key:t},n)=>(t!==void 0&&this.isChecked(t,n)===!0&&e.push(t),e),[])}isActive(e){return typeof e=="object"&&(e=e.key),this._activeSet.cache.has(e)}getActiveKeys(){return[...this._activeSet.value]}getActiveKey(){return this.getActiveKeys()[0]}async toggleActive(e,t){typeof e=="string"&&(e=[e]),e.length&&(t=t??!this.isActive(e[0]),await this.changeState(n=>({activeMap:this.props.multipleActive?e.reduce((r,o)=>(r[o]=t,r),{...n.activeMap}):{[e[0]]:t}}),()=>{var n;(n=this.props.onActive)==null||n.call(this,e,t)}))}getNextItem(e,t,n=1,s=void 0){s=s||this._renderedItems,t=t||(l=>l.type==="item"&&!l.disabled);const r=s.length;let o=e===void 0?r-1:s.findIndex(l=>l.key===e),a=0;for(;a<r;){o=(o+n+r)%r;const l=s[o];if(l&&!l.hidden&&t.call(this,l,o))return l;a++}}getPrevItem(e,t){return this.getNextItem(e,t,-1)}activeNext(e,t=1){const n=this.getNextItem(this.getActiveKey(),e,t);n&&this.toggleActive(n.key)}activePrev(e){this.activeNext(e,-1)}activeFirst(e){const t=this.getNextItem(void 0,e);t&&this.toggleActive(t.key)}_afterRender(e){var t;(t=this.props.afterRender)==null||t.call(this,e)}_beforeRender(e){var t;return(t=this.props.beforeRender)==null?void 0:t.call(this,e)}_getItems(e){const{items:t}=e,{items:n}=this.state;return n||(Array.isArray(t)?t:[])}_getRenderedItem(e,t,n){const{divider:s,multiline:r}=e;t=Pe({},ch({divider:s,multiline:r}),t);const{itemName:o,name:a}=this;if(t.innerClass=[o?`${o}-inner${a?` ${a}-${t.type}-inner`:""}`:"",t.innerClass],t.type==="item"){const{checkbox:l}=e;t.checkbox===!1?t.checked=void 0:(l||t.checkbox)&&(t.checked=this.isChecked(t.key,n,t.checked),typeof l=="object"&&t.checkbox!==!1&&(t.checkbox=t.checkbox?v.extend({},l,t.checkbox):l),e.selectOnChecked&&t.checked===!0&&(t.selected=!0)),t.active===void 0&&this.isActive(t)&&(t.active=!0)}return t.icon&&(this._hasIcons=!0),t.checked!==void 0&&(this._hasCheckbox=!0),t}_getItem(e,t,n){const s=super._getItem(e,t,n);return s&&this._getRenderedItem(e,s,n)}_renderItem(e,t,n){return t.type==="item"&&this._hasIcons&&t.icon===void 0&&(t.icon="EMPTY"),super._renderItem(e,t,n)}_handleClick(e){const t=super._handleClick(e);let{checkOnClick:n}=this.props;if(n==="any"?n=".item-checkbox,.item-content,.item-icon":n===!0&&(n=".item-checkbox"),!n||!t||!t.renderedItem)return t;const s=t.renderedItem,r=s.checkbox;if(r!==!1&&(this.props.checkbox||r||s.checked!==void 0)&&!s.disabled&&t&&e.target.closest(n)){this.toggleChecked(t.key),e.stopPropagation();return}return t}_getClassName(e){const{loading:t,loadFailed:n}=this.state;return[super._getClassName(e),t?"loading":n?"is-load-failed":"",e.hoverItemActions?"with-hover-actions":""]}_getProps(e){const{className:t,...n}=super._getProps(e);return{...n,className:U(t,this._hasIcons?"has-icons":"",this._hasCheckbox?"has-checkbox":"")}}_getChildren(e){this._hasIcons=!1,this._hasCheckbox=!1,this._activeSet.compute();const t=super._getChildren(e),{loadFailed:n}=this.state;return n&&t.push(n),t}};ht.ItemComponents={...$t.ItemComponents,default:Ve,item:Pn,heading:Pn},ht.NAME="list";const Bh="```ZUI_STR\n";class Lr{constructor(e="",t="local"){this._cache=new Map,this._type=t,this._id=e,this._name=`ZUI_STORE:${this._id}`,this._storage=t==="local"?localStorage:sessionStorage}get type(){return this._type}get session(){return this.type==="session"?this:(this._altStorage||(this._altStorage=new Lr(this._id,"session")),this._altStorage)}_getKey(e){return`${this._name}:${e}`}switch(e){this._id=e,this._name=`ZUI_STORE:${this._id}`,this._cache.clear()}get(e,t){if(this._cache.has(e))return this._cache.get(e);const n=this._storage.getItem(this._getKey(e));if(typeof n=="string"){if(n.startsWith(Bh))return n.substring(Bh.length);try{return JSON.parse(n)}catch{}}return n??t}setCache(e,t){this._cache.set(e,t)}set(e,t){if(t==null)return this.remove(e);try{this._storage.setItem(this._getKey(e),typeof t=="string"?`${Bh}${t}`:JSON.stringify(t))}catch(n){this.setCache(e,t),console.warn(`[ZUI] Failed to set value to ${this._type} store: ${this._getKey(e)}, use cache instead.`,n)}}remove(e){this._cache.delete(e),this._storage.removeItem(this._getKey(e))}each(e){const t=[];for(let n=0;n<this._storage.length;n++){const s=this._storage.key(n);if(s!=null&&s.startsWith(this._name)){const r=this._storage.getItem(s),o=s.substring(this._name.length+1);typeof r=="string"&&e(o,JSON.parse(r)),t.push(o)}}for(const n of this._cache.keys())t.includes(n)||e(n,this._cache.get(n))}getAll(){const e={};this.each((t,n)=>{e[t]=n});for(const t of this._cache.keys())e[t]=this._cache.get(t);return e}}const nt=new Lr("DEFAULT");function WC(i,e="local"){return new Lr(i,e)}Object.assign(nt,{create:WC});const _D="";function eg(i,e){const{children:t}=i;t.length&&t.forEach(n=>{e(n),eg(n,e)})}function KC(i,e){let t=i.parent;for(;t;)e(t),t=t.parent}function tg(i){return i.split(":").reduce((e,t,n)=>(e.push(n?e[n-1]+":"+t:t),e),[])}function jh(i,e,t,n,s=0,r){return i.reduce((o,a,l)=>{if(!a)return o;const c=String((e?a[e]:a.key)??a.key??l),h=r?`${r.keyPath}:${c}`:c,d={key:c,level:s,keyPath:h,parentKey:r==null?void 0:r.keyPath,parent:r,data:a,children:[]};return r&&r.children.push(d),o=t(o,d),Array.isArray(a.items)?jh(a.items,e,t,o,s+1,d):o},n)}let ns=class extends ht{constructor(e){super(e);const{defaultNestedShow:t,preserve:n,nestedShow:s}=e;if(v.extend(this.state,typeof t=="boolean"?{defaultShow:t,nestedShow:{}}:{nestedShow:t||{}},s!==void 0?{nestedShow:s}:null),n&&s===void 0){this._storeID=`${this.constructor.NAME}:${n}:state`;const r=nt.get(this._storeID);r&&(this.state.nestedShow=r.nestedShow)}if(!e.level){const r=this.state.nestedShow;r&&Object.keys(r).forEach(o=>{r[o]&&tg(o).forEach(a=>{r[a]=!0})}),this._needInitChecks=!0}this._renderedItemMap=new Map,this._handleClick=this._handleClick.bind(this),this._beforeRenderNestedItem=this._beforeRenderNestedItem.bind(this),this._handleNestedToggle=this._handleNestedToggle.bind(this),this._handleNestedCheck=this._handleNestedCheck.bind(this),this._preserveState=this._preserveState.bind(this)}get isRoot(){return!this.props.level}get nestedShow(){return this.props.nestedShow??this.state.nestedShow??!1}async setItems(e,t){var s;this.isRoot&&(this._needInitChecks=!0);const n=await super.setItems(e,t);return e&&((s=this.props.parent)==null?void 0:s.checked)===!0?this.toggleChecked(this._renderedItems.map(r=>r.key),!0):e!=null&&e.some(r=>r.checked)&&(this._needInitChecks=!0,this.forceUpdate()),n}getItemMap(e){if(e&&(this._itemMap||this._itemMapCache))return this._itemMap||this._itemMapCache;if(!this._itemMap){let t=!1;const n=jh(this._items,this.props.itemKey,(s,r)=>(s.set(r.keyPath,r),r.data.items&&!Array.isArray(r.data.items)&&(t=!0),s),new Map);if(t)return this._renderedItemMap.forEach((s,r)=>{n.has(r)||n.set(r,{key:s.key,level:s._level,keyPath:r,parentKey:`${r.split(":").slice(0,-1).join(":")}`,children:[],data:s})}),n.forEach(s=>{const{parentKey:r}=s;if(!r)return;const o=n.get(r);o&&(o.children.push(s),s.parent=o)}),this._itemMapCache=n,n;this._itemMap=n}return this._itemMap}getRenderedItem(e){return this._renderedItemMap.get(e)}getItem(e){var s;const t=this._itemMap||this._itemMapCache;if(t)return(s=t.get(e))==null?void 0:s.data;const n=this.getRenderedItem(e);return n?n._item:super.getItem(e)}isExpanded(e){const{nestedShow:t}=this;return typeof t=="boolean"?t:!!(t[e]??this.state.defaultShow)}isAllExpanded(){const{nestedShow:e}=this;if(typeof e=="boolean")return e;const{defaultShow:t}=this.state;if(!Object.keys(e).length)return!!t;const n=this.getItemMap(!0);return Array.from(n.entries()).every(([s])=>e[s]??t)}async toggle(e,t,n){const s=this.isExpanded(e);if(!n&&t===s)return;t===void 0&&(t=!s);const{nestedShow:r,onToggle:o,accordion:a}=this.props;o&&o.call(this,e,t,n)===!1||r===void 0&&await this.changeState(l=>{let c={...n?{}:l.nestedShow,[e]:t};if(t&&a){let h=`${e.split(":").slice(0,-1).join(":")}`;h.length&&(h+=":"),Object.keys(c).forEach(d=>{d!==e&&d.startsWith(h)&&(c[d]=!1)})}return c=t?tg(e).reduce((h,d)=>(h[d]=t,h),c):c,{nestedShow:c}},this._preserveState)}toggleAll(e){if(this.props.nestedShow===void 0)return this.setState({nestedShow:{},defaultShow:e},this._preserveState)}getChecks(){return Array.from(this.getItemMap(!0).values()).reduce((e,{keyPath:t,data:n})=>{const s=this.state.checked[t];return(s===!0||n.checked&&s!==!1)===!0&&e.push(t),e},[])}isChecked(e,t,n=!1){const s=(typeof t=="number"?this._items[t]:this.getItem(e))||{};return this.isRoot?this.state.checked[e]??s.checked??n:this.props.checkedState[`${this.props.parentKey}:${e}`]??s.checked??n}async toggleChecked(e,t){let n;if(Array.isArray(e)){if(!e.length)return;t===void 0&&(t=!this.isChecked(e[0])),n=e.reduce((a,l)=>(a[l]=t,a),{})}else typeof e=="object"?n=e:(t===void 0&&(t=!this.isChecked(e)),n={[e]:t});if(!Object.keys(n).length)return;if(this.isRoot){await this.changeState(({checked:a,nestedShow:l})=>{const c=p=>n[p.keyPath]??a[p.keyPath]??p.data.checked??!1,h=this.getItemMap(),d={},{expandChildrenOnCheck:f}=this.props;return Object.keys(n).forEach(p=>{t=n[p];const y=h.get(p);y&&(eg(y,b=>{c(b)!==t&&(n[b.keyPath]=t)}),KC(y,b=>{const{children:w}=b,x=w.reduce((T,D)=>(c(D)&&T++,T),0);n[b.keyPath]=x===w.length?!0:x?"indeterminate":!1}),f&&t&&y.data.items&&(d[p]=!0))}),{checked:{...a,...n},nestedShow:{...l,...d}}},()=>{var l;const a=this.state.checked;(l=this.props.onCheck)==null||l.call(this,n,Object.keys(a).filter(c=>a[c]===!0))});return}const{parentKey:s,onCheck:r}=this.props,o=Object.keys(n).reduce((a,l)=>(a[`${s!==void 0?`${s}:`:""}${l}`]=n[l],a),{});r.call(this,o,[])}getKeyPath(e){if(this.isRoot)return e;const t=this.props.parentKey;return e.startsWith(t+":")?e:`${t}:${e}`}isActive(e){if(typeof e=="object"){const t=e._keyPath??e.key;if(t===void 0)return!1;e=t}return this._activeSet.cache.has(this.getKeyPath(e))}async toggleActive(e,t){if(typeof e=="string"&&(e=[e]),e=e.map(n=>this.getKeyPath(n)),this.isRoot){await super.toggleActive(e,t),this.props.toggleOnActive&&e.forEach(n=>{this.isActive(n)&&!this.isExpanded(n)&&this.toggle(n,!0)});return}this.props.onActive.call(this,e,t??!this.isActive(e[0]))}activeNext(e,t=1){const n=this.getNextItem(this.getActiveKey(),e,t);n&&this.toggleActive(n._keyPath)}getNextItem(e,t,n=1,s=void 0){return s=s||jh(this._items,this.props.itemKey,(r,o)=>(o.data.disabled||r.push({_keyPath:o.keyPath,type:"item",...o.data,...this._renderedItemMap.get(o.keyPath),key:o.keyPath}),r),[]),super.getNextItem(e,t,n,s)}_afterRender(e){if(super._afterRender(e),this._needInitChecks){const t={};this.getItemMap().forEach(s=>{s.data.checked!==void 0&&(t[s.keyPath]=s.data.checked)}),this.toggleChecked(t),this._needInitChecks=!1}}_preserveState(){this._storeID&&nt.set(this._storeID,{nestedShow:this.state.nestedShow,defaultShow:this.state.defaultShow})}_getClassName(e){return[super._getClassName(e),"is-nested",e.level?"is-nested-sub":"is-nested-root"]}_getNestedProps(e,t,n,s){const{parentKey:r,level:o=0}=e,{isRoot:a}=this;return Pe(this.constructor.inheritNestedProps.reduce((l,c)=>(l[c]=e[c],l),{}),{key:n.key,level:o+1,className:`is-nested-${s?"expanded":"collapsed"}`,items:t,parent:n,parentKey:r?`${r}:${n.key}`:n.key,nestedShow:this.nestedShow,defaultNestedShow:this.state.defaultShow,checkedState:e.checkedState||this.state.checked,onCheck:a?this._handleNestedCheck:e.onCheck,onToggle:a?this._handleNestedToggle:e.onToggle,beforeRenderItem:a?this._beforeRenderNestedItem:e.beforeRenderItem,active:a?this.getActiveKeys():e.active,onActive:a?this.toggleActive.bind(this):e.onActive},n.listProps)}_renderNestedList(e,t,n,s){if(!s&&!e.renderCollapsedList)return;const r=this._getNestedProps(e,t,n,s),o=this.constructor;return k(o,{...r},`nested:${n.key}`)}_renderNestedToggle(e,t){let n,s="";const{toggleIcons:r={}}=e;return typeof t=="boolean"?(n=t?r.expanded||k("span",{className:"caret-down"}):r.collapsed||k("span",{className:"caret-right"}),s=`state is-${t?"expanded":"collapsed"}`,I.isValidElement(n)||(n=k($e,{icon:n}))):(n=k($e,{icon:r.normal}),s="is-empty"),k("span",{className:U(`${this.name}-toggle nested-toggle-icon`,s),children:n})}_getItems(e){const t=super._getItems(e);return this.isRoot&&t!==this._items&&(this._itemMap=void 0),t}_getItem(e,t,n){const s=super._getItem(e,t,n)??t;if(!s)return s;const{parentKey:r}=e,o=s.key,a=`${r!==void 0?`${r}:`:""}${o}`;if(s.items){const l=s.expanded??this.isExpanded(a);Pe(s,{expanded:l,className:["is-nested",`is-nested-${l?"show":"hide"}`]}),this._hasNestedItems=!0}return Pe(s,{_level:e.level,_keyPath:a,parentKey:r})}_beforeRenderNestedItem(e,t){const{beforeRenderItem:n}=this.props;if(n){const s=n.call(this,e,t);s!==void 0&&(e=s)}return this._renderedItemMap.set(e._keyPath,e),e}_renderItem(e,t,n){(this._hasNestedItems||!this.isRoot)&&t.type==="item"&&t.toggleIcon===void 0&&(t.toggleIcon=this._renderNestedToggle(e,t.expanded));const s=t.items?this._renderNestedList(e,t.items,t,t.expanded):null;return t=Pe(t,{"z-parent":t.parentKey,"z-key-path":t._keyPath},s?{children:s}:null),this._renderedItemMap.set(t._keyPath,t),super._renderItem(e,t,n)}_getItemFromEvent(e,t){t=t||e.target;let n=super._getItemFromEvent(e,t);if(!n){const r=t.closest("[z-list]");if(r){const o=r.getAttribute("z-list"),a=this.getItem(o),l=this.getRenderedItem(o);if(!a||!l)return;n={target:t,index:l._index,item:a,element:r,event:e,key:o,keyPath:o,renderedItem:l}}return}(e.type==="mouseenter"||e.type==="mouseleave"||e.type==="mouseover")&&(n.hover=e.type!=="mouseleave");const{parentKey:s}=this.props;return{...n,parentKey:s,keyPath:`${s!==void 0?`${s}:`:""}${n.key}`,target:t}}_handleNestedToggle(e,t,n){this.toggle(e,t,n)}_handleClick(e){const t=super._handleClick(e);if(t){const{renderedItem:n,keyPath:s,target:r}=t,{nestedToggle:o}=this.props;if(!n.items||e.defaultPrevented||r.closest(".not-nested-toggle")||o&&!n.disabled&&!r.closest(o)||!o&&!n.disabled&&r.closest("a,.btn,.item-checkbox,.open-url,input,select,textarea")&&!r.closest(".nested-toggle-icon,.item-icon"))return t;this.toggle(s),e.preventDefault()}return t}_handleNestedCheck(e){this.toggleChecked(e)}_getProps(e){const{level:t=0,indent:n=20,parentKey:s}=e,r=Pe(super._getProps(e),{"z-level":t,"z-list":s,style:{"--list-nested-indent":`${t*n}px`,"--list-indent":`${n}px`},className:this._hasNestedItems?"has-nested-items":"no-nested-items"});return r.className=U(r.className),r}_beforeRender(e){return this._renderedItemMap.clear(),this._hasIcons=!1,this._hasNestedItems=!1,super._beforeRender(e)}};ns.defaultProps={...ht.defaultProps,defaultNestedShow:!1,level:0,indent:20},ns.inheritNestedProps=["component","name","itemName","itemKey","indent","hover","divider","multiline","toggleIcons","nestedToggle","accordion","itemRender","itemProps","onToggle","checkbox","getItem","getItems","checkOnClick","selectOnChecked","checkedState","onClickItem","activeOnHover","multipleActive","onActive","hoverItemActions"];const qC=Object.freeze(Object.defineProperty({__proto__:null,List:ht,Listitem:Pn,NestedList:ns},Symbol.toStringTag,{value:"Module"}));class Rr extends ve{}Rr.NAME="List",Rr.Component=ht,Rr.replace=ht.TAG,Rr.register();class zr extends ve{}zr.NAME="NestedList",zr.Component=ns,zr.replace=ns.TAG,zr.register(),st(qC);const bD="",wD="",CD="",Pi=class Wb extends ns{constructor(e){super(e),this._handleHover=this._handleHover.bind(this)}get isHoverTrigger(){return this.props.nestedTrigger==="hover"}_getClassName(e){return[super._getClassName(e),this._hasNestedItems?"menu-nested":"",e.className,e.wrap?{"scrollbar-thin":e.scrollbarThin,"scrollbar-hover":e.scrollbarHover}:{popup:e.popup,compact:e.compact}]}_getWrapClass(e){return["menu-wrapper",e.wrapClass,{popup:e.popup,compact:e.compact}]}_getWrapperProps(e){const{wrapAttrs:t,height:n,maxHeight:s,parentKey:r}=e,o=Pe({"z-list-wrapper":r},t,n||s?{style:{height:n,maxHeight:s}}:null,this.isRoot&&this.isHoverTrigger?{onMouseEnter:this._handleHover,onMouseLeave:this._handleHover,onMouseOver:this._handleHover}:null);return o.className=U(this._getWrapClass(e),o.className),o}_renderWrapperHeader(e){return k(de,{content:e.header,generatorThis:this},"header")}_renderWrapperFooter(e){return k(de,{content:e.footer,generatorThis:this},"footer")}_handleHover(e){const t=e.target;if(!(t instanceof HTMLElement)||!this.isHoverTrigger)return;let n;if(e.type!=="mouseleave"){const c=t.closest("[z-item]");if(c)n=c.getAttribute("z-key-path"),c.classList.contains("is-nested")||(n=c.getAttribute("z-parent"));else{const h=t.closest("[z-list-wrapper]");n=h==null?void 0:h.getAttribute("z-list-wrapper")}}const s=this._hoverInfo,r=s==null?void 0:s.keyPath;if(r===n)return;s!=null&&s.timer&&clearTimeout(s.timer);const o=typeof n=="string",l=o?typeof r=="string"&&(s!=null&&s.shown)?50:200:s!=null&&s.shown?100:200;this._hoverInfo={keyPath:n,timer:window.setTimeout(()=>{o?(this.toggle(n,!0,!0),this._hoverInfo.shown=!0):(this.toggleAll(!1),this._hoverInfo=void 0)},l)}}componentWillUnmount(){var t;super.componentWillUnmount();const e=(t=this._hoverInfo)==null?void 0:t.timer;e&&clearTimeout(e)}render(e){const t=super.render(e);return e.wrap?k("menu",{...this._getWrapperProps(e),children:[this._renderWrapperHeader(e),t,this._renderWrapperFooter(e)]}):t}static render(e,t,n,s){let r=typeof e=="function"?e.call(s??this,...t):e;if(r)return Array.isArray(r)&&(r={items:r}),n&&(r=Pe(n,r)),k(Wb,{...r})}};Pi.NAME="menu",Pi.TAG="menu",Pi.inheritNestedProps=[...ns.inheritNestedProps,"compact"],Pi.ItemComponents={...ns.ItemComponents,item:[Pn,{innerComponent:"a"}]},Pi.defaultProps={...ns.defaultProps,scrollbarHover:!0};let Rt=Pi;const xD="",kD="",SD="";let vs=class extends re{constructor(e){super(e),this._input=pe(),this._timer=0,this._handleClearBtnClick=t=>{t.stopPropagation(),this.clear(t)},this._handleChange=t=>{const n=this.state.value,s=t.target.value,{onChange:r,delay:o}=this.props;this.setState({value:s},()=>{!r||n===s||(o?(this._clearTimer(),this._timer=window.setTimeout(()=>{r(s,t),this._timer=0},o)):r(s,t))})},this._handleFocus=t=>{const n=t.type==="focus";this.setState({focus:n},()=>{const s=n?this.props.onFocus:this.props.onBlur;s==null||s(t)})},this.state={focus:!1,value:e.defaultValue||""},this._gid=e.id||`search-box-${Xe()}`}componentDidMount(){const{hotkeys:e}=this.props;if(e){const t=uh(e,{clear:{keys:"Escape",handler:n=>{this.clear(n)}},enter:{keys:"Enter",handler:n=>{var s,r;(r=(s=this.props).onEnter)==null||r.call(s,this.state.value,n)}}});t&&(this._hotkeysScope=`SearchBox_${this._gid}`,v(this.input).hotkeys(t,{scope:this._hotkeysScope,event:"keydown"}))}}componentWillUnmount(){this._hotkeysScope&&v(this.input).unbindHotkeys(this._hotkeysScope)}get id(){return this._gid}get input(){return this._input.current}focus(){var e;(e=this.input)==null||e.focus()}blur(){var e;(e=this.input)==null||e.blur()}clear(e){const t=this.state.value;this.setState({value:""},()=>{const{onChange:n,onClear:s}=this.props;s==null||s(e),this.focus(),t.trim()!==""&&(n==null||n("",e))})}_clearTimer(){this._timer&&clearTimeout(this._timer),this._timer=0}render(e,t){const{style:n,className:s,rootClass:r,rootStyle:o,readonly:a,disabled:l,circle:c,placeholder:h,mergeIcon:d,searchIcon:f,clearIcon:p,value:y,compact:b,prefixClass:w,suffixClass:x,name:T}=e,{focus:D,value:N}=t,{id:A}=this,z=y??N,O=typeof z!="string"||!z.trim().length;let K,Z,ye;return f&&(ye=f===!0?k("span",{class:"magnifier"}):k($e,{icon:f})),!d&&f&&(K=k("label",{for:A,class:U("input-control-prefix",w),children:ye},"prefix")),p&&!O?Z=k("button",{type:"button",class:"btn ghost size-sm square rounded-full",onClick:this._handleClearBtnClick,children:p===!0?k("span",{class:"close"}):k($e,{icon:p})}):d&&f&&(Z=ye),Z&&(Z=k("label",{for:A,class:U("input-control-suffix",x),children:Z},"suffix")),k("div",{class:U("search-box input-control",r,{focus:D,empty:O,compact:b,"has-prefix-icon":K,"has-suffix-icon":Z}),style:o,children:[K,k("input",{ref:this._input,id:A,name:T,type:"text",class:U("form-control",{"rounded-full":c,"size-sm":b},s),style:n,placeholder:h,disabled:l,readonly:a,value:z,onInput:this._handleChange,onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleFocus},"input"),Z]})}};vs.defaultProps={clearIcon:!0,searchIcon:!0,delay:500,hotkeys:!0};const GC=Object.freeze(Object.defineProperty({__proto__:null,SearchBox:vs},Symbol.toStringTag,{value:"Module"}));let dt=class extends Rt{constructor(e){super(e),this._handleSearchChange=t=>{const n=this.constructor.getSearchKeys(t);this._searchKeys=n,this.setState({search:n.join(" ")})},this.state.search=e.search??e.defaultSearch,this._searchKeys=this.constructor.getSearchKeys(this.state.search),this._isNestedItemMatch=this._isNestedItemMatch.bind(this)}componentWillUpdate(e){this.isRoot&&e.search!==void 0&&e.search!==this.props.search&&(this._searchKeys=this.constructor.getSearchKeys(e.search))}componentDidMount(){super.componentDidMount(),this._updateMatchedParents()}componentDidUpdate(){super.componentDidUpdate(),this._updateMatchedParents()}isExpanded(e){return this.props.expandOnSearch&&this._searchKeys.length?!0:super.isExpanded(e)}_updateMatchedParents(){var n;if(!this.isRoot)return;const e=v(this.element),t=e.find(".item.is-nested.is-not-match").filter((s,r)=>this._matchedParents.has(r.getAttribute("z-key-path")||"")).addClass("has-match-child");e.parent().toggleClass("no-match-child",!!((n=this._searchKeys)!=null&&n.length)&&!t.length&&!e.children(".item").not(".is-not-match").length)}_isItemMatch(e,t,n,s){const{isItemMatch:r,nestedSearch:o}=e,a=r?r.call(this,t,this._searchKeys,n,s):this.constructor.isItemMatch(t,this._searchKeys,e.searchProps);if(o&&this.isRoot&&a&&s!==void 0){let l="";String(s).split(":").forEach(c=>{l+=`${l.length?":":""}${c}`,this._matchedParents.add(l)})}return a}_isNestedItemMatch(e,t,n,s){return this._isItemMatch(this.props,e,n,s)}_getNestedProps(e,t,n,s){const r=super._getNestedProps(e,t,n,s);return this.isRoot&&e.nestedSearch?(r.isItemMatch=this._isNestedItemMatch,r.search=this._searchKeys.join(" ")):e.nestedSearch||Pe(r,{search:void 0,defaultSearch:void 0},n.listProps),r}_getItem(e,t,n){const s=super._getItem(e,t,n);return s&&(this.isRoot&&this.props.limit&&this._showCount>=this.props.limit?!1:(s.hidden=!this._isItemMatch(e,t,n,e.parentKey),s.hidden||this._showCount++,s))}_renderItem(e,t,n){return t.hidden&&!this._hasNestedItems?null:(t.className=[t.className,t.hidden?"is-not-match":""],!t.hidden&&e.underlineKeys&&this._searchKeys.length&&["text","title","subtitle","content"].forEach(s=>{typeof t[s]=="string"&&(t[s]=this.constructor.underlineKeys(this._searchKeys,[t[s]]))}),super._renderItem(e,t,n))}_getWrapClass(e){const t=this.isRoot&&this._searchKeys.length;return U(super._getWrapClass(e),"search-menu",e.searchBox?`search-menu-on-${e.searchPlacement||"top"}`:"",t?"is-search-mode":"",t&&e.expandOnSearch?"no-toggle-on-search":"")}_getSearchBoxProps(e){const{searchBox:t}=e,n={compact:!0,className:"not-nested-toggle",onChange:this._handleSearchChange};return typeof t=="object"&&Pe(n,t),e.search!==void 0&&(n.value=this._searchKeys.join(" "),n.disabled=!0),n}_renderSearchBox(e){const t=this._getSearchBoxProps(e);return k(vs,{...t},"search")}_renderWrapperHeader(e){const t=e.header,{noMatchHint:n,searchBox:s,searchPlacement:r,nestedSearch:o,headerClass:a}=e,l=(!o||this.isRoot)&&s&&r!=="bottom";return!t&&!l&&!n?null:[n?k("div",{className:"search-menu-no-match-hint",children:n},"noMatchHint"):null,t||l?k("header",{className:U("search-menu-header",a),children:[t?super._renderWrapperHeader(e):null,l?this._renderSearchBox(e):null]},"header"):null]}_renderWrapperFooter(e){const t=e.footer,{searchBox:n,searchPlacement:s,nestedSearch:r,footerClass:o,exceedLimitHint:a,limit:l}=e,c=(!r||this.isRoot)&&n&&s==="bottom",h=a&&l&&this._items.length>l;return!t&&!c&&!h?null:k("footer",{className:U("search-menu-footer",o),children:[h?k("div",{className:"search-menu-exceed-limit-hint",children:De(a,this._items.length-l)}):null,t?super._renderWrapperFooter(e):null,c?this._renderSearchBox(e):null]},"footer")}_beforeRender(e){return this.isRoot&&(this._matchedParents=new Set,this._showCount=0),super._beforeRender(e)}static isItemMatch(e,t,n=["keys","text","title","subtitle"]){return t.length?t.every(s=>n.some(r=>{const o=typeof r=="function"?r(e):e[r];return typeof o=="string"&&o.length&&o.toLowerCase().includes(s)})):!0}static getSearchKeys(e=""){return v.unique(e.toLowerCase().split(" ").filter(t=>t.length))}static underlineKeys(e,t,n="is-match-keys"){return e.reduce((s,r)=>[...s].reduce((o,a)=>{if(typeof a!="string")return o.push(a),o;const l=a.toLowerCase().split(r);if(l.length===1)return o.push(a),o;let c=0;return l.forEach((h,d)=>{d&&(o.push(k("span",{class:n,children:a.substring(c,c+r.length)})),c+=r.length),o.push(a.substring(c,c+h.length)),c+=h.length}),o},[]),t)}};dt.inheritNestedProps=[...Rt.inheritNestedProps,"isItemMatch","search","underlineKeys","nestedSearch"],dt.defaultProps={...Rt.defaultProps,defaultNestedShow:!0,wrap:!0,nestedSearch:!0,underlineKeys:!0,limit:200};const ZC=Object.freeze(Object.defineProperty({__proto__:null,Menu:Rt,SearchMenu:dt},Symbol.toStringTag,{value:"Module"}));class Ca extends ve{}Ca.NAME="Menu",Ca.Component=Rt,Ca.replace=Rt.TAG;class xa extends ve{}xa.NAME="SearchMenu",xa.Component=dt,xa.replace=dt.TAG,st(ZC);const TD="",$D="",DD="",ID="",MD="",ND="",ED="",AD="",PD="",LD="",RD="";function YC({className:i,style:e,actions:t,heading:n,content:s,contentClass:r,children:o,close:a,onClose:l,icon:c,iconClass:h,...d}){let f;a===!0?f=k(we,{className:"alert-close btn ghost square text-inherit",square:!0,onClick:l,children:k("span",{class:"close"})}):I.isValidElement(a)?f=a:typeof a=="object"&&(f=k(we,{...a,onClick:l}));const p=Fe.render(t,[]);return k("div",{className:U("alert",i),style:e,...d,children:[k($e,{icon:c,className:U("alert-icon",h)}),typeof s!="string"?k(de,{content:s}):k("div",{className:U("alert-content",r),children:[typeof n!="string"?k(de,{content:n}):n&&k("div",{className:"alert-heading",children:n}),k("div",{className:"alert-text",children:s}),n?p:null]}),n?null:p,f,o]})}function JC(i){if(i==="center")return"fade-from-center";if(i){if(i.includes("top"))return"fade-from-top";if(i.includes("bottom"))return"fade-from-bottom"}return"fade"}let XC=class extends re{render(e){const{margin:t,type:n,placement:s,animation:r,show:o,className:a,message:l,html:c,content:h,time:d,...f}=e,p=h?[h]:[];return typeof c=="string"&&p.push({html:c}),l&&p.push(l),k(YC,{className:U("messager",a,n,r===!0?JC(s):r,o?"in":""),content:p,...f})}};class Hh extends ve{constructor(){super(...arguments),this._show=!1,this._showTimer=0,this._afterRender=({firstRender:e})=>{e&&this.show();const{margin:t}=this.options;t&&this.$element.css("margin",`${t}px`)}}get isShown(){return this._show}afterInit(){this.on("click",e=>{v(e.target).closest('.alert-close,[data-dismiss="messager"]').length&&(e.preventDefault(),e.stopPropagation(),this.hide())})}setOptions(e,t){return e=super.setOptions(e,t),{...e,show:this._show,afterRender:this._afterRender}}show(){this.render(),this.emit("show"),this._resetTimer(()=>{this._show=!0,this.render(),this._resetTimer(()=>{this.emit("shown");const{time:e}=this.options;e&&this._resetTimer(()=>this.hide(),e)})},100)}hide(){this._show&&this._resetTimer(()=>{this.emit("hide"),this._show=!1,this.render(),this._resetTimer(()=>{this.emit("hidden")})},50)}_resetTimer(e,t=200){this._showTimer&&clearTimeout(this._showTimer),this._showTimer=window.setTimeout(()=>{e(),this._showTimer=0},t)}}Hh.NAME="MessagerItem",Hh.Component=XC;const Fr=class Kb extends qe{get isShown(){var e;return!!((e=this._item)!=null&&e.isShown)}show(e){this.setOptions(e),this._getItem().show()}hide(){var e;(e=this._item)==null||e.hide()}_getItem(){const e={...this.options};if(this._item)this._item.setOptions(e);else{const t=this._getHolder(),n=new Hh(t,e);n.on("hidden",()=>{n.destroy(),t==null||t.remove(),this._holder=void 0,this._item=void 0}),this._item=n}return this._item}_getHolder(){if(this._holder)return this._holder;const{placement:e="top"}=this.options;let t=this.$element.find(`.messagers-${e}`);t.length||(t=v(`<div class="messagers messagers-${e}"></div>`).appendTo(this.$element));let n=t.find(`#messager-${this.gid}`);return n.length||(n=v(`<div class="messager-holder" id="messager-${this.gid}"></div>`).appendTo(t),this._holder=n[0]),n[0]}static show(e,t){typeof e=="string"&&(e={content:e});const{container:n,...s}=e;t=t??s.type;const r={type:t,key:`messager_${Xe()}`,content:void 0,message:void 0,...t?this.TypeOptions[t]:{},...s},o=Kb.ensure(n||"body",r);return o.hide(),o.show(),o}};Fr.NAME="messager",Fr.DEFAULT={placement:"top",animation:!0,close:!0,margin:6,time:5e3},Fr.MULTI_INSTANCE=!0,Fr.TypeOptions={};let Ln=Fr,ka=class extends re{render(e){const{percent:t=50,color:n,background:s=null,height:r,width:o,children:a,className:l,style:c}=e;return k("div",{class:U("progress",l),style:{width:o,height:r,"--progress-bg":s,"--progress-bar-color":n,...c},children:[k("div",{class:"progress-bar",style:{width:`${t}%`}}),a]})}};ka.defaultProps={percent:50,height:20,width:"auto"},st(Object.freeze(Object.defineProperty({__proto__:null,ProgressBar:ka},Symbol.toStringTag,{value:"Module"})));class Uh extends ve{}Uh.NAME="ProgressBar",Uh.Component=ka,Uh.register();const FD="",OD="";let Sa=class extends re{render(e){const{percent:t=50,size:n=24,circleBg:s,circleColor:r,text:o,className:a,textStyle:l,textX:c,textY:h,children:d}=e,f=n/2;let{circleWidth:p=.1}=e;p<1&&(p=n*p);const y=(n-p)/2;return k("svg",{className:a,width:n,height:n,children:[k("circle",{cx:f,cy:f,r:y,"stroke-width":p,stroke:s,fill:"transparent"}),k("circle",{cx:f,cy:f,r:y,"stroke-width":p,stroke:r,fill:"transparent","stroke-linecap":"round","stroke-dasharray":Math.PI*y*2,"stroke-dashoffset":Math.PI*y*2*(100-t)/100,style:{transformOrigin:"center",transform:"rotate(-90deg)"}}),o?k("text",{x:c??f,y:h??f+p/2,"dominant-baseline":"middle","text-anchor":"middle",style:l||{fontSize:`${y}px`,stroke:"currentColor"},children:o===!0?Math.floor(t):o}):null,d]})}};Sa.defaultProps={circleBg:"var(--color-surface)",circleColor:"var(--color-primary-500)",text:!0};class Ta extends ve{}Ta.NAME="ProgressCircle",Ta.Component=Sa,Ta.register(),st(Object.freeze(Object.defineProperty({__proto__:null,ProgressCircle:Sa},Symbol.toStringTag,{value:"Module"})));const jD="";let ng=class extends re{render(){const{time:e,format:t="yyyy-MM-dd hh:mm",invalidText:n,className:s,...r}=this.props,o=Ye(e);if(!Sr(o))return k("span",{class:U("time-span is-invalid",s),...r,children:n??e});const a=Ze(o,t);return k("span",{class:U("time-span",s),...r,children:a})}};const QC={justNow:"刚刚",xAgo:"{0}前",xLater:"{0}后",lessThanAMinute:"不到1分钟",yesterday:"昨天",dayBeforeYesterday:"前天",tomorrow:"明天",minutes:"{0}分钟",hours:"{0}小时",days:"{0}天",weeks:"{0}周",months:"{0}个月",years:"{0}年"},e0={justNow:"剛剛",xAgo:"{0}前",xLater:"{0}後",lessThanAMinute:"不到1分鐘",yesterday:"昨天",dayBeforeYesterday:"前天",tomorrow:"明天",minutes:"{0}分鐘",hours:"{0}小時",days:"{0}天",weeks:"{0}周",months:"{0}個月",years:"{0}年"},t0={justNow:"Just Now",xAgo:"{0} ago",xLater:"{0} later",lessThanAMinute:"Less than a minute",yesterday:"Yesterday",dayBeforeYesterday:"Day Before Yesterday",tomorrow:"Tomorrow",minutes:"{0} minutes",hours:"{0} hours",days:"{0} days",weeks:"{0} weeks",months:"{0} months",years:"{0} years"};be.addLang({zh_cn:{ago:QC},zh_tw:{ago:e0},en:{ago:t0}});function sg(i,e,t){const n=Ye(i),r=Ye(e).getTime()-n.getTime(),o=Math.abs(r),a=r>0,l=Math.floor(o/1e3),c=Math.floor(l/60),h=Math.floor(c/60),d=Math.floor(h/24),f=Math.floor(d/7),p=Math.floor(d/30),y=Math.floor(d/365),b=(x,T)=>be.getLang(`ago.${x}`,T,x,t)??x,w=x=>b(a?"xAgo":"xLater",[x]);return l<10?b("justNow"):l<60?w(b("lessThanAMinute")):c<60?w(b("minutes",[c])):h<24?w(b("hours",[h])):d===1?b(a?"yesterday":"tomorrow"):d===2&&a?b("dayBeforeYesterday"):d<7?w(b("days",[d])):f<4?w(b("weeks",[f])):p<12?w(b("months",[p])):w(b("years",[y]))}const Vh=class Jf extends re{constructor(){super(...arguments),this.state={tick:0}}componentDidMount(){Jf.register(this)}componentWillUnmount(){Jf.unregister(this)}update(){this.setState(e=>({tick:e.tick+1}))}render(){const{time:e,now:t,lang:n,invalidText:s,className:r,hint:o=!0,hintFormat:a,...l}=this.props,c=Ye(e);if(!Sr(c))return k("span",{class:U("time-ago is-invalid",r),...l,children:s??e});const h=sg(c,t,n),d=o?typeof o=="string"?o:Ze(c,a):void 0;return k("span",{class:U("time-ago",r),title:d,...l,children:h})}static register(e){this.instances.add(e),this.timer===0&&(this.timer=window.setInterval(()=>{this.instances.forEach(t=>t.update())},6e4))}static unregister(e){this.instances.delete(e),this.instances.size===0&&(window.clearInterval(this.timer),this.timer=0)}};Vh.timer=0,Vh.instances=new Set;let ig=Vh;st(Object.freeze(Object.defineProperty({__proto__:null,TimeAgo:ig,TimeSpan:ng},Symbol.toStringTag,{value:"Module"})));class $a extends ve{}$a.NAME="TimeSpan",$a.Component=ng,$a.register();class Da extends ve{}Da.NAME="TimeAgo",Da.Component=ig,Da.register();const UD="",VD="",WD="",KD="",qD="",GD="",ZD="",YD="",Or='[droppable="true"]';class Br extends qe{constructor(){super(...arguments),this._state={dragging:null,dropping:null},this._handleMouseDown=e=>{const{selector:t,handle:n,beforeDrag:s}=this.options,r=v(e.target),o=r.closest(t),a=o[0];!a||n&&!r.closest(n).length||s&&s.call(this,e,a)===!1||(o.attr("draggable","true"),this._setState({dragging:a}))},this._handleDragStart=e=>{const{dragElement:t}=this;if(!t){e.preventDefault();return}const{options:n}=this,{onDragStart:s}=n;if(s&&s.call(this,e,t)===!1){this._clean();return}const{$element:r}=this,{target:o,selector:a,draggingClass:l,droppableClass:c,hasDraggingClass:h,canDrop:d}=n;l&&(this.$element.find(l).removeClass(l),v(t).addClass(l));let f=typeof o=="function"?v(o.call(this,t)):r.find(o||a||Or);if(d&&(f=f.filter((p,y)=>d.call(this,e,t,y)!==!1)),!f.length){this._clean();return}c&&(r.find(c).removeClass(c),f.addClass(c)),h&&r.addClass(h),r.find(Or).removeAttr("droppable"),f.attr("droppable","true"),this._$targets=f},this._handleDrag=e=>{var n;const{dragElement:t}=this;t&&(this._setDragEffect(e),(n=this.options.onDrag)==null||n.call(this,e,t))},this._handleDragEnd=e=>{var n;const{dragElement:t}=this;t&&((n=this.options.onDragEnd)==null||n.call(this,e,t)),this._clean()},this._handleDragEnter=e=>{this._handleDragOver(e)},this._handleDragOver=e=>{var o,a;const{dragElement:t}=this,s=v(e.target).closest(Or)[0];if(!t||!s)return;const r=this.state.dropping;if(e.preventDefault(),this._setDragEffect(e),r!==s){const{droppingClass:l}=this.options;l&&(r&&this._leaveDropElement(e,r),v(s).addClass(l)),this._setState({dropping:s}),(o=this.options.onDragEnter)==null||o.call(this,e,t,s)}(a=this.options.onDragOver)==null||a.call(this,e,t,s)},this._handleDragLeave=e=>{const{dragElement:t}=this,n=v(e.target).filter(Or)[0];!t||!n||(e.preventDefault(),this._leaveDropElement(e,n),this._setState({dropping:null}))},this._handleDrop=e=>{var n;const t=v(e.target).closest(Or)[0];t&&(e.preventDefault(),(n=this.options.onDrop)==null||n.call(this,e,this.dragElement,t)),this._needClean=!0,setTimeout(()=>{this._needClean&&this._clean()},50)}}get state(){return this._state}get dragElement(){return this._state.dragging}get dropElement(){return this._state.dropping}async afterInit(){const{namespace:e}=this,{dragContainer:t,dropContainer:n,onDrag:s}=this.options;this._$dragContainer=t?v(t):this.$element,this._$dropContainer=n?v(n):this._$dragContainer,this._$dragContainer.on("mousedown"+e,this._handleMouseDown).on("dragstart"+e,this._handleDragStart).on("dragend"+e,this._handleDragEnd),s&&this._$dragContainer.on("drag"+e,this._handleDrag),this._$dropContainer.on("dragover"+e,this._handleDragOver).on("dragenter"+e,this._handleDragEnter).on("dragleave"+e,this._handleDragLeave).on("drop"+e,this._handleDrop),v(document).on(`mouseup${this.namespace}`,this._clean.bind(this))}destroy(){this._clean(),v(document).off(this.namespace),this._$dragContainer.off(this.namespace),this._$dropContainer.off(this.namespace),super.destroy()}_setState(e){var r;const t=this._state,{dragging:n=t.dragging,dropping:s=t.dropping}=e;n===t.dragging&&s===t.dropping||(this._state={dragging:n,dropping:s},(r=this.options.onChange)==null||r.call(this,this._state,t))}_setDragEffect(e){const{dropEffect:t}=this.options;t&&(e.dataTransfer.dropEffect=t)}_leaveDropElement(e,t){var s;const{droppingClass:n}=this.options;n&&v(t).removeClass(n),(s=this.options.onDragLeave)==null||s.call(this,e,this.dragElement,t)}_clean(){this._needClean=!0;const{draggingClass:e,droppableClass:t,droppingClass:n,hasDraggingClass:s}=this.options;s&&this.$element.removeClass(s);const{dragElement:r}=this;if(r){const a=v(r);e&&a.removeClass(e)}this._setState({dropping:null,dragging:null});const o=this._$targets;o&&(t&&o.removeClass(t),n&&o.removeClass(n),this._$targets=void 0)}}Br.NAME="Draggable",Br.DEFAULT={selector:'[draggable="true"]',dropEffect:"move",hasDraggingClass:"has-dragging",draggingClass:"is-dragging",droppableClass:"is-droppable",droppingClass:"is-dropping"};const n0='[moveable="true"]',Wh=class qb extends qe{constructor(){super(...arguments),this._handleMouseDown=e=>{const{options:t}=this,{selector:n,handle:s,onMoveStart:r}=t,o=v(e.target),a=n==="self"?this.$element:o.closest(n),l=a[0];if(!l||s&&!o.closest(s).length||r&&r.call(this,e,l)===!1)return;a.attr("moveable","true");const{movingClass:c,hasMovingClass:h}=t;c&&a.addClass(c),h&&this.$element.addClass(h),e.preventDefault();let d;if(this.options.move===!0){const f=v(l).css("position");d=f==="fixed"||f==="absolute"||f==="relative"?"position":"transform"}else d=this.options.move||"none";this._state={event:e,target:l,strategy:d},this._moveStart(e.screenX,e.screenY),v(document).off("mousemove mouseup").on(`mousemove${this.namespace}`,this._handleMouseMove.bind(this)).on(`mouseup${this.namespace}`,this._handleMouseUp.bind(this))},this._handleMouseMove=e=>{!this._state||!e.buttons||(e.preventDefault(),this._moveTo(e.screenX,e.screenY,e))},this._handleMouseUp=e=>{var n;const t=this._state;t&&((n=this.options.onMoveEnd)==null||n.call(this,e,t),this._clean())}}get state(){return this._state}get moveElement(){var e;return(e=this._state)==null?void 0:e.target}get isEdgeDetectionEnabled(){return!!this.options.edgeDetection}get edgeRect(){const e={x:0,y:0,width:0,height:0,padding:0};if(this.isEdgeDetectionEnabled){const{container:t,distance:n}=this.options.edgeDetection;t==="viewport"&&(e.width=window.innerWidth,e.height=window.innerHeight),e.padding=n}return e}async afterInit(){this.on("mousedown",this._handleMouseDown)}destroy(){this._clean(),v(document).off(this.namespace),super.destroy()}_edgeDetect(e,t){if(!this.isEdgeDetectionEnabled)return!1;const{x:n,y:s,width:r,height:o,padding:a}=this.edgeRect,l=!Number.isInteger(a),c=l?a.left:a,h=l?a.right:a,d=l?a.top:a,f=l?a.bottom:a,p={left:n+c,right:n+r-h,top:s+d,bottom:s+o-f},y=this.moveElement.getBoundingClientRect(),b=y.x+e,w=y.y+t,x={left:b,right:b+y.width,top:w,bottom:w+y.height},T=x.left<p.left,D=x.right>p.right,N=x.top<p.top,A=x.bottom>p.bottom;let z=0;D?z=p.right-x.right:T&&(z=p.left-x.left);let O=0;return A?O=p.bottom-x.bottom:N&&(O=p.top-x.top),{x:z,y:O}}_moveBy(e,t){var c,h;let n=e,s=t;const r=this._edgeDetect(e,t);switch(r&&(n+=r.x,s+=r.y),this._state.strategy){case"position":this._moveByPosition(n,s);break;case"transform":this._moveByTransform(n,s);break;case"scroll":this._moveByScroll(n,s);break}const{deltaX:o,deltaY:a,event:l}=this._state;this._state={...this._state,deltaX:o+n,deltaY:a+s},(c=this.options.onMove)==null||c.call(this,l,this._state),(h=this.options.onChange)==null||h.call(this,this._state,this._state,l)}_moveByPosition(e,t){const{target:n}=this._state,s=parseFloat(n.style.left||"0"),r=parseFloat(n.style.top||"0");n.style.left=`${s+e}px`,n.style.top=`${r+t}px`}_moveByTransform(e,t){const{target:n}=this._state,s=qb.getTranslate(n),r=s.left+e,o=s.top+t;n.style.transform=`translate(${r}px, ${o}px)`}_moveByScroll(e,t){const{target:n}=this._state;n.scrollLeft-=e,n.scrollTop-=t}_moveStart(e,t){this._state={...this._state,fromX:e,fromY:t,lastX:e,lastY:t,deltaX:0,deltaY:0}}_moveTo(e,t,n){const{lastX:s,lastY:r}=this._state,o=e-s,a=t-r;this._moveBy(o,a),this._state={...this._state,lastX:e,lastY:t,event:n}}_clean(){v(document).off("mousemove mouseup");const{hasMovingClass:e,movingClass:t}=this.options;e&&this.$element.removeClass(e);const{moveElement:n}=this;if(n){const s=v(n);t&&s.removeClass(t)}this._state=void 0}static getTranslate(e){const n=window.getComputedStyle(e).getPropertyValue("transform");if(n==="none")return{left:0,top:0};const s=n.match(/^matrix\((.+)\)$/);if(!s)return{left:0,top:0};const r=s[1].split(", ");return{left:parseFloat(r[4]),top:parseFloat(r[5])}}};Wh.NAME="Moveable",Wh.DEFAULT={selector:n0,hasMovingClass:"has-moving",movingClass:"is-moving",move:!0,edgeDetection:!1};let _s=Wh;const JD="",rg="zui-resizable-handle";class Kh extends qe{constructor(){super(...arguments),this._isMouseDown=!1,this._handleMouseDown=e=>{e.preventDefault();const n={handle:v(e.target).data("dir"),startX:e.screenX,startY:e.screenY};this._state=n,this._isMouseDown=!0,v(document).on(`mousemove${this.namespace}`,this._handleMouseMove.bind(this)).on(`mouseup${this.namespace}`,this._handleMouseUp.bind(this))},this._handleMouseMove=e=>{if(e.preventDefault(),!this._isMouseDown||!e.buttons)return;let t={x:!1,y:!1};this.isEdgeDetectionEnabled&&(t=this._edgeDetect(e.clientX,e.clientY)),this._moveTo(e.screenX,e.screenY,t.x,t.y),this._state={...this._state,startX:e.screenX,startY:e.screenY}},this._handleMouseUp=e=>{e.preventDefault(),this._isMouseDown=!1,v(document).off(`mousemove${this.namespace} mouseup${this.namespace}`)},this._moveTo=(e,t,n,s)=>{const{handle:r,startX:o,startY:a}=this._state;let l={dx:0,dy:0,dw:0,dh:0};const c=n?0:e-o,h=s?0:t-a,d=this.options.x,f=this.options.y;switch(r){case"n":l={dx:0,dy:f==="top"?h:0,dw:0,dh:-h};break;case"s":l={dx:0,dy:f==="bottom"?h:0,dw:0,dh:h};break;case"w":l={dx:d==="left"?c:0,dy:0,dw:-c,dh:0};break;case"e":l={dx:d==="right"?c:0,dy:0,dw:c,dh:0};break;case"ne":l={dx:d==="right"?c:0,dy:f==="top"?h:0,dw:c,dh:-h};break;case"nw":l={dx:d==="left"?c:0,dy:f==="top"?h:0,dw:-c,dh:-h};break;case"se":l={dx:d==="right"?c:0,dy:f==="bottom"?h:0,dw:c,dh:h};break;case"sw":l={dx:d==="left"?c:0,dy:f==="bottom"?h:0,dw:-c,dh:h};break}this._resizeBy(l)},this._resizeBy=e=>{var h;const t=this._element.getBoundingClientRect(),n=_s.getTranslate(this._element);let s=t.width+e.dw,r=t.height+e.dh,o=n.left+e.dx,a=n.top+e.dy;const{minWidth:l,minHeight:c}=this.options;l&&s<l&&(s=l,o=n.left),c&&r<c&&(r=c,a=n.top),this._element.style.width=`${s}px`,this._element.style.height=`${r}px`,this._element.style.transform=`translate(${o}px, ${a}px)`,(h=this.options.onChange)==null||h.call(this,this._state,{...e,width:s,height:r,x:o,y:a})}}get isEdgeDetectionEnabled(){return!!this.options.edgeDetection}get edgeRect(){const e={x:0,y:0,width:0,height:0,padding:0};if(this.isEdgeDetectionEnabled){const{container:t,distance:n}=this.options.edgeDetection;t==="viewport"&&(e.width=window.innerWidth,e.height=window.innerHeight),e.padding=n}return e}get handles(){return v(this._element).find(`.${rg}`)}async afterInit(){const e=v(this._element);["n","e","s","w","ne","nw","se","sw"].forEach(n=>{const s=v(`<div class="${rg}" data-dir="${n}"></div>`);e.append(s)}),v(this.handles).on("mousedown",this._handleMouseDown)}_edgeDetect(e,t){if(!this.isEdgeDetectionEnabled)return!1;const{x:n,y:s,width:r,height:o,padding:a}=this.edgeRect,l=!Number.isInteger(a),c=l?a.left:a,h=l?a.right:a,d=l?a.top:a,f=l?a.bottom:a,p=n+c,y=n+r-h,b=s+d,w=s+o-f;return{x:e<p||e>y,y:t<b||t>w}}destroy(){v(this.handles).off("mousedown"),v(document).off(`mousemove${this.namespace} mouseup${this.namespace}`)}}Kh.NAME="Resizable",Kh.DEFAULT={edgeDetection:!1,x:"left",y:"top",minWidth:0,minHeight:0};const qh=class Gb extends qe{async afterInit(){const e=await Gb.loadModule(),{options:t}=this;if(t.dragShadow!==void 0&&t.dragShadow!==!0){const{dragShadow:n,onEnd:s,setData:r}=t;t.setData=(o,a)=>{n===!1&&!this._emptyShadow&&(this._emptyShadow=a.cloneNode(!0),this._emptyShadow.classList.add("sortable-empty-shadow"),document.body.appendChild(this._emptyShadow)),o.setDragImage(n===!1?this._emptyShadow:n,0,0),r==null||r(o,a)},t.onEnd=o=>{var a;s==null||s(o),(a=this._emptyShadow)==null||a.remove(),this._emptyShadow=void 0},delete t.dragShadow}this.module=new e(this.element,t)}option(e,t){if(t===void 0)return this.module.option(e);this.module.option(e,t)}closest(e,t){return this.module.closest(e,t)}sort(e,t){this.module.sort(e,t)}save(){this.module.save()}destroy(){var e;super.destroy(),(e=this.module)==null||e.destroy()}toArray(){return this.module.toArray()}static async loadModule(){return this.Module||(this.Module=await v.getLib("sortablejs")),this.Module}};qh.NAME="Sortable",qh.DEFAULT={animation:150};let Ia=qh;v.registerLib("sortablejs",{src:"sortable/sortable.min.js",check:"Sortable"});let jr=class extends ht{componentDidMount(){super.componentDidMount();const e=this._getSortableOptions();e&&(this._sortable=new Ia(this.element,e))}componentWillUnmount(){this._sortable&&this._sortable.destroy()}getOrders(){var e;return((e=this._sortable)==null?void 0:e.toArray())||[]}_getClassName(e){return[super._getClassName(e),"sortable-list"]}_getSortableOptions(){const{sortable:e,canSortTo:t}=this.props;if(!e)return;const n=typeof e=="object"?e:{};return{group:`SortableList.${this.gid}`,dataIdAttr:"z-key",draggable:".list-item",...n,onSort:s=>{var o,a;const r=this.getOrders();(o=this.props.onSort)==null||o.call(this,s,r),(a=n.onSort)==null||a.call(this,s)},onMove:(s,r)=>{var o;if(t){const a=s.dragged.getAttribute("z-key-path"),l=s.related.getAttribute("z-key-path"),c=this.getItem(a),h=this.getItem(l),d=t.call(this,s,c,h);if(d!==void 0)return d}return(o=n.onMove)==null?void 0:o.call(this,s,r)}}}};jr.defaultProps={...ht.defaultProps,sortable:!0};let zt=class extends Rt{_getClassName(e){return[super._getClassName(e),e.lines?"tree-lines":""]}_getItem(e,t,n){return this.constructor.getTreeItem(e,super._getItem(e,t,n))}static getTreeItem(e,t){return t&&(t.type==="item"&&(t.icon===void 0&&(t.icon=t.items?t.expanded?e.expandedIcon:e.collapsedIcon:e.normalIcon),t.actions===void 0&&(t.actions=e.itemActions)),t)}};zt.NAME="tree",zt.defaultProps={...Rt.defaultProps,indent:12},zt.defaultItemProps={...Rt.defaultItemProps,innerComponent:"div"},zt.inheritNestedProps=[...Rt.inheritNestedProps,"itemActions","expandedIcon","collapsedIcon","normalIcon"];let Zs=class extends dt{_getClassName(e){return[super._getClassName(e),e.lines?"tree-lines":""]}_getItem(e,t,n){return zt.getTreeItem(e,super._getItem(e,t,n))}};Zs.NAME="tree",Zs.inheritNestedProps=[...dt.inheritNestedProps,"itemActions","expandedIcon","collapsedIcon","normalIcon"],Zs.ItemComponents={...dt.ItemComponents,item:[Pn,{innerComponent:"div"}]};const s0=Object.freeze(Object.defineProperty({__proto__:null,SearchTree:Zs,Tree:zt},Symbol.toStringTag,{value:"Module"}));let Li=class extends zt{componentDidMount(){super.componentDidMount();const e=this._getSortableOptions();e&&(this._sortable=new Ia(this.element,e))}componentWillUnmount(){this._sortable&&this._sortable.destroy()}getOrders(){var e;return((e=this._sortable)==null?void 0:e.toArray())||[]}_getClassName(e){return[super._getClassName(e),"sortable-tree"]}_getSortableOptions(){const{sortable:e}=this.props;if(!e)return;const t=typeof e=="object"?e:{},{onSort:n,canSortTo:s,parentKey:r}=this.props;return{group:`SortableTree.${this.gid}`,dataIdAttr:"z-key",draggable:".tree-item",...t,onSort:o=>{var l;const a=this.getOrders();n==null||n.call(this,o,a,r),(l=t.onSort)==null||l.call(this,o)},onMove:(o,a)=>{var l;if(s){const c=o.dragged.getAttribute("z-key-path"),h=o.related.getAttribute("z-key-path"),d=this.getItem(c),f=this.getItem(h),p=s.call(this,o,d,f,r);if(p!==void 0)return p}return(l=t.onMove)==null?void 0:l.call(this,o,a)}}}};Li.defaultProps={...zt.defaultProps,sortable:!0},Li.inheritNestedProps=[...zt.inheritNestedProps,"onSort","sortable","canSortTo"];class Ma extends ve{}Ma.NAME="SortableList",Ma.Component=jr,Ma.replace=jr.TAG;class Na extends ve{}Na.NAME="SortableTree",Na.Component=Li,Na.replace=Li.TAG;const XD="";var sn=typeof window<"u"?window:null,Gh=sn===null,Hr=Gh?void 0:sn.document,fn="addEventListener",pn="removeEventListener",Zh="getBoundingClientRect",Ur="_a",mn="_b",ss="_c",Ea="horizontal",gn=function(){return!1},i0=Gh?"calc":["","-webkit-","-moz-","-o-"].filter(function(i){var e=Hr.createElement("div");return e.style.cssText="width:"+i+"calc(9px)",!!e.style.length}).shift()+"calc",og=function(i){return typeof i=="string"||i instanceof String},ag=function(i){if(og(i)){var e=Hr.querySelector(i);if(!e)throw new Error("Selector "+i+" did not match a DOM element");return e}return i},Mt=function(i,e,t){var n=i[e];return n!==void 0?n:t},Aa=function(i,e,t,n){if(e){if(n==="end")return 0;if(n==="center")return i/2}else if(t){if(n==="start")return 0;if(n==="center")return i/2}return i},r0=function(i,e){var t=Hr.createElement("div");return t.className="gutter gutter-"+e,t},o0=function(i,e,t){var n={};return og(e)?n[i]=e:n[i]=i0+"("+e+"% - "+t+"px)",n},a0=function(i,e){var t;return t={},t[i]=e+"px",t},lg=function(i,e){if(e===void 0&&(e={}),Gh)return{};var t=i,n,s,r,o,a,l;Array.from&&(t=Array.from(t));var c=ag(t[0]),h=c.parentNode,d=getComputedStyle?getComputedStyle(h):null,f=d?d.flexDirection:null,p=Mt(e,"sizes")||t.map(function(){return 100/t.length}),y=Mt(e,"minSize",100),b=Array.isArray(y)?y:t.map(function(){return y}),w=Mt(e,"maxSize",1/0),x=Array.isArray(w)?w:t.map(function(){return w}),T=Mt(e,"expandToMin",!1),D=Mt(e,"gutterSize",10),N=Mt(e,"gutterAlign","center"),A=Mt(e,"snapOffset",30),z=Array.isArray(A)?A:t.map(function(){return A}),O=Mt(e,"dragInterval",1),K=Mt(e,"direction",Ea),Z=Mt(e,"cursor",K===Ea?"col-resize":"row-resize"),ye=Mt(e,"gutter",r0),Q=Mt(e,"elementStyle",o0),ne=Mt(e,"gutterStyle",a0);K===Ea?(n="width",s="clientX",r="left",o="right",a="clientWidth"):K==="vertical"&&(n="height",s="clientY",r="top",o="bottom",a="clientHeight");function xe(me,G,he,Te){var Le=Q(n,G,he,Te);Object.keys(Le).forEach(function(it){me.style[it]=Le[it]})}function Me(me,G,he){var Te=ne(n,G,he);Object.keys(Te).forEach(function(Le){me.style[Le]=Te[Le]})}function Re(){return l.map(function(me){return me.size})}function je(me){return"touches"in me?me.touches[0][s]:me[s]}function te(me){var G=l[this.a],he=l[this.b],Te=G.size+he.size;G.size=me/this.size*Te,he.size=Te-me/this.size*Te,xe(G.element,G.size,this[mn],G.i),xe(he.element,he.size,this[ss],he.i)}function X(me){var G,he=l[this.a],Te=l[this.b];this.dragging&&(G=je(me)-this.start+(this[mn]-this.dragOffset),O>1&&(G=Math.round(G/O)*O),G<=he.minSize+he.snapOffset+this[mn]?G=he.minSize+this[mn]:G>=this.size-(Te.minSize+Te.snapOffset+this[ss])&&(G=this.size-(Te.minSize+this[ss])),G>=he.maxSize-he.snapOffset+this[mn]?G=he.maxSize+this[mn]:G<=this.size-(Te.maxSize-Te.snapOffset+this[ss])&&(G=this.size-(Te.maxSize+this[ss])),te.call(this,G),Mt(e,"onDrag",gn)(Re()))}function Ee(){var me=l[this.a].element,G=l[this.b].element,he=me[Zh](),Te=G[Zh]();this.size=he[n]+Te[n]+this[mn]+this[ss],this.start=he[r],this.end=he[o]}function Ae(me){if(!getComputedStyle)return null;var G=getComputedStyle(me);if(!G)return null;var he=me[a];return he===0?null:(K===Ea?he-=parseFloat(G.paddingLeft)+parseFloat(G.paddingRight):he-=parseFloat(G.paddingTop)+parseFloat(G.paddingBottom),he)}function Ue(me){var G=Ae(h);if(G===null||b.reduce(function(it,Bt){return it+Bt},0)>G)return me;var he=0,Te=[],Le=me.map(function(it,Bt){var jt=G*it/100,ir=Aa(D,Bt===0,Bt===me.length-1,N),rr=b[Bt]+ir;return jt<rr?(he+=rr-jt,Te.push(0),rr):(Te.push(jt-rr),jt)});return he===0?me:Le.map(function(it,Bt){var jt=it;if(he>0&&Te[Bt]-he>0){var ir=Math.min(he,Te[Bt]-he);he-=ir,jt=it-ir}return jt/G*100})}function Qt(){var me=this,G=l[me.a].element,he=l[me.b].element;me.dragging&&Mt(e,"onDragEnd",gn)(Re()),me.dragging=!1,sn[pn]("mouseup",me.stop),sn[pn]("touchend",me.stop),sn[pn]("touchcancel",me.stop),sn[pn]("mousemove",me.move),sn[pn]("touchmove",me.move),me.stop=null,me.move=null,G[pn]("selectstart",gn),G[pn]("dragstart",gn),he[pn]("selectstart",gn),he[pn]("dragstart",gn),G.style.userSelect="",G.style.webkitUserSelect="",G.style.MozUserSelect="",G.style.pointerEvents="",he.style.userSelect="",he.style.webkitUserSelect="",he.style.MozUserSelect="",he.style.pointerEvents="",me.gutter.style.cursor="",me.parent.style.cursor="",Hr.body.style.cursor=""}function Ct(me){if(!("button"in me&&me.button!==0)){var G=this,he=l[G.a].element,Te=l[G.b].element;G.dragging||Mt(e,"onDragStart",gn)(Re()),me.preventDefault(),G.dragging=!0,G.move=X.bind(G),G.stop=Qt.bind(G),sn[fn]("mouseup",G.stop),sn[fn]("touchend",G.stop),sn[fn]("touchcancel",G.stop),sn[fn]("mousemove",G.move),sn[fn]("touchmove",G.move),he[fn]("selectstart",gn),he[fn]("dragstart",gn),Te[fn]("selectstart",gn),Te[fn]("dragstart",gn),he.style.userSelect="none",he.style.webkitUserSelect="none",he.style.MozUserSelect="none",he.style.pointerEvents="none",Te.style.userSelect="none",Te.style.webkitUserSelect="none",Te.style.MozUserSelect="none",Te.style.pointerEvents="none",G.gutter.style.cursor=Z,G.parent.style.cursor=Z,Hr.body.style.cursor=Z,Ee.call(G),G.dragOffset=je(me)-G.end}}p=Ue(p);var Dt=[];l=t.map(function(me,G){var he={element:ag(me),size:p[G],minSize:b[G],maxSize:x[G],snapOffset:z[G],i:G},Te;if(G>0&&(Te={a:G-1,b:G,dragging:!1,direction:K,parent:h},Te[mn]=Aa(D,G-1===0,!1,N),Te[ss]=Aa(D,!1,G===t.length-1,N),f==="row-reverse"||f==="column-reverse")){var Le=Te.a;Te.a=Te.b,Te.b=Le}if(G>0){var it=ye(G,K,he.element);Me(it,D,G),Te[Ur]=Ct.bind(Te),it[fn]("mousedown",Te[Ur]),it[fn]("touchstart",Te[Ur]),h.insertBefore(it,he.element),Te.gutter=it}return xe(he.element,he.size,Aa(D,G===0,G===t.length-1,N),G),G>0&&Dt.push(Te),he});function ln(me){var G=me.i===Dt.length,he=G?Dt[me.i-1]:Dt[me.i];Ee.call(he);var Te=G?he.size-me.minSize-he[ss]:me.minSize+he[mn];te.call(he,Te)}l.forEach(function(me){var G=me.element[Zh]()[n];G<me.minSize&&(T?ln(me):me.minSize=G)});function It(me){var G=Ue(me);G.forEach(function(he,Te){if(Te>0){var Le=Dt[Te-1],it=l[Le.a],Bt=l[Le.b];it.size=G[Te-1],Bt.size=he,xe(it.element,it.size,Le[mn],it.i),xe(Bt.element,Bt.size,Le[ss],Bt.i)}})}function jn(me,G){Dt.forEach(function(he){if(G!==!0?he.parent.removeChild(he.gutter):(he.gutter[pn]("mousedown",he[Ur]),he.gutter[pn]("touchstart",he[Ur])),me!==!0){var Te=Q(n,he.a.size,he[mn]);Object.keys(Te).forEach(function(Le){l[he.a].element.style[Le]="",l[he.b].element.style[Le]=""})}})}return{setSizes:It,getSizes:Re,collapse:function(G){ln(l[G])},destroy:jn,parent:h,pairs:Dt}};const QD="";function cg(i,e,t,n){for(e=e-(t-1)*n;i.length<t;)i.push(void 0);i=i.splice(0,t);const s=[],r=[];let o=0;if(i.forEach((a,l)=>{if(a==null){r.push(l);return}const[c,h]=In(a);if(Number.isNaN(c)){r.push(l);return}const d=h==="%"?e*c/100:c;o+=d,s[l]=d}),r.length){const a=Math.max(1,(e-o)/r.length);r.forEach(l=>{s[l]=a,o+=a})}return s.map(a=>100*a/o)}class Pa extends qe{constructor(){super(...arguments),this._sizeBack=[]}get count(){return this._elements.length}get isVertical(){return this.options.direction==="vertical"||!!this.options.vertical}get totalSize(){return this.$element[this.isVertical?"height":"width"]()}isCollapsed(e){return v(this._elements[e])[this.isVertical?"height":"width"]()<1}setSizes(e,t){t||(e=cg(e,this.totalSize,this.count,this.options.gutterSize)),this._split.setSizes(e),this._update()}getSizes(){return this._split.getSizes()}collapse(e){this._sizeBack[e]=this.getSizes(),this._split.collapse(e),this._update()}expand(e){const t=this.getSizes(),n=this._sizeBack[e];if(n){t[e]=n[e];const s=e===this.count-1?e-1:e+1;t[s]=n[s]}else t[e]=50;this.setSizes(t)}toggle(e){this.isCollapsed(e)?this.expand(e):this.collapse(e)}afterInit(){const{elements:e=".split-cell",toggleBtn:t,vertical:n,sizes:s,gutterSize:r=8,animation:o,dblClickToggle:a,...l}=this.options,c=(Array.isArray(e)?e:[e]).reduce((f,p)=>(p&&(p instanceof HTMLElement?f.push(p):(typeof p=="string"?this.$element.children(p):v(p)).each((y,b)=>{f.push(b)})),f),[]);c.forEach(f=>v(f).addClass("split-cell")),this._elements=c,this._handleDragEnd=this._handleDragEnd.bind(this),this._createGutter=this._createGutter.bind(this);let h;s&&(h=cg(s,this.totalSize,c.length,r)),this._split=lg(c,{direction:n?"vertical":"horizontal",sizes:h,gutterSize:r,...l,onDragEnd:this._handleDragEnd,gutter:this._createGutter});const d=f=>{const p=f.z("index"),{count:y}=this;this.toggle(p===y-1&&y>2?p:p-1)};t&&this.on("click",f=>{const p=v(f.target).closest(".gutter-toggle");p.length&&d(p.parent())}),a&&this.on("dblclick",f=>{const p=v(f.target).closest(".gutter");p.length&&d(p)}),o&&this.on("transitionend",this._update.bind(this,!1)),this._update()}destroy(e,t){return super.destroy(),this.off("click transitionend"),this._raf&&cancelAnimationFrame(this._raf),this._split.destroy(e,t)}render(){super.render(),this._update()}_update(e){if(!e){this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=0,this._update(!0)});return}const{animation:t,vertical:n,gutterSize:s}=this.options,r=this.isVertical||!!n;this.$element.css("--split-gutter-size",`${s}px`).toggleClass("split-vert",r).toggleClass("split-horz",!r).toggleClass("has-animation",!!t),this._elements.forEach((o,a)=>{const l=this.isCollapsed(a),c=v(this._elements[a]).toggleClass("is-collapsed",l);c.prev(".gutter").toggleClass("is-next-collapsed",l),c.next(".gutter").toggleClass("is-prev-collapsed",l)})}_createGutter(e,t){const{toggleBtn:n}=this.options,{count:s}=this,r=v(`<div class="gutter gutter-${t==="vertical"?"vert":"horz"}" />`).z("index",e).toggleClass("is-first",e===1).toggleClass("is-last",e===s-1);return(n===!0||Array.isArray(n)&&n[e])&&r.append('<button class="gutter-toggle" type="button"><span class="chevron-left"></span></button>'),r[0]}_handleDragEnd(e){var t,n;this._update(),(n=(t=this.options).onDragEnd)==null||n.call(t,e)}}Pa.NAME="Split",Pa.DEFAULT={gutterSize:8,dblClickToggle:!0},Pa.SplitJS=lg;const eI="";/*! js-cookie v3.0.5 | MIT */function La(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)i[n]=t[n]}return i}var l0={read:function(i){return i[0]==='"'&&(i=i.slice(1,-1)),i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(i){return encodeURIComponent(i).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Yh(i,e){function t(s,r,o){if(!(typeof document>"u")){o=La({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=s+"="+i.write(r,s)+a}}function n(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var r=document.cookie?document.cookie.split("; "):[],o={},a=0;a<r.length;a++){var l=r[a].split("="),c=l.slice(1).join("=");try{var h=decodeURIComponent(l[0]);if(o[h]=i.read(c,h),s===h)break}catch{}}return s?o[s]:o}}return Object.create({set:t,get:n,remove:function(s,r){t(s,"",La({},r,{expires:-1}))},withAttributes:function(s){return Yh(this.converter,La({},this.attributes,s))},withConverter:function(s){return Yh(La({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(i)}})}var hg=Yh(l0,{path:"/"});window.$&&Object.assign(window.$,{cookie:hg});var dg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function c0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ug={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(dg,function(){var t=function(u,m){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,C){_.__proto__=C}||function(_,C){for(var S in C)Object.prototype.hasOwnProperty.call(C,S)&&(_[S]=C[S])})(u,m)},n=function(){return(n=Object.assign||function(u){for(var m,_=1,C=arguments.length;_<C;_++)for(var S in m=arguments[_])Object.prototype.hasOwnProperty.call(m,S)&&(u[S]=m[S]);return u}).apply(this,arguments)};function s(u,m,_){if(_||arguments.length===2)for(var C,S=0,$=m.length;S<$;S++)!C&&S in m||((C=C||Array.prototype.slice.call(m,0,S))[S]=m[S]);return u.concat(C||Array.prototype.slice.call(m))}var r=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:dg,o=Object.keys,a=Array.isArray;function l(u,m){return typeof m!="object"||o(m).forEach(function(_){u[_]=m[_]}),u}typeof Promise>"u"||r.Promise||(r.Promise=Promise);var c=Object.getPrototypeOf,h={}.hasOwnProperty;function d(u,m){return h.call(u,m)}function f(u,m){typeof m=="function"&&(m=m(c(u))),(typeof Reflect>"u"?o:Reflect.ownKeys)(m).forEach(function(_){y(u,_,m[_])})}var p=Object.defineProperty;function y(u,m,_,C){p(u,m,l(_&&d(_,"get")&&typeof _.get=="function"?{get:_.get,set:_.set,configurable:!0}:{value:_,configurable:!0,writable:!0},C))}function b(u){return{from:function(m){return u.prototype=Object.create(m.prototype),y(u.prototype,"constructor",u),{extend:f.bind(null,u.prototype)}}}}var w=Object.getOwnPropertyDescriptor,x=[].slice;function T(u,m,_){return x.call(u,m,_)}function D(u,m){return m(u)}function N(u){if(!u)throw new Error("Assertion Failed")}function A(u){r.setImmediate?setImmediate(u):setTimeout(u,0)}function z(u,m){if(typeof m=="string"&&d(u,m))return u[m];if(!m)return u;if(typeof m!="string"){for(var _=[],C=0,S=m.length;C<S;++C){var $=z(u,m[C]);_.push($)}return _}var M=m.indexOf(".");if(M!==-1){var E=u[m.substr(0,M)];return E==null?void 0:z(E,m.substr(M+1))}}function O(u,m,_){if(u&&m!==void 0&&!("isFrozen"in Object&&Object.isFrozen(u)))if(typeof m!="string"&&"length"in m){N(typeof _!="string"&&"length"in _);for(var C=0,S=m.length;C<S;++C)O(u,m[C],_[C])}else{var $,M,E=m.indexOf(".");E!==-1?($=m.substr(0,E),(M=m.substr(E+1))===""?_===void 0?a(u)&&!isNaN(parseInt($))?u.splice($,1):delete u[$]:u[$]=_:O(E=!(E=u[$])||!d(u,$)?u[$]={}:E,M,_)):_===void 0?a(u)&&!isNaN(parseInt(m))?u.splice(m,1):delete u[m]:u[m]=_}}function K(u){var m,_={};for(m in u)d(u,m)&&(_[m]=u[m]);return _}var Z=[].concat;function ye(u){return Z.apply([],u)}var hi="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ye([8,16,32,64].map(function(u){return["Int","Uint","Float"].map(function(m){return m+u+"Array"})}))).filter(function(u){return r[u]}),Q=new Set(hi.map(function(u){return r[u]})),ne=null;function xe(u){return ne=new WeakMap,u=function m(_){if(!_||typeof _!="object")return _;var C=ne.get(_);if(C)return C;if(a(_)){C=[],ne.set(_,C);for(var S=0,$=_.length;S<$;++S)C.push(m(_[S]))}else if(Q.has(_.constructor))C=_;else{var M,E=c(_);for(M in C=E===Object.prototype?{}:Object.create(E),ne.set(_,C),_)d(_,M)&&(C[M]=m(_[M]))}return C}(u),ne=null,u}var Me={}.toString;function Re(u){return Me.call(u).slice(8,-1)}var je=typeof Symbol<"u"?Symbol.iterator:"@@iterator",te=typeof je=="symbol"?function(u){var m;return u!=null&&(m=u[je])&&m.apply(u)}:function(){return null};function X(u,m){return m=u.indexOf(m),0<=m&&u.splice(m,1),0<=m}var Ee={};function Ae(u){var m,_,C,S;if(arguments.length===1){if(a(u))return u.slice();if(this===Ee&&typeof u=="string")return[u];if(S=te(u)){for(_=[];!(C=S.next()).done;)_.push(C.value);return _}if(u==null)return[u];if(typeof(m=u.length)!="number")return[u];for(_=new Array(m);m--;)_[m]=u[m];return _}for(m=arguments.length,_=new Array(m);m--;)_[m]=arguments[m];return _}var Ue=typeof Symbol<"u"?function(u){return u[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},To=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],cn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(To),Qt={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Ct(u,m){this.name=u,this.message=m}function Dt(u,m){return u+". Errors: "+Object.keys(m).map(function(_){return m[_].toString()}).filter(function(_,C,S){return S.indexOf(_)===C}).join(`
  7. `)}function ln(u,m,_,C){this.failures=m,this.failedKeys=C,this.successCount=_,this.message=Dt(u,m)}function It(u,m){this.name="BulkError",this.failures=Object.keys(m).map(function(_){return m[_]}),this.failuresByPos=m,this.message=Dt(u,this.failures)}b(Ct).from(Error).extend({toString:function(){return this.name+": "+this.message}}),b(ln).from(Ct),b(It).from(Ct);var jn=cn.reduce(function(u,m){return u[m]=m+"Error",u},{}),me=Ct,G=cn.reduce(function(u,m){var _=m+"Error";function C(S,$){this.name=_,S?typeof S=="string"?(this.message="".concat(S).concat($?`
  8. `+$:""),this.inner=$||null):typeof S=="object"&&(this.message="".concat(S.name," ").concat(S.message),this.inner=S):(this.message=Qt[m]||_,this.inner=null)}return b(C).from(me),u[m]=C,u},{});G.Syntax=SyntaxError,G.Type=TypeError,G.Range=RangeError;var he=To.reduce(function(u,m){return u[m+"Error"]=G[m],u},{}),Te=cn.reduce(function(u,m){return["Syntax","Type","Range"].indexOf(m)===-1&&(u[m+"Error"]=G[m]),u},{});function Le(){}function it(u){return u}function Bt(u,m){return u==null||u===it?m:function(_){return m(u(_))}}function jt(u,m){return function(){u.apply(this,arguments),m.apply(this,arguments)}}function ir(u,m){return u===Le?m:function(){var _=u.apply(this,arguments);_!==void 0&&(arguments[0]=_);var C=this.onsuccess,S=this.onerror;this.onsuccess=null,this.onerror=null;var $=m.apply(this,arguments);return C&&(this.onsuccess=this.onsuccess?jt(C,this.onsuccess):C),S&&(this.onerror=this.onerror?jt(S,this.onerror):S),$!==void 0?$:_}}function rr(u,m){return u===Le?m:function(){u.apply(this,arguments);var _=this.onsuccess,C=this.onerror;this.onsuccess=this.onerror=null,m.apply(this,arguments),_&&(this.onsuccess=this.onsuccess?jt(_,this.onsuccess):_),C&&(this.onerror=this.onerror?jt(C,this.onerror):C)}}function C$(u,m){return u===Le?m:function(_){var C=u.apply(this,arguments);l(_,C);var S=this.onsuccess,$=this.onerror;return this.onsuccess=null,this.onerror=null,_=m.apply(this,arguments),S&&(this.onsuccess=this.onsuccess?jt(S,this.onsuccess):S),$&&(this.onerror=this.onerror?jt($,this.onerror):$),C===void 0?_===void 0?void 0:_:l(C,_)}}function x$(u,m){return u===Le?m:function(){return m.apply(this,arguments)!==!1&&u.apply(this,arguments)}}function pf(u,m){return u===Le?m:function(){var _=u.apply(this,arguments);if(_&&typeof _.then=="function"){for(var C=this,S=arguments.length,$=new Array(S);S--;)$[S]=arguments[S];return _.then(function(){return m.apply(C,$)})}return m.apply(this,arguments)}}Te.ModifyError=ln,Te.DexieError=Ct,Te.BulkError=It;var Hn=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function cb(u){Hn=u}var So={},hb=100,hi=typeof Promise>"u"?[]:function(){var u=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[u,c(u),u];var m=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[m,c(m),u]}(),To=hi[0],cn=hi[1],hi=hi[2],cn=cn&&cn.then,di=To&&To.constructor,mf=!!hi,$o=function(u,m){Do.push([u,m]),hc&&(queueMicrotask(S$),hc=!1)},gf=!0,hc=!0,ui=[],dc=[],yf=it,As={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Le,pgp:!1,env:{},finalize:Le},ke=As,Do=[],fi=0,uc=[];function ge(u){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var m=this._PSD=ke;if(typeof u!="function"){if(u!==So)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&_f(this,this._value))}this._state=null,this._value=null,++m.ref,function _(C,S){try{S(function($){if(C._state===null){if($===C)throw new TypeError("A promise cannot be resolved with itself.");var M=C._lib&&or();$&&typeof $.then=="function"?_(C,function(E,L){$ instanceof ge?$._then(E,L):$.then(E,L)}):(C._state=!0,C._value=$,ub(C)),M&&ar()}},_f.bind(null,C))}catch($){_f(C,$)}}(this,u)}var vf={get:function(){var u=ke,m=gc;function _(C,S){var $=this,M=!u.global&&(u!==ke||m!==gc),E=M&&!Ls(),L=new ge(function(F,H){bf($,new db(pb(C,u,M,E),pb(S,u,M,E),F,H,u))});return this._consoleTask&&(L._consoleTask=this._consoleTask),L}return _.prototype=So,_},set:function(u){y(this,"then",u&&u.prototype===So?vf:{get:function(){return u},set:vf.set})}};function db(u,m,_,C,S){this.onFulfilled=typeof u=="function"?u:null,this.onRejected=typeof m=="function"?m:null,this.resolve=_,this.reject=C,this.psd=S}function _f(u,m){var _,C;dc.push(m),u._state===null&&(_=u._lib&&or(),m=yf(m),u._state=!1,u._value=m,C=u,ui.some(function(S){return S._value===C._value})||ui.push(C),ub(u),_&&ar())}function ub(u){var m=u._listeners;u._listeners=[];for(var _=0,C=m.length;_<C;++_)bf(u,m[_]);var S=u._PSD;--S.ref||S.finalize(),fi===0&&(++fi,$o(function(){--fi==0&&wf()},[]))}function bf(u,m){if(u._state!==null){var _=u._state?m.onFulfilled:m.onRejected;if(_===null)return(u._state?m.resolve:m.reject)(u._value);++m.psd.ref,++fi,$o(k$,[_,u,m])}else u._listeners.push(m)}function k$(u,m,_){try{var C,S=m._value;!m._state&&dc.length&&(dc=[]),C=Hn&&m._consoleTask?m._consoleTask.run(function(){return u(S)}):u(S),m._state||dc.indexOf(S)!==-1||function($){for(var M=ui.length;M;)if(ui[--M]._value===$._value)return ui.splice(M,1)}(m),_.resolve(C)}catch($){_.reject($)}finally{--fi==0&&wf(),--_.psd.ref||_.psd.finalize()}}function S$(){pi(As,function(){or()&&ar()})}function or(){var u=gf;return hc=gf=!1,u}function ar(){var u,m,_;do for(;0<Do.length;)for(u=Do,Do=[],_=u.length,m=0;m<_;++m){var C=u[m];C[0].apply(null,C[1])}while(0<Do.length);hc=gf=!0}function wf(){var u=ui;ui=[],u.forEach(function(C){C._PSD.onunhandled.call(null,C._value,C)});for(var m=uc.slice(0),_=m.length;_;)m[--_]()}function fc(u){return new ge(So,!1,u)}function at(u,m){var _=ke;return function(){var C=or(),S=ke;try{return Rs(_,!0),u.apply(this,arguments)}catch($){m&&m($)}finally{Rs(S,!1),C&&ar()}}}f(ge.prototype,{then:vf,_then:function(u,m){bf(this,new db(null,null,u,m,ke))},catch:function(u){if(arguments.length===1)return this.then(null,u);var m=u,_=arguments[1];return typeof m=="function"?this.then(null,function(C){return(C instanceof m?_:fc)(C)}):this.then(null,function(C){return(C&&C.name===m?_:fc)(C)})},finally:function(u){return this.then(function(m){return ge.resolve(u()).then(function(){return m})},function(m){return ge.resolve(u()).then(function(){return fc(m)})})},timeout:function(u,m){var _=this;return u<1/0?new ge(function(C,S){var $=setTimeout(function(){return S(new G.Timeout(m))},u);_.then(C,S).finally(clearTimeout.bind(null,$))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&y(ge.prototype,Symbol.toStringTag,"Dexie.Promise"),As.env=fb(),f(ge,{all:function(){var u=Ae.apply(null,arguments).map(yc);return new ge(function(m,_){u.length===0&&m([]);var C=u.length;u.forEach(function(S,$){return ge.resolve(S).then(function(M){u[$]=M,--C||m(u)},_)})})},resolve:function(u){return u instanceof ge?u:u&&typeof u.then=="function"?new ge(function(m,_){u.then(m,_)}):new ge(So,!0,u)},reject:fc,race:function(){var u=Ae.apply(null,arguments).map(yc);return new ge(function(m,_){u.map(function(C){return ge.resolve(C).then(m,_)})})},PSD:{get:function(){return ke},set:function(u){return ke=u}},totalEchoes:{get:function(){return gc}},newPSD:Ps,usePSD:pi,scheduler:{get:function(){return $o},set:function(u){$o=u}},rejectionMapper:{get:function(){return yf},set:function(u){yf=u}},follow:function(u,m){return new ge(function(_,C){return Ps(function(S,$){var M=ke;M.unhandleds=[],M.onunhandled=$,M.finalize=jt(function(){var E,L=this;E=function(){L.unhandleds.length===0?S():$(L.unhandleds[0])},uc.push(function F(){E(),uc.splice(uc.indexOf(F),1)}),++fi,$o(function(){--fi==0&&wf()},[])},M.finalize),u()},m,_,C)})}}),di&&(di.allSettled&&y(ge,"allSettled",function(){var u=Ae.apply(null,arguments).map(yc);return new ge(function(m){u.length===0&&m([]);var _=u.length,C=new Array(_);u.forEach(function(S,$){return ge.resolve(S).then(function(M){return C[$]={status:"fulfilled",value:M}},function(M){return C[$]={status:"rejected",reason:M}}).then(function(){return--_||m(C)})})})}),di.any&&typeof AggregateError<"u"&&y(ge,"any",function(){var u=Ae.apply(null,arguments).map(yc);return new ge(function(m,_){u.length===0&&_(new AggregateError([]));var C=u.length,S=new Array(C);u.forEach(function($,M){return ge.resolve($).then(function(E){return m(E)},function(E){S[M]=E,--C||_(new AggregateError(S))})})})}),di.withResolvers&&(ge.withResolvers=di.withResolvers));var xt={awaits:0,echoes:0,id:0},T$=0,pc=[],mc=0,gc=0,$$=0;function Ps(u,m,_,C){var S=ke,$=Object.create(S);return $.parent=S,$.ref=0,$.global=!1,$.id=++$$,As.env,$.env=mf?{Promise:ge,PromiseProp:{value:ge,configurable:!0,writable:!0},all:ge.all,race:ge.race,allSettled:ge.allSettled,any:ge.any,resolve:ge.resolve,reject:ge.reject}:{},m&&l($,m),++S.ref,$.finalize=function(){--this.parent.ref||this.parent.finalize()},C=pi($,u,_,C),$.ref===0&&$.finalize(),C}function lr(){return xt.id||(xt.id=++T$),++xt.awaits,xt.echoes+=hb,xt.id}function Ls(){return!!xt.awaits&&(--xt.awaits==0&&(xt.id=0),xt.echoes=xt.awaits*hb,!0)}function yc(u){return xt.echoes&&u&&u.constructor===di?(lr(),u.then(function(m){return Ls(),m},function(m){return Ls(),lt(m)})):u}function D$(){var u=pc[pc.length-1];pc.pop(),Rs(u,!1)}function Rs(u,m){var _,C=ke;(m?!xt.echoes||mc++&&u===ke:!mc||--mc&&u===ke)||queueMicrotask(m?(function(S){++gc,xt.echoes&&--xt.echoes!=0||(xt.echoes=xt.awaits=xt.id=0),pc.push(ke),Rs(S,!0)}).bind(null,u):D$),u!==ke&&(ke=u,C===As&&(As.env=fb()),mf&&(_=As.env.Promise,m=u.env,(C.global||u.global)&&(Object.defineProperty(r,"Promise",m.PromiseProp),_.all=m.all,_.race=m.race,_.resolve=m.resolve,_.reject=m.reject,m.allSettled&&(_.allSettled=m.allSettled),m.any&&(_.any=m.any))))}function fb(){var u=r.Promise;return mf?{Promise:u,PromiseProp:Object.getOwnPropertyDescriptor(r,"Promise"),all:u.all,race:u.race,allSettled:u.allSettled,any:u.any,resolve:u.resolve,reject:u.reject}:{}}function pi(u,m,_,C,S){var $=ke;try{return Rs(u,!0),m(_,C,S)}finally{Rs($,!1)}}function pb(u,m,_,C){return typeof u!="function"?u:function(){var S=ke;_&&lr(),Rs(m,!0);try{return u.apply(this,arguments)}finally{Rs(S,!1),C&&queueMicrotask(Ls)}}}function Cf(u){Promise===di&&xt.echoes===0?mc===0?u():enqueueNativeMicroTask(u):setTimeout(u,0)}(""+cn).indexOf("[native code]")===-1&&(lr=Ls=Le);var lt=ge.reject,mi=String.fromCharCode(65535),hs="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",mb="String expected.",cr=[],vc="__dbnames",xf="readonly",kf="readwrite";function gi(u,m){return u?m?function(){return u.apply(this,arguments)&&m.apply(this,arguments)}:u:m}var gb={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function _c(u){return typeof u!="string"||/\./.test(u)?function(m){return m}:function(m){return m[u]===void 0&&u in m&&delete(m=xe(m))[u],m}}function yb(){throw G.Type()}function Ge(u,m){try{var _=vb(u),C=vb(m);if(_!==C)return _==="Array"?1:C==="Array"?-1:_==="binary"?1:C==="binary"?-1:_==="string"?1:C==="string"?-1:_==="Date"?1:C!=="Date"?NaN:-1;switch(_){case"number":case"Date":case"string":return m<u?1:u<m?-1:0;case"binary":return function(S,$){for(var M=S.length,E=$.length,L=M<E?M:E,F=0;F<L;++F)if(S[F]!==$[F])return S[F]<$[F]?-1:1;return M===E?0:M<E?-1:1}(_b(u),_b(m));case"Array":return function(S,$){for(var M=S.length,E=$.length,L=M<E?M:E,F=0;F<L;++F){var H=Ge(S[F],$[F]);if(H!==0)return H}return M===E?0:M<E?-1:1}(u,m)}}catch{}return NaN}function vb(u){var m=typeof u;return m!="object"?m:ArrayBuffer.isView(u)?"binary":(u=Re(u),u==="ArrayBuffer"?"binary":u)}function _b(u){return u instanceof Uint8Array?u:ArrayBuffer.isView(u)?new Uint8Array(u.buffer,u.byteOffset,u.byteLength):new Uint8Array(u)}var bb=(rt.prototype._trans=function(u,m,_){var C=this._tx||ke.trans,S=this.name,$=Hn&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(u==="readonly"?"read":"write"," ").concat(this.name));function M(F,H,P){if(!P.schema[S])throw new G.NotFound("Table "+S+" not part of transaction");return m(P.idbtrans,P)}var E=or();try{var L=C&&C.db._novip===this.db._novip?C===ke.trans?C._promise(u,M,_):Ps(function(){return C._promise(u,M,_)},{trans:C,transless:ke.transless||ke}):function F(H,P,W,R){if(H.idbdb&&(H._state.openComplete||ke.letThrough||H._vip)){var j=H._createTransaction(P,W,H._dbSchema);try{j.create(),H._state.PR1398_maxLoop=3}catch(V){return V.name===jn.InvalidState&&H.isOpen()&&0<--H._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),H.close({disableAutoOpen:!1}),H.open().then(function(){return F(H,P,W,R)})):lt(V)}return j._promise(P,function(V,B){return Ps(function(){return ke.trans=j,R(V,B,j)})}).then(function(V){if(P==="readwrite")try{j.idbtrans.commit()}catch{}return P==="readonly"?V:j._completion.then(function(){return V})})}if(H._state.openComplete)return lt(new G.DatabaseClosed(H._state.dbOpenError));if(!H._state.isBeingOpened){if(!H._state.autoOpen)return lt(new G.DatabaseClosed);H.open().catch(Le)}return H._state.dbReadyPromise.then(function(){return F(H,P,W,R)})}(this.db,u,[this.name],M);return $&&(L._consoleTask=$,L=L.catch(function(F){return console.trace(F),lt(F)})),L}finally{E&&ar()}},rt.prototype.get=function(u,m){var _=this;return u&&u.constructor===Object?this.where(u).first(m):u==null?lt(new G.Type("Invalid argument to Table.get()")):this._trans("readonly",function(C){return _.core.get({trans:C,key:u}).then(function(S){return _.hook.reading.fire(S)})}).then(m)},rt.prototype.where=function(u){if(typeof u=="string")return new this.db.WhereClause(this,u);if(a(u))return new this.db.WhereClause(this,"[".concat(u.join("+"),"]"));var m=o(u);if(m.length===1)return this.where(m[0]).equals(u[m[0]]);var _=this.schema.indexes.concat(this.schema.primKey).filter(function(E){if(E.compound&&m.every(function(F){return 0<=E.keyPath.indexOf(F)})){for(var L=0;L<m.length;++L)if(m.indexOf(E.keyPath[L])===-1)return!1;return!0}return!1}).sort(function(E,L){return E.keyPath.length-L.keyPath.length})[0];if(_&&this.db._maxKey!==mi){var $=_.keyPath.slice(0,m.length);return this.where($).equals($.map(function(L){return u[L]}))}!_&&Hn&&console.warn("The query ".concat(JSON.stringify(u)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(m.join("+"),"]"));var C=this.schema.idxByName;function S(E,L){return Ge(E,L)===0}var M=m.reduce(function(P,L){var F=P[0],H=P[1],P=C[L],W=u[L];return[F||P,F||!P?gi(H,P&&P.multi?function(R){return R=z(R,L),a(R)&&R.some(function(j){return S(W,j)})}:function(R){return S(W,z(R,L))}):H]},[null,null]),$=M[0],M=M[1];return $?this.where($.name).equals(u[$.keyPath]).filter(M):_?this.filter(M):this.where(m).equals("")},rt.prototype.filter=function(u){return this.toCollection().and(u)},rt.prototype.count=function(u){return this.toCollection().count(u)},rt.prototype.offset=function(u){return this.toCollection().offset(u)},rt.prototype.limit=function(u){return this.toCollection().limit(u)},rt.prototype.each=function(u){return this.toCollection().each(u)},rt.prototype.toArray=function(u){return this.toCollection().toArray(u)},rt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},rt.prototype.orderBy=function(u){return new this.db.Collection(new this.db.WhereClause(this,a(u)?"[".concat(u.join("+"),"]"):u))},rt.prototype.reverse=function(){return this.toCollection().reverse()},rt.prototype.mapToClass=function(u){var m,_=this.db,C=this.name;function S(){return m!==null&&m.apply(this,arguments)||this}(this.schema.mappedClass=u).prototype instanceof yb&&(function(L,F){if(typeof F!="function"&&F!==null)throw new TypeError("Class extends value "+String(F)+" is not a constructor or null");function H(){this.constructor=L}t(L,F),L.prototype=F===null?Object.create(F):(H.prototype=F.prototype,new H)}(S,m=u),Object.defineProperty(S.prototype,"db",{get:function(){return _},enumerable:!1,configurable:!0}),S.prototype.table=function(){return C},u=S);for(var $=new Set,M=u.prototype;M;M=c(M))Object.getOwnPropertyNames(M).forEach(function(L){return $.add(L)});function E(L){if(!L)return L;var F,H=Object.create(u.prototype);for(F in L)if(!$.has(F))try{H[F]=L[F]}catch{}return H}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=E,this.hook("reading",E),u},rt.prototype.defineClass=function(){return this.mapToClass(function(u){l(this,u)})},rt.prototype.add=function(u,m){var _=this,C=this.schema.primKey,S=C.auto,$=C.keyPath,M=u;return $&&S&&(M=_c($)(u)),this._trans("readwrite",function(E){return _.core.mutate({trans:E,type:"add",keys:m!=null?[m]:null,values:[M]})}).then(function(E){return E.numFailures?ge.reject(E.failures[0]):E.lastResult}).then(function(E){if($)try{O(u,$,E)}catch{}return E})},rt.prototype.update=function(u,m){return typeof u!="object"||a(u)?this.where(":id").equals(u).modify(m):(u=z(u,this.schema.primKey.keyPath),u===void 0?lt(new G.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(u).modify(m))},rt.prototype.put=function(u,m){var _=this,C=this.schema.primKey,S=C.auto,$=C.keyPath,M=u;return $&&S&&(M=_c($)(u)),this._trans("readwrite",function(E){return _.core.mutate({trans:E,type:"put",values:[M],keys:m!=null?[m]:null})}).then(function(E){return E.numFailures?ge.reject(E.failures[0]):E.lastResult}).then(function(E){if($)try{O(u,$,E)}catch{}return E})},rt.prototype.delete=function(u){var m=this;return this._trans("readwrite",function(_){return m.core.mutate({trans:_,type:"delete",keys:[u]})}).then(function(_){return _.numFailures?ge.reject(_.failures[0]):void 0})},rt.prototype.clear=function(){var u=this;return this._trans("readwrite",function(m){return u.core.mutate({trans:m,type:"deleteRange",range:gb})}).then(function(m){return m.numFailures?ge.reject(m.failures[0]):void 0})},rt.prototype.bulkGet=function(u){var m=this;return this._trans("readonly",function(_){return m.core.getMany({keys:u,trans:_}).then(function(C){return C.map(function(S){return m.hook.reading.fire(S)})})})},rt.prototype.bulkAdd=function(u,m,_){var C=this,S=Array.isArray(m)?m:void 0,$=(_=_||(S?void 0:m))?_.allKeys:void 0;return this._trans("readwrite",function(M){var F=C.schema.primKey,E=F.auto,F=F.keyPath;if(F&&S)throw new G.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(S&&S.length!==u.length)throw new G.InvalidArgument("Arguments objects and keys must have the same length");var L=u.length,F=F&&E?u.map(_c(F)):u;return C.core.mutate({trans:M,type:"add",keys:S,values:F,wantResults:$}).then(function(j){var P=j.numFailures,W=j.results,R=j.lastResult,j=j.failures;if(P===0)return $?W:R;throw new It("".concat(C.name,".bulkAdd(): ").concat(P," of ").concat(L," operations failed"),j)})})},rt.prototype.bulkPut=function(u,m,_){var C=this,S=Array.isArray(m)?m:void 0,$=(_=_||(S?void 0:m))?_.allKeys:void 0;return this._trans("readwrite",function(M){var F=C.schema.primKey,E=F.auto,F=F.keyPath;if(F&&S)throw new G.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(S&&S.length!==u.length)throw new G.InvalidArgument("Arguments objects and keys must have the same length");var L=u.length,F=F&&E?u.map(_c(F)):u;return C.core.mutate({trans:M,type:"put",keys:S,values:F,wantResults:$}).then(function(j){var P=j.numFailures,W=j.results,R=j.lastResult,j=j.failures;if(P===0)return $?W:R;throw new It("".concat(C.name,".bulkPut(): ").concat(P," of ").concat(L," operations failed"),j)})})},rt.prototype.bulkUpdate=function(u){var m=this,_=this.core,C=u.map(function(M){return M.key}),S=u.map(function(M){return M.changes}),$=[];return this._trans("readwrite",function(M){return _.getMany({trans:M,keys:C,cache:"clone"}).then(function(E){var L=[],F=[];u.forEach(function(P,W){var R=P.key,j=P.changes,V=E[W];if(V){for(var B=0,q=Object.keys(j);B<q.length;B++){var Y=q[B],J=j[Y];if(Y===m.schema.primKey.keyPath){if(Ge(J,R)!==0)throw new G.Constraint("Cannot update primary key in bulkUpdate()")}else O(V,Y,J)}$.push(W),L.push(R),F.push(V)}});var H=L.length;return _.mutate({trans:M,type:"put",keys:L,values:F,updates:{keys:C,changeSpecs:S}}).then(function(P){var W=P.numFailures,R=P.failures;if(W===0)return H;for(var j=0,V=Object.keys(R);j<V.length;j++){var B,q=V[j],Y=$[Number(q)];Y!=null&&(B=R[q],delete R[q],R[Y]=B)}throw new It("".concat(m.name,".bulkUpdate(): ").concat(W," of ").concat(H," operations failed"),R)})})})},rt.prototype.bulkDelete=function(u){var m=this,_=u.length;return this._trans("readwrite",function(C){return m.core.mutate({trans:C,type:"delete",keys:u})}).then(function(M){var S=M.numFailures,$=M.lastResult,M=M.failures;if(S===0)return $;throw new It("".concat(m.name,".bulkDelete(): ").concat(S," of ").concat(_," operations failed"),M)})},rt);function rt(){}function Io(u){function m(M,E){if(E){for(var L=arguments.length,F=new Array(L-1);--L;)F[L-1]=arguments[L];return _[M].subscribe.apply(null,F),u}if(typeof M=="string")return _[M]}var _={};m.addEventType=$;for(var C=1,S=arguments.length;C<S;++C)$(arguments[C]);return m;function $(M,E,L){if(typeof M!="object"){var F;E=E||x$;var H={subscribers:[],fire:L=L||Le,subscribe:function(P){H.subscribers.indexOf(P)===-1&&(H.subscribers.push(P),H.fire=E(H.fire,P))},unsubscribe:function(P){H.subscribers=H.subscribers.filter(function(W){return W!==P}),H.fire=H.subscribers.reduce(E,L)}};return _[M]=m[M]=H}o(F=M).forEach(function(P){var W=F[P];if(a(W))$(P,F[P][0],F[P][1]);else{if(W!=="asap")throw new G.InvalidArgument("Invalid event config");var R=$(P,it,function(){for(var j=arguments.length,V=new Array(j);j--;)V[j]=arguments[j];R.subscribers.forEach(function(B){A(function(){B.apply(null,V)})})})}})}}function Mo(u,m){return b(m).from({prototype:u}),m}function hr(u,m){return!(u.filter||u.algorithm||u.or)&&(m?u.justLimit:!u.replayFilter)}function Sf(u,m){u.filter=gi(u.filter,m)}function Tf(u,m,_){var C=u.replayFilter;u.replayFilter=C?function(){return gi(C(),m())}:m,u.justLimit=_&&!C}function bc(u,m){if(u.isPrimKey)return m.primaryKey;var _=m.getIndexByKeyPath(u.index);if(!_)throw new G.Schema("KeyPath "+u.index+" on object store "+m.name+" is not indexed");return _}function wb(u,m,_){var C=bc(u,m.schema);return m.openCursor({trans:_,values:!u.keysOnly,reverse:u.dir==="prev",unique:!!u.unique,query:{index:C,range:u.range}})}function wc(u,m,_,C){var S=u.replayFilter?gi(u.filter,u.replayFilter()):u.filter;if(u.or){var $={},M=function(E,L,F){var H,P;S&&!S(L,F,function(W){return L.stop(W)},function(W){return L.fail(W)})||((P=""+(H=L.primaryKey))=="[object ArrayBuffer]"&&(P=""+new Uint8Array(H)),d($,P)||($[P]=!0,m(E,L,F)))};return Promise.all([u.or._iterate(M,_),Cb(wb(u,C,_),u.algorithm,M,!u.keysOnly&&u.valueMapper)])}return Cb(wb(u,C,_),gi(u.algorithm,S),m,!u.keysOnly&&u.valueMapper)}function Cb(u,m,_,C){var S=at(C?function($,M,E){return _(C($),M,E)}:_);return u.then(function($){if($)return $.start(function(){var M=function(){return $.continue()};m&&!m($,function(E){return M=E},function(E){$.stop(E),M=Le},function(E){$.fail(E),M=Le})||S($.value,$,function(E){return M=E}),M()})})}var No=(xb.prototype.execute=function(u){var m=this["@@propmod"];if(m.add!==void 0){var _=m.add;if(a(_))return s(s([],a(u)?u:[],!0),_,!0).sort();if(typeof _=="number")return(Number(u)||0)+_;if(typeof _=="bigint")try{return BigInt(u)+_}catch{return BigInt(0)+_}throw new TypeError("Invalid term ".concat(_))}if(m.remove!==void 0){var C=m.remove;if(a(C))return a(u)?u.filter(function(S){return!C.includes(S)}).sort():[];if(typeof C=="number")return Number(u)-C;if(typeof C=="bigint")try{return BigInt(u)-C}catch{return BigInt(0)-C}throw new TypeError("Invalid subtrahend ".concat(C))}return _=(_=m.replacePrefix)===null||_===void 0?void 0:_[0],_&&typeof u=="string"&&u.startsWith(_)?m.replacePrefix[1]+u.substring(_.length):u},xb);function xb(u){this["@@propmod"]=u}var I$=(Je.prototype._read=function(u,m){var _=this._ctx;return _.error?_.table._trans(null,lt.bind(null,_.error)):_.table._trans("readonly",u).then(m)},Je.prototype._write=function(u){var m=this._ctx;return m.error?m.table._trans(null,lt.bind(null,m.error)):m.table._trans("readwrite",u,"locked")},Je.prototype._addAlgorithm=function(u){var m=this._ctx;m.algorithm=gi(m.algorithm,u)},Je.prototype._iterate=function(u,m){return wc(this._ctx,u,m,this._ctx.table.core)},Je.prototype.clone=function(u){var m=Object.create(this.constructor.prototype),_=Object.create(this._ctx);return u&&l(_,u),m._ctx=_,m},Je.prototype.raw=function(){return this._ctx.valueMapper=null,this},Je.prototype.each=function(u){var m=this._ctx;return this._read(function(_){return wc(m,u,_,m.table.core)})},Je.prototype.count=function(u){var m=this;return this._read(function(_){var C=m._ctx,S=C.table.core;if(hr(C,!0))return S.count({trans:_,query:{index:bc(C,S.schema),range:C.range}}).then(function(M){return Math.min(M,C.limit)});var $=0;return wc(C,function(){return++$,!1},_,S).then(function(){return $})}).then(u)},Je.prototype.sortBy=function(u,m){var _=u.split(".").reverse(),C=_[0],S=_.length-1;function $(L,F){return F?$(L[_[F]],F-1):L[C]}var M=this._ctx.dir==="next"?1:-1;function E(L,F){return Ge($(L,S),$(F,S))*M}return this.toArray(function(L){return L.sort(E)}).then(m)},Je.prototype.toArray=function(u){var m=this;return this._read(function(_){var C=m._ctx;if(C.dir==="next"&&hr(C,!0)&&0<C.limit){var S=C.valueMapper,$=bc(C,C.table.core.schema);return C.table.core.query({trans:_,limit:C.limit,values:!0,query:{index:$,range:C.range}}).then(function(E){return E=E.result,S?E.map(S):E})}var M=[];return wc(C,function(E){return M.push(E)},_,C.table.core).then(function(){return M})},u)},Je.prototype.offset=function(u){var m=this._ctx;return u<=0||(m.offset+=u,hr(m)?Tf(m,function(){var _=u;return function(C,S){return _===0||(_===1?--_:S(function(){C.advance(_),_=0}),!1)}}):Tf(m,function(){var _=u;return function(){return--_<0}})),this},Je.prototype.limit=function(u){return this._ctx.limit=Math.min(this._ctx.limit,u),Tf(this._ctx,function(){var m=u;return function(_,C,S){return--m<=0&&C(S),0<=m}},!0),this},Je.prototype.until=function(u,m){return Sf(this._ctx,function(_,C,S){return!u(_.value)||(C(S),m)}),this},Je.prototype.first=function(u){return this.limit(1).toArray(function(m){return m[0]}).then(u)},Je.prototype.last=function(u){return this.reverse().first(u)},Je.prototype.filter=function(u){var m;return Sf(this._ctx,function(_){return u(_.value)}),(m=this._ctx).isMatch=gi(m.isMatch,u),this},Je.prototype.and=function(u){return this.filter(u)},Je.prototype.or=function(u){return new this.db.WhereClause(this._ctx.table,u,this)},Je.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Je.prototype.desc=function(){return this.reverse()},Je.prototype.eachKey=function(u){var m=this._ctx;return m.keysOnly=!m.isMatch,this.each(function(_,C){u(C.key,C)})},Je.prototype.eachUniqueKey=function(u){return this._ctx.unique="unique",this.eachKey(u)},Je.prototype.eachPrimaryKey=function(u){var m=this._ctx;return m.keysOnly=!m.isMatch,this.each(function(_,C){u(C.primaryKey,C)})},Je.prototype.keys=function(u){var m=this._ctx;m.keysOnly=!m.isMatch;var _=[];return this.each(function(C,S){_.push(S.key)}).then(function(){return _}).then(u)},Je.prototype.primaryKeys=function(u){var m=this._ctx;if(m.dir==="next"&&hr(m,!0)&&0<m.limit)return this._read(function(C){var S=bc(m,m.table.core.schema);return m.table.core.query({trans:C,values:!1,limit:m.limit,query:{index:S,range:m.range}})}).then(function(C){return C.result}).then(u);m.keysOnly=!m.isMatch;var _=[];return this.each(function(C,S){_.push(S.primaryKey)}).then(function(){return _}).then(u)},Je.prototype.uniqueKeys=function(u){return this._ctx.unique="unique",this.keys(u)},Je.prototype.firstKey=function(u){return this.limit(1).keys(function(m){return m[0]}).then(u)},Je.prototype.lastKey=function(u){return this.reverse().firstKey(u)},Je.prototype.distinct=function(){var u=this._ctx,u=u.index&&u.table.schema.idxByName[u.index];if(!u||!u.multi)return this;var m={};return Sf(this._ctx,function(S){var C=S.primaryKey.toString(),S=d(m,C);return m[C]=!0,!S}),this},Je.prototype.modify=function(u){var m=this,_=this._ctx;return this._write(function(C){var S,$,M;M=typeof u=="function"?u:(S=o(u),$=S.length,function(B){for(var q=!1,Y=0;Y<$;++Y){var J=S[Y],ee=u[J],se=z(B,J);ee instanceof No?(O(B,J,ee.execute(se)),q=!0):se!==ee&&(O(B,J,ee),q=!0)}return q});var E=_.table.core,P=E.schema.primaryKey,L=P.outbound,F=P.extractKey,H=200,P=m.db._options.modifyChunkSize;P&&(H=typeof P=="object"?P[E.name]||P["*"]||200:P);function W(B,J){var Y=J.failures,J=J.numFailures;j+=B-J;for(var ee=0,se=o(Y);ee<se.length;ee++){var le=se[ee];R.push(Y[le])}}var R=[],j=0,V=[];return m.clone().primaryKeys().then(function(B){function q(J){var ee=Math.min(H,B.length-J);return E.getMany({trans:C,keys:B.slice(J,J+ee),cache:"immutable"}).then(function(se){for(var le=[],ie=[],oe=L?[]:null,ue=[],ae=0;ae<ee;++ae){var _e=se[ae],Oe={value:xe(_e),primKey:B[J+ae]};M.call(Oe,Oe.value,Oe)!==!1&&(Oe.value==null?ue.push(B[J+ae]):L||Ge(F(_e),F(Oe.value))===0?(ie.push(Oe.value),L&&oe.push(B[J+ae])):(ue.push(B[J+ae]),le.push(Oe.value)))}return Promise.resolve(0<le.length&&E.mutate({trans:C,type:"add",values:le}).then(function(We){for(var Ke in We.failures)ue.splice(parseInt(Ke),1);W(le.length,We)})).then(function(){return(0<ie.length||Y&&typeof u=="object")&&E.mutate({trans:C,type:"put",keys:oe,values:ie,criteria:Y,changeSpec:typeof u!="function"&&u,isAdditionalChunk:0<J}).then(function(We){return W(ie.length,We)})}).then(function(){return(0<ue.length||Y&&u===$f)&&E.mutate({trans:C,type:"delete",keys:ue,criteria:Y,isAdditionalChunk:0<J}).then(function(We){return W(ue.length,We)})}).then(function(){return B.length>J+ee&&q(J+H)})})}var Y=hr(_)&&_.limit===1/0&&(typeof u!="function"||u===$f)&&{index:_.index,range:_.range};return q(0).then(function(){if(0<R.length)throw new ln("Error modifying one or more objects",R,j,V);return B.length})})})},Je.prototype.delete=function(){var u=this._ctx,m=u.range;return hr(u)&&(u.isPrimKey||m.type===3)?this._write(function(_){var C=u.table.core.schema.primaryKey,S=m;return u.table.core.count({trans:_,query:{index:C,range:S}}).then(function($){return u.table.core.mutate({trans:_,type:"deleteRange",range:S}).then(function(M){var E=M.failures;if(M.lastResult,M.results,M=M.numFailures,M)throw new ln("Could not delete some values",Object.keys(E).map(function(L){return E[L]}),$-M);return $-M})})}):this.modify($f)},Je);function Je(){}var $f=function(u,m){return m.value=null};function M$(u,m){return u<m?-1:u===m?0:1}function N$(u,m){return m<u?-1:u===m?0:1}function en(u,m,_){return u=u instanceof Sb?new u.Collection(u):u,u._ctx.error=new(_||TypeError)(m),u}function dr(u){return new u.Collection(u,function(){return kb("")}).limit(0)}function Cc(u,m,_,C){var S,$,M,E,L,F,H,P=_.length;if(!_.every(function(j){return typeof j=="string"}))return en(u,mb);function W(j){S=j==="next"?function(B){return B.toUpperCase()}:function(B){return B.toLowerCase()},$=j==="next"?function(B){return B.toLowerCase()}:function(B){return B.toUpperCase()},M=j==="next"?M$:N$;var V=_.map(function(B){return{lower:$(B),upper:S(B)}}).sort(function(B,q){return M(B.lower,q.lower)});E=V.map(function(B){return B.upper}),L=V.map(function(B){return B.lower}),H=(F=j)==="next"?"":C}W("next"),u=new u.Collection(u,function(){return zs(E[0],L[P-1]+C)}),u._ondirectionchange=function(j){W(j)};var R=0;return u._addAlgorithm(function(j,V,B){var q=j.key;if(typeof q!="string")return!1;var Y=$(q);if(m(Y,L,R))return!0;for(var J=null,ee=R;ee<P;++ee){var se=function(le,ie,oe,ue,ae,_e){for(var Oe=Math.min(le.length,ue.length),We=-1,Ke=0;Ke<Oe;++Ke){var tn=ie[Ke];if(tn!==ue[Ke])return ae(le[Ke],oe[Ke])<0?le.substr(0,Ke)+oe[Ke]+oe.substr(Ke+1):ae(le[Ke],ue[Ke])<0?le.substr(0,Ke)+ue[Ke]+oe.substr(Ke+1):0<=We?le.substr(0,We)+ie[We]+oe.substr(We+1):null;ae(le[Ke],tn)<0&&(We=Ke)}return Oe<ue.length&&_e==="next"?le+oe.substr(le.length):Oe<le.length&&_e==="prev"?le.substr(0,oe.length):We<0?null:le.substr(0,We)+ue[We]+oe.substr(We+1)}(q,Y,E[ee],L[ee],M,F);se===null&&J===null?R=ee+1:(J===null||0<M(J,se))&&(J=se)}return V(J!==null?function(){j.continue(J+H)}:B),!1}),u}function zs(u,m,_,C){return{type:2,lower:u,upper:m,lowerOpen:_,upperOpen:C}}function kb(u){return{type:1,lower:u,upper:u}}var Sb=(Object.defineProperty(kt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),kt.prototype.between=function(u,m,_,C){_=_!==!1,C=C===!0;try{return 0<this._cmp(u,m)||this._cmp(u,m)===0&&(_||C)&&(!_||!C)?dr(this):new this.Collection(this,function(){return zs(u,m,!_,!C)})}catch{return en(this,hs)}},kt.prototype.equals=function(u){return u==null?en(this,hs):new this.Collection(this,function(){return kb(u)})},kt.prototype.above=function(u){return u==null?en(this,hs):new this.Collection(this,function(){return zs(u,void 0,!0)})},kt.prototype.aboveOrEqual=function(u){return u==null?en(this,hs):new this.Collection(this,function(){return zs(u,void 0,!1)})},kt.prototype.below=function(u){return u==null?en(this,hs):new this.Collection(this,function(){return zs(void 0,u,!1,!0)})},kt.prototype.belowOrEqual=function(u){return u==null?en(this,hs):new this.Collection(this,function(){return zs(void 0,u)})},kt.prototype.startsWith=function(u){return typeof u!="string"?en(this,mb):this.between(u,u+mi,!0,!0)},kt.prototype.startsWithIgnoreCase=function(u){return u===""?this.startsWith(u):Cc(this,function(m,_){return m.indexOf(_[0])===0},[u],mi)},kt.prototype.equalsIgnoreCase=function(u){return Cc(this,function(m,_){return m===_[0]},[u],"")},kt.prototype.anyOfIgnoreCase=function(){var u=Ae.apply(Ee,arguments);return u.length===0?dr(this):Cc(this,function(m,_){return _.indexOf(m)!==-1},u,"")},kt.prototype.startsWithAnyOfIgnoreCase=function(){var u=Ae.apply(Ee,arguments);return u.length===0?dr(this):Cc(this,function(m,_){return _.some(function(C){return m.indexOf(C)===0})},u,mi)},kt.prototype.anyOf=function(){var u=this,m=Ae.apply(Ee,arguments),_=this._cmp;try{m.sort(_)}catch{return en(this,hs)}if(m.length===0)return dr(this);var C=new this.Collection(this,function(){return zs(m[0],m[m.length-1])});C._ondirectionchange=function($){_=$==="next"?u._ascending:u._descending,m.sort(_)};var S=0;return C._addAlgorithm(function($,M,E){for(var L=$.key;0<_(L,m[S]);)if(++S===m.length)return M(E),!1;return _(L,m[S])===0||(M(function(){$.continue(m[S])}),!1)}),C},kt.prototype.notEqual=function(u){return this.inAnyRange([[-1/0,u],[u,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},kt.prototype.noneOf=function(){var u=Ae.apply(Ee,arguments);if(u.length===0)return new this.Collection(this);try{u.sort(this._ascending)}catch{return en(this,hs)}var m=u.reduce(function(_,C){return _?_.concat([[_[_.length-1][1],C]]):[[-1/0,C]]},null);return m.push([u[u.length-1],this.db._maxKey]),this.inAnyRange(m,{includeLowers:!1,includeUppers:!1})},kt.prototype.inAnyRange=function(q,m){var _=this,C=this._cmp,S=this._ascending,$=this._descending,M=this._min,E=this._max;if(q.length===0)return dr(this);if(!q.every(function(Y){return Y[0]!==void 0&&Y[1]!==void 0&&S(Y[0],Y[1])<=0}))return en(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",G.InvalidArgument);var L=!m||m.includeLowers!==!1,F=m&&m.includeUppers===!0,H,P=S;function W(Y,J){return P(Y[0],J[0])}try{(H=q.reduce(function(Y,J){for(var ee=0,se=Y.length;ee<se;++ee){var le=Y[ee];if(C(J[0],le[1])<0&&0<C(J[1],le[0])){le[0]=M(le[0],J[0]),le[1]=E(le[1],J[1]);break}}return ee===se&&Y.push(J),Y},[])).sort(W)}catch{return en(this,hs)}var R=0,j=F?function(Y){return 0<S(Y,H[R][1])}:function(Y){return 0<=S(Y,H[R][1])},V=L?function(Y){return 0<$(Y,H[R][0])}:function(Y){return 0<=$(Y,H[R][0])},B=j,q=new this.Collection(this,function(){return zs(H[0][0],H[H.length-1][1],!L,!F)});return q._ondirectionchange=function(Y){P=Y==="next"?(B=j,S):(B=V,$),H.sort(W)},q._addAlgorithm(function(Y,J,ee){for(var se,le=Y.key;B(le);)if(++R===H.length)return J(ee),!1;return!j(se=le)&&!V(se)||(_._cmp(le,H[R][1])===0||_._cmp(le,H[R][0])===0||J(function(){P===S?Y.continue(H[R][0]):Y.continue(H[R][1])}),!1)}),q},kt.prototype.startsWithAnyOf=function(){var u=Ae.apply(Ee,arguments);return u.every(function(m){return typeof m=="string"})?u.length===0?dr(this):this.inAnyRange(u.map(function(m){return[m,m+mi]})):en(this,"startsWithAnyOf() only works with strings")},kt);function kt(){}function Un(u){return at(function(m){return Eo(m),u(m.target.error),!1})}function Eo(u){u.stopPropagation&&u.stopPropagation(),u.preventDefault&&u.preventDefault()}var Ao="storagemutated",Df="x-storagemutated-1",Fs=Io(null,Ao),E$=(Vn.prototype._lock=function(){return N(!ke.global),++this._reculock,this._reculock!==1||ke.global||(ke.lockOwnerFor=this),this},Vn.prototype._unlock=function(){if(N(!ke.global),--this._reculock==0)for(ke.global||(ke.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var u=this._blockedFuncs.shift();try{pi(u[1],u[0])}catch{}}return this},Vn.prototype._locked=function(){return this._reculock&&ke.lockOwnerFor!==this},Vn.prototype.create=function(u){var m=this;if(!this.mode)return this;var _=this.db.idbdb,C=this.db._state.dbOpenError;if(N(!this.idbtrans),!u&&!_)switch(C&&C.name){case"DatabaseClosedError":throw new G.DatabaseClosed(C);case"MissingAPIError":throw new G.MissingAPI(C.message,C);default:throw new G.OpenFailed(C)}if(!this.active)throw new G.TransactionInactive;return N(this._completion._state===null),(u=this.idbtrans=u||(this.db.core||_).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=at(function(S){Eo(S),m._reject(u.error)}),u.onabort=at(function(S){Eo(S),m.active&&m._reject(new G.Abort(u.error)),m.active=!1,m.on("abort").fire(S)}),u.oncomplete=at(function(){m.active=!1,m._resolve(),"mutatedParts"in u&&Fs.storagemutated.fire(u.mutatedParts)}),this},Vn.prototype._promise=function(u,m,_){var C=this;if(u==="readwrite"&&this.mode!=="readwrite")return lt(new G.ReadOnly("Transaction is readonly"));if(!this.active)return lt(new G.TransactionInactive);if(this._locked())return new ge(function($,M){C._blockedFuncs.push([function(){C._promise(u,m,_).then($,M)},ke])});if(_)return Ps(function(){var $=new ge(function(M,E){C._lock();var L=m(M,E,C);L&&L.then&&L.then(M,E)});return $.finally(function(){return C._unlock()}),$._lib=!0,$});var S=new ge(function($,M){var E=m($,M,C);E&&E.then&&E.then($,M)});return S._lib=!0,S},Vn.prototype._root=function(){return this.parent?this.parent._root():this},Vn.prototype.waitFor=function(u){var m,_=this._root(),C=ge.resolve(u);_._waitingFor?_._waitingFor=_._waitingFor.then(function(){return C}):(_._waitingFor=C,_._waitingQueue=[],m=_.idbtrans.objectStore(_.storeNames[0]),function $(){for(++_._spinCount;_._waitingQueue.length;)_._waitingQueue.shift()();_._waitingFor&&(m.get(-1/0).onsuccess=$)}());var S=_._waitingFor;return new ge(function($,M){C.then(function(E){return _._waitingQueue.push(at($.bind(null,E)))},function(E){return _._waitingQueue.push(at(M.bind(null,E)))}).finally(function(){_._waitingFor===S&&(_._waitingFor=null)})})},Vn.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new G.Abort))},Vn.prototype.table=function(u){var m=this._memoizedTables||(this._memoizedTables={});if(d(m,u))return m[u];var _=this.schema[u];if(!_)throw new G.NotFound("Table "+u+" not part of transaction");return _=new this.db.Table(u,_,this),_.core=this.db.core.table(u),m[u]=_},Vn);function Vn(){}function If(u,m,_,C,S,$,M){return{name:u,keyPath:m,unique:_,multi:C,auto:S,compound:$,src:(_&&!M?"&":"")+(C?"*":"")+(S?"++":"")+Tb(m)}}function Tb(u){return typeof u=="string"?u:u?"["+[].join.call(u,"+")+"]":""}function Mf(u,m,_){return{name:u,primKey:m,indexes:_,mappedClass:null,idxByName:(C=function(S){return[S.name,S]},_.reduce(function(S,$,M){return M=C($,M),M&&(S[M[0]]=M[1]),S},{}))};var C}var Po=function(u){try{return u.only([[]]),Po=function(){return[[]]},[[]]}catch{return Po=function(){return mi},mi}};function Nf(u){return u==null?function(){}:typeof u=="string"?(m=u).split(".").length===1?function(_){return _[m]}:function(_){return z(_,m)}:function(_){return z(_,u)};var m}function $b(u){return[].slice.call(u)}var A$=0;function Lo(u){return u==null?":id":typeof u=="string"?u:"[".concat(u.join("+"),"]")}function P$(u,m,L){function C(B){if(B.type===3)return null;if(B.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var R=B.lower,j=B.upper,V=B.lowerOpen,B=B.upperOpen;return R===void 0?j===void 0?null:m.upperBound(j,!!B):j===void 0?m.lowerBound(R,!!V):m.bound(R,j,!!V,!!B)}function S(W){var R,j=W.name;return{name:j,schema:W,mutate:function(V){var B=V.trans,q=V.type,Y=V.keys,J=V.values,ee=V.range;return new Promise(function(se,le){se=at(se);var ie=B.objectStore(j),oe=ie.keyPath==null,ue=q==="put"||q==="add";if(!ue&&q!=="delete"&&q!=="deleteRange")throw new Error("Invalid operation type: "+q);var ae,_e=(Y||J||{length:1}).length;if(Y&&J&&Y.length!==J.length)throw new Error("Given keys array must have same length as given values array.");if(_e===0)return se({numFailures:0,failures:{},results:[],lastResult:void 0});function Oe(Ht){++tn,Eo(Ht)}var We=[],Ke=[],tn=0;if(q==="deleteRange"){if(ee.type===4)return se({numFailures:tn,failures:Ke,results:[],lastResult:void 0});ee.type===3?We.push(ae=ie.clear()):We.push(ae=ie.delete(C(ee)))}else{var oe=ue?oe?[J,Y]:[J,null]:[Y,null],ze=oe[0],At=oe[1];if(ue)for(var Pt=0;Pt<_e;++Pt)We.push(ae=At&&At[Pt]!==void 0?ie[q](ze[Pt],At[Pt]):ie[q](ze[Pt])),ae.onerror=Oe;else for(Pt=0;Pt<_e;++Pt)We.push(ae=ie[q](ze[Pt])),ae.onerror=Oe}function Lc(Ht){Ht=Ht.target.result,We.forEach(function(_i,Zf){return _i.error!=null&&(Ke[Zf]=_i.error)}),se({numFailures:tn,failures:Ke,results:q==="delete"?Y:We.map(function(_i){return _i.result}),lastResult:Ht})}ae.onerror=function(Ht){Oe(Ht),Lc(Ht)},ae.onsuccess=Lc})},getMany:function(V){var B=V.trans,q=V.keys;return new Promise(function(Y,J){Y=at(Y);for(var ee,se=B.objectStore(j),le=q.length,ie=new Array(le),oe=0,ue=0,ae=function(We){We=We.target,ie[We._pos]=We.result,++ue===oe&&Y(ie)},_e=Un(J),Oe=0;Oe<le;++Oe)q[Oe]!=null&&((ee=se.get(q[Oe]))._pos=Oe,ee.onsuccess=ae,ee.onerror=_e,++oe);oe===0&&Y(ie)})},get:function(V){var B=V.trans,q=V.key;return new Promise(function(Y,J){Y=at(Y);var ee=B.objectStore(j).get(q);ee.onsuccess=function(se){return Y(se.target.result)},ee.onerror=Un(J)})},query:(R=F,function(V){return new Promise(function(B,q){B=at(B);var Y,J,ee,oe=V.trans,se=V.values,le=V.limit,ae=V.query,ie=le===1/0?void 0:le,ue=ae.index,ae=ae.range,oe=oe.objectStore(j),ue=ue.isPrimaryKey?oe:oe.index(ue.name),ae=C(ae);if(le===0)return B({result:[]});R?((ie=se?ue.getAll(ae,ie):ue.getAllKeys(ae,ie)).onsuccess=function(_e){return B({result:_e.target.result})},ie.onerror=Un(q)):(Y=0,J=!se&&"openKeyCursor"in ue?ue.openKeyCursor(ae):ue.openCursor(ae),ee=[],J.onsuccess=function(_e){var Oe=J.result;return Oe?(ee.push(se?Oe.value:Oe.primaryKey),++Y===le?B({result:ee}):void Oe.continue()):B({result:ee})},J.onerror=Un(q))})}),openCursor:function(V){var B=V.trans,q=V.values,Y=V.query,J=V.reverse,ee=V.unique;return new Promise(function(se,le){se=at(se);var ue=Y.index,ie=Y.range,oe=B.objectStore(j),oe=ue.isPrimaryKey?oe:oe.index(ue.name),ue=J?ee?"prevunique":"prev":ee?"nextunique":"next",ae=!q&&"openKeyCursor"in oe?oe.openKeyCursor(C(ie),ue):oe.openCursor(C(ie),ue);ae.onerror=Un(le),ae.onsuccess=at(function(_e){var Oe,We,Ke,tn,ze=ae.result;ze?(ze.___id=++A$,ze.done=!1,Oe=ze.continue.bind(ze),We=(We=ze.continuePrimaryKey)&&We.bind(ze),Ke=ze.advance.bind(ze),tn=function(){throw new Error("Cursor not stopped")},ze.trans=B,ze.stop=ze.continue=ze.continuePrimaryKey=ze.advance=function(){throw new Error("Cursor not started")},ze.fail=at(le),ze.next=function(){var At=this,Pt=1;return this.start(function(){return Pt--?At.continue():At.stop()}).then(function(){return At})},ze.start=function(At){function Pt(){if(ae.result)try{At()}catch(Ht){ze.fail(Ht)}else ze.done=!0,ze.start=function(){throw new Error("Cursor behind last entry")},ze.stop()}var Lc=new Promise(function(Ht,_i){Ht=at(Ht),ae.onerror=Un(_i),ze.fail=_i,ze.stop=function(Zf){ze.stop=ze.continue=ze.continuePrimaryKey=ze.advance=tn,Ht(Zf)}});return ae.onsuccess=at(function(Ht){ae.onsuccess=Pt,Pt()}),ze.continue=Oe,ze.continuePrimaryKey=We,ze.advance=Ke,Pt(),Lc},se(ze)):se(null)},le)})},count:function(V){var B=V.query,q=V.trans,Y=B.index,J=B.range;return new Promise(function(ee,se){var le=q.objectStore(j),ie=Y.isPrimaryKey?le:le.index(Y.name),le=C(J),ie=le?ie.count(le):ie.count();ie.onsuccess=at(function(oe){return ee(oe.target.result)}),ie.onerror=Un(se)})}}}var $,M,E,H=(M=L,E=$b(($=u).objectStoreNames),{schema:{name:$.name,tables:E.map(function(W){return M.objectStore(W)}).map(function(W){var R=W.keyPath,B=W.autoIncrement,j=a(R),V={},B={name:W.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:R==null,compound:j,keyPath:R,autoIncrement:B,unique:!0,extractKey:Nf(R)},indexes:$b(W.indexNames).map(function(q){return W.index(q)}).map(function(ee){var Y=ee.name,J=ee.unique,se=ee.multiEntry,ee=ee.keyPath,se={name:Y,compound:a(ee),keyPath:ee,unique:J,multiEntry:se,extractKey:Nf(ee)};return V[Lo(ee)]=se}),getIndexByKeyPath:function(q){return V[Lo(q)]}};return V[":id"]=B.primaryKey,R!=null&&(V[Lo(R)]=B.primaryKey),B})},hasGetAll:0<E.length&&"getAll"in M.objectStore(E[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),L=H.schema,F=H.hasGetAll,H=L.tables.map(S),P={};return H.forEach(function(W){return P[W.name]=W}),{stack:"dbcore",transaction:u.transaction.bind(u),table:function(W){if(!P[W])throw new Error("Table '".concat(W,"' not found"));return P[W]},MIN_KEY:-1/0,MAX_KEY:Po(m),schema:L}}function L$(u,m,_,C){var S=_.IDBKeyRange;return _.indexedDB,{dbcore:(C=P$(m,S,C),u.dbcore.reduce(function($,M){return M=M.create,n(n({},$),M($))},C))}}function xc(u,C){var _=C.db,C=L$(u._middlewares,_,u._deps,C);u.core=C.dbcore,u.tables.forEach(function(S){var $=S.name;u.core.schema.tables.some(function(M){return M.name===$})&&(S.core=u.core.table($),u[$]instanceof u.Table&&(u[$].core=S.core))})}function kc(u,m,_,C){_.forEach(function(S){var $=C[S];m.forEach(function(M){var E=function L(F,H){return w(F,H)||(F=c(F))&&L(F,H)}(M,S);(!E||"value"in E&&E.value===void 0)&&(M===u.Transaction.prototype||M instanceof u.Transaction?y(M,S,{get:function(){return this.table(S)},set:function(L){p(this,S,{value:L,writable:!0,configurable:!0,enumerable:!0})}}):M[S]=new u.Table(S,$))})})}function Ef(u,m){m.forEach(function(_){for(var C in _)_[C]instanceof u.Table&&delete _[C]})}function R$(u,m){return u._cfg.version-m._cfg.version}function z$(u,m,_,C){var S=u._dbSchema;_.objectStoreNames.contains("$meta")&&!S.$meta&&(S.$meta=Mf("$meta",Ib("")[0],[]),u._storeNames.push("$meta"));var $=u._createTransaction("readwrite",u._storeNames,S);$.create(_),$._completion.catch(C);var M=$._reject.bind($),E=ke.transless||ke;Ps(function(){return ke.trans=$,ke.transless=E,m!==0?(xc(u,_),F=m,((L=$).storeNames.includes("$meta")?L.table("$meta").get("version").then(function(H){return H??F}):ge.resolve(F)).then(function(H){return W=H,R=$,j=_,V=[],H=(P=u)._versions,B=P._dbSchema=Tc(0,P.idbdb,j),(H=H.filter(function(q){return q._cfg.version>=W})).length!==0?(H.forEach(function(q){V.push(function(){var Y=B,J=q._cfg.dbschema;$c(P,Y,j),$c(P,J,j),B=P._dbSchema=J;var ee=Af(Y,J);ee.add.forEach(function(ue){Pf(j,ue[0],ue[1].primKey,ue[1].indexes)}),ee.change.forEach(function(ue){if(ue.recreate)throw new G.Upgrade("Not yet support for changing primary key");var ae=j.objectStore(ue.name);ue.add.forEach(function(_e){return Sc(ae,_e)}),ue.change.forEach(function(_e){ae.deleteIndex(_e.name),Sc(ae,_e)}),ue.del.forEach(function(_e){return ae.deleteIndex(_e)})});var se=q._cfg.contentUpgrade;if(se&&q._cfg.version>W){xc(P,j),R._memoizedTables={};var le=K(J);ee.del.forEach(function(ue){le[ue]=Y[ue]}),Ef(P,[P.Transaction.prototype]),kc(P,[P.Transaction.prototype],o(le),le),R.schema=le;var ie,oe=Ue(se);return oe&&lr(),ee=ge.follow(function(){var ue;(ie=se(R))&&oe&&(ue=Ls.bind(null,null),ie.then(ue,ue))}),ie&&typeof ie.then=="function"?ge.resolve(ie):ee.then(function(){return ie})}}),V.push(function(Y){var J,ee,se=q._cfg.dbschema;J=se,ee=Y,[].slice.call(ee.db.objectStoreNames).forEach(function(le){return J[le]==null&&ee.db.deleteObjectStore(le)}),Ef(P,[P.Transaction.prototype]),kc(P,[P.Transaction.prototype],P._storeNames,P._dbSchema),R.schema=P._dbSchema}),V.push(function(Y){P.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(P.idbdb.version/10)===q._cfg.version?(P.idbdb.deleteObjectStore("$meta"),delete P._dbSchema.$meta,P._storeNames=P._storeNames.filter(function(J){return J!=="$meta"})):Y.objectStore("$meta").put(q._cfg.version,"version"))})}),function q(){return V.length?ge.resolve(V.shift()(R.idbtrans)).then(q):ge.resolve()}().then(function(){Db(B,j)})):ge.resolve();var P,W,R,j,V,B}).catch(M)):(o(S).forEach(function(H){Pf(_,H,S[H].primKey,S[H].indexes)}),xc(u,_),void ge.follow(function(){return u.on.populate.fire($)}).catch(M));var L,F})}function F$(u,m){Db(u._dbSchema,m),m.db.version%10!=0||m.objectStoreNames.contains("$meta")||m.db.createObjectStore("$meta").add(Math.ceil(m.db.version/10-1),"version");var _=Tc(0,u.idbdb,m);$c(u,u._dbSchema,m);for(var C=0,S=Af(_,u._dbSchema).change;C<S.length;C++){var $=function(M){if(M.change.length||M.recreate)return console.warn("Unable to patch indexes of table ".concat(M.name," because it has changes on the type of index or primary key.")),{value:void 0};var E=m.objectStore(M.name);M.add.forEach(function(L){Hn&&console.debug("Dexie upgrade patch: Creating missing index ".concat(M.name,".").concat(L.src)),Sc(E,L)})}(S[C]);if(typeof $=="object")return $.value}}function Af(u,m){var _,C={del:[],add:[],change:[]};for(_ in u)m[_]||C.del.push(_);for(_ in m){var S=u[_],$=m[_];if(S){var M={name:_,def:$,recreate:!1,del:[],add:[],change:[]};if(""+(S.primKey.keyPath||"")!=""+($.primKey.keyPath||"")||S.primKey.auto!==$.primKey.auto)M.recreate=!0,C.change.push(M);else{var E=S.idxByName,L=$.idxByName,F=void 0;for(F in E)L[F]||M.del.push(F);for(F in L){var H=E[F],P=L[F];H?H.src!==P.src&&M.change.push(P):M.add.push(P)}(0<M.del.length||0<M.add.length||0<M.change.length)&&C.change.push(M)}}else C.add.push([_,$])}return C}function Pf(u,m,_,C){var S=u.db.createObjectStore(m,_.keyPath?{keyPath:_.keyPath,autoIncrement:_.auto}:{autoIncrement:_.auto});return C.forEach(function($){return Sc(S,$)}),S}function Db(u,m){o(u).forEach(function(_){m.db.objectStoreNames.contains(_)||(Hn&&console.debug("Dexie: Creating missing table",_),Pf(m,_,u[_].primKey,u[_].indexes))})}function Sc(u,m){u.createIndex(m.name,m.keyPath,{unique:m.unique,multiEntry:m.multi})}function Tc(u,m,_){var C={};return T(m.objectStoreNames,0).forEach(function(S){for(var $=_.objectStore(S),M=If(Tb(F=$.keyPath),F||"",!0,!1,!!$.autoIncrement,F&&typeof F!="string",!0),E=[],L=0;L<$.indexNames.length;++L){var H=$.index($.indexNames[L]),F=H.keyPath,H=If(H.name,F,!!H.unique,!!H.multiEntry,!1,F&&typeof F!="string",!1);E.push(H)}C[S]=Mf(S,M,E)}),C}function $c(u,m,_){for(var C=_.db.objectStoreNames,S=0;S<C.length;++S){var $=C[S],M=_.objectStore($);u._hasGetAll="getAll"in M;for(var E=0;E<M.indexNames.length;++E){var L=M.indexNames[E],F=M.index(L).keyPath,H=typeof F=="string"?F:"["+T(F).join("+")+"]";!m[$]||(F=m[$].idxByName[H])&&(F.name=L,delete m[$].idxByName[H],m[$].idxByName[L]=F)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&r.WorkerGlobalScope&&r instanceof r.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(u._hasGetAll=!1)}function Ib(u){return u.split(",").map(function(m,_){var C=(m=m.trim()).replace(/([&*]|\+\+)/g,""),S=/^\[/.test(C)?C.match(/^\[(.*)\]$/)[1].split("+"):C;return If(C,S||null,/\&/.test(m),/\*/.test(m),/\+\+/.test(m),a(S),_===0)})}var O$=(Dc.prototype._parseStoresSpec=function(u,m){o(u).forEach(function(_){if(u[_]!==null){var C=Ib(u[_]),S=C.shift();if(S.unique=!0,S.multi)throw new G.Schema("Primary key cannot be multi-valued");C.forEach(function($){if($.auto)throw new G.Schema("Only primary key can be marked as autoIncrement (++)");if(!$.keyPath)throw new G.Schema("Index must have a name and cannot be an empty string")}),m[_]=Mf(_,S,C)}})},Dc.prototype.stores=function(_){var m=this.db;this._cfg.storesSource=this._cfg.storesSource?l(this._cfg.storesSource,_):_;var _=m._versions,C={},S={};return _.forEach(function($){l(C,$._cfg.storesSource),S=$._cfg.dbschema={},$._parseStoresSpec(C,S)}),m._dbSchema=S,Ef(m,[m._allTables,m,m.Transaction.prototype]),kc(m,[m._allTables,m,m.Transaction.prototype,this._cfg.tables],o(S),S),m._storeNames=o(S),this},Dc.prototype.upgrade=function(u){return this._cfg.contentUpgrade=pf(this._cfg.contentUpgrade||Le,u),this},Dc);function Dc(){}function Lf(u,m){var _=u._dbNamesDB;return _||(_=u._dbNamesDB=new ds(vc,{addons:[],indexedDB:u,IDBKeyRange:m})).version(1).stores({dbnames:"name"}),_.table("dbnames")}function Rf(u){return u&&typeof u.databases=="function"}function zf(u){return Ps(function(){return ke.letThrough=!0,u()})}function Ff(u){return!("from"in u)}var Et=function(u,m){if(!this){var _=new Et;return u&&"d"in u&&l(_,u),_}l(this,arguments.length?{d:1,from:u,to:1<arguments.length?m:u}:{d:0})};function Ro(u,m,_){var C=Ge(m,_);if(!isNaN(C)){if(0<C)throw RangeError();if(Ff(u))return l(u,{from:m,to:_,d:1});var S=u.l,C=u.r;if(Ge(_,u.from)<0)return S?Ro(S,m,_):u.l={from:m,to:_,d:1,l:null,r:null},Nb(u);if(0<Ge(m,u.to))return C?Ro(C,m,_):u.r={from:m,to:_,d:1,l:null,r:null},Nb(u);Ge(m,u.from)<0&&(u.from=m,u.l=null,u.d=C?C.d+1:1),0<Ge(_,u.to)&&(u.to=_,u.r=null,u.d=u.l?u.l.d+1:1),_=!u.r,S&&!u.l&&zo(u,S),C&&_&&zo(u,C)}}function zo(u,m){Ff(m)||function _(C,L){var $=L.from,M=L.to,E=L.l,L=L.r;Ro(C,$,M),E&&_(C,E),L&&_(C,L)}(u,m)}function Mb(u,m){var _=Ic(m),C=_.next();if(C.done)return!1;for(var S=C.value,$=Ic(u),M=$.next(S.from),E=M.value;!C.done&&!M.done;){if(Ge(E.from,S.to)<=0&&0<=Ge(E.to,S.from))return!0;Ge(S.from,E.from)<0?S=(C=_.next(E.from)).value:E=(M=$.next(S.from)).value}return!1}function Ic(u){var m=Ff(u)?null:{s:0,n:u};return{next:function(_){for(var C=0<arguments.length;m;)switch(m.s){case 0:if(m.s=1,C)for(;m.n.l&&Ge(_,m.n.from)<0;)m={up:m,n:m.n.l,s:1};else for(;m.n.l;)m={up:m,n:m.n.l,s:1};case 1:if(m.s=2,!C||Ge(_,m.n.to)<=0)return{value:m.n,done:!1};case 2:if(m.n.r){m.s=3,m={up:m,n:m.n.r,s:0};continue}case 3:m=m.up}return{done:!0}}}}function Nb(u){var m,_,C=(((m=u.r)===null||m===void 0?void 0:m.d)||0)-(((_=u.l)===null||_===void 0?void 0:_.d)||0),S=1<C?"r":C<-1?"l":"";S&&(m=S=="r"?"l":"r",_=n({},u),C=u[S],u.from=C.from,u.to=C.to,u[S]=C[S],_[S]=C[m],(u[m]=_).d=Eb(_)),u.d=Eb(u)}function Eb(_){var m=_.r,_=_.l;return(m?_?Math.max(m.d,_.d):m.d:_?_.d:0)+1}function Mc(u,m){return o(m).forEach(function(_){u[_]?zo(u[_],m[_]):u[_]=function C(S){var $,M,E={};for($ in S)d(S,$)&&(M=S[$],E[$]=!M||typeof M!="object"||Q.has(M.constructor)?M:C(M));return E}(m[_])}),u}function Of(u,m){return u.all||m.all||Object.keys(u).some(function(_){return m[_]&&Mb(m[_],u[_])})}f(Et.prototype,((cn={add:function(u){return zo(this,u),this},addKey:function(u){return Ro(this,u,u),this},addKeys:function(u){var m=this;return u.forEach(function(_){return Ro(m,_,_)}),this},hasKey:function(u){var m=Ic(this).next(u).value;return m&&Ge(m.from,u)<=0&&0<=Ge(m.to,u)}})[je]=function(){return Ic(this)},cn));var yi={},Bf={},jf=!1;function Nc(u){Mc(Bf,u),jf||(jf=!0,setTimeout(function(){jf=!1,Hf(Bf,!(Bf={}))},0))}function Hf(u,m){m===void 0&&(m=!1);var _=new Set;if(u.all)for(var C=0,S=Object.values(yi);C<S.length;C++)Ab(M=S[C],u,_,m);else for(var $ in u){var M,E=/^idb\:\/\/(.*)\/(.*)\//.exec($);E&&($=E[1],E=E[2],(M=yi["idb://".concat($,"/").concat(E)])&&Ab(M,u,_,m))}_.forEach(function(L){return L()})}function Ab(u,m,_,C){for(var S=[],$=0,M=Object.entries(u.queries.query);$<M.length;$++){for(var E=M[$],L=E[0],F=[],H=0,P=E[1];H<P.length;H++){var W=P[H];Of(m,W.obsSet)?W.subscribers.forEach(function(B){return _.add(B)}):C&&F.push(W)}C&&S.push([L,F])}if(C)for(var R=0,j=S;R<j.length;R++){var V=j[R],L=V[0],F=V[1];u.queries.query[L]=F}}function B$(u){var m=u._state,_=u._deps.indexedDB;if(m.isBeingOpened||u.idbdb)return m.dbReadyPromise.then(function(){return m.dbOpenError?lt(m.dbOpenError):u});m.isBeingOpened=!0,m.dbOpenError=null,m.openComplete=!1;var C=m.openCanceller,S=Math.round(10*u.verno),$=!1;function M(){if(m.openCanceller!==C)throw new G.DatabaseClosed("db.open() was cancelled")}function E(){return new ge(function(W,R){if(M(),!_)throw new G.MissingAPI;var j=u.name,V=m.autoSchema||!S?_.open(j):_.open(j,S);if(!V)throw new G.MissingAPI;V.onerror=Un(R),V.onblocked=at(u._fireOnBlocked),V.onupgradeneeded=at(function(B){var q;H=V.transaction,m.autoSchema&&!u._options.allowEmptyDB?(V.onerror=Eo,H.abort(),V.result.close(),(q=_.deleteDatabase(j)).onsuccess=q.onerror=at(function(){R(new G.NoSuchDatabase("Database ".concat(j," doesnt exist")))})):(H.onerror=Un(R),B=B.oldVersion>Math.pow(2,62)?0:B.oldVersion,P=B<1,u.idbdb=V.result,$&&F$(u,H),z$(u,B/10,H,R))},R),V.onsuccess=at(function(){H=null;var B,q,Y,J,ee,se=u.idbdb=V.result,le=T(se.objectStoreNames);if(0<le.length)try{var ie=se.transaction((J=le).length===1?J[0]:J,"readonly");if(m.autoSchema)q=se,Y=ie,(B=u).verno=q.version/10,Y=B._dbSchema=Tc(0,q,Y),B._storeNames=T(q.objectStoreNames,0),kc(B,[B._allTables],o(Y),Y);else if($c(u,u._dbSchema,ie),((ee=Af(Tc(0,(ee=u).idbdb,ie),ee._dbSchema)).add.length||ee.change.some(function(oe){return oe.add.length||oe.change.length}))&&!$)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),se.close(),S=se.version+1,$=!0,W(E());xc(u,ie)}catch{}cr.push(u),se.onversionchange=at(function(oe){m.vcFired=!0,u.on("versionchange").fire(oe)}),se.onclose=at(function(oe){u.on("close").fire(oe)}),P&&(ee=u._deps,ie=j,se=ee.indexedDB,ee=ee.IDBKeyRange,Rf(se)||ie===vc||Lf(se,ee).put({name:ie}).catch(Le)),W()},R)}).catch(function(W){switch(W==null?void 0:W.name){case"UnknownError":if(0<m.PR1398_maxLoop)return m.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),E();break;case"VersionError":if(0<S)return S=0,E()}return ge.reject(W)})}var L,F=m.dbReadyResolve,H=null,P=!1;return ge.race([C,(typeof navigator>"u"?ge.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(W){function R(){return indexedDB.databases().finally(W)}L=setInterval(R,100),R()}).finally(function(){return clearInterval(L)}):Promise.resolve()).then(E)]).then(function(){return M(),m.onReadyBeingFired=[],ge.resolve(zf(function(){return u.on.ready.fire(u.vip)})).then(function W(){if(0<m.onReadyBeingFired.length){var R=m.onReadyBeingFired.reduce(pf,Le);return m.onReadyBeingFired=[],ge.resolve(zf(function(){return R(u.vip)})).then(W)}})}).finally(function(){m.openCanceller===C&&(m.onReadyBeingFired=null,m.isBeingOpened=!1)}).catch(function(W){m.dbOpenError=W;try{H&&H.abort()}catch{}return C===m.openCanceller&&u._close(),lt(W)}).finally(function(){m.openComplete=!0,F()}).then(function(){var W;return P&&(W={},u.tables.forEach(function(R){R.schema.indexes.forEach(function(j){j.name&&(W["idb://".concat(u.name,"/").concat(R.name,"/").concat(j.name)]=new Et(-1/0,[[[]]]))}),W["idb://".concat(u.name,"/").concat(R.name,"/")]=W["idb://".concat(u.name,"/").concat(R.name,"/:dels")]=new Et(-1/0,[[[]]])}),Fs(Ao).fire(W),Hf(W,!0)),u})}function Uf(u){function m($){return u.next($)}var _=S(m),C=S(function($){return u.throw($)});function S($){return function(L){var E=$(L),L=E.value;return E.done?L:L&&typeof L.then=="function"?L.then(_,C):a(L)?Promise.all(L).then(_,C):_(L)}}return S(m)()}function Ec(u,m,_){for(var C=a(u)?u.slice():[u],S=0;S<_;++S)C.push(m);return C}var j$={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(u){return n(n({},u),{table:function(m){var _=u.table(m),C=_.schema,S={},$=[];function M(P,W,R){var j=Lo(P),V=S[j]=S[j]||[],B=P==null?0:typeof P=="string"?1:P.length,q=0<W,q=n(n({},R),{name:q?"".concat(j,"(virtual-from:").concat(R.name,")"):R.name,lowLevelIndex:R,isVirtual:q,keyTail:W,keyLength:B,extractKey:Nf(P),unique:!q&&R.unique});return V.push(q),q.isPrimaryKey||$.push(q),1<B&&M(B===2?P[0]:P.slice(0,B-1),W+1,R),V.sort(function(Y,J){return Y.keyTail-J.keyTail}),q}m=M(C.primaryKey.keyPath,0,C.primaryKey),S[":id"]=[m];for(var E=0,L=C.indexes;E<L.length;E++){var F=L[E];M(F.keyPath,0,F)}function H(P){var W,R=P.query.index;return R.isVirtual?n(n({},P),{query:{index:R.lowLevelIndex,range:(W=P.query.range,R=R.keyTail,{type:W.type===1?2:W.type,lower:Ec(W.lower,W.lowerOpen?u.MAX_KEY:u.MIN_KEY,R),lowerOpen:!0,upper:Ec(W.upper,W.upperOpen?u.MIN_KEY:u.MAX_KEY,R),upperOpen:!0})}}):P}return n(n({},_),{schema:n(n({},C),{primaryKey:m,indexes:$,getIndexByKeyPath:function(P){return(P=S[Lo(P)])&&P[0]}}),count:function(P){return _.count(H(P))},query:function(P){return _.query(H(P))},openCursor:function(P){var W=P.query.index,R=W.keyTail,j=W.isVirtual,V=W.keyLength;return j?_.openCursor(H(P)).then(function(q){return q&&B(q)}):_.openCursor(P);function B(q){return Object.create(q,{continue:{value:function(Y){Y!=null?q.continue(Ec(Y,P.reverse?u.MAX_KEY:u.MIN_KEY,R)):P.unique?q.continue(q.key.slice(0,V).concat(P.reverse?u.MIN_KEY:u.MAX_KEY,R)):q.continue()}},continuePrimaryKey:{value:function(Y,J){q.continuePrimaryKey(Ec(Y,u.MAX_KEY,R),J)}},primaryKey:{get:function(){return q.primaryKey}},key:{get:function(){var Y=q.key;return V===1?Y[0]:Y.slice(0,V)}},value:{get:function(){return q.value}}})}}})}})}};function Vf(u,m,_,C){return _=_||{},C=C||"",o(u).forEach(function(S){var $,M,E;d(m,S)?($=u[S],M=m[S],typeof $=="object"&&typeof M=="object"&&$&&M?(E=Re($))!==Re(M)?_[C+S]=m[S]:E==="Object"?Vf($,M,_,C+S+"."):$!==M&&(_[C+S]=m[S]):$!==M&&(_[C+S]=m[S])):_[C+S]=void 0}),o(m).forEach(function(S){d(u,S)||(_[C+S]=m[S])}),_}function Wf(u,m){return m.type==="delete"?m.keys:m.keys||m.values.map(u.extractKey)}var H$={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(u){return n(n({},u),{table:function(m){var _=u.table(m),C=_.schema.primaryKey;return n(n({},_),{mutate:function(S){var $=ke.trans,M=$.table(m).hook,E=M.deleting,L=M.creating,F=M.updating;switch(S.type){case"add":if(L.fire===Le)break;return $._promise("readwrite",function(){return H(S)},!0);case"put":if(L.fire===Le&&F.fire===Le)break;return $._promise("readwrite",function(){return H(S)},!0);case"delete":if(E.fire===Le)break;return $._promise("readwrite",function(){return H(S)},!0);case"deleteRange":if(E.fire===Le)break;return $._promise("readwrite",function(){return function P(W,R,j){return _.query({trans:W,values:!1,query:{index:C,range:R},limit:j}).then(function(V){var B=V.result;return H({type:"delete",keys:B,trans:W}).then(function(q){return 0<q.numFailures?Promise.reject(q.failures[0]):B.length<j?{failures:[],numFailures:0,lastResult:void 0}:P(W,n(n({},R),{lower:B[B.length-1],lowerOpen:!0}),j)})})}(S.trans,S.range,1e4)},!0)}return _.mutate(S);function H(P){var W,R,j,V=ke.trans,B=P.keys||Wf(C,P);if(!B)throw new Error("Keys missing");return(P=P.type==="add"||P.type==="put"?n(n({},P),{keys:B}):n({},P)).type!=="delete"&&(P.values=s([],P.values,!0)),P.keys&&(P.keys=s([],P.keys,!0)),W=_,j=B,((R=P).type==="add"?Promise.resolve([]):W.getMany({trans:R.trans,keys:j,cache:"immutable"})).then(function(q){var Y=B.map(function(J,ee){var se,le,ie,oe=q[ee],ue={onerror:null,onsuccess:null};return P.type==="delete"?E.fire.call(ue,J,oe,V):P.type==="add"||oe===void 0?(se=L.fire.call(ue,J,P.values[ee],V),J==null&&se!=null&&(P.keys[ee]=J=se,C.outbound||O(P.values[ee],C.keyPath,J))):(se=Vf(oe,P.values[ee]),(le=F.fire.call(ue,se,J,oe,V))&&(ie=P.values[ee],Object.keys(le).forEach(function(ae){d(ie,ae)?ie[ae]=le[ae]:O(ie,ae,le[ae])}))),ue});return _.mutate(P).then(function(J){for(var ee=J.failures,se=J.results,le=J.numFailures,J=J.lastResult,ie=0;ie<B.length;++ie){var oe=(se||B)[ie],ue=Y[ie];oe==null?ue.onerror&&ue.onerror(ee[ie]):ue.onsuccess&&ue.onsuccess(P.type==="put"&&q[ie]?P.values[ie]:oe)}return{failures:ee,results:se,numFailures:le,lastResult:J}}).catch(function(J){return Y.forEach(function(ee){return ee.onerror&&ee.onerror(J)}),Promise.reject(J)})})}}})}})}};function Pb(u,m,_){try{if(!m||m.keys.length<u.length)return null;for(var C=[],S=0,$=0;S<m.keys.length&&$<u.length;++S)Ge(m.keys[S],u[$])===0&&(C.push(_?xe(m.values[S]):m.values[S]),++$);return C.length===u.length?C:null}catch{return null}}var U$={stack:"dbcore",level:-1,create:function(u){return{table:function(m){var _=u.table(m);return n(n({},_),{getMany:function(C){if(!C.cache)return _.getMany(C);var S=Pb(C.keys,C.trans._cache,C.cache==="clone");return S?ge.resolve(S):_.getMany(C).then(function($){return C.trans._cache={keys:C.keys,values:C.cache==="clone"?xe($):$},$})},mutate:function(C){return C.type!=="add"&&(C.trans._cache=null),_.mutate(C)}})}}}};function Lb(u,m){return u.trans.mode==="readonly"&&!!u.subscr&&!u.trans.explicit&&u.trans.db._options.cache!=="disabled"&&!m.schema.primaryKey.outbound}function Rb(u,m){switch(u){case"query":return m.values&&!m.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var V$={stack:"dbcore",level:0,name:"Observability",create:function(u){var m=u.schema.name,_=new Et(u.MIN_KEY,u.MAX_KEY);return n(n({},u),{transaction:function(C,S,$){if(ke.subscr&&S!=="readonly")throw new G.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(ke.querier));return u.transaction(C,S,$)},table:function(C){var S=u.table(C),$=S.schema,M=$.primaryKey,P=$.indexes,E=M.extractKey,L=M.outbound,F=M.autoIncrement&&P.filter(function(R){return R.compound&&R.keyPath.includes(M.keyPath)}),H=n(n({},S),{mutate:function(R){function j(ae){return ae="idb://".concat(m,"/").concat(C,"/").concat(ae),J[ae]||(J[ae]=new Et)}var V,B,q,Y=R.trans,J=R.mutatedParts||(R.mutatedParts={}),ee=j(""),se=j(":dels"),le=R.type,ue=R.type==="deleteRange"?[R.range]:R.type==="delete"?[R.keys]:R.values.length<50?[Wf(M,R).filter(function(ae){return ae}),R.values]:[],ie=ue[0],oe=ue[1],ue=R.trans._cache;return a(ie)?(ee.addKeys(ie),(ue=le==="delete"||ie.length===oe.length?Pb(ie,ue):null)||se.addKeys(ie),(ue||oe)&&(V=j,B=ue,q=oe,$.indexes.forEach(function(ae){var _e=V(ae.name||"");function Oe(Ke){return Ke!=null?ae.extractKey(Ke):null}function We(Ke){return ae.multiEntry&&a(Ke)?Ke.forEach(function(tn){return _e.addKey(tn)}):_e.addKey(Ke)}(B||q).forEach(function(Ke,At){var ze=B&&Oe(B[At]),At=q&&Oe(q[At]);Ge(ze,At)!==0&&(ze!=null&&We(ze),At!=null&&We(At))})}))):ie?(oe={from:(oe=ie.lower)!==null&&oe!==void 0?oe:u.MIN_KEY,to:(oe=ie.upper)!==null&&oe!==void 0?oe:u.MAX_KEY},se.add(oe),ee.add(oe)):(ee.add(_),se.add(_),$.indexes.forEach(function(ae){return j(ae.name).add(_)})),S.mutate(R).then(function(ae){return!ie||R.type!=="add"&&R.type!=="put"||(ee.addKeys(ae.results),F&&F.forEach(function(_e){for(var Oe=R.values.map(function(ze){return _e.extractKey(ze)}),We=_e.keyPath.findIndex(function(ze){return ze===M.keyPath}),Ke=0,tn=ae.results.length;Ke<tn;++Ke)Oe[Ke][We]=ae.results[Ke];j(_e.name).addKeys(Oe)})),Y.mutatedParts=Mc(Y.mutatedParts||{},J),ae})}}),P=function(j){var V=j.query,j=V.index,V=V.range;return[j,new Et((j=V.lower)!==null&&j!==void 0?j:u.MIN_KEY,(V=V.upper)!==null&&V!==void 0?V:u.MAX_KEY)]},W={get:function(R){return[M,new Et(R.key)]},getMany:function(R){return[M,new Et().addKeys(R.keys)]},count:P,query:P,openCursor:P};return o(W).forEach(function(R){H[R]=function(j){var V=ke.subscr,B=!!V,q=Lb(ke,S)&&Rb(R,j)?j.obsSet={}:V;if(B){var Y=function(oe){return oe="idb://".concat(m,"/").concat(C,"/").concat(oe),q[oe]||(q[oe]=new Et)},J=Y(""),ee=Y(":dels"),V=W[R](j),B=V[0],V=V[1];if((R==="query"&&B.isPrimaryKey&&!j.values?ee:Y(B.name||"")).add(V),!B.isPrimaryKey){if(R!=="count"){var se=R==="query"&&L&&j.values&&S.query(n(n({},j),{values:!1}));return S[R].apply(this,arguments).then(function(oe){if(R==="query"){if(L&&j.values)return se.then(function(Oe){return Oe=Oe.result,J.addKeys(Oe),oe});var ue=j.values?oe.result.map(E):oe.result;(j.values?J:ee).addKeys(ue)}else if(R==="openCursor"){var ae=oe,_e=j.values;return ae&&Object.create(ae,{key:{get:function(){return ee.addKey(ae.primaryKey),ae.key}},primaryKey:{get:function(){var Oe=ae.primaryKey;return ee.addKey(Oe),Oe}},value:{get:function(){return _e&&J.addKey(ae.primaryKey),ae.value}}})}return oe})}ee.add(_)}}return S[R].apply(this,arguments)}}),H}})}};function zb(u,m,_){if(_.numFailures===0)return m;if(m.type==="deleteRange")return null;var C=m.keys?m.keys.length:"values"in m&&m.values?m.values.length:1;return _.numFailures===C?null:(m=n({},m),a(m.keys)&&(m.keys=m.keys.filter(function(S,$){return!($ in _.failures)})),"values"in m&&a(m.values)&&(m.values=m.values.filter(function(S,$){return!($ in _.failures)})),m)}function Kf(u,m){return _=u,((C=m).lower===void 0||(C.lowerOpen?0<Ge(_,C.lower):0<=Ge(_,C.lower)))&&(u=u,(m=m).upper===void 0||(m.upperOpen?Ge(u,m.upper)<0:Ge(u,m.upper)<=0));var _,C}function Fb(u,m,W,C,S,$){if(!W||W.length===0)return u;var M=m.query.index,E=M.multiEntry,L=m.query.range,F=C.schema.primaryKey.extractKey,H=M.extractKey,P=(M.lowLevelIndex||M).extractKey,W=W.reduce(function(R,j){var V=R,B=[];if(j.type==="add"||j.type==="put")for(var q=new Et,Y=j.values.length-1;0<=Y;--Y){var J,ee=j.values[Y],se=F(ee);q.hasKey(se)||(J=H(ee),(E&&a(J)?J.some(function(ae){return Kf(ae,L)}):Kf(J,L))&&(q.addKey(se),B.push(ee)))}switch(j.type){case"add":var le=new Et().addKeys(m.values?R.map(function(_e){return F(_e)}):R),V=R.concat(m.values?B.filter(function(_e){return _e=F(_e),!le.hasKey(_e)&&(le.addKey(_e),!0)}):B.map(function(_e){return F(_e)}).filter(function(_e){return!le.hasKey(_e)&&(le.addKey(_e),!0)}));break;case"put":var ie=new Et().addKeys(j.values.map(function(_e){return F(_e)}));V=R.filter(function(_e){return!ie.hasKey(m.values?F(_e):_e)}).concat(m.values?B:B.map(function(_e){return F(_e)}));break;case"delete":var oe=new Et().addKeys(j.keys);V=R.filter(function(_e){return!oe.hasKey(m.values?F(_e):_e)});break;case"deleteRange":var ue=j.range;V=R.filter(function(_e){return!Kf(F(_e),ue)})}return V},u);return W===u?u:(W.sort(function(R,j){return Ge(P(R),P(j))||Ge(F(R),F(j))}),m.limit&&m.limit<1/0&&(W.length>m.limit?W.length=m.limit:u.length===m.limit&&W.length<m.limit&&(S.dirty=!0)),$?Object.freeze(W):W)}function Ob(u,m){return Ge(u.lower,m.lower)===0&&Ge(u.upper,m.upper)===0&&!!u.lowerOpen==!!m.lowerOpen&&!!u.upperOpen==!!m.upperOpen}function W$(u,m){return function(_,C,S,$){if(_===void 0)return C!==void 0?-1:0;if(C===void 0)return 1;if((C=Ge(_,C))===0){if(S&&$)return 0;if(S)return 1;if($)return-1}return C}(u.lower,m.lower,u.lowerOpen,m.lowerOpen)<=0&&0<=function(_,C,S,$){if(_===void 0)return C!==void 0?1:0;if(C===void 0)return-1;if((C=Ge(_,C))===0){if(S&&$)return 0;if(S)return-1;if($)return 1}return C}(u.upper,m.upper,u.upperOpen,m.upperOpen)}function K$(u,m,_,C){u.subscribers.add(_),C.addEventListener("abort",function(){var S,$;u.subscribers.delete(_),u.subscribers.size===0&&(S=u,$=m,setTimeout(function(){S.subscribers.size===0&&X($,S)},3e3))})}var q$={stack:"dbcore",level:0,name:"Cache",create:function(u){var m=u.schema.name;return n(n({},u),{transaction:function(_,C,S){var $,M,E=u.transaction(_,C,S);return C==="readwrite"&&(M=($=new AbortController).signal,S=function(L){return function(){if($.abort(),C==="readwrite"){for(var F=new Set,H=0,P=_;H<P.length;H++){var W=P[H],R=yi["idb://".concat(m,"/").concat(W)];if(R){var j=u.table(W),V=R.optimisticOps.filter(function(_e){return _e.trans===E});if(E._explicit&&L&&E.mutatedParts)for(var B=0,q=Object.values(R.queries.query);B<q.length;B++)for(var Y=0,J=(le=q[B]).slice();Y<J.length;Y++)Of((ie=J[Y]).obsSet,E.mutatedParts)&&(X(le,ie),ie.subscribers.forEach(function(_e){return F.add(_e)}));else if(0<V.length){R.optimisticOps=R.optimisticOps.filter(function(_e){return _e.trans!==E});for(var ee=0,se=Object.values(R.queries.query);ee<se.length;ee++)for(var le,ie,oe,ue=0,ae=(le=se[ee]).slice();ue<ae.length;ue++)(ie=ae[ue]).res!=null&&E.mutatedParts&&(L&&!ie.dirty?(oe=Object.isFrozen(ie.res),oe=Fb(ie.res,ie.req,V,j,ie,oe),ie.dirty?(X(le,ie),ie.subscribers.forEach(function(_e){return F.add(_e)})):oe!==ie.res&&(ie.res=oe,ie.promise=ge.resolve({result:oe}))):(ie.dirty&&X(le,ie),ie.subscribers.forEach(function(_e){return F.add(_e)})))}}}F.forEach(function(_e){return _e()})}}},E.addEventListener("abort",S(!1),{signal:M}),E.addEventListener("error",S(!1),{signal:M}),E.addEventListener("complete",S(!0),{signal:M})),E},table:function(_){var C=u.table(_),S=C.schema.primaryKey;return n(n({},C),{mutate:function($){var M=ke.trans;if(S.outbound||M.db._options.cache==="disabled"||M.explicit||M.idbtrans.mode!=="readwrite")return C.mutate($);var E=yi["idb://".concat(m,"/").concat(_)];return E?(M=C.mutate($),$.type!=="add"&&$.type!=="put"||!(50<=$.values.length||Wf(S,$).some(function(L){return L==null}))?(E.optimisticOps.push($),$.mutatedParts&&Nc($.mutatedParts),M.then(function(L){0<L.numFailures&&(X(E.optimisticOps,$),(L=zb(0,$,L))&&E.optimisticOps.push(L),$.mutatedParts&&Nc($.mutatedParts))}),M.catch(function(){X(E.optimisticOps,$),$.mutatedParts&&Nc($.mutatedParts)})):M.then(function(L){var F=zb(0,n(n({},$),{values:$.values.map(function(H,P){var W;return L.failures[P]?H:(H=(W=S.keyPath)!==null&&W!==void 0&&W.includes(".")?xe(H):n({},H),O(H,S.keyPath,L.results[P]),H)})}),L);E.optimisticOps.push(F),queueMicrotask(function(){return $.mutatedParts&&Nc($.mutatedParts)})}),M):C.mutate($)},query:function($){if(!Lb(ke,C)||!Rb("query",$))return C.query($);var M=((F=ke.trans)===null||F===void 0?void 0:F.db._options.cache)==="immutable",P=ke,E=P.requery,L=P.signal,F=function(j,V,B,q){var Y=yi["idb://".concat(j,"/").concat(V)];if(!Y)return[];if(!(V=Y.queries[B]))return[null,!1,Y,null];var J=V[(q.query?q.query.index.name:null)||""];if(!J)return[null,!1,Y,null];switch(B){case"query":var ee=J.find(function(se){return se.req.limit===q.limit&&se.req.values===q.values&&Ob(se.req.query.range,q.query.range)});return ee?[ee,!0,Y,J]:[J.find(function(se){return("limit"in se.req?se.req.limit:1/0)>=q.limit&&(!q.values||se.req.values)&&W$(se.req.query.range,q.query.range)}),!1,Y,J];case"count":return ee=J.find(function(se){return Ob(se.req.query.range,q.query.range)}),[ee,!!ee,Y,J]}}(m,_,"query",$),H=F[0],P=F[1],W=F[2],R=F[3];return H&&P?H.obsSet=$.obsSet:(P=C.query($).then(function(j){var V=j.result;if(H&&(H.res=V),M){for(var B=0,q=V.length;B<q;++B)Object.freeze(V[B]);Object.freeze(V)}else j.result=xe(V);return j}).catch(function(j){return R&&H&&X(R,H),Promise.reject(j)}),H={obsSet:$.obsSet,promise:P,subscribers:new Set,type:"query",req:$,dirty:!1},R?R.push(H):(R=[H],(W=W||(yi["idb://".concat(m,"/").concat(_)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[$.query.index.name||""]=R)),K$(H,R,E,L),H.promise.then(function(j){return{result:Fb(j.result,$,W==null?void 0:W.optimisticOps,C,H,M)}})}})}})}};function Ac(u,m){return new Proxy(u,{get:function(_,C,S){return C==="db"?m:Reflect.get(_,C,S)}})}var ds=(ct.prototype.version=function(u){if(isNaN(u)||u<.1)throw new G.Type("Given version is not a positive number");if(u=Math.round(10*u)/10,this.idbdb||this._state.isBeingOpened)throw new G.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,u);var m=this._versions,_=m.filter(function(C){return C._cfg.version===u})[0];return _||(_=new this.Version(u),m.push(_),m.sort(R$),_.stores({}),this._state.autoSchema=!1,_)},ct.prototype._whenReady=function(u){var m=this;return this.idbdb&&(this._state.openComplete||ke.letThrough||this._vip)?u():new ge(function(_,C){if(m._state.openComplete)return C(new G.DatabaseClosed(m._state.dbOpenError));if(!m._state.isBeingOpened){if(!m._state.autoOpen)return void C(new G.DatabaseClosed);m.open().catch(Le)}m._state.dbReadyPromise.then(_,C)}).then(u)},ct.prototype.use=function(u){var m=u.stack,_=u.create,C=u.level,S=u.name;return S&&this.unuse({stack:m,name:S}),u=this._middlewares[m]||(this._middlewares[m]=[]),u.push({stack:m,create:_,level:C??10,name:S}),u.sort(function($,M){return $.level-M.level}),this},ct.prototype.unuse=function(u){var m=u.stack,_=u.name,C=u.create;return m&&this._middlewares[m]&&(this._middlewares[m]=this._middlewares[m].filter(function(S){return C?S.create!==C:!!_&&S.name!==_})),this},ct.prototype.open=function(){var u=this;return pi(As,function(){return B$(u)})},ct.prototype._close=function(){var u=this._state,m=cr.indexOf(this);if(0<=m&&cr.splice(m,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}u.isBeingOpened||(u.dbReadyPromise=new ge(function(_){u.dbReadyResolve=_}),u.openCanceller=new ge(function(_,C){u.cancelOpen=C}))},ct.prototype.close=function(_){var m=(_===void 0?{disableAutoOpen:!0}:_).disableAutoOpen,_=this._state;m?(_.isBeingOpened&&_.cancelOpen(new G.DatabaseClosed),this._close(),_.autoOpen=!1,_.dbOpenError=new G.DatabaseClosed):(this._close(),_.autoOpen=this._options.autoOpen||_.isBeingOpened,_.openComplete=!1,_.dbOpenError=null)},ct.prototype.delete=function(u){var m=this;u===void 0&&(u={disableAutoOpen:!0});var _=0<arguments.length&&typeof arguments[0]!="object",C=this._state;return new ge(function(S,$){function M(){m.close(u);var E=m._deps.indexedDB.deleteDatabase(m.name);E.onsuccess=at(function(){var L,F,H;L=m._deps,F=m.name,H=L.indexedDB,L=L.IDBKeyRange,Rf(H)||F===vc||Lf(H,L).delete(F).catch(Le),S()}),E.onerror=Un($),E.onblocked=m._fireOnBlocked}if(_)throw new G.InvalidArgument("Invalid closeOptions argument to db.delete()");C.isBeingOpened?C.dbReadyPromise.then(M):M()})},ct.prototype.backendDB=function(){return this.idbdb},ct.prototype.isOpen=function(){return this.idbdb!==null},ct.prototype.hasBeenClosed=function(){var u=this._state.dbOpenError;return u&&u.name==="DatabaseClosed"},ct.prototype.hasFailed=function(){return this._state.dbOpenError!==null},ct.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(ct.prototype,"tables",{get:function(){var u=this;return o(this._allTables).map(function(m){return u._allTables[m]})},enumerable:!1,configurable:!0}),ct.prototype.transaction=function(){var u=(function(m,_,C){var S=arguments.length;if(S<2)throw new G.InvalidArgument("Too few arguments");for(var $=new Array(S-1);--S;)$[S-1]=arguments[S];return C=$.pop(),[m,ye($),C]}).apply(this,arguments);return this._transaction.apply(this,u)},ct.prototype._transaction=function(u,m,_){var C=this,S=ke.trans;S&&S.db===this&&u.indexOf("!")===-1||(S=null);var $,M,E=u.indexOf("?")!==-1;u=u.replace("!","").replace("?","");try{if(M=m.map(function(F){if(F=F instanceof C.Table?F.name:F,typeof F!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return F}),u=="r"||u===xf)$=xf;else{if(u!="rw"&&u!=kf)throw new G.InvalidArgument("Invalid transaction mode: "+u);$=kf}if(S){if(S.mode===xf&&$===kf){if(!E)throw new G.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");S=null}S&&M.forEach(function(F){if(S&&S.storeNames.indexOf(F)===-1){if(!E)throw new G.SubTransaction("Table "+F+" not included in parent transaction.");S=null}}),E&&S&&!S.active&&(S=null)}}catch(F){return S?S._promise(null,function(H,P){P(F)}):lt(F)}var L=(function F(H,P,W,R,j){return ge.resolve().then(function(){var V=ke.transless||ke,B=H._createTransaction(P,W,H._dbSchema,R);if(B.explicit=!0,V={trans:B,transless:V},R)B.idbtrans=R.idbtrans;else try{B.create(),B.idbtrans._explicit=!0,H._state.PR1398_maxLoop=3}catch(J){return J.name===jn.InvalidState&&H.isOpen()&&0<--H._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),H.close({disableAutoOpen:!1}),H.open().then(function(){return F(H,P,W,null,j)})):lt(J)}var q,Y=Ue(j);return Y&&lr(),V=ge.follow(function(){var J;(q=j.call(B,B))&&(Y?(J=Ls.bind(null,null),q.then(J,J)):typeof q.next=="function"&&typeof q.throw=="function"&&(q=Uf(q)))},V),(q&&typeof q.then=="function"?ge.resolve(q).then(function(J){return B.active?J:lt(new G.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):V.then(function(){return q})).then(function(J){return R&&B._resolve(),B._completion.then(function(){return J})}).catch(function(J){return B._reject(J),lt(J)})})}).bind(null,this,$,M,S,_);return S?S._promise($,L,"lock"):ke.trans?pi(ke.transless,function(){return C._whenReady(L)}):this._whenReady(L)},ct.prototype.table=function(u){if(!d(this._allTables,u))throw new G.InvalidTable("Table ".concat(u," does not exist"));return this._allTables[u]},ct);function ct(u,m){var _=this;this._middlewares={},this.verno=0;var C=ct.dependencies;this._options=m=n({addons:ct.addons,autoOpen:!0,indexedDB:C.indexedDB,IDBKeyRange:C.IDBKeyRange,cache:"cloned"},m),this._deps={indexedDB:m.indexedDB,IDBKeyRange:m.IDBKeyRange},C=m.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var S,$,M,E,L,F={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:Le,dbReadyPromise:null,cancelOpen:Le,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:m.autoOpen};F.dbReadyPromise=new ge(function(P){F.dbReadyResolve=P}),F.openCanceller=new ge(function(P,W){F.cancelOpen=W}),this._state=F,this.name=u,this.on=Io(this,"populate","blocked","versionchange","close",{ready:[pf,Le]}),this.on.ready.subscribe=D(this.on.ready.subscribe,function(P){return function(W,R){ct.vip(function(){var j,V=_._state;V.openComplete?(V.dbOpenError||ge.resolve().then(W),R&&P(W)):V.onReadyBeingFired?(V.onReadyBeingFired.push(W),R&&P(W)):(P(W),j=_,R||P(function B(){j.on.ready.unsubscribe(W),j.on.ready.unsubscribe(B)}))})}}),this.Collection=(S=this,Mo(I$.prototype,function(q,B){this.db=S;var R=gb,j=null;if(B)try{R=B()}catch(Y){j=Y}var V=q._ctx,B=V.table,q=B.hook.reading.fire;this._ctx={table:B,index:V.index,isPrimKey:!V.index||B.schema.primKey.keyPath&&V.index===B.schema.primKey.name,range:R,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:j,or:V.or,valueMapper:q!==it?q:null}})),this.Table=($=this,Mo(bb.prototype,function(P,W,R){this.db=$,this._tx=R,this.name=P,this.schema=W,this.hook=$._allTables[P]?$._allTables[P].hook:Io(null,{creating:[ir,Le],reading:[Bt,it],updating:[C$,Le],deleting:[rr,Le]})})),this.Transaction=(M=this,Mo(E$.prototype,function(P,W,R,j,V){var B=this;this.db=M,this.mode=P,this.storeNames=W,this.schema=R,this.chromeTransactionDurability=j,this.idbtrans=null,this.on=Io(this,"complete","error","abort"),this.parent=V||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new ge(function(q,Y){B._resolve=q,B._reject=Y}),this._completion.then(function(){B.active=!1,B.on.complete.fire()},function(q){var Y=B.active;return B.active=!1,B.on.error.fire(q),B.parent?B.parent._reject(q):Y&&B.idbtrans&&B.idbtrans.abort(),lt(q)})})),this.Version=(E=this,Mo(O$.prototype,function(P){this.db=E,this._cfg={version:P,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(L=this,Mo(Sb.prototype,function(P,W,R){if(this.db=L,this._ctx={table:P,index:W===":id"?null:W,or:R},this._cmp=this._ascending=Ge,this._descending=function(j,V){return Ge(V,j)},this._max=function(j,V){return 0<Ge(j,V)?j:V},this._min=function(j,V){return Ge(j,V)<0?j:V},this._IDBKeyRange=L._deps.IDBKeyRange,!this._IDBKeyRange)throw new G.MissingAPI})),this.on("versionchange",function(P){0<P.newVersion?console.warn("Another connection wants to upgrade database '".concat(_.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(_.name,"'. Closing db now to resume the delete request.")),_.close({disableAutoOpen:!1})}),this.on("blocked",function(P){!P.newVersion||P.newVersion<P.oldVersion?console.warn("Dexie.delete('".concat(_.name,"') was blocked")):console.warn("Upgrade '".concat(_.name,"' blocked by other connection holding version ").concat(P.oldVersion/10))}),this._maxKey=Po(m.IDBKeyRange),this._createTransaction=function(P,W,R,j){return new _.Transaction(P,W,R,_._options.chromeTransactionDurability,j)},this._fireOnBlocked=function(P){_.on("blocked").fire(P),cr.filter(function(W){return W.name===_.name&&W!==_&&!W._state.vcFired}).map(function(W){return W.on("versionchange").fire(P)})},this.use(U$),this.use(q$),this.use(V$),this.use(j$),this.use(H$);var H=new Proxy(this,{get:function(P,W,R){if(W==="_vip")return!0;if(W==="table")return function(V){return Ac(_.table(V),H)};var j=Reflect.get(P,W,R);return j instanceof bb?Ac(j,H):W==="tables"?j.map(function(V){return Ac(V,H)}):W==="_createTransaction"?function(){return Ac(j.apply(this,arguments),H)}:j}});this.vip=H,C.forEach(function(P){return P(_)})}var Pc,cn=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",G$=(qf.prototype.subscribe=function(u,m,_){return this._subscribe(u&&typeof u!="function"?u:{next:u,error:m,complete:_})},qf.prototype[cn]=function(){return this},qf);function qf(u){this._subscribe=u}try{Pc={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch{Pc={indexedDB:null,IDBKeyRange:null}}function Bb(u){var m,_=!1,C=new G$(function(S){var $=Ue(u),M,E=!1,L={},F={},H={get closed(){return E},unsubscribe:function(){E||(E=!0,M&&M.abort(),P&&Fs.storagemutated.unsubscribe(R))}};S.start&&S.start(H);var P=!1,W=function(){return Cf(j)},R=function(V){Mc(L,V),Of(F,L)&&W()},j=function(){var V,B,q;!E&&Pc.indexedDB&&(L={},V={},M&&M.abort(),M=new AbortController,q=function(Y){var J=or();try{$&&lr();var ee=Ps(u,Y);return ee=$?ee.finally(Ls):ee}finally{J&&ar()}}(B={subscr:V,signal:M.signal,requery:W,querier:u,trans:null}),Promise.resolve(q).then(function(Y){_=!0,m=Y,E||B.signal.aborted||(L={},function(J){for(var ee in J)if(d(J,ee))return;return 1}(F=V)||P||(Fs(Ao,R),P=!0),Cf(function(){return!E&&S.next&&S.next(Y)}))},function(Y){_=!1,["DatabaseClosedError","AbortError"].includes(Y==null?void 0:Y.name)||E||Cf(function(){E||S.error&&S.error(Y)})}))};return setTimeout(W,0),H});return C.hasValue=function(){return _},C.getValue=function(){return m},C}var vi=ds;function Gf(u){var m=Os;try{Os=!0,Fs.storagemutated.fire(u),Hf(u,!0)}finally{Os=m}}f(vi,n(n({},Te),{delete:function(u){return new vi(u,{addons:[]}).delete()},exists:function(u){return new vi(u,{addons:[]}).open().then(function(m){return m.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(u){try{return m=vi.dependencies,_=m.indexedDB,m=m.IDBKeyRange,(Rf(_)?Promise.resolve(_.databases()).then(function(C){return C.map(function(S){return S.name}).filter(function(S){return S!==vc})}):Lf(_,m).toCollection().primaryKeys()).then(u)}catch{return lt(new G.MissingAPI)}var m,_},defineClass:function(){return function(u){l(this,u)}},ignoreTransaction:function(u){return ke.trans?pi(ke.transless,u):u()},vip:zf,async:function(u){return function(){try{var m=Uf(u.apply(this,arguments));return m&&typeof m.then=="function"?m:ge.resolve(m)}catch(_){return lt(_)}}},spawn:function(u,m,_){try{var C=Uf(u.apply(_,m||[]));return C&&typeof C.then=="function"?C:ge.resolve(C)}catch(S){return lt(S)}},currentTransaction:{get:function(){return ke.trans||null}},waitFor:function(u,m){return m=ge.resolve(typeof u=="function"?vi.ignoreTransaction(u):u).timeout(m||6e4),ke.trans?ke.trans.waitFor(m):m},Promise:ge,debug:{get:function(){return Hn},set:function(u){cb(u)}},derive:b,extend:l,props:f,override:D,Events:Io,on:Fs,liveQuery:Bb,extendObservabilitySet:Mc,getByKeyPath:z,setByKeyPath:O,delByKeyPath:function(u,m){typeof m=="string"?O(u,m,void 0):"length"in m&&[].map.call(m,function(_){O(u,_,void 0)})},shallowClone:K,deepClone:xe,getObjectDiff:Vf,cmp:Ge,asap:A,minKey:-1/0,addons:[],connections:cr,errnames:jn,dependencies:Pc,cache:yi,semVer:"4.0.11",version:"4.0.11".split(".").map(function(u){return parseInt(u)}).reduce(function(u,m,_){return u+m/Math.pow(10,2*_)})})),vi.maxKey=Po(vi.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Fs(Ao,function(u){Os||(u=new CustomEvent(Df,{detail:u}),Os=!0,dispatchEvent(u),Os=!1)}),addEventListener(Df,function(u){u=u.detail,Os||Gf(u)}));var ur,Os=!1,jb=function(){};return typeof BroadcastChannel<"u"&&((jb=function(){(ur=new BroadcastChannel(Df)).onmessage=function(u){return u.data&&Gf(u.data)}})(),typeof ur.unref=="function"&&ur.unref(),Fs(Ao,function(u){Os||ur.postMessage(u)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(u){if(!ds.disableBfCache&&u.persisted){Hn&&console.debug("Dexie: handling persisted pagehide"),ur!=null&&ur.close();for(var m=0,_=cr;m<_.length;m++)_[m].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(u){!ds.disableBfCache&&u.persisted&&(Hn&&console.debug("Dexie: handling persisted pageshow"),jb(),Gf({all:new Et(-1/0,[[]])}))})),ge.rejectionMapper=function(u,m){return!u||u instanceof Ct||u instanceof TypeError||u instanceof SyntaxError||!u.name||!he[u.name]?u:(m=new he[u.name](m||u.message,u),"stack"in u&&y(m,"stack",{get:function(){return this.inner.stack}}),m)},cb(Hn),n(ds,Object.freeze({__proto__:null,Dexie:ds,liveQuery:Bb,Entity:yb,cmp:Ge,PropModification:No,replacePrefix:function(u,m){return new No({replacePrefix:[u,m]})},add:function(u){return new No({add:u})},remove:function(u){return new No({remove:u})},default:ds,RangeSet:Et,mergeRanges:zo,rangesOverlap:Mb}),{default:ds}),ds})})(ug);var h0=ug.exports;const Jh=c0(h0),fg=Symbol.for("Dexie"),Ys=globalThis[fg]||(globalThis[fg]=Jh);if(Jh.semVer!==Ys.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${Jh.semVer} and ${Ys.semVer}`);const{liveQuery:d0,mergeRanges:u0,rangesOverlap:f0,RangeSet:p0,cmp:m0,Entity:g0,PropModification:y0,replacePrefix:v0,add:_0,remove:b0}=Ys,w0=Object.freeze(Object.defineProperty({__proto__:null,Dexie:Ys,Entity:g0,PropModification:y0,RangeSet:p0,add:_0,cmp:m0,default:Ys,liveQuery:d0,mergeRanges:u0,rangesOverlap:f0,remove:b0,replacePrefix:v0},Symbol.toStringTag,{value:"Module"}));class is{}is.TABLE={name:"cache",schema:"++id, type, key, data, createTime, updateTime, [type+key]",version:1},is.DEFAULT_TYPE="cache";const pg=Object.freeze(Object.defineProperty({__proto__:null,CacheData:is},Symbol.toStringTag,{value:"Module"})),C0=Object.values(pg).reduce((i,e)=>Math.max(e.TABLE.version,i),1),x0=Object.values(pg).reduce((i,{TABLE:e})=>(i[e.name]=e.schema,i),{});class mg extends Ys{constructor(e="DataHub"){super(e),this.version(C0).stores(x0),this.cache.mapToClass(is)}async getCache(e,t=is.DEFAULT_TYPE){return this.cache.where("[type+key]").equals([t,e]).first()}async getCacheData(e,t=is.DEFAULT_TYPE){const n=await this.getCache(e,t);return n==null?void 0:n.data}async limitSize(e=is.DEFAULT_TYPE,t=1e3){let n=await this.cache.where("type").equals(e).count();for(;n>=t;){const s=await this.cache.where("type").equals(e).first();if(!s)break;await this.cache.delete(s.id),n=await this.cache.where("type").equals(e).count()}}async setCacheData(e,t,n,s=is.DEFAULT_TYPE){if(t===null)return this.deleteCacheData(e,s);const r=await this.getCache(e,s);return n=n||Date.now(),r?(await this.cache.update(r.id,{data:t,updateTime:n}),r.id):await this.cache.add({key:e,data:t,type:s,createTime:n,updateTime:n})}async deleteCacheData(e,t=is.DEFAULT_TYPE){return typeof e=="number"?this.cache.delete(e):this.cache.where("[type+key]").equals([t,e]).delete()}async getPageData(e,t,n){const{currentModule:s,currentMethod:r}=window.config;return this.getCacheData(e,`PAGE_${t||s}_${n||r}`)}setPageData(e,t,n,s){const{currentModule:r,currentMethod:o}=window.config;return this.setCacheData(e,t,void 0,`PAGE_${n||r}_${s||o}`)}}Object.defineProperty(window.$,"db",{get(){var i;if(!this._db){try{window.parent!==window&&(this._db=window.parent.$.db)}catch{}this._db||(this._db=new mg(`zentao_${((i=window.config)==null?void 0:i.account)||""}`))}return this._db}});const k0=Ys;class Xh extends ve{}Xh.NAME="Avatar",Xh.Component=ts,st(VC);const tI="",nI="",sI="",iI="";class Qh extends ve{}Qh.NAME="BtnGroup",Qh.Component=un,st(Object.freeze(Object.defineProperty({__proto__:null,BtnGroup:un},Symbol.toStringTag,{value:"Module"})));const oI="";be.addLang({zh_cn:{today:"今天",yearFormat:"{0}年",weekNames:["日","一","二","三","四","五","六"],monthNames:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},zh_tw:{today:"今天",yearFormat:"{0}年",weekNames:["日","一","二","三","四","五","六"],monthNames:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},en:{today:"Today",yearFormat:"{0}",weekNames:["SUN","MON","TUE","WED","THU","FRI","SAT"],monthNames:["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."]}});const S0={defaultCategoryName:"默认",weekNamesFull:["周日","周一","周二","周三","周四","周五","周六"],moreItems:"还有 {0} 项…"},T0={defaultCategoryName:"預設",weekNamesFull:["週日","週一","週二","週三","週四","週五","週六"],moreItems:"還有 {0} 項…"},$0={defaultCategoryName:"Default",weekNamesFull:["SUN","MON","TUE","WED","THU","FRI","SAT"],moreItems:"+{0} more…"};be.addLang({zh_cn:S0,zh_tw:T0,en:$0});class D0 extends re{constructor(){super(...arguments),this._getNavItems=e=>{const{monthFormat:t="yyyy-MM",dateFormat:n="yyyy-MM-dd",date:s}=e,r=Ye(s,!0),o=new Date;r.setHours(0,0,0,0),o.setHours(0,0,0,0);const a=sa(r,-1,"month"),l=sa(r,1,"month");return[{hint:Ze(o,n),text:be.getLang("today"),command:`.~switchDate/${o.getTime()}`,btnType:Nn(r,o)?"gray-pale":"primary-pale"},{hint:Ze(a,t),text:"",textClass:"chevron-left",command:`.~switchDate/${a.getTime()}`},{type:"text",text:Ze(r,t)},{hint:Ze(l,t),text:"",textClass:"chevron-right",command:`.~switchDate/${l.getTime()}`}]}}render(e){const{title:t,actions:n,navProps:s,btnSize:r="sm"}=e,o=this._getNavItems(e);return k("div",{className:"calendar-header",children:[t?k(de,{content:t,className:"calendar-header-title"},"title"):null,k(Fe,{className:"calendar-header-nav",btnType:"primary-pale",size:r,gap:2,items:o,...s},"nav"),n?Fe.render(n,[],{key:"actions",className:"calendar-header-actions",gap:2,size:r,btnType:"default"},this):null]})}}const gg=(i,e)=>{const t=new Map,n=[];for(const s of i){const r=t.get(s.id);if(r)v.extend(!0,r,s,r.events&&s.events?{events:ed([...r.events,...s.events])}:{});else{const o=v.extend(!0,{},s);o.order===void 0&&(o.order=n.length),t.set(s.id,o),n.push(o)}}return e!==void 0&&(t.get(e)||n.push({order:0,id:e,name:be.getLang("defaultCategoryName")})),n.sort((s,r)=>s.order-r.order),n},ed=(i,e)=>{const t=new Map,n=[];for(const s of i){if(s.start===void 0)continue;typeof s.start!="number"&&(s.start=dn(s.start)),s.end!==void 0&&typeof s.end!="number"&&(s.end=dn(s.end));const r=t.get(s.id);if(r)v.extend(!0,r,s);else{const o=v.extend(!0,{},s);o.order===void 0&&(o.order=n.length),e!==void 0&&o.category===void 0&&(o.category=e),t.set(s.id,o),n.push(o)}}return n.sort((s,r)=>{let o=(s.allDay?0:1)-(r.allDay?0:1);return o!==0||(o=s.start-r.start,o!==0)?o:s.order-r.order}),n},I0=(i,e,t=0)=>{const n=new Date(i,e-1,1),s=n.getDay(),r=new Date(i,e,0),o=n.getTime()-(7+s-t)%7*Qn;return{days:r.getDate(),startTime:o,firstDay:n.getTime()}};class M0 extends re{constructor(){super(...arguments),this._showAll$=fe(!1),this._getItems=e=>{const{events:t,categoriesMap:n,maxEventCount:s,eventRender:r}=e,o=[];let a=0;const l=this._showAll$.value;for(const c of t){if(c.hidden)continue;const h=n.get(c.category??"")||{};if(h.hidden)continue;if(s&&o.length>=s&&!l){a++;continue}const d=c.color??h.color,f=c.background??h.background,p=c.allDay?"":Ze(c.start,"hh:mm"),y={type:"item",key:c.id,text:c.title,hint:`${h.name?`[${h.name}]`:""}${c.allDay?"":p} ${c.title}`,icon:c.icon??h.icon??"calendar-event-dot",leading:c.allDay?null:k("span",{className:"calendar-event-list-item-time",children:p}),className:["calendar-event-list-item",f?"has-bg":""],style:d||f?{"--calendar-event-color":d,"--calendar-event-background":f}:void 0,multiline:!1,url:`#!.~clickEvent/${c.id}/$.event`};if(r){const b=r.call(this,c,h,y);if(b===!1)continue;b&&v.extend(y,b)}o.push(y)}return a&&!l&&o.push({type:"item",key:"more",textClass:"text-gray",text:be.getLang("moreItems",[a]),className:"calendar-event-list-item-more state",onClick:()=>this._showAll$.value=!0}),o}}render(e){return k(ht,{items:this._getItems(e),className:e.className})}}class N0 extends re{_renderHeader(e){const t=be.getLang("weekNamesFull"),n=[];for(let s=0;s<7;s++){const r=(e+s)%7;n.push(k("div",{className:U("calendar-month-view-col calendar-month-view-header-col",{"is-weekend":r===0||r===6}),children:k("div",{class:"calendar-month-view-week-name",children:t?t[r]:r})},s))}return k("div",{className:"calendar-month-view-row calendar-month-view-header",children:n})}_renderDay(e,t,n,s,r,o,a){const l=new Date(e),c=l.getDate(),h=Ze(l,o),d=t.get(h)||[],f=l.getDay(),p=kr(l,s),y=U("calendar-month-view-col calendar-month-view-day",{"is-first":c===1,"is-in-month":p,"is-out-month":!p,"is-today":Nn(l,r),"is-weekend":f===0||f===6});return k("div",{className:y,"z-date":h,"zui-command":`.~clickDay/${h}`,children:[k("div",{className:"calendar-month-view-day-head",title:h,children:[c===1&&a?k("span",{class:"calendar-month-view-month-name",children:a[l.getMonth()]}):null,k("span",{class:"calendar-month-view-day-number",children:l.getDate()})]}),k(M0,{className:"calendar-month-view-day-events",events:d,categoriesMap:n,maxEventCount:this.props.maxEventCount,eventRender:this.props.eventRender})]},h)}_renderRows(e,t,n,s){const{dateFormat:r="yyyy-MM-dd",events:o=[],categories:a=[]}=s,{startTime:l,days:c,firstDay:h}=I0(e,t,n),d=h+c*Qn,f=[],p=be.getLang("monthNames"),y=new Date,b=new Map;for(const T of o){const D=Ze(T.start,r);b.set(D,[...b.get(D)||[],T])}const w=new Map;for(const T of a)w.set(T.id,T);let x=l;for(;x<=d;){const T=[];for(let D=0;D<7;D++)T.push(this._renderDay(x,b,w,h,y,r,p)),x+=Qn;f.push(k("div",{className:"calendar-month-view-row calendar-month-view-week",children:T},x))}return f}render(e){const{weekStart:t=1,date:n}=e,s=Ye(n,!0),r=s.getFullYear(),o=s.getMonth()+1;return k("div",{className:"calendar-view calendar-month-view",children:[this._renderHeader(t),this._renderRows(r,o,t,e)]},`${r}-${o}`)}}let td=class extends Er{constructor(){super(...arguments),this._categories$=Ce(()=>gg([...this.props.categories||[],...this.signals.modifidCategories.value],this.defaultCategoryID)),this._events$=Ce(()=>ed([...this.props.events||[],...this.categories.reduce((e,t)=>[...e,...t.events||[]],[]),...this.signals.modifiedEvents.value],this.defaultCategoryID)),this._dateEffect=_t(()=>{var n;const{date:e,mode:t}=this;(n=this.props.onSwitchDate)==null||n.call(this,Ye(e),t)})}get defaultCategoryID(){return this.props.defaultCategory??"DEFAULT"}get date(){return this.signals.date.value}get mode(){return this.signals.mode.value}get readonly(){return this.state.readonly}get categories$(){return this._categories$}get categories(){return this._categories$.value}get events$(){return this._events$}get events(){return this._events$.value}getDefaultState(e){return{date:dn(e.date),mode:e.view||"month",readonly:e.readonly??!1,modifidCategories:[],modifiedEvents:[]}}switchDate(e){this.changeState({date:dn(e)})}modifyEvents(e){this.changeState({modifiedEvents:ed([...e,...this.signals.modifiedEvents.value])})}modifyCategories(e){this.changeState({modifidCategories:gg([...e,...this.signals.modifidCategories.value])})}clickEvent(e,t){var r;const n=this.getEvent(e);if(!n)return;const s=this.getCategory(n.category??"");(r=this.props.onClickEvent)==null||r.call(this,n,s,t)}getEvent(e){return this.events.find(t=>String(t.id)===String(e))}getCategory(e){return this.categories.find(t=>String(t.id)===String(e))}componentWillUnmount(){this._dateEffect(),super.componentWillUnmount()}_renderHeader(e){const{headerTitle:t,headerActions:n,headerProps:s,monthFormat:r,dateFormat:o}=e;return k(D0,{title:t,actions:n,date:this.date,monthFormat:r,dateFormat:o,...s},"header")}_renderBody(e){const{mode:t,date:n,categories:s,events:r}=this;return k("div",{className:"calendar-body","z-mode":t,"z-date":n,children:k(N0,{date:n,categories:s,events:r,weekStart:e.weekStart,maxEventCount:e.maxEventCount,eventRender:e.eventRender})},"body")}_getChildren(e){return[this._renderHeader(e),this._renderBody(e)]}};td.NAME="Calendar",td.defaultProps={commands:{},maxEventCount:5};class Ra extends ve{}Ra.NAME="Calendar",Ra.Component=td,Ra.register();const aI="",lI="",cI="",hI="",yg=Symbol("EVENT_PICK");class za extends re{constructor(e){super(e),this._handleClick=this._handleClick.bind(this),this._hasInput=!!v(`#${e.id}`).length}get hasInput(){return this._hasInput}_handleClick(e){const{togglePop:t,clickType:n,onClick:s}=this.props;let r=n==="open"?!0:void 0;const o=v(e.target),a=s==null?void 0:s(e);if(!e.defaultPrevented){if(typeof a=="boolean")r=a;else{if(o.closest('[data-dismiss="pick"]').length){t(!1);return}if(o.closest("a,input").length)return}requestAnimationFrame(()=>t(r))}}_getClass(e){const{state:t,className:n,disabled:s,readonly:r,pickerName:o,empty:a}=e,{open:l}=t;return U("pick",n,o?`${o}-pick`:"",l&&"is-open focus",s&&"disabled",r&&"readonly",a?"is-empty-value":"")}_getProps(e){const{id:t,style:n,attrs:s}=e;return{id:`pick-${t}`,className:this._getClass(e),style:n,tabIndex:-1,onClick:this._handleClick,...s}}_renderTrigger(e){const{children:t,state:n}=e;return t??n.value}_renderValue(e){const{name:t,state:{value:n=""},disabled:s,readonly:r,id:o,onRenderValue:a}=e;if(a)return a.call(this,n,e);if(t)if(this._hasInput)v(`#${o}`).val(n);else return k("input",{id:o,type:"hidden",className:"pick-value",name:t,value:n,readonly:r,disabled:s});return null}componentDidMount(){const{id:e}=this.props;v(`#${e}`).on(`change.zui.pick.${e} syncValue.zui.pick.${e}`,(t,n)=>{if(typeof n=="symbol")return;const s=v.isPlainObject(n)&&typeof n.setValue=="string"?n.setValue:t.target.value;this._skipTriggerChange=s,this.props.changeState({value:s})})}componentWillUnmount(){const{id:e}=this.props;v(`#${e}`).off(`change.zui.pick.${e}`)}componentDidUpdate(e){const{id:t,state:n,name:s}=this.props;s&&e.state.value!==n.value&&(this._skipTriggerChange!==n.value&&v(`#${t}`).trigger("change",yg),this._skipTriggerChange=!1)}render(e){return g(e.tagName||"div",this._getProps(e),this._renderTrigger(e),this._renderValue(e))}}const bs=Math.min,Kt=Math.max,Fa=Math.round,Oa=Math.floor,Rn=i=>({x:i,y:i}),E0={left:"right",right:"left",bottom:"top",top:"bottom"},A0={start:"end",end:"start"};function nd(i,e,t){return Kt(i,bs(e,t))}function Ri(i,e){return typeof i=="function"?i(e):i}function ws(i){return i.split("-")[0]}function zi(i){return i.split("-")[1]}function vg(i){return i==="x"?"y":"x"}function sd(i){return i==="y"?"height":"width"}const P0=new Set(["top","bottom"]);function rs(i){return P0.has(ws(i))?"y":"x"}function id(i){return vg(rs(i))}function L0(i,e,t){t===void 0&&(t=!1);const n=zi(i),s=id(i),r=sd(s);let o=s==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(o=Ba(o)),[o,Ba(o)]}function R0(i){const e=Ba(i);return[rd(i),e,rd(e)]}function rd(i){return i.replace(/start|end/g,e=>A0[e])}const _g=["left","right"],bg=["right","left"],z0=["top","bottom"],F0=["bottom","top"];function O0(i,e,t){switch(i){case"top":case"bottom":return t?e?bg:_g:e?_g:bg;case"left":case"right":return e?z0:F0;default:return[]}}function B0(i,e,t,n){const s=zi(i);let r=O0(ws(i),t==="start",n);return s&&(r=r.map(o=>o+"-"+s),e&&(r=r.concat(r.map(rd)))),r}function Ba(i){return i.replace(/left|right|bottom|top/g,e=>E0[e])}function j0(i){return{top:0,right:0,bottom:0,left:0,...i}}function wg(i){return typeof i!="number"?j0(i):{top:i,right:i,bottom:i,left:i}}function ja(i){const{x:e,y:t,width:n,height:s}=i;return{width:n,height:s,top:t,left:e,right:e+n,bottom:t+s,x:e,y:t}}function Cg(i,e,t){let{reference:n,floating:s}=i;const r=rs(e),o=id(e),a=sd(o),l=ws(e),c=r==="y",h=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,f=n[a]/2-s[a]/2;let p;switch(l){case"top":p={x:h,y:n.y-s.height};break;case"bottom":p={x:h,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-s.width,y:d};break;default:p={x:n.x,y:n.y}}switch(zi(e)){case"start":p[o]-=f*(t&&c?-1:1);break;case"end":p[o]+=f*(t&&c?-1:1);break}return p}const H0=async(i,e,t)=>{const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o}=t,a=r.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:i,floating:e,strategy:s}),{x:h,y:d}=Cg(c,n,l),f=n,p={},y=0;for(let b=0;b<a.length;b++){const{name:w,fn:x}=a[b],{x:T,y:D,data:N,reset:A}=await x({x:h,y:d,initialPlacement:n,placement:f,strategy:s,middlewareData:p,rects:c,platform:o,elements:{reference:i,floating:e}});h=T??h,d=D??d,p={...p,[w]:{...p[w],...N}},A&&y<=50&&(y++,typeof A=="object"&&(A.placement&&(f=A.placement),A.rects&&(c=A.rects===!0?await o.getElementRects({reference:i,floating:e,strategy:s}):A.rects),{x:h,y:d}=Cg(c,f,l)),b=-1)}return{x:h,y:d,placement:f,strategy:s,middlewareData:p}};async function od(i,e){var t;e===void 0&&(e={});const{x:n,y:s,platform:r,rects:o,elements:a,strategy:l}=i,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Ri(e,i),y=wg(p),w=a[f?d==="floating"?"reference":"floating":d],x=ja(await r.getClippingRect({element:(t=await(r.isElement==null?void 0:r.isElement(w)))==null||t?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),T=d==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,D=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),N=await(r.isElement==null?void 0:r.isElement(D))?await(r.getScale==null?void 0:r.getScale(D))||{x:1,y:1}:{x:1,y:1},A=ja(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:T,offsetParent:D,strategy:l}):T);return{top:(x.top-A.top+y.top)/N.y,bottom:(A.bottom-x.bottom+y.bottom)/N.y,left:(x.left-A.left+y.left)/N.x,right:(A.right-x.right+y.right)/N.x}}const U0=i=>({name:"arrow",options:i,async fn(e){const{x:t,y:n,placement:s,rects:r,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:h=0}=Ri(i,e)||{};if(c==null)return{};const d=wg(h),f={x:t,y:n},p=id(s),y=sd(p),b=await o.getDimensions(c),w=p==="y",x=w?"top":"left",T=w?"bottom":"right",D=w?"clientHeight":"clientWidth",N=r.reference[y]+r.reference[p]-f[p]-r.floating[y],A=f[p]-r.reference[p],z=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let O=z?z[D]:0;(!O||!await(o.isElement==null?void 0:o.isElement(z)))&&(O=a.floating[D]||r.floating[y]);const K=N/2-A/2,Z=O/2-b[y]/2-1,ye=bs(d[x],Z),Q=bs(d[T],Z),ne=ye,xe=O-b[y]-Q,Me=O/2-b[y]/2+K,Re=nd(ne,Me,xe),je=!l.arrow&&zi(s)!=null&&Me!==Re&&r.reference[y]/2-(Me<ne?ye:Q)-b[y]/2<0,te=je?Me<ne?Me-ne:Me-xe:0;return{[p]:f[p]+te,data:{[p]:Re,centerOffset:Me-Re-te,...je&&{alignmentOffset:te}},reset:je}}}),V0=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(e){var t,n;const{placement:s,middlewareData:r,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:b=!0,...w}=Ri(i,e);if((t=r.arrow)!=null&&t.alignmentOffset)return{};const x=ws(s),T=rs(a),D=ws(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(c.floating)),A=f||(D||!b?[Ba(a)]:R0(a)),z=y!=="none";!f&&z&&A.push(...B0(a,b,y,N));const O=[a,...A],K=await od(e,w),Z=[];let ye=((n=r.flip)==null?void 0:n.overflows)||[];if(h&&Z.push(K[x]),d){const Me=L0(s,o,N);Z.push(K[Me[0]],K[Me[1]])}if(ye=[...ye,{placement:s,overflows:Z}],!Z.every(Me=>Me<=0)){var Q,ne;const Me=(((Q=r.flip)==null?void 0:Q.index)||0)+1,Re=O[Me];if(Re&&(!(d==="alignment"?T!==rs(Re):!1)||ye.every(X=>rs(X.placement)===T?X.overflows[0]>0:!0)))return{data:{index:Me,overflows:ye},reset:{placement:Re}};let je=(ne=ye.filter(te=>te.overflows[0]<=0).sort((te,X)=>te.overflows[1]-X.overflows[1])[0])==null?void 0:ne.placement;if(!je)switch(p){case"bestFit":{var xe;const te=(xe=ye.filter(X=>{if(z){const Ee=rs(X.placement);return Ee===T||Ee==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(Ee=>Ee>0).reduce((Ee,Ae)=>Ee+Ae,0)]).sort((X,Ee)=>X[1]-Ee[1])[0])==null?void 0:xe[0];te&&(je=te);break}case"initialPlacement":je=a;break}if(s!==je)return{reset:{placement:je}}}return{}}}},W0=new Set(["left","top"]);async function K0(i,e){const{placement:t,platform:n,elements:s}=i,r=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=ws(t),a=zi(t),l=rs(t)==="y",c=W0.has(o)?-1:1,h=r&&l?-1:1,d=Ri(e,i);let{mainAxis:f,crossAxis:p,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof y=="number"&&(p=a==="end"?y*-1:y),l?{x:p*h,y:f*c}:{x:f*c,y:p*h}}const q0=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(e){var t,n;const{x:s,y:r,placement:o,middlewareData:a}=e,l=await K0(e,i);return o===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:r+l.y,data:{...l,placement:o}}}}},G0=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(e){const{x:t,y:n,placement:s}=e,{mainAxis:r=!0,crossAxis:o=!1,limiter:a={fn:w=>{let{x,y:T}=w;return{x,y:T}}},...l}=Ri(i,e),c={x:t,y:n},h=await od(e,l),d=rs(ws(s)),f=vg(d);let p=c[f],y=c[d];if(r){const w=f==="y"?"top":"left",x=f==="y"?"bottom":"right",T=p+h[w],D=p-h[x];p=nd(T,p,D)}if(o){const w=d==="y"?"top":"left",x=d==="y"?"bottom":"right",T=y+h[w],D=y-h[x];y=nd(T,y,D)}const b=a.fn({...e,[f]:p,[d]:y});return{...b,data:{x:b.x-t,y:b.y-n,enabled:{[f]:r,[d]:o}}}}}},Z0=function(i){return i===void 0&&(i={}),{name:"size",options:i,async fn(e){var t,n;const{placement:s,rects:r,platform:o,elements:a}=e,{apply:l=()=>{},...c}=Ri(i,e),h=await od(e,c),d=ws(s),f=zi(s),p=rs(s)==="y",{width:y,height:b}=r.floating;let w,x;d==="top"||d==="bottom"?(w=d,x=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,w=f==="end"?"top":"bottom");const T=b-h.top-h.bottom,D=y-h.left-h.right,N=bs(b-h[w],T),A=bs(y-h[x],D),z=!e.middlewareData.shift;let O=N,K=A;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(K=D),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(O=T),z&&!f){const ye=Kt(h.left,0),Q=Kt(h.right,0),ne=Kt(h.top,0),xe=Kt(h.bottom,0);p?K=y-2*(ye!==0||Q!==0?ye+Q:Kt(h.left,h.right)):O=b-2*(ne!==0||xe!==0?ne+xe:Kt(h.top,h.bottom))}await l({...e,availableWidth:K,availableHeight:O});const Z=await o.getDimensions(a.floating);return y!==Z.width||b!==Z.height?{reset:{rects:!0}}:{}}}};function Ha(){return typeof window<"u"}function Fi(i){return xg(i)?(i.nodeName||"").toLowerCase():"#document"}function qt(i){var e;return(i==null||(e=i.ownerDocument)==null?void 0:e.defaultView)||window}function zn(i){var e;return(e=(xg(i)?i.ownerDocument:i.document)||window.document)==null?void 0:e.documentElement}function xg(i){return Ha()?i instanceof Node||i instanceof qt(i).Node:!1}function yn(i){return Ha()?i instanceof Element||i instanceof qt(i).Element:!1}function Fn(i){return Ha()?i instanceof HTMLElement||i instanceof qt(i).HTMLElement:!1}function kg(i){return!Ha()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof qt(i).ShadowRoot}const Y0=new Set(["inline","contents"]);function Vr(i){const{overflow:e,overflowX:t,overflowY:n,display:s}=vn(i);return/auto|scroll|overlay|hidden|clip/.test(e+n+t)&&!Y0.has(s)}const J0=new Set(["table","td","th"]);function X0(i){return J0.has(Fi(i))}const Q0=[":popover-open",":modal"];function Ua(i){return Q0.some(e=>{try{return i.matches(e)}catch{return!1}})}const ex=["transform","translate","scale","rotate","perspective"],tx=["transform","translate","scale","rotate","perspective","filter"],nx=["paint","layout","strict","content"];function ad(i){const e=ld(),t=yn(i)?vn(i):i;return ex.some(n=>t[n]?t[n]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||tx.some(n=>(t.willChange||"").includes(n))||nx.some(n=>(t.contain||"").includes(n))}function sx(i){let e=Cs(i);for(;Fn(e)&&!Oi(e);){if(ad(e))return e;if(Ua(e))return null;e=Cs(e)}return null}function ld(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ix=new Set(["html","body","#document"]);function Oi(i){return ix.has(Fi(i))}function vn(i){return qt(i).getComputedStyle(i)}function Va(i){return yn(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function Cs(i){if(Fi(i)==="html")return i;const e=i.assignedSlot||i.parentNode||kg(i)&&i.host||zn(i);return kg(e)?e.host:e}function Sg(i){const e=Cs(i);return Oi(e)?i.ownerDocument?i.ownerDocument.body:i.body:Fn(e)&&Vr(e)?e:Sg(e)}function Wr(i,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=Sg(i),r=s===((n=i.ownerDocument)==null?void 0:n.body),o=qt(s);if(r){const a=cd(o);return e.concat(o,o.visualViewport||[],Vr(s)?s:[],a&&t?Wr(a):[])}return e.concat(s,Wr(s,[],t))}function cd(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function Tg(i){const e=vn(i);let t=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=Fn(i),r=s?i.offsetWidth:t,o=s?i.offsetHeight:n,a=Fa(t)!==r||Fa(n)!==o;return a&&(t=r,n=o),{width:t,height:n,$:a}}function hd(i){return yn(i)?i:i.contextElement}function Bi(i){const e=hd(i);if(!Fn(e))return Rn(1);const t=e.getBoundingClientRect(),{width:n,height:s,$:r}=Tg(e);let o=(r?Fa(t.width):t.width)/n,a=(r?Fa(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const rx=Rn(0);function $g(i){const e=qt(i);return!ld()||!e.visualViewport?rx:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ox(i,e,t){return e===void 0&&(e=!1),!t||e&&t!==qt(i)?!1:e}function Js(i,e,t,n){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=i.getBoundingClientRect(),r=hd(i);let o=Rn(1);e&&(n?yn(n)&&(o=Bi(n)):o=Bi(i));const a=ox(r,t,n)?$g(r):Rn(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,h=s.width/o.x,d=s.height/o.y;if(r){const f=qt(r),p=n&&yn(n)?qt(n):n;let y=f,b=cd(y);for(;b&&n&&p!==y;){const w=Bi(b),x=b.getBoundingClientRect(),T=vn(b),D=x.left+(b.clientLeft+parseFloat(T.paddingLeft))*w.x,N=x.top+(b.clientTop+parseFloat(T.paddingTop))*w.y;l*=w.x,c*=w.y,h*=w.x,d*=w.y,l+=D,c+=N,y=qt(b),b=cd(y)}}return ja({width:h,height:d,x:l,y:c})}function Wa(i,e){const t=Va(i).scrollLeft;return e?e.left+t:Js(zn(i)).left+t}function Dg(i,e){const t=i.getBoundingClientRect(),n=t.left+e.scrollLeft-Wa(i,t),s=t.top+e.scrollTop;return{x:n,y:s}}function ax(i){let{elements:e,rect:t,offsetParent:n,strategy:s}=i;const r=s==="fixed",o=zn(n),a=e?Ua(e.floating):!1;if(n===o||a&&r)return t;let l={scrollLeft:0,scrollTop:0},c=Rn(1);const h=Rn(0),d=Fn(n);if((d||!d&&!r)&&((Fi(n)!=="body"||Vr(o))&&(l=Va(n)),Fn(n))){const p=Js(n);c=Bi(n),h.x=p.x+n.clientLeft,h.y=p.y+n.clientTop}const f=o&&!d&&!r?Dg(o,l):Rn(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+h.x+f.x,y:t.y*c.y-l.scrollTop*c.y+h.y+f.y}}function lx(i){return Array.from(i.getClientRects())}function cx(i){const e=zn(i),t=Va(i),n=i.ownerDocument.body,s=Kt(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=Kt(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+Wa(i);const a=-t.scrollTop;return vn(n).direction==="rtl"&&(o+=Kt(e.clientWidth,n.clientWidth)-s),{width:s,height:r,x:o,y:a}}const Ig=25;function hx(i,e){const t=qt(i),n=zn(i),s=t.visualViewport;let r=n.clientWidth,o=n.clientHeight,a=0,l=0;if(s){r=s.width,o=s.height;const h=ld();(!h||h&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=Wa(n);if(c<=0){const h=n.ownerDocument,d=h.body,f=getComputedStyle(d),p=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,y=Math.abs(n.clientWidth-d.clientWidth-p);y<=Ig&&(r-=y)}else c<=Ig&&(r+=c);return{width:r,height:o,x:a,y:l}}const dx=new Set(["absolute","fixed"]);function ux(i,e){const t=Js(i,!0,e==="fixed"),n=t.top+i.clientTop,s=t.left+i.clientLeft,r=Fn(i)?Bi(i):Rn(1),o=i.clientWidth*r.x,a=i.clientHeight*r.y,l=s*r.x,c=n*r.y;return{width:o,height:a,x:l,y:c}}function Mg(i,e,t){let n;if(e==="viewport")n=hx(i,t);else if(e==="document")n=cx(zn(i));else if(yn(e))n=ux(e,t);else{const s=$g(i);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ja(n)}function Ng(i,e){const t=Cs(i);return t===e||!yn(t)||Oi(t)?!1:vn(t).position==="fixed"||Ng(t,e)}function fx(i,e){const t=e.get(i);if(t)return t;let n=Wr(i,[],!1).filter(a=>yn(a)&&Fi(a)!=="body"),s=null;const r=vn(i).position==="fixed";let o=r?Cs(i):i;for(;yn(o)&&!Oi(o);){const a=vn(o),l=ad(o);!l&&a.position==="fixed"&&(s=null),(r?!l&&!s:!l&&a.position==="static"&&!!s&&dx.has(s.position)||Vr(o)&&!l&&Ng(i,o))?n=n.filter(h=>h!==o):s=a,o=Cs(o)}return e.set(i,n),n}function px(i){let{element:e,boundary:t,rootBoundary:n,strategy:s}=i;const o=[...t==="clippingAncestors"?Ua(e)?[]:fx(e,this._c):[].concat(t),n],a=o[0],l=o.reduce((c,h)=>{const d=Mg(e,h,s);return c.top=Kt(d.top,c.top),c.right=bs(d.right,c.right),c.bottom=bs(d.bottom,c.bottom),c.left=Kt(d.left,c.left),c},Mg(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function mx(i){const{width:e,height:t}=Tg(i);return{width:e,height:t}}function gx(i,e,t){const n=Fn(e),s=zn(e),r=t==="fixed",o=Js(i,!0,r,e);let a={scrollLeft:0,scrollTop:0};const l=Rn(0);function c(){l.x=Wa(s)}if(n||!n&&!r)if((Fi(e)!=="body"||Vr(s))&&(a=Va(e)),n){const p=Js(e,!0,r,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else s&&c();r&&!n&&s&&c();const h=s&&!n&&!r?Dg(s,a):Rn(0),d=o.left+a.scrollLeft-l.x-h.x,f=o.top+a.scrollTop-l.y-h.y;return{x:d,y:f,width:o.width,height:o.height}}function dd(i){return vn(i).position==="static"}function Eg(i,e){if(!Fn(i)||vn(i).position==="fixed")return null;if(e)return e(i);let t=i.offsetParent;return zn(i)===t&&(t=t.ownerDocument.body),t}function Ag(i,e){const t=qt(i);if(Ua(i))return t;if(!Fn(i)){let s=Cs(i);for(;s&&!Oi(s);){if(yn(s)&&!dd(s))return s;s=Cs(s)}return t}let n=Eg(i,e);for(;n&&X0(n)&&dd(n);)n=Eg(n,e);return n&&Oi(n)&&dd(n)&&!ad(n)?t:n||sx(i)||t}const yx=async function(i){const e=this.getOffsetParent||Ag,t=this.getDimensions,n=await t(i.floating);return{reference:gx(i.reference,await e(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function vx(i){return vn(i).direction==="rtl"}const _x={convertOffsetParentRelativeRectToViewportRelativeRect:ax,getDocumentElement:zn,getClippingRect:px,getOffsetParent:Ag,getElementRects:yx,getClientRects:lx,getDimensions:mx,getScale:Bi,isElement:yn,isRTL:vx};function Pg(i,e){return i.x===e.x&&i.y===e.y&&i.width===e.width&&i.height===e.height}function bx(i,e){let t=null,n;const s=zn(i);function r(){var a;clearTimeout(n),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),r();const c=i.getBoundingClientRect(),{left:h,top:d,width:f,height:p}=c;if(a||e(),!f||!p)return;const y=Oa(d),b=Oa(s.clientWidth-(h+f)),w=Oa(s.clientHeight-(d+p)),x=Oa(h),D={rootMargin:-y+"px "+-b+"px "+-w+"px "+-x+"px",threshold:Kt(0,bs(1,l))||1};let N=!0;function A(z){const O=z[0].intersectionRatio;if(O!==l){if(!N)return o();O?o(!1,O):n=setTimeout(()=>{o(!1,1e-7)},1e3)}O===1&&!Pg(c,i.getBoundingClientRect())&&o(),N=!1}try{t=new IntersectionObserver(A,{...D,root:s.ownerDocument})}catch{t=new IntersectionObserver(A,D)}t.observe(i)}return o(!0),r}function Lg(i,e,t,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,c=hd(i),h=s||r?[...c?Wr(c):[],...Wr(e)]:[];h.forEach(x=>{s&&x.addEventListener("scroll",t,{passive:!0}),r&&x.addEventListener("resize",t)});const d=c&&a?bx(c,t):null;let f=-1,p=null;o&&(p=new ResizeObserver(x=>{let[T]=x;T&&T.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var D;(D=p)==null||D.observe(e)})),t()}),c&&!l&&p.observe(c),p.observe(e));let y,b=l?Js(i):null;l&&w();function w(){const x=Js(i);b&&!Pg(b,x)&&t(),b=x,y=requestAnimationFrame(w)}return t(),()=>{var x;h.forEach(T=>{s&&T.removeEventListener("scroll",t),r&&T.removeEventListener("resize",t)}),d==null||d(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(y)}}const ud=q0,fd=G0,pd=V0,Rg=Z0,wx=U0,md=(i,e,t)=>{const n=new Map,s={platform:_x,...t},r={...s.platform,_c:n};return H0(i,e,{...s,platform:r})};class gd extends re{constructor(e){super(e),this._ref=pe(),this._handleDocClick=t=>{const{state:{open:n},id:s,togglePop:r}=this.props,o=v(t.target);n!=="closing"&&!o.closest(`#pick-${s},#pick-pop-${s}`).length&&o.parent().length&&r(!1)},this._handleClick=this._handleClick.bind(this)}get trigger(){return v(`#pick-${this.props.id}`)[0]}get element(){var e;return(e=this._ref)==null?void 0:e.current}get container(){return this._container}_handleClick(e){const{togglePop:t,onClickItem:n,state:s}=this.props,r=v(e.target),o=r.closest("[data-pick-value]");if(n&&n(e,s.value),o.length)return e.stopPropagation(),t(!1,{value:`${o.dataset("pickValue")}`});if(r.closest('[data-dismiss="pick"]').length)return t(!1)}_getClass(e){const{className:t,state:n,pickerName:s,empty:r}=e,{open:o}=n;return U("pick-pop",s?`${s}-pick-pop`:"",t,o===!0&&"in",r?"is-empty-value":"")}_getProps(e){const{id:t,style:n,maxHeight:s,maxWidth:r,minHeight:o,minWidth:a}=e,l=v.extend({maxHeight:s,maxWidth:r,minHeight:o,minWidth:a},n);return{id:`pick-pop-${t}`,className:this._getClass(e),style:l,ref:this._ref,onClick:this._handleClick}}_getContainer(e){if(!this._container){const t=v(e.container||"body");let n=t.find(".pick-container");n.length||(n=v("<div>").addClass("pick-container").appendTo(t)),this._container=n[0]}return this._container}_renderHeader(e){const{header:t}=e;return t?k(de,{component:"header",className:"pick-pop-header",content:t},"header"):null}_renderFooter(e){const{footer:t}=e;return t?k(de,{component:"footer",className:"pick-pop-footer",content:t},"footer"):null}_render(e){return k("div",{...this._getProps(e),children:[this._renderHeader(e),this._renderPop(e),this._renderFooter(e)]})}_renderPop(e){return e.children}_getStyle(e={},t){var c;const n=(c=this.trigger)==null?void 0:c.getBoundingClientRect();if(!n)return{};const{width:s,minWidth:r,maxWidth:o,maxHeight:a}=this.props,l=n.width;if(typeof s=="function"?e.width=s():s==="100%"?e.width=l:s&&(e.width=Be(s)),r==="100%"&&(e.minWidth=l),o==="100%"&&(e.maxWidth=l),this.props.limitInScreen&&t&&(!a||a==="auto"||typeof a=="number")){let h;if(t.includes("bottom"))h=window.innerHeight-n.bottom-2;else{const d=this.element.getBoundingClientRect().height;h=n.top,d>h&&typeof e.top=="number"&&(e.top+=d-h)}h&&(e.maxHeight=typeof a=="number"?Math.min(h,a):h)}else a&&(e.maxHeight=a);return e}layout(){const{element:e,trigger:t,props:n}=this,{state:s}=n;if(!e||!t||!s.open){this._layoutWatcher&&(this._layoutWatcher(),this._layoutWatcher=void 0);return}this._layoutWatcher||(this._layoutWatcher=Lg(t,e,()=>{const{placement:r,width:o,noFlipAfterShow:a}=n,l=this._lastPlacement;md(t,e,{placement:a&&l?l:!r||r==="auto"?"bottom-start":r,middleware:[r==="auto"&&(!a||!l)?pd():null,fd(),ud(1)].filter(Boolean)}).then(({x:c,y:h,placement:d})=>{var f,p;if(En(t)||!Mr(t,{checkZeroSize:!0})){v(e).css({display:"none"});return}v(e).css(this._getStyle({left:c,top:h},d)),(p=(f=this.props).onLayout)==null||p.call(f,e),l||(this._lastPlacement=d)}),o==="100%"&&v(e).css(this._getStyle())}))}componentDidMount(){var e,t;this.layout(),v(document).on("click",this._handleDocClick),(t=(e=this.props).afterRender)==null||t.call(e,{firstRender:!0})}componentDidUpdate(){var e,t;(t=(e=this.props).afterRender)==null||t.call(e,{firstRender:!1})}componentWillUnmount(){var t,n;v(document).off("click",this._handleDocClick);const e=this._layoutWatcher;e&&(e(),this._layoutWatcher=void 0),this._container=void 0,this._ref=void 0,v(`#pick-pop-${this.props.id}`).remove(),(n=(t=this.props).beforeDestroy)==null||n.call(t)}render(e){return Wm(this._render(e),this._getContainer(e))}}const dI="";let ot=class extends re{constructor(e){super(e),this._toggleTimer=0,this._pop=pe(),this._trigger=pe(),this.toggle=async(t,n)=>{(this.props.disabled||this.props.readonly)&&(t=!1);const{state:s}=this;if(typeof t=="boolean"&&t===(!!s.open&&s.open!=="closing"))return n&&await this.changeState(n),this.state;this._toggleTimer&&(clearTimeout(this._toggleTimer),this._toggleTimer=0);let r=await this.changeState(a=>(t=t??!a.open,{open:t?"opening":"closing",...n}));const{open:o}=r;return o==="closing"?(await Dn(200,a=>{this._toggleTimer=a}),this._toggleTimer=0,r=await this.changeState({open:!1})):o==="opening"&&(await Dn(50,a=>{this._toggleTimer=a}),this._toggleTimer=0,r=await this.changeState({open:!0})),r},this._id=e.id??`_pick${Xe()}`,this.changeState=this.changeState.bind(this),this.state=this.getDefaultState(e)}get id(){return this._id}get pop(){return this._pop.current}get trigger(){return this._trigger.current}get value(){return this.props.value??this.state.value}getDefaultState(e){const{value:t,defaultValue:n=""}=e||this.props;return{value:String(t??n),open:!1}}resetState(e,t){const n=this.getDefaultState(e);t?this.state=n:this.changeState(n)}changeState(e,t){return new Promise(n=>{this.setState(e,()=>{t==null||t(),n(this.state)})})}open(e){return this.toggle(!0,e)}close(e){return this.toggle(!1,e)}_getTriggerProps(e,t){return{id:this.id,ref:this._trigger,state:t,className:e.className,pickerName:e.pickerName,style:e.style,name:e.name,tagName:e.tagName,attrs:e.attrs,disabled:e.disabled,readonly:e.readonly,clickType:e.clickType,onRenderValue:e.onRenderValue,onClick:e.onClick,changeState:this.changeState,togglePop:this.toggle}}_getPopProps(e,t){return{id:this.id,state:t,className:e.popClass,pickerName:e.pickerName,style:e.popStyle,disabled:e.disabled,readonly:e.readonly,changeState:this.changeState,togglePop:this.toggle,placement:e.popPlacement,container:e.popContainer,width:e.popWidth,height:e.popHeight,minHeight:e.popMinHeight,maxHeight:e.popMaxHeight,maxWidth:e.popMaxWidth,minWidth:e.popMinWidth,limitInScreen:e.limitPopInScreen,onClickItem:e.onClickItem,header:e.popHeader,footer:e.popFooter}}_renderTrigger(e,t){return null}_renderPop(e,t){return null}_afterRender(e=!1){var t;(t=this.props.afterRender)==null||t.call(this,{firstRender:e})}_getPop(e){return e.Pop||this.constructor.Pop}_getTrigger(e){return e.Trigger||this.constructor.Trigger}_isEmptyValue(){const{value:e}=this.state;return e==null||e===""}_handleChange(e,t){const{onChange:n}=this.props;n&&n.call(this,e,t)}_handlePopToggle(e){const{onPopShown:t,onPopHidden:n}=this.props;e===!0&&t?t.call(this):!e&&n&&n.call(this)}async setValue(e,t){typeof e!="string"&&(e=String(e));const{beforeChange:n}=this.props;if(n){const s=await n.call(this,e,this.state.value);if(s===!1)return;typeof s=="string"&&(e=s)}if(t){const s=this._trigger.current;s&&(s._skipTriggerChange=e)}return this.changeState({value:e})}componentDidMount(){this._afterRender(!0);const{value:e,defaultValue:t}=this.props,n=e??t??"",s=this.state.value;n!==s&&this._handleChange(s,n)}componentWillUpdate(e,t){const{open:n}=this.state,{open:s}=t;if(!n==!s)return;const{onPopShow:r,onPopHide:o}=this.props;s&&r?r.call(this):!s&&o&&o.call(this)}componentDidUpdate(e,t){if(e.value!==this.props.value&&this.props.value!==void 0){this.setValue(this.props.value);return}const{open:n,value:s}=this.state,{open:r,value:o}=t;!!n!=!!r&&this._handlePopToggle(!!n),s!==o&&this._handleChange(s,o),this._afterRender()}componentWillUnmount(){var t;(t=this.props.beforeDestroy)==null||t.call(this),this._toggleTimer&&clearTimeout(this._toggleTimer);const e=this._pop.current;e&&e.componentWillUnmount&&e.componentWillUnmount()}render(e,t){const{open:n}=t,s=this._getTrigger(e);let r;if(n&&(!e.hidePopWhenEmpty||!this._isEmptyValue())){const o=this._getPop(e);r=k(o,{ref:this._pop,...this._getPopProps(e,t),children:this._renderPop(e,t)},"pop")}return[k(s,{...this._getTriggerProps(e,t),children:this._renderTrigger(e,t)},"pick"),r]}};ot.Trigger=za,ot.Pop=gd,ot.defaultProps={popContainer:"body",popClass:"popup",popWidth:"100%",popPlacement:"auto",popMinWidth:50,popMinHeight:32,popMaxHeight:300,limitPopInScreen:!0,clickType:"open"};let zg=class extends ot{getDefaultState(e){const t=super.getDefaultState(e);return t.value===void 0&&(e||this.props).required&&(t.value=this.getColors()[0]),t}getColors(){const{colors:e}=this.props;return typeof e=="string"?e.split(","):e||[]}componentDidMount(){this.syncColor()}syncColor(){const{syncBackground:e,syncBorder:t,syncColor:n,syncValue:s}=this.props,r=this.state.value||"";if(e&&v(e).css("backgroundColor",r),t&&v(t).css("borderColor",r),n&&v(n).css("color",r),s){const o=v(s);o.is("input,textarea,select")?o.val(r):o.text(r)}}_handleChange(e,t){this.props.disabled||(super._handleChange(e||"",t||""),this.syncColor())}_renderTrigger(e,t){const{icon:n,hint:s=""}=e,{value:r}=t;return[n?k($e,{icon:n,title:s},"icon"):k("span",{class:"color-picker-item bg-current ring ring-gray ring-inset",style:{background:r},title:s})]}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return n.style=v.extend({color:t.value},n.style),n.className=U("color-picker",n.className,{disabled:e.disabled}),n}_renderPop(e,t){const{closeBtn:n,heading:s}=e,r=this.getColors(),{value:o}=t;let a;return s&&(a=k("div",{className:"color-picker-heading",children:[s,n?k("button",{className:"btn ghost square rounded size-sm","data-dismiss":"pick",children:k("span",{class:"close"})}):null]},"heading")),[a,k("div",{className:"color-picker-row",children:[r.map(l=>k("button",{className:"btn color-picker-item",style:{backgroundColor:l},"data-pick-value":l,children:o===l?k($e,{icon:"check"}):null},l)),k("button",{className:"btn color-picker-item","data-pick-value":"",children:k($e,{className:"text-fore",icon:"trash"})})]},"row")]}};zg.defaultProps={...ot.defaultProps,className:"rounded btn square size-sm ghost",popClass:"color-picker-pop popup",colors:["#ef4444","#f97316","#eab308","#84cc16","#22c55e","#14b8a6","#0ea5e9","#6366f1","#a855f7","#d946ef","#ec4899"],closeBtn:!0,popWidth:"auto",popMinWidth:184};class xs extends ve{}xs.NAME="ColorPicker",xs.Component=zg,xs.register();const uI="";let Cx=class extends re{render(e){const{id:t,popup:n,title:s,content:r,style:o,className:a,closeBtn:l,arrow:c,headingClass:h,titleClass:d,contentClass:f,arrowStyle:p,onlyInner:y,footer:b,footerClass:w}=e;let x=k(de,{content:r},"content");(f||s)&&(x=k("div",{className:f,children:x},"content"));let T=k(de,{content:b},"footer");(w||s)&&(T=k("div",{className:w,children:T},"footer"));const D=[],N=l?k("button",{className:"btn ghost square size-sm btn-close","data-dismiss":"popover",children:k("span",{className:"close"})}):null;return s?D.push(k("div",{className:h,children:[s?k(de,{className:d,content:s}):null,N]},"heading")):D.push(N),D.push(x,T),c&&D.push(k("div",{className:typeof c=="string"?c:"arrow",style:p},"arrow")),y?D:k("div",{id:t,className:U("popover",a,{popup:n,"has-heading":s}),style:o,children:D})}};class Ka extends ve{}Ka.NAME="PopoverPanel",Ka.Component=Cx;const Fg="show",Og="in",ji=class Zb extends qe{constructor(){super(...arguments),this._lastTriggerAttr="",this._handlePanelInited=()=>{this.layout()},this._getClickBounding=()=>{const e=this._triggerEvent;return{x:e.clientX,y:e.clientY,left:e.clientX,top:e.clientY,width:0,height:0,bottom:e.clientY,right:e.clientX}}}get shown(){return this._shown}get id(){return this._id}get zIndex(){return this._zIndex}get trigger(){return this._triggerElement}get target(){return this._targetElement}afterInit(){const{trigger:e,id:t,triggerEvent:n}=this.options;this._triggerEvent=n,this._id=t||`popover_${this.gid}`;const s=this.getTriggerElement();if(s instanceof HTMLElement){const o=v(s),{namespace:a}=this;if(e){const l=()=>{const c=o.attr(`zui-toggle-${this.constructor.ZUI}`)??"";if(c&&this._lastTriggerAttr===c)return;this._lastTriggerAttr=c;let h=o.dataset();if(c){const d=Yn(c);let f=d.$options;typeof f=="function"&&(f=f.call(this,this.element,d)),h=v.extend(h,d,f||{})}this.setOptions(h)};e==="hover"?o.on(`mouseenter${a}`,c=>{o.is("[disabled],.disabled")||(l(),this._clearDelayHide(),this.shown||this.show({delay:!0,event:c}))}).on(`mouseleave${a}`,()=>{this.delayHide()}):o.on(`${e}${a}`,c=>{o.is("[disabled],.disabled")||(this.shown||l(),this.toggle({event:c,delay:!0}),c.preventDefault())})}}const{show:r}=this.options;r&&this.show({delay:typeof r=="number"?r:!1})}getTriggerElement(){if(!this._triggerElement){let{element:e=this.element}=this.options;e===document.body&&(e={getBoundingClientRect:this._getClickBounding}),this._triggerElement=e,this._virtual=!(e instanceof HTMLElement)}return this._triggerElement}initTarget(){let e=this.options.target;return this._dynamic=!e,e?(typeof e=="function"&&(e=e()),typeof e=="string"&&(e==="$next"?e=v(this._triggerElement).next():e.startsWith("$target:")&&(e=v(this._triggerElement).closest(e.slice(8)))),v(e)[0]):this._createTarget()}show(e){const{delay:t,event:n,hideOthers:s=this.options.hideOthers}=e||{};if(n&&(this._triggerEvent=n),t)return this._resetTimer(()=>{this.show()},t===!0?this.options.delay:t);if(!this.inited){this.setOptions({show:!0});return}if(this._shown)return;const r=this.initTarget();if(!r)return;this._targetElement=r;const o=v(r),{animation:a,onShow:l,onShown:c,trigger:h,elementShowClass:d}=this.options;if((l==null?void 0:l.call(this))===!1)return;const{SHOWN_POPOVERS:p}=this.constructor;o.addClass(Fg),a&&o.addClass(a===!0?"fade":a),this._zIndex=Zb.Z_INDEX++,this._shown=!0,this.render(),p.set(this.gid,this),this.emit("show"),s&&p.forEach(b=>{b!==this&&b.hide()});const{namespace:y}=this;h==="hover"&&(this._clearDelayHide(),o.off(y).on(`mouseenter${y}`,()=>{this._clearDelayHide()}).on(`mouseleave${y}`,()=>{this.delayHide()})),this._virtual||(o.attr("zui-commands-proxy","").data("zui.commandProxy",this._triggerElement),d&&v(this._triggerElement).addClass(d)),this._resetTimer(()=>{o.addClass(Og),this._resetTimer(()=>{c==null||c.call(this),this.emit("shown")},200)},50)}hide(e){(!this._shown||!this._targetElement)&&this._resetTimer();const{destroyOnHide:t,animation:n,onHide:s,onHidden:r,trigger:o,hideNewOnHide:a,elementShowClass:l}=this.options,c=v(this._targetElement),{SHOWN_POPOVERS:h}=this.constructor;if((s==null?void 0:s.call(this))!==!1){if(this._shown=!1,h.delete(this.gid),this.emit("hide"),c.removeClass(Og),o==="hover"&&(this._clearDelayHide(),c.off(this.namespace)),!this._virtual){const f=v(this._triggerElement);f.removeAttr("zui-commands-proxy").removeData("zui.commandProxy"),l&&f.removeClass(l).removeAttr("data-pop-placement")}a&&h.forEach(f=>{f!==this&&f.zIndex>this.zIndex&&f.options.trigger!=="hover"&&f.hide()}),this._resetTimer(()=>{r==null||r.call(this),this.emit("hidden"),c.removeClass(Fg),(t||e)&&this._resetTimer(()=>{this.destroy()},!e&&typeof t=="number"?t:0),this._destoryTarget()},n&&!e?200:0)}}toggle(e){this._shown?this.hide():this.show(e)}destroy(){if(super.destroy(),!this._virtual){const{namespace:e}=this;v(this._triggerElement).off(e)}this.$element.hasClass("popover-tmp")&&this.$element.remove(),this._resetTimer(),this._destoryTarget(),this._clearDelayHide()}updateLayout(){if(this.destroyed||!this._shown)return;const e=this.getTriggerElement(),t=this._targetElement,{minWidth:n,minHeight:s,maxWidth:r,maxHeight:o}=this.options;if(!this._virtual){const a={minWidth:Be(n),minHeight:Be(s),maxWidth:Be(r),maxHeight:Be(o)},{width:l,height:c}=this.options;l&&(a.width=typeof l=="function"?l():l==="100%"?v(e).outerWidth():l),c&&(a.height=typeof c=="function"?c():c),Object.keys(a).length&&v(t).css(a)}this.updatePosition()}updatePosition(){const e=this.getTriggerElement(),t=this._targetElement,{animation:n,name:s="popover",limitInScreen:r,onLayout:o}=this.options;md(...this._getLayoutOptions()).then(({x:a,y:l,middlewareData:c,placement:h,strategy:d})=>{if(e instanceof HTMLElement&&En(e)){this.hide(!0);return}const f={position:d,left:a,top:l},p=v(t).css(f);r&&p.css({top:Math.max(0,Math.min(window.innerHeight-p.outerHeight(),l)),left:Math.max(0,Math.min(window.innerWidth-p.outerWidth(),a))});const y=h.split("-")[0],b={top:"bottom",right:"left",bottom:"top",left:"right"}[y],w=c.arrow;w&&p.attr("data-pop-placement",y).find(".arrow").css({left:w.x,top:w.y}).attr("class",`arrow ${s}-arrow arrow-${b}`),n===!0&&p.attr("class",`${p.attr("class").split(" ").filter(x=>x!=="fade"&&!x.startsWith("fade-from")).join(" ")} fade-from-${b}`),this._virtual||v(this._triggerElement).attr("data-pop-placement",y),o&&o.call(this,{target:t,trigger:e,popSide:y,arrowSide:b,x:a,y:l,placement:h,strategy:d})})}layout(){const e=this._triggerElement,t=this._targetElement,n=this._layoutWatcher;if(!t||!e||!this._shown){n&&(n(),this._layoutWatcher=void 0);return}n||(this._layoutWatcher=Lg(e,t,this.updateLayout.bind(this),{ancestorResize:!1}))}render(e){super.render(e);const t=this._targetElement;if(!t)return;const n=this._getRenderOptions(),s=v(t);if(s.z("popover",this.gid).toggleClass("popup",n.popup).css(n.style),n.className&&s.setClass(n.className),this._dynamic){let r=this._panel;r&&r.element!==t&&(r.destroy(),r=void 0),r?r.render(n):(r=new Ka(t,n),r.on("inited",this._handlePanelInited)),this._panel=r}else n.arrow&&(s.find(".arrow").length||s.append(v('<div class="arrow"></div>').css(n.arrowStyle))),this.layout()}handleClickOutside(e){if(this.options.mask){const t=this._triggerElement;t instanceof HTMLElement&&v(e.target).closest(t).length||this.hide()}}handleClickTarget(e){}delayHide(e=150){this._resetTimer(),this._clearDelayHide(),this._hideTimer=window.setTimeout(()=>{this._hideTimer=0,this.hide()},e)}_clearDelayHide(){this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=0)}_getLayoutOptions(){const e=this.getTriggerElement(),t=this._targetElement,{placement:n,flip:s,limitSize:r,shift:o,offset:a,arrow:l,strategy:c,maxHeight:h,maxWidth:d}=this.options,f=l?t.querySelector(".arrow"):null,p=f?typeof l=="number"?l:5:0,y=()=>typeof a=="function"?a:typeof a=="object"?{mainAxis:(a.mainAxis||0)+p,...a}:(a||0)+p;return[e,t,{placement:n,strategy:c,middleware:[s?pd():null,o?fd(typeof o=="object"?o:void 0):null,a||p?ud(y()):null,l?wx({element:f}):null,r?Rg({apply({availableWidth:b,availableHeight:w,placement:x}){let T=w-(["top","bottom"].includes(x.split("-")[0])?p:0)-2,D=b-2;h&&(T=Math.min(T,In(h)[0])),d&&(D=Math.min(D,In(d)[0])),v(t).css({maxHeight:T,maxWidth:D})}}):null].filter(Boolean)}]}_getRenderOptions(){const{name:e="popover"}=this.options,{popup:t,title:n,content:s,headingClass:r=`${e}-heading`,titleClass:o=`${e}-title`,contentClass:a=`${e}-content`,style:l,className:c=e,closeBtn:h,arrow:d,footer:f,footerClass:p=`${e}-footer`}=this.options;return{popup:t,title:n,titleClass:o,headingClass:r,contentClass:a,content:s,style:{zIndex:this._zIndex,...l},className:c,closeBtn:h,arrow:d?`arrow ${e}-arrow`:!1,arrowStyle:{"--arrow-size":`${typeof d=="number"?d:5}px`},onlyInner:!0,footer:f,footerClass:p}}_destoryTarget(){var e,t,n;(e=this._layoutWatcher)==null||e.call(this),this._layoutWatcher=void 0,this._dynamic&&((t=this._panel)==null||t.destroy(),(n=this._targetElement)==null||n.remove(),this._panel=void 0,this._targetElement=void 0)}_resetTimer(e,t=0){this._timer&&clearTimeout(this._timer),e&&(this._timer=window.setTimeout(()=>{this._timer=0,e()},t))}_createTarget(){const{container:e="body"}=this.options,t=v(e);let n=t.find(`#${this._id}`);return n.length||(n=v("<div />").attr({id:this._id,class:"popover"}).appendTo(t)),n[0]}static create(e,t){const{element:n,container:s="body",id:r=`popover_${Xe()}`}=e||{};return t=t||(n instanceof HTMLElement?n:void 0),t||(t=v(`<div id="${r}" class="popover-tmp"></div>`).appendTo(v(s))[0]),this.ensure(t,{id:r,destroyOnHide:!0,...e})}static show(e){const{element:t,event:n,...s}=e,r=t||(n==null?void 0:n.currentTarget);return this.create({element:r,show:!0,destroyOnHide:!0,triggerEvent:n,...s},r instanceof HTMLElement?r:document.body)}};ji.NAME="Popover",ji.Z_INDEX=1700,ji.MULTI_INSTANCE=!0,ji.DEFAULT={placement:"top",strategy:"absolute",flip:!0,arrow:!0,offset:1,trigger:"click",mask:!0,delay:0,animation:!0,closeBtn:!0,popup:!0,elementShowClass:"with-popover-show",hideNewOnHide:!0},ji.SHOWN_POPOVERS=new Map;let Gt=ji;Gt.toggle={trigger:["click","hover"],convertHref:{selector:"target"},check(i,e){const t=v(i);return t.data(this.KEY)?!1:e==="hover"?(t.dataset("trigger")||this.DEFAULT.trigger)==="hover":!0},getOptions(i,e,t){return{triggerEvent:t,...e}},onToggle(i,e,t){i.toggle({event:t})}},Gt.register(),v(()=>{v(document).on(`click.${Gt.NAMESPACE}`,i=>{const{SHOWN_POPOVERS:e}=Gt;if(!e.size)return;const t=v(i.target),n=t.closest("[z-popover]"),s=n.length?n.z("popover"):0,r=s?e.get(s):null;if(r){const a=r.options.name??r.constructor.ZUI;if(t.closest(`[data-dismiss="popover"],[data-dismiss="${a}"]`).length){r.hide();return}if(r.handleClickTarget(i))return}const o=[...e.values()].sort((a,l)=>l.zIndex-a.zIndex);for(const a of o)if(a!==r&&a.handleClickOutside(i))return})}),Object.assign(window,{Popover:Gt});const fI="";class Xs extends Gt{_getRenderOptions(){const{type:e,className:t,title:n,content:s}=this.options;let r=n,o=s;return o===void 0&&(o=r,r=void 0),{...super._getRenderOptions(),title:r,content:o,className:U("tooltip",e,t,r?"tooltip-has-title":""),contentClass:r?"tooltip-content":""}}}Xs.NAME="Tooltip",Xs.DEFAULT={...Gt.DEFAULT,trigger:"hover",delay:500,closeBtn:!1,popup:!1,name:"tooltip",animation:"fade",destroyOnHide:5e3,hideOthers:!0,hideNewOnHide:!1},Xs.register();const pI="",mI="",gI="";let Qs=class extends qe{constructor(){super(...arguments),this._timer=0,this._copying=!1}async getContent(){const{copy:e,target:t,onCopy:n}=this.options;let s=e;if(t&&s===void 0){const r=v(t);s={text:r.text(),html:r.html()}}if(n){const r=await n.call(this,s);r!==void 0&&(r instanceof v?s={text:r.text(),html:r.html()}:s=r)}return s}async copy(){if(this._copying)return;this._copying=!0,this._hideTip();const{onCopied:e,copyingClass:t}=this.options;t&&this.$element.addClass(t);const n=await this.getContent();if(n===!1||n===void 0){this._copying=!1;return}await kh(n),this._showTip(),e&&e.call(this),this._copying=!1}_showTip(){const{$element:e}=this,{mode:t,tooltipOptions:n,copiedText:s,duration:r,copiedIcon:o,overlayClass:a,copiedClass:l}=this.options;let c=s;if(c===void 0&&(c={zh_cn:"已复制",zh_tw:"已複製",en:"Copied"}[be.getCode()]??"Copied"),l&&e.addClass(l),t==="tooltip"){let h=this._tooltip;(!h||h.destroyed)&&(h=new Xs(this.$element,{trigger:"manual",type:"success",title:c,placement:"top",...n}),this._tooltip=h),h.show()}else a&&e.addClass(a),e.addClass("hide-children"),o&&e.append(`<i class="copied-overlay icon ${o.startsWith("icon-")?o:`icon-${o}`}" style="display:inline!important"></i>`),e.append(`<span class="copied-overlay text" style="display:inline!important">${c}</span>`);this._timer=window.setTimeout(()=>{this._hideTip()},r)}_hideTip(){var o;this._timer&&(clearTimeout(this._timer),this._timer=0);const{$element:e,options:t}=this,{copyingClass:n,copiedClass:s,overlayClass:r}=t;e.removeClass("hide-children"),e.children(".copied-overlay").remove(),[n,s,r].forEach(a=>{a&&e.removeClass(a)}),(o=this._tooltip)==null||o.hide()}destroy(){var e;this._hideTip(),(e=this._tooltip)==null||e.destroy()}};Qs.NAME="CopyBtn",Qs.DEFAULT={mode:"tooltip",duration:3e3,copiedClass:"is-copied",overlayClass:"success-pale",copyingClass:"is-copying"},Qs.toggle={trigger:"click",convertHref:{selector:"target"},onToggle(i){i.copy()}},Qs.register();const yI="";class Bg extends re{constructor(){super(...arguments),this._ref=pe(),this._handleClickItem=(e,t)=>{var n,s;(s=(n=this.props).onChange)==null||s.call(n,e,+t.item.key)}}componentDidMount(){setTimeout(()=>{v(this._ref.current).find(".menu-item>.active").scrollIntoView({container:".menu"})},100)}render(e){const{minuteStep:t=5,hour:n,minute:s}=e,r=[],o=[];for(let l=0;l<24;++l)r.push({key:String(l),text:l<10?`0${l}`:l,active:n===l});for(let l=0;l<60;l+=t)o.push({key:String(l),text:l<10?`0${l}`:l,active:s===l});const a="col w-10 max-h-full overflow-y-auto scrollbar-thin scrollbar-hover";return k("div",{className:"time-picker-menu row",ref:this._ref,children:[k(Rt,{className:a,items:r,onClickItem:this._handleClickItem.bind(this,"hour")}),k(Rt,{className:a,items:o,onClickItem:this._handleClickItem.bind(this,"minute")})]})}}const vI="",jg=i=>{if(!i)return;const e=Ye(`1999-01-01 ${i}`);if(!Number.isNaN(e.getDay()))return e};let qa=class extends ot{constructor(){super(...arguments),this._handleInputFocus=()=>{this.toggle(!0)},this._handleInputChange=e=>{this.setTime(e.target.value)},this._handleSetTime=(e,t)=>{this.setTime({[e]:String(t)})},this._handleClearBtnClick=()=>{this.setTime("")}}getDefaultState(e){const t=super.getDefaultState(e);return t.value==="now"&&(t.value=Ze(new Date,(e||this.props).format)),t}setTime(e,t){if(!t&&(this.props.disabled||this.props.readonly))return;let n="";if(typeof e=="string")n=e;else{const[c,h]=(this.state.value||"00:00").split(":"),{hour:d=+c,minute:f=+h}=e;n=`${d}:${f}`}const s=jg(n),{onInvalid:r,required:o,defaultValue:a,format:l}=this.props;return this.changeState({value:s?Ze(s,l):o?a:""},()=>{!s&&r&&r(n)})}setValue(e,t){if(t){const n=this._trigger.current;n&&(n._skipTriggerChange=e)}return this.setTime(e,!0)}getTime(){const e=jg(this.state.value);return e?[e.getHours(),e.getMinutes()]:null}_renderTrigger(e,t){const{placeholder:n,icon:s,required:r,disabled:o,readonly:a}=e,{value:l="",open:c}=t,h=`time-picker-${this.id}`;let d;return c&&!r&&l.length?d=k("button",{type:"button",className:"btn size-sm square ghost",onClick:this._handleClearBtnClick,children:k("span",{className:"close"})}):s&&(s===!0?d=k("i",{class:"i-time"}):d=k($e,{icon:s})),[k("input",{id:h,type:"text",className:"form-control",placeholder:n,value:l,disabled:o,readOnly:a,autoComplete:"off",onFocus:this._handleInputFocus,onChange:this._handleInputChange},"input"),d?k("label",{for:h,className:"input-control-suffix",children:d},"icon"):null]}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return{...n,className:U(n.className,"time-picker input-control has-suffix-icon")}}_renderPop(e){const[t,n]=this.getTime()||[];return k(Bg,{hour:t,minute:n,minuteStep:e.minuteStep,onChange:this._handleSetTime})}};qa.defaultProps={...ot.defaultProps,popWidth:"auto",popMaxHeight:320,minuteStep:5,format:"hh:mm",icon:!0};function xx(i,e,t){return e&&i<e?e:t&&i>t?t:i}function Kr(i){if(i==null)return null;if(typeof i=="function"&&(i=i()),typeof i=="string"&&i.startsWith("today")){const e=new Date;i.length>6?i=sa(e,i.substring(5).replace("+","")):i=e}else i=Ye(i);return Sr(i)?i:null}const kx=(i,e,t=0)=>{const n=new Date(i,e-1,1),s=n.getDay(),r=n.getTime()-(7+s-t)%7*Qn;return{days:7*5,startTime:r,firstDay:n.getTime()}},Hg=(i,e)=>new Set((Array.isArray(i)?i:[i]).map(t=>Ze(t,e)));class Sx extends re{constructor(){super(...arguments),this._handleClickDate=e=>{const{onClickDate:t}=this.props;if(!t)return;const n=v(e.target).closest(".mini-calendar-day").dataset("date");n&&t(n)}}render(e){var ye,Q;const t=new Date,{weekStart:n=1,weekNames:s=be.getLang("weekNames"),monthNames:r=be.getLang("monthNames"),year:o=t.getFullYear(),month:a=t.getMonth()+1,highlights:l=[],selections:c=[],maxDate:h,minDate:d,isAllowDate:f}=e,p=[],y="btn ghost square rounded-full";for(let ne=0;ne<7;ne++){const xe=(n+ne)%7;p.push(k("div",{className:U("col mini-calendar-day",{"is-weekend":xe===0||xe===6}),children:k("div",{children:s?s[xe]:xe})},ne))}const{startTime:b,days:w,firstDay:x}=kx(o,a,n),T=x+w*Qn;let D=b;const N=[],A="yyyy-MM-dd",z=Hg(l,A),O=Hg(c,A),K=((ye=h?Ye(h):null)==null?void 0:ye.getTime())??Number.MAX_SAFE_INTEGER,Z=((Q=d?Ye(d):null)==null?void 0:Q.getTime())??0;for(;D<=T;){const ne=[];for(let xe=0;xe<7;xe++){const Me=new Date(D);let Re=(f==null?void 0:f(Me))??!0;typeof Re=="boolean"&&(Re={allow:Re});const je=Me.getDate(),te=Ze(Me,A),X=Me.getDay(),Ee=kr(Me,x),Ae=U("col mini-calendar-day",{active:z.has(te),selected:O.has(te),"is-first":je===1,"is-in-month":Ee,"is-out-month":!Ee,"is-today":Nn(Me,t),"is-weekend":X===0||X===6,disabled:!Re.allow||(D>K||D<Z)&&!Nn(Me,K)&&!Nn(Me,Z)});ne.push(k("div",{className:Ae,"data-date":te,children:k("button",{type:"button",className:y,onClick:this._handleClickDate,title:Re.hint,children:je===1&&r?r[Me.getMonth()]:Me.getDate()})},te)),D+=Qn}N.push(k("div",{className:"row",children:ne},D))}return k("div",{className:"mini-calendar",children:[k("div",{className:"row",children:p},"header"),N]},`${o}-${a}`)}}class Ug extends re{constructor(){super(...arguments),this._ref=pe(),this._handleClickItem=e=>{const{onChange:t}=this.props;if(!t)return;const s=v(e.target).closest("[data-value]").dataset("value");s&&(t(+s),e.stopPropagation())}}render(e){const{className:t,max:n,min:s,value:r}=e,o=[],a=new Date().getFullYear();for(let l=s;l<=n;++l)o.push(k(we,{type:"ghost","data-value":l,active:l===r,className:U(a===l?"is-current":""),onClick:this._handleClickItem,children:l},l));return k("div",{className:t,ref:this._ref,children:o})}}class Tx extends re{constructor(e){super(e),this._ref=pe(),this._handleClick=s=>{const r=v(s.target).closest("[data-set-date]");r.length&&this.changeDate(r.dataset("set-date"))},this._switchToPrevMonth=()=>{const{year:s,month:r}=this.state;r===1?this.setState({year:s-1,month:12}):this.setState({month:r-1})},this._switchToNextMonth=()=>{const{year:s,month:r}=this.state;r===12?this.setState({year:s+1,month:1}):this.setState({month:r+1})},this._changeYear=s=>{this.setState({year:s,select:"day"})},this._changeMonth=s=>{this.setState({month:s,select:"day"})},this.changeDate=s=>{var r,o;(o=(r=this.props).onChange)==null||o.call(r,s)};const{date:t}=e,n=Kr(t)||new Date;this.state={select:"day",year:n.getFullYear(),month:n.getMonth()+1}}_renderMenu(e){return Rt.render(e.menu,[],{onClickItem:t=>{const n=t.item.value;typeof n=="string"&&this.changeDate(n)}},this)}_renderFooter(e){let{actions:t}=e;const{todayText:n=be.getLang("today"),clearText:s}=e;return t===void 0&&(t=[{text:n,"data-set-date":Ze(new Date,"yyyy-MM-dd")}]),Array.isArray(t)&&(t={items:t}),k("div",{className:"date-picker-menu-footer",children:[k(Fe,{btnProps:{className:"ghost text-primary"},...t}),s?k(we,{type:"ghost text-link","data-set-date":"",children:s}):null]})}_showSelect(e){this.setState(t=>t.select===e?{select:"day"}:{select:e})}render(e,t){const{date:n,yearText:s=be.getLang("yearFormat")||"{0}",weekNames:r=be.getLang("weekNames"),monthNames:o=be.getLang("monthNames"),minDate:a,maxDate:l,weekStart:c}=e,h=Kr(n),{year:d,month:f,select:p}=t,y=p==="day",b=a||Ye("1970-1-1"),w=l||Ye("2099-12-31");return k("div",{className:"date-picker-menu row",ref:this._ref,onClick:this._handleClick,children:[this._renderMenu(e),k("div",{className:"cell",style:"width: 312px",children:[k("div",{className:"row p-2",children:[k(we,{type:p==="year"?"primary-pale":"ghost",size:"sm",caret:!0,onClick:this._showSelect.bind(this,"year"),children:De(s,d)}),k(we,{type:p==="month"?"primary-pale":"ghost",size:"sm",caret:!0,onClick:this._showSelect.bind(this,"month"),children:o?o[f-1]:f}),k("div",{className:"flex-auto"}),y?k("div",{children:[k(we,{type:"ghost",size:"sm",square:!0,onClick:this._switchToPrevMonth,children:k("i",{className:"chevron-left"})}),k(we,{type:"ghost",size:"sm",square:!0,onClick:this._switchToNextMonth,children:k("i",{className:"chevron-right"})})]}):null]}),y?k(Sx,{weekStart:c,weekNames:r,monthNames:o,maxDate:w,minDate:b,year:d,month:f,selections:h||[],onClickDate:this.changeDate,isAllowDate:e.isAllowDate}):null,p==="year"?k(Ug,{className:"date-pick-menu-years overflow-y-auto scrollbar-hover scrollbar-thin",value:d,min:b.getFullYear(),max:w.getFullYear(),onChange:this._changeYear}):p==="month"?k(Ug,{className:"date-pick-menu-month overflow-y-auto scrollbar-hover scrollbar-thin",value:f,min:1,max:12,onChange:this._changeMonth}):null,y?this._renderFooter(e):null]})]})}}const _I="";let Hi=class extends ot{constructor(){super(...arguments),this.setDate=(e,t)=>{const{disabled:n,readonly:s}=this.props;if(!t&&(n||s))return;const r=this._calcValue(e);return this.changeState({value:r},()=>{this._afterSetDate()})},this._handleInputFocus=()=>{this.toggle(!0)},this._handleInputChange=e=>{this.setDate(e.target.value)},this._handleClearBtnClick=()=>{this.setDate("")},this._handleSetDate=e=>{this.setDate(e)}}getDefaultState(e){const t=super.getDefaultState(e);return{...t,value:this._calcValue(t.value)}}getDate(){return this._date}setValue(e,t){if(t){const n=this._trigger.current;n&&(n._skipTriggerChange=e)}return this.setDate(e,!0)}_calcValue(e){const{onInvalid:t,defaultValue:n="",required:s,allowInvalid:r,format:o}=this.props;let a=this._parseDate(e);if(!a&&t){const l=t(e);l&&(a=this._parseDate(l))}return this._date=a,a?Ze(a,o):r?e:s?n:""}_getDateRange(e){const{minDate:t,maxDate:n}=this.props;return[Kr(typeof t=="function"?t(e):t),Kr(typeof n=="function"?n(e):n)]}_parseDate(e){const t=Kr(e);return t&&this._isAllowDate(t)?xx(t,...this._getDateRange(e)):null}_afterSetDate(){this.toggle(!1)}_renderTrigger(e,t){const{placeholder:n,icon:s,required:r,disabled:o,readonly:a,display:l}=e,{value:c="",open:h}=t,d=`date-picker-${this.id}`;let f;h&&!r&&c.length?f=k("button",{type:"button",className:"btn size-sm square ghost",onClick:this._handleClearBtnClick,children:k("span",{className:"close"})}):s&&(s===!0?f=k("i",{class:"i-calendar"}):f=k($e,{icon:s}));const p=h?c:l?l(c,this._date):c;return[k("input",{id:d,type:"text",className:"form-control",placeholder:n,value:p,disabled:o,readOnly:a,autoComplete:"off",onFocus:this._handleInputFocus,onChange:this._handleInputChange},"input"),f?k("label",{for:d,className:"input-control-suffix",children:f},"icon"):null]}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return{...n,className:U(n.className,"date-picker input-control has-suffix-icon")}}_getPopProps(e,t){const n=super._getPopProps(e,t);return{...n,className:U(n.className,"popup")}}_isAllowDate(e){var n;const t=((n=this.props.isAllowDate)==null?void 0:n.call(this,e))??!0;return t===!0||typeof t=="object"&&t&&t.allow}_renderPop(e,t){const{weekNames:n,monthNames:s,weekStart:r,yearText:o,todayText:a,clearText:l,menu:c,actions:h,required:d,isAllowDate:f}=e,[p,y]=this._getDateRange(t.value);return k(Tx,{onChange:this._handleSetDate,date:this._date,weekNames:n,monthNames:s,weekStart:r,yearText:o,todayText:a,clearText:d?"":l,menu:c,actions:h,minDate:p,maxDate:y,isAllowDate:f?this._isAllowDate.bind(this):void 0})}};Hi.defaultProps={...ot.defaultProps,popWidth:"auto",popMaxHeight:320,format:"yyyy-MM-dd",icon:!0,limitPopInScreen:!1};let yd=class extends Hi{constructor(){super(...arguments),this._handleSetDate=e=>{const t=Ye(e),n=this.getDate()||new Date;t.setHours(n.getHours()),t.setMinutes(n.getMinutes()),this.setDate(Ze(t,this.props.format))},this._handleSetTime=(e,t)=>{const n=this.getDate()||new Date;e==="hour"?n.setHours(t):n.setMinutes(t),this.setDate(Ze(n,this.props.format))}}getTime(){const e=this.getDate();return e?[e.getHours(),e.getMinutes()]:null}_afterSetDate(){}_renderPop(e,t){const[n,s]=this.getTime()||[];return k("div",{className:"datetime-picker-menu row",children:[super._renderPop(e,t),k("div",{className:"divider"}),k(Bg,{hour:n,minute:s,minuteStep:e.minuteStep,onChange:this._handleSetTime})]})}};yd.defaultProps={...Hi.defaultProps,popMaxHeight:310,format:"yyyy-MM-dd hh:mm",minuteStep:5};class Ga extends ve{}Ga.NAME="TimePicker",Ga.Component=qa,Ga.register();class Za extends ve{}Za.NAME="DatePicker",Za.Component=Hi,Za.register();class Ya extends ve{}Ya.NAME="DatetimePicker",Ya.Component=yd,Ya.register();const bI="",Vg="show",vd="in",$x='[data-dismiss="modal"]',Ja="modal-hide",Ui=class bi extends qe{constructor(){super(...arguments),this._timer=0,this._handleClick=e=>{const t=e.target,n=t.closest(".modal");!n||n!==this.modalElement||(t.closest($x)||this.options.backdrop===!0&&t===n)&&(e.preventDefault(),this.hide())}}static get SELECTOR(){return".modal"}get modalElement(){return this.element}get shown(){return this._shown}get dialog(){return this.modalElement.querySelector(".modal-dialog")}get rob(){return this._rob}_observeResize(){var e;if(this.options.responsive&&typeof ResizeObserver<"u"){(e=this._rob)==null||e.disconnect();const{dialog:t}=this;if(t){const n=new ResizeObserver(()=>{if(!this._shown)return;const s=t.clientWidth,r=t.clientHeight,[o,a]=this._lastDialogSize||[];(o!==s||a!==r)&&(this._lastDialogSize=[s,r],this.layout())});n.observe(t),this._rob=n}}}_cancelObserver(){var e;(e=this._rob)==null||e.disconnect(),this._rob=void 0}afterInit(){this.on("click",this._handleClick),this.options.show&&(this.show(),this._observeResize()),this.on("hidden",e=>{const{modalElement:t}=this;if(!t.parentNode)return this.destroy();const n=e.target.closest(".modal")===t;n&&this._cancelObserver(),n&&!bi.getAll().some(s=>s.shown)&&v("html").enableScroll()}),this.on("show",e=>{const{modalElement:t}=this;if(!t.parentNode)return this.destroy();e.target.closest(".modal")===t&&(this._observeResize(),v("html").disableScroll())}),this.shown&&v("html").disableScroll()}destroy(){super.destroy(),this._cancelObserver()}show(e){var c;const{modalElement:t}=this,n=v(t);if(this._shown&&n.hasClass(vd))return n.removeClass(Ja).css("z-index",`${bi.zIndex++}`),!1;this._shown=!0,this.setOptions(e);const{animation:s,backdrop:r,className:o,style:a}=this.options;n.setClass({"modal-trans":s,"modal-no-backdrop":!r,[Ja]:!1},Vg,o).css({zIndex:`${bi.zIndex++}`,...a});const l=this.constructor;return l.hideOthers&&this.options.hideOthers!==!1&&l.getAll().forEach(h=>{h!==this&&h.shown&&!n.closest(h.modalElement).length&&h.hideForOther()}),this.options.closeOthers&&l.getAll().forEach(h=>{h!==this&&!n.closest(h.modalElement).length&&h.hide()}),this.layout(),(c=this.options.onShow)==null||c.call(this),this.emit("show"),this._setTimer(()=>{n.addClass(vd),this._setTimer(()=>{var h,d;(h=n.find("[autofocus]")[0])==null||h.focus(),(d=this.options.onShown)==null||d.call(this),this.emit("shown")})},50),!0}hideForOther(){v(this.modalElement).addClass(Ja)}hide(){var t;if(!this._shown||(this._shown=!1,v(this.modalElement).removeClass(vd),((t=this.options.onHide)==null?void 0:t.call(this))===!1))return!1;this.emit("hide"),this._setTimer(()=>{var n;v(this.modalElement).removeClass(Vg),(n=this.options.onHidden)==null||n.call(this),this.emit("hidden")});const e=this.constructor;return e.hideOthers&&this.options.hideOthers!==!1&&e.getAll().forEach(n=>{n.shown&&n!==this&&v(n.modalElement).removeClass(Ja)}),!0}layout(e,t){if(!this._shown)return;const{dialog:n}=this;if(!n)return;const s=v(n);if(t=t??this.options.size,t){s.removeAttr("data-size");const h={width:"",height:""};typeof t=="object"?(h.width=t.width,h.height=t.height):typeof t=="string"&&["md","sm","lg","full"].includes(t)?s.attr("data-size",t):t&&(h.width=t),s.css(h)}e=e??this.options.position??"fit";const r=n.clientWidth,o=n.clientHeight;this._lastDialogSize=[r,o],typeof e=="function"&&(e=e({width:r,height:o}));const a={left:null,bottom:null,right:null};let l=null,c="center";typeof e=="number"?(c="flex-start",l=e):typeof e=="object"&&e?(Object.assign(a,e),l=a.top??l,c=a.alignSelf??"flex-start"):e==="fit"?(c="flex-start",l=`${Math.max(0,Math.floor((window.innerHeight-o)/3))}px`):e==="bottom"?c="flex-end":e==="top"?c="flex-start":e!=="center"&&typeof e=="string"&&(c="flex-start",l=e),a.top=l,a.alignSelf=c,s.css(a),v(this.modalElement).css("justifyContent",a.left?"flex-start":"center")}_setTimer(e,t){this._timer&&(clearTimeout(this._timer),this._timer=0),e&&(this.options.animation?this._timer=window.setTimeout(e,t??this.options.transTime):e())}static last(e){return bi.query(e,void 0,t=>t.shown)}static hide(e){var t;(t=bi.last(e))==null||t.hide()}static show(e){var t;(t=bi.query(e,void 0,n=>!n.shown))==null||t.show()}};Ui.NAME="Modal",Ui.MULTI_INSTANCE=!0,Ui.DEFAULT={position:"fit",show:!0,keyboard:!0,animation:!0,backdrop:!0,responsive:!0,transTime:300},Ui.hideOthers=!0,Ui.zIndex=1500;let Vi=Ui;v(window).on(`resize.${Vi.NAMESPACE}`,()=>{Vi.getAll().forEach(i=>{const e=i;e.shown&&e.options.responsive&&e.layout()})});class Wg extends re{constructor(e){super(e),this._ref=pe(),this.state={showed:!e.waitShowEvent}}componentDidMount(){const{waitShowEvent:e,afterRender:t}=this.props;t==null||t.call(this,{firstRender:!0}),e&&v(this._ref.current).on(e,()=>{this.setState({showed:!0})})}componentDidUpdate(){var e;(e=this.props.afterRender)==null||e.call(this,{firstRender:!1})}componentWillUnmount(){var e;(e=this.props.beforeDestroy)==null||e.call(this)}renderHeader(){const{header:e,headerClass:t,title:n}=this.props;return I.isValidElement(e)?e:e===!1||!n?null:e?k(de,{className:U("modal-header",t),content:e}):k("div",{className:U("modal-header",t),children:k("div",{className:"modal-title",children:n})})}renderActions(){const{actions:e,closeBtn:t}=this.props;return!t&&!e?null:I.isValidElement(e)?e:k("div",{className:"modal-actions",children:[e?k(Fe,{...e}):null,t?k("button",{type:"button",class:"btn square ghost","data-dismiss":"modal",children:k("span",{class:"close"})}):null]})}renderBody(){const{body:e,bodyClass:t}=this.props;return e?I.isValidElement(e)?e:k(de,{className:U("modal-body",t),content:e}):null}renderFooter(){const{footer:e,footerClass:t,footerActions:n}=this.props;return I.isValidElement(e)?e:e===!1||!n?null:e?k(de,{className:U("modal-footer",t),content:e}):k("div",{className:U("modal-footer",t),children:n?k(Fe,{...n}):null})}render(){const{className:e,style:t,contentClass:n,children:s,waitShowEvent:r}=this.props,o=r&&!this.state.showed;return k("div",{ref:r?this._ref:void 0,className:U("modal-dialog",e,o?"loading":""),style:t,children:[k("div",{className:U("modal-content",n),children:[this.renderHeader(),this.renderActions(),this.renderBody(),s,this.renderFooter()]}),o?k("div",{class:"load-indicator loading"}):null]})}}Wg.defaultProps={closeBtn:!0};class _d extends re{constructor(){super(...arguments),this._ref=pe(),this._height=fe(),this._timer=0,this._handleError=e=>{e.message.includes("ResizeObserver loop completed with undelivered notifications")&&this.componentWillUnmount()},this._handleIframeLoad=()=>{const e=this.iframeDoc;if(e){try{const{iframeBodyClass:t,watchHeight:n}=this.props;n&&this._watchIframeHeight(),t&&e.body.classList.add(t)}catch{}v(this._ref.current).trigger("modal-iframe-loaded")}}}get iframeDoc(){var e,t;return(t=(e=this._ref.current)==null?void 0:e.contentWindow)==null?void 0:t.document}componentDidMount(){this.props.watchHeight&&this._watchIframeHeight(),window.addEventListener("error",this._handleError)}componentWillUnmount(){var e;window.removeEventListener("error",this._handleError),(e=this._rob)==null||e.disconnect(),this._timer&&clearTimeout(this._timer)}_watchIframeHeight(){const e=this.iframeDoc;if(!e)return;let t=this._rob;t==null||t.disconnect(),t=new ResizeObserver(()=>{this._timer&&clearTimeout(this._timer),this._timer=window.setTimeout(()=>{const n=e.body,s=e.documentElement,r=Math.ceil(Math.max(n.scrollHeight,n.offsetHeight,s.offsetHeight));r&&r!==this._height.value&&(this._height.value=r),this._timer=0},10)}),t.observe(e.body),this._rob=t}render(){return k("iframe",{className:"modal-iframe",style:this._height.value?`height: ${this._height.value}px;`:void 0,src:this.props.url,ref:this._ref,onLoad:this._handleIframeLoad})}}_d.defaultProps={watchHeight:!0};var bd=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_n=(i,e,t)=>(bd(i,e,"read from private field"),t?t.call(i):e.get(i)),qr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Wi=(i,e,t,n)=>(bd(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t),Xa=(i,e,t)=>(bd(i,e,"access private method"),t),os,Gr,as,Qa,wd,el,Cd;function Dx(i,e){const{custom:t,title:n,content:s,closeBtn:r}=e;return{body:s,closeBtn:r,title:n,...typeof t=="function"?t():t}}async function Ix(i,e){const{dataType:t="html",url:n,request:s,custom:r,title:o,replace:a=!0,executeScript:l=!0}=e,c=await v.ajax({url:n,headers:{"X-ZUI-Modal":"true"},...s});if(t!=="html")try{const h=JSON.parse(c);return{title:o,...r,...h}}catch{}return a!==!1&&t==="html"?[c]:{title:o,...r,body:t==="html"?k(An,{className:"modal-body",html:c,executeScript:l}):c}}async function Mx(i,e){const{url:t,custom:n,title:s,size:r}=e,o=typeof r=="object"&&typeof r.height=="number";return{title:s,...n,waitShowEvent:"modal-iframe-loaded",body:k(_d,{url:t,watchHeight:!o})}}const Nx={custom:Dx,ajax:Ix,iframe:Mx},Kg="loading",qg=class wi extends Vi{constructor(){super(...arguments),qr(this,Qa),qr(this,el),qr(this,os,void 0),qr(this,Gr,void 0),qr(this,as,void 0),this._builded=!1}get id(){return _n(this,Gr)}get loading(){var e;return(e=_n(this,os))==null?void 0:e.classList.contains(Kg)}get shown(){var e;return!!((e=_n(this,os))!=null&&e.classList.contains("show"))}get modalElement(){let e=_n(this,os);if(!e){const{options:t}=this;let n=_n(this,Gr);n||(n=t.id||`modal-${Xe()}`,Wi(this,Gr,n));const{$element:s}=this;if(e=s.find(`#${n}`)[0],e)v(e).data(this.constructor.KEY,this);else{const r=this.key;e=v("<div>").attr({id:n,"data-key":r}).data(this.constructor.KEY,this).css(t.style||{}).setClass("modal modal-async load-indicator",t.className).appendTo(s)[0]}Wi(this,os,e)}return e}get $emitter(){const e=_n(this,os);return e?v(e):this.$element}afterInit(){super.afterInit(),this.options.type==="static"?(this._staticMbo=new MutationObserver(t=>{let n=!1;for(const s of t)if(s.removedNodes.length){n=!0;break}n&&this.autoDestroy()}),this._staticMbo.observe(this.modalElement.parentNode,{childList:!0})):this.options.destroyOnHide&&this.on("hidden",t=>{v(t.target).data("key")===this.key&&this.destroy()})}autoDestroy(e=100){this._autoDestory&&clearTimeout(this._autoDestory),this._autoDestory=window.setTimeout(()=>{this._autoDestory=0,(En(this.element)||this.options.type==="static"&&En(this.modalElement))&&this.destroy()},e)}show(e){return super.show(e)?(this.buildDialog(),!0):!1}destroy(){var t;super.destroy();const e=_n(this,os);e&&(v(e).removeData(this.constructor.KEY).remove(),Wi(this,os,void 0)),(t=this._staticMbo)==null||t.disconnect()}render(e){return super.render(e),this.buildDialog()}async buildDialog(){if(this.loading)return!1;_n(this,as)&&clearTimeout(_n(this,as));const{modalElement:e,options:t}=this,n=v(e),{type:s,loadTimeout:r,loadingClass:o=Kg,loadingText:a=null,cache:l}=t;if(!s||s==="static")return!0;if(l&&this._builded)return this.layout(),!0;const c=Nx[s];if(!c)return console.warn(`Modal: Cannot build modal with type "${s}"`),!1;n.attr("data-loading",a).addClass(o),r&&Wi(this,as,window.setTimeout(()=>{Wi(this,as,0),Xa(this,el,Cd).call(this,this.options.timeoutTip)},r));const h=await c.call(this,e,t);return this._destroyed?!1:(h===!1?await Xa(this,el,Cd).call(this,this.options.failedTip):h&&typeof h=="object"&&await Xa(this,Qa,wd).call(this,h),_n(this,as)&&(clearTimeout(_n(this,as)),Wi(this,as,0)),this.layout(),this._builded=!0,await Dn(100),n.removeClass(o),!0)}static isValid(e){return!v.isDetached(e.modalElement)}static open(e){return new Promise(t=>{const{container:n=document.body,ref:s,...r}=e,o={show:!0,...r};!o.type&&o.url&&(o.type="ajax"),!o.type&&e.id&&(o.type="static"),o.key===void 0&&(o.key=o.id);const a=wi.ensure(n,o);s&&(s.current=a);const l=`${wi.NAMESPACE}.open${Xe()}`;a.on(`hidden${l}`,()=>{a.off(l),t(a)}),a.show()})}static async alert(e){typeof e=="string"&&(e={message:e});const{type:t,message:n,icon:s,iconClass:r="icon-lg muted",actions:o="confirm",onClickAction:a,custom:l,key:c="__alert",...h}=e,d=(typeof l=="function"?l():l)||{};let f=k(de,{content:n});s?f=k("div",{className:U("modal-body row gap-4 items-center",d.bodyClass),children:[k("div",{className:`icon ${s} ${r}`}),f]}):f=k("div",{className:U("modal-body",d.bodyClass),children:f});const p=[];(Array.isArray(o)?o:o?[o]:[]).forEach(w=>{w={...typeof w=="string"?{key:w}:w},typeof w.key=="string"&&(w.text||(w.text=be.getLang(w.key,w.key)),w.btnType||(w.btnType=`btn-wide ${w.key==="confirm"?"primary":"btn-default"}`)),w&&p.push(w)},[]);let y;const b=p.length?{gap:4,items:p,onClickItem:({item:w,event:x})=>{const T=wi.query(x.target);if(!T||T.key!==c)return;y=w.key,(a==null?void 0:a(w,T))!==!1&&T&&T.hide()}}:void 0;return await wi.open({key:c,type:"custom",size:400,className:"modal-alert",content:f,modal:!0,backdrop:"static",hideOthers:!1,custom:{footerActions:b,...d},...h}),y}static async confirm(e){typeof e=="string"&&(e={message:e});const{onClickAction:t,onResult:n,...s}=e;return await wi.alert({actions:["confirm","cancel"],onClickAction:(o,a)=>{n==null||n(o.key==="confirm",a),t==null||t(o,a)},...s})==="confirm"}static async prompt(e){typeof e=="string"&&(e={message:e});const{defaultValue:t="",placeholder:n,onResult:s,onShown:r,message:o,content:a,bodyClass:l,custom:c,multiline:h,...d}=e;let f=t,p=!1;const y=T=>{f=T.target.value},b=pe(),w=T=>{var D,N;T.key==="Enter"?(p=!0,T.preventDefault(),(D=b.current)==null||D.hide()):T.key==="Escape"&&((N=b.current)==null||N.hide())};return await wi.confirm({...d,custom:{closeBtn:!1,...c},message:o,ref:b,content:k("div",{className:U("modal-body",l),children:[k(de,{content:o}),h?k("textarea",{className:"modal-prompt-input form-control mt-3",autoFocus:!0,placeholder:n,defaultValue:t,onChange:y,onKeyDown:w,rows:10}):k("input",{type:"text",className:"modal-prompt-input form-control mt-3",autoFocus:!0,placeholder:n,defaultValue:t,onChange:y,onKeyDown:w}),a]})})||p?f:null}};os=new WeakMap,Gr=new WeakMap,as=new WeakMap,Qa=new WeakSet,wd=function(i){return new Promise(e=>{if(Array.isArray(i))return v(this.modalElement).html(i[0]).zuiInit(),this.layout(),this._observeResize(),e();const{afterRender:t,...n}=i;i={afterRender:s=>{this.layout(),t==null||t(s),this._observeResize(),e()},...n},ms(k(Wg,{...i}),this.modalElement)})},el=new WeakSet,Cd=function(i){if(i)return Xa(this,Qa,wd).call(this,{body:k("div",{className:"modal-load-failed",children:i})})},qg.DEFAULT={...Vi.DEFAULT,loadTimeout:1e4,destroyOnHide:!0};let He=qg;He.register();class Ki extends qe{get modal(){return this._modal}get container(){const{container:e}=this.options;return typeof e=="string"?document.querySelector(e):e instanceof HTMLElement?e:document.body}show(){var e;return(e=this._initModal())==null?void 0:e.show()}hide(){var e;return(e=this._modal)==null?void 0:e.hide()}_getBuilderOptions(){const{container:e,...t}=this.options,n=t,s=this.$element.attr("href")||"";return n.type||(n.target||s[0]==="#"?n.type="static":n.type=n.type||(n.url||s?"ajax":"custom")),!n.url&&(n.type==="iframe"||n.type==="ajax")&&s[0]!=="#"&&(n.url=s),n.key===void 0&&(n.key=`${this._key}`),n}_initModal(){const e=this._getBuilderOptions();let t=this._modal;if(t)return t.setOptions(e),t;if(e.type==="static"){const n=this._getStaticModalElement();if(!n)return;t=Vi.ensure(n,e)}else t=He.ensure(this.container,e);return this._modal=t,t.on("destroyed",()=>{this._modal=void 0}),t}_getStaticModalElement(){let e=this.options.target;if(!e){const{$element:t}=this;if(t.is("a")){const n=t.attr("href");n!=null&&n.startsWith("#")&&(e=n)}}return this.container.querySelector(e||".modal")}}Ki.NAME="ModalTrigger",Ki.toggle={name:"modal",skip:"[disabled],.disabled,.open-in-parent",convertHref:!0,onGet(i){return Ki.get(i)},onCreate(i,e,t){return new Ki(i,t)}},Ki.register();const Gg={zh_cn:{selectFile:"选择文件",fileSelectTip:"(不超过 {maxFileSize})",removeFile:"移除文件",renameFile:"重命名",duplicatedTip:"文件 “{name}”({size}) 已存在。",exceededSizeTip:"文件 “{name}”({size}) 超过了 {maxFileSize} 的限制。",exceededTotalSizeTip:"文件 “{name}”({size}) 超过了总大小 {totalFileSize} 的限制。",exceededCountTip:"文件 “{name}”({size}) 超过了数量 {maxFileCount} 的限制。"},zh_tw:{selectFile:"選擇文件",fileSelectTip:"(不超過 {maxFileSize})",removeFile:"移除文件",renameFile:"重命名",duplicatedTip:"文件 “{name}”({size}) 已存在。",exceededSizeTip:"文件 “{name}”({size}) 超過了 {maxFileSize} 的限制。",exceededTotalSizeTip:"文件 “{name}”({size}) 超過了總大小 {totalFileSize} 的限制。",exceededCountTip:"文件 “{name}”({size}) 超過了數量 {maxFileCount} 的限制。"},en:{selectFile:"Select File",fileSelectTip:"(Not exceeding {maxFileSize})",removeFile:"Remove File",renameFile:"Rename",duplicatedTip:"File “{name}” ({size}) already exists.",exceededSizeTip:"File “{name}” ({size}) exceeds the limit of {maxFileSize}.",exceededTotalSizeTip:"File “{name}” ({size}) exceeds the total size limit of {totalFileSize}.",exceededCountTip:"File “{name}” ({size}) exceeds the limit of {maxFileCount}."}};let ks=class extends Ve{constructor(e){if(e.totalFileSize)if(e.maxFileSize){const{maxFileSize:t,totalFileSize:n}=e,s=typeof t=="number"?t:$n(t),r=typeof n=="number"?n:$n(n);e.maxFileSize=s>r?n:t}else e.maxFileSize=e.totalFileSize;e.maxFileSize||(e.maxFileSize="100MB"),super(e),this._input=pe(),this._file=pe(),this._id=`file-selector-input-${Xe()}`,this._data=new DataTransfer,this.stopRenameFile=()=>{const{renaming:t,newName:n}=this.state;this.cancelRenameFile(),!(!t||!n)&&this.renameFile(t,n)},this.cancelRenameFile=()=>{this.setState({renaming:""})},this._handleChange=t=>{const n=t.target;n.files&&(this.selectFiles(n.files),this.setState({inputKey:Xe()}))},this._handleDragOver=t=>{t.preventDefault(),this.state.dragging||this.setState({dragging:!0})},this._handleDragLeave=t=>{t.preventDefault(),this.setState({dragging:!1})},this._handleDrop=t=>{this._handleDragLeave(t);const n=t.dataTransfer;if(!n)return;const s=[];if(n.items)for(const o of n.items){if(o.kind==="file"&&o.webkitGetAsEntry){const l=o.webkitGetAsEntry();if(l&&l.isDirectory)continue}const a=o.getAsFile();a&&s.push(a)}else s.push(...Array.from(n.files||[]));const r=this.constructor.filterFiles(s,this.props.accept);r.length&&(this.selectFiles(r),this.setState({inputKey:Xe()}))},this._handleRenameChange=t=>{this.setState({newName:t.target.value})},this._handleClick=t=>{if(this.props.disabled)return;const s=v(t.target).closest("[data-remove-file],[data-rename-file]");if(!s.length)return;const r=s.data();r.renameFile?this.startRenameFile(String(r.renameFile)):r.removeFile&&this.removeFile(String(r.removeFile))},this.state={files:(e.value||e.defaultFiles||[]).map(t=>this.constructor.getInfo(t)),inputKey:0}}get size(){return this.state.files.reduce((e,t)=>e+t.size,0)}get count(){return this.state.files.length}get multiple(){const{multiple:e,maxFileCount:t,name:n=""}=this.props;return!!(t!==1&&(e??n.endsWith("[]")))}get info(){const{maxFileSize:e=0,maxFileCount:t=Number.MAX_SAFE_INTEGER}=this.props;return{size:pt(this.size,1),maxFileSize:pt(typeof e=="string"?$n(e):e,1),maxFileCount:t,count:this.count}}get files(){return this._data.files}componentDidMount(){const e=this.state.files.reduce((t,n)=>(n.file&&t.push(n.file),t),[]);e.length&&(e.forEach(t=>this._data.items.add(t)),this._syncFiles())}getFile(e){return this.state.files.find(t=>t.id===e)}getFileByName(e){return this.state.files.find(t=>t.name===e)}select(){var e;(e=this._input.current)==null||e.click()}setFiles(e){this.setState({files:e.map(t=>this.constructor.getInfo(t))})}setValue(e){this.setFiles(e)}async selectFiles(e){var t;if(((t=this.props.onSelect)==null?void 0:t.call(this,e))!==!1){this._skipAddMore=!1;for(const n of e)if(await this.addFile(n),this._skipAddMore)break}}async findSameFile(e){const t=this.state.files;for(const n of t)if(n.file&&await this.constructor.isSame(e,n.file))return n}async _checkDuplicated(e){const{allowSameName:t,onDuplicated:n,duplicatedTip:s=this.i18n("duplicatedTip"),checkBuffer:r}=this.props,o=r&&e.file?await this.findSameFile(e.file):void 0,{name:a}=e,l=o||(t?this.getFile(e.id):this.getFileByName(a));return l?(n&&await n.call(this,a,e,l)===!0||s&&await this._showAlert(s,{name:a,size:pt(e.size,1)}),!0):!1}async _checkExceededSize(e){const{maxFileSize:t,onExceededSize:n,exceededSizeTip:s=this.i18n("exceededSizeTip")}=this.props;if(!t)return!1;const r=typeof t=="string"?$n(t):t;return e.size<=r?!1:((n==null?void 0:n.call(this,r,e))===!0||s&&await this._showAlert(s,{name:e.name,size:pt(e.size,1),maxFileSize:t}),!0)}async _checkTotalSize(e){const{totalFileSize:t,onExceededTotalSize:n,exceededTotalSizeTip:s=this.i18n("exceededTotalSizeTip")}=this.props;if(!t)return!1;const r=typeof t=="string"?$n(t):t,o=e.size+this.size;return o<=r?!1:((n==null?void 0:n.call(this,r,e))===!0||s&&await this._showAlert(s,{name:e.name,size:pt(e.size,1),totalSize:pt(o,1)}),!0)}async _checkExceededCount(e){const{maxFileCount:t=0,onExceededCount:n,exceededCountTip:s=this.i18n("exceededCountTip")}=this.props;if(!t)return!1;const r=this.count+1;return r<=t?!1:((n==null?void 0:n.call(this,t,e))===!0||s&&await this._showAlert(s,{name:e.name,size:pt(e.size,1),exceededCount:r}),!0)}async addFile(e){const{onAdd:t,disabled:n}=this.props;if(n)return!1;const s=this.constructor.getInfo(e);return await this._checkExceededCount(s)?(this._skipAddMore=!0,!1):await this._checkDuplicated(s)?!1:await this._checkExceededSize(s)?(this._skipAddMore=!0,!1):await this._checkTotalSize(s)?(this._skipAddMore=!0,!1):t&&t.call(this,s)===!1?!1:(this._data.items.add(e),this._syncFiles(!0),await this.changeState(c=>({files:[...c.files,s]})),!0)}startRenameFile(e){this.setState({renaming:e,newName:void 0},()=>{const t=v(this._file.current).closest(".file-selector").find(".file-selector-rename-input")[0];t&&(t.select(),t.focus())})}replaceFileName(e,t){const n=e.file;if(!n)return;const s=new File([n],t,{type:n.type,lastModified:n.lastModified}),r=Array.from(this._data.files).indexOf(n);return r>=0&&this._data.items.remove(r),this._data.items.add(s),e.file=s,this._syncFiles(!0),s}async renameFile(e,t){const n=this.getFile(e);if(!n||n.name===t)return;const{onRename:s}=this.props;if(s&&await s.call(this,t,n.name,n)===!1)return;const{files:r,renamedFiles:o={}}=this.state;n.file?this.replaceFileName(n,t):o[n.id]=t,n.name=t,n.ext=this.constructor.getExt(t);const a=r.indexOf(n);a>=0?r.splice(a,1,n):r.push(n),this.setState({files:[...r],renamedFiles:{...o}})}async removeFile(e){const t=this.getFile(e);if(!t)return;const{onRemove:n,removeConfirm:s}=this.props;if(s){let c=s;if(typeof c=="string"&&(c={message:c}),typeof c.message=="string"&&(c.message=De(c.message,{name:t.name,size:pt(t.size,1)})),!await He.confirm(c))return}if(n&&await n.call(this,t)===!1)return;if(t.file){const c=Array.from(this._data.files).indexOf(t.file);c>=0&&this._data.items.remove(c)}const{files:r,deletedFiles:o=[],renamedFiles:a={}}=this.state,l=r.indexOf(t);l>=0&&(!t.file&&!o.includes(t.id)&&(delete a[t.id],o.push(t.id)),r.splice(l,1),this.setState({files:[...r],deletedFiles:[...o],renamedFiles:{...a}}),this._syncFiles(!0))}_syncFiles(e=!1){const t=this._data.files,n=this._file.current;n.files=t,e&&v(n).trigger("change",{files:t})}_showAlert(e,t){return typeof e=="string"&&(e={message:e}),typeof e.message=="string"&&(e.message=De(e.message,{...this.info,...t})),He.alert(e)}_getTip(e){return typeof e=="string"?De(e,this.info):e}_renderInput(e){return k("input",{id:this._id,multiple:this.multiple,accept:e.accept,style:"display:none",type:"file",ref:this._input,onChange:this._handleChange},`input${this.state.inputKey}`)}_getDraggableProps(){const e={};return this.props.draggable&&!this.props.disabled&&(e.onDragOver=this._handleDragOver,e.onDragLeave=this._handleDragLeave,e.onDrop=this._handleDrop),e}_renderUpload(e){const{mode:t,disabled:n,tip:s=this.i18n("fileSelectTip"),uploadBtn:r}=e,o=Pe({component:"label",attrs:{for:n?void 0:this._id},disabled:n,text:this.i18n("selectFile")},typeof r=="object"?r:typeof r=="string"?{text:r}:{}),a=k("div",{className:"file-selector-tip",children:k(de,{content:this._getTip(s),generatorThis:this,generatorArgs:[this.state]})}),l=t==="grid",c=l?{}:this._getDraggableProps();return l||t==="box"?k(we,{...o,...c,className:U(l?"file-selector-grid-btn":"file-selector-box",o.className),children:a},"upload"):k("div",{className:"file-selector-btn",...c,children:[k(we,{rounded:"full",size:"sm",...o}),a]},"upload")}_renderForForm(e){const{name:t,accept:n,onChange:s,deleteName:r,renameName:o}=e,{deletedFiles:a,renamedFiles:l}=this.state,c=[k("input",{ref:this._file,type:"file",name:t,multiple:this.multiple,accept:n,style:"display:none",onChange:s},"form")];return r&&a&&c.push(...a.map(h=>k("input",{type:"hidden",name:`${r}[${h}]`,value:h},`delete:${h}`))),o&&l&&c.push(...Object.entries(l).map(([h,d])=>k("input",{type:"hidden",name:`${o}[${h}]`,value:d},`rename:${h}`))),c}_getIcon(e){let{fileIcons:t}=this.props;if(t)return typeof t=="string"&&(t={default:t}),t[e.ext]??t.default}_getThumbnail(e){if((e.file||e.url)&&this.props.thumbnail&&this.constructor.isImage(e))return e.url||URL.createObjectURL(e.file)}_getAvatar(e){const t=this._getThumbnail(e);let n;if(t)n={src:t};else{const s=this._getIcon(e);s&&(n={icon:s})}return n&&{size:this.props.mode==="grid"?void 0:"sm",...n}}_getFileActions(e){if(this.props.disabled)return;let{removeBtn:t,renameBtn:n}=this.props;typeof t=="function"&&(t=t.call(this,e)),typeof t=="string"?t={text:t}:t===!0&&(t={hint:this.i18n("removeFile"),icon:"trash"}),typeof n=="function"&&(n=n.call(this,e)),typeof n=="string"?n={text:n}:n===!0&&(n={hint:this.i18n("renameFile"),icon:"edit"});const s=[];return n&&s.push({"data-rename-file":e.id,...n}),t&&s.push({"data-remove-file":e.id,...t}),s}_renderFile(e){const{itemProps:t}=this.props,n=Pe({className:this.props.mode==="grid"?"file-selector-grid-item":"file-selector-item",multiline:!1,title:e.name,subtitle:pt(e.size,1),avatar:this._getAvatar(e),actions:this._getFileActions(e),"z-id":e.id},typeof t=="function"?t.call(this,e):t);return k(Pn,{...n},e.id)}_renderFileRename(e){const{itemProps:t}=this.props,{newName:n=e.name}=this.state,s=this.props.mode==="grid",r=k("div",{className:"file-selector-rename-text",children:[k("div",{className:"form-control size-sm",children:n}),k("input",{type:"text",defaultValue:e.name,className:"form-control size-sm select-all file-selector-rename-input",autofocus:!0,onBlur:s?this.stopRenameFile:void 0,onChange:this._handleRenameChange,onInput:this._handleRenameChange})]}),o=Pe({className:`${s?"file-selector-grid-item":"file-selector-item"} is-renaming`,multiline:!1,avatar:this._getAvatar(e),"z-id":e.id,contentClass:"file-selector-rename",content:s?r:[r,k(we,{icon:"check",text:this.i18n("confirm"),type:"primary-pale",size:"sm",onClick:this.stopRenameFile}),k(we,{icon:"close",text:this.i18n("cancel"),type:"gray-pale",size:"sm",onClick:this.cancelRenameFile})]},typeof t=="function"?t.call(this,e):t);return k(Pn,{...o},e.id)}_renderList(e){const{files:t,renaming:n}=this.state;return k("div",{className:`file-selector-list${t.length?"":" is-empty"}`,onClick:this._handleClick,children:t.map(s=>s.id===n?this._renderFileRename(s):this._renderFile(s))},"list")}_renderGrid(e){const t=this._getDraggableProps(),{gridWidth:n=120,gridHeight:s=148,gridGap:r=12}=e,o={"--file-selector-grid-width":Be(n),"--file-selector-grid-height":Be(s),"--file-selector-grid-gap":Be(r)},{files:a,renaming:l}=this.state;return k("div",{className:"file-selector-grid",style:o,onClick:this._handleClick,...t,children:[a.map(c=>c.id===l?this._renderFileRename(c):this._renderFile(c)),this._renderUpload(e)]},"grid")}_getClassName(e){return["file-selector",`is-mode-${e.mode}`,e.className,this.state.dragging?"is-dragging":""]}_getChildren(e){const t=e.mode==="grid";return[t?null:this._renderUpload(e),t?this._renderGrid(e):this._renderList(e),this._renderInput(e),this._renderForForm(e)]}static getExt(e){return(e.split(".").pop()||"").toLowerCase()}static getInfo(e){const{name:t,size:n,type:s}=e;if(e instanceof File)return{name:t,size:n,type:s,file:e,id:[t,n].join(":"),ext:this.getExt(t)};const r=typeof n=="string"?$n(n):n;return{name:t,size:r,id:e.id?String(e.id):[t,r].join(":"),type:s??"",ext:this.getExt(t),file:e.file,url:e.url}}static isAccept(e,t){return!t||!t.length?!0:(Array.isArray(t)?t:t.split(",")).some(s=>e.type&&s===e.type?!0:s.startsWith(".")?e.name.endsWith(s):s.endsWith("/*")?e.type.startsWith(s.slice(0,-1)):!1)}static isImage(e){return this.isAccept(e,this.imageAccepts)}static filterFiles(e,t){if(!t||!t.length)return e;e instanceof FileList&&(e=Array.from(e));const n=t.split(",");return e.filter(s=>s.type===""&&!s.size&&!s.name.includes(".")?!1:this.isAccept(s,n))}static async isSame(e,t){if(e.size!==t.size)return!1;const[n,s]=await Promise.all([e.arrayBuffer(),t.arrayBuffer()]);if(n.byteLength!==s.byteLength)return!1;const r=new Uint8Array(n),o=new Uint8Array(s);for(let a=0;a<r.length;a++)if(r[a]!==o[a])return!1;return!0}};ks.defaultProps={mode:"button",fileIcons:"file",renameBtn:!0,removeBtn:!0,draggable:!0,thumbnail:!0,maxFileCount:0},ks.i18n=Gg,ks.imageAccepts="image/*,.png,.jpg,.jpeg,.gif";let xd=class extends ks{};xd.defaultProps={...ks.defaultProps,mode:"grid",accept:ks.imageAccepts};const Ex=Object.freeze(Object.defineProperty({__proto__:null,FileSelector:ks,ImageSelector:xd},Symbol.toStringTag,{value:"Module"}));class Zr extends ve{}Zr.NAME="FileSelector",Zr.Component=ks,Zr.replace=!0;class tl extends ve{}tl.NAME="ImageSelector",tl.Component=xd,tl.replace=!0,st(Ex);const wI="";class kd extends re{constructor(e){super(e),this._searchInput=pe(),this._measure=pe(),this._changeTimer=0,this._handleChange=t=>{if(t.isComposing)return;const n=t.target.value;this.setState({search:n},()=>{const{onSearch:s}=this.props;s&&(this._changeTimer&&clearTimeout(this._changeTimer),this._changeTimer=window.setTimeout(()=>{this._changeTimer=0,s(n)},this.props.debounce||300))}),t.stopPropagation()},this._handleClear=t=>{t.stopPropagation(),this.clear()},this.state={search:e.defaultSearch??""}}get $pop(){return v(`#pick-pop-${this.props.id}`)}focus(){var e;(e=this._searchInput.current)==null||e.focus()}setSearch(e,t=!0){var s,r,o,a;if(!e.length&&this.state.search.length&&((r=(s=this.props).onClear)==null||r.call(s)),((o=this._searchInput.current)==null?void 0:o.value)===e){t&&this.focus();return}v((a=this._searchInput)==null?void 0:a.current).val(e).trigger("change"),t&&this.focus()}clear(){this.setSearch("")}componentDidMount(){this.focus();const{hotkeys:e}=this.props;if(e){const t=uh(e,{clear:{keys:"Escape",handler:()=>{this.state.search.trim().length?this.clear():this.$pop.trigger("hidePop")}},enter:{keys:"Enter",handler:n=>{n.preventDefault(),this.$pop.trigger("selectActive"),this.clear()}},activeNext:{keys:"ArrowDown",handler:()=>{this.$pop.trigger("activeNext")}},activePrev:{keys:"ArrowUp",handler:()=>{this.$pop.trigger("activePrev")}},deselectLast:{keys:"Backspace",handler:()=>{this.state.search.trim().length||this.$pop.trigger("deselectLast")}}});t&&(this._hotkeysScope=`PickerSearch_${Xe()}`,v(this._searchInput.current).hotkeys(t,{scope:this._hotkeysScope,event:"keydown"}))}v(this._searchInput.current).on("compositionend",this._handleChange)}componentDidUpdate(){const{inline:e}=this.props;if(e){const{current:t}=this._measure,{current:n}=this._searchInput;if(t&&n){const s=v(n).parent();s.width(Math.ceil(Math.min(t.clientWidth,s.closest(".picker").outerWidth()-32)))}}}componentWillUnmount(){clearTimeout(this._changeTimer),this._hotkeysScope&&v(this._searchInput.current).unbindHotkeys(this._hotkeysScope),v(this._searchInput.current).off("compositionend",this._handleChange)}render(e,t){const{placeholder:n,inline:s}=e,{search:r}=t,o=r.trim().length>0;let a;return s?a=k("div",{className:"picker-search-measure",ref:this._measure,children:r}):o?a=k("button",{type:"button",className:"btn picker-search-clear square size-sm ghost",onClick:this._handleClear,children:k("span",{className:"close"})}):a=k("span",{className:"magnifier"}),k("div",{className:`picker-search${s?" is-inline":""}`,children:[k("input",{className:"form-control picker-search-input",type:"text",placeholder:n,value:r,autoComplete:"off",onChange:this._handleChange,onInput:this._handleChange,ref:this._searchInput}),a]})}}class Zg extends za{constructor(){super(...arguments),this._search=pe(),this._handleDeselectClick=e=>{const{onDeselect:t,state:{selections:n}}=this.props,s=v(e.target).closest(".picker-deselect-btn").attr("data-value");t&&n.length&&typeof s=="string"&&t(s),e.stopPropagation()},this._handleSearch=e=>{this.props.changeState({search:e})},this._handleSearchClear=()=>{this.props.togglePop(!0,{search:""})},this._renderSelection=e=>{const{text:t}=e;return k("div",{className:"picker-multi-selection",title:typeof t=="string"?t:void 0,children:[k("span",{className:"text",children:k(de,{content:t})}),this.props.disabled||this.props.readonly?null:k("div",{className:"picker-deselect-btn btn size-xs ghost",onClick:this._handleDeselectClick,"data-value":e.value,children:k("span",{className:"close"})})]},e.value)}}get searchBox(){return this._search.current}_handleClick(e){var t;super._handleClick(e),(t=this._search.current)==null||t.focus()}_getClass(e){return U(super._getClass(e),e.search?"":"picker-no-search","picker-select picker-select-multi form-control")}_renderSearch(e){const{state:{search:t},searchHint:n,hotkeys:s}=e;return k(kd,{inline:!0,id:e.id,ref:this._search,defaultSearch:t,onSearch:this._handleSearch,onClear:this._handleSearchClear,placeholder:n,hotkeys:s})}_renderTrigger(e){const{state:{selections:t=[],open:n,value:s},search:r,placeholder:o,display:a,valueList:l,children:c,caretClass:h}=this.props,d=n&&r;let f;const p=!d&&!t.length;return a&&(!p||o===void 0)?(typeof a=="function"?f=a.call(this,l,t):typeof a=="string"&&(f=De(a,{value:s,values:l,count:l.length})),f=k("div",{className:"picker-multi-selections",children:f},"selections")):p?f=k("span",{className:"picker-select-placeholder",children:o},"selections"):f=k("div",{className:"picker-multi-selections",children:[t.map(this._renderSelection),d?this._renderSearch(e):null]},"selections"),[f,c,k("span",{class:U("caret",h)},"caret")]}_renderValue(e){const{name:t,state:{value:n=""},disabled:s,id:r,valueList:o,emptyValue:a,onRenderValue:l}=e;if(l)return l(o,e);if(t)if(this.hasInput)v(`#${r}`).val(n);else{const c=o.length?o:[a];return k("select",{id:r,multiple:!0,className:"pick-value",name:t.endsWith("[]")?t:`${t}[]`,disabled:s,style:{display:"none"},children:c.map(h=>k("option",{value:h,children:h},h))})}return null}componentDidMount(){super.componentDidMount();const{id:e,valueList:t,emptyValue:n}=this.props;v(`#${e}`).val(t.length?t:[n])}componentDidUpdate(e){const{id:t,state:n,name:s,valueList:r,emptyValue:o}=this.props;if(s&&e.state.value!==n.value){const a=v(`#${t}`).val(r.length?r:[o]);this._skipTriggerChange!==n.value&&a.trigger("change",yg),this._skipTriggerChange=!1}}}class Yg extends za{constructor(){super(...arguments),this._search=pe(),this._handleDeselectClick=e=>{this.props.disabled||(this.props.onClear(),e.stopPropagation())},this._handleSearch=e=>{this.props.changeState({search:e})},this._handleSearchClear=()=>{this.props.togglePop(!0,{search:""})}}get searchBox(){return this._search.current}_getSearchPlaceholder(){const{searchHint:e,state:{value:t,selections:n}}=this.props;let s=e;if(s===void 0){const r=n.find(o=>o.value===t);r&&typeof r.text=="string"&&(s=r.text)}return s}_handleClick(e){var t;super._handleClick(e),(t=this._search.current)==null||t.focus()}_getClass(e){return U(super._getClass(e),e.search?"":"picker-no-search","picker-select picker-select-single form-control")}_renderSearch(e){const{state:{search:t},hotkeys:n}=e;return k(kd,{ref:this._search,id:e.id,defaultSearch:t,onSearch:this._handleSearch,onClear:this._handleSearchClear,placeholder:this._getSearchPlaceholder(),hotkeys:n})}_renderTrigger(e){const{children:t,state:{selections:n=[],value:s,open:r},placeholder:o,search:a,disabled:l,clearable:c,display:h,caretClass:d}=e,[f]=n,p=r&&a;let y;if(p)y=this._renderSearch(e);else if(f||o===void 0&&h){const{text:x}=f||{text:"",value:""};typeof h=="function"?y=h.call(this,s,n):typeof h=="string"?y=De(h,f):y=k(de,{content:x}),y=k("span",{className:"picker-single-selection",title:typeof x=="string"?x:void 0,children:y},"main")}else y=k("span",{className:"picker-select-placeholder",children:o},"main");const b=c&&!p?k("button",{type:"button",className:"btn picker-deselect-btn size-xs square ghost",disabled:l,onClick:this._handleDeselectClick,children:k("span",{className:"close"})},"deselect"):null,w=p?null:k("span",{className:U("caret flex-none",d)},"caret");return[y,t,b,w]}}function Jg(i,e){return i.reduce((t,n)=>(Array.isArray(n.items)&&Jg(n.items,t),typeof n.value=="string"&&t.set(n.value,n),t),e||new Map)}class Xg extends gd{constructor(){super(...arguments),this._menu=pe(),this._disabledSet=new Set,this._getItem=(e,t)=>{var c;if(e.parentKey!==void 0)return e;const n=new Set(this.props.valueList);let s=e.items,r=!1,o=!1;Array.isArray(s)&&this.props.multiple&&!this.props.noNestedPick&&(r=!0,s=s.reduce((h,d,f)=>{const p=this._getItem(d,f);return p&&(p.selected?o=!0:r=!1,h.push(p)),h},[]));const a=r||n.has(e.value);e={selected:a,hint:typeof e.text=="string"?e.text:void 0,...e,checked:this._hasCheckbox||typeof e.checked=="boolean"?r?!0:o?"indeterminate":a:void 0,className:U(e.className,{hover:e.value!==void 0&&e.value===this.props.state.hoverItem}),items:s},e.content&&e.text&&delete e.text,this.props.getItem&&(e=this.props.getItem(e,t));const l=((c=this._getItemCallback)==null?void 0:c.call(this,e,t))??e;return l&&((l.disabled||l.value===void 0)&&(l.hover===void 0&&(l.hover=!1),l.disabled===void 0&&(l.disabled=!0),this._disabledSet.add(l.value)),a&&!l.disabled&&l.value!==void 0&&this._firstSelected===void 0&&(this._firstSelected=l.value),l)},this._beforeRenderItem=(e,t)=>{var n;return(n=this._renderItemCallback)==null?void 0:n.call(this,e,t)},this._handleItemClick=({item:e,event:t})=>{const n=e.value,s=t.target;if(e.disabled||n===void 0||s.closest(".item-icon,.nested-toggle-icon,.disabled")||Array.isArray(e.items)&&e.items.every(l=>this._disabledSet.has(l.value)))return;const{multiple:r,onPick:o,noNestedPick:a}=this.props;if(r)if(e.items&&!a){const c=[...Jg(e.items).values()].filter(h=>!h.items&&!this._disabledSet.has(h.value)).map(h=>h.value);v(s).closest(".item").children(".item-inner.selected").length?o({diselect:c}):o({select:c})}else o({toggle:n});else o({select:n})}}get menu(){return this._menu.current}get picker(){return this.props.picker}componentDidMount(){var e,t;super.componentDidMount(),this._firstSelected===void 0?(e=this.menu)==null||e.activeNext():(t=this.menu)==null||t.toggleActive(this._firstSelected,!0),v(this.element).on("activeNext.zui.Picker",()=>{var n;(n=this.menu)==null||n.activeNext()}).on("activePrev.zui.Picker",()=>{var n;(n=this.menu)==null||n.activePrev()}).on("selectActive.zui.Picker",()=>{const n=this.menu;if(!n)return;const s=n.getActiveKey();if(s!==void 0){const r=n.getRenderedItem(s);r&&v(this.element).find(`.item[z-key-path="${r._keyPath}"]`).trigger("click")}}).on("hidePop.zui.Picker",()=>{this.props.togglePop(!1)}).on("deselectLast.zui.Picker",()=>{if(this.props.multiple){const{valueList:n}=this.props,s=n[n.length-1];s&&this.props.onDeselect(s)}}),setTimeout(()=>{var n;v((n=this.menu)==null?void 0:n.element).find(".menu-item>.selected").scrollIntoView({block:"center"})},100)}componentWillUnmount(){super.componentWillUnmount(),v(this.element).off(".zui.Picker")}_getClass(e){return U(super._getClass(e),"picker-menu")}_getMenuProps(e){const{menu:t,tree:n,state:s,checkbox:r,header:o,footer:a,noMatchHint:l,maxItemsCount:c,exceedLimitHint:h}=e,{items:d,search:f}=s;return Pe({ref:this._menu,className:"picker-menu-list",underlineKeys:!0,limit:c,items:d,defaultNestedShow:!0,activeOnHover:!0,search:f,exceedLimitHint:h,onClickItem:this._handleItemClick,nestedToggle:".nested-toggle-icon,.item-icon",checkbox:r,searchProps:["keys","text","title","subtitle","value"],header:o,footer:a,noMatchHint:l,relativeTarget:this},t,n)}_renderHeader(){return null}_renderFooter(){return null}_renderPop(e){const{tree:t}=e;this._firstSelected=void 0,this._disabledSet.clear();const n=this._getMenuProps(e);return this._hasCheckbox=!!n.checkbox,this._getItemCallback=n.getItem,this._renderItemCallback=n.beforeRenderItem,n.getItem=this._getItem,n.beforeRenderItem=this._beforeRenderItem,t?k(Zs,{...n}):k(dt,{...n})}}function ei(i,e){return i.reduce((t,n)=>(Array.isArray(n.items)&&ei(n.items,t),t.set(n.value===void 0?"":String(n.value),n),t),e||new Map)}const nl=class Ci extends ot{constructor(e){super(e),this._updateTimer=0,this.toggleValue=(t,n)=>{if(!this.props.multiple)return n||t!==this.value?this.setValue(t):this.setValue();const{valueList:s}=this,r=s.indexOf(t);if(n!==r>=0)return r>-1?s.splice(r,1):s.push(t),this.setValue(s)},this.deselect=(t=[])=>{const{valueList:n}=this,s=new Set(this.formatValueList(t)),r=n.filter(o=>!s.has(o));this.setValue(r)},this.clear=()=>{this.setValue()},this.select=t=>{const n=this.formatValueList(t),s=this.props.multiple?[...this.valueList,...n]:n[0];return this.setValue(s)},this.isSelected=t=>this.valueList.includes(t),this._handlePickValue=t=>{var o,a;const{toggle:n,select:s,diselect:r}=t;n!==void 0?this.toggleValue(n):s!==void 0?this.select(s):r!==void 0&&this.deselect(r),this.props.multiple?this.props.clearSearchOnSelect&&((o=this.state.search)!=null&&o.length)&&this.focusSearch(""):(this.toggle(!1),(a=this.searchBox)==null||a.clear())},this._getMenuItem=t=>{var n;return(n=this._sharedValueSet)!=null&&n.has(t.value)&&(t.disabled=!0),t},this.setValue=this.setValue.bind(this),this.isEmptyValue=this.isEmptyValue.bind(this)}get valueList(){if(this.props.multiple)return this.formatValueList(this.state.value);const e=this.state.value;return this.isEmptyValue(e)?[]:[e]}get firstEmptyValue(){return this._emptyValueSet.values().next().value}get searchBox(){var e;return(e=this.trigger)==null?void 0:e.searchBox}get value(){return this.props.value??this.state.value}focusSearch(e){const{searchBox:t}=this;t&&(typeof e=="string"?t.setSearch(e):t.focus())}getDefaultState(e){const{items:t,valueSplitter:n=",",emptyValue:s=""}=e||this.props,r={...super.getDefaultState(e),loading:!1,search:"",items:Array.isArray(t)?t:[],selections:[]};if(this._emptyValueSet=new Set(typeof s=="string"?s.split(n):[]),Array.isArray(t)&&t.length){const{limitValueInList:o,required:a,multiple:l}=this.props;if(t.forEach(c=>{typeof c.value=="number"&&(c.value=String(c.value))}),o){const c=ei(t);r.value=this.formatValueList(r.value,n).filter(h=>c.has(h)).join(n),a&&!l&&!this.formatValueList(r.value,n).length&&(r.value=t[0].value??"")}}return r}isEmptyValue(e){return this._emptyValueSet.has(e)}deselectAll(){this.setValue([])}selectAll(){const{items:e}=this.state;if(!Array.isArray(e))return;const n=[...ei(e).values()].reduce((s,r)=>(!r.disabled&&!r.items&&s.push(r.value),s),[]);return this.select(n)}isSelectedAll(){const{items:e}=this.state;if(!Array.isArray(e))return!1;const t=ei(e),n=new Set(this.valueList);return[...t.values()].every(s=>s.disabled||n.has(s.value))}async load(){let e=this._abort;e&&e.abort();const{items:t=[],searchDelay:n}=this.props,{search:s=""}=this.state;let r=[];if(Array.isArray(t))r=t;else{if(e=new AbortController,this._abort=e,await Dn(n||500),this._abort!==e)return r;let o=t;typeof o=="string"&&(o={url:o}),typeof o=="object"&&o.url&&(o={...o,url:De(o.url,{search:encodeURIComponent(s),"search:base64":Ep(s)})});try{r=await Ne(o,[this,s],{signal:e.signal})}catch(a){r=[],console.warn("[ZUI] Picker: Failed to load items.",this.props.name,{error:a})}if(this._abort!==e)return r}return this._abort=void 0,r}changeState(e,t){return super.changeState(n=>{const s=typeof e=="function"?e(n):e;if(s.value!==void 0&&s.value!==n.value||s.items&&s.items!==n.items){const r=s.items||n.items,o=new Map;Array.isArray(n.items)&&n.items!==s.items&&ei(n.items,o),Array.isArray(r)&&(ei(r,o),s.selections=this.formatValueList(s.value??n.value).reduce((a,l)=>(this.isEmptyValue(l)||a.push(o.get(l)||{value:l,text:l}),a),[]))}return s},t)}async update(e){const{state:t,props:n}=this,s=this._itemsCacheInfo||{},r={};if(this._itemsCacheInfo=s,!t.loading&&(e||s.search!==t.search||n.items!==s.items)){await this.changeState({loading:!0});let a=await this.load();const l=c=>c.filter(h=>(h.key=h.key??h.value,typeof h.value=="number"&&(h.value=String(h.value)),this.isEmptyValue(h.value)?!1:(Array.isArray(h.items)&&(h.items=l(h.items)),!0)));a=l(a),r.loading=!1,r.items=a,s.items=n.items,s.search=t.search}else s.items&&!t.open&&n.cache===!1&&!Array.isArray(n.items)&&(s.items=void 0);(e||s.value!==t.value)&&(s.value=t.value);const o=r.items;n.limitValueInList&&n.required&&!n.multiple&&this.isEmptyValue(this.state.value)&&Array.isArray(o)&&o.length&&(r.value=o[0].value),Object.keys(r).length&&await this.changeState(r)}async tryUpdate(){this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._updateTimer=0,this.update()},50)}componentDidUpdate(e,t){super.componentDidUpdate(e,t),this.tryUpdate()}componentDidMount(){super.componentDidMount(),this.tryUpdate();const{shareSelections:e}=this.props;if(e){const t=Ci.sharedPickers.get(e)||new Set;t.add(this),Ci.sharedPickers.set(e,t)}}componentWillUnmount(){var t;(t=this._abort)==null||t.abort(),this._abort=void 0,this._itemsCacheInfo=void 0,clearTimeout(this._updateTimer);const{shareSelections:e}=this.props;if(e){const n=Ci.sharedPickers.get(e)||new Set;n.delete(this),n.size||Ci.sharedPickers.delete(e)}super.componentWillUnmount()}_handleChange(e,t){if(super._handleChange(e,t),e!==t){const{onDeselect:n,onSelect:s,onClear:r,multiple:o}=this.props,a=this.formatValueList(t),l=this.valueList;if(r&&!l.length&&a.length&&r.call(this),n){const c=a.filter(h=>!l.includes(h));c.length&&n.call(this,o?c:c[0])}if(s){const c=l.filter(h=>!a.includes(h));c.length&&s.call(this,o?c:c[0])}}}_getTriggerProps(e,t){return{...super._getTriggerProps(e,t),multiple:e.multiple,hotkeys:e.hotkeys,placeholder:e.placeholder,search:e.search,display:e.display,searchHint:e.searchHint,caretClass:e.caretClass,clearable:!!this.valueList.length&&!e.required,valueList:this.valueList,emptyValue:this.firstEmptyValue,onDeselect:this.deselect,onSelect:this.select,onClear:this.clear,onToggleValue:this.toggleValue,onSetValue:this.setValue}}_getPopProps(e,t){return e.shareSelections&&(this._sharedValueSet=Ci.getSharedSelections(e.shareSelections)),{...super._getPopProps(e,t),picker:this,menu:e.menu,tree:e.tree,getItem:e.shareSelections?this._getMenuItem:void 0,checkbox:e.checkbox,multiple:e.multiple,search:e.search,maxItemsCount:e.maxItemsCount,noNestedPick:e.noNestedPick,footer:this._renderToolbar(),valueList:this.valueList,noFlipAfterShow:!0,noMatchHint:t.loading?be.getLang("loadingHint"):e.searchEmptyHint??be.getLang("searchEmptyHint"),exceedLimitHint:e.exceedLimitHint??be.getLang("exceedLimitHint"),onDeselect:this.deselect,onSelect:this.select,onClear:this.clear,onToggleValue:this.toggleValue,onSetValue:this.setValue,onPick:this._handlePickValue}}_getTrigger(e){return e.Trigger||(e.multiple?Zg:Yg)}_renderToolbar(){let{toolbar:e}=this.props;return e?(e===!0&&(e=[{key:"selectAll",text:be.getLang("selectAll")},{key:"cancelSelect",text:be.getLang("cancelSelect")}]),Fe.render(e,[],{size:"sm",relativeTarget:this,getItem:t=>(t.onClick||(t.key==="selectAll"?(t.onClick=this.selectAll.bind(this),t.disabled=this.isSelectedAll()):t.key==="cancelSelect"&&(t.onClick=this.deselectAll.bind(this),t.disabled=!this.valueList.length)),t)},this)):null}formatValueList(e,t){let n;return typeof e=="string"&&e.length?n=e.split(t??this.props.valueSplitter??","):Array.isArray(e)?n=e:n=[e],v.unique(n).reduce((s,r)=>(r==null||(r=typeof r!="string"?String(r):r,this.isEmptyValue(r)||s.push(r)),s),[])}formatValue(e){const t=this.formatValueList(e);return t.length?t.join(this.props.valueSplitter??","):this.firstEmptyValue}setValue(e=[],t){let n=this.formatValueList(e);if(n.length){const{items:r,limitValueInList:o}=this.props;if(o){const a=ei(Array.isArray(r)?r:this.state.items);n=n.filter(l=>a.has(l))}}const s=this.formatValue(n);return super.setValue(s,t)}static getSharedSelections(e){const t=new Set;return(Ci.sharedPickers.get(e)||new Set).forEach(s=>{s.valueList.forEach(r=>t.add(r))}),t}};nl.defaultProps={...ot.defaultProps,className:"picker",valueSplitter:",",limitValueInList:!0,search:!0,emptyValue:"",cache:!0,hotkeys:!0,clearSearchOnSelect:!0},nl.Pop=Xg,nl.sharedPickers=new Map;let Zt=nl;const Ax=Object.freeze(Object.defineProperty({__proto__:null,Picker:Zt,PickerMenu:Xg,PickerMultiSelect:Zg,PickerSearch:kd,PickerSingleSelect:Yg},Symbol.toStringTag,{value:"Module"}));class Px extends re{constructor(e){super(e),this._handleChange=t=>{const{onChange:n}=this.props,s=Array.from(t.target.selectedOptions).map(o=>o.value),r=this.props.multiple?s:s[0];this.setState({value:r}),n&&n(r,t)},this.state={value:e.value??e.defaultValue??(e.multiple?[]:"")}}get value(){return this.state.value}componentDidUpdate(e){e.value!==this.props.value&&this.setState({value:this.props.value??this.props.defaultValue??(this.props.multiple?[]:"")})}render(e){const{items:t=[],className:n,value:s,defaultValue:r,multiple:o,placeholder:a,onChange:l,...c}=e,{value:h}=this.state,d=new Set(o?h:[h]);let f=!1;const p=t.map(y=>{const b=d.has(y.value);return b&&(f=!0),k("option",{value:y.value,selected:b,children:y.text},y.value)});return k("select",{className:U("form-control",n),multiple:o,onChange:this._handleChange,...c,children:[f&&!o?null:k("option",{value:"",children:a}),p]})}}class Lx extends re{constructor(e){super(e),this._handleChange=t=>{const{onChange:n,type:s}=this.props,r=t.target.value;n&&n(s==="number"?+r:r,t)},this._controlled=e.value!==void 0}get value(){return this.base.value}render(e){const{type:t="text",className:n,onChange:s,...r}=e;return k("input",{type:t,className:U("form-control",n),onChange:this._handleChange,...r})}}class Rx extends re{constructor(){super(...arguments),this._handleChange=e=>{const{onChange:t}=this.props,n=e.target.value;t&&t(n,e)}}get value(){return this.base.value}autoHeight(){v.autoHeight(this.base)}componentDidMount(){this.props.autoHeight&&(this.autoHeight(),v(this.base).on("input paste change",()=>{this.autoHeight()}))}componentWillUnmount(){this.props.autoHeight&&v(this.base).off("input paste change")}render(e){const{className:t,onChange:n,...s}=e;return k("textarea",{className:U("form-control",t),onChange:this._handleChange,...s})}}class zx extends re{constructor(e){super(e),this._handleValueChange=n=>{const s=n.target,r=v(s).closest(".string-list-edit-item").attr("z-key");typeof r=="string"&&this.setValue(+r,s.value)},this._handleDeleteClick=n=>{const s=v(n.target).closest(".string-list-edit-item").attr("z-key");typeof s=="string"&&this.remove(+s)},this._handleAddClick=n=>{const s=v(n.target).closest(".string-list-edit-item").attr("z-key");this.add(typeof s=="string"?+s:void 0)};const t=e.defaultValue?e.defaultValue.map(n=>[Xe(),n]):[];t.length||t.push([Xe(),""]),this._items$=fe(t),this._value=t.reduce((n,[s,r])=>(r.length&&n.push(r),n),[]),this._changeEffect=_t(()=>{const n=this._value,s=this._items$.value.reduce((o,[a,l])=>(l.length&&o.push(l),o),[]);(n.length!==s.length||n.some((o,a)=>o!==o[a]))&&(this._value=s,this.props.onChange&&requestAnimationFrame(()=>{var o,a;(a=(o=this.props).onChange)==null||a.call(o,s)}))})}get value(){return this._value}componentDidUpdate(){this._preserveOne()}componentWillUnmount(){this._changeEffect()}_preserveOne(){this._items$.value.length||this.add()}_renderItem(e,t){const{readonly:n,placeholder:s}=this.props;return k("div",{className:"string-list-edit-item","z-key":e,children:[k("input",{className:"string-list-edit-item-value form-control",type:"text",value:t,placeholder:s,readonly:n,onChange:this._handleValueChange}),k("div",{className:"string-list-edit-item-actions",children:[k(we,{type:"ghost",size:"sm",icon:"plus",onClick:this._handleAddClick}),k(we,{type:"ghost",size:"sm",icon:"trash",onClick:this._handleDeleteClick})]})]},e)}setValue(e,t){const n=this._items$.value,s=n.findIndex(([r])=>r===e);n[s][1]=t,this._items$.value=[...n]}add(e){const t=this._items$.value,n=e?t.findIndex(([s])=>s===e):t.length-1;t.splice(n+1,0,[Xe(),""]),this._items$.value=[...t]}remove(e){const t=this._items$.value,n=t.findIndex(([s])=>s===e);t.splice(n,1),t.length||t.push([Xe(),""]),this._items$.value=[...t]}render(e){const t=this._items$.value,{itemWidth:n,maxWidth:s=400}=e,r={};return n&&n!=="auto"&&(r["--string-list-edit-item-width"]=Be(n)||""),s&&s!=="auto"&&s!=="100%"&&(r.maxWidth=Be(s)||""),k("div",{className:"string-list-edit",style:r,children:t.map(([o,a])=>this._renderItem(o,a))})}}class sl extends re{constructor(e){super(e),this._handleKeyChange=n=>{const s=n.target,r=v(s).closest(".map-edit-item").attr("z-key");typeof r=="string"&&this.setKey(+r,s.value)},this._handleValueChange=n=>{const s=n.target,r=v(s).closest(".map-edit-item").attr("z-key");typeof r=="string"&&this.setValue(+r,s.value)},this._handleDeleteClick=n=>{const s=v(n.target).closest(".map-edit-item").attr("z-key");typeof s=="string"&&this.remove(+s)},this._handleAddClick=n=>{const s=v(n.target).closest(".map-edit-item").attr("z-key");this.add(typeof s=="string"?+s:void 0)};const t=e.defaultValue?Object.entries(e.defaultValue).map(([n,s])=>[Xe(),n,s]):[];t.length||t.push([Xe(),"",""]),this._pairs$=fe(t),this._valuePairs=sl.formatPairs(t),this._pairsChangeEffect=_t(()=>{const n=this._valuePairs,s=sl.formatPairs(this._pairs$.value);(n.length!==s.length||n.some(([o,a],l)=>o!==s[l][0]||a!==s[l][1]))&&(this._valuePairs=s,this.props.onChange&&requestAnimationFrame(()=>{var o,a;(a=(o=this.props).onChange)==null||a.call(o,this.value)}))})}static formatPairs(e){return e.reduce((t,[n,s,r])=>(s.length&&t.push([s,r]),t),[]).sort((t,n)=>t[0].localeCompare(n[0]))}get value(){return this._valuePairs.reduce((e,[t,n])=>(e[t]=n,e),{})}componentDidUpdate(){this._preserveOne()}componentWillUnmount(){this._pairsChangeEffect()}_preserveOne(){this._pairs$.value.length||this.add()}_renderItem(e,t,n){const{readonly:s}=this.props;return k("div",{className:"map-edit-item","z-key":e,children:[k("input",{className:"map-edit-item-key form-control",type:"text",value:t,readonly:s,onChange:this._handleKeyChange}),k("input",{className:"map-edit-item-value form-control",type:"text",value:n,readonly:s,onChange:this._handleValueChange}),k("div",{className:"map-edit-item-actions",children:[k(we,{type:"ghost",size:"sm",icon:"plus",onClick:this._handleAddClick}),k(we,{type:"ghost",size:"sm",icon:"trash",onClick:this._handleDeleteClick})]})]},e)}setKey(e,t){const n=this._pairs$.value,s=n.findIndex(([r])=>r===e);n[s][1]=t,this._pairs$.value=[...n]}setValue(e,t){const n=this._pairs$.value,s=n.findIndex(([r])=>r===e);n[s][2]=t,this._pairs$.value=[...n]}add(e){const t=this._pairs$.value,n=e?t.findIndex(([s])=>s===e):t.length-1;t.splice(n+1,0,[Xe(),"",""]),this._pairs$.value=[...t]}remove(e){const t=this._pairs$.value,n=t.findIndex(([s])=>s===e);t.splice(n,1),t.length||t.push([Xe(),"",""]),this._pairs$.value=[...t]}render(e){const t=this._pairs$.value,{keyWidth:n,valueWidth:s,maxWidth:r=400}=e,o={};return n&&n!=="auto"&&(o["--map-edit-key-width"]=Be(n)||""),s&&s!=="auto"&&(o["--map-edit-value-width"]=Be(s)||""),r&&r!=="auto"&&r!=="100%"&&(o.maxWidth=Be(r)||""),k("div",{className:"map-edit",style:o,children:t.map(([a,l,c])=>this._renderItem(a,l,c))})}}class Fx extends re{constructor(){super(...arguments),this._defaultID=`_form-control-${Xe()}`}_renderZUIComponent(e,t){return e.ZUI?k(ya,{$use:e,$options:t}):k(e,{...t})}_renderSelect(e){return k(Px,{...e})}_renderCheckbox(e){const{className:t,type:n,name:s,defaultValue:r,disabled:o,...a}=e;return k("div",{className:`check-list-inline is-type-${n}`,children:k(es,{type:n,id:s??this._defaultID,className:t,name:s,defaultChecked:!!r,disabled:!!o,...a})})}_renderCheckList(e){const{items:t=[],type:n="radio",className:s,disabled:r,block:o=!1,name:a,defaultValue:l,...c}=e;return k(zC,{type:n,items:t,className:s,name:a,defaultChecked:l,disabled:!!r,inline:!o,...c})}_renderText(e){const{value:t,className:n,...s}=e;return k("div",{className:U("form-static-text",n),...s,children:t})}_renderTextarea(e){return k(Rx,{...e})}_renderInput(e){return k(Lx,{...e})}_renderMap(e){return k(sl,{...e})}_renderStringList(e){return k(zx,{...e})}render(e){const{widget:t="input",props:n,...s}=e,r=Pe({},s,n);return typeof t=="function"?this._renderZUIComponent(t,r):t==="select"||t==="multiSelect"?this._renderSelect({multiple:t==="multiSelect",...r}):t==="checkbox"||t==="switch"?this._renderCheckbox({type:t,...r}):t==="checkboxList"||t==="switchList"||t==="radioList"||t==="radio"?this._renderCheckList({type:t==="switchList"?"switch":t==="radioList"||t==="radio"?"radio":"checkbox",...r}):t==="text"?this._renderText(r):t==="textarea"?this._renderTextarea(r):t==="input"?this._renderInput(r):t==="map"?this._renderMap(r):t==="stringList"?this._renderStringList(r):k(ya,{$use:t,$options:r})}}function Ox(i){const{children:e,name:t,label:n,tooltip:s,labelClass:r,required:o,style:a,className:l,hint:c,control:h}=i;return k("div",{className:U("form-group",l,(h==null?void 0:h.widget)==="text"?"is-static-text":null),"data-name":t,style:a,children:[n!==void 0?k("label",{class:U("form-label",r,o?"required":""),for:t,children:[k("div",{class:"form-label-text",title:typeof n=="string"?n:void 0,children:k(de,{content:n})}),s?k("div",{className:"state","zui-toggle":"tooltip","zui-toggle-tooltip":Lp(typeof s=="string"?{content:s}:s),children:k($e,{icon:"info"})}):null]}):null,h?k(Fx,{...h}):null,e,c?k(de,{className:"form-tip",content:c}):null]})}class Bx extends re{constructor(){super(...arguments),this._handleChange=e=>{const{schemaInfo:t,onChangeField:n}=this.props,s=t.widget[2];let r;if(s)r=s(e);else{if(e===void 0)return;if(e instanceof Event){const o=e.target;if(o.tagName==="INPUT"&&o.type==="radio"&&!v(o).prop("checked"))return;o.tagName==="INPUT"&&o.type==="checkbox"?r=v(o).prop("checked"):o.tagName==="SELECT"&&o.multiple?r=Array.from(v(o).val()):r=o.value}else if(typeof e=="function"||typeof e=="object"&&!Array.isArray(e)&&!v.isPlainObject(e)){console.warn("[ZUI] Unsupported value type:",typeof e,e);return}else r=e}n(t.path,r)}}render({schemaInfo:e}){const{schema:t,value:n,widget:s,path:r,required:o}=e,{title:a,description:l,tooltip:c,disabled:h,readonly:d,placeholder:f}=t,[p,y]=s,b={widget:p,disabled:h,readonly:d,placeholder:f,required:o,props:y,value:n,onChange:this._handleChange};return k(Ox,{name:r,label:a,hint:l,tooltip:c,required:b.required,control:b})}}class il extends re{_getSchemaInfo(e){const{infoGetter:t,path:n=""}=e;return e.schemaInfo||t(n)}_renderObjectSchema(e){const{infoGetter:t,errorsGetter:n,path:s="",onChangeField:r}=this.props,{schema:o,properties:a=[]}=e,{title:l,description:c}=o,h=[];for(const d of a){const f=s.length?`${s}.${d}`:d,p=n(f);h.push(k(il,{infoGetter:t,path:f,onChangeField:r,errorsGetter:n,errors:p.length?p:void 0},d))}return s.length?k(Ar,{title:l,caption:c,className:"form-builder-collapsible",contentClass:"form-builder-items",children:h},s):k("div",{className:"form-builder-items",children:h})}_renderArraySchema(e){const{infoGetter:t,errorsGetter:n,path:s=""}=this.props;if(!e)return console.warn("[ZUI] Schema not found:",s),null;const r=e.schema,{title:o,description:a,items:l}=r;if(l){const c=t(`${s}[]`);if(!c)return console.warn("[ZUI] Schema not found:",`${s}[]`),null;const h=c.value;return k(Ar,{title:o,caption:a,disabled:r.collapsed==="disabled",collapsed:typeof r.collapsed=="boolean"?r.collapsed:!r.title,className:"form-builder-collapsible",children:h.map((d,f)=>{const p={...c,path:`${s}[${f}]`,value:d},y=n(p.path);return k(il,{infoGetter:t,errors:y.length?y:void 0,errorsGetter:n,path:p.path,schemaInfo:p,onChangeField:this.props.onChangeField})})})}return this._renderFormItem(e)}_renderSchema(e){const{type:t}=e.schema;return t==="object"?this._renderObjectSchema(e):t==="array"?this._renderArraySchema(e):this._renderFormItem(e)}_renderFormItem(e){return k(Bx,{schemaInfo:e,onChangeField:this.props.onChangeField})}_getWidthStyle(e){if(typeof e!="string"&&typeof e!="number")return"";if(typeof e=="number")return`${e/12*100}%`;if(e==="full")return"100%";if(/^\d+\/\d+$/.test(e)){const[t,n]=e.split("/").map(Number);return`${t/n*100}%`}return e}render(e){const{infoGetter:t,errors:n,path:s=""}=e,r=e.schemaInfo||t(s);if(!r)return console.warn("[ZUI] Schema not found:",s),null;const{schema:o}=r;if(o.hidden)return null;const{extra:a,hint:l,width:c,type:h,disabled:d,readonly:f,required:p}=o,y=this._getWidthStyle(c);return k("div",{"z-key":s,"z-type":h,className:U("form-builder-item",{"is-root":!s.length,"is-disabled":d,"is-readonly":f,"is-required":p,"has-error":n==null?void 0:n.length}),style:y?{"flex-basis":y}:void 0,children:[this._renderSchema(r),n!=null&&n.length?k("div",{class:"form-item-errors",children:n.map(([b,w])=>k("div",{class:"form-item-error",children:w},b))}):null,l?k("div",{className:"form-hint",children:l}):null,a?k(de,{className:"form-builder-extra",content:a}):null]},s)}}const jx={validate:{required:"“{title}”不能为空",minLength:"“{title}”的长度不能少于{min}",maxLength:"“{title}”的长度不能超过{max}",minCount:"“{title}”的数目不能少于{min}",maxCount:"“{title}”的数目不能超过{max}",min:"“{title}”不能小于{min}",max:"“{title}”不能超过{max}",pattern:"“{title}”格式不正确",integer:"“{title}”必须是整数"}},Hx={validate:{required:"“{title}”不能為空",minLength:"“{title}”的長度不能少於{min}",maxLength:"“{title}”的長度不能超過{max}",minCount:"“{title}”的數目不能少於{min}",maxCount:"“{title}”的數目不能超過{max}",min:"“{title}”不能小於{max}",max:"“{title}”不能超過{max}",pattern:"“{title}”格式不正確",integer:"“{title}”必須是整數"}},Ux={validate:{required:'"{title}" is required',minLength:'"{title}" length must be greater than {min}',maxLength:'"{title}" length must be less than {max}',minCount:'"{title}" count must be greater than {min}',maxCount:'"{title}" count must be less than {max}',min:'"{title}" must be greater than {min}',max:'"{title}" must be less than {max}',pattern:'"{title}" format is incorrect',integer:'"{title}" must be an integer'}};be.addLang({zh_cn:{formBuilder:jx},zh_tw:{formBuilder:Hx},en:{formBuilder:Ux}});function Vx(i,e,t){return be.getLang(`formBuilder.${i}`,e,t)}const Yr=class Bs extends Ve{constructor(e){super(e),this._map=new Map,this.setFieldValue=(n,s)=>{const r=this.getFieldSchemaInfo(n),o=(r==null?void 0:r.schema).autoTrim;o&&typeof s=="string"&&(o==="start"?s=s.trimStart():o==="end"?s=s.trimEnd():s=s.trim());const l=this._dataMap$.value[n];l!==s&&requestAnimationFrame(()=>{var h;const c=(h=this.props.onFieldChange)==null?void 0:h.call(this,n,s,l);c!==!1&&gs(()=>{const d={[n]:s,...typeof c=="object"?c:{}};this._dataMap$.value={...this._dataMap$.value,...d};const f=Object.keys(d);this._updateFieldInfos(f)})})},this.getFieldValidationErrors=n=>this.validationErrors[n]||[],this.getFieldSchemaInfo=(n="")=>{var s;return(s=this.getFieldSchemaInfo$(n))==null?void 0:s.value},this._handleSubmit=n=>{const{onSubmit:s,autoValidate:r}=this.props;if(r!=null&&r.onSubmit&&!this.validate()){n.preventDefault();return}(s==null?void 0:s.call(this,n,this.formData))===!1&&n.preventDefault()},this._schema$=fe(e.schema);const t=Bs.buildDataMap(e.schema,e.defaultData);this._dataMap$=fe(t),this._schemaPatches$=fe({}),this._validationErrors$=fe({}),this._formData$=Ce(()=>Bs.buildFormData(this._dataMap$.value)),this._lastFormData=Bs.buildFormData(t),this._schemaMap$=Ce(()=>{const n={},s=this._schemaPatches$.value;return Bs.loopSchema(this.schema,(r,o)=>{n[o]=v.extend(!0,r,s[o])}),n}),this._formDataEffect=_t(()=>{var s;const n=this._lastFormData;this._lastFormData=this._formData$.value,(s=this.props.onDataChange)==null||s.call(this,this._formData$.value,n)})}get schema$(){return this._schema$}get schema(){return this._schema$.value}get formData(){return this._formData$.value}get schemaMap(){return this._schemaMap$.value}get validationErrors(){return this._validationErrors$.value}componentDidMount(){var e;(e=this.props.afterRender)==null||e.call(this,!0)}componentDidUpdate(e){var t;e.schema!==this.props.schema?this._schema$.value=this.props.schema:(t=this.props.afterRender)==null||t.call(this,!1)}componentWillUnmount(){this._formDataEffect()}getSchemaByPath(e){return this.schemaMap[e]}setSchemaByPath(e,t,n=!0){const s=this._schemaPatches$.value;this._schemaPatches$.value={...s,[e]:n?v.extend(!0,s[e]||{},t):{...s[e],...t}}}validateField(e,t){const n=typeof e=="string"?this.getFieldSchemaInfo(e):e,s=n==null?void 0:n.schema.type;if(!s||s==="object")return[];const{schema:r}=n,o=(t==null?void 0:t.value)??n.value,a=h=>[h,Vx(`validate.${h}`,r)],l=(h,d,f="pattern")=>{if(!h)return;const p=typeof h=="string"?{pattern:h}:h;if(!new RegExp(p.pattern).test(d))return p.message?[f,p.message]:a(f)};if(n.required&&(o==null||s==="string"&&o===""||s==="array"&&(!Array.isArray(o)||o.length===0)||s==="map"&&Object.keys(o).length===0||(s==="number"||s==="integer")&&Number.isNaN(o)))return[a("required")];const c=[];if(r.type==="string"){typeof r.min=="number"&&r.min>0&&String(o??"").length<r.min&&c.push(a("minLength")),typeof r.max=="number"&&r.max>0&&String(o??"").length>r.max&&c.push(a("maxLength"));const h=l(r.pattern,String(o??""));h&&c.push(h)}else if(r.type==="number"||r.type==="integer")typeof r.min=="number"&&r.min>0&&Number(o??0)<r.min&&c.push(a("min")),typeof r.max=="number"&&r.max>0&&Number(o??0)>r.max&&c.push(a("max")),r.type==="integer"&&!Number.isInteger(Number(o??0))&&c.push(a("integer"));else if(r.type==="array")typeof r.min=="number"&&r.min>0&&Array.isArray(o)&&o.length<r.min&&c.push(a("minCount")),typeof r.max=="number"&&r.max>0&&Array.isArray(o)&&o.length>r.max&&c.push(a("maxCount"));else if(r.type==="map"&&(r.keyPattern||r.valuePattern)){const h=o,{keyPattern:d,valuePattern:f}=r;for(const[p,y]of Object.entries(h)){const b=l(d,p,"keyPattern"),w=l(f,String(y??""),"valuePattern");b&&c.push(b),w&&c.push(w)}}if(!(t!=null&&t.skipUpdate)){const{validationErrors:h}=this;if(JSON.stringify(h[n.path])===JSON.stringify(c))return c;this._validationErrors$.value={...h,[n.path]:c},this._updateFieldInfo(n.path)}return c}validate(){const e={},{validationErrors:t}=this,n={skipUpdate:!0};let s=!1,r="";return Bs.loopSchema(this.schema,(o,a)=>{const l=this.validateField(a,n);!s&&JSON.stringify(t[a]||[])!==JSON.stringify(l)&&(s=!0),l.length>0&&(e[a]=l,r=a)}),s?(this._validationErrors$.value=e,r.length&&v(this.element).find(`[z-key="${r}"]`).scrollIntoView(),!1):!0}_updateMap(){const e=this._map,t=new Set(e.keys());Bs.loopSchema(this.schema,(n,s)=>{t.delete(s),this._updateFieldInfo(s)});for(const n of t.keys())e.delete(n)}_updateFieldInfos(e){const t=new Set(e);for(const n of e)this._updateFieldInfo(n,t)}_updateFieldInfo(e,t){var a;const n=this._createFieldSchemaInfo(e);if(!n)return;const s=this._map;let r=s.get(e);r?r.value=n:(r=fe(n),this._map.set(e,r)),t=t||new Set,s.values().forEach(({value:l})=>{!l||l.path===e||t.has(l.path)||!l.dependenciesSet.has(e)||this._updateFieldInfo(l.path,t)});const{autoValidate:o={}}=this.props;if(o.onChange){const l=this._validationErrors$.value;o.onChange==="removeErrors"&&((a=l[e])!=null&&a.length)?this._validationErrors$.value={...l,[e]:[]}:this.validateField(e)}return n}getFieldSchemaInfo$(e=""){let t=this._map.get(e);return t||(this._updateFieldInfo(e),t=this._map.get(e)),t}_evaluateExpression(e,...t){try{const n=e.substring(2,e.length-2);return v.runJS(n,...t)}catch(n){console.warn("[ZUI] Failed to evaluate expression:",e,n)}}_createFieldSchemaInfo(e){const t=this.schemaMap[e];if(!t)return;const n=this._dataMap$.value[e],s=Object.keys(t),r={};for(const h of s){let d=t[h];typeof d=="string"&&d.startsWith("{{")&&d.endsWith("}}")&&(d=this._evaluateExpression(d,["formBuilder",this],["schema",t],["formData",this.formData],["value",n],["path",e])),r[h]=d}const o=r.type,a=o==="object"&&r.properties?Object.keys(r.properties):void 0;if(a){const h=new Map;for(const d of a){const f=r.properties[d];if(typeof f.order!="number")break;h.set(d,f.order)}h.size===a.length&&a.sort((d,f)=>h.get(d)-h.get(f))}let l=Array.isArray(r.required)?!1:!!r.required;if(o!=="object"&&r.required===void 0&&e.length>2&&e.includes(".")){const h=e.split("."),d=h.pop(),f=h.join("."),p=this.getFieldSchemaInfo(f),y=p?p.schema:this.getSchemaByPath(f);y&&(l=Array.isArray(y.required)&&y.required.includes(d))}const c={required:l,path:e,schema:r,properties:a,value:n,dependenciesSet:new Set(t.dependencies||[])};return{...c,widget:this._getWidget(c)}}_getWidget(e){const{widget:t,props:n}=e.schema,{widgetMap:s}=Bs,{widgets:r={}}=this.props;let o;if(t)for(o=r[t]||s[t];typeof o=="string"&&o!==t;){const l=r[o]||s[o];if(!l||o===l)break;o=l}o||(o=t||r._||s._),typeof o=="function"&&(o=o.call(this,e,this));const a=Array.isArray(o)?o:[o];return n&&(a[1]=Pe({},n,a[1])),a}_renderHeader(e){const{header:t}=e;return t?k(de,{className:"form-builder-header",content:t},"header"):null}_renderBody(e){const{schema:t,actions:n}=e,{title:s}=t;return k("div",{className:`form-builder-body form-grid form-${t.displayType||"vert"}`,children:[s?k("div",{className:"form-builder-title",children:s}):null,k(il,{infoGetter:this.getFieldSchemaInfo,errorsGetter:this.getFieldValidationErrors,onChangeField:this.setFieldValue}),n?Fe.render(n,[],{className:"form-actions"}):null]},"body")}_renderFooter(e){const{footer:t}=e;return t?k(de,{className:"form-builder-footer",content:t},"footer"):null}_getProps(e){return Pe({},super._getProps(e),{action:e.formAction,onSubmit:this._handleSubmit})}_getClassName(e){return["form-builder",e.className]}_getChildren(e){return[this._renderHeader(e),this._renderBody(e),this._renderFooter(e),e.formName?k("input",{type:"hidden",name:e.formName,value:JSON.stringify(this.formData)}):null]}static loopSchema(e,t,n=""){if(t(e,n),e.type==="object")for(const s in e.properties){const r=e.properties[s];this.loopSchema(r,t,n.length?`${n}.${s}`:s)}else e.type==="array"&&e.items&&this.loopSchema(e.items,t,`${n}[]`)}static buildDataMap(e,t,n="",s={}){if(e.type==="object"&&"properties"in e)for(const r in e.properties){const o=e.properties[r],a=t&&typeof t=="object"?t[r]:void 0;this.buildDataMap(o,a,n.length?`${n}.${r}`:r,s)}else{const r=e.type==="array"&&e.items?`${n}[]`:n;s[r]=t??JSON.parse(JSON.stringify(e.defaultValue??this.typeDefaultValueMap[e.type]??""))}return s}static buildFormData(e){return Object.keys(e).reduce((t,n)=>{const s=e[n],r=n.split(".");let o=t;return r.forEach((a,l)=>{l===r.length-1?o[a.endsWith("[]")?a.substring(0,a.length-2):a]=s:(o[a]||(o[a]={}),o=o[a])}),t},{})}};Yr.NAME="FormBuilder",Yr.defaultProps={autoValidate:{onChange:"removeErrors",onSubmit:!0}},Yr.widgetMap={_:i=>i.schema.type==="boolean"?"checkbox":"input",picker:({schema:i})=>{var n;const e=i.type==="array",t=((n=i.props)==null?void 0:n.multiple)??(i.widget==="multiPicker"?!0:e);return[Zt,{multiple:t},s=>{var r;return t&&e?s.split(((r=i.props)==null?void 0:r.valueSplitter)??","):s}]},multiPicker:"picker",input:({schema:i})=>{const{type:e="string"}=i;return e==="number"||e==="integer"?["input",{type:"number"}]:"input"}},Yr.typeDefaultValueMap={string:"",number:0,integer:0,boolean:!1,array:[],object:{},map:{}};let Sd=Yr;const Wx=Object.freeze(Object.defineProperty({__proto__:null,FormBuilder:Sd},Symbol.toStringTag,{value:"Module"}));class rl extends ve{}rl.NAME="FormBuilder",rl.Component=Sd,rl.register(),st(Wx);const CI="",xI="";class qi{constructor(e,t){const{DEFAULT:n,globalControls:s}=this.constructor;this._options={...n,...t,controls:{...s,...n.controls,...t==null?void 0:t.controls}},this._$element=v(e),this._cachedFields=new Map}get element(){return this._$element[0]}get options(){return this._options}get $element(){return this._$element}_queryField(e){const t=this._$element;if("#.[".includes(e[0])){const o=t.find(e);return o.length?o:void 0}const n=this._options,s=e.replaceAll("[","\\[").replaceAll("]","\\]");let r=t.find(`[zui-form-field="${s}"]`);return r.length||(r=t.find(`[name="${s}"]`)),!r.length&&n.matchID&&(r=t.find(`#${s}`)),!r.length&&n.matchBrackets&&!e.includes("[")&&(r=t.find(`[name="${s}\\[\\]"]`),r.length||(r=t.find(`[name^="${s}["]`))),r.length?r:void 0}_getControl(e){const{controls:t}=this._options;if(t)for(const[n,s]of Object.entries(t)){const r=s(e,this._$element);if(r)return{type:n,...r}}}getFieldInfo(e){const{cacheQuery:t,allowSameName:n,fields:s}=this._options;let r;if(s){const a=typeof s=="function"?s:s[e];if(a){const l=a.call(this,e,this._$element);if(l instanceof v)r=l;else if(l)return l;if(l===!1)return}}const o=r||(t?this._cachedFields.get(e):this._queryField(e));if(o!=null&&o.length){if(!n&&o.length>1)throw new Error(`[ZUI] FormHelper: Multiple fields found for query "${e}".`);return t&&this._cachedFields.set(e,o),{$field:o,query:e,name:o.attr("name")??"",value:o.val(),control:this._getControl(o)}}}getFieldVal(e){const t=this.getFieldInfo(e);if(t)return t.control?t.control.getVal():t.value}setFieldVal(e,t){const n=this.getFieldInfo(e);if(!n){if(this._options.throwError)throw new Error(`[ZUI] FormHelper: Field "${e}" not found.`);return!1}return n.control?n.control.setVal(t):(n.$field.val(t),!0)}setFormData(e){Object.entries(e).forEach(([t,n])=>{this.setFieldVal(t,n)})}static registerControl(e,t){this.globalControls[e]=t}}qi.DEFAULT={matchID:!0,matchBrackets:!0,throwError:!0},qi.globalControls={picker:(i,e)=>{let t=i.closest("[z-use-picker]"),n=!1;if(!t.length&&i.hasClass("pick-value")&&(t=i.closest("[z-use]"),n=!0),!t.length||e&&!t.closest(e).length)return;const s=n?t.zui():t.data("zui.Picker");if(s)return{type:"picker",$element:t,instance:s,getVal:()=>{var r;return(r=s.$)==null?void 0:r.value},setVal:r=>{var o;return(o=s.$)==null||o.setValue(r),!0}}}};function Kx(i,e){return new qi(i,e)}class Ft extends Gt{constructor(){super(...arguments),this._menuRef=pe()}get menu(){return this._menuRef.current}handleClickTarget(e){const t=v(e.target),{notHideOnClick:n}=this.options;return(!n||!t.closest(n).length)&&this.hide(),!0}_getMenuOptions(){const{items:e,placement:t,menu:n,tree:s,onClickItem:r,relativeTarget:o=this._triggerElement}=this.options;return{items:e,placement:t,tree:s,onClickItem:r,nestedToggle:".item",accordion:!0,relativeTarget:{target:o,event:this.options.triggerEvent,dropdown:this},dropdown:this,popup:!0,ref:this._menuRef,...n}}_getRenderOptions(){const e=super._getRenderOptions();return this._dynamic?{...e,contentClass:"",popup:!1,content:g(ol,this._getMenuOptions())}:e}}Ft.NAME="Dropdown",Ft.DEFAULT={...Gt.DEFAULT,name:"dropdown",placement:"bottom-start",arrow:!1,closeBtn:!1,animation:"fade",limitSize:!0,notHideOnClick:".not-hide-menu,.form-control,input,label,.nested-toggle-icon"},Ft.toggle={...Gt.toggle,getOptions(i,e,t){var n,s;return e=((s=(n=Gt.toggle)==null?void 0:n.getOptions)==null?void 0:s.call(this,i,e,t))||{},!e.target&&!e.items&&!e.menu&&(e.target=v(i).next(".dropdown-menu")),e}},Ft.register();class rn extends we{constructor(){super(...arguments),this._ref=pe()}get triggerElement(){return this._ref.current}_updateData(){const{dropdown:e,menu:t,items:n,onClickItem:s,relativeTarget:r=this.triggerElement}=this.props,o=Ft.get(this.triggerElement),a={items:n,onClickItem:s,menu:t,relativeTarget:r,...v(this.triggerElement).dataset(),...e};o?o.setOptions(a):new Ft(this.triggerElement,a)}componentDidMount(){this._updateData()}componentDidUpdate(){this._updateData()}componentWillUnmount(){var e;(e=Ft.get(this.triggerElement))==null||e.destroy()}_getProps(e){const{trigger:t,placement:n}=e;return{...super._getProps(e),"data-toggle":"dropdown","data-trigger":t,"data-placement":n,ref:this._ref}}}rn.defaultProps={caret:!0},Object.assign(un.ItemComponents,{dropdown:rn}),Object.assign(Fe.ItemComponents,{dropdown:rn});class ol extends dt{constructor(){super(...arguments),this._handleSearchFocus=()=>{this._searchFocused=!0},this._handleSearchBlur=()=>{this._searchFocused=!1}}get isHoverTrigger(){const{nestedTrigger:e,tree:t}=this.props;return e?e==="hover":!t}get dropdown(){return this.props.dropdown}layout(){var h;if(this.props.tree||this.isRoot)return;const e=(h=this.element)==null?void 0:h.parentElement,t=v(e);e&&this._searchFocused&&this._position&&t.css(this._position);const r=t.parent().children(".dropdown-menu").children(`[z-key-path="${this.props.parentKey}"]`)[0];if(!e||!r)return;let{maxHeight:o}=this.props;const{flip:a,shift:l,offset:c}=this.props;md(r,e,{placement:this.props.placement,middleware:[a?pd():null,l?fd(typeof l=="object"?l:void 0):null,ud(c),Rg({apply({availableWidth:d,availableHeight:f}){if(o){const[p,y]=In(o);o=Math.min(y==="%"?p*window.innerHeight:p,f-2)}else o=f;t.css({maxHeight:o,maxWidth:d-2})}})]}).then(({x:d,y:f})=>{t.css({left:d,top:f}),this._position={left:d,top:f,width:e.offsetWidth,height:e.offsetHeight}})}_getClassName(e){return["dropdown-menu scrollbar-hover scrollbar-thin",super._getClassName(e)]}_afterRender(e){super._afterRender(e),this.layout()}_getNestedProps(e,t,n,s){return Pe(this.isHoverTrigger?{"z-key":n.key,"z-hover":this.props.parentKey??"root",onMouseEnter:this._handleHover,onMouseLeave:this._handleHover}:{},super._getNestedProps(e,t,n,s))}_getItemFromEvent(e){const t=super._getItemFromEvent(e);if(t)return t;const n=v(e.target).closest(".dropdown-menu[z-key]");if(n.length){const s=n.attr("z-key"),r=n.parent().parent().children(".dropdown-menu").children(`[z-key="${s}"]`);if(r.length)return super._getItemFromEvent(e,r[0])}}_renderNestedList(e,t,n,s){const r=super._renderNestedList(e,t,n,s);if(this.props.tree)return r;this._nestedContextMenu.push(r)}_getWrapClass(e){return[super._getWrapClass(e),e.tree?"is-tree":this.isRoot?"is-contextmenu":"is-contextmenu popup"]}_renderWrapperFooter(e){const t=super._renderWrapperFooter(e),n=this._nestedContextMenu;return this.props.tree||!n.length?t:[t,...n]}_renderNestedToggle(e,t){if(this.props.tree)return super._renderNestedToggle(e,t);if(typeof t=="boolean")return k("span",{className:`${this.name}-toggle nested-toggle-icon`,children:k("span",{className:"caret-right"})})}_getSearchBoxProps(e){return{...super._getSearchBoxProps(e),onFocus:this._handleSearchFocus,onBlur:this._handleSearchBlur}}_beforeRender(e){return this._nestedContextMenu=[],super._beforeRender(e)}}ol.defaultProps={...dt.defaultProps,searchBox:!1,placement:"right-start",defaultNestedShow:!1,expandOnSearch:!1,nestedSearch:!1,flip:!0,shift:!0,offset:1},ol.inheritNestedProps=[...dt.inheritNestedProps,"container","tree"];const qx=Object.freeze(Object.defineProperty({__proto__:null,DropdownButton:rn,DropdownMenu:ol},Symbol.toStringTag,{value:"Module"})),al=class Yb extends ht{_getClassName(e){const{type:t,stacked:n,justified:s}=e;return[super._getClassName(e),t?`nav-${t}`:"",n?"nav-stacked":"",s?"nav-justified":""]}static render(e,t,n,s){let r=typeof e=="function"?e.call(s??this,...t):e;if(r)return Array.isArray(r)&&(r={items:r}),n&&(r=Pe(n,r)),k(Yb,{...r})}};al.NAME="nav",al.ItemComponents={...ht.ItemComponents,dropdown:[ht.ItemComponents.default,i=>{const{text:e,items:t,menu:n,props:s,className:r,innerClass:o}=i;return{className:r,children:k(rn,{className:o,type:"ghost",text:e,items:t,menu:n,...s})}}]},al.defaultItemProps={component:"li",innerComponent:"a"};let Td=al;const Gx=Object.freeze(Object.defineProperty({__proto__:null,Nav:Td},Symbol.toStringTag,{value:"Module"}));class $d extends ve{}$d.NAME="Nav",$d.Component=Td,st(Gx);const kI="",SI="",TI="",$I="",DI="",II="",MI="",NI="",EI="",AI="",PI="",LI="",RI="";function Jr(i,e){const t=i.pageTotal||Math.ceil(i.recTotal/i.recPerPage);return typeof e=="string"&&(e==="first"?e=1:e==="last"?e=t:e==="prev"?e=i.page-1:e==="next"?e=i.page+1:e==="current"?e=i.page:e=Number.parseInt(e,10)),e=e!==void 0?Math.max(1,Math.min(e<0?t+e:e,t)):i.page,{...i,pageTotal:t,page:e}}function Qg({key:i,type:e,btnType:t,page:n,format:s,pagerInfo:r,linkCreator:o,...a}){const l=Jr(r,n);return a.text===void 0&&!a.icon&&s&&(a.text=typeof s=="function"?s(l):De(s,l)),a.url===void 0&&o&&(a.url=typeof o=="function"?o(l):De(o,l)),a.disabled===void 0&&(a.disabled=n!==void 0&&l.page===r.page),k(we,{type:t,"z-go-to-page":l.page,...a})}function ey({key:i,type:e,page:t,text:n="",pagerInfo:s,children:r,...o}){const a=Jr(s,t);return n=typeof n=="function"?n(a):De(n,a),k(Ve,{...o,children:[r,n]})}function Zx({type:i,btnType:e,count:t=12,pagerInfo:n,linkCreator:s,...r}){if(!n.pageTotal)return;const o={...r,square:!0},a=()=>(o.text="",o.icon="icon-ellipsis-h",o.disabled=!0,k(we,{type:e,...o})),l=(h,d)=>{const f=[];for(let p=h;p<=d;p++){o.text=p,delete o.icon,o.disabled=!1;const y=Jr(n,p);s&&(o.url=typeof s=="function"?s(y):De(s,y)),f.push(k(we,{type:e,...o}))}return f};let c=[];return c=[...l(1,1)],n.pageTotal<=1||(n.pageTotal<=t?c=[...c,...l(2,n.pageTotal)]:n.page<t-2?c=[...c,...l(2,t-2),a(),...l(n.pageTotal,n.pageTotal)]:n.page>n.pageTotal-t+3?c=[...c,a(),...l(n.pageTotal-t+3,n.pageTotal)]:c=[...c,a(),...l(n.page-Math.ceil((t-4)/2),n.page+Math.floor((t-4)/2)),a(),...l(n.pageTotal,n.pageTotal)]),c}function Yx({type:i,pagerInfo:e,linkCreator:t,items:n=[5,10,15,20,25,30,35,40,45,50,100,200,500,1e3,2e3],dropdown:s={},menu:r,itemProps:o,...a}){var c;s.items=n.map(h=>{const d={...e,recPerPage:h};return{...o,key:h,text:`${h}`,active:h===e.recPerPage,url:t?typeof t=="function"?t(d):De(t,d):void 0,"z-change-page-size":h}});const{text:l=""}=a;return a.text=typeof l=="function"?l(e):De(l,e),s.menu={...r,...s.menu,className:U((c=s.menu)==null?void 0:c.className,"pager-size-menu")},k(rn,{dropdown:s,...a})}function ty({key:i,page:e,type:t,btnType:n,pagerInfo:s,size:r,onClick:o,onChange:a,linkCreator:l,...c}){const h={...c};let d;const f=b=>{var w;d=Number((w=b.target)==null?void 0:w.value)||1,d=d>s.pageTotal?s.pageTotal:d},p=b=>{if(!(b!=null&&b.target))return;d=d<=s.pageTotal?d:s.pageTotal;const w=Jr(s,d);a&&!a({info:w,event:b})||(b.target.href=h.url=typeof l=="function"?l(w):De(l,w))},y=Jr(s,e||0);return h.url=typeof l=="function"?l(y):De(l,y),k("div",{className:U("input-group","pager-goto-group",r?`size-${r}`:""),children:[k("input",{type:"number",class:"form-control",max:s.pageTotal,min:"1",onInput:f}),k(we,{type:n,...h,onClick:p})]})}const ll=class Xf extends Fe{constructor(){super(...arguments),this._pagerChanges=fe({}),this._changedPager=Ce(()=>Xf.format({...this.props,...this._pagerChanges.value})),this._changeEffect=_t(()=>{const{onChangePageInfo:e}=this.props,t=this._changedPager.value;e&&this._changeEvent&&(e(t,this._changeEvent),this._changeEvent=void 0)}),this._handleClickLink=e=>{const t=v(e.currentTarget);if(t.is(".disabled"))return;const n=t.z("goToPage");typeof n=="number"&&(this._changeEvent=e,this._pagerChanges.value={...this._pagerChanges.value,page:n})},this._handleClickSizeMenu=e=>{const{item:t}=e,n=t["z-change-page-size"];typeof n=="number"&&!t.disabled&&(this._changeEvent=e.event,this._pagerChanges.value={...this._pagerChanges.value,recPerPage:n})}}_isBtnType(e){const{type:t}=e;return super._isBtnType(e)||["link","nav","size-menu","goto"].includes(t)}componentDidUpdate(e){if(this.props.useState)this.props.recTotal!==e.recTotal&&(this._pagerChanges.value={...this._pagerChanges.value,recTotal:this.props.recTotal});else{const{page:t,recTotal:n,recPerPage:s}=this.props;(t!==e.page||n!==e.recTotal||s!==e.recPerPage)&&(this._pagerChanges.value={})}}componentWillUnmount(){this._changeEffect()}_beforeRender(e){return this._pagerInfo=e.useState?this._changedPager.value:Xf.format(e),super._beforeRender(e)}_getItem(e,t,n){const s=super._getItem(e,t,n);if(!s)return!1;const{type:r="item"}=t,o=this._pagerInfo;return r==="info"?v.extend(s,{pagerInfo:o}):(r==="link"||r==="size-menu"||r==="nav"||r==="goto")&&v.extend(s,{pagerInfo:o,linkCreator:e.linkCreator}),r==="size-menu"&&(s.menu={onClickItem:this._handleClickSizeMenu,...s.menu}),r==="link"&&(s.onClick=this._handleClickLink),s}static format(e){const{page:t=1,recTotal:n=0,recPerPage:s=10}=e,r=Math.max(0,+n),o=Math.max(1,+s),a=o?Math.ceil(r/o):0;return{page:Math.min(Math.max(1,+t),a),recTotal:r,recPerPage:o,pageTotal:a}}};ll.NAME="pager",ll.ItemComponents={...Fe.ItemComponents,info:ey,link:Qg,nav:Zx,"size-menu":Yx,goto:ty},ll.defaultItemProps={btnType:"ghost",size:"sm"};let Xr=ll;class Dd extends ve{}Dd.NAME="Pager",Dd.Component=Xr,st(Object.freeze(Object.defineProperty({__proto__:null,Pager:Xr,PagerGoto:ty,PagerInfoItem:ey,PagerLink:Qg},Symbol.toStringTag,{value:"Module"})));const FI="",OI="";class cl extends ve{}cl.NAME="Pick",cl.Component=ot,cl.replace=!0;const BI="",jI="",HI="",UI="";class hl extends ve{}hl.NAME="Picker",hl.Component=Zt,hl.register(),be.addLang({zh_cn:{selectAll:"全选",cancelSelect:"取消选择",searchEmptyHint:"无匹配选项",loadingHint:"正在加载...",exceedLimitHint:"还有 {0} 个选项没有显示,可尝试搜索来查找"},zh_tw:{selectAll:"全選",cancelSelect:"取消選擇",searchEmptyHint:"無匹配選項",loadingHint:"正在載入...",exceedLimitHint:"還有 {0} 個選項沒有顯示,可嘗試搜索來查找"},en:{selectAll:"Select All",cancelSelect:"Cancel Select",searchEmptyHint:"No matching options",loadingHint:"Loading...",exceedLimitHint:"There are {0} items not displayed, try searching to find"}}),st(Ax);const VI="";st(qx);class dl extends qe{init(){this.$element.addClass("fade"),this._tryRender=ca(()=>this.render(),this.options.debounce||20)}afterInit(){this.render(),this.$element.addClass("in");const{watch:e=["container"]}=this.options;let t=!1;const n=e.reduce((s,r)=>{if(r==="window")t=!0;else if(r==="container")s.add(this.getContainer()[0]);else if(r==="self")s.add(this.element);else if(r==="parent"){const o=this.element.parentElement;o&&s.add(o)}else v(r).each((o,a)=>{s.add(a)});return s},new Set);n.size&&(this._observer=Th([...n],()=>{this._tryRender()})),t&&(this._windowResizeHandler=this._tryRender,window.addEventListener("resize",this._windowResizeHandler))}destroy(){var e,t;super.destroy(),(e=this._dropdown)==null||e.destroy(),this.$element.removeClass("rsh-overflowed").find(".rsh-more").remove(),(t=this._observer)==null||t.disconnect(),this._windowResizeHandler&&(window.removeEventListener("resize",this._windowResizeHandler),this._windowResizeHandler=void 0)}render(e,t){super.render(e,t);const n=this.getContainer();if(!n.length)return;const s=this.getContainerSize(n[0]);if(!s)return;const r=this.getItems();if(!r.length)return;const o=this.getMore();o.css({display:"flex",opacity:0});const a=this.getItemSize(o[0]);o.css({display:"none",opacity:0});let l=a,c=!1;this._moreItems=void 0,this._moreElements=[];const h=new Map,{fixedItems:d=".is-rsh-fixed",moreItems:f=".is-rsh-more",showSelected:p}=this.options,y=d?r.filter(d):null,b=y!=null&&y.length?new Set(y):null,w=f?r.filter(f):null,x=w!=null&&w.length?new Set(w):null;if(y!=null&&y.length)for(const D of y)l+=this.getItemSize(D);for(const D of r){const N=v(D),A=b==null?void 0:b.has(D);if(N.toggleClass("rsh-fixed-item",!!A),A||N.hasClass("rsh-more"))continue;const z=N.data("rsh-display")||N.css("display");if(x!=null&&x.has(D)){this._moreElements.push(D),N.css({display:"none"}).addClass("rsh-overflow-item");continue}const O=N.css("opacity");N.data({"rsh-opacity":O,"rsh-display":z}).css({display:z,opacity:0});const K=this.getItemSize(D);h.set(D,K),c||(l+=K),l>s&&(c=!0),c&&this._moreElements.push(D),N.css({opacity:O,display:c?"none":z}).toggleClass("rsh-overflow-item",c)}let T=!!this._moreElements.length;if(c&&!(x!=null&&x.size)){const D=this._moreElements.reduce((N,A)=>{const z=v(A);if(!N&&z.hasClass("divider"))return 0;const O=h.get(A)||0;return N+O},0);if(a>=D){c=!1;for(const N of this._moreElements){const A=v(N);A.css({display:A.data("rsh-display")||"flex",opacity:A.data("rsh-opacity")||1})}this._moreElements=[],T=!1}}this.$element.toggleClass("rsh-has-more-items",T).toggleClass("rsh-overflowed",c),o.css({display:T?"flex":"none",opacity:1}).appendTo(this.$element),T&&p&&this._renderMoreBtn()}getContainer(){const{container:e}=this.options;return e==="parent"?this.$element.parent():e?v(e):this.$element}getContainerSize(e){if(e=e||this.getContainer()[0],!e)return 0;const{getContainerSize:t,scrollbarDetect:n,scrollbarSize:s=10}=this.options;let r=t?t.call(this,e):e.offsetWidth;return n!==!1&&((typeof n=="function"?n:()=>window.innerWidth-document.body.clientWidth)()||(r-=s)),r}getItems(){const{items:e="li",ignoreItems:t}=this.options;let n=this.$element.children(e);return t&&(n=n.not(t)),n}getItemSize(e){const{getItemSize:t}=this.options;if(t)return t.call(this,e);const n=getComputedStyle(e);return e.offsetWidth+parseInt(n.marginLeft)+parseInt(n.marginRight)}getMoreItems(){var o;const{_moreElements:e}=this;if(!(e!=null&&e.length))return[];const{getMoreItem:t=this.getMoreItem.bind(this),getMoreItems:n,mergeDropdown:s}=this.options;if(n)return n.call(this,e);const r=e.reduce((a,l)=>{var h;const c=t.call(this,l);if(c){if(c.type==="divider"&&(!a.length||((h=a[a.length-1])==null?void 0:h.type)==="divider"))return a;if(Array.isArray(c.items)){if(!c.items.length)return a;if(s&&(s===!0||v(l).closest(s).length))return a.length&&a.push({type:"divider"}),a.push(...c.items,{type:"divider"}),a}a.push(c)}return a},[]);return r.length&&((o=r[r.length-1])==null?void 0:o.type)==="divider"&&r.pop(),r}getMoreItem(e){var r,o,a;const t=v(e);if(t.hasClass("divider"))return{type:"divider"};const n=t.children('[data-toggle="dropdown"],[z-use-dropdown],[zui-toggle-dropdown]');if(n.length){let l=Ft.query(n);l||(l=new Ft(n));let c=l.options.items||((r=l.options.menu)==null?void 0:r.items);if(!c&&n.attr("zui-toggle-dropdown")){const h=n.attr("zui-toggle-dropdown"),d=h?Yn(h,["_element",n[0]],["_$element",n]):null;d&&(c=d.items||((o=d.menu)==null?void 0:o.items))}return{items:c,text:n.find(".text").text(),icon:(a=n.find(".icon").attr("class"))==null?void 0:a.replace("icon ","")}}const s=Object.fromEntries(Array.from(e.attributes).map(l=>[l.name,l.value]));return s.style&&(s.style=s.style.replace("display: none;","")),s.class&&(s.class=s.class.replace("nav-item","menu-item")),{type:"node",html:t.html(),attrs:s}}getMore(){var s;let e=this.$element.find(".rsh-more");if(e.length)return e;e=v('<li class="rsh-more item nav-item" style="order:9999"></li>');let t=this.options.more||{html:'<a><span class="more-vert"></span></a>',attrs:{title:be.getLang("more")}};typeof t=="string"&&(t={text:t});const n=v(t.html||"<a></a>").attr({...t.attrs}).addClass("rsh-more-btn");return t.icon&&n.prepend(`<i class="icon ${t.icon}"></i>`),t.text&&n.append(Jm`<span class="text">${t.text}</span>`),t.caret&&n.append('<span class="caret"></span>'),e.append(n),this._dropdown=new Ft(n[0],{placement:"bottom-start",items:this.getMoreItems.bind(this),...this.options.moreDropdown}),this.$element.append(e),(s=this.options.onCreateMore)==null||s.call(this,e,this._dropdown),e}_renderMoreBtn(){const e=this.$element.find(".rsh-more-btn"),{showSelected:t}=this.options;if(!e.length||!t)return;e.data("originHTML")||e.data("originHTML",e.html());const n=v(this._moreElements).filter(t===!0?(r,o)=>{const a=v(o);return a.is(".active,.selected")||!!a.children(".active,.selected").length}:t),s=!!n.length;e.toggleClass("active",s),s?(e.empty().append(n.children().html()),e.find('.caret,[class*="caret"]').length||e.append('<span class="caret"></span>')):e.html(e.data("originHTML"))}}dl.DEFAULT={showSelected:!0},dl.NAME="ResponsiveNavHelper",dl.register();class ul extends ve{}ul.NAME="SearchBox",ul.Component=vs,ul.register(),st(GC);function Id(i,e){const[t,n]=In(i);return n==="%"?e*t/100:t}const ny="is-sidebar-resizing",sy="has-sidebar-animation",Md="is-animating",fl=".sidebar-gutter";let Qr=class extends qe{get side(){return this._side}get width(){return this._width}get $parent(){const{parent:e}=this.options;return e?v(e):this.$element.parent()}afterInit(){const{$element:e}=this,t=e.parent(),n=t[0],s=t.width();this._container=n;const{preserve:r,side:o=e.hasClass("sidebar-right")?"right":"left",animation:a,dragToResize:l,width:c,minWidth:h=0,maxWidth:d=Number.MAX_SAFE_INTEGER,toggleBtn:f,dbclick:p}=this.options;this._storeID=r?`SIDEBAR:${r}:width`:"",this._side=o,this._minWidth=Id(h,s),this._maxWidth=Id(d,s),this._defaultWidth=Math.max(this._minWidth,Math.min(this._maxWidth,Id(c||e.width(),s))),this._width=(r?nt.get(this._storeID):null)??this._defaultWidth,this.render(),f&&e.on(`click${this.namespace}`,".gutter-toggle",()=>this.toggle()),p&&e.on(`dblclick${this.namespace}`,fl,()=>{p==="reset"?this.update(this._defaultWidth):this.toggle()}).on("mousedown",fl,y=>{y.preventDefault()}),l&&(this._moveable=new _s(e,{selector:fl,move:!1,onMoveStart:()=>{this._startWidth=this._width,this.$parent.addClass(ny).removeClass(sy)},onMove:(y,b)=>{const{deltaX:w}=b;Math.abs(w)<10||this.update(this._startWidth+w*(o==="left"?1:-1))},onMoveEnd:()=>{a&&this.$parent.addClass(sy),this.$parent.removeClass(ny)}})),a&&this.on("transitionend",y=>{y.target===e[0]&&y.propertyName==="width"&&e.removeClass(Md)})}destroy(){var e;super.destroy(),this._raf&&cancelAnimationFrame(this._raf),(e=this._moveable)==null||e.destroy()}toggle(e){e=e??!!this._width,e&&(this._widthBack=this._width),this.update(e?0:this._widthBack||this._defaultWidth)}update(e,t){if(!t){this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=0,this.update(e,!0)});return}const{preserve:n,toggleBtn:s,onResize:r,onToggle:o,animation:a}=this.options;if(e=e<this._minWidth?s?0:this._minWidth:Math.min(this._maxWidth,e,this._container.clientWidth),e===this._width)return;const l=!this._width,c=!e;this._width=e,n&&nt.set(this._storeID,e),this.render(),r==null||r(e),l!==c&&(l&&a&&this.$element.addClass(Md),o==null||o(c)),this.emit("sidebarResize",e)}render(){var h;const{side:e,width:t,$element:n,$parent:s}=this,r=!t,{toggleBtn:o,gutterWidth:a=In(n.parent().css("gap"))[0]||1,animation:l}=this.options;n.addClass(`sidebar-${e}`).toggleClass("is-collapsed",r).toggleClass("is-expanded",!r).css({"--gutter-width":`${a}px`,width:`var(--sidebar-${e}-width)`,"--sidebar-duration":typeof l=="number"?`${l}ms`:null});let c=n.find(fl);c.length||(c=v('<div class="sidebar-gutter gutter gutter-horz"></div>').appendTo(n)),o?c.children(".gutter-toggle").length||c.append(`<button class="gutter-toggle" type="button"><span class="chevron-${e}"></span></button>`):c.children(".gutter-resize-handler").length||c.append('<div class="gutter-resize-handler"></div>'),s.addClass(`has-sidebar-${e}`).css(`--sidebar-${e}-width`,`${t}px`).toggleClass(`is-sidebar-${e}-collapsed`,r),(h=this._moveable)!=null&&h.state&&n.removeClass(Md)}};Qr.NAME="Sidebar",Qr.DEFAULT={minWidth:40,toggleBtn:!0,animation:!0,dragToResize:!0,dbclick:"reset"};const WI="",KI="",qI="";class Nd extends ve{}Nd.NAME="Toolbar",Nd.Component=Fe,st(OC);const GI="";class pl extends ve{}pl.NAME="Tree",pl.Component=zt,pl.replace=zt.TAG;class Ed extends ve{}Ed.NAME="SearchTree",Ed.Component=Zs,st(s0);const ZI="",YI="",JI="",XI="";class ml extends qe{init(){const{multiple:e,defaultFileList:t,limitSize:n}=this.options;this.fileMap=new Map,this.renameMap=new Map,this.itemMap=new Map,this.dataTransfer=new DataTransfer,this.limitBytes=n?$n(n):Number.MAX_VALUE,this.currentBytes=0,e||(this.options.limitCount=1),this.$element.addClass("upload"),this.initFileInputCash(),this.initUploadCash(),t&&this.addFileItem(t)}initUploadCash(){const{name:e,uploadText:t,uploadIcon:n,listPosition:s,btnClass:r,tip:o,draggable:a}=this.options;this.$list=v('<ul class="file-list py-1"></ul>');const l=v(`<span class="upload-tip">${o}</span>`);if(!a){if(this.$label=v(`<label class="btn ${r}" for="${e}">${t}</label>`),n){const f=v(`<i class="icon icon-${n}"></i>`);this.$label.prepend(f)}const d=s==="bottom"?[this.$label,l,this.$list]:[this.$list,this.$label,l];this.$element.append(this.$input,...d);return}const c=v(`<span class="text-primary">${t}</span>`);if(n){const d=v(`<i class="icon icon-${n} mr-1"></i>`);c.prepend(d)}this.$label=v(`<label class="draggable-area col justify-center items-center cursor-pointer block w-full h-16" for="${e}"></label>`).append(c).append(l),this.bindDragEvent();const h=s==="bottom"?[this.$label,this.$list]:[this.$list,this.$label];this.$element.append(this.$input,...h)}bindDragEvent(){this.$label.on("dragover",e=>{e.preventDefault(),this.$label.hasClass("border-primary")||(this.$label.removeClass("border-gray"),this.$label.addClass("border-primary")),this.$label.hasClass("dragover")||this.$label.addClass("dragover")}).on("dragleave",e=>{e.preventDefault(),this.$label.removeClass("border-primary"),this.$label.addClass("border-gray"),this.$label.removeClass("dragover")}).on("drop",e=>{var n;e.preventDefault(),this.$label.removeClass("border-primary"),this.$label.addClass("border-gray"),this.$label.removeClass("dragover");const t=Array.from(((n=e.dataTransfer)==null?void 0:n.files)??[]);console.log(e.dataTransfer.files),this.addFileItem(t)})}initFileInputCash(){const{name:e,multiple:t,accept:n}=this.options;this.$input=v("<input />").addClass("hidden").prop("type","file").prop("name",e).prop("id",e).prop("multiple",t).on("change",s=>{const r=s.target.files;if(!r)return;const o=[...r];this.addFileItem(o)}),n&&this.$input.prop("accept",n)}addFile(e){const{multiple:t,onSizeChange:n}=this.options;t||(this.renameMap.clear(),this.fileMap.clear(),this.dataTransfer.items.clear(),this.currentBytes=e.size),this.renameMap.set(e.name,e.name),this.fileMap.set(e.name,e),this.dataTransfer.items.add(e),this.$input.prop("files",this.dataTransfer.files),this.currentBytes+=e.size,n==null||n(this.currentBytes)}renameDuplicatedFile(e){if(!this.fileMap.has(e.name))return e;const t=e.name.lastIndexOf(".");if(t===-1)return this.renameDuplicatedFile(new File([e],`${e.name}(1)`));const n=e.name.substring(0,t),s=e.name.substring(t);return this.renameDuplicatedFile(new File([e],`${n}(1)${s}`))}filterFiles(e){const{accept:t}=this.options;if(!t)return e;const n=t.replace(/\s/g,"").split(","),s=[],r=[],o=[];return n.forEach(a=>{a.endsWith("/*")?r.push(a.substring(0,a.length-1)):a.includes("/")?s.push(a):a.startsWith(".")&&o.push(a)}),e.filter(a=>s.includes(a.type)||r.some(l=>a.type.startsWith(l))||o.some(l=>a.name.endsWith(l)))}addFileItem(e){e=this.filterFiles(e);const{multiple:t,limitCount:n,exceededSizeHint:s,onExceededSize:r,exceededCountHint:o,onExceededCount:a,onAdd:l}=this.options;if(t){for(let f of e){if(n&&this.fileMap.size>=n){a==null||a(n),o&&alert(o);return}if(this.currentBytes+f.size>this.limitBytes){r==null||r(this.limitBytes),s&&alert(s);return}f=this.renameDuplicatedFile(f);const p=l==null?void 0:l(f);if(!p)continue;f=p;const y=this.createFileItem(f);this.itemMap.set(f.name,y),this.$list.append(y)}return}if(e.length===0||e[0].size>this.limitBytes)return;let c=this.renameDuplicatedFile(e[0]);const h=l==null?void 0:l(c);if(!h)return;c=h;const d=this.createFileItem(c);this.itemMap.clear(),this.itemMap.set(c.name,d),this.$list.empty().append(d)}deleteFileItem(e){var l,c;const t=this.renameMap.get(e)??e;this.renameMap.delete(e);const n=this.fileMap.get(t);if(!n)return;const{onDelete:s,onSizeChange:r}=this.options,o=this.itemMap.get(n.name);this.itemMap.delete(n.name),o==null||o.addClass("hidden");const a=(l=o==null?void 0:o.find(".file-delete"))==null?void 0:l.data("tooltip");a&&(a.destroy(),(c=a.tooltip)==null||c.remove()),setTimeout(()=>o==null?void 0:o.remove(),3e3),s==null||s(n),this.fileMap.delete(n.name),this.currentBytes-=n.size,r==null||r(this.currentBytes),this.dataTransfer=new DataTransfer,this.fileMap.forEach(h=>this.dataTransfer.items.add(h)),this.$input.prop("files",this.dataTransfer.files)}renameFileItem(e,t){var r,o;const n=this.renameMap.get(e.name);this.renameMap.set(e.name,t),n&&(e=this.fileMap.get(n)??e);const s=this.itemMap.get(e.name);s&&(this.itemMap.set(t,s).delete(e.name),(o=(r=this.options).onRename)==null||o.call(r,t,e.name),this.fileMap.delete(e.name),this.dataTransfer=new DataTransfer,e=new File([e],t),this.fileMap.set(t,e).forEach(a=>this.dataTransfer.items.add(a)),this.$input.prop("files",this.dataTransfer.files))}createFileItem(e){const{showIcon:t}=this.options;return this.addFile(e),v('<li class="file-item my-1 flex items-center gap-2"></li>').append(t?this.fileIcon():null).append(this.createFileInfo(e)).append(this.createRenameContainer(e))}fileIcon(){const{icon:e}=this.options;return v(`<i class="icon icon-${e}"></i>`)}fileRenameBtn(){const{useIconBtn:e,renameText:t,renameIcon:n,renameClass:s}=this.options;if(e){const r=v(`<button class="btn btn-link h-5 w-5 p-0 ${s}"><i class="icon icon-${n}"></i></button>`).prop("type","button").addClass("file-action file-rename");return new Xs(r,{title:t}),r}return v("<button />").prop("type","button").addClass(`btn size-sm rounded-sm text-primary canvas file-action file-rename ${s}`).html(t)}fileDeleteBtn(){const{useIconBtn:e,deleteText:t,deleteIcon:n,deleteClass:s}=this.options;if(e){const r=v(`<button class="btn btn-link h-5 w-5 p-0 ${s}"><i class="icon icon-${n}"></i></button>`).prop("type","button").addClass("file-action file-delete");return r.data("tooltip",new Xs(r,{title:t})),r}return v("<button />").html(t).prop("type","button").addClass(`btn size-sm rounded-sm text-primary canvas file-action file-delete ${s}`)}fileName(e){return v(`<span class="file-name">${e}</span>`)}fileSize(e){return v(`<span class="file-size text-gray">${pt(e)}</span>`)}createFileInfo(e){const{renameBtn:t,deleteBtn:n,showSize:s}=this.options,r=v('<div class="file-info flex items-center gap-2"></div>');return r.append(this.fileName(e.name)),s&&r.append(this.fileSize(e.size)),t&&r.append(this.fileRenameBtn().on("click",o=>{r.addClass("hidden").closest(".file-item").find(".input-rename-container.hidden").removeClass("hidden");const a=v(o.target).closest("li").find("input")[0];a.focus(),a.value.lastIndexOf(".")!==-1&&a.setSelectionRange(0,a.value.lastIndexOf("."))})),n&&r.append(this.fileDeleteBtn().on("click",()=>this.deleteFileItem(e.name))),r}createRenameContainer(e){const{confirmText:t,cancelText:n,duplicatedHint:s,onDuplicated:r}=this.options,o=v('<div class="input-group input-rename-container hidden"></div>'),a=v("<input />").addClass("form-control").prop("type","text").prop("autofocus",!0).prop("defaultValue",e.name).on("keydown",d=>{if(d.key==="Enter"){const f=o.closest(".file-item"),p=f.find(".file-name");if(p.html()===a.val()){o.addClass("hidden"),f.find(".file-info.hidden").removeClass("hidden");return}if(this.fileMap.has(a.val())){r==null||r(a.val()),s&&alert(s);return}this.renameFileItem(e,a.val()),o.addClass("hidden"),f.find(".file-info.hidden").removeClass("hidden"),p.html(a.val())}else d.key==="Escape"&&(a.val(e.name),o.addClass("hidden").closest(".file-item").find(".file-info.hidden").removeClass("hidden"))}),l=v("<button />").addClass("btn primary rename-confirm-btn").prop("type","button").html(t).on("click",()=>{const d=o.closest(".file-item"),f=d.find(".file-name");if(f.html()===a.val()){o.addClass("hidden"),d.find(".file-info.hidden").removeClass("hidden");return}if(this.fileMap.has(a.val())){r==null||r(a.val()),s&&alert(s);return}this.renameFileItem(e,a.val()),o.addClass("hidden"),d.find(".file-info.hidden").removeClass("hidden"),f.html(a.val())}),c=v("<button />").prop("type","button").addClass("btn rename-cancel-btn").html(n).on("click",()=>{a.val(e.name),o.addClass("hidden").closest(".file-item").find(".file-info.hidden").removeClass("hidden")}),h=v('<div class="btn-group"></div').append(l).append(c);return o.append(a).append(h)}}ml.NAME="Upload",ml.DEFAULT={uploadText:"上传文件",confirmText:"确定",cancelText:"取消",useIconBtn:!0,renameBtn:!0,renameText:"重命名",renameIcon:"edit",renameClass:"",deleteBtn:!0,deleteText:"删除",deleteIcon:"trash",deleteClass:"",showIcon:!0,multiple:!0,listPosition:"bottom",limitSize:!1,icon:"file-o",btnClass:"",tip:"",draggable:!1,showSize:!0,onAdd:i=>i};const QI="";class Ad extends ml{init(){this.initUploadButtonItemCash(),this.options.onSizeChange=()=>{this.$uploadInfo.html(this.options.totalCountText.replace("%s",this.fileMap.size.toString()).replace("%s",this.fileMap.size.toString())),this.fileMap.size>0?(this.$tip.remove(),this.$list.append(this.$uploadButtonItem)):(this.$uploadButtonItem.remove(),this.$label.append(this.$tip))},super.init(),this.$list.addClass("flex")}initUploadButtonItemCash(){this.$uploadButtonItem=v(`<label class="upload-button-item order-last" for="${this.options.name}" />`).addClass("flex justify-center items-center cursor-pointer").css({width:120,height:120,background:"var(--color-slate-100)"}).append(v('<i class="icon icon-plus" />'))}initUploadCash(){const{name:e,tip:t,uploadText:n,uploadIcon:s,totalCountText:r}=this.options;this.$list=v('<ul class="file-list py-1 flex-wrap gap-x-4 gap-y-4"></ul>'),this.$label=v('<div class="draggable-area relative block w-full border border-dashed border-gray"></div>').css({minHeight:64});const o=v(`<label for="${e}" class="text-primary cursor-pointer">${n}</label>`);if(s){const a=v(`<i class="icon icon-${s} mr-1"></i>`);o.prepend(a)}this.$tip=v('<div class="absolute inset-0 col justify-center items-center"></div>').append(o),t&&this.$tip.append(v(`<span class="upload-tip">${t}</span>`)),this.$label.append(this.$tip),this.$label.append(this.$input,this.$list),this.bindDragEvent(),this.$element.append(this.$label),this.$uploadInfo=v('<div class="py-1" />').css({color:"var(--color-slate-500)"}).html(r.replace("%s",this.fileMap.size.toString()).replace("%s",this.fileMap.size.toString())),this.$element.append(this.$uploadInfo)}filterFiles(e){const{accept:t}=this.options;if(t==="image/*")return e.filter(s=>s.type.includes("image"));const n=t.replace(/\s/g,"").replace(/\./g,"image/").split(",");return e.filter(s=>n.includes(s.type))}createFileItem(e){const t=super.createFileItem(e).addClass("relative").removeClass("flex items-center gap-2 my-1");this.setImageUrl(e,t);const{deleteBtn:n,showSize:s}=this.options;return n&&t.append(this.fileDeleteBtn().addClass("absolute right-0 top-0 text-white").css({background:"var(--color-slate-500)"}).on("click",()=>this.deleteFileItem(e.name))),s&&t.append(this.fileSize(e.size).addClass("file-size label text-white circle darker absolute px-1 hidden").removeClass("text-gray").css({top:96,left:4})),t}setImageUrl(e,t){const n=new FileReader;n.onload=()=>{v('<div class="img flex-none" />').addClass("rounded").css({backgroundImage:`url(${n.result})`,backgroundSize:"cover"}).prependTo(t)},n.readAsDataURL(e)}createFileInfo(e){const t=this.fileRenameBtn().addClass("flex-none").on("click",s=>{const r=v(s.target).closest(".file-item");r.find(".file-info").addClass("hidden"),r.find(".input-rename-container").removeClass("hidden");const o=r.find("input")[0];o.focus(),o.value.lastIndexOf(".")!==-1&&o.setSelectionRange(0,o.value.lastIndexOf("."))});return v('<div class="file-info flex justify-between items-center"></div>').css({width:120}).append(v(`<div class="file-name py-1 ellipsis">${e.name}</div>`)).append(t)}createRenameContainer(e){const{duplicatedHint:t,onDuplicated:n}=this.options,s=v("<input />").addClass("input-rename-container border-primary border hidden").prop("type","text").prop("autofocus",!0).prop("defaultValue",e.name).css({width:120}).on("keydown",r=>{if(r.key==="Enter"){const o=s.closest(".file-item").find(".file-name");if(o.html()===s.val()){s.addClass("hidden"),o.closest(".file-info").removeClass("hidden");return}if(this.fileMap.has(s.val())){n==null||n(s.val()),t&&alert(t);return}this.renameFileItem(e,s.val()),s.addClass("hidden"),o.html(s.val()).closest(".file-info").removeClass("hidden")}else r.key==="Escape"&&s.val(e.name).addClass("hidden").closest(".file-item").find(".file-name").removeClass("hidden")}).on("blur",()=>{const r=s.closest(".file-item").find(".file-name");if(r.html()===s.val()){s.addClass("hidden"),r.closest(".file-info").removeClass("hidden");return}if(this.fileMap.has(s.val())){n==null||n(s.val()),t&&alert(t);return}this.renameFileItem(e,s.val()),s.addClass("hidden"),r.html(s.val()).closest(".file-info").removeClass("hidden")});return s}}Ad.NAME="UploadImgs",Ad.DEFAULT={uploadText:"添加文件",renameBtn:!0,renameText:"重命名",renameIcon:"edit",renameClass:"",deleteBtn:!0,deleteText:"删除",deleteIcon:"trash",deleteClass:"",showIcon:!1,multiple:!0,limitSize:!1,btnClass:"",draggable:!0,accept:"image/jpg, image/jpeg, image/gif, image/png",showSize:!0,useIconBtn:!0,totalCountText:'共 <span class="font-bold text-black">%s</span> 个文件 <span class="font-bold text-black">%s</span> 个文件等待上传。'};class Jx extends re{constructor(){super(...arguments),this._element=pe()}get sidebar(){return this._sidebar}componentDidMount(){const{current:e}=this._element;if(e){const{className:t,style:n,children:s,contentClass:r,contentStyle:o,...a}=this.props;this._sidebar=new Qr(e,a)}}componentWillUnmount(){var e;(e=this._sidebar)==null||e.destroy()}render(e){const{className:t="w-40",side:n="left",style:s,children:r,contentClass:o,contentStyle:a}=e;return k("div",{ref:this._element,className:U(`sidebar side-bar-${n}`,t),style:s,children:k("div",{className:U("sidebar-content",o),style:a,children:r})})}}class Xx extends Ve{_getClassName(e){return[super._getClassName(e),"container-with-side"]}}const Qx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ot=(i=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(i|=0));for(;i--;)e+=Qx[t[i]&63];return e};const ek={newChat:"新对话",recentChats:"最近对话",untitledChat:"未命名对话",deleteChat:"删除对话",sendboxPlaceholder:"输入消息...",noMessagesTip:"暂无消息,快来跟我对话吧~",selectChatTip:"请从左侧选择一个对话",deleteConfirm:"确定删除对话“{title}”吗?",close:"关闭",send:"发送",rename:"重命名",copy:"复制",copied:"已复制",maximize:"最大化",minimize:"最小化",loading:"加载中...",searchChats:"搜索对话",selectModel:"选择模型",defaultModel:"默认模型",processing:"正在处理...",thinking:"正在思考...",thinkCompleted:"思考完成",updateTitle:"更新标题",timeConsuming:"耗时{time}s",completed:"已完成",toolCalling:"调用工具",functionCallingConfirm:"确定要执行该工具吗?",noChatModelHint:"没有可用的对话模型,请检查模型配置",needSubmitFormFirst:"请先填写并提交表单",formSubmitted:"已提交表单",toolCallingStatus:{wait:"等待执行",running:"执行中...",finished:"已完成",error:"错误",cancelled:"已取消"},toolCallingMessages:{wait:"正在生成数据...",running:"正在执行...",finished:"已完成",error:"发生了错误",cancelled:"用户已终止执行"},dateGroup:{today:"今天",yesterday:"昨天",thisMonth:"本月",thisWeek:"本周",other:"其他"},errors:{loadDataFailed:"加载数据失败,请稍后重试",loadChatFailed:"加载对话数据失败",createChatFailed:"创建对话失败,请稍后重试",postMessageFailed:"请求失败,请稍后重试","Internal Server Error":"服务器错误,请稍后重试",unauthorized:"未授权,请联系管理员检查应用 ID 和应用密钥",configNotValid:"配置不正确,请联系管理员检查配置",zaiConfigNotValid:"ZAI 配置不正确,ZAI 服务地址、应用 ID 和应用 Token 不能为空,请联系管理员检查配置",code:{invalid_api_key:"授权失败,无效的 API 密钥,请联系管理员检查应用 ID 和应用密钥"}},zentaoAgentResult:{changeTitleFormat:"变更{type} {id}",dataListSizeInfo:"共 {0} 条数据",notSupportPreview:"暂不支持预览该内容",changeProp:"属性",changeDetail:"变更详情",applyFormFormat:"应用到{0}表单",applyFormSuccess:"已成功应用到{0}表单"},taskStatus:{wait:"未开始",doing:"进行中",done:"待验收",fail:"执行失败",closed:"已关闭",cancel:"已取消"},taskNoMessagesTip:"暂无消息。",taskStatusMessage:{wait:"执行等待中,请稍后查看。",doing:"任务正在执行..."},taskVerifyTip:"请输入补充要求",taskVerifyPass:"验收通过",taskVerifyPassFailed:"验收失败,请稍后重试",taskVerifyPassSuccess:"验收通过成功",taskVerifyRefine:"继续完善"},tk={newChat:"新對話",untitledChat:"未命名對話",deleteChat:"刪除對話",sendboxPlaceholder:"輸入訊息...",noMessagesTip:"尚無訊息,快來跟我對話吧~",selectChatTip:"請從左側選擇一個對話",deleteConfirm:"確定刪除對話“{title}”嗎?",close:"關閉",send:"發送",rename:"重命名",copy:"複製",copied:"已複製",maximize:"最大化",minimize:"最小化",loading:"加載中...",searchChats:"搜索對話",selectModel:"選擇模型",defaultModel:"預設模型",processing:"正在處理...",thinking:"正在思考...",thinkCompleted:"思考完成",updateTitle:"更新標題",timeConsuming:"耗時{time}s",completed:"已完成",toolCalling:"調用工具",functionCallingConfirm:"確定要執行該工具嗎?",noChatModelHint:"沒有可用的對話模型,請檢查模型配置",needSubmitFormFirst:"請先填寫並提交表單",formSubmitted:"已提交表單",toolCallingStatus:{wait:"等待執行",running:"執行中...",finished:"已完成",error:"錯誤",cancelled:"已取消"},toolCallingMessages:{wait:"正在生成數據...",running:"正在執行...",finished:"已完成",error:"發生了錯誤",cancelled:"用戶已終止執行"},dateGroup:{today:"今天",yesterday:"昨天",thisMonth:"本月",thisWeek:"本周",other:"其他"},errors:{loadDataFailed:"加載數據失敗,請稍後重試",loadChatFailed:"加載對話數據失敗,請稍後重試",createChatFailed:"創建對話失敗,請稍後重試",postMessageFailed:"請求失敗,請稍後重試","Internal Server Error":"服務器錯誤,請稍後重試",unauthorized:"未授權,請聯系管理員檢查應用 ID 和應用密鑰",configNotValid:"配置不正確,請聯系管理員檢查配置",zaiConfigNotValid:"ZAI 配置不正確,ZAI 服務地址、應用 ID 和應用 Token 不能為空,請聯系管理員檢查配置",code:{invalid_api_key:"授權失敗,無效的 API 密鑰,請聯系管理員檢查應用 ID 和應用密鑰"}},zentaoAgentResult:{changeTitleFormat:"變更{type} {id}",dataListSizeInfo:"共 {0} 條數據",notSupportPreview:"暫不支持預覽該內容",changeProp:"屬性",changeDetail:"變更詳情",applyFormFormat:"應用到{0}表單",applyFormSuccess:"已成功應用到{0}表單"},taskStatus:{wait:"未開始",doing:"進行中",done:"待驗收",fail:"執行失敗",closed:"已關閉",cancel:"已取消"},taskNoMessagesTip:"尚無消息。",taskStatusMessage:{wait:"執行等待中,請稍後查看。",doing:"任務正在執行..."},taskVerifyTip:"請輸入補充要求...",taskVerifyPass:"驗收通過",taskVerifyPassFailed:"驗收失敗,請稍後重試",taskVerifyPassSuccess:"驗收通過成功",taskVerifyRefine:"繼續完善"},nk={newChat:"New Chat",untitledChat:"Untitled Chat",deleteChat:"Delete Chat",sendboxPlaceholder:"Enter message...",noMessagesTip:"No messages yet, let's chat with me~",selectChatTip:"Please select a chat from the left panel.",deleteConfirm:'Are you sure you want to delete the chat "{title}"?',close:"Close",send:"Send",rename:"Rename",copy:"Copy",copied:"Copied",maximize:"Maximize",minimize:"Minimize",loading:"Loading...",searchChats:"Search chats",selectModel:"Select Model",defaultModel:"Default Model",processing:"Processing...",thinking:"Thinking...",thinkCompleted:"Thinking completed",updateTitle:"Update Title",timeConsuming:"Time consuming {time}s",completed:"Completed",toolCalling:"Call Tools",functionCallingConfirm:"Are you sure you want to execute the tool?",noChatModelHint:"No chat model available, please check the model configuration",needSubmitFormFirst:"Please fill in the form and submit it first",formSubmitted:"Form submitted",toolCallingStatus:{wait:"Waiting",running:"Running...",finished:"Completed",error:"Error",cancelled:"Cancelled"},toolCallingMessages:{wait:"Generating data...",running:"Running...",finished:"Completed",error:"Error",cancelled:"Cancelled"},dateGroup:{today:"Today",yesterday:"Yesterday",thisMonth:"This Month",thisWeek:"This Week",other:"Other"},errors:{loadDataFailed:"Load data failed, try again later.",loadChatFailed:"Load chat failed, try again later.",createChatFailed:"Create chat failed, try again later.",postMessageFailed:"Request failed, try again later.","Internal Server Error":"Server error, try again later.",unauthorized:"Unauthorized, please contact the administrator to check the application ID and application key.",configNotValid:"Config is not valid, please contact the administrator to check the config.",zaiConfigNotValid:"ZAI config is not valid, ZAI service address, application ID and application token cannot be empty, please contact the administrator to check the config.",code:{invalid_api_key:"Authorization failed, invalid API key, please contact the administrator to check the application ID and application key."}},zentaoAgentResult:{changeTitleFormat:"Change {type} {id}",dataListSizeInfo:"Total {0} items",notSupportPreview:"Not supported preview this content",changeProp:"Property",changeDetail:"Change detail",applyFormFormat:"Apply to {0} form",applyFormSuccess:"Successfully applied to {0} form"},taskStatus:{wait:"Waiting",doing:"Doing",done:"Pending review",fail:"Failed",closed:"Closed",cancel:"Canceled"},taskNoMessagesTip:"No messages yet.",taskStatusMessage:{wait:"Execution waiting, please check later.",doing:"Task is running..."},taskVerifyTip:"Please enter the supplement requirements...",taskVerifyPass:"Pass review",taskVerifyPassFailed:"Review failed, please try again later.",taskVerifyPassSuccess:"Review passed successfully",taskVerifyRefine:"Continue to improve"};be.addLang({zh_cn:{ai:ek},zh_tw:{ai:tk},en:{ai:nk}});function Se(i,e,t){return be.getLang(`ai.${i}`,e,t)}class eo{constructor(e){this._alias=Ce(()=>{const t=this._options$.value.alias;return t!=null&&t.length?new Set(Array.isArray(t)?t:[t]):new Set}),this._options$=fe(e)}get code(){return this._options$.value.code}get name(){return this._options$.value.name}get desc(){return this._options$.value.desc}get icon(){return this._options$.value.icon}get options(){return this._options$.value}get tools(){return this._options$.value.tools}get welcome(){return this._options$.value.welcome}get alias(){return this._alias.value}getTitle(e,t){const n=this.options.title;return typeof n=="function"?n(e,t||{}):n??e}getPrompt(e,t){const n=this.options.prompt;return typeof n=="function"?n(e,t||{}):n??e}getMemory(e,t){const n=this.options.memory;return typeof n=="function"?n(e,t||{}):n??void 0}getTools(e){const t=this.options.tools;return typeof t=="function"?t.call(this,e):t||[]}static define(e,t){return new eo({code:e,name:e,...t})}}function sk(i){return Object.fromEntries(Object.entries(i).map(([e,t])=>[e,new eo({...t,code:e})]))}const gl=class xn{constructor(e){var t;this._methods={},this._events={},this._contextProviders={},this._options$=fe({...e}),this._agents$=fe(sk(e.agents||{})),this._suggestions$=fe(e.suggestions||[]),this._methods={...e.methods},this._events={...e.events},this._i18n={...e.i18n},(t=e.contextProviders)==null||t.forEach(this.defineContextProvider.bind(this))}get code(){return this._options$.value.code}get name(){return this.tryGetLangText(this._options$.value.name)}get desc(){return this.tryGetLangText(this._options$.value.desc)}get icon(){return this._options$.value.icon}get options(){return this._options$.value}get agents(){return this._agents$.value}get suggestions(){return this._suggestions$.value}get methods(){return this._methods}get events(){return this._events}get contextProviders(){return Object.values(this._contextProviders)}tryGetLangText(e){if(!(e!=null&&e.length))return e;if(e.startsWith("{{")&&e.endsWith("}}")){const t=e.slice(2,-2).trim();return this.getLang(t,[],e)}return e}getLang(e,t,n){return be(this._i18n,e,t,n)}getAgent(e){return this._agents$.value[e]||Object.values(this._agents$.value).find(t=>t.alias.has(e))}defineAgent(e,t){const n=this.agents;return this._agents$.value={...n,[e]:new eo({...t,code:e})},this}formatCommand(e,t){return e[0]==="."?e=`${t}~${this.code}${e}`:e[0]==="~"&&(e=`${t}${e}`),e}defineSuggestion(e){return this._suggestions$.value=[...this.suggestions,e],this}getSuggestions(e){return this.suggestions.reduce((t,n)=>{if(!n.when||n.when(e)){const{command:s,title:r,items:o,hint:a,...l}=n,c={...l,_plugin:this.code,command:typeof s=="string"?this.formatCommand(s,e.commandScope):s,title:this.tryGetLangText(r)??r,hint:this.tryGetLangText(a)??a};if(o){const h=typeof o=="function"?o(e):o;Array.isArray(h)&&h.forEach(d=>{(!d.when||d.when(e))&&t.push({...c,...d})})}else t.push(c)}return t},[])}getContextProviderFromDefinition(e){const{code:t,title:n,hint:s,...r}=e;return{...r,$provider:!0,code:t,plugin:this.code,title:this.tryGetLangText(n)??n,hint:this.tryGetLangText(s)??s}}defineContextProvider(e){const t=this.getContextProviderFromDefinition(e);return this._contextProviders[t.code]=t,this}defineMethod(e,t){return this._methods[e]=t,this}callMethod(e,t,...n){var s;return(s=this._methods[t])==null?void 0:s.call(this,e,...n)}bindEvent(e,t){return this._events[e]=t,this}triggerEvent(e,t,n){var s;(s=this._events[t])==null||s.call(this,e,n)}attach(e){return this.callCallback("onAttach",e)}detach(e){return this.callCallback("onDetach",e)}defineCallback(e,t){return this._options$.value[e]=t,this}hasCallback(e){return!!this._options$.value[e]}callCallback(e,...t){const n=this._options$.value[e];if(n)return n.apply(this,t)}getToolsMap(){const e=new Map,t=(n,s)=>{if(Array.isArray(n)){n.forEach(o=>t(o,s));return}s=Array.isArray(s)?s:[s];const r=e.get(n)||[];e.set(n,[...r,...s])};return Object.entries(this._agents$.value).forEach(([n,{name:s,tools:r,alias:o}])=>{!(r!=null&&r.length)||!Array.isArray(r)||(t([`@${s}`,`@${n}`,...Array.from(o).map(a=>`@${a}`)],r),r.forEach(a=>{t(`@${s}/${a.name}`,a);const{shortcuts:l=!0}=a;l&&t(l===!0?a.name:l,a)}))}),e}static use(e){return e==="ALL"?xn.all.value:(e=Array.isArray(e)?e:[e],e.reduce((t,n)=>{if(typeof n=="string"){const s=xn.map.value.get(n);s&&(n=s)}else typeof n=="object"&&!(n instanceof xn)&&(n=new xn(n));return n instanceof xn?t.push(n):console.warn(`[AIPlugin] Use invalid plugin: ${n}`),t},[]))}static define(e,t){const n=new xn({...t,code:e});return xn.all.value=[...xn.all.value,n],n}static remove(e){const t=xn.all.value,n=t.findIndex(s=>s.code===e);n!==-1&&(t.splice(n,1),xn.all.value=[...t])}};gl.all=fe([]),gl.map=Ce(()=>{const i=gl.all.value;return new Map(i.map(e=>[e.code,e]))});let Pd=gl;function iy(i=[],e){const{noDisabled:t}=e||{},n=[...i],s=[],r=new Set;for(let o=n.length-1;o>=0;o--){const a=n[o];if(t&&a.disabled)continue;const{code:l}=a;r.has(l)||(r.add(l),s.unshift(a))}return s}function ry(i,e){var s,r;const t=((s=e.$local)==null?void 0:s.tools)||[],n=((r=i.$local)==null?void 0:r.tools)||[];return{...i,...e,$local:{...i.$local,...e.$local,tools:Array.from(new Set([...n,...t]))},custom_data:{...i.custom_data,...e.custom_data},settings:{...i.settings,...e.settings}}}const ls="$global";function ik(i,e){const{globalMemory:t}=e||{};i=Array.isArray(i)?i:[i];const n={collections:[],content_filter:{}},s=new Set;for(const r of i){r.collections.forEach(h=>{h===ls&&t&&(h=t),!(!h||s.has(h))&&(s.add(h),n.collections.push(h))});const{attrs:o,...a}=n.content_filter||{},{attrs:l,...c}=r.content_filter||{};n.content_filter=v.extend(!0,a,c),o&&l?(Object.keys(l).forEach(h=>{const d=l[h];let f=o[h];f===void 0?o[h]=d:((!f||typeof f!="object")&&(f={$in:[f]}),f.$in||(f={$in:[]}),f.$in.push(d)),o[h]=f}),n.content_filter.attrs=o):n.content_filter.attrs=o||l}return n}function oy(i,...e){const t=e.reduce((n,s)=>(s.refs&&(n.refs=[...n.refs||[],...s.refs]),s.taskResults&&(n.taskResults=[...n.taskResults||[],...s.taskResults]),Object.keys(s).forEach(r=>{r!=="refs"&&r!=="taskResults"&&s[r]!==void 0&&(n[r]=s[r])}),n),{...i});return t.refs&&!t.refs.length&&delete t.refs,t}function ay(i){return i.type?i.type==="task":i.id.startsWith("task-")}function Ld(i,e=`
  9. `){return typeof i=="string"?i.trim():i.reduce((t,n)=>`${t}${e}${n.trim()}`,"").trim()}function ly(i){const e=[],t=[],n={},s=[],r=[];for(const c of i){if(typeof c=="string"){t.push(c);continue}const{role:h,content:d="",invisibleContent:f="",custom_data:p={}}=c;if(h==="tool")s.push(c);else if(h==="system")d.length&&e.push(d);else if(h==="assistant")r.push(c);else if(h==="user"&&d.length)if(p.invisible)e.push(d);else{const y=p.invisiblePromptIndex;typeof y=="number"?(e.push(d.slice(0,y)),t.push(d.slice(y))):t.push(d)}f.length&&e.push(f),Object.keys(p).length&&Object.assign(n,p)}const o=[],a=Ld(t,`
  10. `),l=Ld(e,`
  11. `);if(a.length||l.length){let c=l;a.length&&(c=`${c}
  12. ${a}`),a.length?l.length&&(n.invisiblePromptIndex=l.length,delete n.invisible):(n.invisible=!0,delete n.invisiblePromptIndex),o.push({role:"user",content:c,custom_data:n})}return r.length&&o.push(...r),s.length&&r.some(c=>{var h;return(h=c.tool_calls)==null?void 0:h.length})&&o.push(...s),o}class cy{constructor(e){this._revokeEventTimers=new Map,this._context=Ce(()=>({store:this._store,events:this.events,state:this.state,panel:this._panel,commandScope:this.commandScope})),this._pluginMap=Ce(()=>this.plugins.reduce((t,n)=>(t.set(n.code,n),t),new Map)),this._suggestions=Ce(()=>{const t=[],n=this._context.value;return this._plugins$.value.forEach(s=>{t.push(...s.getSuggestions(n))}),t.sort((s,r)=>(r.priority??0)-(s.priority??0))}),this._contextProviders=Ce(()=>{const t=new Map;return this._plugins$.value.forEach(n=>{n.contextProviders.forEach(s=>{t.set(s.code,s)})}),t}),this._toolsMap=Ce(()=>this.plugins.reduce((t,n)=>(n.getToolsMap().forEach((r,o)=>{t.has(o)?t.get(o).push(...r):t.set(o,r)}),t),new Map)),this._agentsMap=Ce(()=>this.plugins.reduce((t,n)=>(Object.entries(n.agents).forEach(([s,r])=>{t.set(s,r),t.set(`${n.code}.${r.code}`,r),r.alias.forEach(o=>{t.set(o,r)})}),t),new Map)),this._plugins$=fe(Pd.use(e.plugins||[])),this._state$=fe({events:{},selectedText:"",lastSelectedText:""}),this._store=e.store,this.plugins.forEach(t=>{t.attach(this.context)})}get toolsMap(){return this._toolsMap.value}get agentsMap(){return this._agentsMap.value}get commandScope(){var e;return((e=this._panel)==null?void 0:e.commandScope)??"ai"}get pluginMap(){return this._pluginMap.value}get context(){return this._context.value}get suggestions(){return this._suggestions.value}get suggestions$(){return this._suggestions}get contextProviders(){return Array.from(this._contextProviders.value.values()).sort((e,t)=>t.order-e.order)}get contextProviders$(){return this._contextProviders}get plugins(){return this._plugins$.value}get state(){return this._state$.value}get state$(){return this._state$}get events(){return this._state$.value.events}get selectedChat(){const{selectedChatID:e}=this.state;return e?this._store.getChat(e):void 0}getContext(e){return{...this.context,...e}}getChat(e){return e?typeof e=="string"&&(e=this._store.getChat(e)):e=this.selectedChat,e}getTools(e){var p;const{chatTools:t=[],extraTools:n=[],agents:s=[],chat:r,message:o}=e,{toolsMap:a}=this,l=[],c=((p=e.userPrompt)==null?void 0:p.trim())??"",h=(...y)=>{for(const b of y)typeof b=="string"?l.push(...a.get(b)||[]):l.push(b)};if(h(...t),s.length){const y=this.getContext({...this.context,chat:r,message:o,userPrompt:c});s.forEach(b=>{if(typeof b=="string"){const x=this.getAgent(b);if(!x)return;b=x}const w=b.getTools(y);h(...w)})}c.length&&a.forEach((y,b)=>{(c.startsWith(`/${b} `)||c.includes(` /${b} `)||c.endsWith(` /${b}`))&&h(...y)}),h(...n);const d=new Set,f=[];for(let y=l.length-1;y>=0;y--){const b=l[y];d.has(b.name)||(f.unshift(b),d.add(b.name))}return f}getContextProvider(e){return this._contextProviders.value.get(e)}getChatContextProviders(e,t){const n=this.getContext({chat:e});return(t||this.contextProviders).reduce((s,r)=>{if(!r.when||r.when(n)){const{command:o,display:a,when:l,...c}=r,h=this.getPlugin(r.plugin);s.push({...c,command:typeof o=="string"&&h?h.formatCommand(o,n.commandScope):o,...a?a.call(this,n):{}})}return s},[])}async getSubChatContextProviders(e,t){let{items:n=[]}=t;const s=this.context;typeof n=="function"&&(n=await n(s));const r=this.getPlugin(t.plugin);return this.getChatContextProviders(e,n.map(o=>r.getContextProviderFromDefinition(o)))}getChatContextSettingsFromProvider(e){const{chat:t,providerOrName:n,userPrompt:s="",onlyGenerate:r}=e,o=typeof n=="string"?this.getContextProvider(n):n;if(!o)return[];const{code:a,title:l,icon:c,data:h,generate:d}=o,f=this.getPlugin(o.plugin),p={plugin:f.code,code:a,title:l,icon:c,data:h};if(d){const y=d.call(this,this.getContext({chat:t,plugin:f,userPrompt:s}));if(y)return(Array.isArray(y)?y:[y]).map(w=>({...p,...w,autoGen:!0}));if(r)return[]}return p.data?[p]:[]}generateChatContextSettings(e){const{chat:t,contextLikes:n=[],userPrompt:s=""}=e;return n.reduce((r,o)=>(typeof o=="string"||"$provider"in o?r.push(...this.getChatContextSettingsFromProvider({chat:t,providerOrName:o,userPrompt:s})):r.push(o),r),[])}generateChatContextSettingsFromPrompt(e){const{chat:t}=e,n=e.providers||this.getChatContextProviders(t),s=e.userPrompt.trim();return s.length?n.reduce((r,o)=>(o.generate&&r.push(...this.getChatContextSettingsFromProvider({chat:t,providerOrName:o,userPrompt:s,onlyGenerate:!0})),r),[]):[]}updateLocalChatContextsFromPrompt(e,t){const n=e.$local.contexts||[],s=new Set,r=n.reduce((c,h)=>(c.set(h.code,h),h.autoGen&&!h.disabled&&s.add(h.code),c),new Map),o=[];this.generateChatContextSettingsFromPrompt({chat:e,userPrompt:t}).forEach(c=>{const h=r.get(c.code);if(h){if(h.disabled||!h.autoGen)return}else s.delete(c.code);r.set(c.code,c),o.push(c)});const l=iy([...n.filter(c=>!s.has(c.code)),...o]);e.$local.contexts=l}getUsedChatContextSettings(e){var r;const{chat:t,noDisabled:n}=e,s=[];return t.$local.id?s.push(...t.$local.contexts||[]):s.push(...((r=t.custom_data.contexts)==null?void 0:r.map(o=>({...o,data:{}})))||[]),iy(s,{noDisabled:n})}async getCreatingChatContextsData(e){var a;const t=e.$local.contexts||[],n=e.$local.memories||[],s=(a=e.settings)==null?void 0:a.prompt,r=e.$local.agents||[],o=[s];for(const l of r){const c=await l.getPrompt("",{chat:e});c.length&&o.push(c)}for(const l of t){let{data:c}=l;typeof c=="function"&&(c=await c.call(this,this.getContext({chat:e,contextSetting:l,plugin:this.getPlugin(l.plugin)})));const{memory:h,prompt:d}=c;h&&n.push(h),d!=null&&d.length&&o.push(d)}return{memories:n.filter(Boolean),prompt:o.filter(Boolean).join(`
  13. `)}}async addChatContext(e,t){const n=this.getChat(e);if(!n){console.warn("[ZUI] add chat context failed, no chat provided.");return}const s=this.generateChatContextSettings({chat:n,contextLikes:[t]}),r=n.$local.contexts||[];s.forEach(o=>{const a=r.findIndex(l=>l.code===o.code);a!==-1?r[a]=o:r.push(o)}),this._store.updateChatLocalData(n.id,{contexts:[...r]})}removeChatContext(e,t){const n=this.getChat(e);if(!n){console.warn("[ZUI] remove chat context failed, no chat provided.");return}const s=n.$local.contexts||[],r=s.findIndex(o=>o.code===t);r!==-1&&(s.splice(r,1),this._store.updateChatLocalData(n.id,{contexts:[...s]}))}toggleChatContext(e,t){const n=this.getChat(e);if(!n){console.warn("[ZUI] remove chat context failed, no chat provided.");return}if(t.autoGen&&!t.disabled)this.addChatContext(n,{disabled:!0,...t});else{if((n.$local.contexts||[]).some(r=>r.code===t.code))return this.removeChatContext(n,t.code),!1;this.addChatContext(n,t)}return!0}async applyProviderContextSettings(e,t){const n=this.getChat(e);if(!n){console.warn("[ZUI] remove chat context failed, no chat provided.");return}let{contexts:s}=t;if(!s||(typeof s=="function"&&(s=await s(this.getContext({chat:n,provider:t}))),!(s!=null&&s.length)))return;const r=n.$local.contexts||[];let o=!1;for(const a of s){if(!a.data)continue;const l=r.findIndex(h=>h.code===a.code),c={...a,plugin:t.plugin};l!==-1?r[l]=c:r.push(c),o=!0}o&&this._store.updateChatLocalData(n.id,{contexts:[...r]})}getPlugin(e){return this.pluginMap.get(e)}getAgent(e){return this.agentsMap.get(e)}getAgents(e,t){var r;const n=(Array.isArray(e)?[...e]:[e]).filter(Boolean);if(t!=null&&t.startsWith("@")){const o=((r=t.split(`
  14. `).shift())==null?void 0:r.split(" "))||[];for(let a of o){if(a=a.trim(),!/^@[\w.]+$/.test(a))break;n.push(a.slice(1))}}const s=new Set;return n.reduce((o,a)=>{const l=typeof a=="object"?a:this.agentsMap.get(a);return l&&!s.has(l)&&(s.add(l),o.push(l)),o},[])}executeCommand(e,t){if(!this._panel){console.warn("[ZUI] Execute command failed, no panel found.");return}_h(e,{event:t,execute:this._panel.executeCommand.bind(this._panel)})}acceptSuggestion(e,t){e.action&&e.action(this.context),e.command&&this.executeCommand(e.command,t)}hasPluginMethod(e){const[t,n]=e.split("."),s=this.pluginMap.get(t);return!!s&&!!s.methods[n]}callPluginMethod(e,...t){const[n,s]=e.split("."),r=this.pluginMap.get(n);if(!r||!r.methods[s])throw new Error(`Plugin ${n} method ${s} not found.`);return r.callMethod(this.context,s,...t)}async callPluginsCallback(e,t,n){const{plugins:s}=this;for(const r of s){if(!r.hasCallback(e))continue;let o,a;try{o=await r.callCallback(e,...t)}catch(l){a=new Error(`[ZUI] Call plugin ${r.code} callback ${e} failed: ${String(a)}`,{cause:l}),console.warn(a)}if(n&&await n(o,a,r)===!1)return!1}}selectChat(e){this.setState({selectedChatID:e})}setPanel(e){this._panel=e}setState(e){const t=this._state$.value,n={};Object.keys(e).forEach(s=>{e[s]!==t[s]&&(n[s]=e[s])}),Object.keys(n).length&&(this._state$.value={...t,...n})}trigger(e,t,n,s){const r={type:e,data:t||{},time:Date.now(),gid:Xe()},o={events:{...this._state$.value.events,[e]:r},lastEvent:r,...n};if(this.setState(o),s!=null&&s.lifeTime){this._revokeEventTimers.has(e)&&window.clearTimeout(this._revokeEventTimers.get(e));const a=window.setTimeout(()=>{this.revokeEvent(e)},s.lifeTime);this._revokeEventTimers.set(e,a)}this.plugins.forEach(a=>{a.triggerEvent(this.context,e,r.data)})}revokeEvent(e){this._revokeEventTimers.delete(e);const t=this._state$.value.events,n=t[e];if(!n)return;delete t[e];let s=this.state.lastEvent;(s==null?void 0:s.gid)===n.gid&&(s=Object.values(t).sort((o,a)=>o.gid-a.gid)[0]);const r={events:t,lastEvent:s};this.setState(r)}destroy(){this._revokeEventTimers.forEach(e=>{window.clearTimeout(e)}),this._plugins$.value.forEach(e=>{e.detach(this.context)}),this._plugins$.value=[],this._panel=void 0}}class on{constructor(e){this._chats=fe([]),this._chatMap=Ce(()=>this._chats.value.reduce((t,n)=>(t.set(n.id,n),t),new Map)),this._loadingMap=fe({}),this._llmModels=fe([]),this._isLoading=Ce(()=>!!Object.values(this._loadingMap.value).length),this._info=fe(),this._error=fe(),this._chatModels=Ce(()=>this._llmModels.value.filter(t=>{var n;return(n=t.abilities)==null?void 0:n.includes("chat")})),this._sortedChats=Ce(()=>this._chats.value.sort((t,n)=>(n.created_at||0)-(t.created_at||0))),this._sortedChats$=Ce(()=>this._sortedChats),this._formatMessage=t=>{var s;this._options.formatMessage&&(t=this._options.formatMessage(t));let n=t.created_at||t.created_on;if(typeof n=="string"&&(this._options.useISODate&&!n.includes("Z")&&(n=n+"Z"),t.created_at=new Date(n).getTime()),t.custom_data||(t.custom_data={}),t.custom_data.invisiblePromptIndex!==void 0&&(t.invisibleContent=t.content.slice(0,t.custom_data.invisiblePromptIndex).trim(),t.content=t.content.slice(t.custom_data.invisiblePromptIndex).trim(),t.content.length||(t.custom_data.invisible=!0,delete t.custom_data.invisiblePromptIndex)),!((s=t.reasonContent)!=null&&s.length)&&t.content.startsWith("<think>")){const{content:r}=t,o=r.indexOf("</think>");o!==-1?(t.reasonContent=r.substring(0,o),t.content=r.substring(o+7)):(t.reasonContent=r,t.content=""),t.$reasonType||(t.$reasonType="thinking")}return t},this._formatChat=t=>{this._options.formatChat&&(t=this._options.formatChat(t)),t.$local||(t.$local={}),t.title===""&&(t.$local.tempTitle||(t.$local.tempTitle=this._untitledChatTitle)),t.custom_data||(t.custom_data={}),t.custom_data.type=t.custom_data.type||"chat";let n=t.created_at||t.created_on;typeof n=="string"&&(this._options.useISODate&&!n.includes("Z")&&(n=n+"Z"),t.created_at=new Date(n).getTime());let s=t.updated_at||t.updated;return typeof s=="string"&&(this._options.useISODate&&!s.includes("Z")&&(s=s+"Z"),t.updated_at=new Date(s).getTime()),t},this._context=fe(e.context),this._fetchers=e.fetchers,this._untitledChatTitle=e.defaultChatTitle??Se("untitledChat")??"New Chat",this._reactions=new cy({store:this,plugins:e.plugins}),this._options=e,this._privs=fe(e.privs||"allow-all"),setTimeout(()=>{this.getInfo()},0)}get error(){return this._error.value}get sortedChats(){return this._sortedChats.value}get info$(){return this._info}get info(){return this._info.value}get llmProviders(){return this._llmModels.value}get chatModels(){return this._chatModels.value}get chatModels$(){return this._chatModels}get assetBaseUrl(){return this._context.value.assetBaseUrl||this._context.value.baseUrl}get context(){return this._context.value}get context$(){return this._context}get chats(){return this._chats.value}get chats$(){return this._chats}get chatMap(){return this._chatMap.value}get chatMap$(){return this._chatMap}get isLoading(){return this._isLoading.value}get isLoading$(){return this._isLoading}get reactions(){return this._reactions}get globalMemory(){return this._context.value.globalMemory}get privs(){return this._privs.value}get isDisabledAllPrivs(){return this.privs==="disable-all"}hasPriv(e){const t=this.privs;return t==="disable-all"?!1:typeof t=="object"?t[e]??!1:t==="allow-all"}isLoadingNow(e){return Object.values(this._loadingMap.value).some(t=>t.type===e)}setError(e){this._error.value=e}getChat(e){return this._chatMap.value.get(e)||this.getLocalChat(e)}getLocalChat(e){return this._chats.value.find(t=>t.$local.id===e)}setContext(e){this._context.value={...this._context.value,...e}}isConfigOK(){return!0}async getInfo(e){if(this._info.value&&!e)return this._info.value;const t=this._checkFetcher("getInfo");let n;try{n=await Ne(t,[this.context])}catch(s){console.error("[ZUI] getInfo error",s)}return this._info.value=n,n}async isOK(){if(this.setError(),!this.isConfigOK())return this._error.value||this.setError({message:Se("errors.configNotValid")||"The config is not valid.",type:"configNotValid"}),!1;const t=await this.getInfo();return!t||typeof t!="object"||!t.version?!1:(await this.getLlmModels(),!this.error)}async extractFile(e){const t=this._checkFetcher("extractFile");return await Ne(t,[this.context,e])}async tryLoadChat(e){var n;const t=this.getChat(e);t?t!=null&&t.messages||(await this.getMessages(e),(n=t.messages)!=null&&n.length&&await this.tryUpdateChatTitle(t)):await this.loadChat(e,!0),this._llmModels.value.length||await this.getLlmModels()}async buildChat(e,t){const{localID:n="",title:s="",tempTitle:r=this._untitledChatTitle,model:o=this.context.defaultModel,agent:a=[],welcome:l,type:c,data:h,userPrompt:d,prompt:f,contexts:p,tools:y,memories:b,form:w,formData:x,customData:T,settings:D}=e||{},N=Array.isArray(a)?a:[a],A=this.reactions.getAgents(N,d);let z={id:n,title:s,messages:[],custom_data:{agents:A.map(O=>O.code),welcome:l,type:c,data:h,tools:y==null?void 0:y.reduce((O,K)=>(typeof K=="string"?O.push(K):O.push(K.name),O),[]),form:x?{data:x}:void 0,...T},settings:{model:o,prompt:f,...D},$local:{id:n,agents:A,tools:y?this.reactions.getTools({extraTools:y}):[],userPrompt:d,contexts:[],tempTitle:s.length?void 0:r,memories:b?b.map(O=>typeof O=="string"?{collections:[O]}:O):[],creatingOptions:e,form:w?{config:w,data:x}:void 0},created_at:Date.now()};if(p&&(z.$local.contexts=this.reactions.generateChatContextSettings({chat:z,contextLikes:p,userPrompt:d}),z.custom_data.contexts=z.$local.contexts.map(O=>({code:O.code,title:O.title,icon:O.icon??"",plugin:O.plugin}))),t){let O=!1;if(await this.reactions.callPluginsCallback("onBuildChat",[{chat:z,userPrompt:d,isLocal:!!n.length}],K=>{if(K===!1)return O=!0,!1;K&&typeof K=="object"&&(z=ry({...z},K))}),O)return}return z}async createLocalChat(e){const t=(e==null?void 0:e.localID)??Ot(),n=await this.buildChat({...e,localID:t},!0);if(n)return this._updateChats(n),t}async createChat(e){var d;const t=e==null?void 0:e.localID,n=t?this.getLocalChat(t):void 0,s=await this.buildChat({...n==null?void 0:n.$local.creatingOptions,...e,...n?{contexts:n.$local.contexts}:{},...(d=n==null?void 0:n.$local.form)!=null&&d.data?{formData:n.$local.form.data}:{},localID:""},!0);if(!s)return;const{prompt:r,memories:o}=await this.reactions.getCreatingChatContextsData(s),a=this._checkFetcher("createConversation");let l={title:Tn(s.title)?s.title:s.$local.tempTitle??this._untitledChatTitle,customData:s.custom_data,settings:s.settings,memories:o,prompt:r};const c=s.$local.userPrompt;await this.reactions.callPluginsCallback("onCreateChat",[{chat:s,options:l,userPrompt:c}],f=>{f&&typeof f=="object"&&(l={...l,...f,settings:{...l.settings,...f.settings},customData:{...l.customData,...f.customData}})});const h=await Ne(a,[this.context,l]);return await this.reactions.callPluginsCallback("afterCreateChat",[{chat:h}]),this._updateChats({...s,...h,$local:{...s.$local,id:void 0,tools:s.$local.tools}}),t&&this._updateChats(this._chats.value.filter(f=>f.$local.id!==t),!0),h.id}destroy(){this._chats.value=[],this._reactions.destroy()}async deleteChat(e){const t=this.getChat(e),n=()=>{this._updateChats(this._chats.value.filter(o=>o.id!==e),!0)};if(t!=null&&t.$local.id){n();return}const s=this._checkFetcher("deleteConversation");await Ne(s,[this.context,e])!==!1&&n()}async loadChats(e){const t=this._checkFetcher("getConversations"),n=this._startLoad("loadChats");try{const s=await Ne(t,[this.context]);gs(()=>{this._updateChats(s,e)}),this._endLoad(n)}catch(s){throw this._endLoad(n),s}}async tryLoadChats(){if(!(this._chats.value.filter(e=>!e.$local.id).length||this.isLoadingNow("getConversations")))return this.loadChats(!0)}async loadChat(e,t=!1){const n=this._checkFetcher("getConversation"),s=this._startLoad("loadChat"),r=await Ne(n,[this.context,e]);if(r)this._updateChats(r),t&&await this.getMessages(e),this._endLoad(s);else throw this._endLoad(s),new Error(`Cannot load chat with id ${e}.`)}async getMessages(e,t=!0){const n=this._checkFetcher("getMessages"),s=this._startLoad("getMessages");try{const r=await Ne(n,[this.context,e]);gs(()=>this._updateChatMessages(e,r,t))}catch(r){console.error("[ZUI] getMessages error",r)}this._endLoad(s)}async getLlmModels(e=!0){let t=this._llmModels.value;if(e||!t.length){const n=this._checkFetcher("getLlmModels");t=await Ne(n,[this.context]),this._llmModels.value=t}return t}async getTextEmbeddingModel(e){const t=await this.getLlmModels(!1);return e?t.find(n=>n.id===e):t.find(n=>{var s;return(s=n.abilities)==null?void 0:s.includes("embedding")})}async ensureChat(e,t={},n){if(e==="NEW"){const r=await this.createChat(t);return r?(n==null||n.call(this,r),this.getChat(r)):void 0}const s=this.getChat(e);if(s!=null&&s.$local.id){const r=await this.createChat({localID:s.$local.id,...t});if(r)return n==null||n.call(this,r),this.getChat(r)}return s}async runTools(e,t,n){const s=t.$toolCalls;if(!(s!=null&&s.length))return[];t.$state="tools_running";const r={},o=(c,h,d,f,p)=>{const y={name:h?h.displayName??h.name:c.function.name,status:d,error:f,result:p};h!=null&&h.display&&(y.message=h.display(y)),r[c.id]=y,t.$toolCallingStates=r,this._updateChatMessages(e,t)},a=s.map(async c=>{const h=n.get(c.function.name);if(!h){o(c,h,"error",`The tool "${c.function.name}" is not found.`);return}o(c,h,"running");try{const d=JSON.parse(c.function.arguments);let f=h.confirm;typeof f=="function"&&(f=f.call(this,c));let p=!1;f&&(await He.confirm(typeof f=="string"?f:Se("functionCallingConfirm"))||(o(c,h,"cancelled"),p=!0));let y=await(p?h.cancel||(()=>""):h.fn).call(this,d);if(y===void 0)return;typeof y=="string"&&(y={message:y,result:y}),o(c,h,p?"cancelled":"finished",void 0,y||void 0);const{message:b,result:w}=y;if(b&&typeof b=="object")return b;if(b!==void 0||w!==void 0)return{role:"tool",tool_call_id:c.id,name:c.function.name,content:b??JSON.stringify(w)}}catch(d){console.error(`[ZUI] AIStore: run tool ${h.name} error`,d),o(c,h,"error",d.message)}});return(await Promise.all(a)).filter(Boolean)}async postFormDataToChat(e,t,n){const s=this.getChat(e);if(!s)return;const r=s.$local.form,o=r==null?void 0:r.config;if(!o)return;let a;const l=o.prompt;if(typeof l=="function"){const d=await l(t);a=typeof d=="string"?{user:d}:d}else typeof l=="string"?a={user:De(l,t)}:l&&typeof l=="object"?a={system:Tn(l.system)?De(l.system,t):void 0,user:Tn(l.user)?De(l.user,t):void 0}:a={system:JSON.stringify(t)};let c="";typeof o.summary=="string"?c=o.summary:typeof o.summary=="function"?c=await o.summary(t):c=a.user?"":Se("formSubmitted")??"";const h=[a.system?{role:"system",content:a.system}:void 0,a.user?{role:"user",content:a.user}:void 0].filter(Boolean);return s.$local.id?this.postMessage({content:h,chat:{localID:s.$local.id,formData:t}}):(this._updateChats({id:e,$local:{form:{...r,data:t}},custom_data:{form:{summary:c,data:t}}}),await this.postMessage({content:h,chat:s.id,...n}),await this.updateChatData(s.id,{...s.custom_data,form:{summary:c,data:t}}),s.id)}async postMessage(e,t){var ne,xe,Me,Re,je;const n=typeof e=="string"?{content:e}:{...e},s=n.content;if(!s||!(s!=null&&s.length)){console.error("[ZUI] postMessage error","The content is empty.");return}let r=ly([...Array.isArray(s)?s:[s],...n.messages||[]]);const o=(ne=r.find(te=>te.role==="user"))==null?void 0:ne.content,a=typeof t=="string"?t:typeof n.chat=="string"?n.chat:"NEW",l={...typeof n.chat=="object"?n.chat:{},...typeof t=="object"?t:{},userPrompt:o},c=await ym(this.ensureChat.bind(this),[a,l,(xe=n.onCreateChat)==null?void 0:xe.bind(this)]);if(!c){console.error("[ZUI] postMessage error","Cannot create or find chat before post message.");return}const h=c.id;if(c.$local.form&&!c.$local.form.data)return this._updateChats({id:h,$local:{waitingMessages:r}}),h;const d=c.$local.waitingMessages;d&&r.unshift(...d);const f=this._startLoad("postMessage");this._updateChats({id:h,$local:{generating:!0,waitingMessages:void 0}});const p=r.reduce((te,X)=>(X.role==="user"&&te.push({id:Ot(),$state:"local",created_at:Date.now(),content:"",...X}),te),[]);p.length&&this._updateChatMessages(h,p);const y={id:Ot(),role:"assistant",content:"",reasonContent:"",$state:"generating",$reasonTime:0,created_at:Date.now()};this._updateChatMessages(h,y);const b=[],w=[],x=[];n.noPlugins||await this.reactions.callPluginsCallback("onPostMessage",[{chat:c,userMessages:p,pendingMessage:y,postingMessages:r,updateState:te=>{y.$stateText=te,this._updateChatMessages(h,y)}}],te=>{te&&(te.tools&&w.push(...te.tools),te.systemPrompt&&b.push(te.systemPrompt),te.refs&&x.push(...te.refs))}),b&&(r=ly([...r,{role:"system",content:Ld(b)}]));const T={chat:c,message:y,userPrompt:o,chatTools:n.noChatTools?void 0:c.$local.tools,agents:n.noAgentTools?void 0:c.custom_data.agents,extraTools:[...n.tools||[],...w]},D=this.reactions.getTools(T),N=D.reduce((te,X)=>(te.set(X.name,X),te),new Map),A=Date.now(),z={chat:"",reason:""};let O="";const K=te=>{var Ee,Ae;let X=!1;te.content!==null&&(te.type==="chat"?y.content=`${y.content}${te.content}`:te.type==="reason"&&(y.$reasonTime=Date.now()-A,y.$reasonType=te.reasonType,y.reasonContent=`${y.reasonContent}${te.content}`),z[te.type]=`${z[te.type]}${te.content}`,y.content=z.chat,y.reasonContent=z.reason,X=!0),(Ee=te.tool_calls)!=null&&Ee.length&&(y.$toolCalls=te.tool_calls.map(Ue=>{var Qt;return{...Ue,name:((Qt=N.get(Ue.function.name))==null?void 0:Qt.displayName)??Ue.function.name}}),X=!0),te.model&&(O=te.model),X&&(this._updateChatMessages(h,y),(Ae=n==null?void 0:n.onResponse)==null||Ae.call(n,y,h))};let Z=oy(n.custom_data||{},{refs:x});Object.keys(Z).length||(Z=void 0);const[ye,Q]=r.reduce((te,X)=>(X.role==="user"?te[0]=X:te[1].push(X),te),[void 0,[]]);try{if(ye){const X=this._checkFetcher("postMessage");await Ne(X,[this.context,{id:h,content:ye.content,tools:D.length?D:void 0,messages:Q.length?Q:void 0,custom_data:ye.custom_data&&Z?oy(ye.custom_data,Z):ye.custom_data||Z},K])}else{const X=this._checkFetcher("postBatchMessages");await Ne(X,[this.context,{id:h,messages:Q,tools:D.length?D:void 0},K])}y.created_at=Date.now();const te=y.$toolCalls||[];if(te.length){const X=await this.runTools(h,y,N);X.some(Ee=>Ee.role==="tool")&&X.push({role:"assistant",tool_calls:te,content:"工具调用完成",custom_data:{test:Date.now()}}),X.length&&this.postMessage({content:X,chat:h,noAgentTools:!0,noChatTools:!0,noPlugins:!0})}y.$state="synced",c.custom_data.type!=="temp"&&this.tryUpdateChatTitle(c,1e3)}catch(te){console.error("[ZUI] postMessage error",te),y.$state="error",y.$error=Se(`errors.${te.message}`)||Se("errors.postMessageFailed"),y.created_at=Date.now()}return this._updateChatMessages(h,y),this._updateChats({id:h,$local:{generating:!1},...O?{custom_data:{model:O}}:{}}),this._endLoad(f),(Me=n.onFinish)==null||Me.call(n,y,h),O&&!((Re=c.settings)!=null&&Re.model)&&((je=c.custom_data)==null?void 0:je.model)!==O&&this.updateChatData(h,{model:O}),h}postTempMessage(e){const t=typeof e=="string"?{content:e}:e;return new Promise((n,s)=>{this.postMessage({...t,chat:{type:"temp"},onFinish:(r,o)=>{n({message:r,chat:this.getChat(o)})}},t.chat).then(r=>{r&&this.deleteChat(r)}).catch(s)})}async generateContentTitle(e){const t=typeof e=="string"?{content:e}:e,s=(await this.postTempMessage({...t,chat:{agent:"generateTitle"}})).message.content;return Array.isArray(s)?s.join(""):s}async updateChatTitle(e){const t=this._checkFetcher("getConversationTitle");try{const n=await Ne(t,[this.context,e]),s=this.getChat(e);s&&n&&(s.title=n.title,delete s.$local.tempTitle,this._updateChats(s))}catch(n){console.error("[ZUI] Update chat title error",n)}}async tryUpdateChatTitle(e,t=0){const n=typeof e=="string"?this.getChat(e):e;if(!n)return;const s=n.id;(!n.title.length||n.title===n.$local.tempTitle||n.title===this._untitledChatTitle)&&(await Dn(t),await this.updateChatTitle(s))}async renameChatTitle(e,t){const n=this._checkFetcher("updateConversation");try{const s=await Ne(n,[this.context,{title:t,id:e}]),r=this.getChat(e);r&&s&&(r.title=t,this._updateChats(r))}catch(s){console.error("[ZUI] Rename chat title error",s)}}async updateChatData(e,t){const n=this._checkFetcher("updateConversation");try{const s=this.getChat(e);if(!s)return;await Ne(n,[this.context,{id:e,custom_data:{...s.custom_data,...t}}])&&(s.custom_data={...s.custom_data,...t},this._updateChats(s))}catch(s){console.error("[ZUI] Update chat data error",s)}}updateChatLocalData(e,t){const n=this.getChat(e);n&&(n.$local={...n.$local,...t},this._updateChats(n))}updateUserPrompt(e,t){const n=this.getChat(e);n&&n.$local.userPrompt!==t&&(n.$local={...n.$local,userPrompt:t},this.reactions.updateLocalChatContextsFromPrompt(n,t),this._updateChats(n))}getAvatar(e,t,n){const s=this._options.getAvatar;if(!s)return{...n};let r=s(e,t);if(r!==!1)return typeof r=="string"&&(r.startsWith("./")||r.startsWith("/")?r={src:r}:r={icon:r}),Pe({},n,r)}_checkFetcher(e){const t=this._fetchers[e];if(!t)throw new Error(`The fetcher "${e}" is not defined.`);return t}_updateChatMessages(e,t,n=!1){const s=this._chats.value,r=s.findIndex(l=>l.id===e);if(r<0)throw new Error(`The chat "${e}" is not found.`);const o=s[r],a=o.messages||[];if(t=Array.isArray(t)?t:[t],n)o.messages=t.map(this._formatMessage).sort((l,c)=>l.created_at-c.created_at);else for(const l of t){const c=a.findIndex(h=>h.id===l.id);c!==-1?a[c]=this._formatMessage({...a[c],...l}):a.push(this._formatMessage({...l})),o.messages=[...a].sort((h,d)=>h.created_at-d.created_at)}s[r]={...o},this._chats.value=[...s]}_updateChats(e,t){const n=this._chats.value;if(e=Array.isArray(e)?e:[e],t)this._chats.value=e.map(this._formatChat);else{const s=[];for(const r of e){const o=n.findIndex(a=>{var l;return a.$local.id&&a.$local.id===((l=r.$local)==null?void 0:l.id)||a.id===r.id});o!==-1?n[o]=this._formatChat(ry(n[o],r)):s.push(this._formatChat(r))}this._chats.value=[...s,...n]}}_startLoad(e){const t=Xe();return this._loadingMap.value={...this._loadingMap.value,[t]:{startTime:Date.now(),type:e}},t}_endLoad(e){const t=this._loadingMap.value;t[e]&&(delete t[e],this._loadingMap.value={...t})}}on.NAME="AIStore";var hy=11;function rk(i,e){var t=e.attributes,n,s,r,o,a;if(!(e.nodeType===hy||i.nodeType===hy)){for(var l=t.length-1;l>=0;l--)n=t[l],s=n.name,r=n.namespaceURI,o=n.value,r?(s=n.localName||s,a=i.getAttributeNS(r,s),a!==o&&(n.prefix==="xmlns"&&(s=n.name),i.setAttributeNS(r,s,o))):(a=i.getAttribute(s),a!==o&&i.setAttribute(s,o));for(var c=i.attributes,h=c.length-1;h>=0;h--)n=c[h],s=n.name,r=n.namespaceURI,r?(s=n.localName||s,e.hasAttributeNS(r,s)||i.removeAttributeNS(r,s)):e.hasAttribute(s)||i.removeAttribute(s)}}var yl,ok="http://www.w3.org/1999/xhtml",Ut=typeof document>"u"?void 0:document,ak=!!Ut&&"content"in Ut.createElement("template"),lk=!!Ut&&Ut.createRange&&"createContextualFragment"in Ut.createRange();function ck(i){var e=Ut.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function hk(i){yl||(yl=Ut.createRange(),yl.selectNode(Ut.body));var e=yl.createContextualFragment(i);return e.childNodes[0]}function dk(i){var e=Ut.createElement("body");return e.innerHTML=i,e.childNodes[0]}function uk(i){return i=i.trim(),ak?ck(i):lk?hk(i):dk(i)}function vl(i,e){var t=i.nodeName,n=e.nodeName,s,r;return t===n?!0:(s=t.charCodeAt(0),r=n.charCodeAt(0),s<=90&&r>=97?t===n.toUpperCase():r<=90&&s>=97?n===t.toUpperCase():!1)}function fk(i,e){return!e||e===ok?Ut.createElement(i):Ut.createElementNS(e,i)}function pk(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function Rd(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var dy={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}Rd(i,e,"selected")},INPUT:function(i,e){Rd(i,e,"checked"),Rd(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var s=n.nodeValue;if(s==t||!t&&s==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,s=i.firstChild,r,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")r=s,s=r.firstChild,s||(s=r.nextSibling,r=null);else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=n;break}n++}s=s.nextSibling,!s&&r&&(s=r.nextSibling,r=null)}i.selectedIndex=t}}},to=1,uy=11,fy=3,py=8;function Ss(){}function mk(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function gk(i){return function(t,n,s){if(s||(s={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=Ut.createElement("html"),n.innerHTML=r}else n=uk(n);else n.nodeType===uy&&(n=n.firstElementChild);var o=s.getNodeKey||mk,a=s.onBeforeNodeAdded||Ss,l=s.onNodeAdded||Ss,c=s.onBeforeElUpdated||Ss,h=s.onElUpdated||Ss,d=s.onBeforeNodeDiscarded||Ss,f=s.onNodeDiscarded||Ss,p=s.onBeforeElChildrenUpdated||Ss,y=s.skipFromChildren||Ss,b=s.addChild||function(te,X){return te.appendChild(X)},w=s.childrenOnly===!0,x=Object.create(null),T=[];function D(te){T.push(te)}function N(te,X){if(te.nodeType===to)for(var Ee=te.firstChild;Ee;){var Ae=void 0;X&&(Ae=o(Ee))?D(Ae):(f(Ee),Ee.firstChild&&N(Ee,X)),Ee=Ee.nextSibling}}function A(te,X,Ee){d(te)!==!1&&(X&&X.removeChild(te),f(te),N(te,Ee))}function z(te){if(te.nodeType===to||te.nodeType===uy)for(var X=te.firstChild;X;){var Ee=o(X);Ee&&(x[Ee]=X),z(X),X=X.nextSibling}}z(t);function O(te){l(te);for(var X=te.firstChild;X;){var Ee=X.nextSibling,Ae=o(X);if(Ae){var Ue=x[Ae];Ue&&vl(X,Ue)?(X.parentNode.replaceChild(Ue,X),Z(Ue,X)):O(X)}else O(X);X=Ee}}function K(te,X,Ee){for(;X;){var Ae=X.nextSibling;(Ee=o(X))?D(Ee):A(X,te,!0),X=Ae}}function Z(te,X,Ee){var Ae=o(X);if(Ae&&delete x[Ae],!Ee){var Ue=c(te,X);if(Ue===!1||(Ue instanceof HTMLElement&&(te=Ue,z(te)),i(te,X),h(te),p(te,X)===!1))return}te.nodeName!=="TEXTAREA"?ye(te,X):dy.TEXTAREA(te,X)}function ye(te,X){var Ee=y(te,X),Ae=X.firstChild,Ue=te.firstChild,Qt,Ct,Dt,ln,It;e:for(;Ae;){for(ln=Ae.nextSibling,Qt=o(Ae);!Ee&&Ue;){if(Dt=Ue.nextSibling,Ae.isSameNode&&Ae.isSameNode(Ue)){Ae=ln,Ue=Dt;continue e}Ct=o(Ue);var jn=Ue.nodeType,me=void 0;if(jn===Ae.nodeType&&(jn===to?(Qt?Qt!==Ct&&((It=x[Qt])?Dt===It?me=!1:(te.insertBefore(It,Ue),Ct?D(Ct):A(Ue,te,!0),Ue=It,Ct=o(Ue)):me=!1):Ct&&(me=!1),me=me!==!1&&vl(Ue,Ae),me&&Z(Ue,Ae)):(jn===fy||jn==py)&&(me=!0,Ue.nodeValue!==Ae.nodeValue&&(Ue.nodeValue=Ae.nodeValue))),me){Ae=ln,Ue=Dt;continue e}Ct?D(Ct):A(Ue,te,!0),Ue=Dt}if(Qt&&(It=x[Qt])&&vl(It,Ae))Ee||b(te,It),Z(It,Ae);else{var G=a(Ae);G!==!1&&(G&&(Ae=G),Ae.actualize&&(Ae=Ae.actualize(te.ownerDocument||Ut)),b(te,Ae),O(Ae))}Ae=ln,Ue=Dt}K(te,Ue,Ct);var he=dy[te.nodeName];he&&he(te,X)}var Q=t,ne=Q.nodeType,xe=n.nodeType;if(!w){if(ne===to)xe===to?vl(t,n)||(f(t),Q=pk(t,fk(n.nodeName,n.namespaceURI))):Q=n;else if(ne===fy||ne===py){if(xe===ne)return Q.nodeValue!==n.nodeValue&&(Q.nodeValue=n.nodeValue),Q;Q=n}}if(Q===n)f(t);else{if(n.isSameNode&&n.isSameNode(Q))return;if(Z(Q,n,w),T)for(var Me=0,Re=T.length;Me<Re;Me++){var je=x[T[Me]];je&&A(je,je.parentNode,!1)}}return!w&&Q!==t&&t.parentNode&&(Q.actualize&&(Q=Q.actualize(t.ownerDocument||Ut)),t.parentNode.replaceChild(Q,t)),Q}}var yk=gk(rk);function zd(i,e,t={}){const n=v(i);if(typeof e=="string"&&!e.length){t.childrenOnly?n.empty():n.replaceWith(document.createTextNode(""));return}if(e===null){n.remove();return}const s="z-zui-inited",{getNodeKey:r,onElUpdated:o,onBeforeElUpdated:a,onBeforeElChildrenUpdated:l,executeScript:c=!0,...h}=t,d=new Set;yk(i,e,{...h,getNodeKey:function(f){const p=r==null?void 0:r(f);if(p!==void 0)return p;if(f instanceof Element&&f.tagName==="BODY")return f.tagName;if(f.getAttribute)return f.getAttribute("zui-key")??f.id},onBeforeElUpdated(f,p){const y=a==null?void 0:a(f,p);if(y!==void 0)return y;if(f.classList.contains("preserve-on-morph"))return!1;if(f.classList.contains("no-morph")||f.hasAttribute("zui-create")!==p.hasAttribute("zui-create")||f.tagName==="IFRAME"&&!f.classList.contains("morph")||f.tagName==="ZEN-EDITOR"||f.tagName.includes("-")&&f.isEqualNode(p))return f.replaceWith(p),!1;if(f.tagName==="SCRIPT"&&c){const w=p.textContent;w&&v(f).addClass("zui-js-run").parent().runJS(w)}const b=v(f);if((f.hasAttribute("zui-create")||f.hasAttribute("data-zui"))&&(!p.childNodes.length||b.zui()instanceof ve)){if(f.isEqualNode(p))d.add(f);else{let w=!0;Array.from(p.attributes).forEach(x=>{const{name:T,value:D}=x;T==="class"?b.addClass(D):f.getAttribute(T)!==D&&((T==="zui-create"||T.startsWith("zui-create-"))&&(w=!1),f.setAttribute(T,D))}),w&&d.add(f)}return!1}return!0},onBeforeElChildrenUpdated(f,p){const y=l==null?void 0:l(f,p);return y!==void 0?y:f.classList.contains("no-morph")?!1:!f.tagName.includes("-")},onElUpdated(f){if(o==null||o(f),f.tagName!=="SCRIPT"){f.hasAttribute(s)&&f.removeAttribute(s);const p=br(f);Object.keys(p).forEach(y=>{const b=p[y];if(y==="zui.commands"&&b)f.setAttribute("z-commands",","+Object.keys(b).join());else if(b instanceof qe){const{ATTR_KEY:w,DATA_KEY:x}=b.constructor;f.setAttribute(w,""),f.setAttribute(x,`${b.gid}`)}})}}}),n.zuiInit({update:"reset",beforeCreate:f=>!d.has(f)}),d.forEach(f=>{v(f).trigger("skipMorph")}),c&&n.find("script:not(.zui-js-run)").each((f,p)=>{const y=p.textContent;y&&n.runJS(y)})}v.fn.morph=function(i,e){return this.each((t,n)=>{zd(n,i,e)})},v.fn.morphInner=function(i,e){return this.each((t,n)=>{zd(n,i,{...e,childrenOnly:!0})})};let Gi;const my=function(){var e;if(Gi)return Gi;const i=window.parent;if(((e=window.config)==null?void 0:e.currentModule)==="index"&&window.config.currentMethod==="index")Gi="home";else if(window===i)Gi="single";else{let t="";try{t=i.getZentaoPageType?i.getZentaoPageType():""}catch{window.top=window,window.parent=window}Gi=t==="home"?"app":"single"}return Gi};Object.assign(window,{getZentaoPageType:my});const gy=new Ni("marked",{src:["markdown/marked/marked.min.js"],check:"marked",success:()=>{const{markedHighlight:i,marked:e}=window;i&&e&&Object.assign(e,i)}}),yy=class Fo extends qe{constructor(){super(...arguments),this._updateID=0}async afterInit(){var s,r;const{$element:e,options:{code:t,lang:n}}=this;t===void 0&&(this.options.code=e.text().trim()),n===void 0&&(this.options.lang=e.attr("data-lang")||((r=(s=e.attr("class"))==null?void 0:s.split(" ").find(o=>o.startsWith("lang-")))==null?void 0:r.substring(5))||""),await Fo.loadModule(),await this.render()}async update(e,t){const{className:n,style:s,code:r,...o}={...this.options,...t},{$element:a}=this;n&&a.setClass(n),s&&a.css(s);const l=++this._updateID,c=await Fo.codeToHtml(e??r??"",o);l===this._updateID&&a.html(c)}async render(e){super.render(e),await this.update()}static async codeToHtml(e,t){const n=await Fo.loadModule();try{return await n.codeToHtml(e,{theme:"github-light",lang:"txt",...t})}catch(s){return console.warn(`[ZUI] Highlight: ${s}`),`<div>${Gn(e)}</div>`}}static async createHighlighter(e){return await(await Fo.loadModule()).createHighlighter(e)}static async loadModule(){if(!this.Module&&!this.Module){const e=await v.getLib("shiki");this.Module=e}return this.Module}};yy.NAME="Highlight";let no=yy;v.registerLib("shiki",{src:"highlight/shiki/shiki.umd.js",check:"shiki"}),no.register();const eM="",_l=class mr extends qe{init(){const{content:e}=this.options;e===void 0&&(this.options.content=this.$element.text(),this.$element.empty()),this.$element.addClass("markdown-content article")}async _initMarked(){let{marked:e}=this.options;if(e&&typeof e=="function")return this._marked=e,e;typeof e=="string"&&(e=[e,{}]);const{highlight:t,markedExts:n=[],htmlSandbox:s,assetBaseUrl:r,copyCode:o}=this.options,a={async:!0,gfm:!0,breaks:!0,highlight:t,markedExts:n,assetBaseUrl:r,htmlSandbox:s,copyCode:o};if(Array.isArray(e)){const[l,c]=e,h=mr.sharedMarkeds.get(l);if(h)return this._marked=h,h;const d=await mr.marked({...a,...c});d&&mr.sharedMarkeds.set(l,d),this._marked=d}else this._marked=await mr.marked({...a,...e});return this._marked}async afterInit(){try{await this._initMarked()}catch(e){console.error("[ZUI] Markdown: init marked failed",e)}await this.render()}parse(e,t){const n=this._marked;return e=e??this.options.content,n?n.parse(e,{...this.options,...t}):`<p style="white-space:pre-wrap">${e??""}</p>`}async render(e,t){super.render(e,t);const n=await this.parse();this.options.morph?this.$element.morphInner(`<div>${n}</div>`):this.$element.html(n)}static async parsed(e,t,n){let s;typeof n=="string"&&(s=n,n=this.sharedMarkeds.get(n));try{n=n||await this.marked(t),s&&n&&this.sharedMarkeds.set(s,n);let r=await n.parse(e,{async:!0,...t});return r.endsWith(`
  15. `)&&(r=r.substring(0,r.length-1)),(!r.startsWith("<")||!r.includes("<")||!r.endsWith(">"))&&(r=`<p style="white-space:pre-wrap">${r}</p>`),r}catch(r){console.error("[ZUI] Markdown: parsed failed",r)}return`<p style="white-space:pre-wrap">${e}</p>`}static async marked(e){const t=await mr.loadModule();if(!t)return;const{highlight:n,markedExts:s=[],html:r,assetBaseUrl:o,htmlSandbox:a,copyCode:l,...c}=e||{};n&&await no.loadModule()&&s.push(t.markedHighlight({emptyLangClass:"code-highlight",langPrefix:"code-highlight language-",async:!0,highlight:async(y,b)=>{if(a&&b==="html"){const x=y.trim();if((y.startsWith("<!DOCTYPE html>")||y.startsWith("<html ")||y.startsWith("<html>"))&&y.endsWith("</html>"))return`<div zui-create="htmlsandbox" zui-create-htmlsandbox='{html:${JSON.stringify(x).replaceAll("'","&#039;")}}'></div>`}if(b==="mermaid")return`<div zui-create="mermaid" zui-create-mermaid='{text:${JSON.stringify(y).replaceAll("'","&#039;")}}'></div>`;if(b==="svg"){const x=y.trim();if(x.startsWith("<svg")&&x.endsWith("</svg>"))return`<div zui-create="svgbox" zui-create-svgbox='{svg:${JSON.stringify(x).replaceAll("'","&#039;")}}'></div>`}const w=await no.codeToHtml(y,{theme:"github-light",structure:"inline",...typeof n=="object"?n:{},lang:b});return`<pre class="markdown-code-block code-highlight github-light code-lang-${b}" z-lang="${b}">${l?`<button type="button" title="${be.getLang("copy")}" class="btn size-xs copy-code-btn" zui-toggle="copybtn" zui-toggle-copybtn="{onCopy:() => _$element.next('code')}"><i class="icon icon-copy"></i></button>`:""}<code>${w}</code></pre>`}}));const h=new t.Marked(...s),d={};(a||n)&&(d.code=p=>p.text),r||(d.html=p=>Gn(p.text));const f=p=>/^(https?:)?\/\//.test(p);return d.image=({href:p,title:y,text:b})=>{if(p&&p.trim().toLowerCase().startsWith("javascript:"))return"";o&&p&&!p.startsWith("http")&&!p.startsWith("data:")&&(p=`${o}${p}`);const w=y?` title="${Gn(y)}"`:"",x=p&&f(p)?' referrerpolicy="no-referrer"':"";return`<img src="${Gn(p)}" alt="${Gn(b)}"${w}${x}>`},d.link=function({href:p,title:y,tokens:b}){if(p&&p.trim().toLowerCase().startsWith("javascript:"))return"";const w=this.parser.parseInline(b),x=y?` title="${Gn(y)}"`:"",T=p&&f(p),D=T?' referrerpolicy="no-referrer"':"",N=T?' target="_blank" rel="noopener noreferrer"':"";return`<a href="${Gn(p)}"${x}${N}${D}>${w}</a>`},h.use({renderer:d}),c&&h.setOptions(c),h}static get Module(){return gy.Module}static loadModule(){return gy.load()}};_l.NAME="Markdown",_l.DEFAULT={highlight:!0,copyCode:!0},_l.sharedMarkeds=new Map;let Fd=_l;Fd.register();class bl extends re{constructor(){super(...arguments),this._ref=pe(),this._transitionTimer=0}async update(){const{content:e,className:t,style:n,marked:s,morph:r,transition:o,...a}=this.props,l=await Fd.parsed(e,a,s);if(e!==this.props.content)return;const{base:c}=this;if(c&&e===this.props.content)if(r){const h=o?new Set(["DIV","P","H1","H2","H3","H4","H5","H6","LI","PRE","BLOCKQUOTE","TD","TH","DETAILS","SUMMARY"]):void 0;v(c).morphInner(`<div>${l}</div>`,o?{onNodeAdded:d=>{d.nodeType===Node.ELEMENT_NODE&&h.has(d.tagName)&&this.transitionText(d)},onElUpdated:d=>{const f=this._transitionEle;d===f?this.transitionText(d):f&&v(d).closest(f).length&&this.transitionText(f)}}:void 0)}else v(c).html(l)}transitionText(e){const t=this._transitionEle;t&&e!==t&&t.classList.remove("changing-text"),this._transitionTimer&&clearTimeout(this._transitionTimer),e.classList.add("changing-text"),this._transitionEle=e,this._transitionTimer=window.setTimeout(()=>{var n;(n=this._transitionEle)==null||n.classList.remove("changing-text")},500)}componentDidMount(){this.update()}componentDidUpdate(e){e.content!==this.props.content&&this.update()}componentWillUnmount(){clearTimeout(this._transitionTimer),this._transitionEle=void 0}render(e){const{className:t,style:n}=e;return g("div",{ref:this._ref,className:U("markdown-content article",t),style:n})}}bl.defaultProps={morph:!0,copyCode:!0};const vk=Object.freeze(Object.defineProperty({__proto__:null,MarkdownContent:bl},Symbol.toStringTag,{value:"Module"}));function _k(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)t.hasOwnProperty(n)&&(i[n]=t[n])}return i}function Od(i,e){return Array(e+1).join(i)}function vy(i){return i.replace(/^\n*/,"")}function _y(i){for(var e=i.length;e>0&&i[e-1]===`
  16. `;)e--;return i.substring(0,e)}function by(i){return _y(vy(i))}var bk=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Bd(i){return jd(i,bk)}var wy=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function Cy(i){return jd(i,wy)}function wk(i){return ky(i,wy)}var xy=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function Ck(i){return jd(i,xy)}function xk(i){return ky(i,xy)}function jd(i,e){return e.indexOf(i.nodeName)>=0}function ky(i,e){return i.getElementsByTagName&&e.some(function(t){return i.getElementsByTagName(t).length})}var Nt={};Nt.paragraph={filter:"p",replacement:function(i){return`
  17. `+i+`
  18. `}},Nt.lineBreak={filter:"br",replacement:function(i,e,t){return t.br+`
  19. `}},Nt.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(i,e,t){var n=Number(e.nodeName.charAt(1));if(t.headingStyle==="setext"&&n<3){var s=Od(n===1?"=":"-",i.length);return`
  20. `+i+`
  21. `+s+`
  22. `}else return`
  23. `+Od("#",n)+" "+i+`
  24. `}},Nt.blockquote={filter:"blockquote",replacement:function(i){return i=by(i).replace(/^/gm,"> "),`
  25. `+i+`
  26. `}},Nt.list={filter:["ul","ol"],replacement:function(i,e){var t=e.parentNode;return t.nodeName==="LI"&&t.lastElementChild===e?`
  27. `+i:`
  28. `+i+`
  29. `}},Nt.listItem={filter:"li",replacement:function(i,e,t){var n=t.bulletListMarker+" ",s=e.parentNode;if(s.nodeName==="OL"){var r=s.getAttribute("start"),o=Array.prototype.indexOf.call(s.children,e);n=(r?Number(r)+o:o+1)+". "}var a=/\n$/.test(i);return i=by(i)+(a?`
  30. `:""),i=i.replace(/\n/gm,`
  31. `+" ".repeat(n.length)),n+i+(e.nextSibling?`
  32. `:"")}},Nt.indentedCodeBlock={filter:function(i,e){return e.codeBlockStyle==="indented"&&i.nodeName==="PRE"&&i.firstChild&&i.firstChild.nodeName==="CODE"},replacement:function(i,e,t){return`
  33. `+e.firstChild.textContent.replace(/\n/g,`
  34. `)+`
  35. `}},Nt.fencedCodeBlock={filter:function(i,e){return e.codeBlockStyle==="fenced"&&i.nodeName==="PRE"&&i.firstChild&&i.firstChild.nodeName==="CODE"},replacement:function(i,e,t){for(var n=e.firstChild.getAttribute("class")||"",s=(n.match(/language-(\S+)/)||[null,""])[1],r=e.firstChild.textContent,o=t.fence.charAt(0),a=3,l=new RegExp("^"+o+"{3,}","gm"),c;c=l.exec(r);)c[0].length>=a&&(a=c[0].length+1);var h=Od(o,a);return`
  36. `+h+s+`
  37. `+r.replace(/\n$/,"")+`
  38. `+h+`
  39. `}},Nt.horizontalRule={filter:"hr",replacement:function(i,e,t){return`
  40. `+t.hr+`
  41. `}},Nt.inlineLink={filter:function(i,e){return e.linkStyle==="inlined"&&i.nodeName==="A"&&i.getAttribute("href")},replacement:function(i,e){var t=e.getAttribute("href");t&&(t=t.replace(/([()])/g,"\\$1"));var n=wl(e.getAttribute("title"));return n&&(n=' "'+n.replace(/"/g,'\\"')+'"'),"["+i+"]("+t+n+")"}},Nt.referenceLink={filter:function(i,e){return e.linkStyle==="referenced"&&i.nodeName==="A"&&i.getAttribute("href")},replacement:function(i,e,t){var n=e.getAttribute("href"),s=wl(e.getAttribute("title"));s&&(s=' "'+s+'"');var r,o;switch(t.linkReferenceStyle){case"collapsed":r="["+i+"][]",o="["+i+"]: "+n+s;break;case"shortcut":r="["+i+"]",o="["+i+"]: "+n+s;break;default:var a=this.references.length+1;r="["+i+"]["+a+"]",o="["+a+"]: "+n+s}return this.references.push(o),r},references:[],append:function(i){var e="";return this.references.length&&(e=`
  42. `+this.references.join(`
  43. `)+`
  44. `,this.references=[]),e}},Nt.emphasis={filter:["em","i"],replacement:function(i,e,t){return i.trim()?t.emDelimiter+i+t.emDelimiter:""}},Nt.strong={filter:["strong","b"],replacement:function(i,e,t){return i.trim()?t.strongDelimiter+i+t.strongDelimiter:""}},Nt.code={filter:function(i){var e=i.previousSibling||i.nextSibling,t=i.parentNode.nodeName==="PRE"&&!e;return i.nodeName==="CODE"&&!t},replacement:function(i){if(!i)return"";i=i.replace(/\r?\n|\r/g," ");for(var e=/^`|^ .*?[^ ].* $|`$/.test(i)?" ":"",t="`",n=i.match(/`+/gm)||[];n.indexOf(t)!==-1;)t=t+"`";return t+e+i+e+t}},Nt.image={filter:"img",replacement:function(i,e){var t=wl(e.getAttribute("alt")),n=e.getAttribute("src")||"",s=wl(e.getAttribute("title")),r=s?' "'+s+'"':"";return n?"!["+t+"]("+n+r+")":""}};function wl(i){return i?i.replace(/(\n+\s*)+/g,`
  45. `):""}function Sy(i){this.options=i,this._keep=[],this._remove=[],this.blankRule={replacement:i.blankReplacement},this.keepReplacement=i.keepReplacement,this.defaultRule={replacement:i.defaultReplacement},this.array=[];for(var e in i.rules)this.array.push(i.rules[e])}Sy.prototype={add:function(i,e){this.array.unshift(e)},keep:function(i){this._keep.unshift({filter:i,replacement:this.keepReplacement})},remove:function(i){this._remove.unshift({filter:i,replacement:function(){return""}})},forNode:function(i){if(i.isBlank)return this.blankRule;var e;return(e=Hd(this.array,i,this.options))||(e=Hd(this._keep,i,this.options))||(e=Hd(this._remove,i,this.options))?e:this.defaultRule},forEach:function(i){for(var e=0;e<this.array.length;e++)i(this.array[e],e)}};function Hd(i,e,t){for(var n=0;n<i.length;n++){var s=i[n];if(kk(s,e,t))return s}}function kk(i,e,t){var n=i.filter;if(typeof n=="string"){if(n===e.nodeName.toLowerCase())return!0}else if(Array.isArray(n)){if(n.indexOf(e.nodeName.toLowerCase())>-1)return!0}else if(typeof n=="function"){if(n.call(i,e,t))return!0}else throw new TypeError("`filter` needs to be a string, array, or function")}function Sk(i){var e=i.element,t=i.isBlock,n=i.isVoid,s=i.isPre||function(d){return d.nodeName==="PRE"};if(!(!e.firstChild||s(e))){for(var r=null,o=!1,a=null,l=Ty(a,e,s);l!==e;){if(l.nodeType===3||l.nodeType===4){var c=l.data.replace(/[ \r\n\t]+/g," ");if((!r||/ $/.test(r.data))&&!o&&c[0]===" "&&(c=c.substr(1)),!c){l=Ud(l);continue}l.data=c,r=l}else if(l.nodeType===1)t(l)||l.nodeName==="BR"?(r&&(r.data=r.data.replace(/ $/,"")),r=null,o=!1):n(l)||s(l)?(r=null,o=!0):r&&(o=!1);else{l=Ud(l);continue}var h=Ty(a,l,s);a=l,l=h}r&&(r.data=r.data.replace(/ $/,""),r.data||Ud(r))}}function Ud(i){var e=i.nextSibling||i.parentNode;return i.parentNode.removeChild(i),e}function Ty(i,e,t){return i&&i.parentNode===e||t(e)?e.nextSibling||e.parentNode:e.firstChild||e.nextSibling||e.parentNode}var Vd=typeof window<"u"?window:{};function Tk(){var i=Vd.DOMParser,e=!1;try{new i().parseFromString("","text/html")&&(e=!0)}catch{}return e}function $k(){var i=function(){};return Dk()?i.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t}:i.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t},i}function Dk(){var i=!1;try{document.implementation.createHTMLDocument("").open()}catch{Vd.ActiveXObject&&(i=!0)}return i}var Ik=Tk()?Vd.DOMParser:$k();function Mk(i,e){var t;if(typeof i=="string"){var n=Nk().parseFromString('<x-turndown id="turndown-root">'+i+"</x-turndown>","text/html");t=n.getElementById("turndown-root")}else t=i.cloneNode(!0);return Sk({element:t,isBlock:Bd,isVoid:Cy,isPre:e.preformattedCode?Ek:null}),t}var Wd;function Nk(){return Wd=Wd||new Ik,Wd}function Ek(i){return i.nodeName==="PRE"||i.nodeName==="CODE"}function Ak(i,e){return i.isBlock=Bd(i),i.isCode=i.nodeName==="CODE"||i.parentNode.isCode,i.isBlank=Pk(i),i.flankingWhitespace=Lk(i,e),i}function Pk(i){return!Cy(i)&&!Ck(i)&&/^\s*$/i.test(i.textContent)&&!wk(i)&&!xk(i)}function Lk(i,e){if(i.isBlock||e.preformattedCode&&i.isCode)return{leading:"",trailing:""};var t=Rk(i.textContent);return t.leadingAscii&&$y("left",i,e)&&(t.leading=t.leadingNonAscii),t.trailingAscii&&$y("right",i,e)&&(t.trailing=t.trailingNonAscii),{leading:t.leading,trailing:t.trailing}}function Rk(i){var e=i.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:e[1],leadingAscii:e[2],leadingNonAscii:e[3],trailing:e[4],trailingNonAscii:e[5],trailingAscii:e[6]}}function $y(i,e,t){var n,s,r;return i==="left"?(n=e.previousSibling,s=/ $/):(n=e.nextSibling,s=/^ /),n&&(n.nodeType===3?r=s.test(n.nodeValue):t.preformattedCode&&n.nodeName==="CODE"?r=!1:n.nodeType===1&&!Bd(n)&&(r=s.test(n.textContent))),r}var zk=Array.prototype.reduce,Fk=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function Cl(i){if(!(this instanceof Cl))return new Cl(i);var e={rules:Nt,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(t,n){return n.isBlock?`
  46. `:""},keepReplacement:function(t,n){return n.isBlock?`
  47. `+n.outerHTML+`
  48. `:n.outerHTML},defaultReplacement:function(t,n){return n.isBlock?`
  49. `+t+`
  50. `:t}};this.options=_k({},e,i),this.rules=new Sy(this.options)}Cl.prototype={turndown:function(i){if(!jk(i))throw new TypeError(i+" is not a string, or an element/document/fragment node.");if(i==="")return"";var e=Dy.call(this,new Mk(i,this.options));return Ok.call(this,e)},use:function(i){if(Array.isArray(i))for(var e=0;e<i.length;e++)this.use(i[e]);else if(typeof i=="function")i(this);else throw new TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(i,e){return this.rules.add(i,e),this},keep:function(i){return this.rules.keep(i),this},remove:function(i){return this.rules.remove(i),this},escape:function(i){return Fk.reduce(function(e,t){return e.replace(t[0],t[1])},i)}};function Dy(i){var e=this;return zk.call(i.childNodes,function(t,n){n=new Ak(n,e.options);var s="";return n.nodeType===3?s=n.isCode?n.nodeValue:e.escape(n.nodeValue):n.nodeType===1&&(s=Bk.call(e,n)),Iy(t,s)},"")}function Ok(i){var e=this;return this.rules.forEach(function(t){typeof t.append=="function"&&(i=Iy(i,t.append(e.options)))}),i.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function Bk(i){var e=this.rules.forNode(i),t=Dy.call(this,i),n=i.flankingWhitespace;return(n.leading||n.trailing)&&(t=t.trim()),n.leading+e.replacement(t,i,this.options)+n.trailing}function Iy(i,e){var t=_y(i),n=vy(e),s=Math.max(i.length-t.length,e.length-n.length),r=`
  51. `.substring(0,s);return t+r+n}function jk(i){return i!=null&&(typeof i=="string"||i.nodeType&&(i.nodeType===1||i.nodeType===9||i.nodeType===11))}const My=new Ni("turndown",{src:["turndown/turndown.js"],check:"TurndownService"}),Ny=async i=>{const e=await My.load();if(!e)throw new Error("Turndown service not loaded");const t=new e(i),{gfm:n}=i||{};if(n){const s=window.turndownPluginGfm;if(s)if(n===!0)t.use(s.gfm);else for(const r of n)t.use(s[r]);else console.warn("[ZUI] turndownPluginGfm not found.")}return t};let Kd;const Ey=async i=>(Kd||(Kd=await Ny({gfm:!0})),Kd.turndown(i));class Ay extends re{constructor(){super(...arguments),this._copied=fe(!1),this._copyTimer=0,this._handleCopyBtnClick=async()=>{let e;const{content:t,onCopy:n}=this.props;if(typeof n=="function")e=n();else{const s=this.base.querySelector(".ai-message-bubble-content");e=s?{html:s.innerHTML}:{},typeof t=="string"?e.text=t:v.isPlainObject(t)&&"markdown"in t?e.text=t.markdown:s&&"html"in e&&(e.text=await Ey(e.html))}await kh(e),this._copied.value=!0,this._copyTimer&&clearTimeout(this._copyTimer),this._copyTimer=window.setTimeout(()=>{this._copied.value=!1,this._copyTimer=0},2e3)}}componentWillUnmount(){this._copyTimer&&clearTimeout(this._copyTimer)}_renderAvatar(e){const{role:t="user",avatar:n,store:s,userName:r}=e;if(n===!1)return null;if(typeof n=="object")return g(ts,{...n});const o=r??t;let a,l,c="";c={user:"contacts",assistant:"ai",system:"chats"}[t],t==="assistant"&&(a="linear-gradient(to left, var(--color-primary-500) 0%, var(--color-secondary-500) 50%, var(--color-secondary-600) 100%)",l="#fff");let d={className:"ai-message-bubble-avatar",background:a,text:o,code:o,icon:c,foreColor:l,circle:!0};return s&&(d=s.getAvatar("role",{role:t},d)),d?g(ts,{...d}):null}_renderMarkdownContent(e,t){return g(bl,{key:"content",className:U("ai-markdown-content",t),content:e,highlight:!0,marked:"ai-message-bubble",htmlSandbox:!0})}_renderCustomContent(e){return v.isPlainObject(e)&&"markdown"in e?this._renderMarkdownContent(e.markdown):g(de,{key:"content",content:e})}_renderActions(e){const{showCopy:t=!0,actions:n,date:s,isEmpty:r}=e,o=[];if(t){const a=this._copied.value;o.push({btnType:a?"success-pale":"ghost",icon:a?"check":"copy text-gray",hint:Se("copy"),text:a?Se("copied"):null,rounded:"lg",disabled:r,onClick:r?void 0:this._handleCopyBtnClick})}return n&&o.push(...n),s&&o.push({type:"text",className:"muted",text:Ze(s,"yyyy-MM-dd hh:mm")}),o.length?g(Fe,{key:"actions",class:"ai-message-actions",items:o,size:"sm",gap:2}):null}render(e){const{role:t="user",avatar:n,content:s,children:r,className:o}=e;return g("div",{className:`ai-message-bubble is-role-${t}${this._copied.value?" is-copied":""} ${o}`},n===!1?null:this._renderAvatar(e),g("div",{class:"ai-message-bubble-container"},s?this._renderCustomContent(s):null,r,this._renderActions(e)))}}const Py=class Jb extends qe{afterInit(){this.$element.addClass("htmldiff"),this.render()}async update(e){const{before:t="",after:n="",className:s,dataPrefix:r,atomicTags:o}={...this.options,...e},a=await Jb.diff(t,n,s,r,o);this.element.innerHTML=a}render(e){super.render(e),this.update()}static async diff(e,t,n,s,r){return(await this.loadModule())(e,t,n,s,r)}static async loadModule(){return this.Module||(this.Module=await v.getLib("htmldiff")),this.Module}};Py.NAME="HTMLDiff";let qd=Py;v.registerLib("htmldiff",{src:["htmldiff/htmldiff.min.js"],check:"htmldiff"});class Hk extends re{constructor(){super(...arguments),this._ref=pe()}get HTMLDiffer(){return this._HTMLDiffer}componentDidMount(){this._HTMLDiffer=new qd(this._ref.current,this.props)}componentDidUpdate(e){(e.before!==this.props.before||e.after!==this.props.after)&&this.update()}componentWillUnmount(){var e;(e=this._HTMLDiffer)==null||e.destroy()}update(){var e;return(e=this._HTMLDiffer)==null?void 0:e.update()}render(e){const{className:t}=e;return g("div",{ref:this._ref,className:U("htmldiff",t)})}}const ti=(i,e,t)=>Se(`zentaoAgentResult.${i}`,e,t);let Gd=class extends re{_renderValue(e){if(e==null)return"";if(typeof e!="object")return e;const t=Object.keys(e),n=t.length===1&&Array.isArray(e[t[0]])?e[t[0]]:e;if(Array.isArray(n)){const s=n[0];return s&&(s.title||s.name)?g("ul",null,n.map(r=>g("li",null,r.title||r.name))):ti("dataListSizeInfo",[n.length])}return ti("notSupportPreview")}_renderChangeProp(e,t,n,s){if(n[e]===void 0)return null;let r=s[e];r==null&&(r=""),t==null&&(t=""),typeof r=="string"&&r.length&&(r=v("<div/>").html(r).text());const o=typeof t=="string"?t:JSON.stringify(t),a=typeof r=="string"?r:JSON.stringify(r),l=o===a;let c=null;return l?c=this._renderValue(t):a.length?c=g(Hk,{className:"article whitespace-prewrap",before:a,after:o}):c=g("div",{class:"htmldiff article whitespace-prewrap"},g("ins",{"data-operation-index":"0"},o)),g("tr",{class:"whitespace-pre-wrap",key:e},g("td",{class:"font-bold"},n[e]),g("td",null,c))}_renderResult(e){const{result:t,objectType:n,objectID:s,tool:r,targetForm:o,objectData:a,objectProps:l}=e,c=(a==null?void 0:a[n])||{},h=l[n],d=!o||o==="empty.empty",f=r.parameters.properties.data,p=f.properties,y=f.title===h.common;return d||(h.title===void 0&&(h.title=f.title),Object.keys(p).forEach(b=>{h[b]===void 0&&(h[b]=p[b].title||p[b].description)})),y&&c?[g("h6",{key:"changeTitle"},De(ti("changeTitleFormat"),{type:h.common||n,id:s?`#${s}`:""})),g("table",{key:"changeTable",class:"table bordered condensed",style:"min-width: 600px"},g("thead",null,g("tr",null,g("th",{style:"width: 100px;"},ti("changeProp")),g("th",null,ti("changeDetail")))),g("tbody",null,Object.entries(t.data||{}).map(([b,w])=>this._renderChangeProp(b,w,h,c))))]:[g("h6",{key:"name"},e.targetFormName),g("div",{key:"data",class:"ring rounded p-2 article whitespace-prewrap col gap-2 success-pale"},Object.entries(t.data).map(b=>{const[w,x]=b;return g("div",{class:"text-fore"},g("div",{class:"font-bold"},h[w]||w),g("div",null,this._renderValue(x)))}))]}_renderActions(e){const{actions:t=[],onOpenTargetForm:n=window.openPageForm,targetFormName:s,formLocation:r,result:o,targetForm:a}=e;if(t===!1)return null;const l=String(s||a),c=[n?{text:ti("applyFormFormat",[l]),onClick:()=>{n.call(this,r,o.data,()=>Ln.show({content:ti("applyFormSuccess",[l]),type:"success"}))},type:"primary-pale",trailingIcon:"icon-arrow-right"}:null,...t].filter(Boolean);return g(Fe,{className:"ai-tool-call-result-actions",items:c})}render(e){const{className:t}=e;return g("div",{className:U("ai-tool-call-result col gap-2 overflow-x-auto",t)},e.result.title?g("h4",null,e.result.title):null,this._renderResult(e),e.result.summary?g("div",{className:"whitespace-pre-line"},g("i",{class:"icon icon-lightbulb text-gray mr-1"}),e.result.summary):null,this._renderActions(e))}};class Ly extends re{constructor(){super(...arguments),this._handleFormSubmit=(e,t)=>{var o;const{message:n,onSubmitForm:s}=this.props,{onSubmit:r}=((o=n.$form)==null?void 0:o.config)||{};return r&&r.call(this,t)===!1||s==null||s.call(this,t,n),!1},this._getCopyContents=()=>{var s;const{message:e}=this.props,{content:t="",reasonContent:n=""}=e;return{text:[n,t].filter(Boolean).join(`
  52. `),html:(s=this.base.querySelector(".ai-message-bubble-content"))==null?void 0:s.innerHTML}}}_getToolCallingStateMessage(e){return e.status==="wait"?Se("processing"):e.message}_renderMarkdownContent(e,t){return g(bl,{className:U("ai-markdown-content",t),content:e,highlight:!0,assetBaseUrl:this.props.assetBaseUrl,marked:"ai-message-bubble",htmlSandbox:!0,transition:ip==="development"})}_renderCustomContent(e){return v.isPlainObject(e)&&"markdown"in e?this._renderMarkdownContent(e.markdown):g(de,{content:e})}_renderToolcall(e,t){t=t||{status:"wait",name:e.name??e.function.name};const{status:n,message:s,name:r,error:o,result:a={}}=t,{view:l,actions:c,info:h}=a,d=Se(`toolCallingStatus.${t.status}`)??t.status,f={wait:"spinner-indicator spin text-gray",running:"spinner-indicator spin text-gray",finished:"check-circle text-success",error:"alert text-danger",cancelled:"ban-circle text-warning"}[n],p=!c&&!l,y=s||Se(`toolCallingMessages.${n}`);return g(Ar,{key:`${e.id}:${p}`,class:"ai-message-bubble-shape ai-message-tool-calling",bordered:!0,defaultCollapsed:p,"data-status":n,header:g("div",{className:"row items-center gap-2 flex-auto min-w-0"},g($e,{icon:`${f} flex-none`,title:d}),g("div",{class:"flex-none whitespace-nowrap",title:d},r),g("div",{class:"text-gray text-sm flex-auto min-w-0 text-left",title:"messageText"},g("div",{class:`whitespace-nowrap overflow-hidden text-ellipsis max-w-full${n==="wait"||n==="running"?" text-shimmer":""}`},y)))},s||p?g("div",{class:"text-gray text-sm"},y):null,l?this._renderCustomContent(l):null,h?this._renderCustomContent(h):null,o?g("div",{class:"text-danger text-sm"},o):null,c?Fe.render(c,[],{key:"actions",className:"ai-message-tool-calling-actions",btnType:"gray-outline",relativeTarget:t,size:"sm"},this):null)}_renderToolCalls(e){const t=e.$toolCallingStates||{},n=e.$toolCalls;return n!=null&&n.length?n.map(s=>this._renderToolcall(s,t[s.id])):null}_renderForm(e){const t={};e.config.width&&(t.width=Be(e.config.width));const n={displayType:"horz",...e.config.schema};return g("div",{className:"ai-message-form",style:t},g(Sd,{component:"form",header:e.config.title?g("div",{className:"form-header font-bold px-2"},e.config.title):null,footer:e.config.hint?g("div",{className:"form-footer px-2 text-gray text-sm"},e.config.hint):null,schema:n,defaultData:e.data??e.config.data,actions:[{btnType:"submit",type:"primary btn-wide",text:e.config.submitBtnText??be.getLang("confirm")}],onSubmit:this._handleFormSubmit}))}_renderTaskResults(e){return g("div",{class:"ai-message-bubble-content space-y-2"},e.map(t=>g(Gd,{className:"py-2",key:t.callID,...t})))}_renderContent(e){var d,f;const{message:t,noThinkLog:n}=e,{content:s="",reasonContent:r="",role:o,$form:a,custom_data:l={}}=t;if((d=l.taskResults)!=null&&d.length&&o!=="assistant")return this._renderTaskResults(l.taskResults);if(a)return this._renderForm(a);if(!s.length&&!r.length)return(f=t.$toolCalls)!=null&&f.length?null:g("div",{className:"px-4 py-2"},t.$error?g("div",{className:"text-danger"},t.$error):g($e,{icon:"spinner-indicator",className:"spin muted"}),t.$stateText?g("span",{className:"text-gray text-shimmer text-sm ml-2"},t.$stateText):null);let h;if(r)if(n)h=s.length?null:g("div",{className:"text-gray flex items-center gap-2 my-1.5"},g($e,{icon:"spinner-indicator",className:"spin muted"}),g("span",null,r.length?r.split(`
  53. `).pop():Se("processing")));else{const p=t.$reasonType==="thinking",y=t.$reasonTime,b=y?Se("timeConsuming",{time:(y/1e3).toFixed(1)}):"";h=g("details",{open:!s.length,class:"ai-message-thinking text-sm px-2 py-1 rounded mt-2 mb-2"},g("summary",{class:"border-b cursor-pointer"},s.length?`${Se(p?"thinkCompleted":"completed")}${b?`(${b})`:""}`:g("span",{class:"text-shimmer"},Se(p?"thinking":"processing")),s.length?null:g($e,{icon:"spinner-indicator",className:"spin muted ml-2"})),this._renderMarkdownContent(r,"ai-message-thinking-content pl-2.5"))}return!h&&!s?null:g("div",{className:"ai-message-bubble-content"},h,s?this._renderMarkdownContent(s):null)}render(e){const{message:t,noAvatar:n,store:s}=e,{content:r="",reasonContent:o="",role:a="user",custom_data:l={}}=t,c=!r.length&&!o.length,h=this._renderContent(e),d=this._renderToolCalls(t);return g(Ay,{store:s,className:t.$state?`is-state-${t.$state}`:"",role:l.asRole??a,date:t.created_at,avatar:n?!1:void 0,isEmpty:c,onCopy:this._getCopyContents},h||!d?g("div",{key:"content",className:"ai-message-bubble-shape ai-message-main-content"},h):null,d)}}function Ry(i){i=i||location.search,i[0]==="?"&&(i=i.substring(1));try{const e=new URLSearchParams(i),t={};for(const n of e.keys())t[n]=e.getAll(n).join(",");return t}catch{return{}}}function zy(i,e){if(!i)return{url:i};const{config:t}=window;if(/^https?:\/\//.test(i)){const c=window.location.origin;if(!i.includes(c))return{external:!0,url:i};i=(t.webRoot.endsWith("/")?"/":"")+i.substring((c+t.webRoot).length)}const n=i.split("#"),s=n[0].split("?"),r=s[1],o=r?Ry(r):{};let a=s[0];e=e||t.requestType,e==="auto"&&(r!=null&&r.length||(e="PATH_INFO"),e=i.startsWith(`${t.router}?${t.moduleVar}=`)?"GET":"PATH_INFO");const l={url:i,isOnlyBody:o.onlybody==="yes",vars:[],hash:n[1]||"",params:o,tid:o.tid||"",requestType:e};if(e==="GET"){l.moduleName=o[t.moduleVar]||"index",l.methodName=o[t.methodVar]||"index",l.viewType=o[t.viewVar]||t.defaultView;for(const c in o)c!==t.moduleVar&&c!==t.methodVar&&c!==t.viewVar&&c!=="onlybody"&&c!=="tid"&&l.vars.push([c,o[c]])}else{let c=a.lastIndexOf("/");c===a.length-1&&(a=a.substring(0,c),c=a.lastIndexOf("/")),c>=0&&(a=a.substring(c+1));const h=a.lastIndexOf(".");h>=0?(l.viewType=a.substring(h+1),a=a.substring(0,h)):l.viewType=t.defaultView;const d=a.split(t.requestFix);if(l.moduleName=d[0]||"index",l.methodName=d[1]||"index",d.length>2)for(let f=2;f<d.length;f++)l.vars.push(["",d[f]]),o["$"+(f-1)]=d[f]}return l}function ut(i,e,t,n,s,r){if(typeof i=="object")return ut(i.moduleName,i.methodName,i.vars,i.viewType,i.hash,i.params);const o=window.config||{};if(t){typeof t=="string"&&(t=t.split("&"));for(let c=0;c<t.length;c++){const h=t[c];if(typeof h=="string"){const d=h.split("=");t[c]=[d.shift(),d.join("=")]}}}const a=[],l=o.requestType==="GET";if(l){if(a.push(o.router,"?",o.moduleVar,"=",i,"&",o.methodVar,"=",e),t)for(const c of t)a.push("&",c[0],"=",c[1]);n&&n!==o.defaultView&&a.push("&",o.viewVar,"=",n)}else{if(a.push(o.webRoot),Tn(o.instCode)&&a.push(o.instCode,"/"),o.requestType=="PATH_INFO"&&a.push(i,o.requestFix,e),o.requestType=="PATH_INFO2"&&a.push("index.php/",i,o.requestFix,e),t)for(const c of t)a.push(o.requestFix+c[1]);n=n||o.defaultView,n&&a.push(".",n)}return r&&Object.keys(r).forEach(c=>{const h=r[c];c[0]!=="$"&&a.push(!l&&!a.includes("?")?"?":"&",c,"=",h)}),Tn(o.instCode)&&l&&a.push("&instCode","=",o.instCode),typeof s=="string"&&a.push(s.startsWith("#")?"":"#",s),a.join("")}const Fy=i=>{v.isPlainObject(i)||(i={container:i});const{container:e,label:t=".form-label",item:n=".form-group",text:s=".text",paddingRight:r=0,paddingLeft:o=0,minWidth:a=0,maxWidth:l,cssVar:c="--form-horz-label-width"}=i,h=v(e);if(!h.length)return;let d=a,f=0,p=r,y=o;h.find(n).each((w,x)=>{const T=v(x);if(!T.isVisible())return;const D=T.find(t);if(!D.length)return;const N=getComputedStyle(D[0]);p||(p=Number.parseFloat(N.paddingRight),y=Number.parseFloat(N.paddingLeft)),f=Math.max(f,Number.parseFloat(N.width)),d=Math.max(d,D.find(s).outerWidth()||0)});let b=d+p+y;l&&(b=Math.min(b,l)),b>f&&h.css(c,`${b}px`)};v.fn._append=v.fn.append,v.fn._prepend=v.fn.prepend,v.fn._before=v.fn.before,v.fn._after=v.fn.after,v.fn._html=v.fn.html;function xl(i,e){return typeof e=="string"&&(e.includes("zui-create")||e.includes("zui-init"))&&i.zuiInit(),i}function Uk(i){return!!i&&i.nodeType===1}v.extend(v.fn,{append(...i){return xl(this._append(...i),i.join(""))},prepend(...i){return xl(this._prepend(...i),i.join(""))},before(...i){const e=this.parent();return this._before(...i),xl(e,i.join("")),this},after(...i){const e=this.parent();return this._after(...i),xl(e,i.join("")),this},html(i,e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(i===void 0)return this;const t=/<script[\s>]/.test(i);return typeof e=="boolean"&&(e={zuiInit:e}),this.each((n,s)=>{Uk(s)&&(t?v(s).empty()._append(i):s.innerHTML=i,(e==null?void 0:e.zuiInit)!==!1&&v(s).zuiInit())})}});const Vk=Object.freeze(Object.defineProperty({__proto__:null,autoLabelWidth:Fy,createLink:ut,parseLink:zy,parseUrlParams:Ry},Symbol.toStringTag,{value:"Module"}));window.$&&Object.assign(window.$,{...Vk,parseRawData:Go});class Oy extends ot{constructor(){super(...arguments),this._subProviderMap=fe({}),this._chat=Ce(()=>this.props.store.getChat(this.props.chatID)),this._selectedProviders=Ce(()=>this.props.store.reactions.getUsedChatContextSettings({chat:this._chat.value})),this._recommendProviders=Ce(()=>{const{selectedProviders:e}=this;if(e.length>3)return[];const t=new Set(e.map(s=>s.code)),n=[];for(const s of this._providerMap.value.values())s.recommend&&!t.has(s.code)&&n.push(s);return n.sort((s,r)=>s.order-r.order),n.length>3&&(n.length=3),n}),this._chatContextProviders=Ce(()=>{const e=this._chat.value;return e?this.store.reactions.getChatContextProviders(e):[]}),this._providerMap=Ce(()=>{const e=new Map;this._chatContextProviders.value.forEach(s=>{e.set(s.code,s)});const n=this._subProviderMap.value;return Object.entries(n).forEach(([s,r])=>{e.set(s,r)}),e}),this._handleTriggerClick=e=>{e.target instanceof HTMLElement&&e.target.closest(".ai-chat-context-provider-item")&&e.preventDefault()},this._handleClickItem=async e=>{const{_item:t}=e.item;if(e.event.preventDefault(),e.event.stopPropagation(),t.items){const n=await this.reactions.getSubChatContextProviders(this._chat.value,t);this.setState(({parentProviders:s})=>{const r=this._subProviderMap.value;return n.forEach(o=>{r[o.code]=o}),this._subProviderMap.value={...r},{parentProviders:[...s,{provider:t,items:n}]}});return}t.data?this.reactions.toggleChatContext(this._chat.value,t):t.contexts&&(this.reactions.applyProviderContextSettings(this._chat.value,t),this.close()),t.command&&(this.reactions.executeCommand(t.command,e.event),this.close())},this._goToParentList=()=>{this.setState(({parentProviders:e})=>(e.pop(),{parentProviders:[...e]}))},this._handleGoToParentList=e=>{e.stopPropagation(),this._goToParentList()},this._handleClickProviderItem=e=>{this.reactions.toggleChatContext(this._chat.value,e)},this._renderProviderItem=(e,t)=>{const n=e.display??e.title;return Tn(n)?g("div",{key:e.code,className:`ai-chat-context-provider-item ${t?" selected":"is-recommend"}`,title:e.hint??n},g($e,{icon:e.icon}),g("div",{className:"text"},n),g("div",{className:"ai-chat-context-provider-item-btn state",onClick:this._handleClickProviderItem.bind(this,e)},g($e,{icon:t?"close":"plus"}))):null}}get chatContextProviders(){return this._chatContextProviders.value}get selectedProviders(){return this._selectedProviders.value}get recommendProviders(){return this._recommendProviders.value}get parentProvider(){return this.state.parentProviders[this.state.parentProviders.length-1]}get store(){return this.props.store}get reactions(){return this.props.store.reactions}_getProviders(e){const t=this._providerMap.value;return t.size?e.reduce((n,s)=>{const r=t.get(s);return r&&n.push(r),n},[]):[]}getDefaultState(e){return{...super.getDefaultState(e),value:"",open:!1,parentProviders:[]}}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return n.onClick=this._handleTriggerClick,n}_renderTrigger(e,t){return[e.disabled?null:g(we,{icon:"at scale-90",size:18,hint:"添加上下文"}),this.selectedProviders.map(n=>this._renderProviderItem(n,!n.disabled)),e.disabled?null:this.recommendProviders.map(n=>this._renderProviderItem(n,!1))]}_getItems(e,t){const{parentProviders:n}=t,s=this._chatContextProviders.value,r=n.length?n[n.length-1].items:s;r.sort((a,l)=>{const c=(a.recommend?0:1)-(l.recommend?0:1);return c||a.order-l.order});const o=new Set(this.selectedProviders.map(a=>a.code));return r.reduce((a,l)=>{const c=o.has(l.code);return l.hidden||a.push({...l,key:l.code,items:void 0,trailingIcon:l.items?"angle-right":c?"check":null,selected:c,disabled:!l.data&&!l.command&&!l.items&&!l.contexts,_item:l}),a},[])}_getSearchBoxProps(e,t){var n;return{placeholder:((n=this.parentProvider)==null?void 0:n.provider.title)??"搜索..."}}_renderPop(e,t){const n=this._getItems(e,t),s=t.parentProviders.length;return g(dt,{wrapClass:"ai-chat-context-picker-list",className:"ai-chat-context-picker-items",maxHeight:300,header:s?g(we,{icon:"arrow-left",size:"sm",type:"ghost",className:"absolute left-2 top-2 z-10",onClick:this._handleGoToParentList}):null,searchBox:this._getSearchBoxProps(e,t),items:n,onClickItem:this._handleClickItem})}}Oy.defaultProps={...ot.defaultProps,className:"ai-chat-context-picker",popClass:"ai-chat-context-picker-pop popup rounded",popWidth:"auto",popMinWidth:200,popMaxWidth:300,popPlacement:"top-start",popMaxHeight:9999};class By extends re{constructor(e){super(e),this._headerRef=pe(),this._inputTimer=0,this._textareaRef=pe(),this._handleHeaderResize=()=>{const t=this._headerRef.current;t&&(this._headerHeight.value=t.clientHeight)},this._syncContent=()=>{const t=this._textareaRef.current;if(t){const n=t.value;this._content.value=n,this.props.store.updateUserPrompt(this.props.chatID,n)}},this._handleInput=()=>{this._inputTimer&&clearTimeout(this._inputTimer),this._inputTimer=window.setTimeout(()=>{this._syncContent(),this._inputTimer=0},100)},this._handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this._handleSend())},this._handleSend=async()=>{var o,a;this._inputTimer&&(clearTimeout(this._inputTimer),this._inputTimer=0,this._syncContent());const{disabled:t,loading:n,onSend:s}=this.props;if(!s||t||this.disabledSend)return;const r=this._content.value.trim();if(r&&!t&&!n){this._loading.value=!0;try{const l=(o=this.base)==null?void 0:o.querySelector("textarea");l&&(l.value=""),this._content.value="",await s(r,{model:this._model.value}),this.props.store.updateUserPrompt(this.props.chatID,"")}catch(l){const c=(a=this.base)==null?void 0:a.querySelector("textarea");c&&(c.value=r),this._content.value=r,this.props.store.updateUserPrompt(this.props.chatID,r),console.error(l)}this._loading.value=!1,v(this.textarea).autoHeight()}},this._handleModelChange=t=>{const n=t.target;this._model.value=n.value},this._content=fe(e.defaultContent||""),this._loading=fe(e.loading||!1),this._model=fe(e.defaultModel||""),this._headerHeight=fe(0)}get textarea(){var e;return(e=this.base)==null?void 0:e.querySelector("textarea")}get disabledSend(){return this.props.generating||this.props.disabled||this._loading.value||!this._content.value.trim().length}componentDidMount(){const e=this.textarea;e&&!this.props.disabled&&(v(e).autoHeight(),e.focus());const t=this._headerRef.current;t&&(this._headerRzObserver=new ResizeObserver(this._handleHeaderResize),this._headerRzObserver.observe(t),this._headerHeight.value=t.clientHeight)}componentWillUpdate(e){if(e.chatID!==this.props.chatID){const{textarea:t}=this;t&&(t.focus(),t.value="")}}componentWillUnmount(){var e;(e=this._headerRzObserver)==null||e.disconnect()}_renderModelSelector(e){const{llmProviders:t=[],canSelectModel:n}=e;if(!t.length)return null;const s=this._model.value,r=this.props.currentModel??s,o=r?t.find(a=>a.id===r):null;return!o&&!n?null:g("div",{class:"ai-model-selector",title:Se("selectModel"),"data-model":s},g("div",{class:`rounded ${o&&n?"primary-pale":"gray-pale"} px-1.5 flex items-center gap-2 backdrop-blur`},g($e,{icon:"ai"}),g("small",null,((o==null?void 0:o.name)||(o==null?void 0:o.id))??Se("defaultModel"))),n?g("select",{className:"form-control cursor-pointer",onChange:this._handleModelChange},g("option",{value:"",selected:s===""},`[${Se("defaultModel")}]`),t.map(a=>g("option",{value:a.id,selected:s===a.id},a.name??a.id))):null)}_renderContextSelector(e){let{contexts:t}=e;return typeof t=="function"&&(t=t(e.chat)),t===!0?null:Array.isArray(t)?g("div",{className:"ai-chat-sendbox-contexts py-2 row flex-wrap gap-1"},t.map(n=>g("div",{class:"ai-chat-context-provider-item text-gray border-strong",key:n.code},g($e,{icon:n.icon}),g("div",null,n.title)))):g(Oy,{disabled:!e.chat.$local.id||t==="readonly",chatID:e.chatID,store:e.store})}render(e){const{defaultContent:t,disabled:n,placeholder:s=Se("sendboxPlaceholder"),sendBtn:r,extraBtns:o}=e,a=this.disabledSend,l=this._renderModelSelector(e),c=!!l,h=this._headerHeight.value,d=typeof s=="function"?s(e.chat):s;return g("div",{className:`ai-chat-sendbox ${c?"has-toolbar":""}${h?" is-header-fixed":""}${n?" is-disabled":""}`,style:{"--ai-chat-sendbox-header-height":h?`${h}px`:void 0}},g("div",{className:"ai-chat-sendbox-container"},n?null:g("div",{className:"ai-sendbox-header",ref:this._headerRef},this._renderContextSelector(e)),g("textarea",{className:"ai-chat-sendbox-input form-control py-2",autoFocus:!n,placeholder:d,defaultValue:t,onKeyDown:this._handleKeyDown,onInput:this._handleInput,rows:2,ref:this._textareaRef}),g("div",{className:"ai-sendbox-footer"},g("div",{className:"ai-sendbox-toolbar"},l),g("div",{className:"ai-sendbox-actions"},o==null?void 0:o.map(f=>g(we,{type:"primary-pale",size:"sm",...f})),g(we,{key:"sendBtn",className:"size-sm ",icon:"send",type:a?"primary-pale":"primary",disabled:a,hint:Se("send")+" (Enter)",onClick:this._handleSend,...r})))))}}function kl(i){const{className:e="animate-pulse row gap-2 items-center",iconClass:t="w-7 h-7",text:n,textClass:s="text-gray"}=i;return g("div",{className:U("ai-loading-box",e)},g("div",{className:U("ai-loading bg-primary",t)}),n&&g("div",{className:U("ai-loading-text",s)},n))}let Zd=class extends re{constructor(e){super(e),this._loadChatError=fe(),this._loadID=0,this._chat=Ce(()=>{const t=this._chatID.value;return t?this.store.getChat(t):void 0}),this._loading=Ce(()=>this.props.store.isLoading||!this._chat.value&&!this.props.store.error),this._handleCreateChat=t=>{var n,s;(s=(n=this.props).onCreateChat)==null||s.call(n,t,this._chatID.value),this._chatID.value=t},this._handleSend=async(t,n)=>{var o;const s=(o=this.base)==null?void 0:o.querySelector(".ai-chat-view-messages");s&&(s.scrollTop=0);const r=this._chat.value;this.postMessage(t,r&&!r.$local.id?r.id:{model:n.model,localID:r==null?void 0:r.$local.id})},this._handleSubmitForm=(t,n)=>{const s=this._chat.value;if(!s)return;const r=s.$local.id??s.id;this.store.postFormDataToChat(r,t,{onCreateChat:this._handleCreateChat})},this._renderItem=t=>{var s;const n=t;return n.role==="tool"||(s=n.custom_data)!=null&&s.invisible?null:g(Ly,{store:this.props.store,message:n,chat:this.chat,noAvatar:this._noAvatar,noThinkLog:this._noThinkLog,assetBaseUrl:this.props.store.assetBaseUrl,onSubmitForm:this._handleSubmitForm})},this._chatID=fe(e.chatID)}get chat(){return this._chat.value}get store(){return this.props.store}get error(){return this.props.store.error}get loading(){return this._loading.value}async loadChat(e,t){const n=++this._loadID;if(e=e||this._chatID.value,e==="NEW"||t)e=await this.store.createLocalChat(t);else if(e)try{if(await this.store.tryLoadChat(e),n!==this._loadID)return;this._loadChatError.value=void 0}catch(s){if(n!==this._loadID)return;this._loadChatError.value={error:s,message:Se("errors.loadChatFailed"),type:"load-chat-failed"}}n===this._loadID&&(this._chatID.value=e)}async postMessage(e,t){const{store:n}=this,s=await n.postMessage({chat:t,...typeof e=="string"?{content:e}:e,onCreateChat:this._handleCreateChat});return this._chatID.value=s,s}async _init(){const{chatID:e="NEW",postMessage:t,creatingChat:n}=this.props;this._chatID.value=e,await this.loadChat(e,n),t&&await this.postMessage(t,this._chatID.value)}componentDidUpdate(e){(e.chatID!==this.props.chatID||e.postMessage!==this.props.postMessage||e.creatingChat!==this.props.creatingChat)&&this._init()}componentDidMount(){this._init()}_renderError(e,t){if(t=t??this.error,!t)return null;const{getErrorContent:n}=e,s=(n==null?void 0:n(t))??t.message;return g("div",{key:"error",className:"ai-chats-panel-error"},g(de,{className:"ai-chats-panel-error-content",content:s,generatorArgs:[e],generatorThis:this}))}render(e){var N,A,z,O;const t=this.chat;if(!t){const K=this._loadChatError.value||this.error;return K?this._renderError(e,K):g(kl,{text:Se("loading"),className:"animate-pulse h-full justify-center row gap-2 items-center"})}const{messages:n=[]}=t,s=!!t.$local.id,{noThinkLog:r,noAvatar:o,mode:a="full",embed:l=!1}=e,{hideUserMessage:c=a!=="full",hideHeader:h=a==="lite",sendbox:d=a==="full",noMessagesTip:f}=e,p=this.loading,y=!n.length,b=t.created_at||t.created_on||Date.now();let w=[...n].reverse();const{form:x}=t.$local,T=x&&!x.data;T?w.push({id:"form-0",role:"assistant",content:"",created_at:b,$form:x}):Tn((N=t.custom_data.form)==null?void 0:N.summary)&&w.push({id:"form-summary",role:"assistant",content:(A=t.custom_data.form)==null?void 0:A.summary,created_at:b}),t.custom_data.welcome&&w.push({id:"welcome",role:"assistant",content:t.custom_data.welcome,created_at:b}),c&&(w=w.filter(K=>{var Z;return(((Z=K.custom_data)==null?void 0:Z.asRole)??K.role)!=="user"})),this._noAvatar=o??c,this._noThinkLog=r??h;const D=c&&this._noAvatar&&!d;return g("div",{className:U(`ai-chat-view is-mode-${a}`,{"is-only-response":D,"is-embed":l,"is-no-message":y})},h?null:g("div",{className:"ai-chat-view-header"},g($e,{icon:"chat"}),g("div",{className:"ai-chat-view-title",title:t.title},t.$local.tempTitle??t.title)),g("div",{className:"ai-chat-view-body"},w.length?g($t,{className:"ai-chat-view-messages scrollbar-hover",itemKey:"id",items:w,itemRender:this._renderItem}):g("div",{className:"muted h-full center py-4 my-8"},p?g(kl,{text:Se("loading"),className:"animate-pulse col gap-2 items-center"}):g(de,{content:f??Se("noMessagesTip"),generatorArgs:[e],generatorThis:this}))),d&&g(By,{key:t.id,chat:t,store:this.store,chatID:t.id,disabled:!!this.store.error||T,onSend:this._handleSend,placeholder:T?Se("needSubmitFormFirst"):void 0,generating:t.$local.generating,llmProviders:e.store.chatModels,defaultModel:(z=t.settings)==null?void 0:z.model,currentModel:(O=t.custom_data)==null?void 0:O.model,canSelectModel:s,contexts:e.noContexts,...typeof e.sendbox=="object"?e.sendbox:{}}))}};function jy(i){const e=v(i)[0];if(!e)return!1;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.select(),!0;const t=window.getSelection;if(t){const n=t();if(n){const s=document.createRange();return s.selectNodeContents(e),n.removeAllRanges(),n.addRange(s),!0}}return!1}v.fn.selectText=function(){return this.each((i,e)=>{jy(e)})};class Wk extends re{constructor(){super(...arguments),this._renameChatID=fe(""),this._handleClickItem=e=>{var t,n;e.item.items||(n=(t=this.props).onSelectChat)==null||n.call(t,e.item.key)},this._getItemMoreActions=e=>{var r,o;const t=(o=(r=e.props.relativeTarget)==null?void 0:r.target)==null?void 0:o.key;if(!t)return;const{store:n}=this.props,s=n.getChat(t);return[s!=null&&s.$local.id?null:{icon:"edit",text:Se("rename"),onClick:this._startRenameChat.bind(this,t)},s!=null&&s.$local.id?null:{icon:"refresh",text:Se("updateTitle"),onClick:this._handleUpdateChatTitle.bind(this,t)},{icon:"trash",text:Se("deleteChat"),onClick:this._handleDeleteChat.bind(this,t)}]},this._startRenameChat=e=>{this._renameChatID.value=e,setTimeout(()=>{const t=v(this.base).find(`.item.is-renaming[z-key="${e}"]`).find("input");t.length&&(t[0].focus(),jy(t))},10)},this._handleDeleteChat=async(e,t)=>{var c,h,d,f;const{store:n}=this.props,s=n.chats.findIndex(p=>p.id===e);if(s===-1)return;const r=n.chats[s];if(!r||!await He.confirm({type:"custom",message:Se("deleteConfirm",{title:r.title}),custom:{}}))return;await n.deleteChat(e);const a=n.chats,l=((c=a[s])==null?void 0:c.id)||((h=a[0])==null?void 0:h.id);l&&((f=(d=this.props).onSelectChat)==null||f.call(d,l))},this._getItemActions=()=>[{icon:"ellipsis-v",type:"dropdown",caret:!1,items:this._getItemMoreActions}],this._handleUpdateChatTitle=e=>this.props.store.updateChatTitle(e),this._handleRenameChatTitleKeyUp=e=>{e.key==="Enter"&&this._handleRenameChatTitle(e)},this._handleRenameChatTitle=async e=>{const t=e.target.value;t.length&&await this.props.store.renameChatTitle(this._renameChatID.value,t),this._renameChatID.value=""}}autoScrollToCurrent(){const{currentChatID:e}=this.props;e&&v(this.base).find(`[z-key="${e}"]`).scrollIntoView({behavior:"smooth",block:"center"})}componentDidMount(){this.autoScrollToCurrent()}componentDidUpdate(e){e.currentChatID!==this.props.currentChatID&&this.autoScrollToCurrent()}_getItems(e){const{chats:t,currentChatID:n,store:s}=e,r=[],o=this._renameChatID.value,a={},l=e.getItem||(d=>{const f=d.id===n,p=d.id===o,y=p?void 0:s.getAvatar("chat",{chat:d},{icon:{icon:"chat",className:f?"text-primary":"text-gray"},size:20,background:"transparent"});return{type:"item",className:`item menu-item${p?" is-renaming":""}`,avatar:y,key:d.id,title:p?g("input",{className:"form-control",defaultValue:d.title,onChange:this._handleRenameChatTitle,onBlur:()=>this._renameChatID.value="",onKeyUp:this._handleRenameChatTitleKeyUp}):d.$local.tempTitle??d.title,hint:d.created_at?`${d.title}(${Ze(d.created_at,"yyyy-MM-dd hh:mm")})`:d.title,selected:f,component:"li",innerComponent:p?"div":"a",contentClass:f?"font-bold":"",actions:p||ay(d)?null:this._getItemActions}}),c=new Date,h=d=>(d=Ye(d),im(d,c)?"today":rm(d,c)?"yesterday":kr(d,c)?"thisMonth":Ze(d,"yyyy-MM"));return t.forEach(d=>{const f=d.created_at?h(d.created_at):"other";a[f]||(a[f]={type:f,start:d.created_at||0,items:[]}),a[f].items.push(l(d))}),Object.values(a).forEach(d=>{r.push({key:d.type,title:Se("dateGroup."+d.type,[],d.type),items:d.items})}),r}render(e){return g(Rt,{className:"ai-chats-list",items:this._getItems(e),onClickItem:this._handleClickItem,defaultNestedShow:!0,indent:0,nestedToggle:"a",hoverItemActions:!0,activeOnHover:!1})}}class Kk extends re{constructor(e){var n;super(e),this._searchValue=fe(""),this._loadedChats=fe({}),this._loading=fe(""),this._currentTab=Ce(()=>{const s=this._currentTabKey.value;return this.props.tabs.find(r=>r.key===s)||{key:"RECENTS",title:Se("recentChats"),chatTypes:["chat"]}}),this._filteredChats=Ce(()=>{const s=this._searchValue.value,{chats:r,chatTypes:o=[],chatsFetcher:a}=this._currentTab.value,l=r||(a?this._loadedChats.value[this._currentTabKey.value]??[]:this.props.store.sortedChats),c=new Set(o);return l.length&&(o||s)?l.filter(h=>(!s||h.title.includes(s))&&(!c.size||c.has(h.custom_data.type||"chat"))):l}),this._handleNewChat=()=>{var s,r;(r=(s=this.props).onCreateChat)==null||r.call(s)},this._handleSearch=s=>{this._searchValue.value=s},this._handleClickTab=s=>{const r=s.item.key;this._currentTabKey.value=r,this.load(r)},this._handleSelectChat=s=>{var o,a;const r=this._filteredChats.value.find(l=>l.id===s);r&&((a=(o=this.props).onSelectChat)==null||a.call(o,r,this._currentTab.value))};const t=e.currentTab??((n=this.props.tabs[0])==null?void 0:n.key)??"";this._currentTabKey=fe(t)}componentDidMount(){const{onSelectChat:e,currentChatID:t}=this.props;if(!t&&e){const n=this._filteredChats.value[0];n&&e(n,this._currentTab.value)}}get currentTab(){return this._currentTab.value}async load(e){e=e??this._currentTabKey.value;const t=this.props.tabs.find(s=>s.key===e);if(!t||!t.chatsFetcher)return;this._loading.value=e;const n=await Ne(t.chatsFetcher,[this.props.store,t]);return this._loadedChats.value={...this._loadedChats.value,[e]:n},this._loading.value="",n}render(e){const{tabs:t}=e,n=this._filteredChats.value||[],s=this._currentTab.value,r=s.key;return g(Jx,{className:"ai-chats-panel-side",contentClass:"scrollbar-hover overflow-auto h-full",minWidth:160,maxWidth:"60%"},g("div",{class:"sticky top-0 bg-canvas z-10 rounded-lg px-2 pt-2 space-y-2"},(t==null?void 0:t.length)>1?g(Td,{className:"ai-chats-sidebar-tabs bg-primary-100 rounded-full",type:"pills",justified:!0,items:t.map(o=>({text:o.title,key:o.key})),active:r,onClickItem:this._handleClickTab}):null,s.searchBox!==!1||s.onCreate!==!1?g("div",{className:"pb-1 flex items-center gap-2 rounded-lg"},s.searchBox!==!1?g(vs,{circle:!0,onChange:this._handleSearch,className:"flex-auto",placeholder:Se("searchChats"),...typeof s.searchBox=="object"?s.searchBox:{}}):null,s.onCreate!==!1?g(we,{hint:Se("newChat"),icon:"plus",type:"primary-pale",rounded:"full",disabled:e.disabled,className:"flex-none",onClick:typeof s.onCreate=="function"?s.onCreate:this._handleNewChat}):null):null),g(Wk,{store:e.store,currentChatID:e.currentChatID,chats:n,onSelectChat:this._handleSelectChat,getItem:s.onRenderMenuItem}),!(n!=null&&n.length)&&r===this._loading.value?g("div",{className:"px-4 py-2"},g($e,{icon:"spinner-indicator",className:"spin muted"}),g("span",{className:"text-gray text-shimmer text-sm ml-2"},Se("loading"))):null)}}class Hy extends re{constructor(e){super(e),this._loadError=fe(),this._loadedID="",this._loading=Ce(()=>this._loadedID===this.props.chatID),this._timer=0,this.verifyTask=async(t,n="")=>{const{task:s}=this;if(s.status!=="done")return;const r=s.id.replace("task-",""),o=ut("aitask","verify",`taskID=${r}`),a=await v.post(o,{result:t,remark:n},"json");if(a.result!=="success"){He.alert(a.message??Se("taskVerifyPassFailed"));return}this._task.value={...s,status:t==="pass"?"closed":"wait"},Ln.show({content:a.message??Se("taskVerifyPassSuccess"),type:"success"})},this._handleSend=t=>this.verifyTask("refine",t),this._handleClose=()=>this.verifyTask("pass"),this._renderItem=t=>{var s;const n=t;return n.role==="assistant"&&n.result?g(Ay,{role:n.role,store:this.props.store,avatar:this._noAvatar?!1:void 0,date:n.created_at},g("div",{className:"ai-message-bubble-shape py-2 px-3"},g(Gd,{className:"ai-message-bubble-content",...n.result}))):n.role==="assistant"&&!n.content.length||n.role==="tool"||(s=n.custom_data)!=null&&s.invisible?null:g(Ly,{store:this.props.store,message:n,chat:this.props.task,noAvatar:this._noAvatar,assetBaseUrl:this.props.store.assetBaseUrl})},this._task=fe(e.task||{id:e.chatID,type:"task",title:"",custom_data:{},$local:{}})}get store(){return this.props.store}get error(){return this.props.store.error}get loading(){return this._loading.value}get task(){return this._task.value}async loadChat(e){if(e=e??this.props.chatID,this._loadedID!==e){this._loadedID=e,e!==this._task.value.id&&(this._task.value={id:e,type:"task",title:"",custom_data:{},$local:{}});try{const t=+e.replace("task-",""),n=await this.store.getTaskMessages(t);this.props.chatID===this._loadedID&&(this._task.value=n)}catch(t){console.error("[ZUI] AITaskView: Load task error",t)}this._loadedID=""}}async _init(){await this.loadChat()}componentDidUpdate(e){e.chatID!==this.props.chatID&&this._init()}componentDidMount(){this._init(),this._timer=window.setInterval(()=>{this.loadChat()},6e4)}componentWillUnmount(){this._timer&&(window.clearInterval(this._timer),this._timer=0)}_renderError(e,t){if(t=t??this.error,!t)return null;const{getErrorContent:n}=e,s=(n==null?void 0:n(t))??t.message;return g("div",{key:"error",className:"ai-chats-panel-error"},g(de,{className:"ai-chats-panel-error-content",content:s,generatorArgs:[e],generatorThis:this}))}_renderStatus(e){const t=Se(`taskStatus.${e}`);return g("div",{className:U("ml-2 font-normal label size-sm rounded-full",{wait:"gray-pale",doing:"warning-pale",done:"primary-pale",fail:"danger-pale",closed:"gray-pale",cancel:"light"}[e]??"gray-pale")},t)}_renderSendbox(e){var r,o;const{sendbox:t}=e,{task:n}=this,{status:s}=n;if(s==="cancel"||s==="closed")return null;if(s==="done"||s==="fail"){const a=[{icon:"",code:`teammate-${n.teammate.id}`,title:n.teammate.name},{icon:"",code:`agent-${n.agents}`,title:n.name}];return g(By,{key:n.id,chat:n,store:this.store,chatID:n.id,disabled:!!this.store.error,onSend:this._handleSend,llmProviders:e.store.chatModels,defaultModel:(r=n.settings)==null?void 0:r.model,currentModel:(o=n.custom_data)==null?void 0:o.model,contexts:a,placeholder:Se("taskVerifyTip"),extraBtns:[{key:"close",text:Se("taskVerifyPass"),icon:"",onClick:this._handleClose}],sendBtn:{text:Se("taskVerifyRefine"),icon:"",trailingIcon:"arrow-right"},...typeof t=="object"?t:{}})}return g("div",{className:"center m-4 p-2 rounded-xl text-gray surface-light"},Se(`taskStatusMessage.${s}`))}render(e){var w,x,T;const t=this.task,n=t.messages||[],{noAvatar:s,mode:r="full",embed:o=!1}=e,{hideUserMessage:a=r!=="full",hideHeader:l=r==="lite",sendbox:c=r==="full",noMessagesTip:h}=e,d=this.loading,f=!n.length,p=t.created_at||t.created_on||Date.now();let y=[...n].reverse();Tn((w=t.custom_data.form)==null?void 0:w.summary)&&y.push({id:"form-summary",role:"assistant",content:(x=t.custom_data.form)==null?void 0:x.summary,created_at:p}),t.custom_data.welcome&&y.push({id:"welcome",role:"assistant",content:t.custom_data.welcome,created_at:p}),a&&(y=y.filter(D=>D.role!=="user")),(T=t.result)==null||T.forEach(D=>{y.unshift({id:D.callID,role:"assistant",content:"",result:D,created_at:t.updated_at||t.finishedDate||t.created_at})}),this._noAvatar=s??a;const b=a&&this._noAvatar&&!c;return g("div",{className:U(`ai-chat-view is-mode-${r}`,{"is-only-response":b,"is-embed":o,"is-no-message":f})},l?null:g("div",{className:"ai-chat-view-header"},g("div",{className:"ai-chat-view-title",title:t.title},t.$local.tempTitle??t.title,this._renderStatus(t.status))),g("div",{className:"ai-chat-view-body"},y.length?g($t,{className:"ai-chat-view-messages scrollbar-hover",itemKey:"id",items:y,itemRender:this._renderItem}):g("div",{className:"muted h-full center py-4 my-8"},d?g(kl,{text:Se("loading"),className:"animate-pulse col gap-2 items-center"}):g(de,{content:h??Se("taskNoMessagesTip"),generatorArgs:[e],generatorThis:this}))),c&&this._renderSendbox(e))}}const Uy=class Xb extends Ve{constructor(e){super(e),this._loaded=fe(!1),this._selectedChat=fe(),this._currentTab=fe(),this._currentChat=Ce(()=>{const n=this._currentChatID.value;return this._store.chats.find(s=>s.id===n)||this._selectedChat.value}),this._handleSelectChat=(n,s)=>{this._selectedChat.value=n,this._currentTab.value=s,this.selectChat(n.id)},this._handleNewChat=()=>{this.createChat()},this._handleCreateChat=(n,s)=>{this._currentChatID.value===s&&(this._currentChatID.value=n)};const{store:t}=e;this._store=t instanceof on||t.constructor.NAME===on.NAME?t:new on(t),this._currentChatID=fe(e.currentChatID??""),this._error=fe(this._store.error)}get currentChatID(){return this._currentChatID.value}get currentChat(){return this._currentChat.value}get store(){return this._store}selectChat(e){this._currentChatID.value!==e&&(this._currentChatID.value=e,this.store.reactions.selectChat(e))}_loadEndWithError(e){this._error.value=e,this._loaded.value=!0}async loadChats(e){const{store:t}=this,n=async()=>{t.chats.length||await this.createChat({local:!0})};if(t.error){await n(),this._loadEndWithError(t.error);return}this._loaded.value=!1;try{e?await t.loadChats():await t.tryLoadChats()}catch(o){console.error("[ZUI] loadChats error",o),await n(),this._loadEndWithError(t.error||{message:Se("errors.loadDataFailed"),type:"load-chats-failed"});return}const s=this._currentChatID.value;s&&this.selectChat(s),this._loaded.value=!0;const{postMessage:r}=this.props;r?await t.postMessage(r,s):t.chats.length||await n()}async createChat(e){const{select:t=!0,local:n=!0,...s}=e||{};let r;return n?r=await this.store.createLocalChat(s):r=await this.store.createChat(s),r&&t&&this.selectChat(r),r}componentDidMount(){const{loadOnMount:e}=this.props;e&&this.loadChats(e==="force")}_getClassName(e){return[e.className,"ai-chats-panel ai-styled",e.popup?"ai-popup-style":""]}_getChildren(e){return[this._renderHeader(e),this._renderBody(e),this._renderFooter(e)]}_renderSidebar(e){return e.sidebar?g(Kk,{currentChatID:this.currentChatID,store:this.store,tabs:this.props.tabs||Xb.defaultProps.tabs,disabled:!!this._error.value,onCreateChat:this._handleNewChat,onSelectChat:this._handleSelectChat}):null}_renderChat(){const e=this.currentChat;return e?ay(e)?g(Hy,{key:e.id,task:e,chatID:e.id,store:this.store}):g(Zd,{key:e.id,chatID:e.id,store:this.store,onCreateChat:this._handleCreateChat}):g("div",{className:"ai-chats-panel-main-empty p-4"},Se("selectChatTip"))}_renderBody(e){return this._loaded.value?g(Xx,{className:"ai-chats-panel-body"},this._renderSidebar(e),g("div",{className:"ai-chats-panel-main"},this._renderChat(),this._renderError(e),e.children)):g("div",{className:"ai-chats-panel-body center"},g(kl,{text:Se("loading")}))}_renderError(e){const t=this._error.value;if(!t)return null;const{getErrorContent:n}=e,s=n?n(t):t.message;return g("div",{key:"error",className:"ai-chats-panel-error"},g(de,{className:"ai-chats-panel-error-content",content:s,generatorArgs:[e],generatorThis:this}))}_renderHeader(e){return g(de,{key:"header",className:"ai-chats-panel-header",content:this.props.header,generatorArgs:[e],generatorThis:this})}_renderFooter(e){return g(de,{key:"footer",className:"ai-chats-panel-footer",content:this.props.footer,generatorArgs:[e],generatorThis:this})}};Uy.defaultProps={loadOnMount:!0,sidebar:!0,popup:!0,tabs:[{key:"chats",chatTypes:["chat","agent"],title:"Chats"}]};let Yd=Uy;class Sl extends on{constructor(e){const{baseUrl:t,host:n,port:s,assetBaseUrl:r,appID:o="",token:a,adminToken:l,userID:c="",agentID:h="zchat",globalMemory:d,defaultModel:f,getAvatar:p}=e;let y=t||(n?s?`///${n}:${s}`:`///${n}`:""),b=e.apiVersion;y.endsWith("/")&&(y=y.substring(-1)),y.endsWith("/v1")?(y=y.substring(0,y.length-3),b="v1"):y.endsWith("/v8")&&(y=y.substring(0,y.length-3),b="v8"),super({context:{baseUrl:y,assetBaseUrl:r?r.endsWith("/")?r.substring(-1):`${r}`:void 0,appID:o,token:typeof a=="string"?a:"",adminToken:typeof l=="string"?l:"",tokenExpiredTime:0,userID:c,agentID:h,apiVersion:b,globalMemory:d,defaultModel:f},getAvatar:p,fetchers:{},plugins:e.plugins,useISODate:!0,privs:e.privs}),this._isConfigOK=!0,this._tokenSetting=a,this._adminTokenSetting=l,this._teammateMap=e.teammateMap||{},this._fetchers=this._getFetchers()}get apiVersion(){return this.context.apiVersion}isConfigOK(){const e=["baseUrl","appID"].filter(t=>!this.context[t]);return this._tokenSetting||e.push("token"),this._isConfigOK=!e.length,e.length?(this.setError({message:Se("errors.zaiConfigNotValid")||"The zai config is not valid.",type:"configNotValid"}),!1):!0}async getInfo(e){if(this._info.value&&!e)return this._info.value;if(this._getInfoCallbacks)return new Promise(s=>{this._getInfoCallbacks.push(s)});this._getInfoCallbacks=[];let t,n=this.apiVersion;if(!n){try{const s=this._getFetchersV8().getInfo;t=await Ne(s,[{...this.context,apiVersion:"v8"}]),t&&(n="v8")}catch{n="v1"}this.setContext({apiVersion:n,tokenExpiredTime:0,adminTokenExpiredTime:0}),this._fetchers=this._getFetchers()}if(t||(t=await super.getInfo(e)),this._getInfoCallbacks){for(const s of this._getInfoCallbacks)s(t);this._getInfoCallbacks=void 0}return t}async getToken(){var r;if(!this._isConfigOK)throw new Error(((r=this._error.value)==null?void 0:r.message)??"The zai config is not valid.");const e=this._tokenSetting;if(typeof e=="string")return e;if(typeof e!="function")throw new Error("Token getter is required.");const t=this.context;if(t.token&&t.tokenExpiredTime&&Date.now()/1e3<t.tokenExpiredTime+60)return t.token;const n=await e.call(this,t.appID);if(typeof n=="string")return this.setContext({token:n,tokenExpiredTime:Date.now()+60}),n;const s={};return s.tokenExpiredTime=n.expiredTime,n.baseUrl&&(s.baseUrl=n.baseUrl),n.appID&&(s.appID=n.appID),n.agentID&&(s.agentID=n.agentID),n.userID&&(s.userID=n.userID),n.token?s.token=n.token:s.token=`${this.apiVersion==="v8"?"ek":"ex"}-${btoa(JSON.stringify({hash:n.hash,app_id:s.appID,user_id:s.userID,expired_time:s.tokenExpiredTime}))}`,this.setContext(s),s.token}async getAdminToken(){var r;if(!this._isConfigOK)throw new Error(((r=this._error.value)==null?void 0:r.message)??"The zai config is not valid.");const e=this._adminTokenSetting;if(!e)return await this.getToken();if(typeof e=="string")return e;const t=this.context,n=await e.call(this,t.appID);if(typeof n=="string")return this.setContext({adminToken:n,adminTokenExpiredTime:Date.now()+60}),n;const s={};return s.adminTokenExpiredTime=n.expiredTime,n.baseUrl&&(s.baseUrl=n.baseUrl),n.appID&&(s.appID=n.appID),n.userID&&(s.userID=n.userID),n.token?s.adminToken=n.token:s.adminToken=`ak-${btoa(JSON.stringify({hash:n.hash,app_id:s.appID,user_id:s.userID,expired_time:s.adminTokenExpiredTime}))}`,this.setContext(s),s.adminToken}async _readStream(e,t){var h,d,f;const n=new TextDecoder,s=()=>new Promise(p=>requestAnimationFrame(p)),r=new Map,o=new Map;let a,l="",c="";for(;;){await s();const{done:p,value:y}=await e.read();if(p)break;const w=n.decode(y).split(`
  54. `).filter(Boolean);let x=!1;for(const T of w)if(T.startsWith("data: ")){if(T==="data: [DONE]"){x=!0;break}try{const D=JSON.parse(T.slice(6)),N=(d=(h=D==null?void 0:D.choices)==null?void 0:h[0])==null?void 0:d.delta;let A;if(N){const{content:z,tool_calls:O}=N;if(typeof z=="string"&&z.length&&(c+=z),Array.isArray(O)&&O.length)for(const K of O){K.id&&(l=K.id);const Z=r.get(l);Z?(f=K.function.arguments)!=null&&f.length&&(Z.function.arguments+=K.function.arguments):(typeof K.function.arguments!="string"&&(K.function.arguments=""),r.set(l,K),o.set(l,o.size))}A={type:"tool_calls",content:c},a=Array.from(r.values()).sort((K,Z)=>(o.get(K.id)??0)-(o.get(Z.id)??0))}else D.reasoning?A={type:"reason",reasonType:D.reasonType||"thinking",content:D.reasoning}:(typeof D.type=="number"&&(D.type=D.type===1?"reason":"chat"),A=D);a!=null&&a.length&&(A.tool_calls=a),D.model&&(A.model=D.model),t(A)}catch(D){console.error("[ZUI] AI: Failed to parse stream data:",D)}}if(x)break}}async fetch(e,t,n){var O,K;if(!this._isConfigOK)throw new Error(((O=this._error.value)==null?void 0:O.message)??"The zai config is not valid.");e.apiVersion||(await this.getInfo(),e.apiVersion=this.apiVersion);const{method:s,data:r,onStream:o,expectStatus:a,statusResult:l,params:c,convert:h,dataType:d="json",admin:f=!1}=typeof n=="string"?{method:n}:n||{},p=await(f?this.getAdminToken():this.getToken()),y={zh_cn:"zh-CN",zh_tw:"zh_TW",en:"en-US"},b=be.getCode(),w=typeof t=="function"?t(e):`${e.baseUrl}/${t.startsWith("/")?t.substring(1):t}`,x=c?new URLSearchParams(c).toString():"",T=x?`${w}?${x}`:w,D=r instanceof FormData,N=await fetch(T,{method:s||(D?"POST":"GET"),headers:{...D?{}:{"Content-Type":"application/json"},Authorization:`Bearer ${p}`,"Accept-Language":y[b]||b},body:!D&&typeof r!="string"?JSON.stringify(r):r});if(a&&!(Array.isArray(a)?a:[a]).includes(N.status))throw new Error(`Expected status ${a} but got ${N.status}`);if(l)return l[N.status]??l[0];if(N.status===401){const Z={type:"unauthorized",message:Se("errors.unauthorized")||"Unauthorized"};let ye="";try{ye=await N.text();try{const Q=JSON.parse(ye);let ne=Q.error||Q.message;ne&&(typeof ne=="string"&&(ne={message:ne}),ne.message&&(Z.message=Se(ne.code?`errors.code.${ne.code}`:`errors.${ne.message}`)||ne.message))}catch{}}catch{}return this.setError(Z),null}else this.setError();if(N.status===404)return null;if(N.status===500){const Z=await N.text();throw new Error(`Server error: ${Z}`)}if(o){const Z=(K=N.body)==null?void 0:K.getReader();if(Z)return await this._readStream(Z,o),{}}let A;const z=await N.text();if(d==="json")try{A=JSON.parse(z)}catch{throw new Error(z)}else A=z;return h&&(A=await h(A)),A}async fetchFromZentao(e,t){typeof t=="string"&&(t={method:t});const n=await v.ajax({url:typeof e=="string"?e:ut(...e),dataType:"json",...t});if(typeof n=="object"){if(n.result==="success"&&n.data!==void 0)return n.data;if(n.result==="fail")throw new Error(n.message)}return n}async getMemories(){const e=this._checkFetcher("getMemories");return await Ne(e,[this.context])}async getMemory(e){const t=this._checkFetcher("getMemory");return await Ne(t,[this.context,e])}async createMemory(e){const t=this._checkFetcher("createMemory");if(!e.embedding_model){const s=await this.getTextEmbeddingModel();s&&(e.embedding_model=s.id)}return await Ne(t,[this.context,e])}async deleteMemory(e){const t=this._checkFetcher("deleteMemory");return await Ne(t,[this.context,e])}async getMemoryContent(e,t){const n=this._checkFetcher("getMemoryContent");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async getMemoryContents(e,t){const n=this._checkFetcher("getMemoryContents");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async saveMemoryContent(e,t){var r,o;const n=this._checkFetcher("saveMemoryContent");return(r=t.title)!=null&&r.length&&!((o=t.content)!=null&&o.length)&&(t.content=t.title),await Ne(n,[this.context,e===ls?this.globalMemory:e,{content_type:"text",...t}])}async deleteMemoryContent(e,t){const n=this._checkFetcher("deleteMemoryContent");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async updateMemoryContent(e,t){const n=this._checkFetcher("updateMemoryContent");return await Ne(n,[this.context,e,t])}async filterMemoryContents(e,t){const n=this._checkFetcher("filterMemoryContents");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async getMemoryContentChunks(e,t){const n=this._checkFetcher("getMemoryContentChunks");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async searchMemoryChunks(e,t){const n=this._checkFetcher("searchMemoryChunks"),s=await Ne(n,[this.context,e===ls?this.globalMemory:e,t]);return s.sort((r,o)=>o.similarity-r.similarity),s}async searchMemoryContents(e,t){const n=this._checkFetcher("searchMemoryContents");return await Ne(n,[this.context,e===ls?this.globalMemory:e,t])}async getTasks(){const e=this._checkFetcher("getTasks");return(await Ne(e,[this.context])).map(this.formatTask.bind(this))}async getTaskMessages(e){const t=this._checkFetcher("getTaskMessages"),n=await Ne(t,[this.context,e]);return this.formatTask(n)}getTeammate(e){return this._teammateMap[e]}formatMessage(e){return typeof e.id=="number"&&(e.id=`zt-${e.id}`),!e.created_at&&typeof e.createdDate=="string"&&(e.created_at=Ye(e.createdDate).getTime()),e}formatTask(e){if(e.type!=="task"&&e.taskType===void 0&&(e.taskType=e.type),e.$local=e.$local||{},e.custom_data=e.custom_data||{},e.type="task",e.title=e.name,typeof e.id=="number"&&(e.id=`task-${e.id}`),typeof e.result=="string"&&e.result.startsWith("["))try{e.result=JSON.parse(e.result)}catch(t){e.result=void 0,console.error("[ZUI] AI: Failed to parse task result:",t)}else Array.isArray(e.result)||(e.result=[]);return!e.created_at&&typeof e.createdDate=="string"&&(e.created_at=Ye(e.createdDate).getTime()),e.llm&&(e.custom_data.model=e.llm),Array.isArray(e.messages)?e.messages=e.messages.map(this.formatMessage):Array.isArray(e.messages)||(e.messages=[]),(typeof e.teammate=="string"||typeof e.teammate=="number")&&(e.teammate=this.getTeammate(e.teammate)||{id:e.teammate,name:e.teammate,avatar:""}),e}_getFetchers(){return this._getFetchersV8()}_getFetchersV8(){return{getInfo:e=>this.fetch(e,"v8/_info",{convert:t=>({name:"zai",...t})}),getConversations:e=>this.fetch(e,"v8/chat/conversations"),getConversation:(e,t)=>this.fetch(e,`v8/chat/conversations/${t}`,{convert:n=>{if(!n||typeof n!="object"||n.error!==void 0){if(n&&typeof n=="object"&&n.error)throw new Error(n.error);return}}}),createConversation:(e,t)=>{const{title:n,settings:s={},prompt:r,memories:o,customData:a}=t,l=o?ik(o,e):void 0;r!=null&&r.length&&(s.prompt=r);let c=s.model??t.model;return c!==void 0&&!this._llmModels.value.some(h=>h.id===c)&&(c=void 0),c!=null&&c.length?s.model=c:delete s.model,this.fetch(e,"v8/chat/conversations",{method:"POST",data:{...n?{title:n}:{},settings:{...s},custom_data:a,reference_settings:l!=null&&l.collections.length?l:void 0}})},updateConversation:(e,t)=>this.fetch(e,`v8/chat/conversations/${t.id}`,{method:"PUT",data:{...t.title?{title:t.title}:{},...t.custom_data?{custom_data:t.custom_data}:{}}}),deleteConversation:(e,t)=>this.fetch(e,`v8/chat/conversations/${t}`,{method:"DELETE",statusResult:{200:!0,0:!1}}),getMessages:(e,t)=>this.fetch(e,`v8/chat/conversations/${t}/messages`),deleteMessages:(e,t)=>this.fetch(e,`v8/chat/conversations/${t}/messages`,{method:"DELETE",statusResult:{200:!0,0:!1}}),postMessage:(e,t,n)=>{var s;return this.fetch(e,`v8/chat/conversations/${t.id}/messages`,{method:"POST",data:{content:t.content,stream:!!n,tools:(s=t.tools)==null?void 0:s.map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}})),messages:t.messages,custom_data:t.custom_data},onStream:n})},postBatchMessages:(e,t,n)=>{var s;return this.fetch(e,"v8/chat/conversation",{method:"POST",data:{conversation_id:t.id,messages:t.messages,tools:(s=t.tools)==null?void 0:s.map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}})),stream:!!n},onStream:n})},getConversationTitle:(e,t)=>this.fetch(e,`v8/chat/conversations/${t}/generate-title`,{method:"POST",data:{}}),getLlmModels:e=>this.fetch(e,"v8/models").then(t=>Array.isArray(t)?t.map(n=>{const s=n.name||n.id;return{name:s,abilities:s.includes("embed")||s.includes("bge")?["embedding"]:["chat"],...n}}):[]),getMemories:e=>this.fetch(e,"v8/memories",{admin:!0}),getMemory:(e,t)=>this.fetch(e,`v8/memories/${t}`,{admin:!0}),createMemory:(e,t)=>{const n=t,s=this.context.defaultEmbeddingModel;return s&&(n.embedding_model=s),this.fetch(e,"v8/memories",{method:"POST",data:t,admin:!0})},deleteMemory:(e,t)=>this.fetch(e,`v8/memories/${t}`,{method:"DELETE",statusResult:{200:!0,0:!1},admin:!0}),getMemoryContent:(e,t,n)=>this.fetch(e,`v8/memories/${t}/contents/${n}`,{admin:!0}),getMemoryContents:(e,t,n)=>{const s=[];return n&&(n.content_type!==void 0&&s.push(["type",n.content_type]),n.content_keywords!==void 0&&s.push(["keywords",n.content_keywords])),this.fetch(e,`v8/memories/${t}/contents`,{admin:!0,params:s})},deleteMemoryContent:(e,t,n)=>this.fetch(e,`v8/memories/${t}/contents/${n}`,{method:"DELETE",statusResult:{200:!0,0:!1},admin:!0}),saveMemoryContent:(e,t,n)=>this.fetch(e,`v8/memories/${t}/contents`,{method:"POST",data:n,admin:!0}),updateMemoryContent:(e,t,n)=>this.fetch(e,`v8/memories/${n.key}/contents/${t}`,{method:"PUT",data:n,admin:!0}),filterMemoryContents:(e,t,n)=>this.fetch(e,`v8/memories/${t}/contents-filter`,{method:"POST",data:n,admin:!0}),getMemoryContentChunks:(e,t,n)=>this.fetch(e,`v8/memories/${t}/contents/${n}/chunks`,{admin:!0}),searchMemoryChunks:(e,t,n)=>this.fetch(e,`v8/memories/${t}/embeddings-search-chunks`,{method:"POST",data:n,admin:!0}),searchMemoryContents:(e,t,n)=>this.fetch(e,`v8/memories/${t}/embeddings-search-contents`,{method:"POST",data:n,admin:!0}),extractFile:(e,t)=>this.fetch(e,"v8/files/extract",{method:"POST",data:vr({file:t}),admin:!0}),getTasks:()=>this.fetchFromZentao(["aitask","ajaxGetList"]),getTaskMessages:(e,t)=>this.fetchFromZentao(["aitask","ajaxGetMessages",`taskID=${t}`])}}static createFromZentao(e){const{appID:t,host:n}=e;return!t||!n?null:new Sl({appID:t,host:n,agentID:e.agentID,port:e.port,token:async function(){const s=ut("zai","ajaxGetToken");return(await v.getJSON(s)).data},baseUrl:e.apiBaseUrl,assetBaseUrl:e.assetBaseUrl,plugins:e.plugins??"ALL",globalMemory:e.globalMemory,privs:e.privs,getAvatar:e.getAvatar,teammateMap:e.teammateMap})}}class qk extends Sl{}const Gk="ai-size-store",Vy="ai-mini-btn",Tl="ai-popup",Wy="ai-panel";function Ky(i){return`${Gk}:${i}`}function Zk(i,e){const t=JSON.stringify(e),n=Ky(i);nt.set(n,t)}function Yk(i){const e=Ky(i),t=nt.get(e);try{return t?JSON.parse(t):null}catch(n){return console.error(n),null}}const Zi={save:Zk,load:Yk};function $l(i,e,t,n){const s={left:n.x+n.padding,right:n.x+n.width-n.padding,top:n.y+n.padding,bottom:n.y+n.height-n.padding},r=t.getBoundingClientRect(),o=r.x+i,a=r.y+e,l={left:o,right:o+r.width,top:a,bottom:a+r.height},c=l.left<s.left,h=l.right>s.right,d=l.top<s.top,f=l.bottom>s.bottom;let p=0;h?p=s.right-l.right:c&&(p=s.left-l.left);let y=0;return f?y=s.bottom-l.bottom:d&&(y=s.top-l.top),{x:p,y}}class Jk extends re{constructor(){super(...arguments),this._hasMoved=!1,this._elementRef=pe(),this._handleClick=e=>{var t,n;(n=(t=this.props).onClick)==null||n.call(t,e)},this._handleWindowResize=()=>{const t=this._elementRef.current.getBoundingClientRect(),n={w:t.width,h:t.height,x:0,y:0};this._applyRect(n),Zi.save(Vy,n)}}_applyRect(e){if(!this._elementRef.current||!e)return;const t=this._elementRef.current,n={x:0,y:0,width:window.innerWidth,height:window.innerHeight,padding:24},s=$l(e.x,e.y,t,n),r=e.x+s.x,o=e.y+s.y;t.style.transform=`translate(${r}px, ${o}px)`}render(e){return g("div",{className:"ai-mini-btn",ref:this._elementRef,onClick:this._handleClick},g(ts,{background:"var(--ai-mini-btn-bg)",className:"shadow text-canvas state cursor-pointer ai-loading",circle:!0,displayText:"AI",size:40}),e.children)}}let qy=class extends Ve{constructor(e){super(e),this._panelRef=pe(),this._lastShowMode="normal",this._beforeEmbedMode="normal",this._lastMode="normal",this._neverShow=!0,this._handleWindowResize=()=>{const t=this.panelElement;if(!t)return;const n=t.getBoundingClientRect(),s={w:n.width,h:n.height,x:0,y:0};this._applyRect(s),Zi.save(Wy,s)},this._handleClickSuggestion=(t,n)=>{var s,r;(r=(s=this.props).onAcceptSuggestion)==null||r.call(s,t,n)},this._handleMiniBtnClick=t=>{t.target.closest(".avatar")&&this.toggleShow(!0)},this._store=e.store instanceof on?e.store:new on(e.store),this._mode=fe(e.open?"normal":e.mode||"minimized"),this._modeEffect=_t(()=>{var s,r;const{mode:t}=this;(t==="normal"||t==="maximized")&&(this._lastShowMode=t),t!=="embed"&&(this._beforeEmbedMode=t),t!=="minimized"&&(this._neverShow=!1);const n=this._lastMode;(r=(s=this.props).onModeChange)==null||r.call(s,t,n),this._lastMode=t})}get panelElement(){return this._panelRef.current?v(".ai-chats-panel")[0]:null}_applyRect(e){if(!this.panelElement||!e)return;const t=this.panelElement,n={x:0,y:0,width:window.innerWidth,height:window.innerHeight,padding:24},s=$l(e.x,e.y,t,n),r=e.x+s.x,o=e.y+s.y;t.style.transform=`translate(${r}px, ${o}px)`}get store(){return this._store}get panel(){return this._panelRef.current}get reactions(){return this.store.reactions}get mode(){return this._mode.value}get shown(){return this._mode.value!=="minimized"}get maximized(){return this._mode.value==="maximized"}get minimized(){return this._mode.value==="minimized"}get embed(){return this._mode.value==="embed"}setMode(e){this._mode.value=e}toggleShow(e){e=e??!this.shown,this.setMode(e?this._lastShowMode:"minimized")}resetPanelPosition(){v(this.element).find(".ai-chats-panel").css("transform","none")}toggleMaximize(e){e=e??!this.maximized,this.setMode(e?"maximized":"normal"),this.resetPanelPosition()}toggleMinimize(e){e=e??!this.minimized,this.setMode(e?"minimized":this._lastShowMode)}toggleEmbed(e){e=e??!this.embed,this.setMode(e?"embed":"minimized")}selectChat(e){var t;return(t=this.panel)==null?void 0:t.selectChat(e)}createChat(e){var t;return(t=this.panel)==null?void 0:t.createChat(e)}postMessage(e,t){return this.store.postMessage(e,t)}async open(e,t){var o,a;await _m(()=>this.panel),typeof e=="string"&&(e={chat:e});let n=typeof e.postMessage=="string"?{content:e.postMessage}:e.postMessage;t&&(n=n||{content:""},typeof t=="string"?n.content=t:n={...n,...t}),(o=n==null?void 0:n.content)!=null&&o.length||(n=void 0);const s=e.chat??(n==null?void 0:n.chat);let r=typeof s=="string"?s:void 0;if(!r){if(!n&&!s)return;r="NEW"}r==="NEW"&&(r=await this.createChat({select:!0,local:!n,...typeof s=="object"?s:{}}),r&&((a=e.onCreateChat)==null||a.call(this,r))),r&&(n&&await this.postMessage(n,r),e.select&&this.selectChat(r))}_getClassName(e){const{mode:t}=this;return[e.className,"ai-panel ai-styled",{"is-shown":t!=="minimized","is-maximized":t==="maximized","is-minimized":t==="minimized","is-normal":t==="normal","is-embed":t==="embed"}]}_getProps(e){const{dock:t="bottom-right",position:n={},maximizedPosition:s,style:r={}}=e,o=(this.maximized?s:n)||n;return t.split("-").forEach(a=>{r[a]=o[a]||24}),["left","top","right","bottom"].forEach(a=>{const l=o[a];l!==void 0&&(r[`--ai-panel-pos-${a}`]=typeof l=="string"?l:`${l}px`)}),Pe(super._getProps(e),{"z-dock":t,style:r})}_getChildren(e){return this.store.isDisabledAllPrivs?[]:[this._renderMiniBtn(),this._renderChatsPanel(e)]}_renderHeader(){const{maximized:e}=this;return g("div",{className:"ai-panel-header"},g(Fe,{className:"ai-panel-toolbar",items:[{icon:e?"fullscreen-exit":"fullscreen",hint:Se(e||e?"minimize":"maximize"),onClick:()=>this.toggleMaximize()},{icon:"close",hint:Se("close"),onClick:()=>this.toggleMinimize(!0)}]}))}_renderChatsPanel(e){if(this._neverShow&&!this.shown)return null;const{size:t={width:"100%",height:"100%"},tabs:n,getErrorContent:s}=e;return g(Yd,{ref:this._panelRef,store:this.store,style:{width:t.width,height:t.height},loadOnMount:"force",header:this._renderHeader(),tabs:n,getErrorContent:s})}_renderSuggestions(){const{suggestions:e}=this.reactions;return g("div",{className:`ai-panel-suggestions${e.length?"":" is-empty"}`},e.map(t=>{const{type:n,title:s,hint:r,icon:o,command:a,action:l,btnProps:c={}}=t;return Pe(c,{type:"ai-btn-style","z-type":n,text:s,size:"sm",icon:o,command:a,onClick:l?this._handleClickSuggestion.bind(this,t):null}),g("div",{className:Tn(r)?"hint hint-left hint-primary":void 0,"data-hint":r},g(we,{key:s,...c}))}))}_renderMiniBtn(){return g(Jk,{onClick:this._handleMiniBtnClick},this._renderSuggestions())}};qy.defaultProps={open:!1,dock:"bottom-right",size:{width:800,height:500}};let Gy=class extends Ve{constructor(e){super(e),this._headerRef=pe(),this._boxRef=pe(),this._handleWindowResize=()=>{const n=this._boxRef.current.getBoundingClientRect(),s={w:n.width,h:n.height,x:0,y:0};this._applyRect(s),Zi.save(Tl,s)},this._store=e.store instanceof on?e.store:new on(e.store)}get store(){return this._store}componentDidMount(){super.componentDidMount();const e=Zi.load(Tl);e&&this._applyRect(e),this._moveable=new _s(this.element,{selector:".ai-popup-box",handle:".ai-popup-header,.ai-chat-view-header",move:"transform",edgeDetection:{container:"viewport",distance:{left:124,top:24,right:24,bottom:56}},onMove:()=>{const t=this._boxRef.current,n=t.getBoundingClientRect(),s=_s.getTranslate(t);Zi.save(Tl,{w:n.width,h:n.height,x:s.left,y:s.top})}}),window.addEventListener("resize",this._handleWindowResize)}componentWillUnmount(){var e;super.componentWillUnmount(),(e=this._moveable)==null||e.destroy(),window.removeEventListener("resize",this._handleWindowResize)}_applyRect(e){if(!this._boxRef.current||!e)return;const t=this._boxRef.current,n={x:0,y:0,width:window.innerWidth,height:window.innerHeight,padding:24},s=$l(e.x,e.y,t,n),r=e.x+s.x,o=e.y+s.y;t.style.transform=`translate(${r}px, ${o}px)`}_getClassName(e){return[e.className,"ai-popup"]}_getProps(e){return Pe(super._getProps(e),{"z-placement":e.placement,style:{height:e.height,...e.style}})}_renderHeader(e){const{onClose:t}=e;return g("div",{className:"ai-popup-header",ref:this._headerRef},g(Fe,{className:"ai-popup-toolbar",items:[t?{icon:"close",hint:Se("close"),onClick:t}:void 0].filter(Boolean)}))}_renderView(e){return e.viewType==="chats"?g(Yd,{store:this.store,postMessage:e.postMessage,currentChatID:e.chatID,sidebar:!1,popup:!1,...e.viewProps}):e.viewType==="task"?g(Hy,{store:this.store,chatID:e.chatID,...e.viewProps}):g(Zd,{store:this.store,postMessage:e.postMessage,chatID:e.chatID,creatingChat:e.creatingChat,...e.viewProps})}_getChildren(e){return[g("div",{className:"ai-styled ai-popup-box ai-popup-style",style:{width:e.width},ref:this._boxRef},this._renderView(e),this._renderHeader(e))]}};Gy.defaultProps={placement:"top-right",width:500,viewType:"chats"};let Zy=class extends Zt{constructor(e){super(e),this._getModelItems=async()=>{var l;const{store:t,defaultModel:n="",foreLoadModels:s,noModelHint:r}=this.props;let o=n;typeof o=="string"&&(o={text:Se("defaultModel"),value:""});const a=[];if(t)try{const c=await t.getLlmModels(s);for(const h of c)(l=h.abilities)!=null&&l.includes("chat")&&a.push({text:h.name,value:h.id})}catch{}return a.length||a.push({text:r??Se("noChatModelHint"),value:"no-model",disabled:!0}),o&&a.unshift(o),a},this.props.items||(this.props.items=this._getModelItems)}_getPopProps(e,t){var o;const{menu:n,...s}=super._getPopProps(e,t),r=(o=e.store)==null?void 0:o.error;return{...s,items:this._getModelItems,menu:{footer:r?g("div",{className:"row items-center gap-2"},g($e,{icon:"alert",className:"text-warning"}),r.message):void 0,...n}}}};Zy.defaultProps={...Zt.defaultProps,emptyValue:!1};let Yy=class extends re{constructor(e){super(e),this._model=Ce(()=>{const{defaultModel:t,store:n,model:s}=this.props,r=n==null?void 0:n.chatModels.find(o=>o.id===s);if(r)return r.name;if(!s||String(s)===String(+s)){if(t===!0)return Se("defaultModel");if(typeof t=="string")return t}return s})}loadModels(){var e;(e=this.props.store)==null||e.getLlmModels(this.props.foreLoadModels)}componentDidMount(){this.loadModels()}render(e){return g("span",{className:U("ai-model-name",e.className),style:e.style,"z-model":e.model},this._model.value)}};Yy.defaultProps={defaultModel:!0};const Jd=class Qb extends ve{destroy(){const e=this.$element.parent();super.destroy(),e.is(".ai-chats-panel-root")&&e.remove()}static open(e,t){const n=v(t||"body");let s=n.find(".ai-chats-panel-root");if(s.length){const o=Qb.query(s);if(o)return o.render(e),o}else s=v('<div class="ai-chats-panel-root" style="position: fixed; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; z-index: 1110"></div>'),n.append(s);return new this(s,e)}};Jd.NAME="AIChatsPanel",Jd.Component=Yd;let Jy=Jd;Jy.register();const Xd="ai-popup-root",Dl=class Qf extends ve{constructor(){super(...arguments),this._closeTimer=0}close(){const e=this.$element.find(".ai-popup");e.find(".ai-popup-box").addClass("is-closing"),this._closeTimer=window.setTimeout(()=>{e.remove(),this.destroy()},500)}_getRenderProps(e){return{...super._getRenderProps(e),onClose:()=>{this.close()}}}destroy(){const e=this.$element;this._closeTimer&&window.clearTimeout(this._closeTimer),super.destroy(),e.hasClass(Xd)&&e.remove()}static open(e,t){const n=v(t||"body"),s=e.id||e.chatID||"";let r=n.find(`.${Xd}[z-id="${s}"]`);if(r.length){const a=Qf.query(r);if(a)return a.render(e),a}else r=v(`<div class="${Xd}" z-id="${s}"></div>`),n.append(r);return Qf.ensure(r,{key:`ai-popup-${s}`,...e})}};Dl.NAME="AIPopup",Dl.Component=Gy,Dl.MULTI_INSTANCE=!0;let Xy=Dl;const Il=class ew extends ve{constructor(){super(...arguments),this._popups={},this._modeChangeTimer=0,this._handleModeChange=(e,t)=>{var n,s;(s=(n=this.options).onModeChange)==null||s.call(n,e,t),this.$element.attr("z-mode",e).attr("z-last-mode",t).addClass("is-mode-changing"),clearTimeout(this._modeChangeTimer),this._modeChangeTimer=window.setTimeout(()=>{this.$element.removeClass("is-mode-changing")},300)},this.acceptSuggestion=(e,t)=>{this.reactions.acceptSuggestion(e,t)}}get store(){return this._store}get reactions(){return this._store.reactions}get commandScope(){return this.options.commandScope||"ai"}get panel(){return this.$}afterInit(){let e=this.options.store;e instanceof on||(e=new on(e),this.options.store=e),this._store=e,this._store.reactions.setPanel(this),super.afterInit();const{commands:t,onCommand:n}=this.options;(t||n)&&Mi(document.body,{commands:t,scope:this.commandScope,onCommand:this.executeCommand.bind(this)})}executeCommand(e,t=[]){const{onCommand:n,commands:s}=this.options;let r;typeof e=="string"&&(e={name:e});const{scope:o,name:a}=e,l=s?s[`${o}~${a}`]||s[a]:null;if(l)return l.call(this,e,t);if(!e.scope||e.scope===this.commandScope){const{name:c}=e;this.reactions.hasPluginMethod(c)?r=this.reactions.callPluginMethod(c,...t):r=nn(this,c,t)}return n&&(r=n.call(this,e,t)),r}_getRenderProps(e){const t=super._getRenderProps(e);return t.store=this._store,t.onAcceptSuggestion=this.acceptSuggestion,t.onModeChange=this._handleModeChange,delete t.commands,delete t.onCommand,t}destroy(){super.destroy(),Object.values(this._popups).forEach(e=>e.close()),this._popups={},clearTimeout(this._modeChangeTimer),$r(document.body,this.commandScope)}minimize(){var e;(e=this.$)==null||e.toggleMinimize(!0)}setMode(e){var t;(t=this.$)==null||t.setMode(e)}toggleEmbed(e){var t;(t=this.$)==null||t.toggleEmbed(e)}open(e,t){const n=this.$;if(n&&(n.mode!=="embed"&&n.toggleShow(!0),e))return n.open(e,t)}openPopup(e){e=e||{viewType:"chat"},typeof e=="string"&&(e==="chats"?e={viewType:"chats"}:e.startsWith("CHAT@")?e={viewType:"chat",chatID:e.substring(5)}:e={viewType:"chat",postMessage:e});const{id:t=e.chatID?`chat-${e.chatID}`:e.viewType==="chats"?"chats":`chat-${Xe()}`,onClose:n,...s}=e,r=Xy.open({id:t,...s,store:this.store,onClose:()=>{delete this._popups[t],n==null||n()}},this.$element);return this._popups[t]=r,this.minimize(),r}closePopup(e){const t=this._popups[e];if(t)return t.close(),delete this._popups[e],!0}static get shared(){try{if(window.parent!==window&&window.parent.zui)return window.parent.zui.AIPanel.shared}catch{}return this._shared}static destroy(){this._shared&&(this._shared.destroy(),this._shared=void 0)}static minimize(){var e;(e=this.shared)==null||e.minimize()}static toggleEmbed(e){var t;(t=this.shared)==null||t.toggleEmbed(e)}static setMode(e){var t;(t=this.shared)==null||t.setMode(e)}static open(e,t){var n;return typeof e=="object"&&e.chatID&&(e.chat=e.chatID,delete e.chatID,console.warn("[ZUI] AIPanel: chatID is deprecated, use chat instead")),(n=this.shared)==null?void 0:n.open(e,t)}static openPopup(e){var t;return(t=this.shared)==null?void 0:t.openPopup(e)}static init(e,t){if(!this._shared){try{if(window.parent!==window&&window.parent.zui)return this._shared=window.parent.zui.AIPanel.init(e,t),this._shared}catch{}const n=v(t||"body");let s=n.find(".ai-panel-root");if(s.length){const r=ew.query(s);if(r)return this._shared=r,r}else s=v('<div class="ai-panel-root" style="position: fixed; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; z-index: 1110"></div>'),n.append(s);this._shared=new this(s,e)}return this._shared}};Il.NAME="AIPanel",Il.Component=qy,Il.DEFAULT={commands:{}};let ni=Il;ni.register(),v(()=>{document.addEventListener("selectionchange",ca(()=>{var s;const i=(s=ni.shared)==null?void 0:s.reactions;if(!i)return;const e=window.getSelection(),t=(e==null?void 0:e.toString())??"",n=i.state.lastSelectedText;n!==t&&i.trigger("selectText",{selectedText:t},{selectedText:t,lastSelectedText:t||n})},200))});class Ml extends ve{_getRenderProps(e){var o;const{store:t="shared",...n}=super._getRenderProps(e),s=ni.shared,r=t==="shared"?(o=ni.shared)==null?void 0:o.store:t;if(!r)throw new Error("store is required");return{embed:!0,store:r,...t==="shared"?{getErrorContent:s==null?void 0:s.options.getErrorContent}:{},...n}}}Ml.NAME="AIChatView",Ml.Component=Zd,Ml.register();class Nl extends ve{_getRenderProps(e){var r;const{store:t="shared",...n}=super._getRenderProps(e);return{store:t==="shared"?(r=ni.shared)==null?void 0:r.store:t,...n}}}Nl.NAME="AIModelPicker",Nl.Component=Zy,Nl.register();class El extends ve{init(){this.options.model===void 0&&(this.options.model=this.$element.text().trim(),this.$element.empty())}_getRenderProps(e){var r;const{store:t="shared",...n}=super._getRenderProps(e);return{store:t==="shared"?(r=ni.shared)==null?void 0:r.store:t,...n}}}El.NAME="AIModelName",El.Component=Yy,El.register();class Al extends ve{}Al.NAME="ZentaoAgentResult",Al.Component=Gd,Al.register();const Yi=class extends ht{_getFileIcon(e,t){if(!t)return null;const n=typeof t;return n==="string"?t:(t=t||this.props.fileIcon,n==="function"?t.call(this,e):t[e.extension]||"file")}_getItems(e){const t=super._getItems(e),{fileIcon:n,fileSizeFormat:s,itemProps:r,heading:o,fileUrl:a,fileActions:l}=e,c=t.map(h=>{let d=null;return typeof h.size=="number"&&(d=pt(h.size),s&&(d=De(s,{size:d}))),{key:`${h.id}`,icon:this.constructor.getFileIcon(h,n),iconClass:"text-gray",title:h.title,subtitle:d,multiline:!1,url:typeof a=="function"?a.call(this,h):a?De(a,h):void 0,actions:l?l.call(this,h):void 0,...r}});return o&&c.unshift({key:"heading",titleClass:"font-bold",type:"heading",...o}),c}_getRenderedItem(e,t){return t}static getFileIcon(e,t){if(!t)return null;const n=typeof t;return n==="string"?t:n==="function"?t.call(this,e):t[e.extension]||"file"}static getDefaultIconMap(){return[["file-image",["png","jpg","jpeg","gif","bmp","webp","tiff","ico","svg"]],["file-audio",["mp3","wav","flac","ogg","m4a","wma","aac","aiff","alac"]],["file-video",["mp4","avi","mkv","mov","flv","wmv","webm"]],["file-archive",["zip","rar","7z","tar","gz","bz2","xz"]],["file-code",["js","ts","jsx","tsx","html","css","scss","less","json","xml","yml","yaml","toml","ini","markdown"]],["file-pdf",["pdf"]],["file-log",["log"]],["markdown",["md"]],["file-word",["doc","docx"]],["file-excel",["xls","xlsx"]],["file-powerpoint",["ppt","pptx"]],["file-text",["txt","csv"]]].reduce((t,[n,s])=>(s.forEach(r=>{t[r]=n}),t),{})}};Yi.NAME="file-list",Yi.defaultProps={...ht.defaultProps,fileSizeFormat:"({size})",fileIcon:Yi.getDefaultIconMap()},Yi.TAG="div",Yi.defaultItemProps={component:"div"};let si=Yi,Pl=class extends ve{};Pl.NAME="FileList",Pl.Component=si;const tM="",so=`
  55. `,Ts=so+so,bn={zh_cn:{translate:"翻译",checkCode:"代码检查",phpExpert:"PHP专家",calculator:"计算器",explain:"解释",explainMessage:`请解释如下内容:${Ts}{text}${so}`,translateHint:"翻译选中的内容",summarize:"总结",summarizeHint:"总结选中的内容",selectedText:"选中内容",currentPage:"当前页面",clipboardContent:"剪贴板",globalMemory:"全局知识库",generateTitle:"生成标题",file:"本地文件"},zh_tw:{translate:"翻譯",checkCode:"代碼檢查",phpExpert:"PHP專家",calculator:"計算器",explain:"解釋",explainMessage:`請解釋如下內容:${Ts}{text}${so}`,translateHint:"翻譯選中的內容",summarize:"總結",summarizeHint:"總結選中的內容",selectedText:"選中內容",currentPage:"當前頁面",clipboardContent:"剪貼板",globalMemory:"全局知識庫",generateTitle:"生成標題",file:"本地檔案"},en:{translate:"Translate",checkCode:"Check Code",calculator:"Calculator",phpExpert:"PHP Expert",explain:"Explain",explainMessage:`Please explain the following content:${Ts}{text}${so}`,translateHint:"Translate the selected content",summarize:"Summarize",summarizeHint:"Summarize the selected content",selectedText:"Selected Text",currentPage:"Current Page",clipboardContent:"Clipboard",globalMemory:"Global Memory",generateTitle:"Generate Title",file:"Local File"}},bt=Pd.define("common",{name:"{{common}}",icon:"magic",i18n:bn});bt.defineAgent("translate",{name:"{{translate}}",alias:[bn.en.translate,bn.zh_cn.translate],icon:"lang",prompt:'你是一个中英文翻译专家,将用户输入的中文翻译成英文,或将用户输入的英文翻译成中文。对于非中文内容,它将提供中文翻译结果。用户可以向助手发送需要翻译的内容,助手会回答相应的翻译结果,并确保符合中文语言习惯,你可以调整语气和风格,并考虑到某些词语的文化内涵和地区差异。同时作为翻译家,需将原文翻译成具有信达雅标准的译文。"信" 即忠实于原文的内容与意图;"达" 意味着译文应通顺易懂,表达清晰;"雅" 则追求译文的文化审美和语言的优美。目标是创作出既忠于原作精神,又符合目标语言文化和读者审美的翻译。直接返回译文,不要添加任何解释或说明。'}),bt.defineAgent("checkCode",{name:"{{checkCode}}",icon:"code",prompt:"I would like you to serve as a code interpreter, elucidate the syntax and the semantics of the code line-by-line. The entire conversation and instructions should be provided in Chinese."}),bt.defineAgent("phpExpert",{name:"{{phpExpert}}",icon:"php",prompt:["你是一个PHP专家,用户可能向你咨询PHP相关问题,请帮忙解答。","用户可能有如下类型的问题:","1. PHP 错误修复:用户可能给出错误信息,请帮忙分析原因,并给出修复建议、","2. 用户可能给出 PHP 代码,请帮忙分析代码中可能存在的问题","3. 用户可能给出前端 JS/HTML 代码,请帮忙分析代码中可能存在的问题,如果无法判断,请引导用户修改代码或操作浏览器获取更多的相关信息"].join(Ts)}),bt.defineAgent("summarize",{name:"{{summarize}}",alias:[bn.en.summarize,bn.zh_cn.summarize],icon:"summary",prompt:"Summarize the following text into 100 words, making it easy to read and comprehend. The summary should be concise, clear, and capture the main points of the text. Avoid using complex sentence structures or technical jargon. The entire conversation and instructions should be provided in Chinese. "}),bt.defineAgent("generateTitle",{name:"{{generateTitle}}",icon:"title",prompt:"Generate a title for the given text. The title should be concise, clear, and capture the main points of the text. Avoid using complex sentence structures or technical jargon. Only return the title in user original language, no other explanation or text, the title should not contain any markdown syntax and line breaks, limit in 10 words."}),bt.defineAgent("ai",{name:"AI",icon:"ai",prompt:"You are a helpful assistant. You can help me with my questions and tasks.",tools:[{name:"getConversations",displayName:"获取会话列表",description:"获取我的对话列表,每个列表项包括对话名称和时间戳,支持提供关键字进行搜索,如果提供关键字,则返回包含关键字的会话列表,多个关键字使用空格分隔",parameters:{type:"object",properties:{keyword:{type:"string",description:"The keyword to search for."}}},fn:function(i){const{keyword:e}=i;let t=this.chats;const n=e==null?void 0:e.trim().split(" ").filter(Boolean);n!=null&&n.length&&(t=t.filter(r=>n.every(o=>r.title.includes(o))));const s=t.map(r=>({id:r.id,title:r.title,timestamp:r.created_at}));return{result:s,info:{markdown:s.map(r=>`- ${r.title} (${Ze(r.timestamp,"yyyy-MM-dd hh:mm")})`).join(`
  56. `)}}}}]}),bt.defineAgent("zui",{name:"zui",icon:"zui",prompt:"You are a helpful assistant. You can help me with my questions and tasks.",tools:[{name:"dtable",displayName:"数据表格",description:"绘制一个数据表格,需要提供表格列名定义和每行的数据。",parameters:{type:"object",properties:{columns:{type:"array",description:"The columns of the table.",items:{type:"object",properties:{name:{type:"string",description:"The name of the column, also is the key of the row data."},title:{type:"string",description:"The title of the column."}}}},data:{type:"array",description:"The data rows of the table.",items:{type:"object",properties:{}}}}},fn:i=>{const{columns:e,data:t}=i;return{view:{style:{width:500},component:"DTable",props:{cols:e,data:t}}}}},{name:"formBuilder",displayName:"表单生成器",description:"生成一个表单,需要提供表单的 JSONSchema配置和数据。",parameters:{type:"object",properties:{schema:{type:"object",description:"The JSONSchema of the form.",properties:{}},data:{type:"object",description:"The data of the form.",properties:{}}}},fn:i=>{const{schema:e,data:t}=i;return{view:{component:"FormBuilder",props:{schema:e,data:t}}}}}]}),bt.defineAgent("calculator",{name:"{{calculator}}",alias:[bn.en.calculator,bn.zh_cn.calculator],icon:"calculator",prompt:"You are a calculator. You can help me calculate the result of the expression. Only return the result, no other explanation or text.",tools:[{name:"calc",displayName:bn.zh_cn.calculator,description:"Calculate the result of the expression, only supports directly executable JS expressions.",parameters:{type:"object",properties:{expression:{type:"string",description:"The expression to calculate."}},required:["expression"]},when:()=>!window.config||window.config.debug,fn:i=>{const{expression:e}=i,t=[...["window","document","navigator","location","history","sessionStorage","localStorage","alert","eval","prompt"].map(r=>`const ${r}={};`),`return (${e});`].join(`
  57. `),n=v.runJS(t),s=e.replaceAll("Math.","");return{value:n,message:JSON.stringify({expression:e,result:n}),view:{markdown:["```js",`${s} = ${n}`,"```"].join(`
  58. `)},actions:[{text:"复制表达式",onClick:()=>navigator.clipboard.writeText(String(s))},{text:"复制结果",onClick:()=>navigator.clipboard.writeText(String(n))}]}}}]}),bt.defineMethod("translate",({state:i,panel:e},t)=>e==null?void 0:e.openPopup({viewType:"chat",postMessage:{content:t??i.selectedText,chat:{agent:"translate"}},viewProps:{mode:"lite"}})),bt.defineMethod("summarize",({state:i,panel:e},t)=>e==null?void 0:e.openPopup({viewType:"chat",postMessage:{content:t??i.selectedText,chat:{agent:"summarize"}},viewProps:{mode:"lite"}})),bt.defineMethod("addFileToChat",async i=>{const e=i.state.selectedChatID;if(!e)return;const t=await wh({accept:".pdf,.docx,.doc,.xlsx,.xls,.csv,.pptx,.html,.htm,.json,.yaml,.yml,.txt,.md",multiple:!1});t&&i.store.reactions.addChatContext(e,{code:`file:${t.name}:${t.size}:${t.lastModified}`,title:t.name,icon:Pl.Component.getFileIcon({title:t.name,extension:t.name.split(".").pop()||""},"file-text"),plugin:"common",data:async()=>{const n=await i.store.extractFile(t);return{prompt:`文件《${t.name}》内容:
  59. ${Ts}${n.content}`}}})}),bt.defineSuggestion({title:"{{translate}}",hint:"{{translateHint}}",icon:"lang",priority:-1,command:".translate",when:({state:i})=>!!i.selectedText.length}),bt.defineSuggestion({title:"{{summarize}}",hint:"{{summarizeHint}}",icon:"summary",priority:-1,command:".summarize",when:({state:i})=>!!i.selectedText.length}),bt.defineContextProvider({code:"selectedText",title:"{{selectedText}}",icon:"rich-text",when:({state:i})=>!!i.lastSelectedText.length,data:({state:i})=>({prompt:`选中的文本:${Ts}${i.lastSelectedText}`}),generate:({userPrompt:i,plugin:e})=>{if(i!=null&&i.length&&new RegExp(`@(${(e==null?void 0:e.getLang("selectedText"))??bn.zh_cn.selectedText})`,"i").test(i))return{}}}),bt.defineContextProvider({code:"currentPage",title:"{{currentPage}}",icon:"globe",recommend:!0,when:()=>!0,data:()=>({prompt:[`当前页面标题:${document.title}`,"当前页面内容:",document.body.textContent].join(Ts)}),generate:({userPrompt:i,plugin:e})=>{if(i!=null&&i.length&&new RegExp(`@(${(e==null?void 0:e.getLang("currentPage"))??bn.zh_cn.currentPage})`,"i").test(i))return{}}}),bt.defineContextProvider({code:"clipboardContent",title:"{{clipboardContent}}",icon:"copy",recommend:!1,when:()=>!!navigator.clipboard,data:async()=>{const i=await navigator.clipboard.readText();return{prompt:`剪贴板内容:${Ts}${i}`}},generate:({userPrompt:i,plugin:e})=>{if(i!=null&&i.length&&new RegExp(`@(${(e==null?void 0:e.getLang("clipboardContent"))??bn.zh_cn.clipboardContent})`,"i").test(i))return{}}}),bt.defineContextProvider({code:"globalMemory",title:"{{globalMemory}}",icon:"book",when:i=>!!i.store.globalMemory,data:{memory:{collections:["$global"]}}}),bt.defineContextProvider({code:"file",title:"{{file}}",icon:"upload-file",command:".addFileToChat"});const nM="",sM="",iM="",rM="",oM="",aM="",lM="",cM="",hM="",dM="",Ll=Symbol("batch-form"),Qd=class ep extends qe{constructor(){super(...arguments),this._actions=null,this._cols=[],this._idSeed=0,this._rows=[]}afterInit(){var s;const e=v(this.element),t=e.find(".form-batch-table").addClass("borderless");let n=t.find("tbody");n.length||(n=v("<tbody/>").appendTo(t)),this.$tbody=n,this._template=(s=e.find(".form-batch-template").get(0))==null?void 0:s.innerHTML,this._cols=[],t.find("thead>tr>.form-batch-head").each((r,o)=>{const a=v(o),l=a.data();l&&(l.hidden=a.hasClass("hidden"),this._cols.push(l)),a.data("name")==="ACTIONS"&&a.addClass("form-batch-col-actions")}),this.options.fixedActions&&(e.addClass("has-fixed-actions"),this._sticky=new oa(e,{side:"right",offset:0,scrollContainer:".form-batch-container",targets:'td[data-name="ACTIONS"],th[data-name="ACTIONS"]'})),e.on("click",r=>{var h;const o=v(r.target).closest(".form-batch-btn");if(!o.length)return;const a=o.dataset("type"),l=o.closest("tr"),c=l.dataset("index");((h=this.options.onClickAction)==null?void 0:h.call(this,a,l,c))!==!1&&(a==="add"?this.addRow(c):a==="delete"?this.deleteRow(c):a==="ditto"&&this.toggleDitto(o))}).on("change",".form-batch-input,.pick-value",r=>{const o=v(r.target);r.___td===Ll||o.hasClass("pick-value")&&!r.___td||this.syncDitto(o)}).on("change",'[type="radio"],[type="checkbox"]',r=>{ep.updateCheckValues(v(r.target))}),this.options.sortable&&(this._sortable=new Ia(n,{draggable:"tr",handle:'.form-batch-btn[data-type="sort"]',dataIdAttr:"data-gid",ghostClass:"bg-primary-50",filter:".disabled",onSort:()=>{this._rows=this._sortable.toArray().map(Number),this.render()},dragShadow:!1,...typeof this.options.sortable=="object"?this.options.sortable:{}})),this.render()}destroy(){var e;v(this.element).off("click change"),this.$tbody=void 0,this._template=void 0,this._cols.length=0,this._rows.length=0,(e=this._sticky)==null||e.destroy()}render(e,t){super.render(e,t),!t&&this._rows.length?this._renderRows():(this._actions=null,this._initRows())}addRow(e,t){return t=t??this._idSeed++,typeof e=="number"&&e>=0&&e<=this._rows.length?this._rows.splice(e+1,0,t):(e=this._rows.length,this._rows.push(t)),this._renderRows(void 0,e),t}deleteRow(e){var n;if(this._rows.length<=1||typeof e!="number"||e<0||e>=this._rows.length)return!1;const t=this._rows[e];this._rows.splice(e,1),(n=this.$tbody)==null||n.children(`[data-gid="${t}"]`).remove(),this._renderRows(void 0,e)}deleteRowByGid(e){return this.deleteRow(this._rows.indexOf(e))}toggleDitto(e,t){const n=e.closest("td");t=t??n.attr("data-ditto")!=="on",n.attr("data-ditto",t?"on":"off"),t&&n.closest("tr").prev("tr").find(`td[data-name="${n.data("name")}"]`).find(".form-batch-input,.pick-value").each((o,a)=>{this.syncDitto(v(a),!1)})}syncDitto(e,t=!0,n=!1){const s=e.closest("td");t&&s.attr("data-ditto","off");const r=s.data("name"),a=(e.hasClass("pick-value")?e.closest(".form-group-wrapper"):e).attr("data-name"),l=`td[data-name="${r}"][data-ditto="on"]`,c=e.val();let h=e.closest("tr").next("tr"),d=h.find(l);for(;d.length;){const f=d.find(`.form-batch-input[data-name="${a}"]`);if(f.length&&f.val()!==c)f.val(c).trigger("change",Ll);else{const p=d.find(".pick").parent().zui();p&&p.$&&p.$element.attr("data-name")===a&&p.$.value!==c&&p.$.setValue(c,!0).then(()=>{p.$element.find(".pick-value").trigger("change",Ll)})}if(n)break;h=h.next("tr"),d=h.find(l)}}toggleCols(e,t){const n=this.$element.find(".form-batch-table").find("th.form-batch-head,td.form-batch-control");n.length&&(typeof e=="string"&&(e=[e]),e.forEach(s=>{const r=this._cols.find(o=>o.name===s);r&&(r.hidden=!t,n.filter(`[data-name="${s}"]`).toggleClass("hidden",!t),t&&requestAnimationFrame(()=>{n.filter(".form-batch-ditto-control").each((o,a)=>{const l=v(a),c=l.find(".form-batch-ditto-btn");l.css("--form-batch-ditto-width",`${c.outerWidth()}px`)})}))}))}_initRows(){const e=this.$tbody;if(!this._template||!(e!=null&&e.length))return;const{data:t=[],minRows:n,maxRows:s,mode:r,rowsCount:o=r==="add"?Math.min(Math.max(1,s??100),Math.max(1,n??(r==="add"?10:1),t.length)):t.length}=this.options;this._rows=Array(o).fill(0).map((a,l)=>l),this._idSeed=this._rows.length,this._renderRows(t)}_renderRows(e=[],t=0){var s;const n=this._rows.length;for(let r=t;r<n;r++)this._renderRow(r,e[r]);(s=this.$tbody)==null||s.attr("data-count",`${n}`)}_renderActions(e){var n;let t=this._actions;if(!t){const{addRowIcon:s="icon-plus",deleteRowIcon:r="icon-trash",sortRowIcon:o="icon-move",sortable:a}=this.options;t=new DocumentFragment;const l='<button type="button" data-type="{type}" class="form-batch-btn btn square ghost size-sm" title="{text}"><i class="icon {icon}"></i></button>';let{actions:c}=this.options;c===void 0&&(c=[],o!==!1&&a&&c.push("sort"),s!==!1&&c.push("add"),r!==!1&&c.push("delete"));const h={sort:{type:"sort",icon:o||"",text:this.i18n("sort"),className:"cursor-move"},add:{type:"add",icon:s||"",text:this.i18n("add")},delete:{type:"delete",icon:r||"",text:this.i18n("delete")}};c.forEach(d=>{typeof d=="string"&&(d={type:d});const f=v.extend({},h[d.type],d),p=v(De(l,f));f.className&&p.addClass(f.className),t.append(p[0])}),(n=this.options.onRenderActions)==null||n.call(this,t),this._actions=t,this.$element.find('.form-batch-head[data-name="ACTIONS"]').attr("data-action-count",t.children.length+"")}e.empty().append(t.cloneNode(!0))}_renderRow(e,t){const n=this.$tbody,s=String(this._rows[e]),{idKey:r="id",mode:o,onRenderRowCol:a,onRenderRow:l}=this.options,c=o==="add",h=String(t&&t[r]!==void 0?t[r]:e+1);let d=n.children(`[data-gid="${s}"]`),f=!1;if(d.length){if(!t&&d.dataset("index")===e)return}else{f=!0;let w=this._template;if((w.includes(" zui-create ")||w.includes(" zui-create="))&&(w=w.replace(/(id|for)="([\\$a-z_]+)"/g,`$1="$2_${s}"`)),w.includes("<script>")&&w.includes('zui.create("')){const x=[];w=w.replace(/(zui\.create\("[a-zA-Z]+","#)(\w+)(",)/g,(T,D,N,A)=>(x.push(N),`${D}${N}_${s}${A}`)),x.forEach(T=>{const D=`${T}_${s}`;w=w.replace(`id="${T}"`,`id="${D}"`)})}w=w.replaceAll("{GID}",s),d=v(w.trim()).attr("data-gid",s).addClass("form-batch-row"),d.find('[type="radio"],[type="checkbox"]').each((x,T)=>{const D=v(T),N=D.attr("id"),A=`${N}_${s}`;D.attr("id",A),d.find(`label[for="${N}"]`).attr("for",A)}),d.zuiInit({onCreate:(x,T)=>(typeof T.name=="string"&&(T._initFromBatchForm=!0),T)})}const p=this._rows[e-1],y=n.children(`[data-gid="${p}"]`);d.attr("data-index",`${e}`),d.find("textarea").autoHeight(),d.on("inited",(w,[x])=>{let T=x.options.name;if(T){const D=T.endsWith("[]");D&&(T=T.slice(0,T.length-2));const N=x.$element.closest("td");if(x.$element.attr("data-name",T),x.options._initFromBatchForm&&(x.$ instanceof ot||x instanceof Zr)&&x.render({name:`${T}[${h}]${D||x.$.props.multiple?"[]":""}`}),y.length&&N.data("ditto")==="on"){const A=y.find(`td[data-name="${N.data("name")}"]`);this.syncDitto(A.find(`[data-name="${T}"] .pick-value`),!1,!0)}else t&&t[T]!==void 0&&x.$.setValue(t[T],!0)}}),t&&d.data("data",t),e?y.length?y.after(d):d.appendTo(n):d.prependTo(n),f&&d.find("script").remove();const b=t||d.data("data");this._cols.forEach(w=>{let x=d.find(`td[data-name="${w.name}"]`);if(x.length||(x=v(`<td data-name="${w.name}"></td>`).appendTo(d)),w.index){x.find(".form-control-static").text(h).attr("id",`${w.name}_${s}`),a==null||a.call(this,x,w,b,e);return}if(x.toggleClass("hidden",!!w.hidden),!x.data("init")||t){if(w.name==="ACTIONS"){if(x.addClass("form-batch-col-actions"),!c)return;this._renderActions(x);return}x.data("init",1).find("[name],.form-control-static").each((D,N)=>{const A=v(N);if(A.hasClass("form-control-static")){const z=A.attr("data-name");t&&A.text(String(t[z]??""))}else if(A.hasClass("pick-value")){if(t){const z=qi.globalControls.picker(A,this.$element);if(z){const O=z.$element.attr("data-name")??z.instance.options.name??A.attr("data-name")??A.attr("name"),K=typeof O=="string"?t[O]:void 0;K!==void 0&&K!==z.getVal()&&z.instance.$.setValue(K,!0).then(()=>{z.$element.find(".pick-value").trigger("change",Ll)})}}}else{const z=A.attr("data-name")??A.attr("name"),O=`${z}[${h}]`;if(A.attr({name:O,"data-name":z}).addClass("form-batch-input"),t&&t[z]!==void 0){const K=String(t[z]??"");if(A.is('[type="radio"]'))A.prop("checked",K===A.val());else if(A.is('[type="checkbox"]')){const Z=new Set(K.split(","));A.prop("checked",Z.has(A.val()))}else A.val(K)}}}),x.find('[type="radio"],[type="checkbox"]').each((D,N)=>{const A=v(N);typeof A.attr("data-name")!="string"||A.attr("data-val")!==void 0||ep.updateCheckValues(A,x,h)})}else x.find("[name]").each((D,N)=>{const A=v(N),z=A.attr("data-name");if((A.attr("name")??"").startsWith(`${z}[`)){if(A.attr("name",`${z}[${h}]`),A.is('[type="radio"]'))A.prop("checked",A.val()===A.attr("data-val"));else if(A.is('[type="checkbox"]')){const O=new Set(A.attr("data-val").split(","));O.size>1&&A.attr("name",`${z}[${h}][]`),A.prop("checked",O.has(A.val()))}}}),x.find(".pick").each((D,N)=>{const A=v(N).parent(),z=A.zui();z&&z.render({name:`${A.data("name")}[${h}]`})});if(w.ditto){x.addClass("form-batch-ditto");let D=x.find(".form-batch-ditto-btn");if(e){const{defaultDitto:N="on"}=w;if(x.attr("data-ditto",N),!D.length){D=v(`<button type="button" class="btn ghost form-batch-btn form-batch-ditto-btn" data-type="ditto">${this.i18n("ditto")}</button>`);let A=x.children(".form-batch-ditto-wrapper");A.length||(A=v('<div class="form-batch-ditto-wrapper"></div>').append(x.children()).appendTo(x)),A.append(D)}requestAnimationFrame(()=>x.css("--form-batch-ditto-width",`${D.outerWidth()}px`)),N==="on"&&y.find(`td[data-name="${w.name}"]`).find(".form-batch-input").each((z,O)=>{this.syncDitto(v(O),!1,!0)})}else x.attr("data-ditto",""),D.remove()}const T=!!(w.ditto&&e);x.toggleClass("form-batch-ditto-control",T),x.find(".form-batch-ditto-btn").toggle(T),a==null||a.call(this,x,w,b,e)}),l==null||l.call(this,d,e,b)}static updateCheckValues(e,t,n){const s=e.attr("data-name");if(typeof s!="string")return;const r=e.attr("type");t=t||e.closest("td");const o=t.find(`[type="${r}"][data-name="${s}"]`);n!==void 0&&r==="checkbox"&&o.length>1&&o.attr("name",`${s}[${n}][]`);const a=[];o.filter(":checked").each((c,h)=>{a.push(v(h).val())});const l=r==="radio"?a[0]:a.join(",");o.attr("data-val",l)}};Qd.NAME="BatchForm",Qd.DEFAULT={mode:"add",idKey:"id",i18n:{zh_cn:{ditto:"同上",delete:"删除",add:"添加",sort:"排序"},zh_tw:{ditto:"同上",delete:"刪除",add:"添加",sort:"排序"},en:{ditto:"Ditto",delete:"Delete",add:"Add",sort:"Sort"}}};let Qy=Qd;const uM="";function Xk(i){return typeof i=="string"?i.split(",").map(e=>{const t=parseFloat(e);return Number.isNaN(t)?null:t}):i}let eu=class extends re{constructor(){super(...arguments),this._canvas=pe(),this._timer=0,this._needDraw=!1}componentDidMount(){var t;this.tryDraw=this.tryDraw.bind(this),this.tryDraw();const e=(t=this._canvas.current)==null?void 0:t.parentElement;if(this.props.responsive!==!1){if(e&&typeof ResizeObserver<"u"){const n=new ResizeObserver(this.tryDraw);n.observe(e),this._rob=n}this._rob||window.addEventListener("resize",this.tryDraw)}if(e&&typeof IntersectionObserver<"u"){const n=new IntersectionObserver(s=>{this._needDraw&&s.some(r=>r.isIntersecting)&&this.tryDraw()});n.observe(e),this._iob=n}}componentDidUpdate(){this.tryDraw()}componentWillUnmount(){var e;(e=this._rob)==null||e.disconnect(),window.removeEventListener("resize",this.tryDraw)}tryDraw(){this._timer&&cancelAnimationFrame(this._timer),this._timer=requestAnimationFrame(()=>{this.draw(),this._timer=0})}draw(){const e=this._canvas.current;if(!e)return;const t=e.parentElement,{width:n,height:s,responsive:r=!0}=this.props;let o=n||t.clientWidth,a=s||t.clientHeight;if(n&&s&&r&&(o=t.clientWidth,a=Math.floor(s*o/n)),e.style.width=`${o}px`,e.style.height=`${a}px`,o=o*(window.devicePixelRatio||1),a=a*(window.devicePixelRatio||1),e.width=o,e.height=a,!v(t).isVisible()&&this._iob){this._needDraw=!0;return}const{lineSize:l=1,scaleLine:c=!1,scaleLineSize:h,scaleLineGap:d=1,scaleLineDash:f,referenceLine:p,referenceLineSize:y,referenceLineDash:b,color:w="#2c78f1",fillColor:x=["rgba(46, 127, 255, 0.3)","rgba(46, 127, 255, 0.05)"],lineDash:T=[],bezier:D}=this.props,N=Xk(this.props.data);if(!N.length)return;const A=Math.floor(o/(N.length-1)),z=Math.max(...N.filter(ye=>ye!==null)),O=N.map((ye,Q)=>{const ne=typeof ye!="number";return{x:Q*A,y:ne?a:Math.round((1-ye/z)*(a-l)),empty:ne}});let K=O[0];const Z=e.getContext("2d");if(c){const ye=typeof c=="string"?c:"rgba(100,100,100,.1)";Z.strokeStyle=ye,Z.lineWidth=h||l,f&&Z.setLineDash(f);for(let Q=0;Q<O.length;++Q){if(Q%d!==0)continue;const ne=O[Q];Z.moveTo(ne.x,0),Z.lineTo(ne.x,a)}Z.stroke()}if(p&&O.length>1){const ye=typeof p=="string"?p:"rgba(100,100,100,.2)",Q=O[O.length-1];Z.moveTo(Q.x,a),Z.strokeStyle=ye,Z.lineWidth=y||l,Z.lineTo(K.x,K.y),b&&Z.setLineDash(b),Z.stroke()}for(Z.setLineDash(T);O.length&&O[O.length-1].empty;)O.pop();if(x){const ye=O[O.length-1];if(Z.beginPath(),Z.moveTo(0,a),Z.lineTo(K.x,K.y),D){const Q=Math.round(A/2);for(let ne=1;ne<O.length;++ne){const xe=O[ne],Me=Math.round((xe.y-K.y)/5);Z.bezierCurveTo(K.x+Q,K.y+Me,xe.x-Q,xe.y-Me,xe.x,xe.y),K=xe}}else for(let Q=1;Q<O.length;++Q)K=O[Q],Z.lineTo(K.x,K.y);if(Z.lineTo(ye.x,a),Array.isArray(x)){const Q=Z.createLinearGradient(0,0,0,a);for(let ne=0;ne<x.length;++ne)Q.addColorStop(ne/(x.length-1),x[ne]);Z.fillStyle=Q}else Z.fillStyle=x;Z.fill()}if(K=O[0],Z.beginPath(),Z.moveTo(K.x,K.y),D){const ye=Math.round(A/2);for(let Q=1;Q<O.length;++Q){const ne=O[Q],xe=Math.round((ne.y-K.y)/5);Z.bezierCurveTo(K.x+ye,K.y+xe,ne.x-ye,ne.y-xe,ne.x,ne.y),K=ne}}else for(let ye=1;ye<O.length;++ye)K=O[ye],Z.lineTo(K.x,K.y);Z.strokeStyle=w,Z.lineWidth=l,Z.stroke()}render(){const{style:e,className:t,canvasClass:n}=this.props;return g("div",{class:"center burn-chart",className:t,style:e},g("canvas",{className:n,ref:this._canvas}))}};eu.defaultProps={responsive:!0,lineSize:1,scaleLine:!1,scaleLineSize:1,bezier:!0};class tu extends ve{}tu.NAME="Burn",tu.Component=eu;class ev extends Ve{_getClassName(e){return["datalist",e.className]}_getProps(e){return Pe(super._getProps(e),e.labelWidth?{style:{"--datalist-label-width":Be(e.labelWidth)}}:null)}_getChildren(){const{items:e=[]}=this.props;return e.map((t,n)=>{const{key:s=n,className:r,label:o,labelStyle:a,labelClass:l,labelAttrs:c,content:h,contentStyle:d,contentClass:f,contentAttrs:p,...y}=t;return g("div",{key:s,className:U("datalist-item",r),...y},g("div",{className:U("datalist-item-label",l),style:a,...c},g(de,{content:o})),g("div",{className:U("datalist-item-content",f),style:d,...p},g(de,{content:h})))})}}st(Object.freeze(Object.defineProperty({__proto__:null,Datalist:ev},Symbol.toStringTag,{value:"Module"})));const pM="";let Ji=class extends re{render(e){const{avatar:t,account:n,realname:s,user:r,...o}=e,a={code:r?r.account:n,text:r?r.realname??r.account:s??n,src:r?r.avatar:t,...o};return g(ts,{...a})}};Ji.defaultProps={size:24,circle:!0};let nu=class extends Er{constructor(){super(...arguments),this._categories=Ce(()=>{const e=this.items,{categories:t=[],extraCategory:n}=this.props,s=new Map,r=t.reduce((l,c)=>(l.set(c.name,c),l),new Map),o=(l,c)=>typeof n=="string"?n===l||n===c:Array.isArray(n)?n.some(h=>h===l||h===c):!!n;let a=0;return e.forEach(l=>{let c=s.get(l.category);c||(c={id:l.id,name:l.category,items:[],order:s.size,required:l.required,...r.get(l.category)},r.delete(l.category)),c.id||(c.id=`new_${a++}`),c.extra=o(l.category,c.id),c.items.push(l),s.set(l.category,c)}),r.size&&r.forEach(l=>{s.set(l.name,{id:l.id,items:[],order:s.size,extra:o(l.name,l.id),...l})}),Array.from(s.values()).sort((l,c)=>l.order-c.order)}),this._handleConfirmRenameClick=e=>{const t=v(e.target).closest(".deliverable-item-rename").find(".form-control").val();this.renameItem(this.signals.renamingItem.value,t),this.cancelRenameItem()},this._handleSelectDoc=e=>{this.selectDoc(this.signals.renamingItem.value,e)}}get items(){return this.signals.items.value}get categories(){return this._categories.value}setFileToInput(e,t){const n=v(this.base).find(`.deliverable-item[z-gid="${e}"]`).find(".deliverable-file-value");if(n.length){const s=new DataTransfer;t&&s.items.add(t),n.prop("files",s.files)}}setFile(e,t){const n=this.items,s=typeof e=="number"?n.find(r=>r._gid===e):e;return s?(s.file=t?{name:t.name,size:t.size,type:t.type,extension:t.name.split(".").pop()||"",blob:t}:void 0,this.signals.items.value=[...n],this.setFileToInput(s._gid,t||null),!0):!1}selectFile(e){const{maxFileSize:t,acceptFileTypes:n,onExceededSize:s,exceededSizeTip:r}=this.props;wh({accept:n,multiple:!1}).then(o=>{const a=typeof t=="string"?$n(t):t;if(a&&o&&o.size>a){if(r){const l=typeof r=="string"?De(r,{size:pt(a),name:o.name,maxFileSize:pt(a)}):r.message;He.alert(l)}s==null||s.call(this,a,o)}else this.setFile(e,o)})}selectDoc(e,t){const n=this.items,s=typeof e=="number"?n.find(r=>r._gid===e):e;return s?(s.doc=t,this.signals.items.value=[...n],this.setFileToInput(s._gid,null),!0):!1}getItem(e){return this.items.find(t=>t._gid===e)}deleteItem(e){const t=this.items,n=typeof e=="number"?t.find(s=>s._gid===e):e;return n?(n.file=void 0,n.doc=void 0,this.signals.items.value=[...t],this.setFileToInput(n._gid,null),!0):!1}removeItem(e){const t=this.items,n=typeof e=="number"?t.find(r=>r._gid===e):e;if(!n)return!1;const s=t.indexOf(n);return s===-1?!1:(t.splice(s,1),this.signals.items.value=[...t],this.setFileToInput(n._gid,null),!0)}startRenameItem(e){const t=typeof e=="number"?e:e._gid;this.signals.renamingItem.value=t,setTimeout(()=>{var s;const n=v(this.base).find(`.deliverable-item[z-gid="${t}"]`).find(".deliverable-item-rename input");n.length&&((s=n[0])==null||s.focus())},0)}addItems(e){const t=this.items;e.forEach(n=>{t.push(this._formatItem(n))}),this.signals.items.value=[...t]}addItem(e){return this.addItems([e])}cancelRenameItem(){this.signals.renamingItem.value=0}renameItem(e,t){const n=typeof e=="number"?e:e._gid,s=this.getItem(n);return s?(s.name=t,this.signals.items.value=[...this.items],!0):!1}getDefaultState(e){return{items:e.items.map(this._formatItem),renamingItem:0}}getItemName(e){var t,n;return typeof e.name=="string"&&e.name.length?e.name:((t=e.file)==null?void 0:t.name)??((n=e.doc)==null?void 0:n.title)??""}_formatItem(e){return{...e,_gid:Xe()}}_getClassName(e){return["deliverable-list",super._getClassName(e)]}_getFileIcon(e){return si.getFileIcon(e,this.props.fileIcon)||"file"}_getItemActions(e,t){const{getFileActions:n,getDocActions:s}=this.props;return e.file&&n?n.call(this,e.file,e,t):e.doc&&s?s.call(this,e.doc,e,t):[]}_renderItem(e,t,n){var o,a,l,c,h;const s=[];if(this.signals.renamingItem.value===e._gid){const d=this.getItemName(e);s.push(g("div",{key:"file",className:"deliverable-item-rename"},g("input",{key:"name",className:"form-control",value:e.name,placeholder:d,defaultValue:d}),g(we,{icon:"check",type:"primary-pale",onClick:this._handleConfirmRenameClick}),g(we,{icon:"close",type:"gray-pale",onClick:()=>this.cancelRenameItem()})))}else if(e.file||e.doc){e.file?s.push(g("div",{key:"file",className:"deliverable-item-file"},g($e,{icon:this._getFileIcon(e.file),className:"text-gray"}),g("span",null,this.getItemName(e)),g("span",{className:"muted ml-1"},pt(e.file.size)))):e.doc&&s.push(g("div",{key:"doc",className:"deliverable-item-doc"},g($e,{icon:n.docIcon}),g("span",null,this.getItemName(e)),g("span",{className:"muted ml-1"},"#",e.doc.version)));const d=this._getItemActions(e,t).map(f=>(!f.onClick&&!f.url&&(f.key==="delete"?f.onClick=()=>this.deleteItem(e):f.key==="rename"&&(f.onClick=()=>this.startRenameItem(e))),f));s.push(g(Fe,{key:"actions",className:"deliverable-item-actions",size:"sm",items:d})),e.createdBy&&s.push(g("div",{className:"deliverable-item-avatar",key:"avatar"},g(Ji,{circle:!0,size:"xs",realname:e.createdBy}),g("span",{className:"deliverable-item-created-by"},e.createdBy))),n.getItemInfo&&s.push(g(de,{key:"info",className:"deliverable-item-info",content:(o=n.getItemInfo)==null?void 0:o.call(this,e,t)}))}else{const d=n.docPicker||{},f=(a=n.getEmptyActions)==null?void 0:a.call(n,e,t).map(b=>(!b.onClick&&!b.url&&b.key==="selectFile"&&(b.onClick=()=>this.selectFile(e)),b.key==="selectTemplate"?{type:"dropdown",menu:{searchBox:!0,searchPlacement:"top",maxHeight:400,...typeof n.templateMenu=="function"?n.templateMenu.call(this,e,t):n.templateMenu},onClickItem:w=>{var x;(x=n.onSelectTemplate)==null||x.call(n,w.item.value,t.name)},...b}:b)),p=this,y=function(b){const w=this.state.selections[0];p.selectDoc(e,{id:b,title:w.text,version:w.docVersion})};s.push(g(Zt,{key:"docPicker",className:"deliverable-item-doc-picker",items:[],...d,onChange:y}),typeof f=="object"&&f.length>0&&[g(Fe,{key:"actions",className:"deliverable-item-empty-actions",btnType:"default",items:f,gap:4})])}const{formName:r}=n;if(r){const d=t.id;s.push(g("div",{key:"form",className:"hidden"},g("input",{type:"hidden",name:`${r}[${d}][name][]`,value:e.name}),g("input",{type:"hidden",name:`${r}[${d}][doc][]`,value:((l=e.doc)==null?void 0:l.id)??""}),(c=e.doc)!=null&&c.version?g("input",{type:"hidden",name:`${r}[${d}][docVersion][]`,value:e.doc.version}):null,g("input",{type:"hidden",name:`${r}[${d}][fileID][]`,value:((h=e.file)==null?void 0:h.id)??""}),g("input",{type:"hidden",name:`${r}[${d}][itemID][]`,value:(e==null?void 0:e.itemID)??""}),g("input",{className:"hidden deliverable-file-value",type:"file",name:`${r}_${d}[]`})))}return e.category===this.props.extraCategory&&(e.file||e.doc)&&s.push(g("div",{className:"deliverable-item-extra-delete"},g(we,{text:be.getLang("delete"),type:"ghost text-primary",onClick:()=>this.removeItem(e)}))),g("div",{className:"deliverable-item form-group",key:e._gid,"z-gid":e._gid,"data-form-name":r?`${r}[${t.id}]`:void 0},g("div",{className:"deliverable-item-row"},s),g("div",{class:"form-tip"}))}_renderCategory(e,t){return g("div",{key:e.name,className:U("deliverable-category",e.required?"required":"")},t.isTemplate?null:g("div",{className:"deliverable-category-name"},g("span",{className:"text"},e.name)),g("div",{className:"deliverable-category-items"},e.items.map(n=>this._renderItem(n,e,t))))}_renderItems(e){return g("div",{key:"items",className:"deliverable-items",style:e.categoryWidth?{"--deliverable-category-width":Be(e.categoryWidth)}:void 0},this.categories.map(t=>this._renderCategory(t,e)))}_renderHeader(e){return g(de,{key:"header",content:e.header})}_renderFooter(e){return g(de,{key:"footer",content:e.footer})}_getChildren(e){return[this._renderHeader(e),this._renderItems(e),this._renderFooter(e)]}componentDidMount(){this._autoAddExtra=_t(()=>{const{categories:e}=this,t=[];e.forEach(n=>{(!n.maxCount||n.items.length<n.maxCount)&&n.extra&&!n.items.some(s=>!s.file&&!s.doc)&&t.push(n.name)}),t.length&&this.addItems(t.map(n=>({category:n})))})}componentWillUnmount(){var e;(e=this._autoAddExtra)==null||e.call(this)}};nu.NAME="DeliverableList",nu.defaultProps={fileIcon:si.getDefaultIconMap(),docIcon:"doc",formName:"deliverable",isTemplate:!1,exceededSizeTip:be(Gg,"exceededSizeTip")};class Rl extends ve{}Rl.NAME="DeliverableList",Rl.Component=nu,Rl.register();const mM="",gM="";class tv extends re{constructor(t){super(t);Yf(this,Ns,void 0);Yf(this,Es,void 0);pr(this,Ns,0),pr(this,Es,null),this._handleWheel=n=>{const{wheelContainer:s}=this.props,r=n.target;if(!(!r||!s)&&(typeof s=="string"&&r.closest(s)||typeof s=="object")){const o=(this.props.type==="horz"?n.deltaX:n.deltaY)*(this.props.wheelSpeed??1);this.scrollOffset(o)&&n.preventDefault()}},this._handleMouseMove=n=>{const{dragStart:s}=this.state;s&&(fr(this,Ns)&&cancelAnimationFrame(fr(this,Ns)),pr(this,Ns,requestAnimationFrame(()=>{const r=this.props.type==="horz"?n.clientX-s.x:n.clientY-s.y;this.scroll(s.offset+r*this.props.scrollSize/this.props.clientSize),pr(this,Ns,0)})),n.preventDefault())},this._handleMouseUp=()=>{this.state.dragStart&&this.setState({dragStart:!1})},this._handleMouseDown=n=>{this.state.dragStart||this.setState({dragStart:{x:n.clientX,y:n.clientY,offset:this.scrollPos}}),n.preventDefault(),n.stopPropagation()},this._handleClick=n=>{const s=n.currentTarget;if(!s)return;const r=s.getBoundingClientRect(),{type:o,clientSize:a,scrollSize:l}=this.props,c=(o==="horz"?n.clientX-r.left:n.clientY-r.top)-this.barSize/2;this.scroll(c*l/a),n.preventDefault()},this.state={scrollPos:this.props.defaultScrollPos??0,dragStart:!1}}get scrollPos(){return this.props.scrollPos??this.state.scrollPos}get controlled(){return this.props.scrollPos!==void 0}get maxScrollPos(){const{scrollSize:t,clientSize:n}=this.props;return Math.max(0,t-n)}get barSize(){const{clientSize:t,scrollSize:n,size:s=12,minBarSize:r=3*s}=this.props;return Math.max(Math.round(t*t/n),r)}componentDidMount(){document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp);const{wheelContainer:t}=this.props;t&&(pr(this,Es,typeof t=="string"?document:t.current),fr(this,Es).addEventListener("wheel",this._handleWheel,{passive:!1}))}componentWillUnmount(){document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),fr(this,Es)&&fr(this,Es).removeEventListener("wheel",this._handleWheel)}scroll(t){return t=Math.max(0,Math.min(Math.round(t),this.maxScrollPos)),t===this.scrollPos?!1:(this.controlled?this._afterScroll(t):this.setState({scrollPos:t},this._afterScroll.bind(this,t)),!0)}scrollOffset(t){return this.scroll(this.scrollPos+t)}_afterScroll(t){const{onScroll:n}=this.props;n&&n(t,this.props.type??"vert")}render(){const{clientSize:t,type:n,size:s=12,className:r,style:o,left:a,top:l,bottom:c,right:h}=this.props,{maxScrollPos:d,scrollPos:f}=this,{dragStart:p}=this.state,y={left:a,top:l,bottom:c,right:h,...o},b={};return n==="horz"?(y.height=s,y.width=t,b.width=this.barSize,b.left=Math.round(Math.min(d,f)*(t-b.width)/d)):(y.width=s,y.height=t,b.height=this.barSize,b.top=Math.round(Math.min(d,f)*(t-b.height)/d)),k("div",{className:U("scrollbar",r,{"is-vert":n==="vert","is-horz":n==="horz","is-dragging":p}),style:y,onMouseDown:this._handleClick,children:k("div",{className:"scrollbar-bar",style:b,onMouseDown:this._handleMouseDown})})}}Ns=new WeakMap,Es=new WeakMap;const zl=new Map,Fl=[];function nv(i,e){const{name:t}=i;if(!(e!=null&&e.override)&&zl.has(t))throw new Error(`DTable: Plugin with name ${t} already exists`);zl.set(t,i),e!=null&&e.buildIn&&!Fl.includes(t)&&Fl.push(t)}function et(i,e){nv(i,e);const t=n=>{if(!n)return i;const{defaultOptions:s,...r}=i;return{...r,defaultOptions:{...s,...n}}};return t.plugin=i,t}function sv(i){return zl.delete(i)}function iv(i){if(typeof i=="string"){const e=zl.get(i);return e||console.warn(`DTable: Cannot found plugin "${i}"`),e}if(typeof i=="function"&&"plugin"in i)return i.plugin;if(typeof i=="object")return i;console.warn("DTable: Invalid plugin",i)}function rv(i,e,t){return e.forEach(n=>{var r;if(!n)return;const s=iv(n);s&&(t.has(s.name)||((r=s.plugins)!=null&&r.length&&rv(i,s.plugins,t),i.push(s),t.add(s.name)))}),i}function Qk(i=[],e=!0){if(e&&Fl.length&&i.unshift(...Fl),!(i!=null&&i.length))return[];const t=rv([],i,new Set),n=[],s=t.reduce((r,o,a)=>{var l;return r.set(o.name,a*1e3),(l=o.requireAfter)!=null&&l.length&&n.push(o),r},new Map);return n.length&&(n.forEach(r=>{const o=r.requireAfter.reduce((a,l)=>(s.has(l)&&a.push(s.get(l)),a),[]);o.length&&s.set(r.name,Math.max(...o)+1)}),t.sort((r,o)=>s.get(r.name)-s.get(o.name))),t}function ov(){return{cols:[],data:[],rowKey:"id",width:"100%",height:"auto",rowHeight:35,defaultColWidth:80,minColWidth:24,maxColWidth:9999,header:!0,footer:void 0,headerHeight:0,footerHeight:0,rowHover:!0,colHover:!1,cellHover:!1,bordered:!1,striped:!0,responsive:!1,scrollbarHover:!0,horzScrollbarPos:"outside"}}function av(i,e,t){return i&&(e&&(i=Math.max(e,i)),t&&(i=Math.min(t,i))),i}function lv(i,e){return typeof i=="string"&&(i=i.endsWith("%")?parseFloat(i)/100:parseFloat(i)),typeof e=="number"&&(typeof i!="number"||isNaN(i))&&(i=e),i}function su(i,e=!1,t=0){if(!i.list.length)return;if(e&&i.widthSetting&&(i.widthSetting=Math.min(i.widthSetting,i.width)),t&&(!i.widthSetting||i.widthSetting>t)&&i.width>t&&(i.widthSetting=t),i.widthSetting&&i.width!==i.widthSetting){i.width=i.widthSetting;const s=i.width-i.totalWidth;if(!e&&s>0||e&&s!==0){const r=i.flexList.length?i.flexList:i.list,o=r.reduce((a,l)=>a+(l.flex||1),0);r.forEach(a=>{const l=Math[s<0?"max":"min"](s,Math.ceil(s*((a.flex||1)/o)));a.realWidth=a.width+l})}}let n=0;i.list.forEach((s,r)=>{s.realWidth||(s.realWidth=s.width),s.left=n,s.sideIndex=r,n+=s.realWidth})}function cv(i){return i?i==="left"?"left":"right":"center"}function eS(i,e,t,n){const{defaultColWidth:s,minColWidth:r,maxColWidth:o,fixedLeftWidth:a=0,fixedRightWidth:l=0}=e,c=N=>(typeof N=="function"&&(N=N.call(i)),N=lv(N,0),N<1&&(N=Math.round(N*n)),N),h={width:0,list:[],flexList:[],widthSetting:0,totalWidth:0},d={...h,list:[],flexList:[],widthSetting:c(a)},f={...h,list:[],flexList:[],widthSetting:c(l)},p={left:d,center:h,right:f},y=[],b={};let w=!1;const x=[],T={};if(t.forEach(N=>{const{colTypes:A,onAddCol:z}=N;A&&Object.entries(A).forEach(([O,K])=>{T[O]||(T[O]=[]),T[O].push(K)}),z&&x.push(z)}),e.cols.forEach((N,A)=>{if(N.hidden)return;const{type:z="",name:O}=N,K={fixed:!1,flex:!1,width:s,minWidth:r,maxWidth:o,...N,type:z},Z={name:O,type:z,setting:K,flex:0,left:0,width:0,realWidth:0,visible:!0,index:A,side:cv(K.fixed),sideIndex:0,order:K.order,border:K.border},ye=T[z];if(ye&&ye.forEach(je=>{const te=typeof je=="function"?je.call(i,K):je;te&&Object.assign(K,te,N)}),K.hidden)return;const{flex:Q,minWidth:ne=r,maxWidth:xe=o}=K,Me=lv(K.width||s,s);Z.flex=Q===!0?1:typeof Q=="number"?Q:0,Z.width=av(Me<1?Math.round(Me*n):Me,ne,xe),Z.side=cv(K.fixed),x.forEach(je=>je.call(i,Z)),y.push(Z),b[Z.name]=Z;const Re=p[Z.side];Re.list.push(Z),Re.totalWidth+=Z.width,Re.width=Re.totalWidth,Z.flex&&Re.flexList.push(Z),typeof Z.order=="number"&&(w=!0)}),w){const N=(A,z)=>(A.order??A.index)-(z.order??z.index);y.sort(N),d.list.sort(N),h.list.sort(N),f.list.sort(N)}su(f,!0);const D=n-f.width-Math.max(40,r);return su(d,!0,D),h.widthSetting=n-d.width-f.width,su(h),{list:y,map:b,...p}}function tS(i){var te;const{col:e,className:t,height:n,row:s,onRenderCell:r,style:o,outerStyle:a,children:l,outerClass:c,width:h,left:d,top:f,...p}=i,y={left:d??e.left,top:f??s.top,width:h??e.realWidth,height:n,...a},{align:b,cellStyle:w,cellClass:x,className:T}=e.setting,D={justifyContent:b?b==="left"?"start":b==="right"?"end":b:void 0,...w,...o},{name:N,border:A}=e,z=["dtable-cell",c,t,T,{"has-border-left":A===!0||A==="left","has-border-right":A===!0||A==="right"}],O=["dtable-cell-content",x],K=(te=s.data)==null?void 0:te[N],Z=[l??K??""],ye=r?r(Z,{row:s,col:e,value:K},i,g):Z,Q=[],ne=[],xe={},Me={};let Re="div";ye==null||ye.forEach(X=>{if(typeof X=="object"&&X&&!I.isValidElement(X)&&("html"in X||"className"in X||"style"in X||"attrs"in X||"children"in X||"tagName"in X)){const Ee=X.outer?Q:ne;X.html?Ee.push(k("div",{className:U("dtable-cell-html",X.className),style:X.style,dangerouslySetInnerHTML:{__html:X.html},...X.attrs??{}})):(X.style&&Object.assign(X.outer?y:D,X.style),X.className&&(X.outer?z:O).push(X.className),X.children&&Ee.push(X.children),X.attrs&&Object.assign(X.outer?xe:Me,X.attrs)),X.tagName&&!X.outer&&(Re=X.tagName)}else(typeof X!="object"||I.isValidElement(X))&&ne.push(X)});const je=Re;return k("div",{className:U(z),style:y,"data-col":N,"data-row":s.id,"data-type":e.type||null,...p,...xe,children:[ne.length>0&&k(je,{className:U(O),style:D,...Me,children:ne}),Q]})}function iu({rows:i=[],cols:e,rowHeight:t,scrollLeft:n=0,scrollTop:s=0,left:r=0,top:o=0,width:a,height:l="100%",className:c,CellComponent:h=tS,cellClass:d,onRenderCell:f}){var w;const p=Array.isArray(i)?i:[i],y=((w=p[0])==null?void 0:w.top)??0,b=p.length;return k("div",{className:U("dtable-cells",c),style:{top:o,left:r,width:a,height:l},children:k("div",{className:"dtable-cells-container",style:{left:-n,top:-s+y},children:p.reduce((x,T,D)=>{const N=e.length;return e.forEach((A,z)=>{x.push(k(h,{className:U(`is-${T.index%2?"odd":"even"}-row`,z?"":"is-first-in-row",z===N-1?"is-last-in-row":"",D?"":"is-first-row",D===b-1?"is-last-row":"",d),col:A,row:T,top:T.top-y,height:t,onRenderCell:f},`${T.index}:${A.name}`))}),x},[])})})}function hv({top:i,height:e,rowHeight:t,rows:n,cols:{left:s,center:r,right:o},scrollLeft:a,scrollTop:l,className:c,cellClass:h,style:d,onRenderCell:f,children:p}){let y=null;s.list.length&&(y=k(iu,{className:"dtable-fixed-left",rows:n,scrollTop:l,cols:s.list,width:s.width,rowHeight:t,cellClass:h,onRenderCell:f},"left"));let b=null;r.list.length&&(b=k(iu,{rows:n,className:"dtable-scroll-center",scrollLeft:a,scrollTop:l,cols:r.list,left:s.width,width:r.width,rowHeight:t,cellClass:h,onRenderCell:f},"center"));let w=null;return o.list.length&&(w=k(iu,{className:"dtable-fixed-right",rows:n,scrollTop:l,cols:o.list,left:s.width+r.width,width:o.width,rowHeight:t,cellClass:h,onRenderCell:f},"right")),k("div",{className:U("dtable-block",c),style:{...d,top:i,height:e},children:[y,b,w,p]})}var dv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ft=(i,e,t)=>(dv(i,e,"read from private field"),t?t.call(i):e.get(i)),wt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Yt=(i,e,t)=>(dv(i,e,"access private method"),t),$s,io,ro,ru,uv,ou,fv,au,pv,lu,mv,Ol,cu,Bl,jl,hu,du,uu,fu,oo,Hl,Ul,pu,mu,gv,gu,yv;let ii=class extends re{constructor(e){super(e),wt(this,ru),wt(this,ou),wt(this,au),wt(this,lu),wt(this,Ol),wt(this,oo),wt(this,Ul),wt(this,mu),wt(this,gu),this.ref=pe(),this._rafId=0,this._needRender=!1,this._plugins=[],this._lastUsedPlugins=new Map,this._events=new Map,this._data={},this._i18nMaps=[],this._hover={in:!1},this._firstRender=!0,this.updateLayout=()=>{this._rafId&&cancelAnimationFrame(this._rafId),this._rafId=requestAnimationFrame(()=>{const{element:t}=this;t&&!En(t)&&this.update({dirtyType:"layout"}),this._rafId=0})},wt(this,$s,(t,n)=>{n=n||t.type;const s=this._events.get(n);if(s!=null&&s.length){for(const r of s)if(r.call(this,t)===!1){t.stopPropagation(),t.preventDefault();break}}}),wt(this,io,t=>{ft(this,$s).call(this,t,`window_${t.type}`)}),wt(this,ro,t=>{ft(this,$s).call(this,t,`document_${t.type}`)}),wt(this,Bl,(t,n,s,r)=>{const{row:o,col:a}=n;n.value=this.getCellValue(o,a),t[0]=n.value;const l=o.id==="HEADER"?"onRenderHeaderCell":"onRenderCell",c=(h,d)=>{try{t=h.call(this,t,n,s,r)}catch(f){console.error(`[ZUI] DTable render cell(${o.id}:${a.name}) by ${d} error:`,f)}};return a.setting[l]&&c(a.setting[l],"col"),this._plugins.forEach(h=>{h[l]&&c(h[l],`plugin (${h.name})`)}),this.options[l]&&c(this.options[l],"options"),t}),wt(this,jl,(t,n)=>{n==="horz"?this.scroll({scrollLeft:t}):this.scroll({scrollTop:t})}),wt(this,hu,t=>{var a,l,c;const n=this.getPointerInfo(t);if(!n)return;const{rowID:s,colName:r,cellElement:o}=n;if(s==="HEADER")o&&((a=this.options.onHeaderCellClick)==null||a.call(this,t,{colName:r,element:o}),this._plugins.forEach(h=>{var d;(d=h.onHeaderCellClick)==null||d.call(this,t,{colName:r,element:o})}));else{const h=this.layout.visibleRows.find(d=>d.id===s);if(o){if(((l=this.options.onCellClick)==null?void 0:l.call(this,t,{colName:r,rowID:s,rowInfo:h,element:o}))===!0)return;for(const d of this._plugins)if(((c=d.onCellClick)==null?void 0:c.call(this,t,{colName:r,rowID:s,rowInfo:h,element:o}))===!0)return}}}),wt(this,du,t=>{const n=t.key.toLowerCase();if(["pageup","pagedown","home","end"].includes(n))return!this.scroll({to:n.replace("page","")})}),wt(this,uu,t=>{const n=v(t.target).closest(".dtable-cell");if(!n.length)return Yt(this,oo,Hl).call(this,!1);Yt(this,oo,Hl).call(this,[n.attr("data-row"),n.attr("data-col")])}),wt(this,fu,()=>{Yt(this,oo,Hl).call(this,!1)}),this._id=e.id??`dtable-${Xe()}`,this.state={scrollTop:0,scrollLeft:0,renderCount:0},this._allPlugins=Object.freeze(Qk(e.plugins)),this._allPlugins.forEach(t=>{const{methods:n,data:s,state:r}=t;n&&Object.entries(n).forEach(([o,a])=>{typeof a=="function"&&Object.assign(this,{[o]:a.bind(this)})}),s&&Object.assign(this._data,s.call(this)),r&&Object.assign(this.state,r.call(this))}),Yt(this,Ul,pu).call(this),this._plugins.forEach(t=>{var n;(n=t.onCreate)==null||n.call(this,t)})}get options(){var e;return((e=this._layout)==null?void 0:e.options)||this._options||ov()}get plugins(){return this._plugins}get layout(){return this._layout}get id(){return this._id}get data(){return this._data}get element(){return this.ref.current}get parent(){var e;return this.props.parent??((e=this.element)==null?void 0:e.parentElement)}get hoverInfo(){return this._hover}componentWillReceiveProps(){this._options=void 0}shouldComponentUpdate(){return!0}componentDidMount(){this._needRender?this.forceUpdate():Yt(this,Ol,cu).call(this),this.on("click",ft(this,hu)),this.on("keydown",ft(this,du));const{options:e}=this;(e.rowHover||e.colHover)&&(this.on("mouseover",ft(this,uu)),this.on("mouseleave",ft(this,fu)));let{responsive:t}=e;if(t){t===!0&&(t="window,parent");const n=t.split(",");if(typeof ResizeObserver<"u"){const s=[],r=new ResizeObserver(this.updateLayout);this._rob=r;const{parent:o}=this;n.forEach(a=>{a!=="window"&&(a==="parent"?o&&r.observe(o):a[0]==="~"?s.push(a.slice(1)):v(a).each((l,c)=>r.observe(c)))}),s.length&&this.on(s.join(" "),this.updateLayout)}n.includes("window")&&this.on("window_resize",this.updateLayout)}this._checkPluginsState()}componentDidUpdate(){Yt(this,Ol,cu).call(this),this._checkPluginsState(),this._plugins.forEach(e=>{var t;(t=e.onUpdated)==null||t.call(this)})}componentWillUnmount(){var t;(t=this._rob)==null||t.disconnect();const{element:e}=this;if(e)for(const n of this._events.keys())n.startsWith("window_")?window.removeEventListener(n.replace("window_",""),ft(this,io)):n.startsWith("document_")?document.removeEventListener(n.replace("document_",""),ft(this,ro)):e.removeEventListener(n,ft(this,$s));this._plugins.forEach(n=>{var s;(s=n.onUnmounted)==null||s.call(this)}),this._allPlugins.forEach(n=>{var s;(s=n.onDestory)==null||s.call(this)}),this._data={},this._events.clear(),this._noAnimation&&clearTimeout(this._noAnimation),this._rafId&&cancelAnimationFrame(this._rafId)}resetState(e,t){this._options=void 0,this._layout=void 0,e=e||this.props;const n={};this._plugins.forEach(s=>{const{resetState:r,state:o}=s;r&&(typeof r=="function"?Object.assign(n,r.call(this,e)):o&&Object.assign(n,o.call(this)))}),Object.keys(n).length&&this.setState(n)}on(e,t,n){var r;n&&(e=`${n}_${e}`);const s=this._events.get(e);s?s.push(t):(this._events.set(e,[t]),e.startsWith("window_")?window.addEventListener(e.replace("window_",""),ft(this,io)):e.startsWith("document_")?document.addEventListener(e.replace("document_",""),ft(this,ro)):(r=this.element)==null||r.addEventListener(e,ft(this,$s)))}off(e,t,n){var o;n&&(e=`${n}_${e}`);const s=this._events.get(e);if(!s)return;const r=s.indexOf(t);r>=0&&s.splice(r,1),s.length||(this._events.delete(e),e.startsWith("window_")?window.removeEventListener(e.replace("window_",""),ft(this,io)):e.startsWith("document_")?document.removeEventListener(e.replace("document_",""),ft(this,ro)):(o=this.element)==null||o.removeEventListener(e,ft(this,$s)))}emitCustomEvent(e,t){ft(this,$s).call(this,t instanceof Event?t:new CustomEvent(e,{detail:t}),e)}disableAnimation(e=200){var t;this._noAnimation&&clearTimeout(this._noAnimation),(t=this.element)==null||t.classList.add("no-animation"),this._noAnimation=window.setTimeout(()=>{var n;this._noAnimation=void 0,(n=this.element)==null||n.classList.remove("no-animation")},e)}scroll(e,t){const{scrollLeft:n,scrollTop:s,rowsHeightTotal:r,rowsHeight:o,rowHeight:a,cols:{center:{totalWidth:l,width:c}}}=this.layout,{to:h}=e;let{scrollLeft:d,scrollTop:f}=e;if(h==="up"||h==="down")f=s+(h==="down"?1:-1)*Math.floor(o/a)*a;else if(h==="left"||h==="right")d=n+(h==="right"?1:-1)*c;else if(h==="top")f=0;else if(h==="bottom")f=r-o;else if(h==="begin")d=0;else if(h==="end")d=l-c;else{const{offsetLeft:y,offsetTop:b}=e;typeof y=="number"&&(d=n+y),typeof b=="number"&&(f=s+b)}const p={};return typeof d=="number"&&(d=Math.max(0,Math.min(d,l-c)),d!==n&&(p.scrollLeft=d)),typeof f=="number"&&(f=Math.max(0,Math.min(f,r-o)),f!==s&&(p.scrollTop=f)),Object.keys(p).length?(this.setState(p,()=>{var y;(y=this.options.onScroll)==null||y.call(this,p),t==null||t.call(this,!0)}),!0):(t==null||t.call(this,!1),!1)}getColInfo(e){if(e===void 0)return;if(typeof e=="object")return e;const{cols:t}=this.layout;return typeof e=="number"?t.list[e]:t.map[e]}getRowInfo(e){if(e===void 0)return;if(typeof e=="object")return e;if(e===-1||e==="HEADER")return{id:"HEADER",index:-1,top:0};const{rows:t,rowsMap:n,allRows:s}=this.layout;return typeof e=="number"?t[e]:n[e]||s.find(r=>r.id===e)}getCellValue(e,t){var a;const n=typeof e=="object"?e:this.getRowInfo(e);if(!n)return;const s=typeof t=="object"?t:this.getColInfo(t);if(!s)return;let r=n.id==="HEADER"?s.setting.title:(a=n.data)==null?void 0:a[s.name];const{cellValueGetter:o}=this.options;return o&&(r=o.call(this,n,s,r)),r}getRowInfoByIndex(e){return this.layout.rows[e]}update(e={},t){if(!this._options)return;typeof e=="function"&&(t=e,e={});const{dirtyType:n,state:s}=e;if(n==="layout")this._layout=void 0;else if(n==="options"){if(this._options=void 0,!this._layout)return;this._layout=void 0}this.setState(s||(r=>({renderCount:r.renderCount+1})),t)}getPointerInfo(e){const t=e.target;if(!t||t.closest(".no-cell-event"))return;const n=v(t).closest(".dtable-cell");if(!n.length)return;const s=n.attr("data-row"),r=n.attr("data-col");if(!(typeof r!="string"||typeof s!="string"))return{cellElement:n[0],colName:r,rowID:s,target:t}}componentDidCatch(e,t){console.error(`[ZUI] DTable ${this.id} Error:`,e,t)}i18n(e,t,n){return be(this._i18nMaps,e,t,n,this.options.lang)??`{i18n:${e}}`}getPlugin(e){return this.plugins.find(t=>t.name===e)}_checkPluginsState(){const e=new Set(this._lastUsedPlugins.keys());this._plugins.forEach(t=>{var s;if(e.has(t.name)){e.delete(t.name);return}let{events:n}=t;n&&(typeof n=="function"&&(n=n.call(this)),Object.entries(n).forEach(([r,o])=>{o&&this.on(r,o)})),(s=t.onMounted)==null||s.call(this),this._lastUsedPlugins.set(t.name,t)}),e.size&&e.forEach(t=>{var s;const n=this._lastUsedPlugins.get(t);(s=n==null?void 0:n.onUnmounted)==null||s.call(this),this._lastUsedPlugins.delete(t)})}render(){let e=Yt(this,gu,yv).call(this);const{className:t,rowHover:n,colHover:s,cellHover:r,bordered:o,striped:a,scrollbarHover:l,beforeRender:c,emptyTip:h,style:d}=this.options,f={...d},p=["dtable",t,{"dtable-hover-row":n,"dtable-hover-col":s,"dtable-hover-cell":r,"dtable-bordered":o,"dtable-striped":a,"scrollbar-hover":l,"no-animation":this._noAnimation}],y=[];if(e){const b=!e.rows.length;if(c){const w=c.call(this,e);w&&(e=w)}this._plugins.forEach(w=>{var T;const x=(T=w.beforeRender)==null?void 0:T.call(this,e);x&&(e=x)}),f.width=e.width,f.height=e.height,f["--dtable-row-height"]=`${e.rowHeight}px`,f["--dtable-header-height"]=`${e.headerHeight}px`,p.push(e.className,b?"dtable-is-empty":"",{"dtable-has-scroll-y":e.rowsHeightTotal>e.rowsHeight,"dtable-scrolled-down":e.scrollTop>0,"dtable-scrolled-bottom":e.scrollTop>=e.rowsHeightTotal-e.rowsHeight,"dtable-scrolled-right":e.scrollLeft>0,"dtable-scrolled-end":e.scrollLeft>=e.cols.center.totalWidth-e.cols.center.width}),e.children&&y.push(...e.children),b&&h?(delete f.height,y.push(k("div",{className:"dtable-empty-tip",children:k(de,{content:h,generatorThis:this,generatorArgs:[e]})},"empty-tip"))):(y.push(Yt(this,ru,uv).call(this,e),Yt(this,ou,fv).call(this,e),Yt(this,au,pv).call(this,e)),e.scrollable&&y.push(Yt(this,lu,mv).call(this,e))),this._plugins.forEach(w=>{var T;const x=(T=w.onRender)==null?void 0:T.call(this,e);x&&(x.style&&Object.assign(f,x.style),x.className&&p.push(x.className),x.children&&y.push(x.children))})}return k("div",{id:this._id,className:U(p),style:f,ref:this.ref,tabIndex:-1,children:y})}};$s=new WeakMap,io=new WeakMap,ro=new WeakMap,ru=new WeakSet,uv=function(i){const{header:e,cols:t,headerHeight:n,scrollLeft:s,headerChildren:r}=i;if(!e)return null;if(e===!0)return k(hv,{className:"dtable-header",cols:t,height:n,scrollLeft:s,rowHeight:n,scrollTop:0,cellClass:"dtable-header-cell",rows:{id:"HEADER",index:-1,top:0},top:0,onRenderCell:ft(this,Bl),children:r},"header");const o=Array.isArray(e)?e:[e];return k(Lh,{className:"dtable-header",style:{height:n},renders:o,generateArgs:[i],generatorThis:this,children:r},"header")},ou=new WeakSet,fv=function(i){const{headerHeight:e,rowsHeight:t,visibleRows:n,rowHeight:s,cols:r,scrollLeft:o,scrollTop:a,bodyChildren:l}=i;return k(hv,{className:"dtable-body",top:e,height:t,rows:n,rowHeight:s,scrollLeft:o,scrollTop:a,cols:r,onRenderCell:ft(this,Bl),children:l},"body")},au=new WeakSet,pv=function(i){let{footer:e}=i;if(typeof e=="function"&&(e=e.call(this,i)),!e)return null;const t=Array.isArray(e)?e:[e];return k(Lh,{className:"dtable-footer",style:{height:i.footerHeight,top:i.rowsHeight+i.headerHeight},renders:t,generateArgs:[i],generatorThis:this,generators:i.footerGenerators,children:i.footerChildren},"footer")},lu=new WeakSet,mv=function(i){const e=[],{scrollLeft:t,cols:{left:{width:n},center:{width:s,totalWidth:r}},scrollTop:o,rowsHeight:a,rowsHeightTotal:l,footerHeight:c,headerHeight:h}=i,{scrollbarSize:d=12,horzScrollbarPos:f,vertScrollbarPos:p}=this.options;return r>s&&e.push(k(tv,{type:"horz",scrollPos:t,scrollSize:r,clientSize:s,onScroll:ft(this,jl),left:n,bottom:(f==="inside"?0:-d)+c,size:d,wheelContainer:this.ref},"horz"),k("div",{className:"dtable-scroll-shadow is-left",style:{left:n,height:h+a}}),k("div",{className:"dtable-scroll-shadow is-right",style:{left:n+s,height:h+a}})),l>a&&e.push(k(tv,{type:"vert",scrollPos:o,scrollSize:l,clientSize:a,onScroll:ft(this,jl),right:p==="outside"?-d:0,size:d,top:h,wheelContainer:this.ref},"vert")),e.length?e:null},Ol=new WeakSet,cu=function(){var i;this._needRender=!1,this._plugins.forEach(e=>{var t;return(t=e.afterRender)==null?void 0:t.call(this,this._firstRender)}),(i=this.options.afterRender)==null||i.call(this,this._firstRender),this._firstRender=!1},Bl=new WeakMap,jl=new WeakMap,hu=new WeakMap,du=new WeakMap,uu=new WeakMap,fu=new WeakMap,oo=new WeakSet,Hl=function(i){const{element:e,options:t}=this;if(!e)return;const n=v(e),s=i?{in:!0,row:i[0],col:i[1]}:{in:!1};t.colHover==="header"&&s.row!=="HEADER"&&(s.col=void 0);const r=this._hover;s.in!==r.in&&n.toggleClass("dtable-hover",s.in),s.row!==r.row&&(n.find(".is-hover-row").removeClass("is-hover-row"),s.row&&n.find(`.dtable-cell[data-row="${s.row}"]`).addClass("is-hover-row")),s.col!==r.col&&(n.find(".is-hover-col").removeClass("is-hover-col"),s.col&&n.find(`.dtable-cell[data-col="${s.col}"]`).addClass("is-hover-col")),this._hover=s},Ul=new WeakSet,pu=function(){if(this._options)return!1;const e={...ov(),...this._allPlugins.reduce((t,n)=>{const{defaultOptions:s}=n;return s&&Object.assign(t,s),t},{}),...this.props};return this._options=e,this._plugins=this._allPlugins.reduce((t,n)=>{const{options:s}=n;let r=e;return s&&(r=Object.assign({...r},typeof s=="function"?s.call(this,e):s)),r!==e&&Object.assign(e,r),t.push(n),t},[]).filter(t=>{const{when:n}=t;return!n||n.call(this,e)}),this._i18nMaps=[this.options.i18n,...this.plugins.map(t=>t.i18n)].filter(Boolean),!0},mu=new WeakSet,gv=function(){var Z,ye;const{plugins:i}=this;let e=this._options;const t={flex:k("div",{style:"flex:auto"}),divider:k("div",{style:"width:1px;margin:var(--space);background:var(--color-border);height:50%"})};i.forEach(Q=>{var xe;const ne=(xe=Q.beforeLayout)==null?void 0:xe.call(this,e);ne&&(e={...e,...ne}),Object.assign(t,Q.footer)});let n=e.width,s=0;if(typeof n=="function"&&(n=n.call(this)),n==="100%"){const{parent:Q}=this;if(Q)s=Q.clientWidth;else{this._needRender=!0;return}}const r=eS(this,e,i,s),{data:o,rowKey:a="id",rowHeight:l=35,rowConverter:c}=e,h=[],d=(Q,ne,xe)=>{var je,te;const Me=xe??{[a]:Q},Re={data:c?c.call(this,Me,ne):Me,id:Q,index:h.length,top:0};if(xe||(Re.lazy=!0),h.push(Re),((je=e.onAddRow)==null?void 0:je.call(this,Re,ne))!==!1){for(const X of i)if(((te=X.onAddRow)==null?void 0:te.call(this,Re,ne))===!1)return}};if(typeof o=="number")for(let Q=0;Q<o;Q++)d(`${Q}`,Q);else Array.isArray(o)&&o.forEach((Q,ne)=>{typeof Q=="object"?d(`${Q[a]??""}`,ne,Q):d(`${Q??""}`,ne)});let f=h;const p={};if(e.onAddRows){const Q=e.onAddRows.call(this,f,r);Q&&(f=Q)}for(const Q of i){const ne=(Z=Q.onAddRows)==null?void 0:Z.call(this,f,r);ne&&(f=ne)}f.forEach((Q,ne)=>{p[Q.id]=Q,Q.index=ne,Q.top=Q.index*l});const{header:y,footer:b}=e,w=y?e.headerHeight||l:0,x=b?e.footerHeight||l:0;let T=e.height,D=0;const N=f.length*l,A=w+x+N;if(typeof T=="function"&&(T=T.call(this,A)),T==="auto")D=A;else if(typeof T=="object")D=Math.min(T.max,Math.max(T.min,A));else if(T==="100%"){const{parent:Q}=this;if(Q)D=Q.clientHeight;else{D=0,this._needRender=!0;return}}else D=T;const z=D-w-x,O={options:e,allRows:h,width:s,height:D,rows:f,rowsMap:p,rowHeight:l,rowsHeight:z,rowsHeightTotal:N,header:y,footer:b,footerGenerators:t,headerHeight:w,footerHeight:x,cols:r},K=(ye=e.onLayout)==null?void 0:ye.call(this,O);K&&Object.assign(O,K),i.forEach(Q=>{if(Q.onLayout){const ne=Q.onLayout.call(this,O);ne&&Object.assign(O,ne)}}),this._layout=O},gu=new WeakSet,yv=function(){(Yt(this,Ul,pu).call(this)||!this._layout)&&Yt(this,mu,gv).call(this);const{layout:i}=this;if(!i)return;const{cols:{center:e}}=i;let{scrollLeft:t}=this.state;t=Math.min(Math.max(0,e.totalWidth-e.width),t);let n=0;e.list.forEach(b=>{b.left=n,n+=b.realWidth,b.visible=b.left+b.realWidth>=t&&b.left<=t+e.width});const{rowsHeightTotal:s,rowsHeight:r,rows:o,rowHeight:a}=i,{rowDataGetter:l,partialRender:c=!0}=this.options,h=Math.min(Math.max(0,s-r),this.state.scrollTop),d=c?Math.floor(h/a):0,f=h+r,p=c?Math.min(o.length,Math.ceil(f/a)):o.length,y=[];for(let b=d;b<p;b++){const w=o[b];w.lazy&&l&&(w.data=l([w.id])[0],w.lazy=!1),y.push(w)}return Object.assign(i,{visibleRows:y,scrollTop:h,scrollLeft:t,headerChildren:[],bodyChildren:[],footerChildren:[],children:[],className:"",scrollable:!0}),i},ii.addPlugin=nv,ii.removePlugin=sv;class nS extends re{constructor(){super(...arguments),this._dtablePlugins=["sort","zentao","resize","pager"],this._dtable=pe(),this._createActionItem=(e,t)=>{var s,r,o,a;const n=t.row.data;return e.command=e.command.replace("{id}",String(n.id)),e.key==="edit"&&(n.contentType==="url"&&(e.command=`showDocSettingModal/${n.id}/${n.contentType}/1`),((s=n.privs)==null?void 0:s.edit)===!1&&(e.disabled=!0)),e.key==="move"&&((o=(r=this.props).canMoveDoc)==null?void 0:o.call(r,n))===!1&&(e.disabled=!0),e.key==="delete"&&((a=n.privs)==null?void 0:a.delete)===!1&&(e.disabled=!0),e},this._getToolbar=e=>{const{getActions:t}=this.props,n=t==null?void 0:t("doc-table",{ui:"table-foot-toolbar",dtable:e});if(n)return{btnProps:{size:"sm",btnType:"secondary"},items:n}}}_getCols(){const e={edit:{hint:"编辑",icon:"edit",command:"startEditDoc/{id}",key:"edit"},move:{hint:"移动",icon:"folder-move",command:"moveDoc/{id}",key:"move"},delete:{hint:"删除",icon:"trash",command:"deleteDoc/{id}",key:"trash"}},{actionsMap:t=e,actionItemCreator:n}=this.props,s=n||this._createActionItem,{searchKeys:r=[],app:o}=this.props;return[{name:"rawID",title:"ID",type:"checkID",sort:"number"},{name:"title",title:"标题",type:"title",onRenderCell:(c,h)=>{const d=h.row.data,f=d.title;return c[0]=g("div",{className:"row items-center gap-1 cursor-pointer flex-auto min-w-0","zui-command":`selectDoc/${d.id}`},g($e,{icon:d.icon??o.getDocIcon(d),className:d.icon?"":"text-special"})," ",g("a",{title:f,className:"doc-list-item-title text-primary"},r.length?dt.underlineKeys(r,[f]):f)),d.status==="draft"&&c.push(g("div",{className:"label special-pale size-sm rounded-full ml-1 flex-none"},o.getLang("draft","草稿"))),c},sort:!0},{name:"collects",title:"收藏数",onRenderCell:(c,h)=>{const d=h.row.data;return d.api?[]:[g(we,{type:"ghost",size:"sm",text:d.collects||0,icon:d.isCollector?"star text-warning":"star-empty text-gray","zui-command":`collectDoc/${h.row.id}`})]},sort:"number",cellClass:"px-2",fixed:"left"},{name:"views",title:"浏览数",sort:"number",align:"center"},{name:"addedBy",title:"创建者",type:"user",sort:!0},{name:"addedDate",title:"创建日期",type:"date",sort:!0},{name:"editedBy",title:"修改者",type:"user",sort:!0},{name:"editedDate",title:"修改日期",type:"date",sort:!0},{name:"actions",title:"操作",type:"actions",width:96,minWidth:96,actionsMap:t,actions:["edit","move","delete"],actionItemCreator:s}]}_getTableOptions(e){const{docs:t,userMap:n,getTableOptions:s,app:r}=e,o=[...t].sort((l,c)=>l.nestedOrder-c.nestedOrder).map(l=>l.data),a={width:"100%",height(l){var h;const c=(h=this.element)==null?void 0:h.parentElement;return c?Math.min(l,c.clientHeight):l},cols:this._getCols(),checkable:!0,sort:!0,plugins:this._dtablePlugins,data:o,userMap:n,colResize:!0,footToolbar:this._getToolbar,footer:["checkbox","toolbar","checkedInfo","flex","pager"],localPager:!0,loadPartial:!0,canRowCheckable:l=>+String(l)==+l?!0:"disabled",emptyTip:g("div",{className:"center gap-4"},g("div",{className:"text-gray"},r.getLang("noDocs","没有文档")),Fe.render({items:r.getActions("doc-list",{ui:"doc-list-empty"})},[])),footPager:{items:r.getPagerItems()}};return(s==null?void 0:s(a,{type:"doc-list"}))??a}render(e){return g("div",{class:U("doc-list h-full col",e.className)},g(ii,{ref:this._dtable,...this._getTableOptions(e)}))}}const yu=class gr extends re{constructor(){super(...arguments),this._files=fe(),this._loadID="",this._timer=0,this._handleChangePager=e=>{this.props.app.resetPager("files",{...e})}}_filterFiles(e){if(!(e!=null&&e.length))return e;const{currentUser:t,onGetUser:n,searchKeys:s=[],filterType:r}=this.props,o=r&&r!=="all";if(!o&&!s.length)return e;const a=["title","extension","objectType","sourceName",l=>`.${l.extension}`,n?l=>n(l.addedBy).realname:null].filter(Boolean);return e.filter(l=>!(o&&!gr.isFileMatchFilter(l,r,t)||s.length&&!dt.isItemMatch(l,s,a)))}_getCols(){const{searchKeys:e=[],fileUrl:t,app:n}=this.props,s=l=>typeof t=="function"?t.call(this,l):t?De(t,l):void 0;return[{name:"id",title:"ID",type:"id",sort:"number"},{name:"title",title:"附件名称",type:"title",width:300,onRenderCell:(l,c)=>{var y;const h=c.row.data,d=gr.getFilterTypeFromExt(h.extension),f=d?(y=gr.filterTypeConfig[d])==null?void 0:y.iconClass:void 0,p=h.title;return l[0]=g("a",{title:p,href:s(h),target:"_blank",className:"doc-list-item-title text-primary"},e.length?dt.underlineKeys(e,[p]):p),l.unshift(g($e,{icon:si.getFileIcon(h,si.getDefaultIconMap())||"file",className:f})),l},sort:!0},{name:"objectName",title:"来源",type:"text",sort:!0,width:400,flex:1,cellClass:"px-2",onRenderCell:(l,c)=>{const h=c.row.data,{objectType:d,objectID:f,sourceName:p}=h;if(!d||!f)return l;const y=ut(d,"view",`${d}ID=${f}`),b=`#${f} ${p}`,w=d==="doc";return l.push(g("a",{"data-toggle":w?void 0:"modal","data-size":w?void 0:"lg",href:y,title:`${h.objectName??""}${b}`},b)),l}},{name:"extension",title:"类型",sort:!0,align:"center"},{name:"size",title:"大小",format:pt,sort:"number"},{name:"addedBy",title:"由谁添加",type:"user",sort:!0},{name:"addedDate",title:"创建日期",type:"date",sort:!0},{name:"actions",title:"操作",fixed:"right",width:64,minWidth:64,onRenderCell:(l,c)=>{const h=c.row.data;return l[0]=g(we,{type:"ghost",className:"text-primary",size:"sm",icon:"download",hint:n.getLang("downloadFile","下载文件"),target:"_blank",url:s(h)}),l}}]}async loadFiles(){const{filesFetcher:e,objectID:t,objectType:n}=this.props;this._files.value=void 0,this._loadID=[n,t].join();const s=await Ne(e,[{objectID:+t,objectType:n}]);[this.props.objectType,this.props.objectID].join()===this._loadID&&(this._files.value=s||[])}tryLoadFiles(){this._loadID!==[this.props.objectType,this.props.objectID].join()&&(this._timer&&clearTimeout(this._timer),this._timer=window.setTimeout(()=>{this._timer=0,this._loadID!==[this.props.objectType,this.props.objectID].join()&&this.loadFiles()},100))}componentDidMount(){this.tryLoadFiles()}componentDidUpdate(){this.tryLoadFiles()}componentWillUnmount(){this._timer&&clearTimeout(this._timer)}_getTableOptions(e,t){const{app:n}=e,s={width:"100%",height(r){var a;const o=(a=this.element)==null?void 0:a.parentElement;return o?Math.min(r,o.clientHeight):r},cols:this._getCols(),checkable:!1,className:"h-full",sort:!0,sortBy:{name:"id",order:"asc"},plugins:["sort","zentao","resize","pager"],data:t||[],userMap:e.userMap,colResize:!0,localPager:!0,loadPartial:!0,emptyTip:t?g("div",{className:"center gap-4 text-gray"},n.getLang("noFiles","没有文件")):null,footPager:{items:n.getPagerItems(),onChangePageInfo:this._handleChangePager}};return n.getTableOptions(s,{type:"file-list"})??s}render(e){const t=this._filterFiles(this._files.value),n=this._getTableOptions(e,t);return g("div",{className:`doc-lib-files h-full col load-indicator${t?"":" loading"}`,"data-loading":e.app.getLang("loadingFilesTip","正在加载文件...")},g(ii,{...n}))}static getFilterTypeFromExt(e){const[t]=Object.entries(gr.filterExtensions).find(([,n])=>n.has(e))||[];return t}static isFileMatchFilter(e,t,n){if(t==="addedByMe")return e.addedBy===n;if(t==="bug"||t==="story"||t==="task")return e.objectType===t;const{filterExtensions:s}=gr,{extension:r}=e;if(t==="other")return Object.values(s).every(a=>!a.has(r));const o=s[t];return o==null?void 0:o.has(r)}};yu.filterTypeConfig={all:{text:"全部",icon:"file-alt",iconClass:"text-gray"},story:{text:"需求",icon:"lightbulb",iconClass:"text-primary"},bug:{text:"Bug",icon:"bug",iconClass:"text-danger"},task:{text:"任务",icon:"checkbox",iconClass:"text-secondary"},office:{text:"Office",icon:"file-word",iconClass:"text-primary"},doc:{text:"文档",icon:"file-text",iconClass:"text-secondary"},image:{text:"图片",icon:"file-image",iconClass:"text-warning"},av:{text:"音视频",icon:"file-video",iconClass:"text-danger"},archive:{text:"压缩包",icon:"file-archive",iconClass:"text-important"},code:{text:"代码",icon:"file-code",iconClass:"text-success"},other:{text:"其他",icon:"file",iconClass:"text-gray"},addedByMe:{text:"由我添加",icon:"person",iconClass:"text-primary"}},yu.filterExtensions={av:new Set(["mp3","wav","flac","ogg","m4a","wma","aac","aiff","alac","mp4","avi","mkv","mov","flv","wmv","webm"]),image:new Set(["png","jpg","jpeg","gif","bmp","webp","tiff","ico","svg"]),code:new Set(["js","ts","jsx","tsx","html","css","scss","less","json","xml","yml","yaml","toml","ini","markdown","log"]),doc:new Set(["pdf","txt","md"]),office:new Set(["doc","docx","xls","xlsx","ppt","pptx"]),archive:new Set(["zip","rar","7z","tar","gz","bz2","xz","exe","dmg"])};let vu=yu;class sS extends re{constructor(){super(...arguments),this.state={},this._menu=pe(),this._ref=pe(),this._isExpandAll=fe(!1),this._getTreeItem=e=>{var b;const t=e.data,n=t.id;if(e.type==="doc")return{className:"item tree-item",type:"item",key:e.key,icon:t.icon??this.props.app.getDocIcon(t),selected:n===this.props.docID,text:t.title,hint:t.title,items:(b=e.docs)!=null&&b.length?[...e.docs]:void 0,innerClass:"group",innerComponent:"div",actions:this.props.app.getItemActions("doc",t,"sidebar"),_data:e};const{moduleIcon:s,moduleID:r,lib:o,docID:a,app:l}=this.props,c=l.props.libColors,{modules:h=[],docs:d=[]}=e,f=e.type==="lib";let p=t.icon;if(p===void 0)if(f){const w=t.type==="api"?this.props.apiLibIcon:this.props.libIcon;p=typeof w=="string"&&c?{icon:w,style:{color:c[n%c.length]}}:w}else p=s;const y={className:"item tree-item",type:"item",key:e.key,text:t.name,icon:p,items:f?void 0:[...h,...d],iconClass:f?"gray-pale w-5 h-5 center rounded-lg":"",selected:!1,innerClass:"group",innerComponent:"div",actions:this.props.app.getItemActions(e.type,t,"sidebar"),hint:t.name,_data:e};if(!a){const w=o==null?void 0:o.data.id;f&&!r?y.selected=n===w:!f&&r&&(y.selected=n===r)}return y},this._toggleSearchBox=()=>{this.setState({search:!this.state.search})},this._handleToggleTree=()=>{var e;this._isExpandAll.value=!!((e=this._menu.current)!=null&&e.isAllExpanded())},this.toggleTree=()=>{var e;(e=this._menu.current)==null||e.toggleAll(!this._isExpandAll.value),this._isExpandAll.value=!this._isExpandAll.value},this._handleClickItem=e=>{var n,s,r,o,a,l,c,h;if(e.event.target.closest(".item-icon,.nested-toggle-icon"))return;const t=e.renderedItem._data;t&&(t.type==="doc"?(s=(n=this.props).onSelectDoc)==null||s.call(n,t.data):t.type==="lib"?(o=(r=this.props).onSelectLib)==null||o.call(r,t.data.id):t.type==="files"?(l=(a=this.props).onShowFiles)==null||l.call(a):(h=(c=this.props).onSelectLib)==null||h.call(c,t.data.lib,t.data.id))},this._handleClickFileFilter=e=>{this.props.app.setFilterType(e.item.key,"files")}}_renderFooterToolbar(e){var n,s;const t=((s=(n=this.props).getActions)==null?void 0:s.call(n,e,"current","sidebar-toolbar"))||[];return t.unshift({icon:this._isExpandAll.value?"list-collapse":"list-expand",onClick:this.toggleTree}),Fe.render({items:t},[],{type:"ghost",size:"sm"})}_renderFooterHint(e){const t=this.props.app.renderCustom("sidebar-footer-hint",e);if(t!==void 0&&typeof t!="string")return t;let n="";if(typeof t=="string")n=t;else{const{space:s,spaceType:r,lib:o,showFiles:a,app:l}=this.props;if(s){const c=l.getLang("colon",": ");n=`${l.getLang(["spaceTypeNames",r],[],{custom:"空间",mine:"空间",product:"产品",project:"项目"}[r]||r)}${c}${s.name}`,o?n+=` ${l.getLang("libNamePrefix","库")}${c}${o.data.name}`:a&&(n+=` ${l.getLang("libNamePrefix","库")}${c}${l.getLang("filesLib","附件库")}`)}}return g("div",{className:"flex-auto text-gray text-clip overflow-hidden whitespace-nowrap",title:n},n)}_renderFooter(e){const t=this.props.app.renderCustom("sidebar-footer",e);return t!==void 0?t:g("div",{key:"actions",className:"doc-tree-actions row items-center flex-none surface-light h-9 border-t pl-2 pr-1"},this._renderFooterHint(e),this._renderFooterToolbar(e))}_getLibs(e){const{libs:t,app:n,onShowFiles:s,libTypes:r=[],libFilesIcon:o="annex-lib"}=e,a=[],l=s?{key:"project-files",text:n.getLang("filesLib","附件库"),icon:o,iconClass:"success-pale w-5 h-5 center rounded-lg",actions:!1,selected:e.showFiles,_data:{type:"files"}}:null;if(!(r!=null&&r.length))return a.push(...t.map(f=>this._getTreeItem(f))),l&&a.push(l),[a,!1];const[c,h]=iS(t,r,n.spaceType),d=!!h.size;return r.forEach((f,p)=>{const y=c.get(f.type)||[];if(y.length)if(a.push({key:`lib-type-${f.type}`,type:"heading",text:f.name,content:g("span",{className:"label size-sm rounded-full gray-pale"},y.length+(l&&!p?1:0)),icon:f.icon,actions:!1,className:p&&a.length>1?"mt-1.5 pt-1 border-t":""}),d){const b=new Set,w=y.reduce((x,T)=>{const D=T.data.execution,N=D?h.get(D):null;if(N&&N.length>1){if(b.has(D))return x;b.add(D),x.push({className:"item tree-item",type:"item",key:`e${D}`,text:T.data.executionName??T.data.name,innerComponent:"div",icon:"run",iconClass:"text-gray",items:N.map(A=>({...this._getTreeItem(A),text:A.data.originName}))})}else x.push(this._getTreeItem(T));return x},[]);a.push(...w)}else a.push(...y.map(b=>this._getTreeItem(b)));!p&&l&&a.push(l)}),[a,d]}_renderLibList(e){const{libs:t,app:n,space:s,preserve:r}=e;if(!(t!=null&&t.length))return g("div",{key:"empty",className:"center gap-4 h-full"},g("div",{className:"text-gray"},n.getLang("noLibs","没有文档库")),Fe.render({items:n.getActions("space",{ui:"sidebar-no-lib",data:s})},[]));const[o,a]=this._getLibs(e),l=e.app.getSortableOptions("lib");return g("div",{key:"list",className:"doc-tree flex-auto min-w-0 overflow-y-auto scrollbar-hover"},a?g(l?Li:zt,{ref:this._menu,preserve:r,wrapClass:"doc-lib-list doc-lib-tree px-1",className:"p-2",items:o,activeOnHover:!1,defaultNestedShow:!0,hoverItemActions:!0,itemKey:"key",lines:!0,nestedToggle:".item-icon,.nested-toggle-icon",onToggle:this._handleToggleTree,onClickItem:this._handleClickItem,...l}):g(l?jr:ht,{className:"doc-lib-list p-2",itemKey:"key",items:o,activeOnHover:!1,hoverItemActions:!0,onClickItem:this._handleClickItem,itemProps:{titleClass:"text-clip"},...l}))}_renderModuleTree(e){const{lib:t,app:n,preserve:s}=e,r=t?[...t.modules,...t.docs].filter(l=>!l.data.deleted):[];if(!r.length)return g("div",{key:"empty",className:"center gap-4 h-full"},g("div",{className:"text-gray"},n.getLang("noModules","没有目录")),Fe.render({items:n.getActions("lib",{ui:"sidebar-no-module",data:t})},[]));const o=e.app.getSortableOptions("doc-module");return g("div",{key:"list",className:"doc-tree flex-auto min-w-0 overflow-y-auto scrollbar-hover"},g(o?Li:zt,{ref:this._menu,preserve:s,wrapClass:"doc-lib-list doc-lib-tree px-1",className:U("p-2",t?"":"pl-3"),items:r,activeOnHover:!1,defaultNestedShow:!0,hoverItemActions:!0,itemKey:"key",lines:!0,nestedToggle:".item-icon,.nested-toggle-icon",getItem:this._getTreeItem,onToggle:this._handleToggleTree,onClickItem:this._handleClickItem,...o}))}_renderFileFilterList(e){const t=["all","story","bug","task","office","doc","image","av","archive","code","other"].map(s=>({key:s,...vu.filterTypeConfig[s]}));e.currentUser&&t.push({key:"addedByMe",...vu.filterTypeConfig.addedByMe});const n=e.app.filterType;return g(ht,{className:"doc-file-filter-list py-2 px-3",itemKey:"key",items:t.map(s=>({...s,selected:s.key===n})),activeOnHover:!1,onClickItem:this._handleClickFileFilter})}_scrollToSelected(){const e=this._ref.current.querySelector(".item>.selected");e&&v(e).scrollIntoView({behavior:"smooth"})}componentDidMount(){this._sidebar=new Qr(this._ref.current,{width:240,minWidth:64,maxWidth:400,parent:".doc-app",side:"left",preserve:this.props.preserve}),this._scrollToSelected(),this._handleToggleTree()}componentDidUpdate(e){(e.moduleID!==this.props.moduleID||e.docID!==this.props.docID)&&this._scrollToSelected()}componentWillUnmount(){var e;(e=this._sidebar)==null||e.destroy()}render(e){const{className:t,lib:n,showFiles:s,app:r}=e,o=!n||s;return g("div",{className:U("doc-sidebar sidebar border-r flex-none z-50 col",t),ref:this._ref},r.renderCustom("sidebar-before",this),o?this._renderLibList(e):this._renderModuleTree(e),r.renderCustom("sidebar-after",this),this._renderFooter(o?"space":"lib"))}}function iS(i,e,t){const n=new Map,s=new Map;for(const{type:o}of e)s.set(o,[]);const r=s.get(t);for(const o of i){const{type:a=""}=o.data;if(s.has(a)?s.get(a).push(o):r&&r.push(o),a!=="execution")continue;const l=o.data.execution;n.has(l)?n.get(l).push(o):n.set(l,[o])}return[s,n]}const vv=1e9;let rS=vv;function oS(){return rS++}function _v(i){return i>=vv}function ri(i){return typeof i=="string"&&String(+i)===i?+i:i}function bv(i){return typeof i=="string"?+i.replace("api.",""):i}function aS(i,e,t){const n=new Map,s=new Map,r=new Map,o=[];if(e){const{libs:c=[],docs:h=[],modules:d=[]}=e;for(const y of c){if(y.deleted||y.space!==i&&!t)continue;const w={type:"lib",key:`l${y.id}`,docs:[],modules:[],data:y,nestedOrder:y.order||0,nestedLevel:1};n.set(y.id,w),o.push(w)}const f=[],p=[...d].sort((y,b)=>(y.order||0)-(b.order||0));for(const y of p){if(y.deleted)continue;const b=`m${y.id}`,w=n.get(y.lib);if(!w||w.data.type==="api"&&y.type!=="api")continue;const x={type:"module",key:b,docs:[],modules:[],data:y,parent:w,nestedOrder:0,nestedLevel:w.nestedLevel+1};s.set(y.id,x),y.parent===y.id&&delete y.parent,y.parent||w.modules.push(x),y.parent!==void 0&&f.push(x)}if(f.length)for(const y of f){const b=s.get(y.data.parent);if(b){b.modules.push(y),y.parent=b,y.nestedLevel=b.nestedLevel+1;const w=n.get(y.data.lib),x=w==null?void 0:w.modules.findIndex(T=>T.data.id===y.data.id);typeof x=="number"&&x>=0&&w.modules.splice(x,1)}}for(const y of h){const b=`${y.id}`,w=n.get(y.lib);if(!w&&y.lib!==i)continue;const x={type:"doc",key:b,data:y,parent:w,docs:[],nestedOrder:0,nestedLevel:0};r.set(y.id,x)}for(const y of r.values()){if(y.data.parent){const x=r.get(y.data.parent);if(x){x.docs.push(y),y.parent=x,y.nestedLevel=x.nestedLevel+1;continue}}const b=s.get(y.data.module),w=n.get(y.data.lib);b?(b.docs.push(y),y.parent=b,y.nestedLevel=b.nestedLevel+1):w&&(y.nestedLevel=w.nestedLevel+1,w.docs.push(y))}}o.sort((c,h)=>(c.data.order||0)-(h.data.order||0));let a=1;const l=(c,h=!1)=>{for(const d of c){d.nestedOrder=a++;const f=d.modules;f&&f.length&&l(f,h),d.docs.length&&(d.docs.sort(h?(p,y)=>y.data.order-p.data.order:(p,y)=>p.data.order-y.data.order),l(d.docs,h))}};return o.forEach(c=>{var d;const h=(d=c.data.orderBy)==null?void 0:d.endsWith("desc");l([c],h)}),{libs:n,modules:s,docs:r,libList:o}}function ao(i,e=[],t){if(e.push(...t?i.docs.map(n=>n.data):i.docs),i.modules)for(const n of i.modules)ao(n,e,t);for(const n of i.docs)ao(n,e,t);return e}const lS=i=>{const{time:e=6e4,content:t,contentType:n="markdown",space:s=6,lib:r=2,module:o=1,title:a=""}=i||{};nt.session.set("nextCreatingDoc",{expired:Date.now()+e,title:a,content:t,contentType:n,space:s,lib:r,module:o})},wv=i=>{const{space:e=0,lib:t=0,module:n=0}=i||{},s=nt.session.get("nextCreatingDoc");if(s&&!(e&&s.space&&e!==s.space||t&&s.lib&&t!==s.lib||n&&s.module&&n!==s.module)&&(nt.session.remove("nextCreatingDoc"),!(Date.now()>s.expired)))return s};function cS(i){const{link:e,itemProps:t={},typeIconMap:n={},labelMap:s={},searchKeys:r,active:o,itemType:a="",checkIcon:l,hideDirIcon:c}=this,{id:h,keys:d,text:f,className:p,type:y,url:b,items:w,icon:x,label:T,...D}=i;let{type:N}=i;N=N==="item"?a:N||a;let A=w?T??(s[N]||N):null,z;typeof A=="string"&&A.length&&(z=A,A=g("span",{class:"label rounded-full gray-pale size-sm ml-1"},A));let O=b;O===void 0&&e&&(typeof e=="function"?O=e(i):typeof e=="object"?(O=e[N],O&&(O=De(O,i))):w||(O=De(e,i)));let K=x;K===void 0&&(!c||O)&&(K=n[N]),typeof K=="string"&&(K={icon:K},z&&v.extend(K,{"data-toggle":"tooltip","data-title":z}));let Z=f??(s[N]||N);r!=null&&r.length&&(Z=Zs.underlineKeys(r,[Z]));const ye=String(o)===String(h);return{type:"item",key:h,content:A,icon:K,trailingIcon:l&&ye?{icon:"check",className:"mx-1 text-primary"}:void 0,items:w,"data-url":O,"data-type":N,title:Z,selected:ye,hint:f,...t,...D,className:U("dropmenu-item tree-item",p,t.className,w?"is-dir":"is-item"),innerClass:O?"is-link open-url":"is-toggle",active:!1}}function Cv(i){const{className:e,items:t,tree:n,onClickItem:s,defaultNestedShow:r}=i;return g(zt,{items:t,getItem:cS.bind(i),className:U(e,"dropmenu-tree"),defaultNestedShow:r,onClickItem:s,...n})}const hS=(i,e)=>{const{keys:t="",text:n}=i;return!e.length||e.every(s=>t.toLowerCase().includes(s)||typeof n=="string"&&n.toLowerCase().includes(s))},xv=(i,e,t=0)=>(i=i.reduce((n,s)=>{const{items:r}=s;if(r){if(r.length){const[o,a]=xv(r,e);o.length&&(n.push({...s,items:o}),t+=a)}}else hS(s,e)&&(n.push(s),t++);return n},[]),[i,t]);class kv extends gd{constructor(e){super(e),this._searchbox=pe(),this._list=pe(),this._handleSearch=t=>{this.setState({search:t})},this._handleExpandBtnClick=()=>{this.expand()},this._handleItemClick=({item:t,event:n})=>{const s=v(n.target);!s.closest(".tree-toggle").length&&s.closest(".is-link").length&&(this.props.togglePop(!1,{text:t.text??`${t.type}:${t.id}`}),this.props.changeState({text:t.text??`${t.type||""}:${t.id}`,value:t.id}))},this._scrollToActive=()=>{requestAnimationFrame(()=>{const t=this._list.current;t&&v(t).find(".tree-item-inner.active").scrollIntoView()})},this.activeTab=t=>{this.setState({active:t})},this.expand=t=>{this.setState({expanded:t??!this.state.expanded})},this.state={search:"",data:e.data,expanded:!1,loading:!!e.fetcher&&!e.data}}async load(){var n,s;let{fetcher:e}=this.props;if(!e)return this._scrollToActive();if(typeof e=="string"&&(e={url:e}),typeof e=="object"){const{url:r,...o}=e;e=()=>v.ajax({url:r,dataType:"json",jsonParser:Go,...o})}this.setState({loading:!0});let t=await e();t.result&&(t=t.data),t={...this.props.data,...t},this.setState({data:t,loading:!1},this._scrollToActive),(s=(n=this.props).onCacheData)==null||s.call(n,t)}componentDidMount(){var e;super.componentDidMount(),this.props.data||this.load(),(e=this._searchbox.current)==null||e.focus(),this._scrollToActive()}_getTreeProps(e){const{data:{labelMap:t,link:n,typeIconMap:s,typeLabelMap:r,itemProps:o,tree:a,itemType:l,checkIcon:c,hideDirIcon:h=!0}={},search:d}=this.state,f=v.unique(d.toLowerCase().split(" ").filter(p=>p.length));return{items:f.length&&e.items.length>100?e.items.slice(0,100):e.items,labelMap:t,typeIconMap:{execution:"run",project:"project",product:"product",program:"cards-view",...s},hideDirIcon:h,typeLabelMap:r,itemProps:o,itemType:l,checkIcon:c,onClickItem:this._handleItemClick,tree:a,link:n,active:this.props.state.value,defaultNestedShow:!!((e.count||e.items.length)<100||f.length||e.index===0&&!e.expand),searchKeys:f}}_getData(){const{data:e={},search:t,active:n}=this.state,{tabs:s=[{name:"other"}],expandName:r}=e;let{data:o=[]}=e;Array.isArray(o)&&(o={other:o});const a={},l=v.unique(t.toLowerCase().split(" ").filter(f=>f.length));let c,h;Object.keys(o).forEach(f=>{const p=r===f,y=s.find(N=>N.name===f)||{name:f},b=o[f]||[],w=(n===f||y.active&&n===void 0)&&!p,[x,T]=xv(b,l),D={name:f,items:x,text:y.text,active:w,count:T,index:0,expand:p};p?c=D:(a[f]=D,w&&(h=D))});const d=s.reduce((f,{name:p})=>{if(p!==r){const y=a[p]||{name:p,items:[]};y.index=f.length,f.push(y)}return f},[]);return!h&&d.length&&(h=d[0]),{tabs:d,expandData:c,activeTab:h}}_renderList(e,t,n){const s=t.name,{expanded:r,data:o={},search:a,loading:l}=this.state;let{hideSingleTab:c=!0}=o;return c=e.length===1&&c,g(ps,null,c?null:g("div",{className:"dropmenu-nav"},g("ul",{key:"nav",className:"nav nav-secondary"},e.map(({name:h,text:d,count:f})=>g("li",{className:"nav-item"},g("a",{className:`${s===h?" active":""}`,onClick:this.activeTab.bind(this,h)},d||h,f?g("span",{className:"label gray-pale rounded-full size-sm font-normal"},f):null))))),g("div",{key:"tab",className:"flex-auto dropmenu-list scrollbar-hover"},l?g("div",{key:"loading",class:"row items-center justify-center h-full text-gray gap-2"},g($e,{icon:"spinner-indicator",className:"spin"}),g("span",{className:"text-sm text-shimmer"},be.getLang("loading"))):g(Cv,{key:`${s}${a!=null&&a.length?"-search":""}`,...this._getTreeProps(t)})),n?g("div",{key:"foot",className:"dropmenu-foot flex-none toolbar justify-between border-t"},o.footToolbar?Fe.render(o.footToolbar,[]):g("div",{className:"flex-auto"}),g(we,{type:"ghost text-dark rounded gap-0.5 px-1.5",trailingIcon:`angle-${this.state.expanded?"left":"right"} opacity-60`,onClick:this._handleExpandBtnClick},n.text||n.name," ",n.count&&r?g("span",{className:"ml-1 label gray-pale rounded-full size-sm font-normal"},n.count):null)):null)}_renderExpand(e){const{search:t}=this.state;return g("div",{className:"col w-1/2 dropmenu-list scrollbar-hover"},g(Cv,{key:`${e.name}${t!=null&&t.length?"-search":""}`,...this._getTreeProps(e)}))}_renderPop(){const{expanded:e,data:t={}}=this.state,{searchHint:n,search:s=!0,title:r}=t,{expandData:o,tabs:a,activeTab:l}=this._getData(),c=e&&o;return g(ps,null,s&&this.props.searchBox!==!1?g("div",{key:"search",className:"p-3 flex-none"},g(vs,{ref:this._searchbox,className:"size-md",placeholder:n,onChange:this._handleSearch})):null,r?g("div",{className:"dropmenu-title"},r):null,g("div",{class:"row flex-auto min-h-0",ref:this._list},g("div",{class:`col w-${c?"1/2":"full"}`},this._renderList(a,l,o)),c?g("div",{class:"w-px bg-gray opacity-10"}):null,e&&o&&this._renderExpand(o)))}_getClass(e){const{expanded:t,loading:n,data:s={}}=this.state;return U("dropmenu load-indicator col",super._getClass(e),t&&"is-expanded",n&&"loading",s.search!==!1&&"has-search",s.title?"has-title":"")}_getStyle(e={},t){e=super._getStyle(e,t);const{width:n=248}=this.props;return typeof n=="number"&&(e.width=n*(this.state.expanded?2:1)),e}_getProps(e){const{style:t,...n}=super._getProps(e),s=this.trigger,r=s==null?void 0:s.getBoundingClientRect();return{...n,style:{...t,...this._getStyle(),maxHeight:r?Math.max(r.top-8,window.innerHeight-r.bottom-8):t.maxHeight}}}}class Sv extends za{_getProps(e){const t=super._getProps(e);return{type:"button","data-value":e.state.value,...t}}_renderTrigger(e){const{icon:t,text:n,state:s,children:r,caret:o,leadingAngle:a,display:l}=e,c=typeof l=="string"?l:s.text??n;let h=l??c;return typeof h=="function"&&(h=h(n,s)),[a&&g($e,{icon:"angle-right",className:"is-leading"}),t?g($e,{icon:t}):null,g(de,{class:"text",generatorThis:this,content:h,title:c}),r,o&&g("div",{key:"caret",class:"is-caret"},g("span",{className:"caret"}))]}}let Xi=class extends ot{constructor(){super(...arguments),this._setCacheData=e=>{const{cache:t}=this.props;t&&(this._cacheData=e,typeof t=="number"&&(this._cacheTimer&&clearTimeout(this._cacheTimer),this._cacheTimer=window.setTimeout(()=>{this._cacheData=void 0,this._cacheTimer=0},t)))}}getDefaultState(e){return{...super.getDefaultState(e),text:void 0}}componentWillUnmount(){super.componentWillUnmount(),this._cacheTimer&&clearTimeout(this._cacheTimer)}componentWillReceiveProps(e){(this.props.data!==e.data||this.props.fetcher!==e.fetcher)&&(this._cacheData=void 0)}_getTriggerProps(e,t){const{className:n,...s}=super._getTriggerProps(e,t),{value:r=""}=t;return{...s,className:U(n,{"has-value":r.length}),text:e.text,caret:e.caret,maxWidth:e.maxWidth,icon:e.icon,leadingAngle:e.leadingAngle,display:e.display}}_getPopProps(e,t){return{...super._getPopProps(e,t),data:this._cacheData||e.data,fetcher:e.fetcher,cache:!!e.cache,onCacheData:this._setCacheData,onClickItem:e.onClickItem}}};Xi.defaultProps={...ot.defaultProps,popWidth:248,popMaxHeight:800,maxWidth:160,className:"dropmenu-btn btn ghost",tagName:"button",clickType:"toggle",leadingAngle:!0,caret:!0,cache:60*1e3*4},Xi.Pop=kv,Xi.Trigger=Sv;class dS extends re{constructor(){super(...arguments),this._handleClickItem=(e,t)=>{var n,s;e.target.closest(".dropmenu-nav")||e.target.closest(".dropmenu-foot")||(s=(n=this.props).onSelect)==null||s.call(n,+t,!0)},this._renderCurrent=()=>{const{space:e}=this.props;return g("div",{class:"row items-center relative gap-2"},g("div",{className:"text-md row items-center flex-auto min-w-0 overflow-hidden"},e==null?void 0:e.name),g(we,{icon:"exchange",type:"gray-pale",className:"doc-path-picker-toggle"}))}}render(e){const{space:t,fetcher:n,menuOptions:s,display:r}=e,o=r??this._renderCurrent();return g(Xi,{text:t==null?void 0:t.name,defaultValue:t==null?void 0:t.id.toString(),onClickItem:this._handleClickItem,fetcher:n,leadingAngle:!1,caret:!1,display:o,...s})}}class Tv extends re{constructor(){super(...arguments),this._picker=pe(),this._getItems=()=>{const{spaces:e=[],spaceIcon:t}=this.props;return e.map(n=>({id:n.id,icon:t,text:n.name,value:n.id,className:"group"}))},this._renderCurrent=()=>{const{space:e}=this.props;return g("div",{class:"row items-center relative gap-2"},g("div",{className:"text-md row items-center flex-auto min-w-0 overflow-hidden"},e==null?void 0:e.name),g(we,{icon:"exchange",type:"gray-pale",className:"doc-path-picker-toggle"}))},this._handleClick=e=>{var t,n,s;!this.props.noClickTrigger&&!e.target.closest(".doc-path-picker-toggle,.doc-space-picker-toggle")&&((s=(n=this.props).onSelect)==null||s.call(n,((t=this.props.space)==null?void 0:t.id)||0,!0),e.preventDefault())},this._handleItemClick=e=>{var s,r;const t=this._picker.current;if(!t)return;const n=e.item.value;(r=(s=this.props).onSelect)==null||r.call(s,n,!0),t.select(n),t.close()}}render(e){const{getSpaceFetcher:t,spaceID:n,space:s,spaceType:r,onSelect:o,menuOptions:a}=e;if(t){const f=t(r,n);if(f)return g(dS,{fetcher:f,space:s,onSelect:o,menuOptions:a})}const{spaces:l=[],searchBox:c=!0}=e,h=s||l[0],d={searchBox:c,search:void 0,onClickItem:this._handleItemClick};return g(Zt,{ref:this._picker,className:"doc-space-picker ring-transparent cursor-pointer state bg-transparent w-auto",popClass:"popup doc-space-picker-menu",style:{maxWidth:160},items:this._getItems,defaultValue:h?String(h.id):"",required:!0,search:!1,cache:!1,caretClass:"hidden",menu:d,popMinWidth:200,display:this._renderCurrent,onClick:this._handleClick})}}Tv.defaultProps={noClickTrigger:!1};class lo extends re{constructor(){super(...arguments),this._picker=pe(),this._getItems=()=>{const{items:e=[],icon:t,apiIcon:n,chapterIcon:s,current:r,getItems:o}=this.props,a=e.filter(l=>!l.data.deleted).map(l=>({id:l.data.id,icon:l.type==="lib"&&l.data.type==="api"?n:l.type==="doc"&&l.data.type==="chapter"?s:t,text:this._getItemText(l),value:l.data.id,selected:(r==null?void 0:r.key)===l.key}));return o?o(a):a},this._renderCurrent=()=>{const{current:e,placeholder:t,icon:n,showIcon:s,type:r,suffixIcon:o,children:a}=this.props,l=r==="lib";return g("div",{class:U("row items-center relative",l?"gap-2":"gap-1")},s?g($e,{icon:n,className:U("transition-opacity group-hover:opacity-0 w-5 h-5 center",l?"rounded-lg primary-pale flex-none":r==="doc"?"text-special":"text-warning","")}):null,g("div",{className:U("row items-center flex-auto min-w-0 overflow-hidden",l?"text-md":"",e?"":"text-gray")},e?this._getItemText(e):t),a,g(we,{icon:"exchange",type:"gray-pale",className:"doc-path-picker-toggle"}),o?g($e,{icon:o}):null)},this._handleClick=e=>{var t,n,s;!this.props.noClickTrigger&&!e.target.closest(".doc-path-picker-toggle")&&((s=(n=this.props).onSelect)==null||s.call(n,((t=this.props.current)==null?void 0:t.data.id)||0,this.props.type),e.preventDefault())},this._handleItemClick=e=>{var s,r;const t=this._picker.current;if(!t)return;const n=e.item.value;(r=(s=this.props).onSelect)==null||r.call(s,ri(n),e.item.dataType),t.select(n),t.close()}}_getItemText(e){return e?e.type==="doc"?e.data.title:e.data.name:""}render(e){const{current:t,type:n,maxWidth:s,display:r,searchBox:o=!0}=e,a={searchBox:o,search:void 0,onClickItem:this._handleItemClick};return g(Zt,{ref:this._picker,className:"doc-path-picker ring-transparent cursor-pointer state bg-transparent w-auto",popClass:"popup doc-path-picker-menu",style:{maxWidth:s},items:this._getItems,defaultValue:t?String(t.data.id):"",search:!1,cache:!1,caretClass:"hidden",menu:a,popMinWidth:200,required:n!=="lib",display:r??this._renderCurrent,onClick:this._handleClick})}}lo.defaultProps={type:"module",maxWidth:160,noClickTrigger:!1,showIcon:!1};function $v({pri:i="",text:e,className:t}){return i=`${i}`.trim(),e===void 0&&(e=i==="0"||i===""?"":i),g("span",{className:U(`pri-${i}`,t)},e)}let co=class extends ot{constructor(){super(...arguments),this._handleClearBtnClick=e=>{this.setValue(""),e.preventDefault()}}getDefaultState(e){const t=super.getDefaultState(e);if(t.value===void 0&&(e||this.props).required){const n=this._getItems().shift();n&&(t.value=n.value)}return t}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return e.disabled&&(n.className=U(n.className,"disabled")),n}_renderTrigger(e,t){var l;const{value:n}=t,{placeholder:s,required:r}=e,o=n===void 0||n==="",a=!o&&!r;return[g("div",{className:"text"},o?g("span",{class:"placeholder"},s):this._renderItem(t.value,(l=this._getItems().find(({value:c})=>c===n))==null?void 0:l.text,"pri")),a?g(we,{type:"button",class:"btn square btn-close size-xs ghost rounded-full",onClick:this._handleClearBtnClick},g("span",{class:"close"})):null,a?null:g("span",{key:"caret",class:"caret"})]}_getItems(){let{items:e=["",1,2,3,4]}=this.props;return Array.isArray(e)?e=e.map((t,n)=>typeof t=="object"?t:t?{text:`${t}`,value:`${n}`}:{text:"",value:""}):typeof e=="object"&&(e=Object.keys(e).map(t=>({value:t,text:e[t]}))),e=e.filter(({value:t})=>t!==""),e.sort((t,n)=>+t.value-+n.value),e}_renderItem(e,t,n){return g($v,{key:n,pri:e,text:t})}_renderPop(){const{value:e}=this.state;return g("div",{className:"pick-pri-list"},this._getItems().map(({value:t,text:n})=>g("button",{key:t,type:"button",class:`btn w-full ${e===t?"primary-pale":"ghost"}`,"data-pick-value":t},this._renderItem(t,n))))}};co.defaultProps={...ot.defaultProps,items:["",1,2,3,4],className:"pick-pri form-control",popClass:"pick-pri-pop popup",popWidth:"auto",popMinWidth:56};let _u=class extends ot{constructor(){super(...arguments),this.enterDiffMode=e=>{var t,n;e.stopPropagation(),(n=(t=this.props).onModeChange)==null||n.call(t,!0),this.setState({diffMode:!0,diffVersions:[]})},this.confirmToDiff=()=>{var n,s;const{diffVersions:e}=this.state,t=[...e];t.length===2&&(t.sort((r,o)=>r-o),this.setState({diffVersions:t}),(s=(n=this.props).onDiff)==null||s.call(n,[t[0],t[1]])),this.close()},this.switchDiff=e=>{e.preventDefault(),this.close(),this.setState(t=>{var r,o;const[n,s]=t.diffVersions;return!n||!s?null:((o=(r=this.props).onDiff)==null||o.call(r,[s,n]),{diffVersions:[s,n]})})},this.cancelDiff=e=>{e.stopPropagation(),e.preventDefault(),this.setState(t=>{var s,r,o,a;const{version:n}=t;return(r=(s=this.props).onCancelDiff)==null||r.call(s,n),(a=(o=this.props).onModeChange)==null||a.call(o,!1),{diffMode:!1,diffVersions:[]}})},this.itemOnClick=e=>{this.setState(t=>{var o,a;const{version:n,diffMode:s,diffVersions:r}=t;if(s){let l=[];if(r.includes(e))l=r.filter(c=>c!==e);else if(r.length<2)l=[...r,e];else return null;return{diffVersions:l}}else return n===e?null:((a=(o=this.props).onVersionChange)==null||a.call(o,e,n),this.close(),{version:e,diffVersions:[]})})},this.checkboxOnClick=(e,t)=>{e.stopPropagation(),this.itemOnClick(t)}}getDefaultState(e){const t=super.getDefaultState(e);t.diffMode=(e==null?void 0:e.diffMode)??!1,t.diffVersions=[];const n=(e==null?void 0:e.latestVersion)??1;t.version=(e==null?void 0:e.version)??(e==null?void 0:e.defaultVersion)??n;const s=[];for(let r=0;r<n;r++)s.unshift(r+1);return t.options=s,t}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return e.disabled&&(n.className=U(n.className,"disabled")),n}componentDidUpdate(){const{diffMode:e,version:t}=this.props;!e&&this.state.diffMode&&this.setState({diffMode:!1}),t!==this.state.version&&this.setState({version:t})}_renderTrigger(){const{version:e,diffMode:t,diffVersions:n}=this.state;return t?g("div",{className:"diff-picker-trigger"},g("button",{className:"btn gray-pale"},g("span",null,n[0]?`#${n[0]}`:""),g("i",{className:"icon icon-angle-down"})),g("button",{className:"btn ghost switch-diff",onClick:s=>this.switchDiff(s)},g("i",{className:"icon icon-exchange"})),g("button",{className:"btn gray-pale"},g("span",null,n[1]?`#${n[1]}`:""),g("i",{className:"icon icon-angle-down"}))):[g("button",{className:"btn gray-pale"},g("span",null,e?`#${e}`:""),g("i",{className:"icon icon-angle-down"}))]}_renderItem(e){const{version:t,diffMode:n,diffVersions:s}=this.state;return g("li",{className:"menu-item",key:e},g("a",{className:`listitem item-inner ${e===t&&!n?"selected checked":""} ${!s.includes(e)&&s.length>=2?"disabled":""}`,onClick:()=>this.itemOnClick(e)},n&&g("input",{type:"checkbox",checked:s.includes(e),onClick:r=>this.checkboxOnClick(r,e)}),g("div",{className:"item-content"},g("div",{className:"item-title"},"#",e))))}_renderPop(){const{labelAllVersions:e,labelDiff:t,labelConfirm:n,labelCancelDiff:s,diffEnabled:r}=this.props,{options:o,diffMode:a,diffVersions:l}=this.state,c=l.length===2&&l.every(h=>!!h);return g("div",{className:"diff-pop"},r&&g("div",{className:"diff-pop-header"},g("span",{class:"text-gray"},e),!a&&o.length>1&&g("button",{className:"btn text-primary size-sm ghost",onClick:h=>this.enterDiffMode(h)},g("i",{className:"icon icon-exchange"}),g("span",{className:"text"},t))),g("menu",{className:"menu"},o.map(h=>this._renderItem(h))),a&&g("div",{className:"diff-pop-footer"},g("button",{className:"btn primary size-sm",disabled:!c,onClick:()=>this.confirmToDiff()},n),g("button",{className:"btn size-sm",onClick:h=>this.cancelDiff(h)},s)))}};_u.defaultProps={popContainer:"body",popClass:"pick-diff-pop popup",popWidth:"auto",popPlacement:"auto",popMinWidth:56,popMinHeight:32,popMaxHeight:300,limitPopInScreen:!0,clickType:"open",className:"pick-diff form-control",latestVersion:1,labelAllVersions:"全部版本",labelDiff:"对比",labelConfirm:"确定",labelCancelDiff:"取消对比",diffEnabled:!1};function Dv({severity:i="",text:e,className:t}){i=`${i}`.trim(),e===void 0&&(e=i==="0"||i===""?"":i);const n=`${+e}`!=`${i}`;return g("span",{className:U(`severity${n?" severity-label":""}`,t),"data-severity":i},n?e:"")}let bu=class extends co{_renderItem(e,t,n){return g(Dv,{key:n,severity:e,text:t})}};bu.defaultProps={...co.defaultProps,items:["",1,2,3,4]};let Iv=class extends ot{constructor(){super(...arguments),this._handleClick=e=>{const t=v(e.target).closest(".pick-range-list-item").data("value");typeof t=="number"&&(this._clickedStart===void 0?(this._clickedStart=t,this.setRange(t)):(this.setRange(this._clickedStart,t),this._clickedStart=void 0,this.close()))},this._handleMouseMove=e=>{if(this._clickedStart===void 0)return;const t=v(e.target).closest(".pick-range-list-item").data("value");typeof t=="number"&&this.setRange(this._clickedStart,t)},this._handleClearBtnClick=e=>{this.setValue(""),e.preventDefault()}}get range(){const{value:e}=this.state;if(e===void 0||e==="")return;const[t,n]=e.split(this.props.valueSplitter??",");return[+t,+(n??t)]}setRange(e,t){return this.setValue([e,t??e].sort((n,s)=>n-s).join(this.props.valueSplitter))}_getTriggerProps(e,t){const n=super._getTriggerProps(e,t);return e.disabled&&(n.className=U(n.className,"disabled")),n}_renderTrigger(e,t){const{value:n}=t,{placeholder:s,display:r,name:o,fromName:a,toName:l}=e,{range:c}=this,h=!c,d=!h;let f=n;return c&&r&&(typeof r=="string"?f=De(r,...c):f=r.call(this,c)),[g("div",{className:"text"},h?g("span",{class:"placeholder"},s):f),d?g(we,{type:"button",class:"btn square btn-close size-xs ghost rounded-full",onClick:this._handleClearBtnClick},g("span",{class:"close"})):null,d?null:g("span",{key:"caret",class:"caret"}),a?g("input",{type:"hidden",name:a,value:c?c[0]:""}):null,l?g("input",{type:"hidden",name:l,value:c?c[1]:""}):null,o?g("input",{type:"hidden",name:o,value:n}):null]}_renderPop(){const{range:e}=this,{start:t=1,end:n=100,formatText:s,colCount:r=2,colSize:o=5}=this.props,a=[],l=n-t+1,c=r*o,h=Math.ceil(l/c),[d,f]=e||[];for(let p=0;p<h;++p){const y=[];for(let b=0;b<c;++b){const w=t+p*c+b;let x=w+"";typeof s=="string"?x=De(s,{from:d,to:f,current:w}):s&&(x=s.call(this,w,e)),y.push(g("div",{key:b,"data-value":w,className:U("pick-range-list-item state",{"is-col-end":b>0&&(b+1)%o===0&&b<c-1,"is-from":e&&w===d,"is-to":e&&w===f,"is-in":e&&w>d&&w<f,"has-small-text":w>=1e3})},g("div",{className:"text"},x)))}a.push(g("div",{key:p,className:"pick-range-list-row"},y))}return g("div",{className:"pick-range-list scrollbar-hover",onClick:this._handleClick,onMouseOver:this._handleMouseMove},a)}};Iv.defaultProps={...ot.defaultProps,className:"pick-range form-control",popClass:"pick-range-pop popup",popWidth:"auto",popMinWidth:120,display:"{0} ~ {1}",valueSplitter:",",start:1,end:100,colCount:2,colSize:5};class uS extends re{constructor(){super(...arguments),this._handleSelectModule=e=>{var t,n;(n=(t=this.props).onSelectModule)==null||n.call(t,+e,!0)},this._handleSelectLib=(e,t)=>{var n,s;t==="files"?this.props.app.showFiles():(s=(n=this.props).onSelectLib)==null||s.call(n,+e,0)},this._unselectLib=()=>{var e,t;(t=(e=this.props).onSelectLib)==null||t.call(e,0,0)},this._handleSelectVersion=e=>{var t,n;(n=(t=this.props).onSelectDocVersion)==null||n.call(t,e)},this._handleDiffVersions=e=>{var t,n;(n=(t=this.props).onDiffDocVersions)==null||n.call(t,e)},this._handleDiffModeChange=e=>{var t,n;(n=(t=this.props).onDiffModeChange)==null||n.call(t,e)},this._handleRestoreDocVersion=async()=>{const{app:e,doc:t}=this.props,{version:n=1,id:s}=t==null?void 0:t.data,r=this.props.docVersion||n;await He.confirm({title:e.getLang("restoreVersionHint","恢复到版本")+` #${r}`,message:e.getLang("restoreVersionConfirm",[{version:r}],"这将使用文档版本 #{version} 的内容创建一个新的版本,确定要继续吗?")})&&e.restoreDoc(s,r)},this._getLibItems=e=>{const{app:t,libIcon:n,showFiles:s}=this.props;return t.canShowLibFiles?[...e,{text:t.getLang("filesLib","附件库"),icon:n,key:"files",dataType:"files",selected:!!s,disabled:!1}]:e}}_renderAngle(e){return g("div",{key:e,class:"doc-path-picker-angle chevron-right scale-75 opacity-75 flex-none"})}_renderModulePickers(e){const{module:t}=e;if(!t||!t.data.id)return[];let n=t;const s=[];for(;n;){const{parent:o}=n;if(s.push(n),o.type!=="module")break;n=o}const r=[];return s.reverse().forEach((o,a)=>{if(s.length>=2&&a>=0&&a<s.length-1){a===0&&r.push(["module-ellipsis",g("div",{key:"module-ellipsis",class:"doc-path-picker-angle mx-1 opacity-50"},g("div",{className:"more"}))]);return}if(a===s.length-1){const{key:l}=o;r.push([`${l}-angle`,g(lo,{key:l,icon:e.moduleIcon,current:o,items:o.parent.modules,searchBox:{placeholder:this.props.app.getLang("searchModulePlaceholder","searchModulePlaceholder")},onSelect:this._handleSelectModule})])}}),r}_renderParents(e){var c,h;const{doc:t,app:n,docIcon:s,onSelectDoc:r}=e;if(!t||((c=t.parent)==null?void 0:c.type)!=="doc")return[];let o=t.parent;const a=[];for(;o&&(a.push(o),((h=o.parent)==null?void 0:h.type)==="doc");)o=o.parent;const l=[];return a.reverse().forEach((d,f)=>{var y;if(a.length>=3&&f>0&&f<a.length-1){f===1&&l.push(["parent-ellipsis",g("div",{key:"parent-ellipsis",class:"doc-path-picker-angle mx-1 opacity-50"},g("div",{className:"more"}))]);return}const{key:p}=d;l.push([`${p}-angle`,g(lo,{key:p,type:"doc",icon:s,chapterIcon:n.props.chapterIcon,current:d,items:(y=d.parent)==null?void 0:y.docs,searchBox:{placeholder:n.getLang("searchPlaceholder","搜索")},onSelect:r,maxWidth:160})])}),l}_renderCurrent(e){var l,c;const{doc:t,docIcon:n,onSelectDoc:s,app:r}=e,[o,a]=r.viewInfo;if(a&&(o==="create"||o==="edit"))return g(we,{key:"doc",type:"ghost",icon:n,className:"mr-4 min-w-0 justify-start"},g("span",{className:"text-gray min-w-0 overflow-hidden"},a.title),g("span",{className:"label size-sm rounded-full primary-pale flex-none"},o==="create"?r.getLang("newDocLabel","新文档"):r.getLang("editingDocLabel","编辑中")));if(t){const{version:h=1,privs:d={},id:f}=t.data,p=r.signals.docVersion.value||h,y=e.docVersion||h,b=!t.data.deleted&&!t.data.api&&h>1&&y!==h&&(((l=r.props.privs)==null?void 0:l.restoreDoc)??d.edit!==!1),w=r.isLoadingDoc(f),{spaceID:x,libID:T,moduleID:D}=r.props,N=[x,T,D,f,h].join("-"),A=r.signals.diffMode.value||!1;return[e.noDocSwitcher?g("div",{className:"doc-app-nav-doc-title px-2"},t.data.title):g(lo,{key:"doc",type:"doc",icon:n,chapterIcon:r.props.chapterIcon,current:t,items:(c=t.parent)==null?void 0:c.docs,onSelect:s,searchBox:{placeholder:r.getLang("searchPlaceholder","搜索")},maxWidth:160,suffixIcon:a&&o==="edit"?"draft-edit":void 0}),h>1?g("div",{key:"version",className:"hint mx-1","data-hint":r.getLang("currentDocVersionHint","当前版本,点击切换")},g(_u,{key:N,labelAllVersions:r.getLang("labelAllVersions","全部版本"),labelDiff:r.getLang("labelDiff","对比"),labelConfirm:r.getLang("labelConfirm","确定"),labelCancelDiff:r.getLang("labelCancelDiff","取消对比"),latestVersion:h,version:p,diffEnabled:r.props.diffEnabled&&!t.data.api,diffMode:A,onVersionChange:z=>{this._handleSelectVersion(z)},onDiff:z=>{this._handleDiffVersions(z)},onCancelDiff:z=>{this._handleSelectVersion(z)},onModeChange:z=>{this._handleDiffModeChange(z)}})):null,b&&!A?g("div",{key:"restoreVersion","data-hint":`${r.getLang("restoreVersionHint","恢复到版本")} #${y}`,className:"hint ml-1"},g(we,{disabled:w,text:r.getLang("restoreVersion","恢复"),type:"ghost text-primary",size:"sm",rounded:"full",onClick:this._handleRestoreDocVersion})):null,t.data.status==="draft"?g("div",{key:"status",className:"label special-pale size-sm rounded-full ml-1"},r.getLang("draft","草稿")):null]}return null}_renderLibPicker(e){const{lib:t,libs:n,libIcon:s,apiLibIcon:r,libPlaceholder:o,showFiles:a,app:l}=e;return(!t||!t.data.id)&&!a?null:g(lo,{key:"lib",type:"lib",icon:s,apiIcon:r,current:t,items:n,getItems:this._getLibItems,display:a?()=>g("div",{class:"row items-center gap-2"},g("div",{class:"text-md"},l.getLang("filesLib","附件库")),g("span",{className:"caret"})):void 0,placeholder:o,searchBox:{placeholder:l.getLang("searchLibPlaceholder","搜索库")},onSelect:this._handleSelectLib})}render(e){const{spaceIcon:t,space:n,spaces:s,onSelectSpace:r,children:o,homeName:a,noSpace:l,getSpaceFetcher:c,spaceID:h,spaceType:d,app:f}=e;let p;if(l)p=l==="hidden"?null:g(we,{icon:n?t:"home",type:"ghost",iconClass:"w-4 h-4 center rounded-md primary flex-none",textClass:"text-md",text:n==null?void 0:n.name,onClick:this._unselectLib});else if(n){let N=f.props.spaceMenuOptions;typeof N=="function"&&(N=N.call(f,d,h)),p=g(Tv,{key:"space",spaceIcon:t,space:n,spaces:s,searchBox:{placeholder:f.getLang("searchSpacePlaceholder","搜索空间")},onSelect:r,getSpaceFetcher:c,spaceType:d,spaceID:h,menuOptions:N})}const y=this._renderLibPicker(e),b=this._renderModulePickers(e),w=this._renderParents(e),x=this._renderCurrent(e);let T=[];a!==!1&&T.push(["home",g(we,{key:"home-btn",icon:"home",size:"md",type:"ghost text-primary",hint:typeof a=="string"?a:void 0,command:"goHome",...typeof a=="object"?a:{}})]),T.push(["space",p]),y&&T.push(["lib",y]),b&&T.push(...b),w&&T.push(...w),x&&T.push(["current",x]);const D=f.getCustomRender("app-nav");return D&&(T=D.call(f,T,this)||T),g("div",{className:"doc-app-nav row items-center flex-auto min-w-0"},T.reduce((N,[A,z],O)=>(z==null||((Array.isArray(z)?z:[z]).forEach(Z=>{typeof Z=="object"&&Z&&"html"in Z?N.push(g(An,{html:Z.html})):N.push(Z)}),O<T.length-1&&N.push(this._renderAngle(A+"-angle"))),N),[]),o)}}function wu(){var i;return(i=window.frameElement)==null?void 0:i.closest("affine-zui-iframe")}function Cu(){const i=wu();if(!i)return;const e=i.getAttribute("data-block-id"),t=i.closest("editor-host");if(!(!t||!e))return t.std.doc.getBlock(e)}function fS(){const i=Cu();i&&i.doc.deleteBlock(i.model)}function pS(i){const e=Cu();e&&e.doc.updateBlock(e.model,i)}function mS(){var i;return(i=wu())==null?void 0:i.adjustHeight()}const gS={getElement:wu,get:Cu,delete:fS,update:pS,adjustHeight:mS};function Mv(i,e){return i.reduce((t,n,s)=>{var o;let r=n;return(o=r.children)!=null&&o.length&&(r={...n,children:Mv(n.children,e)}),e(t,r,s)},[])}let Nv=class extends re{constructor(){super(...arguments),this._toolbarState={bold:!1,italic:!1,underline:!1,strikethrough:!1,bulleted:!1,numbered:!1,fontSize:"text",color:"",background:""},this.colorPickerRef=null,this.colorPicker=null,this.bgColorPickerRef=null,this.bgColorPicker=null,this.formatButtons=[{key:"bold",icon:"format-bold",command:"toggleBold",hint:"加粗"},{key:"italic",icon:"format-italic",command:"toggleItalic",hint:"斜体"},{key:"underline",icon:"format-underline",command:"toggleUnderline",hint:"下划线"},{key:"strikethrough",icon:"format-strike",command:"toggleStrike",hint:"删除线"}],this.listButtons=[{key:"bulleted",icon:"format-list-bulleted",slashName:"Bulleted List",hint:"无序列表"},{key:"numbered",icon:"format-list-numbers",slashName:"Numbered List",hint:"有序列表",iconClass:"text-lg"}],this.otherButtons=[{key:"todo",icon:"checkbox",slashName:"To-do List",hint:"待办事项"},{key:"link",icon:"text-link",command:"toggleLink",hint:"链接",iconClass:"text-lg"},{key:"image",icon:"image",slashName:"Image",hint:"插入图片"},{key:"file",icon:"file",slashName:"Attachment",hint:"上传附件"}],this.basicButtons=[{key:"code",icon:"code-block",slashName:"Code Block",hint:"代码块"},{key:"quote",icon:"icon-quote",slashName:"Quote",hint:"引用"},{key:"divider",icon:"add-divider",slashName:"Divider",hint:"分割线"},{key:"inLineEquation",icon:"sigma",slashName:"Inline equation",hint:"内嵌公式"},{key:"equation",icon:"sigma-box",slashName:"Equation",hint:"公式"},{key:"simpleTable",icon:"table",slashName:"简单表格",hint:"简单表格"}],this.databaseButtons=[{key:"table",icon:"data-table",slashName:"Table View",hint:"表格视图"},{key:"kanban",icon:"kanban-box",slashName:"Kanban View",hint:"看板视图"}],this.colorList=[{key:"default",value:"#30394A"},{key:"red",value:"#C62222"},{key:"orange",value:"#D34F0B"},{key:"yellow",value:"#B67C04"},{key:"green",value:"#149343"},{key:"teal",value:"#0782A0"},{key:"blue",value:"#2159D3"},{key:"purple",value:"#842ED3"},{key:"grey",value:"#7A7A7A"}],this.fontSizeItems=[{text:"文本",value:"text",slashName:"Text"},{text:"标题 1",value:"h1",slashName:"Heading 1"},{text:"标题 2",value:"h2",slashName:"Heading 2"},{text:"标题 3",value:"h3",slashName:"Heading 3"},{text:"标题 4",value:"h4",slashName:"Heading 4"},{text:"标题 5",value:"h5",slashName:"Heading 5"},{text:"标题 6",value:"h6",slashName:"Heading 6"}],this.fullscreen$=fe(!1),this.syncSelectionRange=()=>{var t;const e=this.checkEditor(!0);e&&e.selection.std.range.syncTextSelectionToRange((t=e.selection.value)==null?void 0:t[0])},this.checkEditor=e=>{var n;const{editor:t}=this.props;if(t)try{const s=t.editor;if(!s)return;const r=s.host;return!r||e&&!((n=r.selection.value)!=null&&n.length)?void 0:r}catch{return}},this.handleColorChange=e=>{var r;const t=this.checkEditor(!0);if(!t||(((r=this.getColor("color"))==null?void 0:r.value)||"")===e)return;const s=this.colorList.find(o=>o.value===e);t.selection.std.command.exec("formatText",{textSelection:t.selection.value[0],styles:{color:`var(--affine-text-highlight-foreground-${s==null?void 0:s.key})`}}),this.updateToolbarState()},this.handleBackgroundChange=e=>{var r;const t=this.checkEditor(!0);if(!t||(((r=this.getColor("background"))==null?void 0:r.value)||"")===e)return;const s=this.colorList.find(o=>o.value===e);t.selection.std.command.exec("formatText",{textSelection:t.selection.value[0],styles:{background:`var(--affine-text-highlight-${s==null?void 0:s.key})`}}),this.updateToolbarState()},this.handleFormat=e=>{var n,s;const t=this.checkEditor();if(t){if(e=="toggleLink"){(s=(n=t.selection.value[0])==null?void 0:n.from)!=null&&s.length?t.selection.std.command.exec(e):this.callSlashMenuAction("Link");return}t.selection.std.command.exec(e),this.updateToolbarState()}},this.callSlashMenuAction=e=>{var t;return(t=this.props.editor)==null?void 0:t.callSlashMenuAction(e)},this.renderButton=e=>{const{key:t,icon:n,command:s,hint:r,slashName:o,iconClass:a}=e,l=this._toolbarState[t];return g(we,{key:t,className:U("ghost",l?"text-primary":""),icon:n,iconClass:a,hint:r,onClick:()=>{o?this.callSlashMenuAction(o):s&&this.handleFormat(s)}})},this._toggleFullscreen=()=>{var e;na({target:this.props.fullscreenTarget||((e=this.props.editor)==null?void 0:e.element),afterEnter:()=>{v("body").addClass("is-editor-fullscreen"),this.fullscreen$.value=!0},afterExit:()=>{v("body").removeClass("is-editor-fullscreen"),this.fullscreen$.value=!1}})}}componentDidMount(){this.initColorPicker(),this.initSelectionListener()}componentDidUpdate(e){e.editor!==this.props.editor&&this.initSelectionListener()}componentWillUnmount(){this.colorPicker&&this.colorPicker.destroy(),this.bgColorPicker&&this.bgColorPicker.destroy(),this.removeSelectionListener()}async ensureEditor(){await Dn(500);const{editor:e}=this.props;return e?await e.ensureEditor():null}initColorPicker(){this.colorPickerRef&&(this.colorPicker=new xs(this.colorPickerRef,{className:"btn ghost px-2",icon:"icon-text-color",hint:"文字颜色",colors:["#30394A","#C62222","#D34F0B","#B67C04","#149343","#0782A0","#2159D3","#842ED3","#7A7A7A"],onChange:e=>this.handleColorChange(e),onClick:()=>this.syncSelectionRange()})),this.bgColorPickerRef&&(this.bgColorPicker=new xs(this.bgColorPickerRef,{className:"btn ghost px-2",icon:"pencil-alt",hint:"文字背景颜色",colors:["#C62222","#D34F0B","#B67C04","#149343","#0782A0","#2159D3","#842ED3","#7A7A7A"],onChange:e=>this.handleBackgroundChange(e),onClick:()=>this.syncSelectionRange()}))}initSelectionListener(){this.ensureEditor().then(e=>{if(!e)return;const t=e.host;t==null||t.selection.slots.changed.on(()=>{this.updateToolbarState()})})}getColor(e){const t=this._toolbarState[e],n=e=="color"?/var\(--affine-text-highlight-foreground-(.*?)\)/:/var\(--affine-text-highlight-(.*?)\)/,s=t==null?void 0:t.match(n),r=s?s[1]:"";return this.colorList.find(o=>o.key===r)}updataColorPicker(){var e,t;if(this.colorPicker){const n=this.getColor("color");(e=this.colorPicker.$)==null||e.changeState({value:(n==null?void 0:n.value)||""})}if(this.bgColorPicker){const n=this.getColor("background");(t=this.bgColorPicker.$)==null||t.changeState({value:(n==null?void 0:n.value)||""})}}removeSelectionListener(){const e=this.checkEditor();e==null||e.selection.slots.changed.dispose()}updateToolbarState(){const e=this.checkEditor();if(!e){this._toolbarState={bold:!1,italic:!1,underline:!1,strikethrough:!1,bulleted:!1,numbered:!1,fontSize:"text",color:"",background:""};return}const n=e.selection.std.command.exec("getTextStyle").textStyle,{selectedModels:s}=e.selection.std.command.exec("getSelectedModels"),r=s==null?void 0:s[0],o=(r==null?void 0:r.flavour)==="affine:list",a=o?r==null?void 0:r.type:null,c=(r==null?void 0:r.flavour)==="affine:paragraph"&&["h1","h2","h3","h4","h5","h6"].includes(r==null?void 0:r.type)?r==null?void 0:r.type:"text";this._toolbarState={bold:n.bold||!1,italic:n.italic||!1,underline:n.underline||!1,strikethrough:n.strike||!1,bulleted:o&&a==="bulleted",numbered:o&&a==="numbered",fontSize:c,color:(n==null?void 0:n.color)||"",background:(n==null?void 0:n.background)||""},this.forceUpdate(),this.updataColorPicker()}render(){this.fontSizeItems.forEach(r=>{r.onClick=this.callSlashMenuAction.bind(this,r.slashName)});const e=this._toolbarState.fontSize,t=this.fontSizeItems.filter(r=>r.value==e),{fullscreenTarget:n}=this.props,s=[{key:"two_equal",icon:"columns-2",text:"1:1",onClick:this.callSlashMenuAction.bind(this,"two_equal")},{key:"two_left_sidebar",icon:"columns-4",text:"1:2",onClick:this.callSlashMenuAction.bind(this,"two_left_sidebar")},{key:"two_right_sidebar",icon:"columns-4",text:"2:1",onClick:this.callSlashMenuAction.bind(this,"two_right_sidebar")},{key:"three_equal",icon:"columns-3",text:"1:1:1",onClick:this.callSlashMenuAction.bind(this,"three_equal")}];return g("div",{className:"doc-toolbar flex items-center flex-wrap gap-1 w-full bg-white border-b z-10 p-1",style:"min-height: 40px;"},g(rn,{className:"w-20",type:"ghost",text:t[0].text,trigger:"hover",items:this.fontSizeItems}),g("div",{className:"divider",style:"height: unset; margin-left: -4px;"}),this.formatButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),g("div",{ref:r=>this.colorPickerRef=r}),g("div",{ref:r=>this.bgColorPickerRef=r}),g("div",{className:"divider",style:"height: unset;"}),this.listButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),this.otherButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),this.basicButtons.map(this.renderButton),g(rn,{type:"ghost",icon:"columns-3",trigger:"hover",items:s}),g("div",{className:"divider",style:"height: unset;"}),this.databaseButtons.map(this.renderButton),n?g("div",{className:"flex-auto"}):null,n?g("button",{type:"button",className:"btn ghost square",onClick:this._toggleFullscreen},g("i",{class:`icon icon-${this.fullscreen$.value?"fullscreen-exit":"fullscreen"}`})):null)}};Nv.defaultProps={className:""};class xu extends ve{}xu.NAME="EditorToolbar",xu.Component=Nv;const wn=class Ie extends qe{constructor(){super(...arguments),this._inputs={},this._lastChangeContent="",this._assetsMap=new Map,this._isEmpty=!0,this._hocuspocusProvider=null,this._zentaoRelations=fe([]),this._blockRelationsMap=Ce(()=>this._zentaoRelations.value.reduce((n,s)=>(s.blocks.forEach(r=>{const o=n.get(r);if(o){if(o.some(a=>a.objectID===s.objectID&&a.objectType===s.objectType))return;o.push(s)}else n.set(r,[s])}),n),new Map)),this.handleRenderBlockSide=(e,t,n)=>{const{onRenderBlockSide:s,pickActions:r}=this.options;if(s)return s.call(this,e,t,n);if(r&&t.picked){const o=document.createElement("div"),a=Fe.render(r,[e,t],{className:"editor-block-pick-options p-px",size:"sm",btnType:"default"},this);return ms(a,o),{html:`<div onclick="event.stopPropagation()">${o.innerHTML}</div>`}}},this.handleRenderBlockFooter=(e,t,n)=>{const{onRenderBlockRelation:s,onRenderBlockFooter:r}=this.options;if(r)return r.call(this,e,t,n);const o=t.relations||[];if(o.length)return n.html`<div class="editor-zentao-relations pointer-events-auto pt-2 flex flex-wrap gap-2 pl-px">${o.map((a,l)=>{if(s){const c=s.call(this,a,l,e,t,n);if(c!==void 0)return typeof c=="object"&&c&&"html"in c?n.unsafeHTML(c.html):c}return n.html`<div class="editor-zentao-relation text-sm flex items-center gap-0.5 group"><a href="${a.url}" data-toggle="modal"><i class="icon icon-${a.objectType}"></i> #${a.objectID} ${a.name}</a><button class="btn size-xs square ghost opacity-0 group-hover:opacity-100" type="button" zui-command=".~removeZentaoRelation/${encodeURIComponent(a.id)}"><i class="icon icon-text-unlink"></i></button></div>`})}</div>`},this.handlePickBlock=(e,t)=>{var r;if(!this.options.onlyPickContinuous)return;const n=this.getBlocksLayout(),s=(r=n.get(e.blockId))==null?void 0:r.order;if(typeof s=="number"){this.setBlockState(e.blockId,{picked:t});const o=Array.from(n.values()),a=this.getAllBlockStates();let l=Number.MAX_SAFE_INTEGER,c=-1;o.forEach(({id:h,order:d})=>{var f,p;(p=(f=a[h])==null?void 0:f.value)!=null&&p.picked&&(l=Math.min(l,d),c=Math.max(c,d))}),(c>=0||l>=0&&l<Number.MAX_SAFE_INTEGER)&&(t?o.forEach(({id:h,order:d})=>{(d>l&&d<s||d>s&&d<c)&&this.setBlockState(h,{picked:t})}):o.forEach(({id:h,order:d})=>{d>s&&this.setBlockState(h,{picked:t})}))}return"canceled"}}get collection(){if(!this._collection)throw new Error("Editor._collection must be initialized!");return this._collection}get schema(){if(!this._schema)throw new Error("Editor._schema must be initialized!");return this._schema}get doc(){if(!this._doc)throw new Error("Editor._doc must be initialized!");return this._doc}get docID(){return this.doc.id}get editor(){if(!this._editor)throw new Error("Editor._editor must be initialized!");return this._editor}get host(){return this.editor.host}get title(){var e;return((e=this.doc.meta)==null?void 0:e.title)??this.options.title??"Untitled"}get tags(){var e;return((e=this.doc.meta)==null?void 0:e.tags)??this.options.tags??[]}get context(){var r,o;const e=(r=this.doc.root)==null?void 0:r.id;if(!e||!this.host)return;const t=this.host.view.getBlock(e);if(!t)return;const n=this.host.selection.find("text");if(!n)return;const s=(o=this.host.doc.getBlock(n.blockId))==null?void 0:o.model;if(s)return{rootComponent:t,model:s}}get isEmpty(){return Ie.Module.utils.isEmptyDoc(this.doc)}get rootService(){try{return this.editor.std.getService("affine:page")}catch{return null}}get zentaoRelations(){return this._zentaoRelations.value}get blockRelationsMap(){return this._blockRelationsMap.value}get content(){return this._lastChangeContent}ensureEditor(){return new Promise(e=>{this._editor?e(this._editor):this.one("inited",()=>{e(this._editor)})})}async readyToUseHocuspocus(e,t=!0){try{if(!e)return null;const n=typeof e=="string"?JSON.parse(e):e,{Y:s,utils:r}=Ie.Module,o=n.meta.id,{hocuspocusUrls:a,token:l}=this.options,c=a==null?void 0:a[0];if(!c||!l)return null;if(t&&(await(await fetch(`${c}/doc/${this.options.docID}@${o}/exists`)).json()).data)return o;const h=await r.convertSnapshotToYDoc(n,this.getBlockSources());if(!h)return null;const d=s.encodeStateAsUpdate(h);return(await(await fetch(`${c}/doc/${this.options.docID}@${o}/init`,{method:"POST",body:d,headers:{"Content-Type":"application/octet-stream",token:l}})).json()).result==="success"?o:null}catch(n){return console.error("Ready to use hocuspocus error:",n),null}}_initExtraStates(){const{extraStates:e,showPickCheck:t}=this.options;e&&Object.entries(e).forEach(([n,s])=>{Ie.setDocState(this.doc.id,n,s)}),this.clearDocStates(),this.setDocStates({...e,showPickCheck:t}),this.resetZentaoRelations(this.options.zentaoRelations||[]),this._zentaoRelationsEffect=_t(()=>{if(!this._doc||this.options.zentaoRelations===!1)return;const n=this._blockRelationsMap.value,s=this.getAllBlockStates(),r=new Set(Object.keys(s));n.entries().forEach(([l,c])=>{this.setBlockState(l,{relations:c.filter(h=>h.blocks[h.blocks.length-1]===l),marked:!!c.length}),r.delete(l)}),r.forEach(l=>{this.setBlockState(l,{relations:[],marked:!1})});const{zentaoRelationsName:o,htmlName:a}=this.options;o&&this._setInput(o,JSON.stringify(this._zentaoRelations.value.reduce((l,c)=>{const h=c.blocks.filter(d=>this.doc.getBlock(d));return h.length&&l.push({objectType:c.objectType,objectID:c.objectID,name:c.name,blocks:h}),l},[]))),a&&this.getHtml().then(l=>{this._setInput(a,l)})})}getBlockView(e){var n,s;const t=(s=(n=this._editor)==null?void 0:n.host)==null?void 0:s.view;return t==null?void 0:t.getBlock(e)}async afterInit(){const{schema:e,collection:t,content:n,mode:s,contentType:r,title:o,tags:a,uid:l,onLoadingLibChange:c,useHocuspocus:h,height:d,minHeight:f,maxHeight:p,toolbar:y,readonly:b}=this.options,{store:w}=await Ie.loadModule(c);if(this.destroyed)return;const{DocCollection:x}=w;if(this._uid=l||Ot(13),h){const{checkExists:D=!0}=typeof h=="object"?h:{},N=await this.readyToUseHocuspocus(n,D);if(N){await this.initHocuspocusDoc({docId:N,mode:s});return}}if(this._schema=e||Ie.createSchema(),this._collection=t||new x({schema:this.schema,blobSources:this.getBlockSources()}),this._collection.meta.initialize(),this._editor=Ie.createEditor(s),await this.updateDoc(n,r,o,a),this.doc.history.clear(),this._initExtraStates(),await this.syncData(!0),d){const D=Be(d);D&&v(this._editor).height(D)}if(f){const D=Be(f);D&&v(this._editor).css("min-height",D)}if(p){const D=Be(p);D&&v(this._editor).css("max-height",D).css("overflow-y","auto")}this.element.appendChild(this.editor),this.$element.addClass("affine-theme editor").on("syncData",()=>this.syncData()),this.$element.toggleClass("has-pick-checks",!!this.options.showPickCheck).toggleClass("only-pick-continuous",!!this.options.onlyPickContinuous),this.options.onClickHolder&&v(this.editor).on("zui-holder-node-click zui-holder-block-click",D=>{var N,A;(A=(N=this.options).onClickHolder)==null||A.call(N,{block:D.type==="zui-holder-block-click",holder:D.detail.holder,event:D,target:D.detail.target})});const{disableScrollOnSlashMenuShow:T}=this.options;if(T&&!v(T).data("zuiEditorSlashMenuObserver")){const D=new MutationObserver(N=>{for(const A of N){for(const z of Array.from(A.addedNodes))if(z.nodeType===1&&z.tagName==="AFFINE-SLASH-MENU"){ea(T,!0);break}for(const z of Array.from(A.removedNodes))if(z.nodeType===1&&z.tagName==="AFFINE-SLASH-MENU"){ea(T,!1);break}}});D.observe(document.body,{childList:!0,subtree:!1}),v(T).data("zuiEditorSlashMenuObserver",D)}if(!b&&y&&!this._toolbarElement){v('<div class="editor-toolbar" />').prependTo(this.$element);const D=this.$element.find(".editor-toolbar");this._toolbarElement=D[0],this._toolbar=new xu(D,{editor:this,...typeof y=="boolean"?{}:y})}}async initHocuspocusDoc({docId:e,mode:t}){const{store:n}=Ie.Module,{DocCollection:s}=n;this._schema=this.options.schema||Ie.createSchema(),this._collection=new s({schema:this.schema,blobSources:this.getBlockSources()}),this.collection.start(),this.collection.meta.initialize(),this._doc=this.collection.createDoc({id:e}),this.createHocuspocusProvider(),this.doc.load(),this._editor=Ie.createEditor(t),this.editor.doc=this.doc,this.element.appendChild(this.editor)}destroyHocuspocusProvider(){var e;(e=this._hocuspocusProvider)==null||e.destroy()}setDocReadonly(){this.options.readonly&&this.collection.awarenessStore.setReadonly(this.collection.getBlockCollection(this.doc.id),!0)}getBlockSources(){const{onDownload:e,downloadUrl:t,onUpload:n}=this.options;if(!e&&!n&&!t)return;const s=this._assetsMap;return{main:{name:this._uid,readonly:!1,get:async r=>{const o=s.get(r);if(o)return o;if(e)try{const a=await e.call(this,{key:r,editorID:this._uid}),l=a==null?void 0:a.blob;if(l)return s.set(r,l),l}catch(a){console.error("[ZUI] download file failed",a)}else if(t){let a=t;if(r.startsWith("data:"))a=r;else if(r.startsWith("file:"))a=ut("file","read",`fileID=${r.substring(5)}`);else if(/https?:\/\//.test(r)){const h=window.EDITOR_IMAGE_PROXY_ENDPOINT;a=h?`${h}?url=${encodeURIComponent(r)}`:r}else a=De(t,{objectType:"doc",objectID:this.options.docID,gid:btoa(`g-${r}`),title:"",extra:"editor"});const c=await(await fetch(a)).blob();return s.set(r,c),c}return null},set:async(r,o)=>(s.set(r,o),n&&await n.call(this,{key:r,blob:o,editorID:this._uid}),r),delete:async r=>{s.delete(r)},list:async()=>Array.from(s.keys())}}}render(e,t){super.render(e,t),t&&this.updateDoc(this.options.content,void 0,this.options.title)}async getHtml(e){var l;const{store:t}=Ie.Module,n=this.doc,s=n.collection;if(e||(e=new t.Job({collection:s}).docToSnapshot(n)),!e)return"";const{onRenderBlockRelationHtml:r,downloadUrl:o}=this.options;return await Ie.convertToHtml(e,s,o,this.blockRelationsMap,(c,h)=>r?h.map((d,f)=>r.call(this,d,f)).join(" &nbsp; "):"",(l=this.options.onConvert)==null?void 0:l.bind(this))}async export(e="pdf",t){const{blocks:n}=Ie.Module,s=this.editor.std.get(n.ExportManager);return s?(v("body").addClass("editor-is-exporting"),e==="png"?await s.exportPng():e==="markdown"?await this.exportMarkdown():e==="json"?await this.exportSnapshot(t):e==="html"?await this.exportHtml():await s.exportPdf(),v("body").removeClass("editor-is-exporting"),!0):!1}exportMarkdown(){var t;const e=(t=this.rootService)==null?void 0:t.transformers.markdown;return e==null?void 0:e.exportDoc(this.doc)}exportHtml(){var t;const e=(t=this.rootService)==null?void 0:t.transformers.html;return e==null?void 0:e.exportDoc(this.doc)}async exportSnapshot(e){const t=await this.toSnapshot(),n=new Blob([JSON.stringify(t)],{type:"application/json"});Xn(n,`${e??(t==null?void 0:t.meta.title)??this.title}.json`)}exportPDF(){return this.export("pdf")}exportPNG(){return this.export("png")}getBlock(e){var t;if(e instanceof HTMLElement&&(e=((t=e.closest("[data-block-id]"))==null?void 0:t.getAttribute("data-block-id"))||""),typeof e=="string")return this.doc.getBlock(e)}deleteBlock(e){const t=this.getBlock(e);if(t)return this.doc.deleteBlock(t.model),!0}updateBlock(e,t){const n=this.getBlock(e);n&&this.doc.updateBlock(n.model,t)}_createEmptyDoc(){const e=Ie.createEmptyDoc(this.collection);return this._isEmpty=!0,e}async _importSnapshot(e){const{store:t}=Ie.Module;let n=e;const s=this.collection,r=new t.Job({collection:s});let o;try{const{onImportSnapshot:a}=this.options;if(a){const l=a(n);l&&(n=l)}o=await r.snapshotToDoc(n),o&&s.setDocMeta(o.id,{createDate:n.meta.createDate,tags:n.meta.tags})}catch(a){console.error("[ZUI] parse doc content error:",a)}return o||this._createEmptyDoc()}async importHTML(e){return await Ie.importHtml(e,this.collection)||this._createEmptyDoc()}async importConfluence(e){return await Ie.importConfluence(e,this.collection)||this._createEmptyDoc()}async importMarkdown(e){const{blocks:t}=Ie.Module,n=this.collection,s=await t.MarkdownTransformer.importMarkdownToDoc({collection:n,markdown:e});return s?n.getDoc(s)||this._createEmptyDoc():this._createEmptyDoc()}_migrateFrom(e){return e.$migrate==="html"?this.importHTML(e.$data):e.$migrate==="markdown"?this.importMarkdown(e.$data):e.$migrate==="confluence"?this.importConfluence(e.$data):this._createEmptyDoc()}_getInput(e){if(!this._inputs[e]){const t=document.createElement("input");t.type="hidden",t.name=e,t.value="",this.element.appendChild(t),this._inputs[e]=t}return this._inputs[e]}_setInput(e,t){const n=this._getInput(e);n.value!==t&&(n.value=t,v(n).trigger("change"))}async updateDoc(e="",t="snapshot",n,s){var c,h,d;if(this._doc&&this._doc.dispose(),e==="")this._doc=this._createEmptyDoc();else if(t==="doc"||t==="snapshot"||typeof e=="object")try{for(;typeof e=="string";)e=JSON.parse(e);e.$migrate?this._doc=await this._migrateFrom(e):this._doc=await this._importSnapshot(e),this._lastChangeContent=typeof e=="string"?e:JSON.stringify(e)}catch(f){this._doc=this._createEmptyDoc(),console.error("[ZUI] parse doc content error:",f)}else t==="html"?this._doc=await this.importHTML(e):t==="markdown"?this._doc=await this.importMarkdown(e):t==="confluence"?this._doc=await this.importConfluence(e):this._doc=this._createEmptyDoc();const{readonly:r,name:o,htmlName:a}=this.options;if(this.setDocReadonly(),o&&(this._setInput("uid",this._uid),this._setInput(o,JSON.stringify(e))),a){const f=await this.getHtml();this._setInput(a,f)}this.editor.doc=this._doc;const l=()=>{this._isEmpty=this.isEmpty,this.$element.toggleClass("is-editor-empty",!!this._isEmpty)};return this._doc.slots.blockUpdated.on(()=>{l(),this.trySyncData()}),l(),this.$element.toggleClass("is-readonly",!!r).toggleClass("is-editing",!r),n!==void 0&&n!==((c=this._doc.meta)==null?void 0:c.title)&&this.updateTitle(n),s!==void 0&&s.join(",")!==((d=(h=this._doc.meta)==null?void 0:h.tags)==null?void 0:d.join(","))&&this.updateTags(s),this._doc}async updateTags(e){const t=this.doc;t.collection.setDocMeta(t.id,{tags:e.map(n=>n.trim()).filter(Boolean)})}async updateTitle(e){var s;const t=this.doc,n=t.root.title;n&&(n.clear(),n.insert(e,0)),t.collection.setDocMeta(t.id,{title:(s=t.root)==null?void 0:s.title.toString()})}trySyncData(){this._updateTimer=window.setTimeout(()=>{this.syncData()},200)}async syncData(e){var s,r;const t=await this.toSnapshot();if(!t)return this._lastChangeContent="",!1;const n=JSON.stringify(t);if(this._lastChangeContent===n)return!1;if(this._lastChangeContent=n,this.options.name&&this._setInput(this.options.name,n),this.options.htmlName){const o=await this.getHtml();this._setInput(this.options.htmlName,o)}if(!e){const o={uid:this._uid,content:n,title:t.meta.title,contentType:"doc",isEmpty:this._isEmpty};(r=(s=this.options).onChange)==null||r.call(s,o,t)}}async getData(e){return e===void 0&&(e=await this.toSnapshot()),e?{content:JSON.stringify(e),title:e.meta.title,uid:this._uid}:{content:"",title:"",uid:this._uid}}async toSnapshot(){return Ie.toSnapshot(this.doc)}insertText(e,t,n){if(n=n||this.context,!n)return;const{rootComponent:s,model:r}=n;if(!r.text){console.error("Can't insert text! Text not found");return}Ie.Module.components.insertContent(s.host,r,e,t)}insertBlock(e,t,n,s=!1){var f;if(n=n||this.context,!n)return;const{rootComponent:r,model:o}=n,a=r.doc.getParent(o);if(!a)return;const l=a.children.indexOf(o),c=e.includes(":")?e:`affine:${e}`,h=(((f=o.text)==null?void 0:f.toString())??"").trim().length,d=r.doc.addBlock(c,t,r.doc.getParent(o),h&&!s?l+1:l);return s&&this.doc.deleteBlock(o),d}insertComponent(e,t,n){const s=typeof e=="string"?{name:e}:e;return this.insertBlock("affine:embed-zui-component",{options:t,...s},n)}insertIframe(e,t){const n=typeof e=="string"?{name:e}:e;return this.insertBlock("affine:embed-zui-iframe",n,t)}insertHtmlBlock(e,t){const n=typeof e=="string"?{html:e}:e;return this.insertBlock("affine:embed-zui-html",n,t)}insertLazyBlock(e,t,n){const{content:s,...r}=t||{};return this.insertCustom({content:s,fetcher:e},r,n)}insertCustom(e,t,n){return this.insertBlock("affine:embed-zui-custom",{content:e,...t},n)}insertHolderBlock(e,t,n,s){return this.insertBlock("affine:zui-holder",{name:e,text:t,data:n},s)}insertHolderText(e,t,n,s){return this.insertText(" ",{holder:{id:Ot(10),name:e,...typeof t!="object"?{text:String(t)}:t,data:n}},s)}updateHolderText(e,t){if(e.id===void 0&&e.name===void 0)return console.error("[ZUI] update holder text failed, id or name is required"),!1;const{id:n,name:s}=e,r=this.$element.find(`.affine-zui-holder${e.id!==void 0?`[data-holder-id="${n}"]`:`[data-holder-name="${s}"]`}`);return r.length?(r.each(function(){v(this).parent("affine-zui-holder-node")[0].updateHolder(e,t)}),!0):(console.warn("[ZUI] update holder text failed, holder not found"),!1)}callSlashMenuAction(e,t){if(t=t||this.context,!t){console.error(`[ZUI] call action slash menu "${e}" failed, context is undefined.`);return}const n=Ie.filterEnabledSlashMenuItems(Ie.Module.blocks.AffineSlashMenuWidget.DEFAULT_CONFIG.items,t);let s;for(const r of n){if((r.name===e||r.key===e)&&(s=r),r.subMenu){for(const o of r.subMenu)if(o.name===e||o.key===e){s=o;break}}if(s)break}return s==null?void 0:s.action(t)}async createHocuspocusProvider(){var c;const e=!!((c=window.config)!=null&&c.debug);e&&console.log("> connect to hocuspocus");const t=this._doc;if(!t)throw new Error("Hocuspocus provider needs a doc.");const{awarenessUser:n,hocuspocusUrls:s,token:r}=this.options;if(!n)throw new Error("Hocuspocus provider needs awarenessUser");if(!s||!s[1])throw new Error("Hocuspocus provider needs hocuspocusUrls");const o=t.awarenessStore.awareness,{hocuspocusProvider:a}=await Ie.loadModule(),l=new a.HocuspocusProvider({url:s[1],name:`${this.options.docID}@${t.id}`,document:t.spaceDoc,awareness:o,token:r,onAuthenticationFailed:h=>{var d,f,p;e&&console.log("> onAuthenticationFailed",h),(f=(d=this.options).onAuthenticationFailed)==null||f.call(d,h),(p=this._hocuspocusProvider)==null||p.destroy()},onAwarenessUpdate:h=>{var d,f;e&&console.log("> Hocuspocus awareness update",h),(f=(d=this.options).onAwarenessUpdate)==null||f.call(d,h)},onConnect:()=>{var h,d;e&&console.log("> Hocuspocus connect"),(d=(h=this.options).onConnect)==null||d.call(h)},onDisconnect:({event:h})=>{var d,f;e&&console.log("> Hocuspocus disconnect",h),(f=(d=this.options).onDisconnect)==null||f.call(d,h)},onClose:({event:h})=>{var d,f,p;e&&console.log(">>> Hocuspocus close",h),h.code===4205&&h.reason==="Reset Connection"&&((d=this._hocuspocusProvider)==null||d.destroy(),(p=(f=this.options).onClose)==null||p.call(f,h))},onMessage:h=>{e&&console.log("> Hocuspocus message",h)},onOutgoingMessage:h=>{e&&console.log("> Hocuspocus outgoing message",h)},onStateless:h=>{e&&console.log("> Hocuspocus stateless",h)},onSynced:h=>{e&&console.log(">>> Hocuspocus synced!",h),this._hocuspocusProvider=l,this.setDocReadonly()},onStatus:h=>{e&&console.log("> Hocuspocus status",h)},onDestroy:()=>{e&&console.log(">>> Hocuspocus destroy"),this._hocuspocusProvider=null}});l.setAwarenessField("user",n)}destroy(){var e,t,n;super.destroy(),(e=this._doc)==null||e.dispose(),this._editor&&(v(this._editor).off("zui-holder-node-click zui-holder-block-click"),this._editor.remove());for(const s of Object.values(this._inputs))s.remove();(t=this._hocuspocusProvider)==null||t.destroy(),(n=this._zentaoRelationsEffect)==null||n.call(this),this._updateTimer&&clearTimeout(this._updateTimer)}queryZentaoRelations(e){const t=this._zentaoRelations.value,{block:n,objectType:s,objectID:r}=e;return t.filter(o=>(n===void 0||o.blocks.includes(n))&&(s===void 0||o.objectType===s)&&(r===void 0||o.objectID===r))}getBlocksLayout(e){var o,a;e=e||Object.keys(this.doc.blocks.value);const t=(a=(o=this._editor)==null?void 0:o.host)==null?void 0:a.view,n=this._blockRelationsMap.value,s=[],r=e.reduce((l,c,h)=>{const d=t==null?void 0:t.getBlock(c);return l.set(c,{id:c,block:this.doc.getBlock(c),component:d,order:h,relations:n.get(c)||[]}),d&&s.push(d),l},new Map);return s.sort((l,c)=>{const h=l.getBoundingClientRect(),d=c.getBoundingClientRect(),f=l.closest("affine-zui-layout"),p=c.closest("affine-zui-layout");return f===p&&f?h.left-d.left||h.top-d.top:h.top-d.top||h.left-d.left}),s.forEach((l,c)=>{r.get(l.blockId).order=c}),r}resetZentaoRelations(e=[]){const t=this.getBlocksLayout(),n=e.map((s,r)=>({...s,index:r,id:Ot(10),blocks:[...s.blocks].sort((o,a)=>{const l=t.get(o),c=t.get(a);return((l==null?void 0:l.order)||Number.MAX_SAFE_INTEGER)-((c==null?void 0:c.order)||Number.MAX_SAFE_INTEGER)})}));this._zentaoRelations.value=n}setZentaoRelations(e){const t=this._zentaoRelations.value,n=t.reduce((s,r,o)=>(r.index=o,s.set(r.id,r),s),new Map);for(const s of e){let r="id"in s?s:{...s,id:Ot(10)};const o=n.get(r.id);o&&(r={...o,...r}),t.push(r)}this.resetZentaoRelations(t)}setZentaoRelationsToPickedBlocks(e,t){const n=this.getPickedBlocks(),s=e.map(o=>({...o,blocks:n}));this.setZentaoRelations(s);const{cancelPicked:r=!0}=t||{};r&&this.cancelPickedBlocks()}removeZentaoRelation(e){const t=this._zentaoRelations.value;this.resetZentaoRelations(t.filter(n=>n.id!==e))}getPickedBlocks(){return Object.entries(this.getAllBlockStates()).reduce((e,[t,n])=>(n.value.picked&&e.push(t),e),[])}cancelPickedBlocks(e){e=e||this.getPickedBlocks(),e.forEach(t=>this.setBlockState(t,{picked:!1}))}getDocStates(){return Ie.getDocStates(this.docID)}setDocStates(e){return Ie.setDocStates(this.docID,e)}clearDocStates(){return Ie.clearDocStates(this.docID)}getDocState(e,t){return Ie.getDocState(this.docID,e,t)}setDocState(e,t){return Ie.setDocState(this.docID,e,t)}setBlockState(e,t){return Ie.setBlockState(this.docID,e,t)}clearBlockState(e){return Ie.clearBlockState(this.docID,e)}getAllBlockStates(){return Ie.getAllBlockStates(this.docID)}static async loadModule(e){var t,n;if(!this.Module){if(e==null||e(!0),!this.Module){const s=await v.getLib("blocksuite");this.Module=s,(n=(t=s.zui).use)==null||n.call(t,{init:yh,create:ia,runJS:Dr}),this.slashMenuSettings.forEach(([r,o])=>{s.utils.setSlashMenu(this.formatSlashMenuItems(r),o)}),this.slashMenuSettings=[]}e==null||e(!1)}return this.Module}static formatSlashMenuItems(e){const t=this.Module,n=s=>r=>s.call(this.query(r.rootComponent),r);return e.map(s=>{if(typeof s=="object"&&s){if(typeof s.icon=="string"){let r=s.icon,o=t.icons[r];o===void 0&&(r.startsWith("icon-")||(r=`icon-${r}`),r.split(" ").includes("icon")||(r=`icon ${r}`),o=t.lit.html`<i class=${r}></i>`),s={...s,icon:o}}s.divider&&(s={groupName:"",...s}),s.action?s={...s,action:n(s.action)}:s.subMenu&&(s={...s,subMenu:this.formatSlashMenuItems(s.subMenu)})}return s})}static filterEnabledSlashMenuItems(e,t){return e.map(n=>typeof n=="function"?n(t):n).flat().filter(n=>n.showWhen?n.showWhen(t):!0).map(n=>"subMenu"in n?{...n,subMenu:this.filterEnabledSlashMenuItems(n.subMenu,t)}:{...n})}static setSlashMenu(e,t){this.Module?this.Module.utils.setSlashMenu(this.formatSlashMenuItems(e),t):this.slashMenuSettings.push([e,t])}static forEachBlock(e,t){t(e);for(const n of e.children)t(n),this.forEachBlock(n,t)}static createEditor(e){const{presets:t,blocks:n,utils:s}=Ie.Module;let r;const o=()=>s!=null&&s.patchPageRootSpec?s.patchPageRootSpec(n.PageEditorBlockSpecs):n.PageEditorBlockSpecs;return e==="full"?(r=new t.AffineEditorContainer,r.pageSpecs=o()):e==="edgeless"?r=new t.EdgelessEditor:(r=new t.PageEditor,r.specs=o()),r}static async convertToHtml(e,t,n,s,r,o){var T;const{store:a,blocks:l}=Ie.Module;let c;if(typeof e=="string")try{c=JSON.parse(e)}catch(D){console.error("[ZUI] parse doc content error:",D)}else c=e;if(!c)return"";t=t||new a.DocCollection({schema:new a.Schema().register(l.AffineSchemas)});const h=new a.Job({collection:t}),d=new l.HtmlAdapter(h),f=new Map;c.blocks.children=Mv(c.blocks.children,(D,N)=>{var A;if(N.flavour==="affine:bookmark"?D.push({...N,flavour:"affine:paragraph",props:{type:"text",text:{"$blocksuite:internal:text$":!0,delta:[{insert:N.props.title??N.props.url,attributes:{link:N.props.url}},N.props.description?{insert:` (${N.props.description})`}:null].filter(Boolean)}}}):D.push(N),r){const z=(A=s==null?void 0:s.get(N.id))==null?void 0:A.filter(O=>O.blocks[O.blocks.length-1]===N.id);z!=null&&z.length&&(D.push({id:Ot(10),flavour:"affine:paragraph",type:"block",props:{type:"text",text:{"$blocksuite:internal:text$":!0,delta:[{insert:`{{__ZENTAO_RELATIONS__${N.id}}}`}]}},children:[],version:1}),f.set(N.id,z))}return D});const p=await d.fromBlockSnapshot({snapshot:c.blocks,assets:h.assetsManager});let y=p.file;y=y.replace("<!--BlockSuiteDocTitlePlaceholder-->",(T=c.meta.tags)!=null&&T.length?`<p>${window.EDITOR_LANG.keywords||"Keywords"}: ${c.meta.tags.join(", ")}</p>`:""),r&&f.forEach((D,N)=>{y=y.replace(`{{__ZENTAO_RELATIONS__${N}}}`,r(N,D))});const b=document.createElement("template");b.innerHTML=y;const w=b.content;if(n&&p.assetsIds.length){const D=new Set(p.assetsIds),N=new Map;h.assets.entries().forEach(([A,z])=>{z.name&&N.set(z.name,{file:z,id:A})}),w.querySelectorAll("img").forEach(A=>{const z=A.getAttribute("alt")??"";let O=z.split(".").shift(),K;if(O&&D.has(O))K=h.assets.get(O);else{const Z=N.get(z);Z&&(O=Z.id,K=Z.file)}if(K){const Z=De(n,{gid:btoa(`g-${O}`),title:btoa(O),extra:"editor"});A.src=Z.replaceAll("&","{{__AMP__}}")+"#g="+btoa(O)}})}return w.querySelectorAll("pre.shiki>code").forEach(D=>{D.textContent=D.textContent}),w.querySelectorAll(".affine-block-children-container").forEach(D=>{D.childNodes.length||D.remove()}),w.querySelectorAll("ul.todo-list li").forEach(D=>{const N=D.querySelectorAll("input[checked]").length?"☑︎":"☐",A=document.createElement("p");A.textContent=`${N} ${D.textContent}`,D.replaceWith(A)}),o&&await o(w),(y.startsWith("<!doctype html><html><head><style>")?w.children[w.childElementCount-1].innerHTML:Array.from(w.children).map(D=>D.tagName!=="STYLE"?D.innerHTML:"").join(`
  60. `)).replaceAll("{{__AMP__}}","&")}static createEmptyDoc(e){const{store:t}=Ie.Module;e||(e=new t.DocCollection({schema:Ie.createSchema()}),e.start(),e.meta.initialize());const n=e.createDoc();n.load();const s=n.addBlock("affine:page",void 0),r=n.addBlock("affine:note",void 0,s);return n.addBlock("affine:paragraph",void 0,r),n}static toSnapshot(e){const{collection:t}=e;return new Ie.Module.store.Job({collection:t}).docToSnapshot(e)}static cleanHtml(e){const t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("img").forEach(s=>{const r=s.getAttribute("src");r!=null&&r.startsWith("/")&&s.setAttribute("src",`${location.origin}${r}`)}),t.innerHTML}static async importConfluence(e,t){const n=await Ie.loadModule(),{store:s}=n;try{t=t||new s.DocCollection({schema:Ie.createSchema()});const r=await n.blocks.ConfluenceTransformer.importConfluenceToDoc({collection:t,confluence:e});if(r)return t.getDoc(r)}catch(r){console.error("[ZUI] import confluence error:",r)}}static async importHtml(e,t){const{store:n,blocks:s}=await Ie.loadModule();try{t=t||new n.DocCollection({schema:Ie.createSchema()});const r=await s.HtmlTransformer.importHTMLToDoc({collection:t,html:this.cleanHtml(e)});if(r)return t.getDoc(r)}catch(r){console.error("[ZUI] import html error:",r)}}static async htmlToSnap(e,t){try{const{store:n,blocks:s}=await Ie.loadModule();t=t||new n.DocCollection({schema:Ie.createSchema()});const r=new n.Job({collection:t});return await new s.HtmlAdapter(r).toBlockSnapshot({file:this.cleanHtml(e)})}catch(n){console.error("[ZUI] html to snap error:",n)}}static async markdownToSnap(e,t){const{store:n,blocks:s}=await Ie.loadModule();t=t||new n.DocCollection({schema:Ie.createSchema()});const r=new n.Job({collection:t});return await new s.MarkdownAdapter(r).toBlockSnapshot({file:e})}static async markdownToHtml(e,t){typeof e=="string"&&(e={content:e,title:""});const n=await Ie.loadModule(),{store:s}=n;t=t||new s.DocCollection({schema:new s.Schema().register(n.blocks.AffineSchemas)});const r=await this.markdownToSnap(e.content,t);return this.convertToHtml({type:"page",meta:{id:Ot(),title:e.title,createDate:Date.now(),tags:[]},blocks:r},t)}static getDocStates(e){return Ie.Module.zui.getDocStates(e)}static setDocStates(e,t){return Ie.Module.zui.setDocStates(e,t)}static clearDocStates(e){return Ie.Module.zui.clearDocStates(e)}static getDocState(e,t,n){return Ie.Module.zui.getDocState(e,t,n)}static setDocState(e,t,n){return Ie.Module.zui.setDocState(e,t,n)}static setBlockState(e,t,n){return Ie.Module.zui.setBlockState(e,t,n)}static clearBlockState(e,t){return Ie.Module.zui.clearBlockState(e,t)}static getAllBlockStates(e){return Ie.Module.zui.getAllBlockStates(e)}static setGlobalConfig(e){window.EDITOR_CONFIG||(window.EDITOR_CONFIG={}),Object.assign(window.EDITOR_CONFIG,e)}static createSchema(){const{store:e,blocks:t}=Ie.Module,{AffineSchemas:n}=t,s=new e.Schema().register(n);return["affine:embed-linked-doc","affine:embed-youtube","affine:embed-figma","affine:embed-github","affine:embed-loom"].forEach(r=>s.flavourSchemaMap.delete(r)),s}static nanoid(){return Ot()}};wn.NAME="Editor",wn.DEFAULT={mode:"page",contentType:"snapshot",onlyPickContinuous:!0},wn.slashMenuSettings=[],wn.iframe=gS,wn.confluenceBlockMatcherMap={},wn.registerConfluenceBlockMatcher=(i,e)=>{if(wn.Module)wn.Module.blocks.ConfluenceAdapter.registerBlockMatcher(i,e);else if(typeof i=="object")for(const t in i)wn.confluenceBlockMatcherMap[t]=i[t];else wn.confluenceBlockMatcherMap[i]=e};let gt=wn;const Ev=be.getCode();v.registerLib("blocksuite",{src:[`editor/blocksuite/editor${Ev!=="zh_cn"?`.${Ev}`:""}.umd.cjs`,"editor/blocksuite/editor.css"],check:"BlockSuite"}),gt.register();let{maxUploadSize:oi}=window.config||{};oi&&(oi=typeof oi=="string"?$n(oi):oi,gt.setGlobalConfig({maxFileSize:oi,maxImageSize:oi}));class Qi extends gt{}Qi.DEFAULT={...gt.DEFAULT,mode:"page"},Qi.register(),Object.assign(window,{Editor:gt});const yS=ut("file","read","fileID={fileID}","{viewType}");gt.setGlobalConfig({imageSrcGetter:i=>{if(i.startsWith("{")&&i.endsWith("}")){const e=i.slice(1,-1),[t,n]=e.split(".");return yS.replace("{fileID}",t).replace("{viewType}",n)}return i},onRenderBlockFooter:(i,e,t)=>(gt.query(i)||Qi.query(i)).handleRenderBlockFooter(i,e,t),onRenderBlockSide:(i,e,t)=>(gt.query(i)||Qi.query(i)).handleRenderBlockSide(i,e,t),onPickBlock:(i,e)=>(gt.query(i)||Qi.query(i)).handlePickBlock(i,e)}),v(document).on("scroll",i=>{i.preventDefault()});class ai extends re{constructor(){super(...arguments),this._ref=pe()}get element(){return this._ref.current}get $(){return this._editor}init(e){var d,f,p;const{className:t,style:n,rootProps:s,ref:r,children:o,jsx:a,key:l,autoInit:c,...h}=this.props;return e={...h,...e},(d=this._editor)==null||d.destroy(),v(this.element).empty(),this._editor=new gt(this.element,e),(p=(f=this.props).onInit)==null||p.call(f,this._editor),this._editor}destroyHocuspocusProvider(){var e;(e=this._editor)==null||e.destroyHocuspocusProvider()}update(e){var t;(t=this._editor)==null||t.render(e)}getData(){var e;return(e=this._editor)==null?void 0:e.getData()}getHtml(){var e;return(e=this._editor)==null?void 0:e.getHtml()}componentDidMount(){this.props.autoInit&&this.init()}componentWillUnmount(){var e;(e=this._editor)==null||e.destroy()}render(e){const{className:t,style:n,rootProps:s,children:r}=e;return g("div",{ref:this._ref,className:U("editor",t),style:n,...s},r)}}ai.defaultProps={autoInit:!0};const Av=class tw extends re{constructor(e){super(e),this._editorRoot=pe(),this._titleEle=pe(),this._handleChange=()=>{var t,n;(n=(t=this.props).onChange)==null||n.call(t,this.data)},this._uid=e.uid??Ot(13).replaceAll("-","_")}get data(){var t,n,s;const e=((n=(t=this._editorRoot.current)==null?void 0:t.querySelector("zen-editor"))==null?void 0:n.value)??"";return{title:((s=this._titleEle.current)==null?void 0:s.value)??"",content:e,html:e,uid:this._uid,contentType:this.props.contentType}}_loadLib(){if(!customElements.get("zen-editor"))return v.getLib("zeneditor",{type:"module"})}async init(e){var y,b,w,x;customElements.get("zen-editor")||((b=(y=this.props).onLoadingLibChange)==null||b.call(y,!0),await this._loadLib(),(x=(w=this.props).onLoadingLibChange)==null||x.call(w,!1));const{readonly:t,content:n,contentType:s,bordered:r,placeholder:o,resizable:a=!0,fullscreenable:l=!0,uploadUrl:c="",injectCssPath:h,menubarMode:d}={...this.props,...e},f=[],p={class:"p-0 w-full h-full","upload-url":De(c,{uid:encodeURIComponent(this._uid),extra:"",field:"imgFile",gid:""}),readonly:!!t,"hide-ui":!!t,fullscreenable:!!l,resizable:!!a,"expose-editor":!0,markdown:s==="markdown",placeholder:o,css:tw.injectCSS(),"core-class":"editor_core","content-class":r?"bordered":"borderless","prose-class":"article","css-src":h,size:"sm","menubar-mode":d};f.push(`<zen-editor${Object.keys(p).reduce((T,D)=>{const N=p[D];return N===!0?T+=` ${D}`:N!==void 0&&N!==!1&&N!==null&&(T+=` ${D}="${N}"`),T},"")}>`,` <article slot="content">${n}</article>`,"</zen-editor>",`<textarea rows="1" style="display: none">${n}</textarea>`,`<input type="hidden" name="uid" value="${this._uid}" />`),v(this._editorRoot.current).html(f.join(`
  61. `))}async getData(){return Promise.resolve(this.data)}update(e){this.init(e)}componentDidMount(){this.props.autoInit&&this.init()}componentWillUnmount(){const e=this._editorRoot.current;e&&(e.innerHTML="")}_renderTitle(e){const{readonly:t,title:n,mode:s}=e;return s!=="full"?null:t?g("h1",{class:"zen-editor-title",style:"font-size: 40px"},n):g("input",{ref:this._titleEle,class:"zen-editor-title w-full font-bold",style:"font-size: 40px",defaultValue:n,onChange:this._handleChange})}render(e){const{className:t,readonly:n,height:s,children:r}=e;return g("div",{className:U("zen-editor-container relative",t),style:{height:s?Be(s):"100%"}},this._renderTitle(e),g("div",{ref:this._editorRoot,className:U("zen-editor h-full p-px mt-px rounded relative",n?"is-readonly":""),onChange:this._handleChange}),r)}static injectCSS(){return[".editor {border: unset; border-radius: unset; color: var(--color-fore)}",".editor.size-auto {min-height: 0;}","zen-editor-menu-item {display: inline-flex; align-items: center;}","zen-editor-menu-item > .menu-item {color: #64758B!important; display: inline-flex; align-items: center; justify-content: center;}","zen-editor-menu-item > .menu-item:hover {color: var(--color-primary-400)!important; background-color: var(--color-gray-100)!important;}","zen-editor-menu-item > .menu-item.is-active {color: var(--color-primary-400)!important; background-color: transparent!important; box-shadow: inset 0 0 0 1px var(--color-primary-300);}","zen-editor-menu-item > .menu-item.is-active:hover {background-color: var(--color-gray-200)!important;}","zen-editor-menu-item > .menu-item.is-active:not(:hover) {background-color: transparent!important;}","zen-editor-menu-item > .menu-item:has(.color):hover, zen-editor-menu-item > .menu-item:has(.color).is-active {background-color: transparent!important; box-shadow: inset 0 0 0 1px var(--color-primary-300)!important;}",".menubar {border-bottom: 1px solid #d8dbde!important; padding: 0.125rem;}",".menu-item-group {display: inline-flex; align-items: center}",".borderless.editor__content {padding: 0!important}",".tippy-content > div {border: 1px solid #d8dbde!important;}",".tippy-content zen-editor-menu-item {line-height: normal;}",".tippy-content zen-editor-menu-item .label {all: unset;}",".tiptap.ProseMirror {padding-top: 0.5rem;}",".tiptap.ProseMirror p {margin: 0;}"].join(`
  62. `)}};Av.defaultProps={autoInit:!0,injectCssPath:v.libRoot?`${v.libRoot}/zen-editor/zui-inject-style.css`:void 0};let Pv=Av;v.registerLib("zeneditor",{src:"zen-editor/zen-editor.esm.js",type:"module"});function Lv(i,e="yyyy年M月d日 hh:mm",t="M月d日 hh:mm"){const n=Ye(i);return xr(n,new Date)?Ze(n,t):Ze(n,e)}const vS=(i,e)=>{if(!e)return;const t=[];for(const n of e)t.includes(n.account)||t.push(n.account);return t.map(n=>i.getUserInfo(n))},_S=i=>i.map(t=>({account:t.account,realname:t.name,avatar:t.avatar})),bS=(i,e=!0)=>i?i.length<=3?i:e?[i[0],"more",i[i.length-1]]:[i[0],i[1],"more"]:null;function Rv(i){const{createDate:e,app:t,editors:n,creator:s}=i,r=t.getUserInfo(s),o=Ce(()=>{var h;const{editingUsers:c}=t.signals;return(h=c.value)!=null&&h.length?_S(c.value):null}),a=o.value||vS(t,n),l=bS(a,!o.value);return g("div",{className:"doc-users-bar flex flex-nowrap gap-2"},g("div",{className:"flex flex-nowrap gap-1 items-center"},g("div",{title:e?t.getLang("createdByUserAt",[{name:r.realname,time:Lv(e)}],"由 {name} 创建于 {time}"):r.realname},g(Ji,{className:"flex-none",size:"xs",user:r})),g("span",null,r.realname),g("span",null,t.getLang("created"))),l!=null&&l.length?g("div",{className:"flex flex-nowrap gap-1 items-center"},g("div",{className:"avatar-group flex-none",title:a==null?void 0:a.map(c=>c.realname).join("、")},l.map(c=>typeof c=="string"?g(Ji,{size:"xs",className:"rotate-90",icon:"ellipsis-v"}):g(Ji,{size:"xs",user:c}))),g("span",null,t.getLang(o.value?"editing":"edited"))):null)}function Vl(){return g("span",{className:"inline-block w-px h-3 bg-gray-400"})}const wS=()=>document.documentElement.lang.includes("zh"),ku=i=>{const e=Ye(i);if(wS())return Lv(e,"yyyy年MM月dd日","MM月dd日");const[,t,n,s]=e.toDateString().split(" "),r=new Date().getFullYear();return e.getFullYear()===r?`${t} ${n} `:`${t} ${n} ${s} `};function CS(i){var s;const{doc:e,app:t}=i;if(!e.status)return g("div",{className:"doc-editor-info flex text-gray gap-2 items-center py-2.5"},g(Rv,{app:t,createDate:e.addedDate,editors:e.editors,creator:e.addedBy}),g(Vl,null),g("span",null,t.getLang("notSaved")));const n=!!t.editingUsers.length;return g("div",{className:"doc-editor-info flex text-gray gap-2 items-center py-2.5"},t.renderCustom("editor-info-before",e),g(Rv,{app:t,createDate:e.addedDate,editors:e.editors,creator:e.addedBy}),g(Vl,null),g("span",null,t.getLang(e.status,t.getLang("released"))),g(Vl,null),g("span",{className:"hint","data-hint":Ye(e.addedDate).toLocaleString()},ku(e.addedDate),t.getLang("created")),n?g("span",{className:"-px-2"},t.getLang("autoSaveHint","所有编辑内容都会自动保存")):null,n?g("span",null,ku(new Date),t.getLang("edited")):e.editedDate?g("span",{className:"hint","data-hint":Ye(e.editedDate).toLocaleString()},ku(e.editedDate),t.getLang("edited")):null,g(Vl,null),g("div",{key:"views",className:"text-sm hint flex items-center gap-1","data-hint":t.getLang("viewsCount","阅读次数")},g($e,{icon:"eye"}),e.views||0),e.api||((s=t.props.privs)==null?void 0:s.collect)==="no"?null:g("div",{key:"star",className:`text-sm hint cursor-pointer ${e.isCollector?"text-warning":"text-gray"} flex items-center gap-1`,"data-hint":t.getLang(e.isCollector?"cancelCollection":"collect"),"zui-command":`collectDoc/${e.id}`},g(we,{size:"xs",type:"ghost",icon:e.isCollector?"star":"star-empty",text:e.collects||0})),t.renderCustom("editor-info-after",e))}class zv extends re{constructor(){super(...arguments),this._toolbarState={bold:!1,italic:!1,underline:!1,strikethrough:!1,bulleted:!1,numbered:!1,fontSize:"text",color:"",background:"",align:"left"},this.colorPickerRef=null,this.colorPicker=null,this.bgColorPickerRef=null,this.bgColorPicker=null,this.formatButtons=[{key:"bold",icon:"format-bold",command:"toggleBold",hint:"加粗"},{key:"italic",icon:"format-italic",command:"toggleItalic",hint:"斜体"},{key:"underline",icon:"format-underline",command:"toggleUnderline",hint:"下划线"},{key:"strikethrough",icon:"format-strike",command:"toggleStrike",hint:"删除线"}],this.listButtons=[{key:"bulleted",icon:"format-list-bulleted",slashName:"Bulleted List",hint:"无序列表"},{key:"numbered",icon:"format-list-numbers",slashName:"Numbered List",hint:"有序列表",iconClass:"text-lg"}],this.otherButtons=[{key:"todo",icon:"checkbox",slashName:"To-do List",hint:"待办事项"},{key:"link",icon:"text-link",command:"toggleLink",hint:"链接",iconClass:"text-lg"},{key:"image",icon:"image",slashName:"Image",hint:"插入图片"},{key:"file",icon:"file",slashName:"Attachment",hint:"上传附件"}],this.basicButtons=[{key:"code",icon:"code-block",slashName:"Code Block",hint:"代码块"},{key:"quote",icon:"icon-quote",slashName:"Quote",hint:"引用"},{key:"divider",icon:"add-divider",slashName:"Divider",hint:"分割线"},{key:"inLineEquation",icon:"sigma",slashName:"Inline equation",hint:"内嵌公式"},{key:"equation",icon:"sigma-box",slashName:"Equation",hint:"公式"},{key:"simpleTable",icon:"table",slashName:"简单表格",hint:"简单表格"}],this.databaseButtons=[{key:"table",icon:"data-table",slashName:"Table View",hint:"表格视图"},{key:"kanban",icon:"kanban-box",slashName:"Kanban View",hint:"看板视图"}],this.colorList=[{key:"default",value:"#30394A"},{key:"red",value:"#C62222"},{key:"orange",value:"#D34F0B"},{key:"yellow",value:"#B67C04"},{key:"green",value:"#149343"},{key:"teal",value:"#0782A0"},{key:"blue",value:"#2159D3"},{key:"purple",value:"#842ED3"},{key:"grey",value:"#7A7A7A"}],this.fontSizeItems=[{text:"文本",value:"text",slashName:"Text"},{text:"标题 1",value:"h1",slashName:"Heading 1"},{text:"标题 2",value:"h2",slashName:"Heading 2"},{text:"标题 3",value:"h3",slashName:"Heading 3"},{text:"标题 4",value:"h4",slashName:"Heading 4"},{text:"标题 5",value:"h5",slashName:"Heading 5"},{text:"标题 6",value:"h6",slashName:"Heading 6"}],this.syncSelectionRange=()=>{var t;const e=this.checkEditor(!0);e&&e.selection.std.range.syncTextSelectionToRange((t=e.selection.value)==null?void 0:t[0])},this.checkEditor=e=>{var n;const{editor:t}=this.props;if(t)try{const s=t.editor;if(!s)return;const r=s.host;return!r||e&&!((n=r.selection.value)!=null&&n.length)?void 0:r}catch{return}},this.handleColorChange=e=>{var r;const t=this.checkEditor(!0);if(!t||(((r=this.getColor("color"))==null?void 0:r.value)||"")===e)return;const s=this.colorList.find(o=>o.value===e);t.selection.std.command.exec("formatText",{textSelection:t.selection.value[0],styles:{color:`var(--affine-text-highlight-foreground-${s==null?void 0:s.key})`}}),this.updateToolbarState()},this.handleBackgroundChange=e=>{var r;const t=this.checkEditor(!0);if(!t||(((r=this.getColor("background"))==null?void 0:r.value)||"")===e)return;const s=this.colorList.find(o=>o.value===e);t.selection.std.command.exec("formatText",{textSelection:t.selection.value[0],styles:{background:`var(--affine-text-highlight-${s==null?void 0:s.key})`}}),this.updateToolbarState()},this.handleFormat=e=>{var n,s;const t=this.checkEditor();if(t){if(e=="toggleLink")if(!((s=(n=t.selection.value[0])==null?void 0:n.from)!=null&&s.length))this.callSlashMenuAction("Link");else{t.selection.std.command.exec(e);return}t.selection.std.command.exec(e),this.updateToolbarState()}},this.callSlashMenuAction=e=>{var t;return(t=this.props.editor)==null?void 0:t.callSlashMenuAction(e)},this.renderButton=e=>{const{key:t,icon:n,command:s,hint:r,slashName:o,iconClass:a}=e,l=this._toolbarState[t];return g(we,{key:t,className:U("ghost",l?"text-primary":""),icon:n,iconClass:a,hint:r,onClick:()=>{o?this.callSlashMenuAction(o):s&&this.handleFormat(s)}})}}componentDidMount(){this.initColorPicker(),this.initSelectionListener()}componentDidUpdate(e){e.editor!==this.props.editor&&this.initSelectionListener()}componentWillUnmount(){this.colorPicker&&this.colorPicker.destroy(),this.bgColorPicker&&this.bgColorPicker.destroy(),this.removeSelectionListener()}async ensureEditor(){await Dn(500);const{editor:e}=this.props;return e?await e.ensureEditor():null}initColorPicker(){this.colorPickerRef&&(this.colorPicker=new xs(this.colorPickerRef,{className:"btn ghost px-2",icon:"icon-text-color",hint:"文字颜色",colors:["#30394A","#C62222","#D34F0B","#B67C04","#149343","#0782A0","#2159D3","#842ED3","#7A7A7A"],onChange:e=>this.handleColorChange(e),onClick:()=>this.syncSelectionRange()})),this.bgColorPickerRef&&(this.bgColorPicker=new xs(this.bgColorPickerRef,{className:"btn ghost px-2",icon:"pencil-alt",hint:"文字背景颜色",colors:["#C62222","#D34F0B","#B67C04","#149343","#0782A0","#2159D3","#842ED3","#7A7A7A"],onChange:e=>this.handleBackgroundChange(e),onClick:()=>this.syncSelectionRange()}))}initSelectionListener(){this.ensureEditor().then(e=>{if(!e)return;const t=e.host;t==null||t.selection.slots.changed.on(()=>{this.updateToolbarState()})})}getColor(e){const t=this._toolbarState[e],n=e=="color"?/var\(--affine-text-highlight-foreground-(.*?)\)/:/var\(--affine-text-highlight-(.*?)\)/,s=t.match(n),r=s?s[1]:"";return this.colorList.find(o=>o.key===r)}updataColorPicker(){var e,t;if(this.colorPicker){const n=this.getColor("color");(e=this.colorPicker.$)==null||e.changeState({value:(n==null?void 0:n.value)||""})}if(this.bgColorPicker){const n=this.getColor("background");(t=this.bgColorPicker.$)==null||t.changeState({value:(n==null?void 0:n.value)||""})}}removeSelectionListener(){const e=this.checkEditor();e==null||e.selection.slots.changed.dispose()}updateToolbarState(){const e=this.checkEditor();if(!e){this._toolbarState={bold:!1,italic:!1,underline:!1,strikethrough:!1,bulleted:!1,numbered:!1,fontSize:"text",color:"",background:""};return}const n=e.selection.std.command.exec("getTextStyle").textStyle,{selectedModels:s=[]}=e.selection.std.command.exec("getSelectedModels"),r=s[0],o=(r==null?void 0:r.flavour)==="affine:list",a=o?r==null?void 0:r.type:null,c=(r==null?void 0:r.flavour)==="affine:paragraph"&&["h1","h2","h3","h4","h5","h6"].includes(r==null?void 0:r.type)?r==null?void 0:r.type:"text",h={left:0,center:0,right:0,justify:0};let d=0;s.forEach(p=>{p.flavour==="affine:paragraph"&&(d++,h[p.align||"left"]++)});const f=Object.keys(h).find(p=>h[p]===d)||"";this._toolbarState={bold:n.bold||!1,italic:n.italic||!1,underline:n.underline||!1,strikethrough:n.strike||!1,bulleted:o&&a==="bulleted",numbered:o&&a==="numbered",fontSize:c,color:(n==null?void 0:n.color)||"",background:(n==null?void 0:n.background)||"",align:f},this.forceUpdate(),this.updataColorPicker()}setParagraphAlign(e){const t=this.checkEditor();if(!t)return;const{selectedModels:n=[]}=t.selection.std.command.exec("getSelectedModels"),s=n==null?void 0:n.filter(r=>(r==null?void 0:r.flavour)==="affine:paragraph");!s||!s.length||t.doc.transact(()=>{s.forEach(r=>{r.align=e})})}render(){var c,h;const{app:e}=this.props;this.fontSizeItems.forEach(d=>{d.onClick=this.callSlashMenuAction.bind(this,d.slashName)});const t=this._toolbarState.fontSize,n=this._toolbarState.align,s=this.fontSizeItems.filter(d=>d.value==t),r=((c=e.props)==null?void 0:c.moreMenu)||[],o=((h=e.props)==null?void 0:h.moreMenuAction)||(()=>{});o&&r.forEach(d=>{d.items?d.items.forEach(f=>{f.onClick=o.bind(this,f)}):d.onClick=o.bind(this,d)});const a=[{key:"two_equal",icon:"columns-2",text:"1:1",onClick:this.callSlashMenuAction.bind(this,"two_equal")},{key:"two_left_sidebar",icon:"columns-4",text:"1:2",onClick:this.callSlashMenuAction.bind(this,"two_left_sidebar")},{key:"two_right_sidebar",icon:"columns-4",text:"2:1",onClick:this.callSlashMenuAction.bind(this,"two_right_sidebar")},{key:"three_equal",icon:"columns-3",text:"1:1:1",onClick:this.callSlashMenuAction.bind(this,"three_equal")}],l=["left","center","right","justify"].map(d=>({key:d,icon:`text-${d}`,selected:d===n,onClick:this.setParagraphAlign.bind(this,d)}));return g("div",{className:"doc-toolbar flex items-center flex-wrap gap-1 absolute top-0 left-0 w-full bg-white border-b z-10",style:"min-height: 40px;"},g(rn,{className:"w-20",type:"ghost",text:s[0].text,trigger:"hover",items:this.fontSizeItems}),g("div",{className:"divider",style:"height: unset; margin-left: -4px;"}),this.formatButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),g("div",{ref:d=>this.colorPickerRef=d}),g("div",{ref:d=>this.bgColorPickerRef=d}),g("div",{className:"divider",style:"height: unset;"}),g(rn,{type:"ghost",icon:`text-${n||"left"}`,active:!n,trigger:"hover",items:l,menu:{className:"doc-toolbar-align-menu"}}),this.listButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),this.otherButtons.map(this.renderButton),g("div",{className:"divider",style:"height: unset;"}),this.basicButtons.map(this.renderButton),g(rn,{type:"ghost",icon:"columns-3",trigger:"hover",items:a}),g("div",{className:"divider",style:"height: unset;"}),this.databaseButtons.map(this.renderButton),r&&r.length>0&&g(rn,{type:"ghost",icon:"plus",trigger:"hover",items:r}))}}zv.defaultProps={className:""};class xS extends re{constructor(e){super(e),this._editor=pe(),this._titleEle=pe(),this._isLoadingLib=fe(!1),this._convertedToNewDoc=fe(0),this._gid=Ot(),this._saveTimer=0,this._dataTime=0,this._cacheDataTime=0,this._isLoadingFile=fe(!1),this._vanillaEditor=fe(),this._loadFileTimer=0,this._handleChange=t=>{const n=t.content;(n!==this._data.content||t.html!==this._data.html)&&(this._data.content=n,this._data.contentType=t.contentType,this._data.html=t.html,this._dataTime=Date.now(),this._callChange()),this.trySaveCache()},this._handleKeywordsChange=t=>{var r;const s=t.target.value.split(/,|,/).map(o=>o.trim()).filter(Boolean).join(", ");if(s!==this._data.keywords){this._data.keywords=s;const{editor:o}=this;o instanceof ai&&((r=o.$)==null||r.updateTags(s.split(", "))),this._callChange()}},this._handleTitleChange=t=>{var s;const n=t.target.value;if(n!==this._data.title){this._data.title=n;const{editor:r}=this;r instanceof ai&&((s=r.$)==null||s.updateTitle(n)),this._callChange()}},this._handleConvertDoc=async()=>{const{app:t}=this.props;await He.confirm({title:t.getLang("convertToNewDoc","转换文档"),content:t.getLang("convertToNewDocConfirm","确定要将此文档转换为新文档格式吗?")})&&await this._switchDoc(!0)},this._switchDoc=async t=>{const{doc:n}=this.props,s=n.$html;s&&this.triggerChange({content:s,contentType:"html",html:s}),await Dn(100),this._convertedToNewDoc.value=t?n.id:0},this._switchToOldDoc=()=>{this._switchDoc(!1)},this._handleLoadingLibChange=t=>{this._isLoadingLib.value=t},this._toggleFileLoading=t=>{this._loadFileTimer&&clearTimeout(this._loadFileTimer),t?(this._isLoadingFile.value=!0,this._loadFileTimer=0):this._loadFileTimer=window.setTimeout(()=>{this._isLoadingFile.value=!1,this._loadFileTimer=0},1500)},this._handleAwarenessUpdate=t=>{const{states:n}=t,{app:s}=this.props,r=Array.from(new Map(n.map(o=>o.user).map(o=>[o.id,o])).values());s.changeState({editingUsers:r})},this._handleDownload=async t=>{const{downloadUrl:n}=this.props,s=this.props.app.getDownloadUrl(t.key,n);this._toggleFileLoading(!0);let r=null;try{r=await(await fetch(s)).blob()}catch(o){console.error("[ZUI - DocEditor] download file failed",o)}return this._toggleFileLoading(!1),{blob:r}},this._handleUpload=async t=>{const{uploadUrl:n}=this.props,{key:s,blob:r,editorID:o}=t,a=await v.post(De(n,{uid:encodeURIComponent(o),extra:"editor",field:"imgFile",gid:btoa(s)}),{imgFile:r,"labels[]":[r.name]},"json");if(a&&typeof a=="object"&&a.result==="fail")throw a.message&&He.alert({title:a.message,content:r.name}),new Error(a.message||"Upload file failed")},this._handleEditorInit=t=>{this._vanillaEditor.value=t},this._data={title:e.doc.title,content:e.doc.content??""}}get gid(){return this._gid}get editor(){return this._editor.current}get cacheID(){return`doc-${this.props.mode==="edit"?this.props.doc.id:"new"}-${this._gid}`}async getData(e){const t=this._editor.current;if(t instanceof ai){const r={...await t.getData(),contentType:"doc"};return e!=null&&e.getHtml&&(r.html=await t.getHtml()),r}return await(t==null?void 0:t.getData())}focusTitle(){var e;(e=this._titleEle.current)==null||e.focus()}setTitle(e){this._data.title=e;const t=this._titleEle.current;t&&(t.value=e,this.triggerChange())}async triggerChange(e,t){var s;const n=await this.getData(t);!n&&!e||((s=this._handleChange)==null||s.call(this,{...n,...e}),this.saveCache())}saveCache(){this._cacheDataTime!==this._dataTime&&(v.db.setCacheData(this.cacheID,this._data,0,"docAppCache"),this._cacheDataTime=this._dataTime)}trySaveCache(){this._saveTimer&&clearTimeout(this._saveTimer),this._saveTimer=window.setTimeout(()=>{this.saveCache(),this._saveTimer=0},1e3)}removeCache(){v.db.deleteCacheData(this.cacheID,"docAppCache")}_callChange(){var t,n;const{doc:e}=this.props;(n=(t=this.props).onChange)==null||n.call(t,{id:e.id,...this._data})}_renderTitle(e){const{doc:{title:t,deleted:n},mode:s,app:r}=e;return s==="view"?n?g("div",{class:"flex gap-2 items-center"},g("h1",{key:"title",class:"doc-editor-title",style:"font-size: 40px"},t),g("span",{class:"label danger"},r.getLang("deleted","已删除"))):g("h1",{key:"title",class:"doc-editor-title",style:"font-size: 40px"},t):g("input",{key:"title",ref:this._titleEle,type:"text",class:"doc-editor-title w-full font-bold",style:"font-size: 40px",defaultValue:t,onChange:this._handleTitleChange,placeholder:r.getLang("docTitlePlaceholder","请输入文档标题")})}_renderInfo(e){return g(CS,{...e})}_renderKeywords(e){const{doc:{keywords:t},mode:n,app:s}=e,r=(t==null?void 0:t.split(/,|,/).map(a=>a.trim()).filter(Boolean))??[];if(n==="view")return g("div",{key:"kw",title:s.getLang("keywords","关键字"),class:`doc-editor-keywords row gap-2 px-1 my-2${r.length?"":" hidden"}`},r.map(a=>g("span",{className:"label label-sm secondary-outline"},a.trim())));const o=`doc-app-kw-${this._gid}`;return g("div",{key:"kw",className:"input-control has-prefix-icon my-2 doc-editor-keywords"},g("input",{key:"kw",type:"text",id:o,class:"form-control ring-0 shadow-none",defaultValue:r.join(", "),onChange:this._handleKeywordsChange,placeholder:s.getLang("keywordsPlaceholder","关键字,使用逗号分隔")}),g("label",{for:o,class:"input-control-prefix"},g("i",{className:"icon icon-tag"})))}componentDidMount(){this.props.mode==="edit"&&this.focusTitle()}render(e){var ne,xe,Me,Re,je,te,X;const{className:t,doc:n,belowTitle:s,mode:r,uploadUrl:o,downloadUrl:a,app:l}=e,c=n.contentType==="doc"?"doc":n.contentType==="markdown"?"markdown":"html",h=c==="doc"&&!n.$convert,d=c==="markdown",f=r==="view",p=r==="edit",y=l.props.autoConvertDoc||n.status==="draft",b=this._convertedToNewDoc.value,w=p&&(n.contentType==="html"||n.contentType==="attachment"||n.$convert),x=!(n.content??"").trim().length,T=x&&r==="view",D=p&&w&&b===n.id,N=d||h||D||x,A=N?ai:Pv,z=n.content===void 0||n.content===null,O=this._isLoadingLib.value,K=z||O;let{useHocuspocus:Z}=l.props;Z=typeof Z=="function"?Z(l):Z;const ye=l.mode==="edit"&&Z,Q=typeof l.props.editorProps=="function"?l.props.editorProps(n,l):l.props.editorProps;return g("div",{class:U("doc-editor col",t,f?"is-readonly":"is-editing",T?"is-empty":"flex-auto")},(ne=l.props)!=null&&ne.showToolbar&&l.mode!="view"?g(zv,{app:l,editor:this._vanillaEditor.value||((xe=this._editor.current)==null?void 0:xe.$)}):null,this._renderTitle(e),this._renderInfo(e),this._renderKeywords(e),y&&D&&N&&p?g("div",{className:"center mb-3"},g("div",{class:"row gap-2 items-center primary-pale pl-2 rounded-full"},g("p",{className:"text-gray"},l.getLang("oldDocEditingTip","此文档为旧版本编辑器创建,已启用新版编辑器编辑,保存后将转换为新版文档")),g(we,{text:l.getLang("switchToOldEditor","切换回旧编辑器"),size:"sm",type:"ghost",rounded:"full",className:"underline",onClick:this._switchToOldDoc}))):null,s,K?g("div",{className:"load-indicator loading relative h-48","data-loading":z?l.getLang("loadingDocTip","正在加载文档内容..."):O?l.getLang("loadingEditorTip","正在加载编辑器..."):""}):null,!K&&!T&&g(A,{ref:this._editor,key:`editor-${n.id}-${r}-${n.currentVersion||n.version}`,className:"doc-editor-control flex-auto",mode:h?"full":"page",autoInit:!0,onInit:this._handleEditorInit,readonly:f,downloadUrl:a,uploadUrl:o,onDownload:a?this._handleDownload:void 0,onUpload:this._handleUpload,uid:n.uid??`doc${n.id}`,content:n.content??"",title:n.title,tags:(Me=n.keywords)==null?void 0:Me.split(", "),contentType:c,placeholder:o?l.getLang("pasteImageTip","可以在编辑器直接贴图。"):"",onChange:this._handleChange,onLoadingLibChange:this._handleLoadingLibChange,token:l.props.token,docID:kS(l.docID),useHocuspocus:ye,hocuspocusUrls:l.props.hocuspocusUrls,awarenessUser:l.props.awarenessUser,onAwarenessUpdate:this._handleAwarenessUpdate,onAuthenticationFailed:(Re=l.props.onAuthenticationFailed)==null?void 0:Re.bind(null,l),onConnect:(je=l.props.onHocuspocusConnect)==null?void 0:je.bind(null,l),onDisconnect:(te=l.props.onHocuspocusDisconnect)==null?void 0:te.bind(null,l),onClose:(X=l.props.onHocuspocusClose)==null?void 0:X.bind(null,l),...Q},y&&w&&!D?g("div",{className:"absolute right-0 top-1"},g(we,{type:"primary-pale",size:"md",onClick:this._handleConvertDoc},l.getLang("convertToNewDoc","转换为新文档格式"))):null))}}function kS(i){if(typeof i=="number")return i;const e=i.match(/\d+/);return e?+e:0}const yM="",vM="",SS=ut("file","ajaxQuery","fileID={gid}&objectType={objectType}&objectID={objectID}&title={title}&extra={extra}");async function Fv(i){if(i.html)return i.html;switch(i.contentType){case"doc":return await gt.convertToHtml(i.content,void 0,SS);case"markdown":return await gt.markdownToHtml(i.content);case"html":return i.content;default:return""}}async function TS(i,e){if(!i||!e[0]||!e[1])return{oldHtml:"",newHtml:""};const t=ut("doc","ajaxGetDoc","docID={docID}&version={version}"),n=await Ne(t,[{docID:i,version:e[0]}]),s=await Fv(n),r=await Ne(t,[{docID:i,version:e[1]}]),o=await Fv(r);return{oldHtml:s,newHtml:o}}class Ov extends Ve{_loadAndDiff(){const{docID:e,versions:t}=this.props;TS(e,t).then(async({oldHtml:n,newHtml:s})=>{const r=await qd.diff(n,s);this.changeState({html:r})})}componentDidMount(){super.componentDidMount(),this._loadAndDiff()}componentDidUpdate(e){(e.docID!==this.props.docID||e.versions!==this.props.versions)&&this._loadAndDiff()}render(){return g("div",{class:"doc-diff",dangerouslySetInnerHTML:{__html:this.state.html||""}})}}Ov.defaultProps={docID:0,versions:[0,0]};let Su=class extends Ve{get actions(){return this.state.actions||this.props.actions||[]}getDefaultState(e){e=e||this.props;let{preserve:t,defaultReversed:n}=e;return t===!0&&(t=""),n===void 0&&typeof t=="string"&&(this._preserveID=`HistoryPanel.reversed${t.length?`:${t}`:""}`,n=nt.get(this._preserveID)),e.actions&&(this._currentLoadID=[e.objectType,e.objectID].join()),{actions:e.actions,expandMap:{},reversed:n}}resetState(e,t){const n=this.getDefaultState(e);t?this.state=n:this.changeState(n)}componentDidMount(){v.on(`load.HistoryPanel.${this.gid}.zt`,(e,{objectType:t,objectID:n})=>{t===this.props.objectType&&String(n)===String(this.props.objectID)&&this.load()}),this.state.actions||this.load()}componentWillUnmount(){v.off(`.HistoryPanel.${this.gid}.zt`)}componentDidUpdate(){(!this.state.actions||this._currentLoadID!==[this.props.objectType,this.props.objectID].join())&&!this.state.loading&&this.load()}async load(){const{objectType:e,objectID:t}=this.props;let n=this.props.fetcher;n||(n=ut("action","ajaxGetList",`objectType=${e}&objectID=${t}`));const s=[e,t].join();if(this.state.loading)return;await this.changeState({loading:!0});const o={actions:await Ne(n,[{objectType:e,objectID:t}])||[],loading:!1},a=[this.props.objectType,this.props.objectID].join();a!==s?delete o.actions:this._currentLoadID=a,await this.changeState(o)}reverse(e){return e===void 0&&(e=!this.state.reversed),this.changeState({reversed:e},()=>{typeof this._preserveID=="string"&&nt.set(this._preserveID,e)})}toggle(e,t){return this.changeState(n=>{const{expandMap:s}=n;return t===void 0&&(t=!s[e]),{expandMap:{...s,[e]:t}}})}isAllExpanded(){const{expandMap:e}=this.state;return this.actions.every(t=>{const{history:n,historyChanges:s}=t;return!(n&&n.length||typeof s=="string"&&s.length)||e[t.id]})}toggleAll(e){return e===void 0&&(e=!this.isAllExpanded()),this.changeState({expandMap:e?this.actions.reduce((t,n)=>({...t,[n.id]:e}),{}):{}})}_getClassName(e){return[super._getClassName(e),"history-panel",e.panel?"panel":""]}_getChildren(e){const t=this._buildHeader(e),n=this._buildBody(e);return e.panel?[t?g("div",{key:"heading",className:"panel-heading"},t):null,g("div",{key:"body",className:"panel-body"},n)]:[t,n]}_buildFiles(e){let t=e.files;return Array.isArray(t)&&(t={items:t}),!t||!t.items?null:g(si,{key:"files",className:"bg-primary-50 py-1 px-1.5",...this.props.fileListProps,...t})}_buildAction(e,t,n,s){const{history:r,historyChanges:o}=e,a=r&&r.length||typeof o=="string"&&o.length,l=typeof e.comment=="string"&&e.comment.length,c=`${t+1}`,h={component:"li",key:String(e.id),"data-id":e.id,"data-action":e.action,className:["history-panel-action list-item item",a?n?"is-expanded":"is-collapsed":""],innerClass:"item-inner list-item-inner",avatar:{className:"text-gray ring canvas",background:"",size:16,circle:!0,...e.action==="finished"?{icon:{icon:"check",className:"text-success"}}:{children:g("span",{style:c.length>1?{transform:`scale(${1-c.length*.1})`}:void 0},c)}},title:{html:e.content},text:a?g(we,{icon:n?"minus":"plus",type:"ghost",size:"xs",className:"history-panel-action-toggle ring text-gray scale-75",onClick:this.toggle.bind(this,e.id,void 0)}):null,children:a&&n||l?g("div",{className:"history-panel-action-content pl-6 col gap-1 mb-1"},a&&n?typeof o=="string"&&o.length?g("div",{key:"history",className:"history-panel-action-history pl-1",dangerouslySetInnerHTML:{__html:o}}):g("ul",{key:"history",className:"history-panel-action-history col pl-1"},r.map(d=>g("li",{key:d.id,className:"history-panel-history-item",dangerouslySetInnerHTML:{__html:d.content}}))):null,e.comment?g("div",{key:"comment",className:`history-panel-action-comment py-2 surface relative ${e.commentEditable?"pl-3 pr-6":"px-3"}`},e.commentEditable?g(we,{key:"btn",type:"ghost",icon:"pencil",size:"sm",className:"comment-btn hover:text-primary absolute top-1 right-1","data-toggle":"comment","data-action-ID":e.id,url:s.editCommentUrl?s.editCommentUrl.replace("{actionID}",String(e.id)):void 0}):null,g("div",{className:"article",key:"comment",dangerouslySetInnerHTML:{__html:e.comment}})):null,this._buildFiles(e)):null};return g(Pn,{...h})}_buildBody(e){const{actions:t}=this,{loading:n,expandMap:s,reversed:r}=this.state;return g("ul",{key:"actions",className:U("list history-panel-body load-indicator",{loading:n},r?"col-reverse":"col",e.bodyClass)},t.map((o,a)=>this._buildAction(o,a,s[o.id],e)))}_buildHeader(e){let{header:t}=e;if(!t)return null;const{title:n="History",toolbar:s=!0,commentBtn:r=!0}=e,o=[];if(s){const{reversed:a}=this.state,l=this.isAllExpanded(),{actions:c}=this,h={key:"toolbar",className:"history-panel-toolbar",gap:1,items:[c.length>1?{icon:a?"arrow-down":"arrow-up",type:"ghost",size:"xs",className:"ring text-gray scale-75",onClick:this.reverse.bind(this,void 0)}:null,c.some(d=>{const{history:f,historyChanges:p}=d;return f&&f.length||typeof p=="string"&&p.length})?{icon:l?"minus":"plus",type:"ghost",size:"xs",className:"ring text-gray scale-75",onClick:this.toggleAll.bind(this,void 0)}:null].filter(Boolean)};typeof s=="object"&&Object.assign(h,s),h.items&&(!Array.isArray(h.items)||h.items.length)&&o.push(g(Fe,{...h}))}if(r){const a={key:"commentBtn",type:"ghost",className:"comment-btn text-gray",size:"sm",url:e.commentUrl,icon:{icon:"message",className:"icon-sm text-primary"},"data-toggle":"comment","data-object-ID":e.objectID,"data-object-type":e.objectType};typeof r=="object"?Object.assign(a,r):typeof r=="string"&&(a.text=r),o.push(g(we,{...a}))}return t={key:"header",className:"history-panel-header",title:n,titleClass:"font-bold mr-1",content:o,contentClass:"flex items-center flex-auto gap-2",...typeof t=="object"?t:{}},g(Pn,{...t})}};Su.defaultProps={header:!0,panel:!0,preserve:!0};class ho extends re{constructor(){super(...arguments),this._ref=pe(),this._timer=0,this._editorSelector="page-editor,affine-page-root,zen-editor,.doc-editor-content",this.state={},this._getItem=e=>{var t;return e.innerClass=(t=e.text)!=null&&t.length?"":"hidden",e},this._handleClickItem=e=>{var t;(t=e.event.target)!=null&&t.closest(".tree-toggle")||this.scrollIntoDoc(e.item)}}update(){var l,c;const e=this.props.container||((l=this._ref.current)==null?void 0:l.closest(".doc-view"));if(!e)return;this._container!==e&&(this._container&&v(this._container).off(".doc-outline"),this._container=e,v(e).on("docChange.doc-outline",()=>{this.tryUpdate()}));const n=v(e).find(this._editorSelector)[0];if(!n)return;const s=n.tagName.toLowerCase(),r=s==="zen-editor"?"zen":s==="page-editor"||s==="affine-page-root"?"blocksuite":"html";this._editorType=r;const o=r==="blocksuite"?ho.getBlocksuiteHeadings(n):ho.getEditorHeadings(n),a=ho.formHeadings(o);this._lastDocID=(c=this.props.doc)==null?void 0:c.id,this.setState({items:a})}tryUpdate(){var e;this._timer&&clearTimeout(this._timer),this._lastDocID!==((e=this.props.doc)==null?void 0:e.id)&&this.setState({items:void 0}),this._timer=window.setTimeout(()=>{this.update(),this._timer=0},1e3)}scrollIntoDoc(e){var s,r,o,a;const t=this._container;if(!t)return;const n=v(t).find(this._editorSelector)[0];if(n)if(this._editorType==="blocksuite")(s=n.querySelector(`affine-paragraph[data-block-id="${e.id}"]`))==null||s.scrollIntoView({behavior:"smooth",block:"start"});else{const c=(((a=(o=(r=n.shadowRoot)==null?void 0:r.querySelector("zen-editor-core"))==null?void 0:o.shadowRoot)==null?void 0:a.querySelector("zen-editor-content"))||n).querySelectorAll("h1,h2,h3,h4,h5,h6");if(!c)return;const{text:h,level:d}=e;let f=e.index!==void 0?c[e.index]:void 0;(!f||f.textContent!==h||f.tagName!==`H${d}`)&&(f=Array.from(c).find(p=>p.textContent===h&&p.tagName===`H${d}`)),f&&f.scrollIntoView({behavior:"smooth",block:"start"})}}componentDidMount(){this.tryUpdate()}componentDidUpdate(e){this.props.doc!==e.doc&&this.tryUpdate()}componentWillUnmount(){this._container&&v(this._container).off(".doc-outline"),this._timer&&clearTimeout(this._timer)}render(e,t){const{items:n}=t,s=e.app.props.docOutlineTreeProps;return g("div",{className:"doc-outline",ref:this._ref},n?n.length?g(zt,{items:n,defaultNestedShow:!0,getItem:this._getItem,nestedToggle:".tree-toggle",onClickItem:this._handleClickItem,...s?typeof s=="function"?s.call(this,e.doc,n):s:{}}):g("div",{className:"text-gray p-2"},e.app.getLang("noOutline","没有大纲")):g("div",{className:"text-gray p-1"},e.app.getLang("loading","加载中...")))}static formHeadings(e){let t,n=e.reduce((s,r)=>{r.text=r.text.trim();const{level:o}=r;if(!r.text.length&&(o===1||t&&t.level===o))return s;if(o>1){t||(t={level:1,text:"",id:""},s.push(t));let a;if(t.level===o-1)a=t;else if(t.level>=o){for(;t.level>=o;)t.parent&&(t=t.parent);a=t}else{for(;t.level<o-1;){const l={level:t.level+1,text:"",id:"",parent:t};t.items||(t.items=[]),t.items.push(l),t=l}a=t}r.parent=a,a.items||(a.items=[]),a.items.push(r)}else s.push(r);return t=r,s},[]);return n.length===1&&n[0].text===""&&(n=n[0].items||[]),n}static getBlocksuiteHeadings(e){const t=[],n=(s,r)=>{var a;const o=((a=s.querySelector("v-text"))==null?void 0:a.textContent)??"";t.push({id:s.closest("affine-paragraph").dataset.blockId??`${r}_${o}`,text:o,level:r})};return e.querySelectorAll(".affine-paragraph-rich-text-wrapper").forEach(s=>{const r=s.classList;let o=0;r.contains("h1")?o=1:r.contains("h2")?o=2:r.contains("h3")?o=3:r.contains("h4")?o=4:r.contains("h5")?o=5:r.contains("h6")&&(o=6),o&&n(s,o)}),t}static getEditorHeadings(e){var s,r,o;const t=[],n=((o=(r=(s=e.shadowRoot)==null?void 0:s.querySelector("zen-editor-core"))==null?void 0:r.shadowRoot)==null?void 0:o.querySelector("zen-editor-content"))||e;return n&&n.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(a=>{const l=a.textContent||"",c=a.id,h=parseInt(a.tagName[1]);l.length&&h<7&&t.push({index:t.length,level:h,text:l,id:c})}),t}}const Bv=class tp extends re{constructor(e){super(e),this._ref=pe();const{defaultStatus:t=tp.defaultProps.defaultStatus}=e;this._status=e.status||fe(t)}toggleTab(e){e===void 0?this._status.value=this._status.value?!1:tp.defaultProps.defaultStatus:this._status.value=e===!1||this._status.value===e?!1:e}_renderContent(e,t,n){var o;if(!e||!n)return null;const{doc:s,app:r}=t;if(n.render)return g(de,{content:n.render(s)});if(e==="info"){const{creator:a,modifier:l}=t,c=[{label:r.getLang("docStatus","状态"),content:s.status==="draft"?g("div",{key:"status",className:"label special-pale size-sm rounded-full ml-1"},r.getLang("draft","草稿")):s.status==="pause"?r.getLang("pause","已暂停"):r.getLang("released","已发布")},{label:r.getLang("creator","创建者"),content:a.realname},{label:r.getLang("createDate","创建时间"),content:Ze(s.addedDate)},{label:r.getLang("modifier","修改者"),content:l==null?void 0:l.realname},s.editedDate?{label:r.getLang("editDate","修改时间"),content:Ze(s.editedDate)}:null,{label:r.getLang("viewsCount","阅读次数"),content:s.views},{label:r.getLang("collectCount","收藏次数"),content:[s.collects,s.isCollector?g("span",{className:"label side-sm rounded-full warning-pale"},r.getLang("collected","已收藏")):null]}].filter(Boolean);return g("div",{className:"col gap-2"},g("div",{className:"font-bold px-1"},r.getLang("docInfo","文档信息")),g(ev,{items:c}))}if(e==="outline")return g("div",{className:"col gap-2"},g("div",{className:"font-bold px-1"},n.title??r.getLang("docOutline","文档大纲")),g(ho,{app:r,container:(o=this._ref.current)==null?void 0:o.closest(".doc-view"),doc:s}));if(e==="history")return _v(s.rawID)?null:g("div",{style:"margin-top: -6px"},g(Su,{panel:!1,title:n.title??r.getLang("history","历史记录"),objectType:s.api?"api":"doc",objectID:s.rawID,fetcher:t.historyFetcher,...t.historyPanel}))}_renderNav(e,t,n){const{app:s}=t;return g("menu",{key:"nav",className:"doc-view-sidebar-nav nav nav-stacked gap-1 p-1 flex-none rounded-lg"},n.map(({icon:r,title:o,key:a})=>g("li",{class:"nav-item item hint-left","data-hint":o,key:a},g("a",{className:`rounded-lg${e===a?" active":""}`,"zui-command":`toggleViewSideTab/${a}`},g($e,{icon:r})))),n.length?g("li",{key:"divider",class:"nav-divider divider"}):null,g("li",{class:"nav-item item hint-left","data-hint":s.fullscreen?s.getLang("exitFullscreen","退出全屏"):s.getLang("enterFullscreen","进入全屏")},g("a",{className:"rounded-lg","zui-command":"toggleFullscreen"},g($e,{icon:s.fullscreen?"fullscreen-exit":"fullscreen"}))),e?g("li",{class:"nav-item item hint-left","data-hint":s.getLang("collapse","收起")},g("a",{className:"rounded-lg","zui-command":"toggleViewSideTab/false"},g($e,{icon:"icon-menu-arrow-right"}))):null)}render(e){var h;const{className:t,app:n,doc:s,showTabsNav:r}=e;let o=this._status.value;const a=_v(+s.id);o&&a&&(o="outline");const l=((h=n.props.getDocViewSidebarTabs)==null?void 0:h.call(n,s,{isNewDoc:a,mode:n.mode}))||[{icon:"list-box",title:n.getLang("docOutline","文档大纲"),key:"outline"}],c=l==null?void 0:l.find(d=>d.key===o);return c||(o=""),!r&&!o?null:g("div",{className:U("doc-view-sidebar flex-none z-50 sticky top-3 right-1 mx-2 mt-2 self-start",t,`is-${o?"opened":"closed"}`,`is-${o}`,r?`has-tabs-nav-${r}`:""),ref:this._ref},g("div",{className:"doc-view-sidebar-container border shadow rounded-lg row items-stretch"},g("div",{key:"content",className:"doc-view-sidebar-content p-2 border-r flex-auto overflow-y-auto scrollbar-hover"},this._renderContent(o,e,c)),r?this._renderNav(o,e,l):g(we,{type:"ghost",size:"sm",icon:"close text-gray",className:"absolute top-1.5 right-1.5 z-10",command:"toggleViewSideTab/false"})))}};Bv.defaultProps={defaultStatus:"outline",showTabsNav:"right"};let $S=Bv;class DS extends re{constructor(e){super(e),this._editorRef=pe(),this._ref=pe(),this._sidebarRef=pe(),this._currentDocID=fe(""),this._modeChangeEffect=_t(()=>{this.props.app.mode!=="view"&&(this._currentDocID.value="")}),this.tryLoadDoc=ca(()=>{if(this.props.mode!=="view")return;const r=this._currentDocID.value;if(r){const[o,a]=r.split(",").map(ri);this.props.app.loadDoc(o,a)}},100),this._docChangeEffect=_t(()=>{const{docID:r,docVersion:o}=this.props.app.signals,a=[r,o].join();a!==this._currentDocID.value&&(this._currentDocID.value=a,this.props.mode==="view"&&this.tryLoadDoc())}),this._handleChange=r=>{const{doc:o,mode:a="view",onChange:l}=this.props;l==null||l(r,a,o),v(this.element).trigger("docChange",[r,a,o])};const{preserve:t,app:n}=e,s=t?`${t}-expanded`:null;n.props.openViewSidebar!==void 0?this._status=fe(n.props.openViewSidebar):this._status=fe(s?nt.get(s,!1):!1),s&&this._status.subscribe(r=>{nt.set(s,r)})}get editor(){return this._editorRef.current}get element(){return this._ref.current}get sidebar(){return this._sidebarRef.current}componentWillUnmount(){this._modeChangeEffect(),this._docChangeEffect(),this.tryLoadDoc.cancel()}_renderEditor(e){const{doc:t,mode:n="view",uploadUrl:s,downloadUrl:r,app:o}=e,a=o.renderCustom("editor");return a!==void 0?a:g(xS,{app:o,ref:this._editorRef,mode:n,doc:t,uploadUrl:s?De(s,{objectID:n==="create"?0:t.id,objectType:"doc",api:t.contentType==="doc"?"true":"",extra:t.contentType==="doc"?"editor":""}):void 0,downloadUrl:r?De(r,{id:t.id,objectID:t.id,objectType:"doc"}):void 0,onChange:this._handleChange})}_renderDiff({doc:e}){const{diffVersions:t}=this.props.app.signals;return g(Ov,{docID:e.id,versions:t.value})}render(e){var b,w;const{doc:t,fileActions:n,fileIcon:s,fileUrl:r,creator:o,modifier:a,onGetUser:l,historyFetcher:c,highlight:h,app:d,mode:f}=e,p=this._status.value,y=(b=d.props)!=null&&b.showToolbar&&d.mode!="view"?"pt-10":"";return g("div",{className:U("doc-view absolute inset-0 canvas z-10 row",y,`is-sidebar-${p?"opened":"closed"}`,h?"highlight":""),ref:this._ref},g("div",{class:"doc-view-content col gap-4 flex-auto overflow-auto scrollbar-hover"},f==="diff"?this._renderDiff(e):this._renderEditor(e),(w=t.files)!=null&&w.length?g(si,{className:"doc-files my-4 px-3 py-2 surface rounded-lg",heading:{icon:"paper-clip",title:d.getLang("attachment","附件")},items:t.files,fileActions:n,fileIcon:s,fileUrl:r,itemProps:{target:"_blank"},hoverItemActions:!0}):null),g($S,{ref:this._sidebarRef,app:d,doc:t,creator:o,modifier:a,status:this._status,historyFetcher:c,historyPanel:d.props.historyPanel,onGetUser:l,showTabsNav:!1}))}}function jv(i,e){const{page:t,recPerPage:n}={page:1,recTotal:i.length,pageTotal:Math.ceil(i.length/20),recPerPage:20,...e},s=(t-1)*n,r=t*n;return i.slice(s,r)}class IS extends re{constructor(e){var n;super(e),this._libsMap=fe({}),this._filterType=fe(),this._loading=fe(!1),this._currentFilterType=Ce(()=>{const{app:s}=this.props,r=this._filterType.value,o=s.spaceType;return r||(o==="product"||o==="project"?"mine":"all")}),this._spaceList=Ce(()=>{const{app:s}=this.props;let r=s.signals.spaces.value;const o=this._currentFilterType.value,a=s.spaceType,l=s.props.isMatchFilter;return o&&l&&(r=r.filter(c=>l.call(s,a,o,c))),r.sort((c,h)=>c.order-h.order)}),this._pagedSpaceList=Ce(()=>{const s=this._spaceList.value;return jv(s,this.props.app.signals.pager.value)}),this._autoLoadLibs=_t(()=>{const s=this._spaceList.value;this.loadLibs(s.map(r=>r.id))}),this._handleFilterTypeClick=s=>{const o=s.target.getAttribute("data-type");o&&(this._filterType.value=o)},this._handleLibClick=s=>{const r=v(s.target);if(r.closest(".toolbar").length)return;const o=r.closest("[z-lib]").z("lib"),a=r.closest("[z-space]").z("space");!o||!a||this.props.app.selectSpace(a,+o)},this._handleChangePager=s=>{this.props.app.resetPager("home",{...s})};const t=e.app.getFilterTypes("home")||[];this._filterType.value=(n=t[0])==null?void 0:n[0]}get app(){return this.props.app}async loadLibs(e){e=e||this._spaceList.value.map(r=>r.id);const{libSummariesFetcher:t}=this.app.props;if(!t)return;const n=typeof t=="object"&&(t.method||"").toLowerCase()==="post"?{data:JSON.stringify(e.join(",")),processData:!1}:void 0;this._loading.value=!0;const s=await Ne(t,[{spaceList:e,spaceType:this.app.spaceType}],n);gs(()=>{this._libsMap.value={...this._libsMap.value,...e.reduce((r,o)=>(r[o]=[],r),{}),...s},this._loading.value=!1})}_getToolbarActions(e){return e.app.getActions("home",{ui:"toolbar"})}_renderHeader(e){const{app:t}=e,s=this._spaceList.value.length,r=t.getFilterTypes("home")||[],o=this._currentFilterType.value;return g("div",{key:"header",class:"doc-app-header flex-none surface-light row items-center border-b py-2 pl-1 pr-2 flex-none"},g("menu",{className:"nav nav-compact ml-2",style:"--nav-active-bg: var(--color-primary-100); --nav-active-color: var(--color-fore); --nav-item-height: 24px; --nav-divider-margin: 8px",onClick:this._handleFilterTypeClick},r.map(([a,l])=>g("li",{key:a,className:"nav-item item"},g("a",{className:a===o?"active rounded":"rounded","data-type":a},l,a===o&&s?g("span",{className:"label size-sm canvas ring-0 rounded-md"},s):null)))),g("div",{className:"flex-auto"}),g(Fe,{className:"doc-app-toolbar",gap:2,size:"md",items:this._getToolbarActions(e)}))}_getSpaceLibs(e){const{app:t}=this.props,s=this._libsMap.value[e];if(s)return s;const r=[],o=t.signals.docs.value,a=t.signals.libs.value,{maxHomeLibsOfSpace:l=5}=t.props,c=new Map;for(const h of o){const d=h.lib,f=c.get(d)||0;c.set(d,f+1)}for(const h of a)if(!(h.deleted||h.space!==e)&&(r.push({id:h.id,name:h.name,docs:c.get(h.id)||0}),l&&r.length>=l))break;return r}_renderSpace(e,t){var c;const{app:n}=t,s=n.getItemActions("space",e,"space-card"),r=[{text:n.getLang("enterSpace","进入空间"),textClass:"text-primary",command:`selectSpace/${e.id}/true`},...s];let o=this._getSpaceLibs(e.id);const a=n.props.libColors;let l;return o?o.length?(o.length>5&&(o=o.slice(0,5)),l=g("div",{class:"row flex-wrap"},o.map(h=>{const d=n.getItemActions("lib",h,"space-card");return g("div",{className:"doc-space-card-lib p-1.5 w-1/5 group"},g("div",{class:"canvas border rounded py-2 px-3 col gap-1 hover:shadow-lg hover:border-primary relative cursor-pointer",onClick:this._handleLibClick,"z-lib":h.id,"z-space":e.id},g($e,{icon:"doclib text-2xl",style:a?{color:a[h.id%a.length]}:null}),g("div",{class:"font-bold text-clip",title:h.name},h.name),g("div",{class:"text-gray text-sm"},h.docs?n.getLang("docsTotalInfo",[h.docs],"共 {0} 个文档"):n.getLang("noDocs","没有文档")),d!=null&&d.length?Fe.render({items:d},[],{size:"sm",type:"ghost",className:"absolute top-1 right-1 opacity-0 group-hover:opacity-100"}):null))}))):l=g("div",{className:"center gap-4 py-3"},g("div",{className:"text-gray"},n.getLang("noLibs","没有文档库")),(c=n.props.privs)!=null&&c.createLib?g(we,{type:"primary-pale",icon:"plus",command:`createLib/${e.id}`},n.getLang("createLib","创建文档库")):null):l=g("div",{className:"relative load-indicator loading center gap-4 h-4 py-3"}),g("div",{class:"doc-space-card ring rounded surface-light",key:e.id},g("header",{class:"row items-center justify-between gap-2 px-2.5 py-1 border-b"},g("div",{class:"row items-center gap-2 flex-none cursor-pointer hover:text-primary","zui-command":`selectSpace/${e.id}/true`},g($e,{icon:"docspace",className:"w-4 h-4 center rounded-md text-gray-600 flex-none"}),g("div",{className:"min-w-0 flex-auto"},g("strong",null,e.name))),g(Fe,{size:"md",items:r})),g("div",{class:"doc-space-card-libs p-1.5",style:"min-height: 118px"},l))}_renderBody(e){const t=this._pagedSpaceList.value;return g("div",{key:"body",class:"doc-app-body flex-auto min-h-0 col gap-4 p-4 items-stretch overflow-auto scrollbar-hover"},t.map(n=>this._renderSpace(n,e)),t.length===0?g("div",{className:"center text-gray h-full"},e.app.getLang("noDataYet","暂无数据")):null)}_renderFooter(e){const t=e.app.getPagerOptions({className:"flex-none",...e.app.signals.pager.value,recTotal:this._spaceList.value.length,onChangePageInfo:this._handleChangePager},{type:"home"});return g("div",{key:"footer",class:"doc-app-footer surface-light row items-center border-t py-1.5 px-2"},g("div",{class:"flex-auto"}),g(Xr,{...t}))}componentDidMount(){this.props.app.resetPager("home",{recTotal:this._spaceList.value.length})}componentWillUnmount(){this._autoLoadLibs()}render(e){return this._loading.value?g("div",{key:"loading",class:"doc-loading relative center h-full load-indicator loading tex-gray","data-loading":e.app.getLang("loadingDocsData","正在加载文档数据...")}):[this._renderHeader(e),this._renderBody(e),this._renderFooter(e)]}}const MS=i=>{var t,n;i=JSON.parse(JSON.stringify(i));const e=new Map;for(const s of i){const r=String(s.id);e.has(r)?s.items&&((n=(t=e.get(r))==null?void 0:t.items)==null||n.push(...s.items)):e.set(r,s)}return Array.from(e.values())};class NS extends re{constructor(e){super(e),this._libsMap=fe({}),this._filterType=fe(),this._programData=fe(),this._hasDocsOnly=fe(!1),this._showClosed=fe(!1),this._otherPrograms=Ce(()=>{var n;if(!this._programData.value)return[];const t=[];if(t.push(...this._programData.value.data.other),this._showClosed.value){const s=this._programData.value.data.closed;for(const r of s){const o={...r,items:(n=r.items)==null?void 0:n.filter(a=>!a.isPO&&!a.involved)};t.push(o)}}return t}),this._myPrograms=Ce(()=>{var n;if(!this._programData.value)return[];const t=[];if(t.push(...this._programData.value.data.my),this._showClosed.value){const s=this._programData.value.data.closed;for(const r of s){const o={...r,items:(n=r.items)==null?void 0:n.filter(a=>a.isPO||a.involved)};t.push(o)}}return t}),this._currentFilterType=Ce(()=>{const t=this._filterType.value;return t||"mine"}),this._programList=Ce(()=>{const n=this._currentFilterType.value==="mine"?this._myPrograms.value:this._otherPrograms.value;return MS(n)}),this._pagedProgramList=Ce(()=>{const t=this._programList.value;return jv(t,this.app.signals.pager.value)}),this._spaceList=Ce(()=>{const{app:t}=this.props;let n=t.signals.spaces.value;const s=this._currentFilterType.value,r=t.spaceType,o=t.props.isMatchFilter;return s&&o&&(n=n.filter(a=>o.call(t,r,s,a))),n.sort((a,l)=>a.order-l.order)}),this._autoLoadLibs=_t(()=>{const t=this._spaceList.value;this.loadLibs(t.map(n=>n.id))}),this._handleFilterTypeClick=t=>{const s=t.target.getAttribute("data-type");s&&(this._filterType.value=s)},this._handleSpaceClick=t=>{const n=v(t.target);if(n.closest(".toolbar").length)return;const s=n.closest("[z-space]").z("space");s!=null&&this.props.app.selectSpace(s,!0)},this._handleChangePager=t=>{this.props.app.resetPager("home",{...t})},this._filterType.value="mine"}get app(){return this.props.app}async loadLibs(e){e=e||this._spaceList.value.map(r=>r.id);const{libSummariesFetcher:t}=this.app.props;if(!t)return;const n=typeof t=="object"&&(t.method||"").toLowerCase()==="post"?{data:JSON.stringify(e.join(",")),processData:!1}:void 0,s=await Ne(t,[{spaceList:e,spaceType:this.app.spaceType}],n);this._libsMap.value={...this._libsMap.value,...e.reduce((r,o)=>(r[o]=[],r),{}),...s}}_getToolbarActions(e){return e.app.getActions("home",{ui:"toolbar"})}_renderHeader(e){const{app:t}=e,n=this._programList.value.length,s=t.spaceType==="product"?[["mine",t.getLang("productMine")],["other",t.getLang("productOther")]]:[["mine",t.getLang("projectMine")],["other",t.getLang("projectOther")]],r=this._currentFilterType.value;return g("div",{key:"header",class:"doc-app-header flex-none surface-light row gap-2 items-center border-b py-2 pl-1 pr-2 flex-none"},g("menu",{className:"nav nav-compact ml-2",style:"--nav-active-bg: var(--color-primary-100); --nav-active-color: var(--color-fore); --nav-item-height: 24px; --nav-divider-margin: 8px",onClick:this._handleFilterTypeClick},s.map(([o,a])=>g("li",{key:o,className:"nav-item item"},g("a",{className:o===r?"active rounded":"rounded","data-type":o},a,o===r&&n?g("span",{className:"label size-sm canvas ring-0 rounded-md"},n):null)))),g(es,{id:"show-no-doc",name:"show-no-doc",defaultChecked:this._hasDocsOnly.value,label:t.getLang(t.spaceType==="product"?"showHasDocsOnlyProduct":"showHasDocsOnlyProject"),onChange:(o,a)=>{typeof a=="boolean"&&(this._hasDocsOnly.value=a)}}),g(es,{id:"show-closed",name:"show-closed",defaultChecked:this._showClosed.value,label:t.getLang(t.spaceType==="product"?"showClosedProduct":"showClosedProject"),onChange:(o,a)=>{typeof a=="boolean"&&(this._showClosed.value=a)}}),g("div",{className:"flex-auto"}),g(Fe,{className:"doc-app-toolbar",gap:2,size:"md",items:this._getToolbarActions(e)}))}_getSpaceLibs(e){const{app:t}=this.props,s=this._libsMap.value[e];if(s)return s;const r=[],o=t.signals.docs.value,a=t.signals.libs.value,{maxHomeLibsOfSpace:l=5}=t.props,c=new Map;for(const h of o){const d=h.lib,f=c.get(d)||0;c.set(d,f+1)}for(const h of a)if(!(h.deleted||h.space!==e)&&(r.push({id:h.id,name:h.name,docs:c.get(h.id)||0}),l&&r.length>=l))break;return r}_getSpaceDocSum(e){var t;return((t=this._getSpaceLibs(e))==null?void 0:t.map(n=>n.docs).reduce((n,s)=>n+s,0))||0}_renderProgram(e,t){var a;const{app:n}=t,s=this._hasDocsOnly.value?(a=e.items)==null?void 0:a.filter(l=>this._getSpaceDocSum(Number(l.id))>0):e.items,r=n.props.libColors;let o;return e?s!=null&&s.length?o=g("div",{class:"row flex-wrap"},s.map(l=>{const c=this._getSpaceDocSum(l.id);return g("div",{className:"doc-space-card-lib p-1.5 w-1/5 group",key:l.id},g("div",{class:"canvas border rounded py-2 px-3 col gap-1 hover:shadow-lg hover:border-primary relative cursor-pointer",onClick:this._handleSpaceClick,"z-space":l.id},g($e,{icon:"doclib text-2xl",style:r?{color:r[Number(l.id)%r.length]}:null}),g("div",{class:"font-bold text-clip",title:l.text},l.text),g("div",{class:"text-gray text-sm"},c?n.getLang("docsTotalInfo",[c],"共 {0} 个文档"):n.getLang("noDocs","没有文档"))))})):o=g("div",{className:"center gap-4 py-3"},g("div",{className:"text-gray"},n.getLang(n.spaceType==="product"?"noProducts":"noProjects"))):o=g("div",{className:"relative load-indicator loading center gap-4 h-4 py-3"}),g("div",{class:"doc-space-card ring rounded surface-light",key:e.id},g("header",{class:"row items-center justify-between gap-2 px-2.5 py-1 border-b"},g("div",{class:"row items-center gap-2 flex-none cursor-pointer hover:text-primary","zui-command":`selectSpace/${e.id}/true`},g($e,{icon:"docspace",className:"w-4 h-4 center rounded-md text-gray-600 flex-none"}),g("div",{className:"min-w-0 flex-auto"},g("strong",null,e.text)))),g("div",{class:"doc-space-card-libs p-1.5",style:"min-height: 118px"},o))}_renderBody(e){const t=this._pagedProgramList.value;return g("div",{key:"body",class:"doc-app-body flex-auto min-h-0 col gap-4 p-4 items-stretch overflow-auto scrollbar-hover"},t.map(n=>this._renderProgram(n,e)),t.length===0?g("div",{className:"center text-gray h-full"},e.app.getLang("noDataYet","暂无数据")):null)}_renderFooter(e){const t=e.app.getPagerOptions({className:"flex-none",...e.app.signals.pager.value,recTotal:this._programList.value.length,onChangePageInfo:this._handleChangePager},{type:"home"});return g("div",{key:"footer",class:"doc-app-footer surface-light row items-center border-t py-1.5 px-2"},g("div",{class:"flex-auto"}),g(Xr,{...t}))}componentDidMount(){var t,n;this.props.app.resetPager("home",{recTotal:this._programList.value.length,recPerPage:5});const e=(n=(t=this.props.app.props).getSpaceFetcher)==null?void 0:n.call(t,this.props.app.spaceType);e&&Ne(e).then(s=>void(this._programData.value=s))}componentWillUnmount(){this._autoLoadLibs()}render(e){return[this._renderHeader(e),this._renderBody(e),this._renderFooter(e)]}}class ES extends re{constructor(){super(...arguments),this._dtable=pe(),this._handleCellClick=(e,t)=>{var s;const n=(s=t.rowInfo)==null?void 0:s.data;this.props.app.selectDoc(n)}}_getCols(){return[{name:"title",onRenderCell:function(e,t){const n=t.row.data;return[{className:`api-list-item row items-center my-0.5 mx-1 gap-2 flex-auto is-${n.method} cursor-pointer rounded`,html:[`<div class="font-mono w-14 text-center api-method py-1 rounded rounded-r-none">${n.method}</div>`,`<div class="font-mono api-path">${n.path}</div>`,`<div class="flex-auto text-right api-title pr-2">${n.originTitle}</div>`].join("")}]}}]}_getTableOptions(e){var h;const{app:t,docs:n}=e,s=t.lib,r=s==null?void 0:s.data.orderBy;let o="",a="";typeof r=="string"&&r&&([o,a]=r.split("_"));const l=n.map(d=>d.data);["order","id"].includes(o)&&a&&(a==="asc"?l.sort(o==="order"?(d,f)=>d.order-f.order:(d,f)=>(d.rawID??+d.id)-(f.rawID??+f.id)):l.sort(o==="order"?(d,f)=>f.order-d.order:(d,f)=>(f.rawID??+f.id)-(d.rawID??+d.id)));const c={width:"100%",height(d){var p;const f=(p=this.element)==null?void 0:p.parentElement;return f?Math.min(d,f.clientHeight):d},cols:this._getCols(),data:l,header:!1,checkable:!1,footer:["flex","pager"],localPager:!0,emptyTip:g("div",{className:"center gap-4"},g("div",{className:"text-gray"},t.getLang("noApi","没有 API")),Fe.render({items:t.getActions("doc-list",{ui:"doc-list-empty"})},[])),footPager:{items:t.getPagerItems()},onCellClick:this._handleCellClick};return((h=t.getTableOptions)==null?void 0:h.call(t,c,{type:"api-list"}))??c}render(e){return g("div",{class:U("doc-list doc-api-list h-full col",e.className)},g(ii,{ref:this._dtable,...this._getTableOptions(e)}))}}class er extends ve{static update(e){v.trigger("load.HistoryPanel",e)}}er.NAME="HistoryPanel",er.Component=Su,er.replace=!0,er.register();function Tu(i){const{objectType:e,objectID:t,actionID:n,url:s,...r}=i;let o=s;return!o&&(n||e&&t)&&(o=ut("action",n?"editComment":"comment",n?`actionID=${n}`:`objectType=${e}&objectID=${t}`)),He.open({id:`modal-comment-${n?`edit-${n}`:`${e}-${t}`}`,url:o,hideOthers:!1,...r})}v(document).on("click.zt",'[data-toggle="comment"]',i=>{i.preventDefault();const e=v(i.currentTarget);if(e.is(".disabled,:disabled"))return;const t=e.data();if(e.is("a")){const n=e.attr("href");n&&(t.url=n)}t.objectId?(t.objectID=+t.objectId,delete t.objectId):t.actionId&&(t.actionID=+t.actionId,delete t.actionId),delete t.toggle,Tu(t)}),Object.assign(He,{comment:Tu});const _M="",$u=class nw extends Er{constructor(e){var t;super(e),this._loadingDocs=new Map,this._viewRef=pe(),this._homeRef=pe(),this._treeMap=Ce(()=>{const{spaceID:n,libs:s,modules:r,docs:o}=this.signals;return aS(n.value,{libs:s.value,modules:r.value,docs:o.value},!!this.props.noSpace)}),this._space=Ce(()=>{const{spaces:n,spaceID:s}=this.signals,r=s.value;return n.value.find(o=>o.id===r)}),this._spaceList=Ce(()=>{const{spaces:n,spaceType:s}=this.signals,r=s.value;return n.value.filter(o=>!o.deleted&&o.type===r)}),this._libList=Ce(()=>this._treeMap.value.libList),this._docList=Ce(()=>{const{lib:n,module:s,doc:r}=this;return(r==null?void 0:r.data.type)==="chapter"?this._filterDocs(ao(r,[],!0),{api:(n==null?void 0:n.data.type)==="api"}):s||n?this._filterDocs(ao(s||n,[],!0),{api:(n==null?void 0:n.data.type)==="api"}):this._filterDocs(void 0,{api:!1})}),this._doc=Ce(()=>this._treeMap.value.docs.get(this.signals.docID.value)),this._viewingDoc=Ce(()=>{const n=this._doc.value,s=this.signals.docVersion.value;return!n||!s||s===n.data.version||!n.data.versions?n:{...n,data:{...n.data,...n.data.versions[s]||{content:null},currentVersion:s}}}),this._module=Ce(()=>{var s;const n=((s=this._doc.value)==null?void 0:s.data.module)||this.signals.moduleID.value;return this._treeMap.value.modules.get(n)}),this._lib=Ce(()=>{var s;const n=((s=this._module.value)==null?void 0:s.data.lib)||this.signals.libID.value;return this._treeMap.value.libs.get(n)}),this._viewType=Ce(()=>this._viewInfo.value[0]),this._viewInfo=Ce(()=>{var a;const n=this.signals.mode.value;let s;const r=this.signals.creatingDoc.value,o=this.signals.editingDoc.value;if(n==="create")s=r;else if(n==="edit"){const l=this.getDoc(o==null?void 0:o.id);s=o,l&&s&&(s={...s,collects:l.collects,isCollector:l.isCollector,views:l.views,files:l.files})}else(n==="view"||n==="diff")&&(s=((a=this._viewingDoc.value)==null?void 0:a.data)||this._getLocalDoc(this.signals.docID.value));return[n,s]}),this._docUsers=Ce(()=>{const n=this._doc.value;if(!n)return[];const{addedBy:s,editedBy:r}=n.data;return[this.getUserInfo(s),r?this.getUserInfo(r):void 0]}),this._hasEditingDoc=Ce(()=>!!this._editingDoc.value),this._editingDoc=Ce(()=>{const[n,s]=this._viewInfo.value;return n==="edit"||n==="create"?s:void 0}),this._canShowLibFiles=Ce(()=>{const n=this.signals.spaceType.value;let{showLibFiles:s}=this.props;return typeof s=="function"?s=s.call(this,n):Array.isArray(s)&&(s=s.includes(n)),s}),this._location=Ce(()=>{var p;const{spaceType:n,spaceID:s,libID:r,moduleID:o,docID:a,pager:l,searchKeys:c,docVersion:h,mode:d,params:f}=this.signals;return{mode:d.value,spaceType:n.value,spaceID:s.value,libID:r.value,moduleID:o.value,docID:a.value,docVersion:h.value,search:(p=c.value)==null?void 0:p.join(" "),filterType:this.filterType,pager:l.value,noSpace:this.props.noSpace,orderBy:"",params:f.value}}),this._filterType=Ce(()=>this.signals.filterType.value[this.signals.mode.value]??"all"),this._modeEffect=_t(()=>{var o,a;const{mode:n}=this.signals;let{useHocuspocus:s}=this.props;const{onModeChange:r}=this.props;s=typeof s=="function"?s(this):s,s&&((a=(o=this.editor)==null?void 0:o.destroyHocuspocusProvider)==null||a.call(o)),r==null||r(this,n.value)}),this._handleDocChange=(n,s)=>{if(s==="create"){const r=this.signals.creatingDoc.value;r&&(r.title!==n.title||r.content!==n.content||r.keywords!==n.keywords||r.html!==n.html)&&(this.signals.creatingDoc.value={...r,...n,changed:!0,contentType:n.contentType||r.contentType})}else if(s==="edit"){const r=this.signals.editingDoc.value;r&&(r.title!==n.title||r.content!==n.content||r.keywords!==n.keywords||r.html!==n.html)&&(this.signals.editingDoc.value={...r,...n,changed:!0,contentType:n.contentType||r.contentType})}},this._getFileActions=n=>{var s;return this.getActions("file",{ui:"doc-view",data:n,doc:(s=this.doc)==null?void 0:s.data})},this._handleSearch=n=>{this.signals.searchKeys.value=dt.getSearchKeys(n)},this._handleFilterTypeClick=n=>{const s=n.target,r=s.getAttribute("data-type");if(r){const o=s.getAttribute("data-view");this.setFilterType(r,o)}},this._preserve=e.preserve??((t=this.element)==null?void 0:t.closest(".modal"))?"":`docapp_${window.config.currentModule}_${window.config.currentMethod}`,this.selectSpace=this.selectSpace.bind(this),this.selectDoc=this.selectDoc.bind(this),this.selectLib=this.selectLib.bind(this),this.selectModule=this.selectModule.bind(this),this.getUserInfo=this.getUserInfo.bind(this),this.selectDocVersion=this.selectDocVersion.bind(this),this.diffDocVersions=this.diffDocVersions.bind(this),this.onDiffModeChange=this.onDiffModeChange.bind(this),this.showFiles=this.showFiles.bind(this),this.getActions=this.getActions.bind(this),this.getItemActions=this.getItemActions.bind(this),this.executeCommand=this.executeCommand.bind(this),this.getTableOptions=this.getTableOptions.bind(this),this.toggleFullscreen=this.toggleFullscreen.bind(this)}get preserve(){return this._preserve}get spaceType(){return this.signals.spaceType.value}get spaceID(){return this.signals.spaceID.value}get libID(){return this.signals.libID.value}get moduleID(){return this.signals.moduleID.value}get docID(){return this.signals.docID.value}get docVersion(){return this.signals.docVersion.value}get diffMode(){return this.signals.diffMode.value}get space(){return this._space.value}get lib(){return this._lib.value}get module(){return this._module.value}get doc(){return this._doc.value}get treeMap(){return this._treeMap.value}get docList(){return this._docList.value}get docUsers(){return this._docUsers.value}get viewInfo(){return this._viewInfo.value}get libList(){return this._libList.value}get spaceList(){return this._spaceList.value}get mode(){return this.signals.mode.value}get canShowLibFiles(){return this._canShowLibFiles.value}get hasEditingDoc(){return this._hasEditingDoc.value}get location(){return this._location.value}get filterType(){return this._filterType.value}get editor(){var e,t;return(t=(e=this._viewRef.current)==null?void 0:e.editor)==null?void 0:t.editor}get editor$(){var e,t,n;return(n=(t=(e=this._viewRef.current)==null?void 0:e.editor)==null?void 0:t.editor)==null?void 0:n.$}get fullscreen(){return this.signals.fullscreen.value}get editingDoc(){return this._editingDoc.value}get editingUsers(){var e;return((e=this.signals.editingUsers)==null?void 0:e.value)||[]}_filterDocs(e,t){var n;if(e=e||this.signals.docs.value,e.length){const{api:s,chapter:r}=t||{},o=this.signals.searchKeys.value||[],a=this.filterType,l="key"in e[0],{currentUser:c,isMatchFilter:h,noSpace:d}=this.props,f=h?h.bind(this,"doc",a):w=>a==="createdByMe"?w.addedBy===c:a==="editedByMe"?w.editedBy===c:a==="draft"?w.status==="draft":a==="collected"?w.isCollector:!0;if(l&&!o.length)return a!=="all"&&a?e.filter(w=>f(w.data)):e;const p=this.signals.spaceID.value,y=this._treeMap.value,b=((n=this.props.docFilterProps)==null?void 0:n.map(w=>typeof w=="function"?w.bind(this):w))||["id","title","keywords","addedBy","editedBy",w=>this.getUserInfo(w.addedBy).realname,w=>{const x=w.editedBy;return x?this.getUserInfo(x).realname:void 0}];return e.reduce((w,x)=>{const T=l?x.data:x;if(T.deleted||!r&&T.type==="chapter"||s!==void 0&&!!T.api!==s||a&&!f(T)||o.length&&!dt.isItemMatch(T,o,b))return w;const D=y.libs.get(T.lib);return(d||T.lib===p||D&&D.data.space===p)&&w.push(l?x:y.docs.get(T.id)),w},[])}return[]}_getLocalDoc(e){if(e)return{id:e,type:"text",rawID:bv(e),parent:0,contentType:"doc",content:"",title:"",addedBy:"",lib:this.libID,module:this.moduleID,addedDate:Ze(new Date),order:0,local:!0}}loadHomeLibs(){var e;(e=this._homeRef.current)==null||e.loadLibs()}toggleFullscreen(){v.toggleFullscreen({target:document.body,afterEnter:()=>{this.signals.fullscreen.value=!0,v("body").addClass("has-doc-app-fullscreen")},afterExit:()=>{v("body").removeClass("has-doc-app-fullscreen"),this.signals.fullscreen.value=!1}})}toggleViewSideTab(e){var t,n,s;return(s=(n=(t=this._viewRef)==null?void 0:t.current)==null?void 0:n.sidebar)==null?void 0:s.toggleTab(e)}getDefaultState(e){e=e||this.props;const{data:t,fetcher:n,mode:s="home",filterType:r="all",pager:o,search:a,docVersion:l=0,defaultState:c,params:h}=e,d=this.formatData({libTypes:e.libTypes||[],...t},e);return{loading:!!(!t&&n),editingDoc:void 0,creatingDoc:void 0,searchKeys:dt.getSearchKeys(a),fullscreen:!1,filterType:{[s]:r},docVersion:l,diffMode:!1,mode:s,highlightView:!1,editingUsers:[],pager:o,params:h,diffVersions:[],...c,...d}}resetState(e){super.resetState(e),requestAnimationFrame(()=>this.reload())}getDataSignal(e){const{signals:t}=this;return e==="doc"?t.docs:e==="module"?t.modules:e==="lib"?t.libs:t.spaces}getCurrentItem(e){var t,n,s;return e==="doc"?(t=this._doc.value)==null?void 0:t.data:e==="module"?(n=this._module.value)==null?void 0:n.data:e==="lib"?(s=this._lib.value)==null?void 0:s.data:this._space.value}getSpace(e){return e?this.signals.spaces.value.find(t=>t.id===e):this._space.value}getLib(e){return e?this.treeMap.libs.get(e):this._lib.value}getDoc(e){var t,n;return e=e||((t=this._doc.value)==null?void 0:t.data),typeof e!="object"&&(e=e?(n=this._treeMap.value.docs.get(e))==null?void 0:n.data:void 0),e}getUserInfo(e){const{userMap:t={}}=this.props,n=t[e];return n?typeof n=="string"?{account:e,realname:n}:{...n,account:e}:{account:e,realname:e}}getDownloadUrl(e,t){if(t=t||this.props.downloadUrl,!t)return;let n="";if(e.startsWith("data:"))n=e;else if(/https?:\/\//.test(e)){const s=window.EDITOR_IMAGE_PROXY_ENDPOINT;n=s?`${s}?url=${encodeURIComponent(e)}`:e}else if(e.startsWith("attachment:")){const s=e.substring(11).split("/")[0];n=De(t,{objectType:"doc",objectID:this.docID,gid:"",title:btoa(s),extra:""})}else n=De(t,{objectType:"doc",objectID:this.docID,gid:btoa(`g-${e}`),title:"",extra:"editor"});return n}downloadFile(e,t){const n=this.getDownloadUrl(e);if(n)return!t&&e.startsWith("attachment:")&&(t=decodeURIComponent(e.substring(11).split("/")[0])),Xn(n,t)}async switchView(e,t){if(!await this.checkEditingDoc())return;t=t||this.mode;const{spaceType:n,spaceID:s,libID:r,moduleID:o,docID:a,params:l,filterType:c,pager:h}=e,{fetchOnChangeSpace:d,fetcher:f}=this.props,p=n&&this.signals.spaceType.value!==n||s!==void 0&&this.signals.spaceID.value!==s,y=d&&f&&p,b={...n?{spaceType:n}:null,...s!==void 0?{spaceID:s}:null,...r!==void 0?{libID:r}:null,...o!==void 0?{moduleID:o}:null,...a!==void 0?{docID:a}:null,...l!==void 0?{params:l}:null,...c!==void 0?{filterType:{...this.signals.filterType.value,[t]:c}}:null,...h!==void 0?{pager:{...this.signals.pager.value,...h}}:null,mode:t};return this.changeState(b,async()=>{y&&await this.load(f,this.signals.spaceType.value,s),a&&t==="edit"?this.startEditDoc(a):t==="create"?this.startCreateDoc():t==="files"?this.showFiles():t==="home"&&this.goHome()})}setFilterType(e,t){this.signals.filterType.value={...this.signals.filterType.value,[t||this.mode]:e}}exportDoc(e="pdf",t){var s;const n=this.editor;if(n instanceof ai)return(s=n.$)==null?void 0:s.export(e,t)}importDoc(e,t,n){var r,o,a;const s=this.editor;s instanceof ai&&((r=s.$)==null||r.updateDoc(e,t==="json"?"snapshot":t,n),typeof n=="string"&&((a=(o=this._viewRef.current)==null?void 0:o.editor)==null||a.setTitle(n)))}getLang(e,t=[],n){const{langData:s}=this.props;let r;if(typeof t=="string"?(n=t,r=[]):r=Array.isArray(t)?t:[t],!s)return n??(Array.isArray(e)?e.join("."):e);const o=Array.isArray(e)?ki(s,e):s[e]??n;return typeof o=="function"?o.call(this,...r):typeof o=="string"&&r.length?De(o,...r):o}getActions(e,t){const{getActions:n}=this.props,s=n?n.call(this,e,t):[];return s!=null&&s.length&&t.ui?s.filter(r=>r&&(!r.ui||r.ui.split(",").includes(t.ui))):s||[]}getFilterTypes(e){const{getFilterTypes:t}=this.props;return t?t.call(this,e)||[]:[["all","All"]]}getTableOptions(e,t){const{getTableOptions:n}=this.props;return n?n.call(this,e,t):e}getDocIcon(e){if(e.icon)return e.icon;const{getDocIcon:t,docIcon:n,attachmentIcon:s,chapterIcon:r}=this.props;let o;return t?o=t.call(this,e):e.contentType==="attachment"?o=s:e.type==="chapter"?o=r:o=n,o||nw.defaultProps.docIcon}getPagerItems(){return[{type:"info",text:this.getLang("recTotalFormat","共 {recTotal} 项")},{type:"size-menu",text:this.getLang("recPerPageFormat","每页 {recPerPage} 项"),placement:"top",caret:"up"},{type:"link",page:"first",hint:this.getLang("firstPage","第一页"),icon:"icon-first-page"},{type:"link",page:"prev",hint:this.getLang("prevPage","上一页"),icon:"icon-angle-left"},{type:"info",text:"{page}/{pageTotal}"},{type:"link",page:"next",hint:this.getLang("nextPage","icon-angle-right"),icon:"icon-angle-right"},{type:"link",page:"last",hint:this.getLang("lastPage","最后一页"),icon:"icon-last-page"}]}getPagerOptions(e,t){const{getPagerOptions:n}=this.props,s=n?n.call(this,e,t):e;return s.items||(s.items=this.getPagerItems()),s}getSortableOptions(e){const{getSortableOptions:t}=this.props;return t==null?void 0:t.call(this,e)}getItemActions(e,t,n){const s=t==="current"?this.getCurrentItem(e):typeof t=="number"?this.getDataSignal(e).value.find(r=>r.id===t):t;return s?this.getActions(e,{ui:n,data:s}):(console.warn(`[ZUI] getItemActions: ${e} data with ID "${t}" not found.`),[])}async selectSpace(e,t,n){var a,l;if(!await this.checkEditingDoc())return;e==="_first"&&(e=((a=this.spaceList[0])==null?void 0:a.id)??0);const{fetchOnChangeSpace:s,fetcher:r,autoSelectLib:o}=this.props;if(n===void 0&&(n=!!(s&&r&&(this.signals.spaceID.value!==e||typeof t=="number"&&t!==this.signals.libID.value))),!(this.signals.spaceID.value===e&&!t))return this.changeState({spaceID:e,mode:"list",...t?{libID:typeof t=="number"?t:o&&!n?((l=this.libList[0])==null?void 0:l.data.id)??0:0,moduleID:0,docID:0}:null,...n?{data:void 0,loading:!0}:null},()=>{n&&this.load(r,this.signals.spaceType.value,e)})}async selectDoc(e,t){if(!await this.checkEditingDoc())return;typeof e!="object"&&(e=this.getDoc(e));const n=e?e.id:0;return this.changeState({mode:!n||(e==null?void 0:e.type)==="chapter"?"list":"view",diffMode:!1,docID:n,...n!==this.signals.docID.value?{docVersion:0}:null,...e?{libID:e.lib,moduleID:e.module}:null,...t!==void 0?{docVersion:+t}:null})}async goHome(){if(await this.checkEditingDoc())return this.changeState({libID:0,moduleID:0,docID:0,mode:"home"})}getDefaultPager(e){const{getDefaultPager:t}=this.props,n=this._preserve?nt.get(`${this._preserve}:pager:${e}`):null;return t?t.call(this,e):{page:1,recTotal:0,recPerPage:typeof n=="number"?n:20,pageTotal:0}}resetPager(e,t){const n={...this.getDefaultPager(e),...this.signals.pager.value,...t};this.signals.pager.value=n;const{preserve:s}=this;s&&nt.set(`${s}:pager:${e}`,n.recPerPage)}async showFiles(){if(this.canShowLibFiles&&await this.checkEditingDoc())return this.changeState({libID:0,moduleID:0,docID:0,mode:"files",pager:this.getDefaultPager("files")})}async selectLib(e,t){if(!await this.checkEditingDoc())return;const n=this._module.value;n&&t===void 0&&n.data.lib!==e&&(t=0),t===void 0&&(t=this.signals.moduleID.value);const s=e?this.treeMap.libs.get(e):null;if(!(e&&!s||t&&!this.treeMap.modules.get(t)))return this.changeState({libID:e,moduleID:t,mode:"list",docID:0})}selectDocVersion(e,t){const n=this.signals.docID.value;t=t||n;const s=this.getDoc(t);s&&(e=Math.max(0,Math.min(+e,s.version??0)),this.changeState({mode:"view",docID:t,docVersion:e}))}diffDocVersions(e){this.changeState({mode:"diff",diffVersions:e})}onDiffModeChange(e){this.changeState({diffMode:e})}async selectModule(e,t){if(!await this.checkEditingDoc())return;const n=this._doc.value;return this.changeState({moduleID:e,...t||n&&e!==n.data.id?{docID:0,mode:"list"}:null})}setData(e,t){var r;const{signals:n}=this,s=this.formatData(e,{spaceType:n.spaceType.value,spaceID:n.spaceID.value,libID:n.libID.value,moduleID:n.moduleID.value,docID:n.docID.value});return this.changeState({...s,...t,libTypes:(r=s.libTypes)!=null&&r.length?s.libTypes:n.libTypes.value})}async checkEditingDoc(){if(this._hasEditingDoc.value){const[,e]=this._viewInfo.value;if(e!=null&&e.changed){this.signals.highlightView.value=!0;const t=await He.confirm(this.getLang("leaveEditingConfirm","文档编辑中,确定要离开吗?"));if(this.signals.highlightView.value=!1,!t)return!1}await this.changeState({editingDoc:void 0,creatingDoc:void 0,docVersion:0})}return!0}async load(e,t,n,s){var r,o;if(e=e||this.props.fetcher,e){const{signals:a}=this;t=t||a.spaceType.value,n=n||a.spaceID.value;const{noLoading:l=!1,picks:c=[]}=s||{},h=typeof c=="string"?[c]:c;await this.changeState({loading:!l,spaceType:t,spaceID:n});const d=await Ne(e,[{spaceType:t,spaceID:n,picks:h,noSpace:!!this.props.noSpace}],void 0,this);await this.setData(h?{spaces:a.spaces.value,libs:a.libs.value,modules:a.modules.value,docs:a.docs.value,spaceID:a.spaceID.value,libTypes:a.libTypes.value,...this.props.autoSelectLib?{libID:((o=(r=d.libs)==null?void 0:r[0])==null?void 0:o.id)??0}:{},...d}:d,l?void 0:{loading:!1})}}isLoadingDoc(e){return this._loadingDocs.has(e)}async loadTemplate(e,t){const n=this.props.templateFetcher||this.props.docFetcher;if(!n)throw new Error("[ZUI] DocApp: templateFetcher or docFetcher is not set.");return await Ne(n,[{docID:e,version:t}],void 0,this)}async fetchDoc(e,t=0,n,s){if(n=n||this.props.docFetcher,!n)return;const r=await Ne(n,[{docID:e,version:t}],void 0,this),o=this.formatDataItem("doc",{...s,...r,id:e,local:!1});if(o&&(this.props.autoConvertDoc||o.status==="draft"))if(o.contentType==="html"&&o.content&&o.$convert===void 0){const a=await gt.htmlToSnap(o.content);o.$convert=!!a}else o.$convert=!1;return o}async loadDoc(e,t,n){var l;let s=this.getDoc(e)||this._getLocalDoc(e);if(!s||((l=this.props.privs)==null?void 0:l.view)===!1)return;if(n=n||this.props.docFetcher,!n){if(s.api)return;n=()=>t?{id:e,content:"",version:t}:{id:e,content:""}}const r=this._loadingDocs;if(r.has(e))return new Promise(c=>{r.get(e).push(c)});r.set(e,[]),t=t||s.version||0;const o=!t||t===s.version||!s.version,a=await this.fetchDoc(e,t,n,s);if(a){const c=o?this.formatDataItem("doc",{...s,...a,id:e,local:!1}):{...s,...a.version?{version:a.version}:null,...a.privs?{privs:a.privs}:null,...a.editable!==void 0?{editable:a.editable}:null,versions:{...s.versions,[t]:this.formatDataItem("doc",a)},contentType:a.contentType||s.contentType,local:!1};s=this.update("doc",c,{keepDeleted:!0})}return r.get(e).forEach(c=>c(s)),r.delete(e),s}formatDataItem(e,t,n,s){if(e==="module")t.lib=+(t.lib??t.root),t.parent=+(t.parent??0);else if(e==="lib"){const o=t;o.space=o.space??n,o.space=String(+o.space)===String(o.space)?+o.space:o.space}else e==="space"&&(t.type=t.type??s);if(t.id=ri(t.id),t.deleted=typeof t.deleted=="string"?!!JSON.parse(t.deleted):t.deleted,e==="doc"){const o=t;if(o.files){!Array.isArray(o.files)&&typeof o.files=="object"&&(o.files=Object.values(o.files));for(const a of o.files)a.id=+a.id,a.size=+a.size,a.downloads=a.downloads?+a.downloads:0,a.deleted=typeof a.deleted=="string"?!!JSON.parse(a.deleted):a.deleted}o.api===void 0&&(o.api=typeof t.id=="string"&&t.id.startsWith("api.")),o.rawID=bv(t.id),o.product=+(o.product??0),o.project=+(o.project??0),o.execution=+(o.execution??0),o.version=+(o.version??0),o.views=+(o.views??0),o.module=+(o.module??0),o.lib=+(o.lib??0),o.collects=+(o.collects??0),o.contentVersion&&(o.contentVersion=+o.contentVersion,Number.isNaN(o.contentVersion)||(o.currentVersion=o.contentVersion)),o.editable!==void 0&&(o.privs={...o.privs,edit:o.editable}),o.contentType==="attachment"&&(o.contentType="html"),o.parent&&(o.parent=ri(o.parent)),o.draft&&(typeof o.draft=="string"?o.draft=o.status==="draft"?{id:0,doc:o.id,content:o.content,contentType:o.contentType,title:o.title,version:0,addedBy:o.addedBy,addedDate:o.addedDate}:null:(o.draft.type&&(o.draft.contentType=o.draft.type),o.draft.rawContent&&(o.draft.content=o.draft.rawContent,delete o.draft.rawContent),o.status==="draft"&&(o.contentType=o.draft.contentType,o.content=o.draft.content))),o.rawContent&&(o.content=o.rawContent,delete o.rawContent),!o.collects&&o.isCollector&&(o.collects=1),o.editedBy===o.addedBy&&o.editedDate===o.addedDate&&(delete o.editedBy,delete o.editedDate)}typeof t.order!="number"&&typeof t.id=="number"&&(t.order=t.id);const{formatDataItem:r}=this.props;return r?r.call(this,e,t,n,s):t}formatData(e,t){let{libID:n=0,moduleID:s=0,docID:r,spaceID:o=0}=t;n&&(n=+n),s&&(s=+s),r&&(r=ri(r));const{spaceType:a}=t,{libs:l=[],modules:c=[],docs:h=[],spaces:d=[],spaceID:f,libTypes:p=[]}=e||{};let y,b,w,x;return f&&(o=f),o=ri(o),l.forEach(T=>{this.formatDataItem("lib",T,f)}),l.sort((T,D)=>(T.order??T.id)-(D.order??D.id)),d.forEach(T=>{this.formatDataItem("space",T,f,a)}),c.forEach(T=>{this.formatDataItem("module",T,f)}),h.forEach(T=>{this.formatDataItem("doc",T,f)}),r?y=h.find(T=>T.id===r):r=0,y&&!s&&(s=y.module??0),s&&(b=c.find(T=>T.id===s)),n=b?b.lib:n,!n&&this.props.autoSelectLib&&(w=l[0],n=w?w.id:0),n&&(!w||w.id!==n)&&(w=l.find(T=>T.id===n)),o=w?w.space:o,!this.props.noSpace&&d.length&&(x=d.find(T=>T.id===o)),o||(x=d[0],o=x?x.id:o),!o&&l.length&&(o=l[0].space),{spaceType:(x?x.type:a)||"mine",libs:l,modules:c,docs:h,spaces:d,spaceID:o,libID:n,moduleID:s,docID:r,libTypes:p}}batchUpdate(e,t){gs(()=>{Object.keys(e).forEach(n=>{const s=e[n];this.update(n,s)}),t&&this.changeState(t)})}update(e,t,n){const s=!Array.isArray(t),r=s?[t]:t,o=this.getDataSignal(e),a=[],l=o.value,c=this.signals.spaceID.value,h=n==null?void 0:n.keepDeleted;return r.forEach(d=>{const f=ri(d.id),p=l.findIndex(b=>b.id===f),y=p>=0?{...l[p],...d}:d;if(this.formatDataItem(e,y,c),y.deleted&&!h)p>=0&&(l[p]=y);else if(p>=0){if(e==="doc"){const b=l[p],w=y,x=w.contentVersion??w.version;b.version!==x&&Object.assign(y,{version:Math.max(b.version,x),versions:{...b.versions,[b.version]:b,[x]:y}}),er.update({objectType:"doc",objectID:+y.id})}l[p]=y}else l.push(y);a.push(y)}),o.value=[...l],s?a[0]:a}delete(e,t){Array.isArray(t)||(t=[t]);const n=new Set(t);if(!n.size)return!1;const s=this.getDataSignal(e),r=s.value;return!r||!Array.isArray(r)||!r.length?!1:(gs(()=>{const o=new Set;e==="module"||e==="lib"?t.forEach(l=>{const c=e==="module"?this.treeMap.modules.get(l):this.treeMap.libs.get(l);c&&c.docs.forEach(h=>o.add(h.data.id))}):e==="doc"&&t.forEach(l=>{const c=this.treeMap.docs.get(l);c!=null&&c.docs.length&&ao(c,[],!0).forEach(h=>o.add(h.id))}),s.value=r.filter(l=>!n.has(l.id)),o.size&&this.delete("doc",[...o]);const a=this.docID;(e==="doc"&&t.includes(a)||o.has(a))&&this.selectDoc(0)}),!0)}async startCreateDoc(e,t,n){e=e??this.signals.libID.value,t=t??this.signals.moduleID.value;let s=this.signals.creatingDoc.value;if(!(s&&s.lib===e&&s.module===t))return s=await this._getCreatingDoc(n),this.changeState({libID:e,moduleID:t,creatingDoc:s,mode:"create"})}cancelCreateDoc(){return this.changeState({creatingDoc:void 0,mode:"list"})}async saveNewDoc(e){var c,h,d,f,p,y,b;await((h=(c=this._viewRef.current)==null?void 0:c.editor)==null?void 0:h.triggerChange(void 0,{getHtml:!0}));const{signals:t}=this,n=t.creatingDoc.value;if(!n)return;if(n.title.trim()===""){await He.alert(this.getLang("docTitleRequired","文档标题不能为空。")),(f=(d=this._viewRef.current)==null?void 0:d.editor)==null||f.focusTitle();return}const s=t.spaceID.value,r=t.libID.value,o=t.moduleID.value,a=await((p=this.props.onCreateDoc)==null?void 0:p.call(this,{...n,status:e||"normal",lib:t.libID.value,module:t.moduleID.value},s,r,o));if(!a)return He.alert(this.getLang("saveDocFailed","文档保存失败,请稍后重试"));const l=+a.space.split(".")[1];return l!==s&&l===l?(await this.changeState({creatingDoc:void 0}),await this.selectSpace(l,a.lib),this.selectDoc(a)):(a.rawContent&&(a.content=a.rawContent),(b=(y=this._viewRef.current)==null?void 0:y.editor)==null||b.removeCache(),this.changeState({docs:[...t.docs.value,a],docID:a.id,libID:a.lib,moduleID:a.module,creatingDoc:void 0,mode:"view"}))}async startEditDoc(e,t){var c,h;if(e=e||((c=this._doc.value)==null?void 0:c.data),typeof e!="object"&&(e=this.getDoc(e)),!e)return;const n=t==null?void 0:t.loadDoc,s=e.version||0;if((n===!0||n!==!1&&!e.api&&(e.content===void 0||e.content===null)||n===void 0&&!e.api&&this.docVersion!==s)&&(e=await this.fetchDoc(e.id,s),!e))return;if(e.editable===!1||((h=e.privs)==null?void 0:h.edit)===!1)return He.alert(this.getLang("needEditable","您没有当前文档的编辑权限。"));const r=!!((t==null?void 0:t.convert)??e.$convert),{content:o,contentType:a,title:l=""}=e.draft||e;await this.changeState({docID:e.id,libID:e.lib,moduleID:e.module,editingDoc:{...e,title:l,contentType:a,content:o,...t==null?void 0:t.template,changed:!1,$convert:r,$html:r?e.content:void 0},mode:"edit"})}async restoreDoc(e,t){var c,h,d;let n=this.getDoc(e);if(!n)return;t=+t;const s=await this.loadDoc(e,t);if(n={...n,...s},((c=n.privs)==null?void 0:c.edit)===!1||n.editable===!1)return He.alert(this.getLang("needEditable","您没有当前文档的编辑权限。"));const r=(h=n.versions)==null?void 0:h[t];if(!r)return;let o=r.html;o===void 0&&r.content&&(o=await gt.convertToHtml(r.content));const a=await((d=this.props.onSaveDoc)==null?void 0:d.call(this,{...n,content:r.content,contentType:r.contentType,html:o,title:r.title,fromVersion:t,files:r.files}));if(a===!1)return;const l=typeof a=="object"?a.version:n.version+1;if(typeof a=="object"){const f={...n,version:l,contentVersion:l,...a};this.update("doc",f)}this.selectDoc(e,l),this.selectDocVersion(l)}cancelEditDoc(e){return this.changeState({mode:"view",editingDoc:void 0,docVersion:0,...e})}async saveDoc(e){var o,a,l,c,h;await((a=(o=this._viewRef.current)==null?void 0:o.editor)==null?void 0:a.triggerChange(void 0,{getHtml:!0}));const t=this.signals.editingDoc.value;if(!t)return this.cancelEditDoc();const n=this.getDoc(t.id);let s={...n,...t,status:e||"normal"};s.contentType==="doc"&&(s.$convert=!1);const r=await((l=this.props.onSaveDoc)==null?void 0:l.call(this,s));if(r!==!1){if((h=(c=this._viewRef.current)==null?void 0:c.editor)==null||h.removeCache(),r&&(r!==!0&&Object.assign(s,r),s=this.update("doc",s),s.lib!==(n==null?void 0:n.lib))){this.cancelEditDoc(),this.selectDoc(s);return}this.cancelEditDoc()}}reload(e=!1){const{fetcher:t,data:n,mode:s,docID:r,libID:o,moduleID:a}=this.props,l=()=>{s==="edit"&&r?this.startEditDoc(r):s==="create"?this.startCreateDoc(o,a,{templateID:r}):s==="files"?this.showFiles():s==="view"&&r===this.docID&&this.loadDoc(r,this.docVersion||this.doc.data.version)};e||t&&!n?this.load().then(l):l()}componentDidMount(){var e;super.componentDidMount(),this.reload(),this._viewEffect=_t(()=>{var c,h,d,f;const{libID:t,moduleID:n,docID:s,diffVersions:r}=this.signals,o=s.value?"doc":n.value?"module":t.value?"lib":"space",a=s.value?(c=this._doc.value)==null?void 0:c.data:n.value?(h=this._module.value)==null?void 0:h.data:t.value?(d=this._lib.value)==null?void 0:d.data:this._space.value,l=this.signals.mode.value;(f=this.props.onSwitchView)==null||f.call(this,l,this._location.value,{type:o,title:a?o==="doc"?a.title:a.name:"",data:a,diffVersions:r.value})}),(e=this.props.onMounted)==null||e.call(this)}componentDidUpdate(e){var o;const{fetcher:t,data:n,spaceID:s,spaceType:r}=this.props;t&&!n&&(e.spaceType!==r||e.spaceID!==s)&&this.load(),(o=this.props.onUpdated)==null||o.call(this)}componentWillUnmount(){var e,t;(e=this._viewEffect)==null||e.call(this),this._modeEffect(),(t=this.props.onUnmounted)==null||t.call(this)}async _getCreatingDoc(e="doc"){const t=oS();if(typeof e!="object"&&(e={contentType:e||"doc"}),e.templateID){const n=await this.loadTemplate(e.templateID);n&&Object.assign(e,{contentType:n.contentType,content:n.content,title:n.title})}else{const n=wv({space:this.signals.spaceID.value,lib:this.signals.libID.value,module:this.signals.moduleID.value});n&&Object.assign(e,{contentType:n.contentType??e.contentType,content:n.content,title:n.title??e.title})}return{id:t,rawID:t,type:"text",parent:0,lib:this.signals.libID.value,module:this.signals.moduleID.value,title:"",content:"",addedBy:this.props.currentUser||"",addedDate:Ze(new Date,"yyyy-MM-dd hh:mm:ss"),uid:Ot(13).replaceAll("-","_"),order:0,...e}}_getClassName(e){return["doc-app",e.className,this._viewType.value!=="list"?"has-show-view":"",this.signals.fullscreen.value?"is-enter-fullscreen":"",`doc-app-mode-${this.mode}`]}_getProps(e){var t;return{...super._getProps(e),style:{width:Be(e.width),height:Be(e.height)},"data-view":this._viewType.value,"data-lib-type":(t=this._lib.value)==null?void 0:t.data.type,"data-space-type":this.spaceType}}_renderSidebar(e){var a,l;if(e.noSidebar)return null;const{libIcon:t,apiLibIcon:n,moduleIcon:s,currentUser:r}=e,o=this.spaceType;return g(sS,{key:"sidebar",app:this,className:"surface-light",preserve:this._preserve?`${this._preserve}-sidebar`:void 0,currentUser:r,libIcon:t,apiLibIcon:n,moduleIcon:s,spaceType:o,space:this._space.value,libs:this._libList.value,lib:this._lib.value,libTypes:this.signals.libTypes.value,showFiles:this.signals.mode.value==="files",moduleID:((a=this._module.value)==null?void 0:a.data.id)||0,docID:((l=this._doc.value)==null?void 0:l.data.id)||0,getActions:this.getItemActions,onSelectDoc:this.selectDoc,onSelectLib:this.selectLib,onShowFiles:this.canShowLibFiles?this.showFiles:void 0})}_renderFiles(){const e=this.renderCustom("files");if(e!==void 0)return e;const{currentUser:t,fileUrl:n,filesFetcher:s,userMap:r}=this.props;return g(vu,{key:"files",app:this,userMap:r,objectType:this.spaceType,objectID:this.spaceID,filterType:this.filterType,currentUser:t,onGetUser:this.getUserInfo,fileUrl:n,searchKeys:this.signals.searchKeys.value,filesFetcher:s})}_renderList(e){var l,c;if(this.signals.mode.value==="files")return this._renderFiles();const t=this.renderCustom("list");if(t!==void 0)return t;if(((l=this.lib)==null?void 0:l.data.type)==="api")return g(ES,{app:this,docs:this._docList.value});const{libIcon:n,moduleIcon:s,userMap:r,canMoveDoc:o}=e,a=this.signals.searchKeys.value;return g(nS,{key:"list",app:this,libIcon:n,moduleIcon:s,userMap:r,searchKeys:a,docs:this._docList.value,canMoveDoc:o,getActions:this.getActions,getTableOptions:this.getTableOptions,orderBy:(c=this._lib.value)==null?void 0:c.data.orderBy})}_renderView(e){const t=this.renderCustom("view");if(t!==void 0)return t;const[n,s]=this._viewInfo.value;if(!s||s.type==="chapter")return null;if(s.contentType==="url")return g("iframe",{className:"absolute inset-0 w-full h-full p-4",src:s.content});const{fileIcon:r,fileUrl:o,historyFetcher:a,uploadUrl:l,downloadUrl:c}=e,[h,d]=this._docUsers.value;return g(DS,{ref:this._viewRef,app:this,key:n,doc:s,mode:n,onChange:this._handleDocChange,fileIcon:r,fileActions:this._getFileActions,fileUrl:o,creator:h,modifier:d,uploadUrl:l,downloadUrl:c,preserve:this._preserve?`${this._preserve}-view`:void 0,onGetUser:this.getUserInfo,historyFetcher:a,highlight:this.signals.highlightView.value})}_renderMain(e){const t=this._renderView(e);return g("div",{key:"main",className:`doc-main flex-auto relative min-w-0${t?" show-view":""}`},e.singleDoc?null:this._renderList(e),t)}_renderSearchBox(e){let t={rootClass:"doc-app-search w-40 ml-1 mr-3",defaultValue:(this.signals.searchKeys.value||[]).join(" "),onChange:this._handleSearch,placeholder:this.getLang("searchPlaceholder","搜索")};const{getSearchBoxOptions:n}=this.props;return n&&(t=n.call(this,t,{type:e})),g(vs,{...t})}_renderFilters(){var a;const e=this.renderCustom("filters");if(e!==void 0)return e;const t=this._viewType.value;if(t!=="list"&&t!=="files")return null;const n=this.getFilterTypes(t),s=t==="list",r=this.filterType,o=s?(a=this._docList.value)==null?void 0:a.length:0;return g("div",{className:"row items-center flex-auto justify-end"},n.length?g("menu",{className:"nav nav-compact",style:"--nav-active-bg: var(--color-primary-100); --nav-active-color: var(--color-fore); --nav-item-height: 24px; --nav-divider-margin: 8px",onClick:this._handleFilterTypeClick},n.map(([l,c])=>g("li",{key:l,className:"nav-item item"},g("a",{className:l===r?"active rounded-full":"rounded-full","data-type":l,"data-view":t},c,l===r&&o?g("span",{className:"label size-sm canvas ring-0 rounded-full"},o):null)))):null,this._renderSearchBox(t))}_renderToolbar(){var r;const e=this.renderCustom("toolbar");if(e!==void 0)return e;const t=this._viewType.value,n=[],s="toolbar";if(t==="list")n.push(...this.getActions("doc-list",{ui:s}));else if(t==="files")n.push(...this.getActions("file-list",{ui:s}));else if(t==="view"){const o=(r=this._doc.value)==null?void 0:r.data;o&&(o.deleted||n.push(...this.getActions("doc",{ui:s,data:o})))}else t==="edit"?n.push(...this.getActions("doc-edit",{ui:s,data:this.signals.editingDoc.value})):t==="create"&&n.push(...this.getActions("doc-create",{ui:s,data:this.signals.creatingDoc.value}));return g(Fe,{className:"doc-app-toolbar",gap:2,size:"md",items:n})}_renderHeader(e){const t=this.renderCustom("header");if(t!==void 0)return t;const n=this._doc.value;return g("div",{key:"header",class:"doc-app-header surface-light row items-center border-b py-1.5 pl-1 pr-2"},g(uS,{app:this,spaceIcon:e.spaceIcon,libIcon:e.libIcon,apiLibIcon:e.apiLibIcon,moduleIcon:e.moduleIcon,libFilesIcon:e.libFilesIcon,noSpace:e.noSpace,docIcon:n?this.getDocIcon(n.data):void 0,spaces:this._spaceList.value,space:this._space.value,libs:this._libList.value,lib:this._lib.value,doc:n,docVersion:this.signals.docVersion.value,showFiles:this.signals.mode.value==="files",module:this._module.value,libPlaceholder:"所有库",onSelectDocVersion:this.selectDocVersion,onDiffDocVersions:this.diffDocVersions,onDiffModeChange:this.onDiffModeChange,onSelectLib:this.selectLib,onSelectSpace:this.selectSpace,onSelectModule:this.selectModule,onSelectDoc:this.selectDoc,homeName:e.homeName,noDocSwitcher:e.noDocSwitcher,getSpaceFetcher:e.getSpaceFetcher,spaceType:this.spaceType,spaceID:this.spaceID},this._renderFilters()),this._renderToolbar())}_renderBody(e){return g("div",{key:"body",class:"doc-app-body flex-auto min-h-0 row items-stretch"},this._renderSidebar(e),this._renderMain(e))}_renderHome(){const e=this.renderCustom("home");return e!==void 0?e:this.spaceType==="product"||this.spaceType==="project"&&window.config.vision!=="lite"?g(NS,{ref:this._homeRef,app:this}):g(IS,{ref:this._homeRef,app:this})}_getChildren(e){return this.signals.mode.value==="home"?this._renderHome():this.signals.loading.value?g("div",{key:"loading",class:"doc-loading relative center h-full load-indicator loading tex-gray","data-loading":this.getLang("loadingDocsData","正在加载文档数据...")}):this._space.value?[this._renderHeader(e),this._renderBody(e)]:g("div",{key:"empty-tip",class:"doc-empty-tip center h-full gap-8"},g("div",{className:"relative text-primary"},g($e,{icon:"file-alt",className:"opacity-10",style:"font-size: 72px; transform: rotate(-30deg); transform-origin: 0 72px;"}),g($e,{icon:"file-alt",className:"opacity-30 absolute left-0 top-0",style:"font-size: 72px; transform: rotate(-15deg); transform-origin: 0 72px;"}),g($e,{icon:"file-text",className:"absolute left-0 top-0",style:"font-size: 72px; transform: rotate(0deg); transform-origin: 0 72px;"})),g("div",{className:"text-gray text-lg"},this.getLang("noSpaceTip","这里什么也没有,先创建一个空间再使用吧!")),Fe.render({size:"lg",items:this.getActions("home",{ui:"home-no-space"})},[]))}getCustomRender(e){var t;return(t=this.props.customRenders)==null?void 0:t[e]}renderCustom(e,...t){const n=this.getCustomRender(e);let s;if(typeof n=="function"&&(s=n.call(this,...t)),s!==void 0)return typeof s=="string"?s:g(de,{key:e,content:s,generatorArgs:t,generatorThis:this})}};$u.NAME="DocApp",$u.defaultProps={spaceIcon:"docspace",libIcon:"doclib",apiLibIcon:"interface-lib",moduleIcon:"folder-o",docIcon:"doc",diffEnabled:!1,libFilesIcon:"annex-lib",chapterIcon:"list-box",attachmentIcon:"file",fetchOnChangeSpace:!0,autoConvertDoc:!0,commands:{},showLibFiles:["product","project","execution"],libColors:["secondary","primary","warning","success","special"].map(i=>`var(--color-${i}-500)`),showToolbar:!1};let AS=$u;async function Hv(i,e){const t=await Ne(e.docFetcher,[{docID:i,version:0}]);if(!(t!=null&&t.content))return!1;let n="";if(e.type==="html"){if(!await gt.htmlToSnap(t.content))return!1}else try{n=await gt.convertToHtml(t.content,void 0,e.downloadUrl)}catch(o){console.warn("[ZUI] Convert doc to html failed:",o)}const s={content:n};let r;return await v.post(De(e.migrateUrl,{docID:i}),s,o=>{const a=o;r=a.result==="success"?!0:a.message},"json"),r}async function Uv(i){try{i=i||ut("doc","ajaxGetMigrateDocs");const e=await Ne(i);return Array.isArray(e)?{doc:e,html:[]}:e}catch{return{}}}async function Vv(i,e){await gt.loadModule();const{onProgress:t,migrateUrl:n=ut("doc","ajaxMigrateDoc","docID={docID}"),docFetcher:s=ut("doc","ajaxGetDoc","docID={docID}"),downloadUrl:r=ut("file","ajaxQuery","fileID={gid}")}=e||{},o={migrateUrl:n,docFetcher:s,downloadUrl:r};let a=0;const l=i.doc.length+i.html.length,c=["doc","html"];for(const h of c)for(const d of i[h])t==null||t(a,l),await Hv(d,{...o,type:h}),await Dn(50),a++;return t==null||t(a,l),i}class Du extends re{constructor(){super(...arguments),this._current=fe(0)}migrate(){const{idList:e,docFetcher:t,downloadUrl:n,migrateUrl:s}=this.props;return Vv(e,{docFetcher:t,downloadUrl:n,migrateUrl:s,onProgress:r=>{this._current.value=r}})}componentDidMount(){this.migrate()}render(e){var o;const t=this._current.value,n=e.idList,s=n.doc.length+n.html.length,r=t===s;return g("div",{className:"col gap-4 p-6"},g("div",{class:"row gap-2 items-center"},g("div",{class:`progress progress-striped flex-auto ${r?"":"active"}`},g("div",{class:"progress-bar",style:`width: ${Math.floor(t*100/s)}%`})),g("div",{class:"text-gray"},Math.floor(t*100/s),"%")),r?g("div",{className:"text-center mt-2"},g("button",{type:"button",class:"btn primary",onClick:(o=e.onFinish)==null?void 0:o.bind(this,n)},e.finishText)):g("div",null,De(e.progressTip,{current:t,total:s})))}static async open(e){let t;const n=pe();return await He.open({type:"custom",ref:n,size:400,content:g(Du,{...e,onFinish:s=>{var r;t=s,(r=n.current)==null||r.hide()}}),custom:{closeBtn:!1}}),t}}async function PS(i){const{preserve:e="DocApp:migratedDocs:v2"}=i||{};if(nt.get(e))return;const{doc:t=[],html:n=[]}=await Uv(i==null?void 0:i.migrateUrl),s=t.length+n.length;if(!s)return;const r={zh_cn:{confirm:"检查到有 {0} 个文档数据需要迁移,是否进行迁移操作?你也可以下次进入文档应用时再进行迁移。",progressTip:"正在迁移文档数据...({current}/{total})",finish:"迁移完成"},zh_tw:{confirm:"檢查到有 {0} 个文檔數據需要遷移,是否進行遷移操作?你也可以下次進入文檔應用時再進行遷移。",progressTip:"正在遷移文檔數據...({current}/{total})",finish:"遷移完成"},en:{confirm:"There are {0} documents need to be migrated, do you want to migrate them now? You can also migrate them next time when you enter the document application.",progressTip:"Migrating documents...({current}/{total})",finish:"Migrate finished"}},o=r[Ap()]||r.en,a=(i==null?void 0:i.confirm)||o.confirm;if(a&&!await He.confirm(De(a,s)))return;const l=(i==null?void 0:i.progressTip)||o.progressTip,c=(i==null?void 0:i.finishText)||o.finish,h=await Du.open({idList:{doc:t,html:n},...i,progressTip:l,finishText:c});return h&&nt.set(e,Date.now()),h}const LS=Object.freeze(Object.defineProperty({__proto__:null,getMigrateDocs:Uv,migrateDoc:Hv,migrateDocs:Vv,tryMigrateDocs:PS},Symbol.toStringTag,{value:"Module"}));class On extends ve{afterInit(){super.afterInit(),this.$element.on("skipMorph",()=>{var e;(e=this.$)==null||e.reload(!0)})}destroy(){this.$element.off("skipMorph"),super.destroy()}}On.NAME="DocApp",On.Component=AS,On.storeNextCreatingDoc=lS,On.fetchNextCreatingDoc=wv,Object.assign(On,LS),On.register();class uo extends On{_getRenderProps(e){const{doc:t,className:n,...s}=super._getRenderProps(e),o={lib:0,module:0,title:"",addedBy:"",contentType:"doc",...typeof t=="object"?t:{id:t}},a={spaces:[{id:1,order:1,name:"",type:"custom"}],libs:[{id:o.lib,space:1,name:""}],modules:[{id:o.module,lib:o.lib,name:"",order:1}],docs:[o],spaceID:1};return{className:U(n,"doc-viewer"),data:a,doc:t,docID:o.id,...s}}}uo.NAME="DocViewer",uo.DEFAULT={...On.DEFAULT,mode:"view",noSidebar:!0,noSpace:"hidden",homeName:!1,noDocSwitcher:!0,singleDoc:!0},uo.register(),gt.setGlobalConfig({attachmentUrlGetter:i=>{var t;const e=On.query()||uo.query();if(e){let n=((t=e.$)==null?void 0:t.getDownloadUrl(i))||"";return n!=null&&n.length&&/^https?:\/\//.test(n)&&(n=`${window.location.origin}${n.startsWith("/")?"":"/"}${n}`),n}return""}});const bM="",wM="",CM="",xM="",kM="",SM="",TM="",$M="",DM="",IM="";st(Object.freeze(Object.defineProperty({__proto__:null,Dropmenu:Xi,DropmenuBtn:Sv,DropmenuPop:kv},Symbol.toStringTag,{value:"Module"})));class Iu extends ve{}Iu.NAME="Dropmenu",Iu.Component=Xi;const Mu=class Oo extends qe{render(e){super.render(e);let t=this.chart;const{responsive:n=!0,theme:s,...r}=this.options;t||(t=Oo.Module.init(this.element,s),n&&v(window).on(`resize.${this.gid}.ECharts.zt`,t.resize),this.chart=t),t.setOption(r)}async afterInit(){if(!await Oo.loadModule()){console.warn("ZUI: ECharts is not loaded.");return}let{plugins:t}=this.options;if(t===void 0){t=[];let n=this.options.series||[];n=Array.isArray(n)?n:[n];const s=new Set(n.map(r=>r==null?void 0:r.type).filter(Boolean));s.has("liquidFill")&&t.push("liquidfill"),s.has("timeline")&&t.push("timeline")}for(const n of t)await Oo.loadPlugin(n);this.render()}destroy(){var t;if(!Oo.Module){super.destroy();return}const{responsive:e=!0}=this.options;e&&v(window).off(`resize.${this.gid}.ECharts.zt`),(t=this.chart)==null||t.dispose(),super.destroy()}static async loadPlugin(e){if(this.pluginLoaded.has(e))return;const t=`echarts-${e}`;await v.getLib(t),this.pluginLoaded.add(e)}static async loadModule(){return this.Module||(this.Module=window.echarts),this.Module||(this.Module=await v.getLib("echarts")),this.Module}};Mu.NAME="ECharts",Mu.pluginLoaded=new Set;let RS=Mu;const Nu=((ab=window.config)==null?void 0:ab.version)?`${window.config.webRoot}js/`:void 0;v.registerLib("echarts",{src:"echarts/echarts.common.min.js",root:Nu,check:"echarts"}),v.registerLib("echarts-liquidfill",{src:"echarts/echarts-liquidfill.min.js",root:Nu,check:!1}),v.registerLib("echarts-timeline",{src:"echarts/timeline.min.js",root:Nu,check:!1});const Wv=i=>i.replace(/([[\]])/g,"\\$1");class Wl extends qe{constructor(){super(...arguments),this._disabled=!1,this._timer=0}init(){if(this.$element.on("submit",this.onSubmit.bind(this)).on("input mousedown change",this.onInput.bind(this)),this.options.checkOnCloseModal){const t=He.query(this.$element);if(!t||t.options.onHide)return;t.setOptions({onHide:this._handleModalHide.bind(this,t)})}let e=this.options.autoHorzLabel;if(e===void 0&&(e=!be.getCode().includes("zh")),e!==!1){let t=this.$element.closest(".form-horz");t.length||(t=t.find(".form-horz")),t.length&&Fy(this.$element)}}_handleModalHide(e){const{checkOnCloseModal:t}=this.options;if(t&&typeof t=="function"){const n=t.call(this,e);return typeof n=="string"?(He.alert(n),!1):n}}enable(e=!0,t=0){if(this._resetTimer(),t){this._timer=window.setTimeout(()=>{this.enable(e),this._timer=0},t);return}this.$element.toggleClass("loading",!e),this.$element.find('.btn-submit,button[type="submit"]').toggleClass("disabled",!e).prop("disabled",!e),this._disabled=!e}disable(){this.enable(!1)}onInput(e){const t=v(e.target).closest(".has-error");if(!t.length)return;let n=t.attr("name");n||(n=t.find(".pick-value").attr("name"));const s=n?`#${n.split("[")[0]}Tip,#${Wv(n)}Tip`:".form-tip";t.removeClass("has-error"),t.closest(".form-group,.form-batch-control").find(s).remove()}onSubmit(e){var o;if(e.preventDefault(),this._disabled)return;const{element:t}=this,n=v.extend({},this.options);this.emit("before",e,t,n);const s=()=>{this.$element.find(".ajax-form-tip").each(function(){const c=v(this);c.closest(".form-group,.form-batch-control").find(".has-error").removeClass("has-error"),c.remove()}),this.disable();let a=this.getFormData();const{beforeSend:l}=n;if(l){const c=l.call(this,a);c instanceof FormData&&(a=c)}this.emit("send",a),this._send(a)},r=(o=n.beforeSubmit)==null?void 0:o.call(this,e,t,n);if(r!==!1){if(r instanceof Promise){r.then(a=>a&&s());return}s()}}submit(){this.element.submit()}reset(){this.element.reset()}destroy(){this._resetTimer()}_resetTimer(){this._timer&&(window.clearTimeout(this._timer),this._timer=0)}getFormData(){const{$element:e,options:t}=this,n=new FormData(this.element);let{submitEmptySelectValue:s="",submitNoValueChecks:r}=t;const{submitDisabledValue:o=!0,cleanEmptyFiles:a}=t;return s!==!1&&(typeof s!="boolean"&&(s=""),e.find("select").each((l,c)=>{const h=v(c),d=h.attr("name");h.is("[disabled]")&&!o||n.has(d)||n.append(d,typeof s=="object"?s[d]:s)})),a&&n.forEach((l,c)=>{var h;l instanceof File&&(!((h=l.name)!=null&&h.length)||!l.size)&&(a==="delete"?n.delete(c):n.set(c,""))}),o&&e.find("[disabled][name]").each((l,c)=>{const h=v(c);if(h.hasClass("not-submit-disabled-value"))return;const d=h.attr("name");n.has(d)||n.append(d,h.val())}),r&&(r=typeof r=="string"?r:"",e.find('[type="checkbox"],[type="radio"]').not(":checked").each((l,c)=>{const h=v(c),d=h.attr("name");n.has(d)||h.is("[disabled]")&&!o||n.append(d,h.data("notCheckedValue")??r)})),n}_send(e){const{$element:t,options:n}=this;let s,r;const o=n.url||t.attr("action"),a={method:t.attr("method")||"POST",data:e,headers:t.closest(".modal").length?{"X-ZUI-Modal":"true"}:void 0,dataType:"json",jsonParser:JSON.parse},{optionsModifiers:l}=this.constructor;l.length&&l.forEach(h=>{const d=h.call(this,a);d&&d!==a&&v.extend(!0,a,d)});const c=v.ajax(o,a).success((h,d,f)=>{var p,y,b;h instanceof Blob?(Xn(h,(b=(y=(p=f.headers.get("Content-Disposition"))==null?void 0:p.split(";")[1])==null?void 0:y.split("=")[1])==null?void 0:b.replace(/"/g,"")),r={result:"success"}):(r=h,(!r||typeof r!="object")&&(s=new Error("Invalid json format")))}).fail(h=>{s=h}).complete(()=>{var h,d;if(s)this.emit("error",s),console.warn("ZUI: send ajax form failed",s),n.onError?n.onError(s):He.showError({size:"lg",error:[["POST",o],["Error",Gn(s.message)],["Response",c.data]].map(([f,p])=>`<b>${f}:</b> ${p}`).join("<br>")});else{const f=(h=n.onResult)==null?void 0:h.call(this,r);if(f===!1)return;f&&(r=v.extend(r,f)),this._handleResult(r)}this.emit("complete",r,s),(d=n.onComplete)==null||d.call(n,r,s),this.enable(!0,s||(r==null?void 0:r.result)!=="success"?0:5e3)})}_showValidateMessage(e){var n;let t;Object.entries(e).forEach(([s,r])=>{Array.isArray(r)&&(r=r.join(""));const o=Wv(s),{$element:a}=this;let l=a.find(`#${o}`);if(l.length||(l=a.find(`[data-form-name="${o}"]`)),l.length||(l=a.find(`[name="${o}"]`)),!l.length&&!s.includes("[")&&(l=a.find(`[name="${o}[]"]`)),!l.length){He.alert(r);return}l.hasClass("pick-value")&&(l=l.closest(".pick")),l.addClass("has-error");const c=l.closest(".form-group,.form-batch-control,td");if(c.length){let h=c.find(`#${o}Tip`);h.length||(h=c.find(".form-tip")),h.length||(h=v(`<div class="form-tip ajax-form-tip text-danger pre-line" id="${s}Tip"></div>`).appendTo(c)),h.removeClass("hidden").text(r)}else He.alert(r);t||(t=l)}),t&&((n=t[0])==null||n.focus())}_handleResult(e){var l,c;const{options:t}=this;let{message:n}=e;const s=e.result==="success";if(s){if(this.emit("success",e),((l=t.onSuccess)==null?void 0:l.call(t,e))===!1)return;typeof n=="string"&&n.length&&Ln.show({content:n,type:"success"})}else{if(this.emit("fail",e),((c=t.onFail)==null?void 0:c.call(t,e))===!1)return;n&&(Array.isArray(n)&&(n=n.join(`
  63. `)),typeof n=="string"&&n.length?He.alert(n):typeof n=="object"&&this._showValidateMessage(n))}const r=t.closeModal??e.closeModal;r&&(r!=="onlySuccess"||s)&&He.hide(typeof r=="string"&&r!=="onlySuccess"?r:void 0);const o=t.callback??e.callback;if(o){const h=[["options",t],["result",e]];if(typeof o=="string"){const d=v.runJS(o,...h);typeof d=="function"&&!o.endsWith(";")&&d(e)}else if(typeof o=="object"){const d=v.runJS(o.name,...h);typeof d=="function"&&d.apply(this,Array.isArray(o.params)?o.params:[o.params])}}const a=t.load??e.load??e.locate;a&&this.$element.trigger("locate.zt",a)}}Wl.NAME="AjaxForm",Wl.optionsModifiers=[];function Eu(i,e){var a,l;const t=i.result==="success";if(t){if(((a=e.onSuccess)==null?void 0:a.call(e,i))===!1)return}else if(((l=e.onFail)==null?void 0:l.call(e,i))===!1)return;const{message:n}=i;n&&(e.onMessage?e.onMessage(n,i):typeof n=="string"&&n.length&&(t?Ln.show({content:n,type:"success"}):He.alert(n)));const s=e.closeModal??i.closeModal;s&&He.hide(typeof s=="string"?s:void 0);const r=e.callback??i.callback;if(r){const c=[["options",e],["result",i]];if(typeof r=="string"){const h=v.runJS(r,...c);typeof h=="function"&&!r.endsWith(";")&&h(i)}else if(typeof r=="object"){const h=v.runJS(r.name,...c);typeof h=="function"&&h.apply(null,Array.isArray(r.params)?r.params:[r.params])}}const o=e.load??i.load??i.locate;o&&v(e.element||document).trigger("locate.zt",o)}function Kv(i){return typeof i=="string"&&(i=i.split(",").reduce((e,t)=>{const[n,s]=t.trim().split(":");return e[n.trim()]=s.trim(),e},{})),Object.keys(i).reduce((e,t)=>{const n=t.endsWith("?"),s=n?t.substring(0):t;let r=i[s];if(typeof r=="string"){const[o,a]=r.split("~"),l=v(o);if(!l.length)return e;a==="checkedIDList"?r=l.closest("[data-zui-dtable]").dtable("getChecks"):l[0].hasAttribute("data-map-value")?r=l.dataset("mapValue"):l.closest(".pick").length?r=l.closest(".pick").find(".pick-value").val():l.is("input,select,textarea")?r=l.val():r=l.text()}return(n||r!=null&&r!==""&&(!Array.isArray(r)||r.length))&&(e[s]=r),e},{})}async function li(i){if(i.confirm)return await He.confirm(i.confirm)?li({...i,confirm:void 0}):[void 0,new Error("canceled")];if(i={...Wl.DEFAULT,...i},i.beforeSubmit&&await i.beforeSubmit(i)===!1)return[void 0,new Error("canceled")];const{loadingClass:e,element:t}=i;t&&e&&v(t).addClass(e);const{data:n,dataMap:s}=i;let r;n&&(r=vr(n)),s&&(r=vr(Kv(s),r));const{beforeSend:o}=i;if(o){const h=o(r);h instanceof FormData&&(r=h)}let a,l;return await new Ir({url:i.url,method:i.method||"POST",body:r,headers:i.inModal?{"X-ZUI-Modal":"true",...i.headers}:i.headers,dataType:"json"}).success((h,d,f)=>{var p,y,b;h instanceof Blob?(Xn(h,(b=(y=(p=f.headers.get("Content-Disposition"))==null?void 0:p.split(";")[1])==null?void 0:y.split("=")[1])==null?void 0:b.replace(/"/g,"")),l={result:"success"}):(l=h,(!l||typeof l!="object")&&(a=new Error("Invalid json format")))}).fail(h=>{a=h,console.warn("ZUI: cannot submit ajax form",h)}).complete(()=>{var h,d,f;if(a)(h=i.onError)==null||h.call(i,a);else{const p=(d=i.onResult)==null?void 0:d.call(null,l);if(p===!1)return;p&&(l=v.extend(l,p)),Eu(l,i)}(f=i.onComplete)==null||f.call(i,l,a),t&&e&&v(t).removeClass(e)}).send(),[l,a]}v.extend(v,{ajaxSubmit:li}),v(document).on("click.ajaxSubmit.zui",".ajax-submit",function(i){i.preventDefault();const e=v(this);if(e.is("[disabled],.disabled"))return;const t=e.data();!t.url&&e.is("a")&&(t.url=e.attr("href")||""),t.inModal=t.inModal??!!e.closest(".modal").length,t.url&&(t.element=this[0],li(t))});class zS extends re{constructor(e){super(e),this.state={pinnedList:e.pinnedList||[]}}_handlePinnedChange(e){const{pinnedList:t}=this.state;t.includes(e)?t.splice(t.indexOf(e),1):t.push(e),this.setState({pinnedList:t})}_handleSave(){var e,t;(t=(e=this.props).onSave)==null||t.call(e,this.state.pinnedList)}render(e,t){const{tip:n,items:s,saveText:r=be.getLang("save"),resetText:o=be.getLang("reset"),cancelText:a=be.getLang("cancel"),pinnedIcon:l="pinned",unpinnedIcon:c="unpinned"}=e,{pinnedList:h}=t,d=new Set(h);return g("form",{className:"form-setting-form w-80 col gap-3"},g("div",{className:"text-gray mt-2"},n),g("div",{className:"divider opacity-5"}),g("div",{className:"row flex-wrap"},s.map(({text:f,value:p})=>{const y=d.has(p);return g("label",{className:"state size-sm ghost w-1/2 pl-1 pr-2 py-1 flex flex-nowrap gap-2 items-center rounded",onClick:this._handlePinnedChange.bind(this,p)},g($e,{icon:y?l:c,className:y?"text-primary":"text-gray-400"}),g("div",{className:`flex-auto text-clip${y?"":" text-gray"}`},f))})),g("div",{className:"row flex-nowrap gap-4 mt-2"},g(we,{size:"md",className:"btn-wide",type:"primary",onClick:this._handleSave.bind(this)},r),g(we,{size:"md",className:"btn-wide","data-dismiss":"popover"},a),g(we,{size:"md",type:"primary-ghost",disabled:!h.length,onClick:()=>this.setState({pinnedList:[]})},o)))}}class qv extends Gt{_getFormItems(){const e=this.$element.closest("form"),t=[],n=[];return e.find(".form-group.is-foldable[data-name]").each((s,r)=>{if(v(r).hasClass("hidden"))return;const o=v(r),a=o.data("name"),l=o.find(".form-label").first();let c=o.data("label");if(c===void 0){const h=l.find(".text");h.length&&(c=h.text())}c===void 0&&(c=l.text().trim()),t.push({value:a,text:c||a}),o.hasClass("is-pinned")&&n.push(a)}),{items:t,pinnedList:n}}_handleSave(e){const{customUrl:t,onSave:n}=this.options,s=()=>{(n==null?void 0:n(e))!==!1&&this.hide();const r=this.$element.closest("form");r.find(".form-group.is-foldable[data-name]").each((o,a)=>{const l=v(a),c=l.data("name");l.toggleClass("is-pinned",e.includes(c))}),r.toggleClass("no-foldable-items",!r.find(".form-group.is-foldable").not(".is-pinned,.hidden").length)};t?li({url:t,data:{"fields[]":e},onSuccess:r=>{delete r.callback,s()}}):s()}_getRenderOptions(){const{title:e,tip:t,className:n,saveText:s,resetText:r,cancelText:o}=this.options,{items:a,pinnedList:l}=this._getFormItems();return{...super._getRenderOptions(),title:e,headingClass:"popover-heading transparent px-4 pt-4",contentClass:"px-4 pb-4",titleClass:"text-lg font-bold",content:g(zS,{tip:t,saveText:s,resetText:r,cancelText:o,items:a,pinnedList:l,onSave:this._handleSave.bind(this),onCancel:this.hide.bind(this)}),className:U("form-setting-popover",n)}}}qv.NAME="FormSetting";class Gv extends qe{constructor(){super(...arguments),this._loadFormTimer=0}get mode(){return this.$container.hasClass("is-full")?"full":"lite"}get shownFoldItems(){return this.$container.hasClass("show-fold-items")}get $container(){let e=this._$container;if(!e){const{$element:t}=this;e=t.closest(".panel-form,.page-form"),e.length||(e=t),this._$container=e}return e}afterInit(){super.afterInit();const e=[],{$element:t}=this;t.children(".form-group[data-name]").each((a,l)=>{e.push(v(l).attr("data-name"))}),this._fields=e;const{fullModeOrders:n}=this.options;this._fullModefields=typeof n=="string"?[n]:n;let{preserve:s}=this.options;(s===!0||s===void 0)&&(s=t.attr("id")),this._preserveID=s||!1;const r=this.options.mode||(this._preserveID?nt.get(`FormGrid:${this._preserveID}:mode`,this.mode):this.mode);this.toggleMode(r,!1,!0);const{namespace:o}=this;this.$container.on(`click${o}`,".btn-full-form",()=>this.toggleMode("full")).on(`click${o}`,".btn-lite-form",()=>this.toggleMode("lite")).on(`click${o}`,".btn-toggle-fold",()=>this.toggleFold()),t.on(`change${o}`,"[name]",this._handleChange.bind(this)),t.toggleClass("no-foldable-items",!t.find(".form-group.is-foldable").not(".is-pinned,.hidden").length)}getField(e){const{$element:t}=this;let n=t.children(`.form-group[data-name="${e}"]`);if(!n.length)return;const s=t.children(`[data-wrap-before="${e}"]`),r=t.children(`[data-wrap-after="${e}"]`);let o=v();return s.length&&(o=o.add(s)),n.find("script").remove(),n=t.children(`.form-group[data-name="${e}"]`),o=o.add(n),r.length&&(o=o.add(r)),{name:e,wrapBefore:!!s.length,wrapAfter:!!r.length,foldable:n.hasClass("is-foldable"),$ele:n,$group:o}}destroy(){super.destroy(),this.$container.off(this.namespace)}toggleFold(e){e=e??!this.shownFoldItems,this.$container.toggleClass("show-fold-items",e)}openSetting(){this.$container.find(".btn-custom-form").trigger("click")}toggleMode(e,t,n){const s=this.mode;e=e||(s==="full"?"lite":"full"),!(s===e&&!t)&&(this.$container.toggleClass("is-full",e==="full").toggleClass("is-lite",e==="lite"),!n&&this._preserveID&&nt.set(`FormGrid:${this._preserveID}:mode`,e),this.updateOrders())}updateOrders(e,t){e&&(this._fields=e),t&&(this._fullModefields=typeof t=="string"?[t]:t);const{mode:n}=this;n==="full"?(t=this._fullModefields,Array.isArray(t)&&t.forEach(s=>{this.sortFields(s)})):this.sortFields()}sortFields(e){e=e||this._fields,typeof e=="string"&&(e=e.split(","));let t;e.forEach(r=>{const o=this.getField(r);if(o){if(t){const a=t.$group.last();if(o.$group.first()[0]===a[0])return;o.$group.insertAfter(a)}t=o}});const n=this.$element.children(".form-group.is-foldable").first(),s=this.$element.children(`[data-wrap-before="${n.attr("data-name")}"]`);this.$element.children(".panel-form-divider").insertBefore(s.length?s:n)}tryLoadForm(e,t=300){this._loadFormTimer&&clearTimeout(this._loadFormTimer),this._loadFormTimer=window.setTimeout(()=>{this._loadFormTimer=0,window.loadForm(e)},t)}_handleChange(e){const{autoLoad:t,loadUrl:n}=this.options;if(!t)return;const s=v(e.target).closest("[name]");Object.keys(t).forEach(r=>{const o=t[r];".[#".includes(r[0])||(r=`[name="${r}"]`),s.closest(r).length&&this.tryLoadForm(v.extend({url:n,target:s},typeof o=="string"?{items:o}:o))})}}Gv.NAME="FormGrid";class Kl extends qi{constructor(e,t){super(e,t),this._batchForm=Qy.query(this.$element)}get batchForm(){return this._batchForm}setFormData(e){return this._batchForm?this.setBatchFormData(e):super.setFormData(Array.isArray(e)?e[0]:e)}setBatchFormData(e){if(!Array.isArray(e)){const r=Object.keys(e);r.length===1&&Array.isArray(e[r[0]])&&(e=e[r[0]])}const t=Array.isArray(e)?e:[e],n=this._batchForm.options.idKey??"id",s=t.map((r,o)=>{const a=r[n]??String(o+1);return{...r,[n]:a}});this._batchForm.render({data:s},!0)}}function FS(i,e){return new Kl(i,e)}Kl.registerControl("zenEditor",(i,e)=>{const t=i.closest("zen-editor");if(!t.length||!t.closest(e).length)return;const n=t[0];return{type:"zenEditor",$element:t,instance:n,getVal:()=>n.value,setVal:s=>(n.setHTML(s),!0)}}),Kl.registerControl("editor",(i,e)=>{const t=i.closest("[z-use-editor]");if(!t.length||!t.closest(e).length)return;const n=t.zui("editor");return{type:"editor",$element:t,instance:n,getVal:()=>n.content,setVal:s=>{let r="doc";if(typeof s=="string")try{s=JSON.parse(s)}catch{r="html"}return n.updateDoc(s,r),!0}}});const EM="",OS=Object.freeze(Object.defineProperty({__proto__:null,zentao:{name:"zentao",plugins:{marker:!0,critical_path:!0,tooltip:!0,fullscreen:!0,click_drag:!0},config(i){let t=this.options.showFields,n;if(t){typeof t=="string"&&(t=t.split(","));const r=function(a,l){const c=i.serverList("userList"),h=l[a]??a,d=c.find(f=>f.key===h);return(d==null?void 0:d.label)??h},o={_:{align:"center",resize:!0,width:80},text:{align:"left",width:250,tree:!0,min_width:150},owner_id:{fixedName:"owner_id",align:"center",template:r.bind(null,"owner_id")},PM:"owner_id",assignedTo:"owner_id",start_date:{fixedName:"start_date",width:90},status:"_",begin:"start_date",id:{width:50,template:function(a){return a.id>0?a.id:""}},duration:{width:70},estimate:"duration",percent:{width:70,template:function(a){const l=a.percent??a.progress;if(l!==void 0)return Math.round(+l)+"%"}},progress:{width:70,template:function(a){const l=a.progress??a.percent;if(l!==void 0)return Math.round(+l)+"%"}},taskProgress:{width:70},deadline:{width:90},realBegan:{width:90},realEnd:"realBegan",consumed:"duration",left:"duration",openedBy:{width:70,template:r.bind(null,"openedBy")},finishedBy:{width:70,template:r.bind(null,"finishedBy")},delay:{width:60,template:function(a){return a.delayDays>0?"<div class='delayed'>"+a.delay+"</div>":a.delay}},delayDays:{resize:!1,width:60}};n=t.reduce((a,l)=>{if(typeof l=="string"){if(!l.length)return a;l={name:l,fixedName:l}}else l.name&&(l={...l,fixedName:l.name});let c=o[l.name];return typeof c=="string"&&(c=o[c]),l={...o._,...c,...l},l.fixedName&&(l.name=l.fixedName,delete l.fixedName),a.push(l),a},[]).filter(Boolean)}n&&(n[n.length-1].resize=!1);const s=[{unit:"year",step:1,format:"%Y"},{unit:"day",step:1,format:"%m-%d"}];return{...n?{columns:n}:{},readonly:!0,details_on_dblclick:!1,order_branch:!1,drag_progress:!1,drag_links:!1,drag_move:!1,drag_resize:!1,smart_rendering:!0,smart_scales:!0,static_background:!0,show_task_cells:!1,row_height:32,details_on_create:!1,duration_unit:"day",show_chart:!0,scales:s,min_column_width:70,scale_height:22*s.length}},serverListMap(){return{userList:this.options.userList}},templates(i){return{grid_date_format:function(e,t){const n=i.date.date_to_str("%Y-%m-%d");return n(t==="end_date"?new Date(e.valueOf()-1):e)}}},onInit(i){i.locale.labels={...i.locale.labels,...this.options.ganttFields},i.config.columns.forEach(e=>{i.locale.labels[`column_${e.name}`]===void 0&&(i.locale.labels[`column_${e.name}`]=e.name==="PM"&&i.locale.labels.column_owner_id?i.locale.labels.column_owner_id:e.name)}),this.options.showDate=new Date}}},Symbol.toStringTag,{value:"Module"})),ql=class np extends qe{get gantt(){return this._gantt}get config(){return this._gantt.config}get templates(){return this._gantt.templates}setOptions(e,t){const n=super.setOptions(e,t);return this._exts=n.exts?(typeof n.exts=="string"?n.exts.split(","):n.exts).map(s=>typeof s=="string"?np.extensions[s]:s).filter(Boolean):[],n}async afterInit(){this._gantt=await np.getInstance(),this._exts.forEach(e=>{var t;(t=e.onCreate)==null||t.call(this,this._gantt)}),this._initGantt(),this.render()}_initGantt(){const{templates:e,events:t,plugins:n,serverListMap:s,markers:r,config:o,onInit:a,zooming:l,readonly:c}=this.options;this.$element.addClass("gantt-container");const h=this._gantt;h.init(this.element),this._exts.forEach(d=>{var f;d.config&&this.setConfig(d.config),d.templates&&this.setTemplates(d.templates),d.events&&this.attachEvents(d.events),d.plugins&&this.setPlugins(d.plugins),d.markers&&this.addMarkers(d.markers),d.serverListMap&&this.setServerListMap(d.serverListMap),(f=d.onInit)==null||f.call(this,h)}),l&&this.setZooming(l,!0),e&&this.setTemplates(e),t&&this.attachEvents(t),n&&this.setPlugins(n),s&&this.setServerListMap(s),r&&this.addMarkers(r),o&&this.setConfig(o),c&&this.setConfig("readonly",c),a==null||a.call(this,this._gantt)}setZooming(e,t=!1){const n={zh_cn:"周",zh_tw:"周"};e==="day"?this.setConfig({scales:[{unit:"year",step:1,format:"%Y"},{unit:"day",step:1,format:"%m-%d"}]}):e==="week"?this.setConfig({scales:[{unit:"year",step:1,format:"%Y"},{unit:"week",step:1,format:`${n[be.getCode()]??"Week"} #%W`},{unit:"day",step:1,date:"%D"}]}):e==="month"?this.setConfig({scales:[{unit:"year",step:1,format:"%Y"},{unit:"month",step:1,format:"%M"},{unit:"week",step:1,date:`${n[be.getCode()]??"Week"} #%W`}]}):e==="quarter"&&this.setConfig({scales:[{unit:"year",step:1,format:"%Y"},{unit:"quarter",step:1,format:s=>{const r=this._gantt,o=r.date.date_to_str("%M"),a=r.date.add(r.date.add(s,3,"month"),-1,"day");return o(s)+" - "+o(a)}}]}),t||this._gantt.render()}setReadonly(e){this.setConfig("readonly",e),this._gantt.render()}setPlugins(e){this._gantt.plugins(typeof e=="function"?e.call(this,this._gantt):e)}setTemplate(e,t){this._gantt.templates[e]=t}setTemplates(e){v.extend(this._gantt.templates,typeof e=="function"?e.call(this,this._gantt):e)}setServerListMap(e){Object.entries(typeof e=="function"?e.call(this,this._gantt):e).forEach(([t,n])=>{this._gantt.serverList(t,n)})}setServerList(e,t){this._gantt.serverList(e,t)}setConfig(e,t){e=typeof e=="function"?e.call(this,this._gantt):e,typeof e=="string"?this._gantt.config[e]=t:v.extend(this._gantt.config,e)}addMarker(e){this._gantt.addMarker(e)}addMarkers(e){typeof e=="function"&&(e=e.call(this,this._gantt)),Array.isArray(e)?e.forEach(t=>{this.addMarker(t)}):Object.entries(e).forEach(([t,n])=>{this.addMarker({id:t,...n})})}attachEvent(e,t){this._gantt.attachEvent(e,t)}attachEvents(e){Object.entries(typeof e=="function"?e.call(this,this._gantt):e).forEach(([t,n])=>{this._gantt.attachEvent(t,n)})}reset(){return this._gantt.destructor(),this.afterInit()}async render(e,t){if(super.render(e,t),t)return this.reset();const{data:n=[],links:s=[],resources:r=[],assignments:o=[],collections:a={},showDate:l,width:c,height:h,onRender:d,beforeRender:f,fetcher:p}=this.options;let y={data:n,links:s,resources:r,assignments:o,collections:a};p&&(this.$element.addClass("loading"),y=await Ne(p,[],{},this),this.$element.removeClass("loading")),f==null||f.call(this,this._gantt,y),c&&this.$element.css("width",Be(c)),h&&this.$element.css("height",Be(h)),this._gantt.clearAll(),this._gantt.parse(y),l&&this._gantt.showDate(l),this._gantt.render(),d==null||d.call(this,this._gantt)}destroy(){var e;super.destroy(),(e=this._gantt)==null||e.destructor()}static async loadModule(){if(!this.Module&&!this.Module){const e=await v.getLib("dhxgantt");this.Module=e}return this.Module}static async getInstance(){var s;const{getGanttInstance:e}=await this.loadModule(),t=e(),n=(s=window.gantt)==null?void 0:s.locale;return n&&v.extend(!0,t.locale,n),t}static registerExtension(e){this.extensions[e.name]=e}};ql.NAME="Gantt",ql.DEFAULT={width:"100%",height:400},ql.extensions=OS;let Zv=ql;Zv.register();const Yv=(lb=window.config)==null?void 0:lb.version;v.registerLib("dhxgantt",{src:Yv?["dhtmlxgantt/min.js","dhtmlxgantt/min.css",`dhtmlxgantt/lang/${be.getCode().replace("_","-")}.js`]:["gantt/dhtmlxgantt/min.js","gantt/dhtmlxgantt/min.css",`gantt/dhtmlxgantt/lang/${be.getCode().replace("_","-")}.js`],root:Yv?`${window.config.webRoot}js/`:void 0,check:"Gantt"});const PM="",LM="";let Jv=class extends ot{constructor(){super(...arguments),this._searchBox=pe(),this._menu=pe(),this._handleChange=e=>{this.setState({value:e.trim()})},this._handleFocus=()=>{this.toggle(!0)},this._handleEenter=()=>{var t;const e=(t=this._menu.current)==null?void 0:t.getActiveKey();e&&this.search(e)},this._handleClickItem=e=>{this.search(e.item.key)}}search(e){var t,n;(t=this.props.onSearch)==null||t.call(this,e,this.state.value),this.toggle(!1,{value:""}),(n=this._searchBox.current)==null||n.blur()}componentDidUpdate(e,t){var s;super.componentDidUpdate(e,t);const n=this._menu.current;this.state.open&&n&&!((s=this._types)!=null&&s.has(n.getActiveKey()))&&n.activeNext()}_getHotkeys(){return this._hotkeys||(this._hotkeys={activeNext:{keys:"ArrowDown",handler:()=>{var e;return(e=this._menu.current)==null?void 0:e.activeNext()}},activePrev:{keys:"ArrowUp",handler:()=>{var e;return(e=this._menu.current)==null?void 0:e.activePrev()}},enter:!0}),this._hotkeys}_renderTrigger(e){return g(vs,{delay:0,ref:this._searchBox,placeholder:e.searchHint,onChange:this._handleChange,onFocus:this._handleFocus,hotkeys:this._getHotkeys(),onEnter:this._handleEenter,...e.searchBox})}_getItems(e,t){const{items:n,getObjectID:s,getSearchType:r}=e,{value:o}=t;let a=r==null?void 0:r.call(this,o);const l=a&&a[0]==="!";l&&(a=a.slice(1));const c=s?s.call(this,o):Number.isInteger(+o)?+o:!1,h=Number.isInteger(c),d=[],f=n.reduce((b,w)=>(b.set(w.key,w),b),new Map),p="search",y=b=>{var w;return{html:((w=b.text)==null?void 0:w.replace("{0}",o))??o}};if(a&&h){const b=f.get(a);b&&d.push({...b,className:U(b.className,"w-full"),text:y(b)})}if(!l){const b=f.get(p);d.push({...b,className:U(b==null?void 0:b.className,"w-full"),text:b?y(b):o})}return h&&n.forEach(b=>{b.key===p||b.key===a||l||d.push({...b,className:U(b.className,"w-1/2"),text:y(b)})}),this._types=new Set(d.map(b=>b.key)),d}_renderPop(e,t){return g(Rt,{className:"row flex-wrap overflow-auto scrollbar-hover",items:this._getItems(e,t),onClickItem:this._handleClickItem,ref:this._menu,activeOnHover:!0,...e.menu})}};Jv.defaultProps={...ot.defaultProps,pickerName:"global-search",hidePopWhenEmpty:!0};class Gl extends ve{}Gl.NAME="GlobalSearch",Gl.Component=Jv,Gl.replace=!0;function BS(i,e=1e3){let t=null;return(...n)=>{t&&clearTimeout(t),t=setTimeout(()=>{i(...n),t=null},e)}}const Xv=class sw extends qe{static async loadModule(){return this.Module||(this.Module=await v.getLib("g6")),this.Module}async afterInit(){const e=await sw.loadModule();if(this.destroyed)return;const{type:t="TreeGraph",width:n=this.$element.width(),height:s=this.$element.height()||500,responsive:r=!1,data:o,nodeFn:a,edgeFn:l,comboFn:c,...h}=this.options,d=new e[t]({container:this.element,width:n,height:s,...h});a&&d.node(a),l&&d.edge(l),c&&d.combo(c),d.data(o),d.render(),this.instance=d,r&&this.initResizeObserver()}initResizeObserver(){const e=BS(()=>{this.instance.changeSize(this.$element.width(),this.$element.height()),this.instance.render()},500);this.resizeObserver=new ResizeObserver(()=>{e()}),this.resizeObserver.observe(this.element)}destroy(){var e;this.options.responsive&&((e=this.resizeObserver)==null||e.disconnect()),this.instance.destroy(),super.destroy()}};Xv.NAME="Graph";let Qv=Xv;v.registerLib("g6",{src:"graph/g6.min.js",check:"G6"}),Qv.register();const RM="";class Au extends qe{init(){this.clipWidth=this.options.defaultWidth,this.clipHeight=this.options.defaultHeight,this.initDom(),this.initSize(),this.bindEvents()}initDom(){this.$canvas=this.$element.find(".canvas"),this.$img=this.$canvas.find("img"),this.$btn=this.$element.find("button");const e=this.$img.prop("src"),{coverColor:t,coverOpacity:n}=this.options;this.$canvas.append([`<div class="cover" style="background: ${t}; opacity: ${n};"></div>`,`<div class="controller" style="width: ${this.clipWidth}px; height: ${this.clipHeight}px">`,["top","right","bottom","left","top-left","top-right","bottom-left","bottom-right"].map(s=>`<div class="control" data-type="${s}"></div>`).join(""),"</div>",'<div class="cliper">',`<img src="${e}"/>`,"</div>"].join("")),this.$controller=this.$canvas.find(".controller"),this.$cliper=this.$canvas.find(".cliper"),this.$chipImg=this.$cliper.find("img")}resetImage(e){this.$img.prop("src",e),this.$chipImg.prop("src",e),this.imgWidth=0,this.left=-1,this.initSize()}initSize(){const{minWidth:e,minHeight:t,ready:n,onSizeError:s}=this.options;if(this.imgWidth)return;const r=a=>{this.imgWidth=a.width,this.imgHeight=a.height,(a.width<e||a.height<t)&&(s==null||s({width:a.width,height:a.height}),this.options.minWidth=Math.min(a.width,e),this.options.minHeight=Math.min(a.height,t)),n==null||n(),this.width=Math.min(this.imgWidth,this.$element.width()),this.$canvas.css("width",this.width),this.height=this.$canvas.height(),(this.left===void 0||this.left<0)&&(this.left=Math.floor((this.width-this.$controller.width())/2),this.top=Math.floor((this.height-this.$controller.height())/2)),this.refreshSize()},o=this.$img[0];o.complete?r(o):o.onload=()=>{r(o)}}refreshSize(e){const{minWidth:t,minHeight:n,fixedRatio:s,defaultWidth:r,defaultHeight:o}=this.options;this.clipWidth=Math.max(t,Math.min(this.width,this.clipWidth)),this.clipHeight=Math.max(n,Math.min(this.height,this.clipHeight)),s&&(e&&e==="height"?(this.clipWidth=Math.max(t,Math.min(this.width,this.clipHeight*r/o)),this.clipHeight=this.clipWidth*o/r):(this.clipHeight=Math.max(n,Math.min(this.height,this.clipWidth*o/r)),this.clipWidth=this.clipHeight*r/o)),this.left=Math.min(this.width-this.clipWidth,Math.max(0,this.left)),this.top=Math.min(this.height-this.clipHeight,Math.max(0,this.top)),this.right=this.left+this.clipWidth,this.bottom=this.top+this.clipHeight,this.$controller.css({left:this.left,top:this.top,width:this.clipWidth,height:this.clipHeight}),this.$cliper.css("clip",`rect(${this.top}px, ${this.left+this.clipWidth}px, ${this.top+this.clipHeight}px, ${this.left}px)`)}getData(){return{originWidth:this.imgWidth,originHeight:this.imgHeight,scaleWidth:this.width,scaleHeight:this.height,width:this.right-this.left,height:this.bottom-this.top,left:this.left,top:this.top,right:this.right,bottom:this.bottom,scaled:this.imgWidth!==this.width||this.imgHeight!==this.height}}bindEvents(){this.$element.on("resize",this.initSize.bind(this)),this.$btn.on("click",e=>{var t,n;(n=(t=this.options).handleBtnClick)==null||n.call(t,e,this.getData())}),this.moveable=new _s(this.$controller,{selector:".control,.controller",move:!1,onMoveStart:()=>{this.startLeft=this.left,this.startTop=this.top,this.startClipWidth=this.clipWidth,this.startClipHeight=this.clipHeight},onMove:(e,t)=>{const n=v(t.target);if(n.is(".controller"))this.left=this.startLeft+t.deltaX,this.top=this.startTop+t.deltaY,this.refreshSize();else{const s=n.data("type");let r=!1;const{minWidth:o,minHeight:a}=this.options;switch(s){case"left":case"top-left":case"bottom-left":this.left=Math.min(this.right-o,Math.max(0,this.startLeft+t.deltaX)),this.clipWidth=this.right-this.left;break;case"right":case"top-right":case"bottom-right":this.clipWidth=Math.min(this.width-this.left,Math.max(o,this.startClipWidth+t.deltaX));break}switch(s){case"top":case"top-left":case"top-right":this.top=Math.min(this.bottom-a,Math.max(0,this.startTop+t.deltaY)),this.clipHeight=this.bottom-this.top,r=!0;break;case"bottom":case"bottom-left":case"bottom-right":this.clipHeight=Math.min(this.height-this.top,Math.max(a,this.startClipHeight+t.deltaY)),r=!0;break}this.refreshSize(r)}}})}destroy(){var e;(e=this.moveable)==null||e.destroy(),super.destroy()}}Au.NAME="ImgCutter",Au.DEFAULT={coverColor:"#000",coverOpacity:.6,defaultWidth:128,defaultHeight:128,minWidth:48,minHeight:48,fixedRatio:!0};const ci=class{static get images(){var e;return(e=this.Module)==null?void 0:e.images}static async loadModule(){return this.Module||(this.Module=await v.getLib("mammoth")),this.Module}};ci.convertToHtml=async function(i,e){const{convertToHtml:t}=await ci.loadModule();return t(i,e)},ci.extractRawText=async function(i){const{extractRawText:e}=await ci.loadModule();return e(i)},ci.embedStyleMap=async function(i,e){const{embedStyleMap:t}=await ci.loadModule();return t(i,e)};let jS=ci;v.registerLib("mammoth",{src:["mammoth/mammoth.browser.min.js"],check:"mammoth",type:"module"}),st(vk);const zM="",FM="",Pu=new Ni("mermaid",{src:["mermaid/mermaid.min.js"],check:"mermaid"}),HS={parseFailed:"绘图解析失败",copyError:"复制错误",rendering:"正在绘制图形..."},US={parseFailed:"绘图解析失敗",copyError:"複製錯誤",rendering:"正在繪製圖形..."},VS={parseFailed:"Parse graph failed",copyError:"Copy error",rendering:"Rendering graph..."};be.addLang({zh_cn:{mermaid:HS},zh_tw:{mermaid:US},en:{mermaid:VS}});function Lu(i,e,t){return be.getLang(`mermaid.${i}`,e,t)}let e_=class extends re{constructor(){super(...arguments),this._id=`_mermaid-${Xe()}`,this._svg=fe(""),this._error=fe(""),this._rendering=fe(!1),this._timer=0,this.copyError=async()=>{navigator.clipboard&&await navigator.clipboard.writeText(this._error.value)}}componentDidMount(){this.tryUpdate()}componentDidUpdate(e){e.text!==this.props.text&&this.tryUpdate()}async update(){const e=this.props.text,t=await Pu.load();if(!t)return;const{id:n=this._id}=this.props,{svg:s,bindFunctions:r}=await t.render(n,e);if(e===this.props.text)return this._svg.value=s,r==null||r(this.base),!0}async tryUpdate(){this._timer&&clearTimeout(this._timer),this._rendering.value=!0,this._timer=window.setTimeout(async()=>{try{this._error.value="",await this.update()}catch(e){console.error("[ZUI] Mermaid: tryUpdate failed",e),this._error.value=String(e)}this._rendering.value=!1},this.props.delay||0)}render(e){const{className:t,style:n,id:s}=e,r=this._error.value,o=this._rendering.value;return r||o?g("div",{id:s,className:U("mermaid-view",t),style:n},o?g("div",{class:"primary-pale text-sm p-1 flex items-center gap-1"},g("i",{class:"icon icon-spinner-indicator spin"}),g("div",{class:"flex-auto"},Lu("rendering"))):g("div",{class:"danger-pale text-sm p-1 flex items-center gap-1",title:r},g("i",{class:"icon icon-alert"}),g("div",{class:"flex-auto"},Lu("parseFailed")),navigator.clipboard?g("button",{type:"button",class:"btn ghost size-xs",onClick:this.copyError,title:Lu("copyError")},g("i",{class:"icon icon-copy"})):null),g("pre",{class:"markdown-code-block code-highlight github-light",style:"margin-top:0;border-top-left-radius: 0;border-top-right-radius: 0;"},e.text)):g("div",{id:s,className:U("mermaid-view",t),style:n,dangerouslySetInnerHTML:{__html:this._svg.value}})}};e_.defaultProps={delay:200};const Ru=class iw extends ve{init(){const{text:e}=this.options;e===void 0&&(this.options.text=this.$element.text(),this.$element.empty())}static async render(e,t,n){const s=await iw.loadModule();if(s)return s.render(e,t,n)}static get Module(){return Pu.Module}static loadModule(){return Pu.load()}};Ru.NAME="Mermaid",Ru.Component=e_;let t_=Ru;t_.register();const OM="",BM="";Object.assign(Ln.TypeOptions,{success:{key:"zt-messager-success",icon:"check-circle",type:"success",close:!1},danger:{icon:"exclamation-sign",type:"danger",close:!1}}),Object.assign(Ln,{success(i){return Ln.show(i,"success")},fail(i){return Ln.show(i,"danger")}}),Object.assign(Ln.DEFAULT,{time:3e3,className:"messager-lite"});const jM="";function WS(i){return He.confirm({iconClass:"warning rounded-full center w-8 h-8 flex-none",type:"custom",custom:{className:"modal-reconfirm",closeBtn:!1},...i})}async function KS(i){const{sortable:e={},onSort:t,items:n,itemProps:s={icon:"move muted",innerClass:"border rounded px-2 canvas cursor-move hover:shadow"},list:r,header:o,message:a,footer:l,...c}=i;let h;const d=(p,y)=>{h=y,t==null||t(p,y)};if(await He.confirm({type:"custom",content:g("div",{className:"modal-body sort-view col gap-2"},g(de,{className:"sort-view-header",content:o}),g(de,{className:"sort-view-message muted",content:a}),g(jr,{className:"space-y-2",sortable:e,items:n,itemProps:s,onSort:d,...r}),g(de,{className:"sort-view-footer",content:l})),...c}))return h}be.addLang({zh_cn:{occurredError:"发生了错误"},zh_tw:{occurredError:"發生了錯誤"},en:{occurredError:"An error occurred"}});async function qS(i){const{title:e,mono:t,html:n=!0,copyBtn:s=!0,basePath:r,contentClass:o,error:a,...l}=i;let c=typeof a=="string"?a:(a==null?void 0:a.message)??"",h=t,d=e;n&&(r&&(c=c.split(r).join('<i class="icon icon-file-text opacity-50"></i>/')),c.startsWith(`<br />
  64. `)&&(c=c.replace(`<br />
  65. `,"")),c.startsWith("<!DOCTYPE html")&&(h===void 0&&(h=!1),d===void 0&&(d=v(c).filter("title").text())));const f=pe();return await He.confirm({title:d??be.getLang("occurredError"),message:"",type:"custom",custom:{className:"backdrop-blur border-2 border-canvas bg-opacity-80 rounded-xl",headerClass:"text-danger"},content:g("div",{ref:f,className:U("modal-body",h!==!1?" font-mono":"",o),style:{whiteSpace:h!==!1?"pre-line":"normal"},dangerouslySetInnerHTML:n?{__html:c}:void 0},n?void 0:c),actions:[s?{key:"confirm",text:typeof s=="string"?s:be.getLang("copy"),icon:"copy",onClick:()=>{const y=f.current;if(navigator.clipboard)navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([y.innerText],{type:"text/plain"}),"text/html":new Blob([y.innerHTML],{type:"text/html"})})]);else{const b=document.createRange();b.selectNode(y),window.getSelection().removeAllRanges(),window.getSelection().addRange(b),document.execCommand("copy"),window.getSelection().removeAllRanges()}}}:null,{key:"cancel",text:be.getLang("close")}].filter(Boolean),...l})}Object.assign(He,{reconfirm:WS,sortView:KS,showError:qS}),He.DEFAULT.backdrop="static",He.DEFAULT.request={dataFilter:i=>{if(i[0]==="{")try{const e=JSON.parse(i);if(e.result)return Eu(e,{closeModal:!0}),setTimeout(()=>{v(".modal").each(function(){const t=v(this);t.text().trim().length||t.modal("hide")})},200),""}catch{}return i}},_d.defaultProps.iframeBodyClass="body-modal";class Zl extends ve{}Zl.NAME="PriPicker",Zl.Component=co,Zl.register();class Yl extends ve{}Yl.NAME="DiffPicker",Yl.Component=_u,Yl.register();class Jl extends ve{}Jl.NAME="SeverityPicker",Jl.Component=bu,Jl.register();class Xl extends ve{}Xl.NAME="RangePicker",Xl.Component=Iv,Xl.register();const HM="",UM="",VM="",WM="",KM="";class Ql extends we{constructor(){super(...arguments),this._handleClick=()=>{var e;(e=this._copyBtn)==null||e.copy()}}get coyBtn(){return this._copyBtn}componentDidMount(){super.componentDidMount(),this._copyBtn=new Qs(this.base,this.props)}componentWillUnmount(){var e;super.componentWillUnmount(),(e=this._copyBtn)==null||e.destroy()}_getProps(e){return{...super._getProps(e),onClick:this._handleClick}}}Ql.NAME="CopyBtn",Ql.DEFAULT={...Qs.DEFAULT};class n_ extends re{constructor(){super(...arguments),this._ref=pe()}get highlighter(){return this._highlighter}componentDidMount(){this._highlighter=new no(this._ref.current,this.props)}componentDidUpdate(e){(e.code!==this.props.code||e.lang!==this.props.lang)&&this.update()}componentWillUnmount(){var e;(e=this._highlighter)==null||e.destroy()}update(){var e;return(e=this._highlighter)==null?void 0:e.update()}render(e){const{className:t,style:n}=e;return g("div",{ref:this._ref,className:U("code-highlight",t),style:n})}}const GS={preview:"预览",source:"源码",downloadSource:"下载",copySource:"复制",openInNewTab:"在新标签页中打开"},ZS={preview:"預覽",source:"源碼",downloadSource:"下載",copySource:"復制",openInNewTab:"在新標籤頁中打開"},YS={preview:"Preview",source:"Source",downloadSource:"Download",copySource:"Copy",openInNewTab:"Open in New Tab"};be.addLang({zh_cn:{htmlSandbox:GS},zh_tw:{htmlSandbox:ZS},en:{htmlSandbox:YS}});function Bn(i,e,t){return be.getLang(`htmlSandbox.${i}`,e,t)}let s_=class extends re{constructor(){super(...arguments),this._iframeRef=pe(),this._viewSource$=fe(!1),this.showPreview=()=>{this._viewSource$.value=!1},this.showSource=()=>{this._viewSource$.value=!0},this.downloadSource=()=>{const e=new Blob([this.props.html],{type:"text/html"});Xn(e,`${this.getTitleFromHtml()}.html`)},this.openInNewTab=()=>{this._blobUrl&&URL.revokeObjectURL(this._blobUrl);const e=new Blob([this.props.html],{type:"text/html"});this._blobUrl=URL.createObjectURL(e),window.open(this._blobUrl,"_blank")}}getTitleFromHtml(){const e=this.props.html.match(/<title>(.*?)<\/title>/);return e?e[1]:"Sandbox"}componentWillUnmount(){this._blobUrl&&URL.revokeObjectURL(this._blobUrl)}render(e){const{className:t,html:n,height:s=400}=e,r=this._viewSource$.value,o=this.getTitleFromHtml(),a=Be(s);return g("div",{className:U("html-sandbox position-relative surface border shadow rounded-md overflow-hidden",t)},g("menu",{class:"sanbox-header toolbar px-2 py-1 gap-4 relative"},g("div",{class:"flex-auto font-bold flex items-center gap-1"},g("i",{class:"icon icon-file-text"}),o),g("div",{class:"inset-0 absolute center"},g("div",{class:"btn-group size-sm"},g("button",{type:"button",class:`btn ${r?"":"active text-primary ring-primary bg-primary-50"}`,onClick:this.showPreview},g("i",{class:"icon icon-eye"}),Bn("preview")),g("button",{type:"button",class:`btn ${r?"active text-primary ring-primary bg-primary-50":""}`,onClick:this.showSource},g("i",{class:"icon icon-code"}),Bn("source")))),g("div",{class:"toolbar size-sm"},g(Ql,{type:"ghost",square:!0,icon:"copy",copy:n,hint:Bn("copySource")}),g("button",{type:"button",class:"btn ghost square",onClick:this.openInNewTab,title:Bn("openInNewTab")},g("i",{class:"icon icon-panel"})),g("button",{type:"button",class:"btn ghost square",onClick:this.downloadSource,title:Bn("downloadSource")},g("i",{class:"icon icon-download"})))),g("div",{class:U("sanbox-iframe canvas",r?"hidden":"")},g("iframe",{ref:this._iframeRef,sandbox:"allow-scripts allow-forms",srcdoc:n,style:{height:a,width:"100%"}})),r?g("div",{class:"sanbox-source border-t overflow-auto",style:{maxHeight:a}},g(n_,{code:n,lang:"html"})):null)}},i_=class extends re{constructor(){super(...arguments),this._viewSource$=fe(!1),this.showPreview=()=>{this._viewSource$.value=!1},this.showSource=()=>{this._viewSource$.value=!0},this.downloadSource=()=>{const e=new Blob([this.props.svg],{type:"image/svg+xml"});Xn(e,`${this.getTitleFromSvg()}.svg`)},this.openInNewTab=()=>{this._blobUrl&&URL.revokeObjectURL(this._blobUrl);const e=new Blob([this.props.svg],{type:"image/svg+xml"});this._blobUrl=URL.createObjectURL(e),window.open(this._blobUrl,"_blank")}}getTitleFromSvg(){const e=this.props.svg.match(/<title>(.*?)<\/title>/);return e?e[1]:"SVG"}componentWillUnmount(){this._blobUrl&&URL.revokeObjectURL(this._blobUrl)}render(e){const{className:t,svg:n}=e,s=this._viewSource$.value,r=this.getTitleFromSvg();return g("div",{className:U("svg-box position-relative surface border shadow rounded-md overflow-hidden",t)},g("menu",{class:"svg-box-header toolbar px-2 py-1 gap-4 relative"},g("div",{class:"flex-auto font-bold flex items-center gap-1"},g("i",{class:"icon icon-file-image"}),r),g("div",{class:"inset-0 absolute center"},g("div",{class:"btn-group size-sm"},g("button",{type:"button",class:`btn ${s?"":"active text-primary ring-primary bg-primary-50"}`,onClick:this.showPreview},g("i",{class:"icon icon-eye"}),Bn("preview")),g("button",{type:"button",class:`btn ${s?"active text-primary ring-primary bg-primary-50":""}`,onClick:this.showSource},g("i",{class:"icon icon-code"}),Bn("source")))),g("div",{class:"toolbar size-sm"},g(Ql,{type:"ghost",square:!0,icon:"copy",copy:n,hint:Bn("copySource")}),g("button",{type:"button",class:"btn ghost square",onClick:this.openInNewTab,title:Bn("openInNewTab")},g("i",{class:"icon icon-panel"})),g("button",{type:"button",class:"btn ghost square",onClick:this.downloadSource,title:Bn("downloadSource")},g("i",{class:"icon icon-download"})))),g("div",{class:U("svg-box-preview canvas flex justify-center items-center",s?"hidden":"")},g("div",{dangerouslySetInnerHTML:{__html:n}})),s?g("div",{class:"svg-box-source border-t overflow-auto"},g(n_,{code:n,lang:"html"})):null)}};const JS=Object.freeze(Object.defineProperty({__proto__:null,HtmlSandbox:s_,SvgBox:i_},Symbol.toStringTag,{value:"Module"}));class ec extends ve{init(){const{html:e}=this.options;e===void 0&&(this.options.html=this.$element.text(),this.$element.empty())}}ec.NAME="HtmlSandbox",ec.Component=s_,ec.register();class tc extends ve{init(){const{svg:e}=this.options;e===void 0&&(this.options.svg=this.$element.text(),this.$element.empty())}}tc.NAME="SvgBox",tc.Component=i_,tc.register(),st(JS);const qM="";let zu=class extends Ve{constructor(e){super(e),this._syncPickerData=()=>{const o=this.getFormData();v(this.element).find(".pick-value[name]").each((a,l)=>{const c=v(l),h=c.attr("name").split("[")[0],d=o[h];c.trigger("syncValue",{setValue:d})})},this._handleDeleteQueryClick=(o,a)=>{a.stopPropagation(),this.deleteQuery(o)},this._handleChange=o=>{const a=v(o.target);let l=a.attr("name");if(!l)return;l.endsWith("]")&&(l=l.split("[")[0]);let c=a.val();Array.isArray(c)&&(c=c.join(",")),this.changeData(l,c)},this._handleSubmit=o=>{o.preventDefault(),this.submit()};const{setting:t,preserve:n,module:s}=e;let r;n&&(r=`SearchForm:${typeof n=="string"?n:s}:more`,this._preserveKey=r),this.state={showQueryPanel:!1,setting:t&&t.conditions?t:void 0,more:r?nt.get(r):void 0},this.submit=this.submit.bind(this),this.reset=this.reset.bind(this)}get showMore(){var e;return this.state.more??((e=this.state.setting)==null?void 0:e.more)}get isShow(){return this.state.show??this.props.show}get loaded(){return!!this.state.setting}get groupItemCount(){var e;return((e=this.state.setting)==null?void 0:e.groupItemCount)||3}componentDidMount(){this.props.show&&this.show(),v.on(`update.SearchForm.zt.${this._gid}`,(e,t)=>{t&&t.module===this.props.module&&this.load(t.reset??!0)}),v.on(`addQuery.SearchForm.zt.${this._gid}`,(e,t)=>{t&&t.module===this.props.module&&this.addQuery(t.id,t.text)})}componentDidUpdate(e,t){const{container:n}=this.props;if(n){const s=v(n),{show:r,more:o}=this.state,a=r!==t.show,l=o!==t.more;a&&s.toggleClass("show-search-form",r),(a||l)&&s.trigger("layout.SearchForm.zt",this),l&&this._preserveKey&&nt.set(this._preserveKey,o)}}componentWillUnmount(){v.off(`.SearchForm.zt.${this._gid}`)}async load(e){if(this.state.loading)return;await this.changeState({loading:!0,...e?{data:void 0}:null});const t=this.props.url||ut("search","buildForm",`module=${this.props.module}`);try{const n=await Ne(t);await this.changeState({setting:n,loading:!1,clickedReset:!1})}catch{await this.changeState({loading:!1,clickedReset:!1})}e&&this._syncPickerData()}async show(){await this.changeState({show:!0}),this.loaded||await this.load()}toggleQueryPanel(e){return e===void 0&&(e=!this.state.showQueryPanel),this.changeState({showQueryPanel:e})}toggle(e){return e===void 0&&(e=!this.isShow),e?this.show():this.hide()}toggleMore(e){return e===void 0&&(e=!this.showMore),this.changeState({more:e})}hide(){return this.changeState({show:!1})}getFormData(e){var s;e=e||this.state.setting;const t={groupAndOr:"or"},n=this.groupItemCount*2;for(let r=1;r<=n;r++)t[`field${r}`]=((s=this._conditionList[r-1])==null?void 0:s.value)??"",t[`operator${r}`]="=",t[`value${r}`]="",t[`andOr${r}`]="and";return{...t,...e.defaultData,...this.state.data}}getSubmitData(){const e=this._data;return{module:this.props.module,actionURL:this.state.setting.actionURL,groupItems:this.groupItemCount,formType:this.showMore?"more":"lite",...e}}submit(){var n;let e=this.getSubmitData();if(!e)return;const t=(n=this.props.beforeSearch)==null?void 0:n.call(this,e);t!==!1&&(t&&(e=t),li({url:this.props.searchUrl||ut("search","buildQuery"),data:e,onSuccess:s=>{var r;return((r=this.props.onSearch)==null?void 0:r.call(this,s))===!1||this._handleSearch(v.extend({success:()=>this.load()},typeof s.load=="string"?{url:s.load}:s.load)),!1}}))}reset(){return this.changeState(e=>{const t=new Array(this.groupItemCount*2).fill(0).reduce((n,s,r)=>(n[`value${r+1}`]="",n),{});return{clickedReset:!0,data:{...e.data,...t}}},this._syncPickerData)}applyQuery(e){var s;const{actionURL:t}=this.state.setting,n=t.replace("myQueryID",String(e));((s=this.props.onSearch)==null?void 0:s.call(this,{result:"success",load:n}))!==!1&&this._handleSearch({url:n,success:()=>this.load(!0)})}deleteQuery(e,t){const{deleteQueryConfirm:n,canDeleteQuery:s}=this.state.setting;if(!t&&n){He.confirm(n).then(o=>{o&&this.deleteQuery(e,!0)});return}const r=typeof s=="string"?s.replace("{id}",`${e}`):ut("search","deleteQuery",`queryID=${e}`);li({url:r,onSuccess:()=>{const o=this.state.setting,{savedQueryList:a=[]}=o;return this.changeState({setting:{...o,savedQueryList:a.filter(l=>l.id!==e)}}),!1}})}addQuery(e,t){const n=this.state.setting,{savedQueryList:s=[]}=n;s.some(r=>r.id===e)||this.changeState({showQueryPanel:!0,setting:{...n,savedQueryList:[{id:e,text:t},...s]}})}changeData(e,t){const n={[e]:t};if(e.startsWith("field")){const s=t,r=+e.substring(5),{defaultOperator:o,defaultValue:a=""}=this._conditionMap[s];o&&(n[`operator${r}`]=o),n[`value${r}`]=a}else if(e.startsWith("value")){const s=this.getFormData(),r=+e.substring(5),o=s[`field${r}`],{control:a}=this._conditionMap[o];if(a==="date"){const l=t.startsWith("$"),c=s[`operator${r}`];l&&c!=="between"?n[`operator${r}`]="between":!l&&c==="between"&&(n[`operator${r}`]="<=")}}this.changeState(s=>({data:{...s.data,...n}}),this._syncPickerData)}_handleSearch(e){const t=this.element.closest(".modal");let{searchLoader:n=t?{load:"modal",target:t}:"table"}=this.props;const s=v(this.element);let r=s.closest(".tab-pane");typeof n=="string"?(n={load:n},r.length||(r=s.closest("#main"))):t&&(r.length||(r=v(t)));const o=r.find("[data-zui-dtable]");return o.length&&!this.props.searchLoader&&(n.load="table",n.target=o.children(".dtable").attr("id")),typeof e=="string"?n.url=e:typeof e=="object"&&(n={...n,...e}),v.trigger("locate.zt",n),!1}_renderOperators(e,t){var s;const n=this._operatorList;return g(Zt,{name:e,items:n,required:!0,defaultValue:t??((s=n[0])==null?void 0:s.value),search:!1,maxItemsCount:0})}_renderControl(e,t,n,s){const r=this._conditionMap[e]||{},{control:o="text"}=r,{controlRenders:a}=this.constructor,l=a[o]||a.text;return o==="date"&&r.datePeriods===void 0&&s.datePeriods&&(r.datePeriods=s.datePeriods),l.call(this,r,t,n??"")}_renderField(e,t,n,s,r){var h;const{conditions:o}=s,a=t*n+e+1,l=!e;this._conditionList||(this._conditionList=o.map(({text:d,name:f})=>({text:d??f,value:f})));const c=r[`field${a}`]??((h=o[a])==null?void 0:h.name);return g("tr",{key:a,className:"search-form-field"},g("td",{className:U("is-andOr",l?"font-bold text-right nowrap":void 0)},l?(s.groupTitles||[])[t]:this._renderAndOrSelect(`andOr${a}`,r[`andOr${a}`],s)),g("td",{className:"is-condition"},g(Zt,{name:`field${a}`,items:this._conditionList,required:!0,defaultValue:c,popMinWidth:"100%",popWidth:"auto",maxItemsCount:0})),g("td",{className:"is-operator"},this._renderOperators(`operator${a}`,r[`operator${a}`])),g("td",{className:"is-control",key:`${c}:${a}`},this._renderControl(c,`value${a}`,r[`value${a}`],s)))}_renderGroup(e,t,n){const{groupItemCount:s}=this,{showMore:r}=this,o=[],a=r?s:1;for(let l=0;l<a;l++)o.push(this._renderField(l,e,s,t,n));return g("div",{className:"search-form-group flex-1",key:e},g("table",{className:"table-fixed w-full"},g("tbody",null,o)))}_renderAndOrSelect(e,t,n){const{andText:s="And",orText:r="Or"}=n;return g(Zt,{name:e,items:[{value:"and",text:s},{value:"or",text:r}],defaultValue:t,required:!0,search:!1})}_renderForm(e,t){this._conditionMap={},this._conditionList=e.conditions.map(d=>{const{name:f,text:p}=d;return this._conditionMap[f]=d,{text:p??f,value:f}});const{showMore:n}=this;this._operatorList=(e.operators||"=,!=,>,>=,<,<=".split(",")).map(d=>typeof d=="string"?{text:d,value:d}:d);const s=this.getFormData(e);this._data=s;const{searchBtnText:r="Search",resetBtnText:o="Reset",saveQueryBtnText:a="Save",canSaveQuery:l}=e,{simple:c,noMore:h}=t;return g("form",{key:"form",className:"search-form-wrapper flex-auto py-3 px-2",onSubmit:this._handleSubmit},g("div",{className:"row items-center",onChange:this._handleChange},this._renderGroup(0,e,s),g("div",{className:"col flex-none items-center justify-center px-4 w-24"},this._renderAndOrSelect("groupAndOr",s.groupAndOr,e)),this._renderGroup(1,e,s)),g("div",{className:`toolbar gap-4 justify-center flex-nowrap ${c?"ml-4":"mt-3"}`},g(we,{key:"submit",type:"primary",btnType:"submit"},r),c?null:g(we,{key:"reset",onClick:this.reset},o),c&&h?null:g("div",{className:c?"":"absolute top-0 right-0"},c?null:g(we,{key:"saveQuery",type:"ghost",className:"text-primary","data-toggle":"modal",disabled:!l||this.state.clickedReset,url:l?typeof l=="string"?l:ut("search","saveQuery",`module=${t.module}`):void 0,"data-title":a},a),h?null:g(we,{key:"toggle",type:"ghost",className:"text-primary",icon:n?"chevron-double-up":"chevron-double-down",onClick:this.toggleMore.bind(this,void 0)}))))}_renderQueryPanel(e,t){const{savedQueryList:n=[],saveQueryPanelWidth:s=200,saveQueryPanelTitle:r="Saved queries",canDeleteQuery:o}=t;return g("div",{key:"panel",className:U("search-form-query sidebar sidebar-right pt-3 transition-none",e?"is-expanded":"is-collapsed"),style:{minHeight:100,width:e?Be(s):0,transition:"none"}},g("div",{class:"sidebar-gutter gutter gutter-border gutter-horz border-default",onClick:this.toggleQueryPanel.bind(this,void 0)},g("button",{class:"gutter-toggle",type:"button"},g("span",{class:"chevron-right"}))),e?g("div",{className:"search-form-query-panel pl-3 h-full col"},g("div",{className:"search-form-query-title font-bold mb-1.5 flex-none"},r),g("ul",{className:"search-form-query-list col items-start gap-1 overflow-auto scrollbar-hover pr-3 pb-2 pt-px pl-0"},n.map(({id:a,text:l,noDelete:c})=>g("li",{key:a,className:`search-form-query-item label gray-pale rounded-full state pl-2 hover:text-primary hover:primary-pale inline-flex gap-1 max-w-full ${o&&!c?"pr-0":"pr-2"}`,onClick:this.applyQuery.bind(this,a)},g("span",{className:"min-w-0 flex-auto overflow-hidden nowrap"},l),o&&!c?g(we,{type:"ghost",className:"size-xs rounded-full flex-none"},g("i",{className:"close",onClick:this._handleDeleteQueryClick.bind(this,a)})):null)))):null)}_getProps(e){return{...super._getProps(e),"data-module":e.module}}_getClassName(e){const t=super._getClassName(e);if(!this.isShow)return[t,"search-form","hidden"];const{setting:n,showQueryPanel:s}=this.state,{showMore:r}=this,o=n==null?void 0:n.savedQueryList;return[t,"search-form",n?"is-loaded":"is-empty",{"is-lite":!r,"is-more":r,"is-simple":e.simple,"show-save-query":o&&s}]}_getChildren(e){if(!this.isShow)return null;const{setting:t,showQueryPanel:n,loading:s}=this.state,r=!e.simple&&t&&t.savedQueryList;return g("div",{className:U(`search-form-container row gap-3 load-indicator${s?" loading":""}`,e.innerClass),style:`max-height: ${76+44*(this.showMore?this.groupItemCount:1)}px`},t?this._renderForm(t,e):null,r?this._renderQueryPanel(n,t):null)}};zu.controlRenders={text:(i,e,t)=>g("input",{className:"form-control",type:"text",name:e,value:t,placeholder:i.placeholder,...i.controlProps}),select:(i,e,t)=>{const{items:n=[]}=i;return g(Zt,{name:e,items:n,defaultValue:t,placeholder:i.placeholder,popMinWidth:"100%",popWidth:"auto",maxItemsCount:0,...i.controlProps})},date:(i,e,t)=>{const{datePeriods:n}=i,s={};return n&&(s.menu=[...n],s.allowInvalid=!0,s.display=r=>{const o=n.find(a=>a.value===r);return o?o.text:r}),g(Hi,{name:e,defaultValue:t,placeholder:i.placeholder,...s,...i.controlProps})},time:(i,e,t)=>g(qa,{name:e,defaultValue:t,placeholder:i.placeholder,...i.controlProps}),datetime:(i,e,t)=>g(yd,{name:e,defaultValue:t,placeholder:i.placeholder,...i.controlProps})},zu.defaultProps={preserve:!0};class an extends ve{}an.NAME="SearchForm",an.Component=zu,an.replace=!0,an.toggleForm=Fu,an.update=r_,an.addQuery=o_,an.toggle={convertHref:!0,getOptions(i,e){const t=v(i);if(t.is("a")){const n=t.attr("href");n&&(!e.target&&"#.".includes(n[0])?e.target=n:e.url||(e.url=n))}return e},handler(i,e){Fu({container:v(i).closest(e.container||".modal,#main"),...e})}},an.register();function Fu(i){typeof i=="string"?i={module:i}:i||(i={module:window.config.currentModule});const e=v(i.container||".modal,#main").first();if(!e.length)return;i.module||(i.module=window.config.currentModule);let t;if(i.target?t=v(i.target,e):(t=e.find(`[${an.DATA_KEY}],.search-form`),i.module&&(t=t.filter(`[data-module="${i.module}"]`))),!t.length&&!i.target){let s=e.closest(".modal").find(".modal-body");s.length||(s=e.find(".main-content-cell")),s.length||(s=e.find("#mainContent")),t=v("<div/>").attr({"zui-key":"searchForm","data-module":i.module}).prependTo(s.length?s.first():e)}let n=t.zui(an.NAME);return n?n.$.toggle(i.show):n=new an(t,{container:e,show:!0,...i}),n}function r_(i,e){v.trigger("update.SearchForm.zt",{module:i,reset:e})}function o_(i){v.trigger("addQuery.SearchForm.zt",i)}const GM="",Ou=new Ni("snapdom",{src:["snapdom/snapdom.min.js"],check:"snapdom"}),a_=async(i,e)=>{const t=await Ou.load();if(!t)throw new Error("SnapDOM method not loaded");return await t(i,e)};["toImg","toSvg","toCanvas","toBlob","toPng","toJpg","toWebp","download"].forEach(i=>{Object.assign(a_,{[i]:async function(...e){return await(await Ou.load())[i].call(this,...e)}})});class fo extends Ft{constructor(){super(...arguments),this._menuRef=pe(),this._handClickItem=e=>{var t,n;(n=(t=this.options).onSelect)==null||n.call(t,e.item)},this._handlePanelInited=()=>{var e;this.layout(),(e=this.menu)==null||e.activeFirst()}}get triggerRect(){return this._triggerRect}get menu(){return this._menuRef.current}_getMenuOptions(){var e;return{...super._getMenuOptions(),items:(e=this._suggestions)==null?void 0:e.map(t=>({...t,key:t.value})),ref:this._menuRef,onClickItem:this._handClickItem}}init(){super.init();const{suggestions:e,triggerRect:t}=this.options;this._triggerRect=t,this._suggestions=e}getTriggerElement(){if(!this._triggerElement){let e=this.options.element;e||(e={getBoundingClientRect:()=>this._triggerRect||new DOMRect}),this._triggerElement=e,this._virtual=!(e instanceof HTMLElement)}return this._triggerElement}update({rect:e,suggestions:t}){var n;t&&(v(this.target).toggleClass(this.options.animation?"fade":"hidden",!t.length),this._suggestions=t,this.render()),e&&((n=this._suggestions)!=null&&n.length)&&(this._triggerRect=e,this.shown||this.show(),this.updatePosition())}handleKeyDown(e){var n,s;if(e.key==="Escape")return this.hide(),!0;const{menu:t}=this;if(t){if(e.key==="ArrowUp")return t.activePrev(),!0;if(e.key==="ArrowDown")return t.activeNext(),!0;if(e.key==="Enter"){const r=t.getActiveKey(),o=t.getItem(r);return o&&((s=(n=this.options).onSelect)==null||s.call(n,o)),!0}}return!1}}fo.NAME="SuggestionMenu",fo.DEFAULT={...Ft.DEFAULT,name:"suggestion-menu",trigger:"manual",show:!0,animation:!1},fo.register();const ZM="",YM="",po=new Ni("tiptap",{src:["teditor/tiptap.js"],check:"tiptap"}),l_=new Map;function c_(i,e){const t=typeof e=="object"?{name:i,...e}:e;l_.set(i,t)}function XS(i){return l_.get(i)}function nc(i,e){const{Extension:t}=po.Module,n=XS(i);if(!n)throw new Error(`Extension ${i} not found`);let s=t.create(n);return e&&(s=s.configure(e)),s}const Bu=class sp extends qe{constructor(){super(...arguments),this._handTransaction=e=>{var s,r,o,a;(r=(s=this.options.tiptap)==null?void 0:s.onTransaction)==null||r.call(s,e);const t=this.getContent(),n=typeof t=="string"?t:JSON.stringify(t);n!==this._lastContent&&(this._lastContent=n,(a=(o=this.options).onChange)==null||a.call(o,n,this._lastContent)),this.$element.trigger("change",{value:n,content:t,transaction:e})},this._handleFocus=e=>{var t,n;(n=(t=this.options.tiptap)==null?void 0:t.onFocus)==null||n.call(t,e),this.$element.addClass("focus").trigger("focus",e)},this._handleBlur=e=>{var t,n;(n=(t=this.options.tiptap)==null?void 0:t.onBlur)==null||n.call(t,e),this.$element.removeClass("focus").trigger("blur",e)}}get value(){return this._lastContent}init(){const{mode:e,contentType:t}=this.options;t||(this.options.contentType=e==="plain"?"text":"html");let{content:n}=this.options;n===void 0&&(n=t==="text"?this.$element.text():this.$element.html(),this.$element.empty(),this.options.content=n),this._lastContent=typeof n=="string"?n:JSON.stringify(n)}async afterInit(){await sp.loadModule(),this.$element.addClass("teditor form-control"),this.render()}render(e){super.render(e);const{Editor:t}=sp.Module;if(this._editor){const n=this.options.content;n&&this._editor.commands.setContent(n)}else this._editor=new t(this._getEditorOptions())}getText(e){var t;return(t=this._editor)==null?void 0:t.getText(e)}getHtml(){var e;return(e=this._editor)==null?void 0:e.getHTML()}getData(){var e;return(e=this._editor)==null?void 0:e.getJSON()}getContent(e){return e=e||this.options.contentType,e==="text"?this.getText():e==="html"?this.getHtml():this.getData()}setContent(e){var t;(t=this._editor)==null||t.commands.setContent(e)}_getEditorOptions(){const{element:e,options:t}=this,{content:n="",editorProps:s,readonly:r,tiptap:o}=t;return{element:e,content:n,editorProps:s,extensions:this._getEditorExtensions(),editable:!r,...o,onFocus:this._handleFocus,onBlur:this._handleBlur,onTransaction:this._handTransaction}}_getEditorExtensions(){const{extensions:e,suggestions:t,suggestionsOptions:n,mode:s}=this.options,r=[];return s==="plain"&&r.push(nc("plainText")),t&&r.push(nc("suggestions",{suggestions:t,...n})),e&&e.forEach(o=>{typeof o=="string"?r.push(nc(o)):Array.isArray(o)?r.push(nc(o[0],o[1])):r.push(o)}),r}static get Module(){return po.Module}static loadModule(){return po.load()}};Bu.NAME="TEditor",Bu.DEFAULT={mode:"plain"};let h_=Bu;h_.register(),c_("plainText",{addExtensions(){const{Node:i}=po.Module,e=i.create({name:"doc",topNode:!0,content:"paragraph+"}),t=i.create({name:"paragraph",group:"block",content:"(text | mention)*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:s}){return["p",s,0]}}),n=i.create({name:"text",group:"inline",inline:!0});return[e,t,n]}});function QS(i,e,t){const n={char:i};return typeof e=="function"?n.items=s=>e(s.query):Array.isArray(e)?(t=t||((s,r)=>dt.isItemMatch(s,[r])),n.items=s=>e.filter(r=>t(r,s.query))):Object.assign(n,e),n.render=n.render||(()=>{let s;return{onStart:({items:r,clientRect:o,command:a})=>{s=fo.create({suggestions:r,triggerRect:o==null?void 0:o(),onSelect:l=>{a==null||a({id:l.key??l.value,label:l.value??l.text})}})},onUpdate:({clientRect:r,items:o})=>{!s||!r||s.update({rect:r(),suggestions:o})},onKeyDown:({event:r})=>s?s.handleKeyDown(r):!0,onExit:()=>{s==null||s.destroy(),s=void 0}}}),n}c_("suggestions",()=>({name:"suggestions",addOptions(){return{suggestions:{}}},addExtensions(){const{extensions:i}=po.Module,{suggestions:e,isItemMatch:t,...n}=this.options,s=Object.entries(e).map(([r,o])=>QS(r,o,t));return[i.Mention.configure({HTMLAttributes:{class:"mention-label"},...n,...s.length===1?{suggestion:s[0]}:{suggestions:s}})]}}));const JM="";class sc extends ve{}sc.NAME="UserAvatar",sc.Component=Ji,sc.register();class ju extends ve{}ju.NAME="ZenEditor",ju.Component=Pv;const XM="",eT={1:"error",2:"warning",4:"parse",8:"notice",16:"core-error",32:"core-warning",64:"compile-error",128:"compile-warning",256:"user-error",512:"user-warning",1024:"user-notice",2048:"strict",4096:"recoverable-error",8192:"deprecated",16384:"user-deprecated",32767:"all"};function Hu(i){return typeof i=="number"&&(i=eT[i]),i}function d_(i){return i=Hu(i),i.includes("error")?"error":i.includes("warning")?"warning":"info"}function tT({errors:i,...e}){const t=i.reduce((n,s)=>(n[d_(s.level)]++,n),{error:0,warning:0,info:0});return g("div",{class:"row items-stretch text-sm","data-hint":"PHP errors",...e},t.error?g("button",{type:"button",class:"state font-bold px-0.5 danger"},g("span",{class:"scale-95 font-bold inline-block text-opacity-70 text-canvas"},"ERR"),t.error):null,t.warning?g("button",{type:"button",class:"state font-bold px-0.5 danger bg-opacity-90"},g("span",{class:"scale-95 font-bold inline-block text-opacity-70 text-canvas"},"WAR"),t.warning):null,t.info?g("button",{type:"button",class:"state font-bold px-0.5 danger bg-opacity-80"},g("span",{class:"scale-95 font-bold inline-block text-opacity-70 text-canvas"},"INF"),t.info):null)}function Jt(i,e,t,n){console.groupCollapsed(`%c${i} %c${e}`,"color: #fff; background-color: #9333ea; padding: 0 0.1em 0 0.25em; border-radius: 0.25em 0 0 0.25em;","color: #9333ea; background-color: #e9d5ff; padding: 0 0.5em; border-radius: 0 0.25em 0.25em 0;",n),console.table(t),console.groupEnd()}function Ds(i,e=400,t=100){return i<t?"success":i<e?"warning":"danger"}function Cn(i){return i<1e3?`${i.toFixed(0)}ms`:`${(i/1e3).toFixed(2)}s`}function u_({perf:i,guardState:e,guardData:t}){var l;const n=i.id==="page"?"页面":i.id==="#dtable"?"表格":"部分",s=[],{trace:r,xhprof:o}=i,a=r==null?void 0:r.request;if(e){const c=e==="sending"?"发送中":e==="error"?"发送失败,点击查看":"已发送",h=e==="sending"?"text-warning":e==="error"?"text-danger":"text-success",d=t?`${t.request.module}-${t.request.method}#${t.requestId}`:"",f=Jt.bind(null,"Perf Guard Data",e===!0?"sended":e||"null",t,t==null?void 0:t.requestId);s.push(g("div",{onClick:f,class:`px-0.5 state ${h}`,"data-hint":`性能门禁数据${t?`(${d})`:""}:${c}`},g("i",{class:e==="sending"?"icon icon-spinner-indicator spin":e===!0?"icon-shield-check":"icon-shield"})),g("div",{class:"muted"},"/"))}if(i.requestEnd){i.clientCache&&s.push(g("div",{class:"px-0.5 state text-success","data-hint":`使用本地缓存渲染:${i.clientCache}`},g("i",{class:"icon-check-circle"})),g("div",{class:"muted"},"/"));const c=i.requestEnd-i.requestBegin;if(s.push(g("div",{class:`px-0.5 state text-${Ds(c,500,300)}`,"data-hint":"总加载时间 (好<300ms≤正常<500ms≤差)",onClick:Jt.bind(null,"Trace","Perf",i,i.id)},g("i",{class:"icon-history"})," ",Cn(c))),a){const d=a.timeUsed;s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${Ds(d)}`,"data-hint":"服务器耗时 (好<300≤正常<500≤差)",onClick:Jt.bind(null,"Trace","Request",a,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"S"),Cn(d)))}if(i.dataSize){if(a){const d=c-a.timeUsed;s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${Ds(d,600,200)}`,"data-hint":"网络用时 (好<200≤正常<600≤差)",onClick:Jt.bind(null,"Trace","Request",a,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"N"),Cn(d)))}if(s.push(g("div",{class:"px-0.5 state","data-hint":"下载大小",onClick:Jt.bind(null,"Trace","Perf",i,i.id)},g("span",{class:"muted"},g("i",{class:"icon icon-cube"})," ",pt(i.dataSize,1)))),a){const d=c-a.timeUsed,f=1e3*i.dataSize/d;s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${f<102400?"danger":f<1024e3?"warning":"success"}`,"data-hint":"下载速度(B<100KB≤正常<1MB≤G)",onClick:Jt.bind(null,"Trace","Request",a,i.id)},g("i",{class:"icon icon-arrow-down"}),pt(f,1),"/s"))}}if(i.renderEnd&&i.renderBegin){const d=i.renderEnd-i.renderBegin,f=Ds(d,200,50);s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${f}`,"data-hint":"浏览器渲染用时 (好<50≤正常<200≤差)",onClick:Jt.bind(null,"Trace","Perf",i,i.id)},g("i",{class:`icon-${f==="danger"?"frown":f==="warning"?"meh":"smile"}`}),Cn(d)))}if(a){const{memory:d,querys:f}=a;typeof d=="number"&&s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${Ds(d*1024,1024e3,102400)}`,"data-hint":"服务器内存占用 (好<10KB≤正常<100KB≤差)",onClick:Jt.bind(null,"Trace","Request",a,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"M"),pt(d*1024))),typeof f=="number"&&s.push(g("div",{class:"muted"},"/"),g("div",{class:`px-0.5 state text-${Ds(f,100,60)}`,"data-hint":"SQL执行次数 (好<60≤正常<100≤差)",onClick:Jt.bind(null,"SQL Query",`${((l=r.sqlQuery)==null?void 0:l.length)??0} queries`,r.sqlQuery,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"Q"),f))}r!=null&&r.files&&s.push(g("div",{class:"muted"},"/"),g("div",{class:"px-0.5 state","data-hint":"服务器加载PHP文件数目",onClick:Jt.bind(null,"Trace",`${r.files.length} php files`,r.files,i.id)},g("span",{class:"muted"},g("i",{class:"icon-file icon-sm scale-75"}),r.files.length)));const h=r==null?void 0:r.profiles;if(h!=null&&h.length){let d=0,f={Duration:0};if(h.forEach(p=>{p.Duration>.3&&d++,p.Duration>f.Duration&&(f=p)}),s.push(g("div",{class:`px-0.5 state text-${Ds(d,3,1)}`,"data-hint":"服务器最慢SQL数 (好<1≤正常<3≤差)",onClick:Jt.bind(null,"SQL Query",`${h.length} SQL profiles`,h,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"LQ"),d)),f.Duration){const p=f.Duration*1e3;s.push(g("div",{class:`px-0.5 state text-${Ds(p,600,300)}`,"data-hint":"服务器最慢SQL耗时 (好<300≤正常<600≤差)",onClick:Jt.bind(null,"SQL Query",`Slowest SQL query: ${p}ms`,f,i.id)},g("span",{class:"scale-95 font-bold inline-block"},"MLQ"),Cn(p)))}}}else s.push(g("div",{class:"muted px-0.5"},"loading..."));return g("div",{class:"zin-perf-btn-list row items-center bg-black text-sm"},g("div",{class:"px-1 bg-canvas bg-opacity-20 self-stretch flex items-center","data-hint":`请求 ${i.id} URL: ${i.url}`},g("span",{class:"muted"},n)),s,o?g("a",{class:"state text-secondary px-0.5",href:o,target:"_blank","data-hint":"打开 xhprof 报告"},"XHP"):null)}function nT(i,e,t){var n,s;if(t.target.closest(".ask-ai")){(s=(n=window.zui)==null?void 0:n.AIPanel)==null||s.shared.openPopup({viewType:"chat",postMessage:[`/phpExpert PHP error message: ${i.message}`,`File: ${i.file}`,`Line: ${i.line}`,`Level: ${Hu(i.level)} ${i.level}`,`Trace:
  66. \`\`\`
  67. ${i.trace}
  68. \`\`\``,e!=null&&e.url?`Request: ${e.method||"GET"} ${e.url}`:"",e!=null&&e.php?`PHP Version: ${e.php}`:""].filter(Boolean).join(`
  69. `),props:{mode:"full"}});return}Jt("Trace","Error",i,i.message),navigator.clipboard.writeText(`vim +${i.line} ${i.file}`)}function sT({errors:i=[],show:e,basePath:t,request:n}){var o,a;i.length||(e=!1);const s=(a=(o=window.zui)==null?void 0:o.AIPanel)==null?void 0:a.shared,r=i.map(l=>{const c=Hu(l.level),h=d_(c),d=h==="error"?"danger":h==="info"?"important":"warning";return g("div",{class:`zin-error-item state ${d}-pale text-fore px-2 py-1 ring ring-darker`,onClick:nT.bind(null,l,n)},g("div",{class:"zin-error-msg font-bold text-base"},g("strong",{class:`text-${d}`,style:"text-transform: uppercase;"},c)," ",l.message),g("div",{class:"zin-error-info text-sm break-all mt-0.5"},s?g("button",{type:"button",class:"btn ai-styled size-xs mr-2 ask-ai"},"Ask AI"):null,g("strong",{className:"opacity-60"},"vim +",l.line)," ",g("span",{className:"underline opacity-70"},t?l.file.substring(t.length):l.file)))});return g("div",{class:`zin-errors-panel canvas absolute bottom-full left-0 mono shadow-xl ring rounded fade-from-bottom ${e?"in":"events-none"}`},r)}const QM="";function iT(){const i=navigator.userAgent;let e="Unknown",t="Unknown";return i.indexOf("Chrome")>-1?(e="Chrome",t=i.substring(i.indexOf("Chrome")+7)):i.indexOf("Firefox")>-1?(e="Firefox",t=i.substring(i.indexOf("Firefox")+8)):i.indexOf("Safari")>-1?(e="Safari",t=i.substring(i.indexOf("Safari")+7),i.indexOf("Version")>-1&&(t=i.substring(i.indexOf("Version")+8))):window.StyleMedia&&(e="Edge",t=i.substring(i.indexOf("Edge")+5)),t=t.split(" ")[0],t=t.split(";")[0],t=t.split(")")[0],{name:e,version:t}}let rT=class extends re{constructor(e){var t,n;super(e),this._timer=0,this._browser=iT(),this._guardData={},this.state={showPanel:e.defaultShow??!0,showZinbar:!!((n=(t=e.defaultData)==null?void 0:t.errors)!=null&&n.length||!nt.get("Zinbar:hidden")),...e.defaultData},this.togglePanel=this.togglePanel.bind(this),this.sendGuardData=this.sendGuardData.bind(this),this.handleClickOutside=this.handleClickOutside.bind(this)}componentDidMount(){document.addEventListener("click",this.handleClickOutside)}componentDidUpdate(){var o,a,l,c;const{pagePerf:e}=this.state;let t="",n="";const s=(a=(o=e==null?void 0:e.trace)==null?void 0:o.sqlQuery)==null?void 0:a.length,r=(c=(l=e==null?void 0:e.trace)==null?void 0:l.request)==null?void 0:c.timeUsed;if(r&&e.renderEnd){const h=e.renderEnd-e.renderBegin,d=r+h,f=[];let p="",y="";d>=500?(p="danger",f.push(`处理时间${Cn(d)}超过500ms(后端${Cn(r)},前端${Cn(h)})`)):d>=300&&(p="warning",f.push(`处理时间${Cn(d)}超过300ms(后端${Cn(r)},前端${Cn(h)})`)),s&&(s>=60?(y="danger",f.push(`SQL查询超过60次(实际${s})`)):s>=40&&(y="warning",f.push(`SQL查询超过40次(实际${s})`))),(p||y)&&(t=p==="danger"||y==="danger"?"danger":"warning",n=[t==="danger"?"页面有性能问题":"页面有优化空间",...f].join(","))}v("body").z({perf:t,perfMessage:n})}componentWillUnmount(){document.removeEventListener("click",this.handleClickOutside)}handleClickOutside(e){const t=e.target;this.state.showPanel&&!t.closest(".zinbar")&&this.setState({showPanel:!1})}async sendGuardData(e=180){var p,y,b;const{guardApi:t}=this.props;if(!t)return;this._timer&&clearTimeout(this._timer);const{pagePerf:n}=this.state;if(!(n!=null&&n.renderEnd))return;if(e){this._timer=window.setTimeout(()=>{this.sendGuardData(0)},e);return}const s=zy(n.url);if(!(s!=null&&s.moduleName))return;this.setState({guardState:"sending"});const{author:r="anonymous",email:o,host:a=location.origin}=this.props,{profiles:l=[],sqlQuery:c=[],request:h}=n.trace||{};l.forEach(w=>{w.DurationOriginal||(w.DurationOriginal=w.Duration,w.Duration=1e3*w.Duration)});const d=c.findIndex(w=>w.includes("SET profiling = ")),f=d>=0?c.length-d-1:c.length;this._guardData={timestamp:Date.now(),identifier:r,email:o,requestId:Ot(),dataVer:3,request:{host:a,url:/https?:/.test(n.url)?n.url:`${a}${n.url}`,module:s.moduleName,method:s.methodName,xhprof:n.xhprof?/https?:/.test(n.xhprof)?n.xhprof:`${a}${n.xhprof}`:null,php:h==null?void 0:h.php,errorCount:((p=this.state.errors)==null?void 0:p.length)||0,errors:this.state.errors??[]},userEnv:{system:navigator.userAgentData?navigator.userAgentData.platform:navigator.platform,userAgent:navigator.userAgent,browser:[this._browser.name,this._browser.version].join(" ")},metrics:{frontend:{renderTime:Math.round(n.renderEnd-n.renderBegin),downloadSize:n.dataSize},backend:{totalTime:h==null?void 0:h.timeUsed,sqlTime:l.reduce((w,x)=>w+x.Duration,0),sqlCount:Math.max(l.length||0,f),sqlDetails:l,phpFileLoaded:((y=n.trace)==null?void 0:y.files.length)||0,phpFiles:(b=n.trace)==null?void 0:b.files,requestMemory:h==null?void 0:h.memory}}};try{const w=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this._guardData),mode:"no-cors"});this._guardData.$response=await w.text(),this.setState({guardState:!0})}catch(w){this._guardData.$error=w,console.error("[ZUI] Send guard data failed:",w,this),this.setState({guardState:"error"})}}update(e,t,n){this.setState(s=>{const r=!(e!=null&&e.id)||e.id==="page",o={};return r?(e&&(o.pagePerf={...s.pagePerf,...e}),t&&(o.errors=t),e!=null&&e.requestEnd||(o.guardState=!1)):(e&&(o.partPerf={...s.partPerf,...e}),t&&(o.errors=[...s.errors??[],...t??[]])),n&&(o.basePath=n),o},this.props.guardApi?this.sendGuardData:void 0)}togglePanel(){this.setState({showPanel:!this.state.showPanel})}toggleZinbar(){const e=!this.state.showZinbar;this.setState({showZinbar:e},()=>{nt.set("Zinbar:hidden",!e)})}render(){var c;const{errors:e,pagePerf:t,partPerf:n,showZinbar:s,basePath:r,guardState:o}=this.state,{fixed:a}=this.props,l=e==null?void 0:e.length;return g("div",{className:U("zinbar row h-5 items-stretch gap-px inverse bg-opacity-50",a?"relative":"fixed right-0 bottom-0",{collapse:!s}),style:{zIndex:9999}},g("button",{type:"button","data-hint":s?"折叠":"展开",className:`w-4 ${l&&!s?"danger":"bg-inverse"} flex items-center justify-center`,style:{marginLeft:-15},onClick:this.toggleZinbar.bind(this)},g("span",{class:s?"caret-right":"caret-left"})),l?g(tT,{errors:e,onClick:this.togglePanel}):null,t?g(u_,{perf:t,guardState:o,guardData:this._guardData}):null,n?g(u_,{perf:n}):null,g("div",{class:"zin-perf-btn-list row items-center bg-black text-sm"},g("div",{"data-hint":`ZUI ${zc} (${Ze(1776236333698)})`},g("a",{href:"#!~showZuiInfo",class:"font-mono primary font-bold italic p-0.5 text-sm"},"ZUI"))),g(sT,{show:this.state.showPanel,basePath:r,errors:e,request:(c=t==null?void 0:t.trace)==null?void 0:c.request}))}};class Uu extends ve{}Uu.NAME="Zinbar",Uu.Component=rT;function f_(){const i=[`ZUI: ${zc} (${Ze(1776236333698)}, ${rp.substring(0,8)})`],e=v("#zuiJS").attr("src");e&&i.push(`Src: ${e}`);const t=window.BlockSuite;t&&i.push(`BlockSuite ${t.zui.VERSION} (${Ze(t.zui.BUILD)})`),He.alert({title:"ZUI Versions",message:i.join(`
  70. `),custom:{contentClass:"zui-info primary",bodyClass:"font-mono"},actions:[navigator.clipboard?{text:"Copy",btnType:"light-outline",icon:"copy",onClick:()=>{navigator.clipboard.writeText(i.join(`
  71. `))}}:null,{key:"close",text:"Close",btnType:"primary",className:"light-outline"}]})}dm("showZuiInfo",f_);let p_=class extends Ve{_renderContent(e){const{subtitle:t,subtitleClass:n,content:s,contentClass:r}=e;if(!(!t&&!s))return[k("div",{className:U("card-content",r),children:[t?k("div",{className:U("card-subtitle",n),children:k(de,{content:t})},"subtitle"):null,s?k(de,{content:s},"extraContent"):null]},"content")]}_renderHeading(e){const{icon:t,prefix:n,prefixClass:s,title:r,titleClass:o,titleUrl:a,titleAttrs:l,suffix:c,suffixClass:h,heading:d,headingClass:f}=e;if(!t&&!n&&!r&&!c&&!d)return;const p=a?"a":"span";return k("div",{className:U("card-heading",f),children:[t?k($e,{className:"card-icon",icon:t},"icon"):null,n?k(de,{className:U("card-prefix",s),content:n},"prefix"):null,r?k(p,{className:U("card-title",o),href:a,...l,children:k(de,{content:r})},"title"):null,c?k(de,{className:U("card-suffix",h),content:c},"suffix"):null,d?k(de,{content:d},"extraHeading"):null]})}_renderHeader(e){const{header:t,headerClass:n}=e;if(t)return k("div",{className:U("card-header",n),children:k(de,{content:t},"header")})}_renderFooter(e){const{footer:t,footerClass:n,footActions:s}=e;if(t||s)return k("div",{className:U("card-footer",n),children:[k(de,{content:t},"footer"),Fe.render(s,[e],{key:"foot-actions",relativeTarget:e,className:"card-foot-actions",size:"sm"},this)]})}_renderActions(e){return Fe.render(e.actions,[e],{key:"actions",relativeTarget:e,className:"card-actions",size:"sm"},this)}_renderList(e){const{items:t}=e;if(!t)return;const n=Pe({key:"list",className:"card-list"},typeof t=="object"?t:{items:t});return k(ht,{...n})}_renderAvatar(e){const{avatar:t}=e;if(t){const n=typeof t=="function"?t.call(this,e):t;if(n)return n.className=U("item-avatar",n.className),k(ts,{...n},"avatar")}}_getClassName(e){return["card",e.className,e.selected?"selected":""]}_getChildren(e){return[this._renderActions(e),this._renderHeader(e),this._renderAvatar(e),this._renderHeading(e),this._renderContent(e),this._renderList(e),this._renderFooter(e),e.children]}};class m_ extends p_{_getClassName(e){return e.className}_getChildren(e){const{innerAttrs:t,innerClass:n,selected:s,innerComponent:r="div"}=e,o=Pe({className:U("card",n,s?"selected":"")},t);return k(r,{...o,children:super._getChildren(e)})}}let tr=class extends ht{_getClassName(e){return[super._getClassName(e),e.countPerRow?"card-grid":""]}_getProps(e){const{gap:t,countPerRow:n}=e;return Pe({style:{"--list-gap":t?Be(t):void 0,"--list-count-per-row":n}},super._getProps(e))}_getRenderedItem(e,t){return t}};tr.NAME="card-list",tr.TAG="div",tr.ItemComponents={...ht.ItemComponents,default:m_,item:m_},tr.defaultItemProps={component:"div"};class ic extends ve{}ic.NAME="Card",ic.Component=p_,ic.replace=!0;class Vu extends ve{}Vu.NAME="CardList",Vu.Component=tr;const eN="",tN="";class nr extends Ft{_getLayoutOptions(){const e=super._getLayoutOptions();return this.options.element||(e[0]={getBoundingClientRect:this._getClickBounding}),e}}nr.NAME="ContextMenu",nr.DEFAULT={...Ft.DEFAULT,name:"contextmenu",trigger:"contextmenu"},nr.register();const nN="",sN="";function oT(i){const{left:e,className:t,top:n,id:s,onMenuBtnClick:r,title:o,width:a,height:l,content:c,loading:h,draggable:d=!0}=i;return k("div",{class:"dashboard-block-cell",style:{left:e,top:n,width:a,height:l},children:k("div",{className:U("dashboard-block load-indicator",h&&!c?"loading":"",r?"has-more-menu":"",t),draggable:d,"data-id":s,children:[k("div",{class:"dashboard-block-header",children:[k("div",{class:"dashboard-block-title",children:o}),r?k("div",{class:"dashboard-block-actions toolbar",children:k("button",{class:"toolbar-item dashboard-block-action btn square ghost rounded size-sm","data-type":"more",onClick:r,children:k("div",{class:"more-vert"})})}):null]}),v.isPlainObject(c)&&c.html?k(An,{className:"dashboard-block-body",executeScript:!0,...c}):k("div",{class:"dashboard-block-body",children:c})]})})}const iN="",rN="",Wu=([i,e,t,n],[s,r,o,a])=>!(i+t<=s||s+o<=i||e+n<=r||r+a<=e),g_=(i,e)=>i[1]===e[1]?i[0]-e[0]:i[1]-e[1],rc="Dashboard:Block.cache:";let y_=class extends re{constructor(e){super(e),this._ref=pe(),this._loadTimer=0,this._map=new Map,this._oldMap=new Map,this.tryLoadNext=()=>{clearTimeout(this._loadTimer),this._loadTimer=window.setTimeout(()=>this.loadNext(),50)},this._checkLayout=()=>{const{onLayoutChange:t}=this.props;if(!t)return;const{blocks:n}=this.state,s={};let r=!1;n.forEach(o=>{const[a,l,c,h]=this._map.get(o.id),d=this._oldMap.get(o.id);(!d||d[0]!==a||d[1]!==l||d[2]!==c||d[3]!==h)&&(r=!0,s[o.id]={left:a,top:l,width:c,height:h},this._oldMap.set(o.id,[a,l,c,h]))}),r&&t(s)},this._handleMenuClick=t=>{const n=t.target.closest(".dashboard-block");if(!n)return;const s=n.dataset.id;if(!s)return;const r=this.getBlock(s);if(!r||!r.menu)return;const{menu:o}=r,{onClickMenu:a}=this.props;nr.show({triggerEvent:t,element:t.currentTarget,placement:"bottom-end",menu:{onClickItem:l=>{var c;((c=l.item.data)==null?void 0:c.type)==="refresh"&&this.load(s),a&&a.call(this,l,r)},...o}})},this.state={blocks:this._initBlocks(e.blocks)}}getBlock(e){return this.state.blocks.find(t=>t.id===e)}update(e,t){const{id:n}=e,{blocks:s}=this.state,r=s.findIndex(a=>a.id===n);if(r<0)return;const o=s[r];e.fetch&&e.fetch!==o.fetch&&e.needLoad===void 0&&(e.needLoad=!0),s[r]={...o,...e},this.setState({blocks:s},t)}delete(e){const{blocks:t}=this.state,n=t.findIndex(s=>s.id===e);n<0||(t.splice(n,1),this.setState({blocks:t}))}add(e){e=Array.isArray(e)?e:[e],this.setState({blocks:[...this.state.blocks,...this._initBlocks(e)]})}load(e,t){const n=this.getBlock(e);!n||n.loading||(t=t||n.fetch,t&&this.update({id:e,loading:!0,needLoad:!1},async()=>{try{const s=await v.fetch(t,[e,n],({url:r})=>({url:De(r,n),dataType:"html"}));this.update({id:e,loading:!1,content:{html:s}},()=>{var r;this._setCache(e,s),(r=this.props.onLoad)==null||r.call(this,n)})}catch(s){const r=k("div",{class:"panel center text-danger p-5",children:["Error:",s.message]});this.update({id:e,loading:!1,content:r},()=>{var o;(o=this.props.onLoadFail)==null||o.call(this,s,n)})}}))}reset(e){this.setState({blocks:this._initBlocks(e)})}loadNext(){const{blocks:e}=this.state;let t="";for(const n of e){if(n.loading)return;if(!n.visible&&this._isVisible(n.id))return this.update({id:n.id,visible:!0});if(n.needLoad&&n.visible){t=n.id;break}}t.length&&requestAnimationFrame(()=>this.load(t))}_isVisible(e){return!this.props.onlyLoadVisible||!!v(this._ref.current).find(`.dashboard-block[data-id="${e}"]`).isVisible()}_setCache(e,t){const{cache:n}=this.props;if(n)try{typeof n=="string"?nt.set(`${rc}${n}:${e}`,t):nt.session.set(`${rc}${e}`,t)}catch(s){console.warn("ZUI: Failed to cache block content.",{id:e,html:t,error:s})}}_getCache(e){const{cache:t}=this.props;if(!t)return;const n=typeof t=="string"?nt.get(`${rc}${t}:${e}`):nt.session.get(`${rc}${e}`);if(n)return{html:n}}_initBlocks(e){const{blockFetch:t,blockMenu:n,grid:s}=this.props;return e.map(o=>{const{id:a,size:l,width:c,height:h,left:d=-1,top:f=-1,fetch:p=t,menu:y=n,content:b,...w}=o,[x,T]=this._getBlockSize(c&&h?{width:c,height:h}:l);return{id:`${a}`,width:x,height:T,left:Math.min(d,s-x),top:f,fetch:p,menu:y,content:b??this._getCache(`${a}`),loading:!1,needLoad:!!p,...w}})}_getBlockSize(e){const{blockDefaultSize:t,blockSizeMap:n}=this.props;return e=e??t,typeof e=="string"&&(e=n[e]),e=e||t,Array.isArray(e)||(e=[e.width,e.height]),e}_layout(){const{blocks:e,dragging:t,dropping:n}=this.state,s=this._map;if(s.size){const a=[0,0,0,0];e.sort((l,c)=>g_(s.get(l.id)||a,s.get(c.id)||a))}s.clear(),t&&n&&s.set(t,n),e.forEach(a=>{a.id!==t&&this._layoutBlock(a)});const r=Array.from(s.entries());r.sort((a,l)=>g_(a[1],l[1]));let o=0;return r.forEach(([a,l])=>{let c=l[1]-1;for(;c>=0&&this._canMove([l[0],c,l[2],l[3]],a);)c--;c++,l[1]=c,o=Math.max(o,c+l[3])}),n&&(o=Math.max(o,n[1]+n[3])),{blocks:e,height:o}}_initDraggable(){const e=this._ref.current;this._draggable=new Br(e,{selector:".dashboard-block",target:()=>e,beforeDrag:(t,n)=>{const s=n.getBoundingClientRect();if(t.clientY-s.top>48)return t.preventDefault(),!1;this._dragOffset=[t.clientX-s.left,t.clientY-s.top]},onDragStart:(t,n)=>{const s=n.dataset.id;s!==void 0&&(this._dragging=this._map.get(s),this.setState({dragging:s}))},onDragOver:t=>{const{cellHeight:n,grid:s}=this.props,r=e.getBoundingClientRect(),[,,o,a]=this._dragging,[l,c]=this._dragOffset,h=Math.min(s-o,Math.max(0,Math.round((t.clientX-r.left-l)/(r.width/s)))),d=Math.max(0,Math.round((t.clientY-r.top-c)/n)),f=this.state.dropping;f&&f[0]===h&&f[1]===d||this.setState({dropping:[h,d,o,a]})},onDragEnd:()=>{const{dragging:t,dropping:n}=this.state,s={dragging:void 0,dropping:void 0},r={};if(t&&n){const{blocks:o}=this.state;o.forEach((a,l)=>{const[c,h]=t===a.id?n:this._map.get(a.id);(a.left!==c||a.top!==h)&&(o[l]={...a,left:c,top:h},r[a.id]={left:c,top:h})}),s.blocks=o}this.setState(s,this._checkLayout),this._dragging=void 0,this._dragOffset=void 0}})}_layoutBlock(e){const{id:t,left:n,top:s,width:r,height:o}=e,a=[n,s,r,o];n<0||s<0?this._appendBlock(t,a):this._insertBlock(t,a)}_canMove(e,t){const{dropping:n}=this.state;if(n&&Wu(e,n))return!1;for(const[s,r]of this._map.entries())if(s!==t&&Wu(r,e))return!1;return!0}_canPlace(e){const{dragging:t}=this.state;return this._canMove(e,t)}_insertBlock(e,t){const{dropping:n}=this.state;for(n&&Wu(t,n)&&(t[1]=n[1]+n[3]);!this._canPlace(t);)t[1]=t[1]+1;this._map.set(e,t)}_appendBlock(e,t){const[n,s,r,o]=t;let a=s;if(n>=0&&s>=0){if(this._canPlace(t)){this._map.set(e,[n,s,r,o]);return}a=-1}let l=n<0?0:n,c=a<0?0:a,h=!1;const d=this.props.grid;for(;!h;){if(this._canPlace([l,c,r,o])){h=!0;break}n<0?(l+=1,l+r>d&&(l=0,c+=1)):c+=1}this._map.set(e,[l,c,r,o])}componentDidMount(){this.loadNext(),v(window).on("scroll",this.tryLoadNext),this._initDraggable();for(const[e,t]of this._map.entries())this._oldMap.set(e,[...t])}componentDidUpdate(e){e.blocks!==this.props.blocks?this.setState({blocks:this._initBlocks(this.props.blocks)}):this.loadNext()}componentWillUnmount(){var e;clearTimeout(this._loadTimer),v(window).off("scroll",this.tryLoadNext),(e=this._draggable)==null||e.destroy()}render(){const{blocks:e,height:t}=this._layout(),{cellHeight:n,grid:s,emptyBlockContent:r}=this.props,{dropping:o,dragging:a}=this.state,l=this._map;return k("div",{class:"dashboard",children:k("div",{class:"dashboard-blocks",style:{height:t*n},ref:this._ref,children:[o?k("div",{className:"dashboard-drop-shadow",style:{left:`${100*o[0]/s}%`,top:n*o[1],width:`${100*o[2]/s}%`,height:n*o[3]}},"dropping"):null,e.map((c,h)=>{const{id:d,menu:f,content:p,title:y}=c,[b,w,x,T]=d===a&&o?o:l.get(d)||[0,0,c.width,c.height];return k(oT,{id:d,index:h,left:`${100*b/s}%`,top:n*w,width:`${100*x/s}%`,height:n*T,content:p??r,title:y,className:U(c.needLoad?"need-load":"",p?"has-content":""),onMenuBtnClick:f?this._handleMenuClick:void 0},c.id)})]})})}};y_.defaultProps={responsive:!1,cache:!0,blocks:[],grid:3,gap:16,cellHeight:64,blockDefaultSize:[1,3],blockMenu:{items:[{text:"Refresh",data:{type:"refresh"}}]},onlyLoadVisible:!0,blockSizeMap:{xs:[1,3],sm:[1,4],md:[1,5],lg:[1,6],xl:[1,8],xsWide:[2,3],smWide:[2,4],mdWide:[2,5],lgWide:[2,6],xlWide:[2,8],xsLong:[3,3],smLong:[3,4],mdLong:[3,5],lgLong:[3,6],xlLong:[3,8]}};class Ku extends ve{}Ku.NAME="Dashboard",Ku.Component=y_;function qu(i,e,t,n){if(typeof i=="function"&&(i=i.call(this,e)),typeof i=="string"&&i.length&&(i={url:i}),!i)return Array.isArray(t)?k(ps,{children:t}):t;const{url:s,...r}=i,{setting:o}=e.col,a={};return o&&Object.keys(o).forEach(l=>{l.startsWith("data-")&&(a[l]=o[l])}),k("a",{href:De(s,e.row.data),...n,...r,...a,children:t})}function Gu(i,e,t){if(i==null)return;const n=e.row.data;return t=t??(n==null?void 0:n[e.col.name]),typeof i=="function"?i.call(this,t,e):De(i,{...n,0:t})}function v_(i,e,t,n){var s;return t?(t=t??((s=e.row.data)==null?void 0:s[e.col.name]),t==="0000-00-00 00:00:00"||t==="0000-00-00"?n??"":i===!1?t:(i===!0&&(i="[yyyy-]MM-dd hh:mm"),typeof i=="function"&&(i=i.call(this,t,e)),Ze(t,i,n??t))):n??t}function __(i,e){const{link:t}=e.col.setting,n=qu.call(this,t,e,i[0]);return n&&(i[0]=n),i}function b_(i,e){const{format:t,digits:n}=e.col.setting;let s=i[0];return typeof n=="number"&&!Number.isNaN(Number(s))&&(s=Number(s),n>=0&&(s=s.toFixed(n))),t&&(s=Gu.call(this,t,e,s)),i[0]=s,i}function w_(i,e){const{map:t,mapSplitter:n=",",mapJoiner:s}=e.col.setting;if(t){let r=i[0];typeof r=="string"&&n&&(r=r.split(n)),typeof t=="function"?i[0]=t.call(this,r,e):typeof t=="object"&&(Array.isArray(r)||(r=[r]),i[0]=r.map(o=>t[o]??o).join(s??n))}return i}function C_(i,e,t){const n={};return typeof i=="function"?Object.assign(n,i.call(this,t)):Object.keys(i).forEach(s=>{var o;const r=(o=t.row.data)==null?void 0:o[i[s]];r!==void 0&&(n[s]=r)}),Object.keys(n).length&&e.push({style:n}),e}function x_(i,e,t="[yyyy-]MM-dd hh:mm"){const{formatDate:n=t,invalidDate:s}=e.col.setting;return i[0]=v_.call(this,n,e,i[0],s),i}function Zu(i,e,t=!1){const{html:n=t}=e.col.setting;if(n===!1)return i;const s=i[0],r=n===!0?s:Gu.call(this,n,e,s);return i[0]={html:r},i}const aT=et({name:"rich",colTypes:{html:{onRenderCell(i,e){return Zu.call(this,i,e,!0)}},progress:{align:"center",onRenderCell(i,{col:e}){const{progressType:t,barColor:n,barBgColor:s,barHeight:r=6,barWidth:o=64,circleSize:a=24,circleBorderSize:l=1,circleBgColor:c="var(--color-border)",circleColor:h="var(--color-success-500)"}=e.setting,d=i[0];return i[0]=t==="bar"?k(ka,{className:"rounded-full",width:o,height:r,color:n||h,background:s,percent:d}):k(Sa,{percent:d,size:a,circleWidth:l,circleBg:c,circleColor:h,text:!0}),i}},datetime:{formatDate:"[yyyy-]MM-dd hh:mm"},date:{formatDate:"yyyy-MM-dd"},time:{formatDate:"hh:mm"}},onRenderCell(i,e){const{formatDate:t,html:n,hint:s,styleMap:r}=e.col.setting;if(t&&(i=x_.call(this,i,e,t)),i=w_.call(this,i,e),i=b_.call(this,i,e),n?i=Zu.call(this,i,e):i=__.call(this,i,e),s){let o=e.value;typeof s=="function"?o=s.call(this,e):typeof s=="string"?o=De(s,e.row.data):typeof i[0]=="string"&&(o=i[0]),i.push({attrs:{title:o}})}return r&&(i=C_.call(this,r,i,e)),i}},{buildIn:!0}),lT={default:(i,e,t)=>{var r,o;const n=(r=i.data)==null?void 0:r[t.name],s=(o=e.data)==null?void 0:o[t.name];return n===s?0:n==null?1:String(n).localeCompare(String(s))},date:(i,e,t)=>{var r,o;const n=Ye(((r=i.data)==null?void 0:r[t.name])??0),s=Ye(((o=e.data)==null?void 0:o[t.name])??0);return n.getTime()-s.getTime()},number:(i,e,t)=>{var r,o;const n=(r=i.data)==null?void 0:r[t.name],s=(o=e.data)==null?void 0:o[t.name];return Number.parseFloat(n)-Number.parseFloat(s)}},cT=et({name:"sort",defaultOptions:{sort:!1},when:i=>!!i.sort,onCreate(){const{sortBy:i}=this.options;i&&(this.state.sortBy=Array.isArray(i)?i:[i])},onAddRows(i,e){const{sortBy:t}=this.state;if(!t||!t.length)return;const{sort:n}=this.options,s={...lT,...typeof n=="function"?{default:n}:typeof n=="object"?n:{}};return[...i].sort((r,o)=>{for(const{name:a,order:l}of t){const c=e.map[a];if(!c)continue;let h=c.setting.sort;if(h===!0?h=s.default:typeof h=="string"&&(h=s[h]),!h)continue;const d=h.call(this,r,o,c);if(d)return l==="asc"?d:-d}return 0})},onHeaderCellClick(i,e){if(!i.target.closest(".dtable-sort-link"))return;const t=this.getColInfo(e.colName);if(!t||!t.setting.sort)return;const{sortBy:n=[]}=this.state,s=n.findIndex(a=>a.name===t.name),{multiSort:r}=this.options;let o="asc";if(s>=0){const a=n[s].order;a==="asc"?o="desc":a==="desc"&&(o="none"),r&&n.splice(s,1)}r||(n.length=0),this.update({dirtyType:"layout",state:{sortBy:[{name:e.colName,order:o},...n].filter(a=>a.order!=="none")}})},onRenderHeaderCell(i,e){var l;const{col:t}=e,{sortBy:n}=this.state;if(!t.setting.sort)return i;const o=((l=n==null?void 0:n.find(c=>c.name===t.name))==null?void 0:l.order)||"none",a=k("div",{className:`dtable-sort dtable-sort-${o}`});return i[0]=k("a",{className:"dtable-sort-link",href:"javascript:;",children:[i[0],a]}),i.push({outer:!0,attrs:{"data-sort":o}}),i}},{buildIn:!0}),hT={html:{component:An}},k_=et({name:"custom",onRenderCell(i,e){const{col:t}=e;let{custom:n}=t.setting;if(typeof n=="function"&&(n=n.call(this,e)),!n)return i;const s=Array.isArray(n)?n:[n],{customMap:r}=this.options;return s.forEach(o=>{let a;typeof o=="string"?a=o.startsWith("<")?{component:An,props:{html:De(o,{value:e.value,...e.row.data,$value:e.value})}}:{component:o}:a=o;let{component:l}=a;const c=[a];typeof l=="string"&&c.unshift(hT[l],r==null?void 0:r[l]);const h={};c.forEach(f=>{if(f){const{props:p}=f;p&&v.extend(h,typeof p=="function"?p.call(this,e):p),l=f.component||l}},{props:{}});const d=l;i[0]={outer:!0,className:"dtable-custom-cell",children:k(d,{...h})}}),i}}),cN="";function dT(i,e){var a,l;typeof i=="boolean"&&(e=i,i=void 0);const t=this.state.checkedRows,n={},{canRowCheckable:s,allowCheckDisabled:r}=this.options,o=(c,h)=>{const d=s?s.call(this,c):!0;!d||!r&&d==="disabled"||!!t[c]===h||(h?t[c]=!0:delete t[c],n[c]=h)};if(i===void 0?(e===void 0&&(e=!S_.call(this)),(a=this.layout)==null||a.allRows.forEach(({id:c})=>{o(c,!!e)})):(Array.isArray(i)||(i=[i]),i.forEach(c=>{o(c,e??!t[c])})),Object.keys(n).length){const c=(l=this.options.beforeCheckRows)==null?void 0:l.call(this,i,n,t);c&&Object.keys(c).forEach(h=>{const d=s?s.call(this,h):!0;!d||!r&&d==="disabled"||(c[h]?t[h]=!0:delete t[h])}),this.setState({checkedRows:{...t}},()=>{var h;(h=this.options.onCheckChange)==null||h.call(this,n)})}return n}function uT(i){return this.state.checkedRows[i]??!1}function S_(){var s,r;const i=(s=this.layout)==null?void 0:s.allRows.length;if(!i)return!1;const e=this.getChecks().length,{canRowCheckable:t,allowCheckDisabled:n}=this.options;return t?e===((r=this.layout)==null?void 0:r.allRows.reduce((o,a)=>{const l=t?t.call(this,a.id):!0;return o+(!l||!n&&l==="disabled"?0:1)},0)):e===i}function fT(){var e;const i=new Set((e=this.layout)==null?void 0:e.allRows.map(t=>t.id));return Object.keys(this.state.checkedRows).filter(t=>i.has(t))}function pT(i){const{checkable:e}=this.options;i===void 0&&(i=!e),e!==i&&this.setState({forceCheckable:i})}function T_(i,e,t=!1,n=void 0){return k(es,{className:"dtable-checkbox",checked:i,disabled:t,label:n})}const $_='input[type="checkbox"],.dtable-checkbox',mT=et({name:"checkable",defaultOptions:{checkable:"auto",checkboxRender:T_},when:i=>!!i.checkable,options(i){const{forceCheckable:e}=this.state;return e!==void 0?i.checkable=e:i.checkable==="auto"&&(i.checkable=!!i.cols.some(t=>t.checkbox)),i},state(){return{checkedRows:{}}},methods:{toggleCheckRows:dT,isRowChecked:uT,isAllRowChecked:S_,getChecks:fT,toggleCheckable:pT},i18n:{zh_cn:{checkedCountInfo:"已选择 {selected} 项",totalCountInfo:"共 {total} 项"},zh_tw:{checkedCountInfo:"已選擇 {selected} 項",totalCountInfo:"共 {total} 項"},en:{checkedCountInfo:"Selected {selected} items",totalCountInfo:"Total {total} items"}},footer:{checkbox(){const i=this.isAllRowChecked();return[k("div",{style:{paddingRight:"calc(3*var(--space))",display:"flex",alignItems:"center"},onClick:()=>this.toggleCheckRows(),children:T_(i,void 0,!1,this.options.checkboxLabel)})]},checkedInfo(i,e){const t=this.getChecks(),{checkInfo:n}=this.options;if(n)return[k(de,{className:"dtable-check-info",content:n.call(this,t)})];const s=t.length,r=[];return s&&r.push(this.i18n("checkedCountInfo",{selected:s})),r.push(this.i18n("totalCountInfo",{total:e.allRows.length})),[k("div",{className:"dtable-check-info",children:r.join(", ")})]}},onCreate(){const{checkedRows:i}=this.options;i&&this.setState(e=>({checkedRows:{...e.checkedRows,...i.reduce((t,n)=>(t[n]=!0,t),{})}}))},onRenderCell(i,{row:e,col:t}){var c;const{id:n}=e,{canRowCheckable:s}=this.options,r=s?s.call(this,n):!0;if(!r)return i;const{checkbox:o}=t.setting,a=typeof o=="function"?o.call(this,n):o,l=this.isRowChecked(n);if(a){const h=(c=this.options.checkboxRender)==null?void 0:c.call(this,l,n,r==="disabled");i.push(h,{outer:!0,className:"has-checkbox"})}return l&&i.push({outer:!0,className:"is-checked"}),i},onRenderHeaderCell(i,{row:e,col:t}){var o;const{id:n}=e,{checkbox:s}=t.setting;if(typeof s=="function"?s.call(this,n):s){const a=this.isAllRowChecked(),l=(o=this.options.checkboxRender)==null?void 0:o.call(this,a,n);i.push(l,{outer:!0,className:"has-checkbox"})}return i},onHeaderCellClick(i){if(this.data.disableCheckable)return;const e=i.target;if(!e)return;const t=e.closest($_);t&&this.toggleCheckRows(t.checked)},onCellClick(i,{rowID:e}){if(this.data.disableCheckable)return;const t=v(i.target);if(!t.length||t.closest("btn,a,button.not-checkable,.form-control,.btn").length)return;(t.closest($_).not(".disabled").length||this.options.checkOnClickRow)&&this.toggleCheckRows(e)}}),D_=et({name:"store",defaultOptions:{store:!0},when:i=>!!i.store,data(){return{store:new Lr(`DTable:${this.id}`)}}}),uN="",fN="";var I_=(i=>(i.unknown="",i.collapsed="collapsed",i.expanded="expanded",i.hidden="hidden",i.normal="normal",i))(I_||{});function oc(i){const e=this.data.nestedMap.get(i);if(!e||e.state!=="")return e??{state:"normal",level:-1};if(!e.parent&&!e.children)return e.state="normal",e;const t=e.children&&this.state.nestedState[i];let n=!1,{parent:s}=e;for(;s;){const r=oc.call(this,s);if(r.state!=="expanded"){n=!0;break}s=r.parent}return e.state=n?"hidden":t?"collapsed":e.children?"expanded":"normal",e.level=e.parent?oc.call(this,e.parent).level+1:0,e}function gT(i){return i!==void 0?oc.call(this,i):this.data.nestedMap}function yT(i,e){let{nestedState:t}=this.state;const{nestedMap:n}=this.data;if(i==="HEADER")if(e===void 0&&(e=!M_.call(this)),e){const s=n.entries();for(const[r,o]of s)o.state==="expanded"&&(t[r]=!0)}else t={};else{const s=Array.isArray(i)?i:[i];e===void 0&&(e=!t[s[0]]),s.forEach(r=>{const o=n.get(r);e&&(o!=null&&o.children)?t[r]=!0:delete t[r]})}this.update({dirtyType:"layout",state:{nestedState:{...t}}},()=>{const{onNestedChange:s,preserveNested:r}=this.options;s==null||s.call(this),r&&this.data.store.set("nestedState",t)})}function M_(){const i=this.data.nestedMap.values();for(const e of i)if(e.state==="expanded")return!1;return!0}function N_(i,e=1,t,n=0){var s;t||(t=[...i.keys()]);for(const r of t){const o=i.get(r);o&&(o.level===n&&(o.order=e++),(s=o.children)!=null&&s.length&&(e=N_(i,e,o.children,n+1)))}return e}function E_(i,e,t,n){const s=i.getNestedRowInfo(e);return!s||s.state===""||!s.children||s.children.forEach(r=>{n[r]=t,E_(i,r,t,n)}),s}function A_(i,e,t,n,s){var a;const r=i.getNestedRowInfo(e);if(!r||r.state==="")return;((a=r.children)==null?void 0:a.every(l=>{const c=!!(n[l]!==void 0?n[l]:s[l]);return t===c}))&&(n[e]=t),r.parent&&A_(i,r.parent,t,n,s)}const ac="dtable-nested-toggle",vT=et({name:"nested",plugins:[D_],requireAfter:["sortable"],defaultOptions:{nested:"auto",nestedParentKey:"parent",asParentKey:"asParent",nestedIndent:20,canSortTo(i,e){const{nestedMap:t}=this.data,n=t.get(i.id),s=t.get(e.id);return(n==null?void 0:n.parent)===(s==null?void 0:s.parent)},beforeCheckRows(i,e,t){if(!this.options.checkable||!(i!=null&&i.length)||this.options.noNestedCheck)return;const n={};return Object.entries(e).forEach(([s,r])=>{const o=E_(this,s,r,n);o!=null&&o.parent&&A_(this,o.parent,r,n,t)}),n}},options(i){return i.nested==="auto"&&(i.nested=!!i.cols.some(e=>e.nestedToggle)),i},when:i=>!!i.nested,data(){return{nestedMap:new Map,nestedRowMap:new Map}},state(){return{nestedState:{}}},methods:{getNestedInfo:gT,toggleRow:yT,isAllCollapsed:M_,getNestedRowInfo:oc},onCreate(){let{defaultNestedState:i}=this.options;if(this.options.preserveNested){const e=this.data.store.get("nestedState");e&&(i=e)}if(i===!0){const{data:e,rowKey:t="id"}=this.options;Array.isArray(e)&&(i=e.reduce((n,s)=>(n[typeof s=="string"?s:s[t]]=!0,n),{}))}this.state.nestedState=i||{}},onMounted(){this.options.defaultNestedState===!0&&!this.options.preserveNested&&this.toggleRow("HEADER",!0)},beforeLayout(){this.data.nestedMap.clear(),this.data.nestedRowMap.clear()},onAddRow(i){this.data.nestedRowMap.set(i.id,i)},onAddRows(i){const{nestedMap:e,nestedRowMap:t}=this.data;i.forEach(r=>{var c,h;const o=e.get(r.id)??{state:"",level:0};let a=((c=r.data)==null?void 0:c[this.options.nestedParentKey??"parent"])??[];Array.isArray(a)||(a=[a]);let l;for(a=[...a];a.length;){let d=a.pop();if(d===void 0)continue;if(d=String(d),t.get(d)){l=d;break}}if(o.parent=l==="0"?void 0:l,(h=r.data)!=null&&h[this.options.asParentKey??"asParent"]&&(o.children=[]),e.set(r.id,o),l){let d=e.get(l);d||(d={state:"",level:0},e.set(l,d)),d.children||(d.children=[]),d.children.push(r.id)}});const n=new Map,s=i.length*100;return i=i.filter(r=>{const o=this.getNestedRowInfo(r.id);return n.set(r.id,o),o.state!=="hidden"}),N_(n),i.sort((r,o)=>{const a=n.get(r.id),l=n.get(o.id);return((a==null?void 0:a.order)??s+r.index)-((l==null?void 0:l.order)??s+o.index)}),i},onRenderCell(i,e){var c;const{row:t,col:n}=e,{id:s,data:r}=t,{nestedToggle:o,childLabel:a}=n.setting,l=this.getNestedRowInfo(s);if(a){const h=Number(r[this.options.nestedParentKey||"parent"]);if(!Number.isNaN(h)&&h>0){let d;typeof a=="string"?d=k("span",{className:"dtable-child-label label rounded-full size-sm gray-pale",children:De(a,r)}):d=k(de,{className:"dtable-child-label",content:a,generatorThis:e}),i.unshift(d)}}if(o&&(l.children||l.parent)&&i.push(((c=this.options.onRenderNestedToggle)==null?void 0:c.call(this,l,s,n,r))??k("a",{className:`${ac} state${l.children?"":" is-no-child"}`,children:k("span",{className:"toggle-icon"})}),{outer:!0,className:`is-${l.state}`}),l.level){let{nestedIndent:h=o}=n.setting;h&&(h===!0&&(h=this.options.nestedIndent??12),i.push(k("div",{className:"dtable-nested-indent",style:{width:h*l.level+"px"}})))}return i},onRenderHeaderCell(i,{row:e,col:t}){var s;const{id:n}=e;return t.setting.nestedToggle&&i.push(((s=this.options.onRenderNestedToggle)==null?void 0:s.call(this,void 0,n,t,void 0))??k("a",{className:`${ac} state`,children:k("span",{className:"toggle-icon"})}),{outer:!0,className:`is-${this.isAllCollapsed()?"collapsed":"expanded"}`}),i},onHeaderCellClick(i){const e=i.target;if(!(!e||!e.closest(`.${ac}`)))return this.toggleRow("HEADER"),!0},onCellClick(i,{rowID:e}){const t=i.target;if(!(!t||!this.getNestedRowInfo(e).children||!t.closest(`.${ac}`)))return this.toggleRow(e),!0}});function Yu(i,{row:e,col:t}){const{data:n}=e,s=n?n[t.name]:void 0;if(!(s!=null&&s.length))return i;const{avatarClass:r="rounded-full",avatarKey:o=`${t.name}Avatar`,avatarCodeKey:a,avatarNameKey:l=`${t.name}Name`}=t.setting;let{avatarProps:c={}}=t.setting;typeof c=="function"&&(c=c(t,e));const h=(n?n[l]:s)||i[0],d={size:"xs",src:n?n[o]:void 0,text:h,code:a?n?n[a]:void 0:s,...c,className:U(r,c.className,"flex-none")};if(i[0]=k(ts,{...d}),t.type==="avatarBtn"){const{avatarBtnProps:f}=t.setting,p=typeof f=="function"?f(t,e):f;i[0]=k("button",{type:"button",className:"btn btn-avatar",...p,children:[i[0],k("div",{children:h})]})}else t.type==="avatarName"&&(i[0]=k("div",{className:"flex items-center gap-1",children:[i[0],k("span",{children:h})]}));return i}const _T=et({name:"avatar",colTypes:{avatar:{onRenderCell:Yu},avatarBtn:{onRenderCell:Yu},avatarName:{onRenderCell:Yu}}},{buildIn:!0}),bT=et({name:"sort-type",defaultOptions:{sortType:!0},when:i=>!!i.sortType&&!i.sort,onRenderHeaderCell(i,e){const{col:t}=e,{setting:n}=t;let{sortType:s}=n;if(t.setting.sort!==void 0||s===!1)return i;const{sortLink:r,orderBy:o}=this.options;if(o&&o[t.name]!==void 0&&(s=o[t.name]),s){const a=s===!0?"none":s,l=k("div",{className:`dtable-sort dtable-sort-${a}`});i.push({outer:!0,attrs:{"data-sort":a}});let{sortLink:c=r}=n;if(c){const h=a==="asc"?"desc":"asc";typeof c=="function"&&(c=c.call(this,t,h,a)),typeof c=="string"&&(c={url:c});const{url:d,...f}=c;i[0]=k("a",{className:"dtable-sort-link",href:De(d,{...n,sortType:h}),...f,children:[typeof i[0]!="object"||I.isValidElement(i[0])?i[0]:t.name,l]})}else i.push(l)}return i}},{buildIn:!0}),Ju=i=>{i.length!==1&&i.forEach((e,t)=>{!t||e.border!==void 0||e.setting.group===i[t-1].setting.group||(e.border="left")})},wT=et({name:"group",defaultOptions:{groupDivider:!0},when:i=>!!i.groupDivider,onLayout(i){if(!this.options.groupDivider)return;const{cols:e}=i;Ju(e.left.list),Ju(e.center.list),Ju(e.right.list)}}),vN="",CT=et({name:"header-group",defaultOptions:{headerGroup:!0},data(){return{headerGroups:new Map}},when:i=>!!i.headerGroup,beforeLayout(i){const{headerGroups:e}=this.data;e.clear();const{cols:t}=i;if(!(t!=null&&t.length))return;const n={};return t.forEach((s,r)=>{const{headerGroup:o}=s;if(!o){n[s.name]=r;return}let a=e.get(o);a?a.cols.push(s.name):(a={cols:[s.name],index:r},e.set(o,a)),n[s.name]=a.index+a.cols.length/t.length}),t.sort((s,r)=>n[s.name]-n[r.name]),{headerHeight:!i.headerHeight&&i.rowHeight?i.rowHeight*2:void 0,cols:t}},onRenderHeaderCell(i,{col:e}){const{headerGroup:t}=e.setting;if(t){const n=this.data.headerGroups.get(t),s=this.layout.headerHeight/2;if(e.name===n.cols[0]){const r=n.cols.reduce((a,l)=>{var c;return a+(((c=this.getColInfo(l))==null?void 0:c.realWidth)??0)},0),o={height:s-1,width:r-1};i.push(k("div",{class:"dtable-header-group",style:o,children:t}))}i.push({className:"dtable-header-as-group",style:{paddingTop:s}})}return i}}),xT=et({name:"cellspan",when:i=>!!i.getCellSpan,data(){return{cellSpanMap:new Map,overlayCellSet:new Set}},onLayout(i){const{getCellSpan:e}=this.options;if(!e)return;const{cellSpanMap:t,overlayCellSet:n}=this.data,{rows:s,cols:r,rowHeight:o}=i;t.clear(),n.clear();const a=(l,c,h)=>{const{index:d}=c;l.forEach((f,p)=>{const{index:y}=f,b=`C${y}R${d}`;if(n.has(b))return;const w=e.call(this,{row:c,col:f});if(!w)return;const x=Math.min(w.colSpan||1,l.length-p),T=Math.min(w.rowSpan||1,s.length-h);if(x<=1&&T<=1)return;let D=0;for(let N=0;N<x;N++){D+=l[p+N].realWidth;for(let A=0;A<T;A++){const z=`C${y+N}R${d+A}`;z!==b&&n.add(z)}}t.set(b,{colSpan:x,rowSpan:T,width:D,height:o*T})})};s.forEach((l,c)=>{["left","center","right"].forEach(h=>{a(r[h].list,l,c)})})},onRenderCell(i,{row:e,col:t}){const n=`C${t.index}R${e.index}`;if(this.data.overlayCellSet.has(n))i.push({outer:!0,style:{display:"none",className:"cellspan-overlayed-cell"}});else{const s=this.data.cellSpanMap.get(n);s&&i.push({outer:!0,style:{width:s.width,height:s.height}})}return i}}),mo=et({name:"mousemove",events:{click(i){this.data.ignoreNextClick&&(i.preventDefault(),this.data.ignoreNextClick=void 0)},mousedown(){this.data.ignoreNextClick&&clearTimeout(this.data.ignoreNextClick)},mousemove(i){this.data.mmRafID&&cancelAnimationFrame(this.data.mmRafID),this.data.mmRafID=requestAnimationFrame(()=>{this.emitCustomEvent("mousemovesmooth",i),this.data.mmRafID=0}),i.preventDefault()},document_mousemove(i){this.data.dmmRafID&&cancelAnimationFrame(this.data.dmmRafID),this.data.dmmRafID=requestAnimationFrame(()=>{this.emitCustomEvent("document_mousemovesmooth",i),this.data.mmRafID=0})}},methods:{ignoreNextClick(i=10){this.data.ignoreNextClick&&clearTimeout(this.data.ignoreNextClick),this.data.ignoreNextClick=window.setTimeout(()=>{this.data.ignoreNextClick=void 0},i)}}});function kT(){var D,N,A,z;const{scrollToMouse:i}=this.data;if(!i)return this.stopScrollToMouse();const{position:e,startTime:t,delay:n}=i;if(!e||Date.now()-t<n)return;const s=(N=(D=this.ref.current)==null?void 0:D.querySelector(".dtable-body"))==null?void 0:N.getBoundingClientRect();if(!s)return;const r=(z=(A=this.ref.current)==null?void 0:A.querySelector(".dtable-scroll-center"))==null?void 0:z.getBoundingClientRect(),{maxStep:o,detectPadding:a,speed:l,side:c}=i,{x:h,y:d}=e,{top:f,bottom:p}=s,{left:y,right:b}=r||s;let w=0;h<y-a?w=-Math.max(o,y-a-h):h>b-a&&(w=Math.max(o,h-(b-a)));let x=0;if(d<f-a?x=-Math.max(o,f-a-d):d>p-a&&(x=Math.max(o,d-(p-a))),c){const O=new Set((Array.isArray(c)?c:[c]).reduce((K,Z)=>(Z==="x"?K.push("left","right"):Z==="y"?K.push("top","bottom"):K.push(Z),K),[]));(!O.has("left")&&w<0||!O.has("right")&&w>0)&&(w=0),(!O.has("top")&&x<0||!O.has("bottom")&&x>0)&&(x=0)}const T={};w!==0&&(T.scrollLeft=this.layout.scrollLeft+l*w),x!==0&&(T.scrollTop=this.layout.scrollTop+l*x),this.scroll(T)}const Xu=et({name:"autoscroll",plugins:[mo],events:{document_mousemovesmooth(i){if(!this.data.scrollToMouse)return;const{clientX:e,clientY:t}=i;this.data.scrollToMouse.position={x:e,y:t}}},methods:{scrollTo({col:i,row:e,extra:t=2}){const n=this.getColInfo(i),s=this.getRowInfo(e);if(!n&&!s)return!1;const r={},{layout:o}=this;if(n){const{scrollLeft:a,cols:l}=o,c=n.left+n.realWidth;n.left<a?r.scrollLeft=n.left-t:c>l.center.width+a&&(r.scrollLeft=c-l.center.width+t)}if(s){const{scrollTop:a,rowHeight:l,rowsHeight:c}=o,h=s.top+l;s.top<a?r.scrollTop=s.top-t:h>c+a&&(r.scrollTop=h-c+t)}return this.scroll(r),!0},startScrollToMouse(i){const e={interval:60,speed:.5,delay:200,maxStep:this.options.rowHeight,onlyInside:!1,detectPadding:30,startTime:Date.now(),...i};this.data.scrollToMouse=e,clearInterval(this.data.scrollToTimer),this.data.scrollToTimer=window.setInterval(kT.bind(this),e.interval)},stopScrollToMouse(){clearInterval(this.data.scrollToTimer),this.data.scrollToMouse=void 0}},onUnmounted(){clearInterval(this.data.scrollToTimer)}}),xN="",ST=et({name:"sortable",defaultOptions:{sortable:!0},when:i=>!!i.sortable,plugins:[mo,Xu],resetState:!0,state(){return{rowOrders:void 0,sortingFrom:void 0,sortingPos:void 0,sortingTo:void 0,sortingSide:void 0}},events:{click(i){i.target.closest(".dtable-sort-link")&&(this.state.rowOrders=void 0)},mousedown(i){var a;if(this.data.disableSortable)return;const{sortHandler:e=".dtable-cell"}=this.options;if(!v(i.target).closest(e).length)return;const s=this.getPointerInfo(i);if(!s||s.rowID==="HEADER")return;const r=this.getRowInfo(s.rowID);if(!r||((a=this.options.onSortStart)==null?void 0:a.call(this,r,i))===!1)return;i.preventDefault();const o=i.clientY;this.data.sortableInfo={from:r,offset:o-s.cellElement.getBoundingClientRect().top,startMouseY:o,lastMouseY:o}},document_mouseup(i){var n;const{sortableInfo:e}=this.data;if(!e)return;this.stopScrollToMouse();const t=this.getSortingState(i);if(t){let s,r;const{sortingFrom:o,sortingTo:a,sortingSide:l}=t;if(a&&l){const c=this.layout.rows.map(p=>p.id),h=[...c],d=o.index,f=a.index;if(!(d===f+1&&l==="after")&&!(d===f-1&&l==="before")){const p=c.splice(d,1);c.splice(f,0,p[0]),s={},r=[],c.forEach((y,b)=>{s[y]=b,r.push(y)}),(h.join()===r.join()||((n=this.options.onSort)==null?void 0:n.call(this,o,a,l,r))===!1)&&(s=void 0,r=void 0)}}(a||Math.abs(e.lastMouseY-e.startMouseY)>4)&&this.ignoreNextClick(),this.disableAnimation(),this.update({dirtyType:"layout",state:c=>v.extend({sortingFrom:void 0,sortingPos:void 0,sortingTo:void 0,sortingSide:void 0},s?{rowOrders:{...c.rowOrders,...s}}:null)},()=>{var c;(c=this.options.onSortEnd)==null||c.call(this,o,a,l,r),setTimeout(()=>{this.data.disableCheckable=void 0},50)})}this.data.sortableInfo=void 0},document_mousemovesmooth(i){const{sortableInfo:e}=this.data;if(!e)return;const t=this.getSortingState(i);t&&(e.state||(this.startScrollToMouse({side:"y"}),this.data.disableCheckable=!0),e.lastMouseY=i.clientY,e.state=t,this.setState(t))}},methods:{getSortingState(i){var z;const{disableSortable:e,sortableInfo:t}=this.data;if(e||!t)return;const{headerHeight:n,footerHeight:s,visibleRows:r,scrollTop:o,rowHeight:a}=this.layout,l=this.element.getBoundingClientRect(),c=l.width,h=l.height-n-s,d=i.clientX-l.left,f=i.clientY-l.top-n;if(d<0||d>c||f<0||f>h)return t.state;const p=f+o,y=r.find(O=>O.top<=p&&O.top+a>p);if(!y)return t.state;const b=t.from,w=y.id!==b.id?y.id:void 0,x=w?this.getRowInfo(w):void 0,T=f,D=p<y.top+a/2?"before":"after";return x&&((z=this.options.canSortTo)==null?void 0:z.call(this,b,x,D))!==!1?{sortingFrom:b,sortingPos:T,sortingTo:x,sortingSide:D}:{sortingFrom:b,sortingPos:T,sortingTo:void 0,sortingSide:void 0}}},onAddRows(i){const{rowOrders:e}=this.state;if(!e)return;const t=i.length*100;return i=i.sort((n,s)=>{const r=e[n.id]??t+n.index,o=e[s.id]??t+s.index;return r-o}),i},beforeRender(i){const{sortingFrom:e}=this.state,{visibleRows:t}=i;e&&(t.some(n=>n.id===e.id)||(i.visibleRows=[...t,e]),i.className=U(i.className,"dtable-sorting"))},onRenderCell(i,e,t){const{sortingFrom:n,sortingPos:s,sortingTo:r,sortingSide:o}=this.state;if(!n)return i;const a=e.row,l={},c=[];if(n.id===a.id)l.top=s-this.data.sortableInfo.offset+((t.top??a.top)-(a.top-this.layout.scrollTop)),c.push("is-sorting-from");else if(r){const h=r.id===a.id;h&&c.push(`text-primary is-sorting-to is-sorting-to-${o}`),n.index>a.index&&(h&&o==="before"||a.index>r.index)?c.push("is-sorting-before"):n.index<a.index&&(h&&o==="after"||a.index<r.index)&&c.push("is-sorting-after")}return c.length&&i.push({outer:!0,style:l,className:c}),i}}),P_=et({name:"pager",state(){const i=this.props.localPager;if(i){const{page:e=1,recTotal:t=0,recPerPage:n=20,pageTotal:s=1}=this.props.footPager||{};return{pager:{page:e,recTotal:t,recPerPage:n,pageTotal:s,...typeof i=="object"?i:null}}}return{}},footer:{pager(){let{footPager:i}=this.options;const{localPager:e}=this.options;return i?(i={items:[{type:"link",page:"first",icon:"icon-first-page"},{type:"link",page:"prev",icon:"icon-angle-left"},{type:"info",text:"{page}/{pageTotal}"},{type:"link",page:"next",icon:"icon-angle-right"},{type:"link",page:"last",icon:"icon-last-page"}],...i},Array.isArray(i.items)&&i.items.forEach(t=>{t.type==="size-menu"&&t.caret===void 0&&(t.caret="up")}),this.options.localPager&&(Object.assign(i,{...typeof e=="object"?e:null,...this.state.pager,recTotal:this.layout.allRows.length,useState:!0}),i.onChangePageInfo=t=>{this.update({dirtyType:"layout",state:n=>({pager:{...n.pager,...t}})})}),[k(Xr,{...i})]):[]}},onAddRows(i){const{localPager:e}=this.options;if(e){const{page:t=1,recPerPage:n=20}={...typeof e=="object"?e:null,...this.state.pager},s=Math.max(0,Math.min(t,Math.ceil(i.length/n))),r=(s-1)*n,o=Math.min(s*n,i.length);return i.slice(r,o)}}}),TT=Object.freeze(Object.defineProperty({__proto__:null,NestedRowState:I_,avatar:_T,cellspan:xT,checkable:mT,custom:k_,group:wT,headerGroup:CT,nested:vT,pager:P_,renderDatetime:v_,renderDatetimeCell:x_,renderFormat:Gu,renderFormatCell:b_,renderHtmlCell:Zu,renderLink:qu,renderLinkCell:__,renderMapCell:w_,renderStyleMapCell:C_,rich:aT,sort:cT,sortType:bT,sortable:ST},Symbol.toStringTag,{value:"Module"}));class Is extends ve{get commandScope(){return this.options.commandScope||"dtable"}afterInit(){super.afterInit();const{commands:e,onCommand:t}=this.options;(e||t)&&Mi(this.element,{commands:e,scope:this.commandScope,onCommand:this.executeCommand.bind(this)})}executeCommand(e,t=[]){const{onCommand:n,commands:s}=this.options;let r;typeof e=="string"&&(e={name:e});const{scope:o,name:a}=e,l=s?s[`${o}~${a}`]||s[a]:null;if(l)return l.call(this,e,t);if(!e.scope||e.scope===this.commandScope){const{name:c}=e;r=nn(this.$,c,t)}return n&&(r=n.call(this,e,t)),r}setOptions(e,t){return e=super.setOptions(e,t),e.parent||(e.parent=this.element),e}}Is.NAME="DTable",Is.Component=ii,Is.definePlugin=et,Is.removePlugin=sv,Is.getPlugin=iv,Is.plugins=TT,Is.register(),st({DTable:ii});const TN="",$N="",DN="",IN="",MN="",NN="",EN="";class Qu extends Ve{_getClassName(e){return["kanban-header-col",e.className,e.subCols?"has-subs":"",e.parentName!==void 0?"is-sub":""]}_getProps(e){const{width:t,color:n,name:s,gapLeft:r,gapRight:o}=e;return Pe(super._getProps(e),{style:{"--kanban-col-color":n,"--kanban-col-width":Be(t),"--kanban-col-gap-left":Be(r),"--kanban-col-gap-right":Be(o)},"z-col":s})}_getChildren(e){const{prefix:t,prefixClass:n,title:s,titleClass:r,titleAlign:o="center",subtitle:a,subtitleClass:l,icon:c,trailingIcon:h,actions:d,subCols:f}=e;return[k("div",{className:`kanban-header-col-wrapper is-align-${o}`,children:[k("div",{className:"kanban-header-title",children:[c?k($e,{className:"as-leading-icon",icon:c},"icon"):null,t?k("span",{className:U("as-prefix",n),children:k(de,{content:t})},"prefix"):null,s?k("span",{className:U("as-title",r),title:typeof s=="string"?s:void 0,children:k(de,{content:s})},"title"):null,a?k("span",{className:U("as-subtitle",l),children:k(de,{content:a})},"subtitle"):null,h?k($e,{className:"as-trailing-icon",icon:h},"trailingIcon"):null]},"title"),Fe.render(d,[e],{key:"actions",className:"kanban-header-col-actions",size:"sm"},this)]},"wrapper"),f?k("div",{className:"kanban-header-sub-cols",children:f.map((p,y)=>k(Qu,{index:y,...p},p.name))},"subs"):null]}}class $T extends re{constructor(){super(...arguments),this._ref=pe()}componentDidMount(){this._ref.current&&(this._sticky=oa.ensure(this._ref.current,{scrollContainer:".kanban-list"}))}componentWillUnmount(){var e;(e=this._sticky)==null||e.destroy()}render(e){return k("div",{className:"kanban-header",ref:this._ref,children:[k("div",{className:"kanban-header-lane-name"},"name"),k("div",{className:"kanban-header-cols",children:e.cols.map((t,n)=>k(Qu,{index:n,...t},t.name))},"cols")]})}}class L_ extends re{constructor(){super(...arguments),this._listRef=pe(),this._renderItem=e=>{const{itemRender:t,lane:n,name:s}=this.props;return t.call(this,{item:e,lane:n,col:s})},this._handleScroll=e=>{const{current:t}=this._listRef;t&&v(t).trigger("laneColScroll",e)}}componentDidMount(){const{current:e}=this._listRef;e&&(this._ob=new ResizeObserver(t=>{v(this._listRef.current).trigger("laneColResize",t[0])}),this._ob.observe(e))}componentWillUnmount(){var e;(e=this._ob)==null||e.disconnect()}render(e){const{items:t}=e,{width:n,color:s,content:r,contentClass:o,itemRender:a,itemGap:l,watchSize:c,name:h,lane:d,itemCountPerRow:f,gapLeft:p,gapRight:y,laneColClass:b}=e,w={"--kanban-col-color":s,"--kanban-col-width":Be(n),"--kanban-col-gap-left":Be(p),"--kanban-col-gap-right":Be(y)};return k("div",{className:U("kanban-lane-col",b),style:w,"z-lane":d,"z-col":h,children:[r?k("div",{className:U("kanban-col-content",o),children:k(de,{content:r,generatorThis:this,generatorArgs:[e]})}):null,k("div",{className:"kanban-items scrollbar-thin scrollbar-hover",onScroll:this._handleScroll,children:k(tr,{forwardRef:c?this._listRef:void 0,itemProps:{className:"kanban-item card-list-item"},items:t,itemRender:a?this._renderItem:void 0,countPerRow:f,gap:l},"list")})]})}}L_.defaultProps={watchSize:!0};class DT extends Ve{_getClassName(e){const{className:t,index:n,maxHeight:s,height:r}=e;return["kanban-lane",t,{"is-first":!n,"is-auto-height":!s&&(!r||r==="auto")}]}_getProps(e){const{height:t,minHeight:n,maxHeight:s,color:r,name:o,gapTop:a,gapBottom:l}=e;return Pe(super._getProps(e),{style:{"--kanban-lane-color":r,height:Be(t),minHeight:Be(n),maxHeight:Be(s),"--kanban-col-gap-top":Be(a),"--kanban-col-gap-bottom":Be(l)},"z-lane":o})}_renderCol(e,t,n,s,r){if(r){const o=r(e,t);o&&(t={...t,...o})}return k(L_,{itemRender:n,lane:e.name,items:s[t.name],...t},t.name)}_getChildren(e){const{title:t,titleClass:n,actions:s,cols:r,items:o={},hideName:a,itemRender:l,getLaneCol:c}=e;return[a?null:k("div",{className:"kanban-lane-name",children:[Fe.render(s,[e],{key:"actions",className:"kanban-lane-actions",size:"sm"},this),k("div",{className:U("kanban-lane-title",n),title:typeof t=="string"?t:void 0,children:k(de,{content:t})},"title")]},"name"),k("div",{className:"kanban-lane-cols",children:r.reduce((h,d)=>(d.subCols?d.subCols.forEach(f=>{h.push(this._renderCol(e,f,l,o,c))}):h.push(this._renderCol(e,d,l,o,c)),h),[])},"cols")]}}function IT(i){const{lanes:e,cols:t,items:n={},itemRender:s,hideLaneName:r,getLaneCol:o}=i;return k("div",{className:"kanban-body",children:e.map((a,l)=>k(DT,{index:l,cols:t,items:n[a.name],hideName:r,itemRender:s,getLaneCol:o,...a},a.name))})}const Xt=12,MT={left:"right",right:"left",top:"bottom",bottom:"top","":""},Ms=({from:i,to:e,fromKanban:t,toKanban:n})=>`${t?`${t}_`:""}${i}-${n?`${n}_`:""}${e}`;function R_(i,e){return e==="top"?{x:i.x+i.width/2,y:i.y}:e==="left"?{x:i.x,y:i.y+i.height/2}:e==="right"?{x:i.x+i.width,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y+i.height}}function NT(i,e){return(i.x-e.x)*(i.x-e.x)+(i.y-e.y)*(i.y-e.y)}function ET(i,e,t,n){const s=t?[t]:["left","right","top","bottom"],r=n?[n]:["left","right","top","bottom"];let o=Number.MAX_SAFE_INTEGER,a={x:0,y:0},l={x:0,y:0};return s.forEach(c=>{r.forEach(h=>{const d=R_(i,c),f=R_(e,h),p=NT(d,f)*(MT[c]===h?1:2);p<o&&(o=p,t=c,n=h,a=d,l=f)})}),{fromSide:t,toSide:n,fromPos:a,toPos:l}}function AT(i,e){return{x:(i.x+e.x)/2,y:(i.y+e.y)/2}}function z_(i,e){return{x:Math.min(i.x,e.x),y:Math.min(i.y,e.y),width:Math.abs(i.x-e.x),height:Math.abs(i.y-e.y)}}function F_(i,e,t){const n={id:`marker-${e}-${t}-${i}`,orient:"auto",markerUnits:"strokeWidth",refX:e==="start"?0:6,refY:3,markerWidth:6,markerHeight:6,path:{d:"",fill:"currentColor"}};return i==="arrow"?e==="start"?n.path.d="M6,0 L6,6 L0,3 z":n.path.d="M0,0 L0,6 L6,3 z":i==="dot"?n.path.d="M3,3 m-3,0 a 3,3 0 1,1 6,0 a 3,3 0 1,1 -6,0":i==="square"?n.path.d="M0,0 L0,6 L6,6 L6,0 z":i==="diamond"&&(n.path.d="M3,0 L6,3 L3,6 L0,3 z"),n}function PT(i,e,t,n,s="curve",r=2,o=1){const{x:a,y:l,width:c,height:h}=z_(i,e),d=Xt-a,f=Xt-l;if(s==="curve"){const p=c*(1+Math.max(-.3,Math.min(.3,1-c/50)))*o,y=h*(1+Math.max(-.3,Math.min(.3,1-h/50)))*o,b=r*5,w={a1x:i.x+(t==="left"?-b:t==="right"?b:0),a1y:i.y+(t==="top"?-b:t==="bottom"?b:0),ax:i.x+(t==="left"?-p:t==="right"?p:0),ay:i.y+(t==="top"?-y:t==="bottom"?y:0),bx:e.x+(n==="left"?-(p-b):n==="right"?p-b:0),by:e.y+(n==="top"?-(y-b):n==="bottom"?y-b:0),b1x:e.x+(n==="left"?-b:n==="right"?b:0),b1y:e.y+(n==="top"?-b:n==="bottom"?b:0)};return`M ${i.x+d} ${i.y+f} L ${w.a1x+d} ${w.a1y+f} C ${w.ax+d} ${w.ay+f} ${w.bx+d} ${w.by+f} ${w.b1x+d} ${w.b1y+f} L ${e.x+d} ${e.y+f}`}if(s==="fold"){const p=AT(i,e),y=c/2,b=h/2,w={ax:i.x+(t==="left"?-y:t==="right"?y:0),ay:i.y+(t==="top"?-b:t==="bottom"?b:0),bx:e.x+(n==="left"?-y:n==="right"?y:0),by:e.y+(n==="top"?-b:n==="bottom"?b:0)};return`M ${i.x+d} ${i.y+f} L ${w.ax+d} ${w.ay+f} L ${p.x+d} ${p.y+f} L ${w.bx+d} ${w.by+f} L ${e.x+d} ${e.y+f}`}return`M ${i.x+d} ${i.y+f} L ${e.x+d} ${e.y+f}`}function LT(i){const{fromRect:e,toRect:t}=i,n=Ms(i),s={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},r={x:t.left,y:t.top,width:t.right-t.left,height:t.bottom-t.top},{fromSide:o,toSide:a,fromPos:l,toPos:c}=ET(s,r),h=z_(l,c),{x:d,y:f,width:p,height:y}=h;l.x+=Xt-d,l.y+=Xt-f,c.x+=Xt-d,c.y+=Xt-f;const{weight:b=1.5,fromPoint:w,toPoint:x="arrow"}=i,T={left:`${0-Xt}px`,top:`${0-Xt}px`,width:`${p+2*Xt}px`,height:`${y+2*Xt}px`},D={"stroke-width":b,fill:"transparent",stroke:"currentColor","stroke-linejoin":"round","marker-start":w&&w!=="none"?`url(#marker-start-${n}-${w})`:void 0,"marker-end":x&&x!=="none"?`url(#marker-end-${n}-${x})`:void 0,d:PT(l,c,o,a,i.shape,b)},N={"stroke-width":b+5,"stroke-linejoin":"round",fill:"transparent",stroke:"currentColor",d:D.d,class:"opacity-0"},A={width:p+2*Xt,height:y+2*Xt},z=[];return i.lineStyle==="dashed"?D["stroke-dasharray"]=`${b*3} ${b*3}`:i.lineStyle==="dotted"&&(D["stroke-dasharray"]=`${b} ${b}`),w&&w!=="none"&&z.push(F_(w,"start",n)),x&&x!=="none"&&z.push(F_(x,"end",n)),{x:d,y:f,width:p,height:y,fromSide:o,toSide:a,fromPos:l,toPos:c,nodeStyle:T,svgPathProps:D,svgPathBackProps:N,svgProps:A,markers:z,padding:Xt}}class O_ extends re{constructor(){super(...arguments),this.state={},this._handleMouseHover=e=>{this.setState({hover:e.type==="mouseenter"})},this._onDelete=()=>{var e;(e=this.props.onDelete)==null||e.call(this,this.props)}}render(e,t){const{text:n,textSize:s,color:r,onDelete:o,weight:a=1.5,from:l,to:c}=e,{hover:h}=t,{x:d,y:f,padding:p,width:y,height:b,svgProps:w,markers:x,svgPathProps:T,svgPathBackProps:D,fromPos:N}=LT(e);return k("div",{className:U("kanban-link",h?"is-hover":""),style:{left:d,top:f,width:y,height:b,color:r,"--kanban-link-weight":a},"z-from":l,"z-to":c,onMouseEnter:o?this._handleMouseHover:void 0,onMouseLeave:o?this._handleMouseHover:void 0,children:[k("svg",{...w,xmlns:"http://www.w3.org/2000/svg",version:"1.1",children:[x.length?k("defs",{children:x.map(({path:A,id:z,...O})=>k("marker",{...O,id:z,children:k("path",{...A})},z))}):null,k("path",{...D}),k("path",{...T})]}),k("div",{className:"kanban-link-start-point",style:{left:N.x-p,top:N.y-p}}),o?k("div",{className:"kanban-link-delete-btn",children:k("button",{type:"button",className:"btn rounded-full size-sm square primary",onClick:this._onDelete,children:k("i",{className:"close"})})}):null,n?k("div",{className:"kanban-link-text",style:{fontSize:`${s||12}px`},children:n}):null]})}}const go=".kanban";class RT extends re{constructor(){super(...arguments),this._ref=pe(),this.state={}}componentDidMount(){const e=this._ref.current,{container:t=".kanban"}=this.props,n=e.closest(t),s=v(n);this._container=n,this._multiKanban=s.find(".kanban").length>1;const r=".kanban-item,.kanban-link-editor-from";s.on(`mouseenter${go}`,r,o=>{if(this.state.dragPos)return;clearTimeout(this._leaveTimer);const a=v(o.target).closest(r),l=a.z("key");this.state.from===l||a.hasClass("is-dragging")||this.setState({from:l,fromKanban:this._multiKanban?a.closest(".kanban").z("key"):void 0,to:void 0,fromRect:this._getRect(a.children()[0]),dragPos:void 0})}).on(`mouseleave${go}`,r,()=>{this.state.dragPos||(clearTimeout(this._leaveTimer),this._leaveTimer=window.setTimeout(()=>{this._cancelHover(),this._leaveTimer=0},200))}).on(`dragstart${go}`,".kanban-item",()=>{this.state.dragPos||this._cancelHover()}).on(`laneColScroll${go}`,o=>{const{from:a}=this.state;a&&this.setState({fromRect:this._getRect(v(o.target).find(`.kanban-item[z-key="${a}"]`).children()[0])})}),this._moveable=new _s(e,{selector:".kanban-link-editor-point",move:"none",onMoveStart:()=>{if(!this.state.from)return!1;s.addClass("is-adding-link")},onMove:o=>{const{top:a,left:l}=n.getBoundingClientRect(),c={left:o.clientX-l+n.scrollLeft,top:o.clientY-a+n.scrollTop};let h,d,f;const p=v(o.target).closest(r);p.length&&h!==this.state.from&&(h=p.attr("z-key"),f=this._multiKanban?p.closest(".kanban").z("key"):void 0,d=this._getRect(p.children()[0])),this.setState({dragPos:c,to:h,toKanban:f,toRect:d})},onMoveEnd:()=>{const{from:o,fromKanban:a,to:l,toKanban:c}=this.state,{onAddLink:h}=this.props;(o!==l||a!==c)&&h&&o!==void 0&&l!==void 0&&(h==null||h.call(this,{from:o,fromKanban:a,to:l,toKanban:c})),this._cancelHover(),s.removeClass("is-adding-link")}})}componentWillUnmount(){var t;const e=(t=this._ref.current)==null?void 0:t.closest(".kanban");e&&v(e).off(go),this._raf&&cancelAnimationFrame(this._raf)}_getRect(e){const t=e.getBoundingClientRect(),n=this._container,{top:s,left:r}=n.getBoundingClientRect();return{left:t.left-r+n.scrollLeft,top:t.top-s+n.scrollTop,width:t.width,height:t.height}}_cancelHover(){this.setState({from:void 0,to:void 0,fromRect:void 0,dragPos:void 0})}_renderLink(e){const{fromRect:t,toRect:n,from:s,to:r="",dragPos:o}=e;if(!t||!s||!o)return null;const a=n?{left:n.left,top:n.top,right:n.left+n.width,bottom:n.top+n.height}:{left:o.left,top:o.top,right:o.left,bottom:o.top};return k(O_,{from:s,to:r,lineStyle:"dotted",color:"var(--color-primary-500)",fromRect:{left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height},toRect:a},"link")}render(e,t){const{from:n,fromRect:s,to:r,toRect:o}=t;let a,l;return n&&s&&(a=k("div",{className:"kanban-link-editor-from not-moveable","z-key":n,style:s,children:[k("div",{className:"kanban-link-editor-point is-left"}),k("div",{className:"kanban-link-editor-point is-top"}),k("div",{className:"kanban-link-editor-point is-right"}),k("div",{className:"kanban-link-editor-point is-bottom"})]})),r&&o&&(l=k("div",{className:"kanban-link-editor-to","z-key":r,style:o})),k("div",{className:U("kanban-link-editor"),ref:this._ref,children:[a,l,this._renderLink(t)]})}}const ef=".kanban";class B_ extends re{constructor(){super(...arguments),this._ref=pe(),this._watchSet=new Set,this.state={layout:{},scrollTop:0,scrollLeft:0}}componentDidMount(){var s;const{container:e=".kanban"}=this.props,t=(s=this._ref.current)==null?void 0:s.closest(e),n=v(t);this._multiKanban=n.find(".kanban").length>1,n.on(`laneColResize${ef} laneColScroll${ef}`,()=>{this._tryUpdateLayout()}),this._container=t,this._tryUpdateLayout()}componentWillUnmount(){const e=this._container;e&&v(e).off(ef),this._raf&&cancelAnimationFrame(this._raf)}componentDidUpdate(e){(e.links!==this.props.links||e.filters!==this.props.filters)&&this._tryUpdateLayout()}_tryUpdateLayout(){this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._updateLayout(),this._raf=0})}_updateLayout(){const e=[...this._watchSet],t=this._container,n=v(t),{top:s,left:r}=t.getBoundingClientRect(),o=t.scrollTop-s,a=t.scrollLeft-r,l={};e.forEach(c=>{const[h,d]=c.split("_"),f=n.find(`${this._multiKanban?`.kanban[z-key="${h}"] `:""}.kanban-item[z-key="${d}"]`).children()[0];if(f&&Mr(f,{container:".kanban-lane-col"})){const{top:p,left:y,bottom:b,right:w}=f.getBoundingClientRect();l[c]={top:p+o,left:y+a,bottom:b+o,right:w+a}}}),this.setState({layout:l})}_renderLink(e){const{layout:t}=this.state,{from:n,fromKanban:s="",to:r,toKanban:o=""}=e,a=`${s}_${n}`,l=`${o}_${r}`,c=t[a],h=t[l];return this._watchSet.add(a),this._watchSet.add(l),!c||!h?null:k(O_,{...e,fromRect:c,toRect:h,onDelete:this.props.onDeleteLink},`${n}-${r}`)}_renderLinks(e){const{links:t,filters:n}=e,s=new Set(n),r=o=>{const{from:a,to:l,fromKanban:c="",toKanban:h=""}=o;return this._multiKanban?s.has(`${c}_${a}`)||s.has(`${h}_${l}`)||s.has(c)||s.has(h)||s.has(Ms(o)):s.has(a)||s.has(l)||s.has(`${a}-${l}`)};return t.reduce((o,a)=>{if(!n||r(a)){const l=this._renderLink(a);l&&o.push(l)}return o},[])}_renderEditor(e){const{editLinks:t,onAddLink:n,container:s}=e;return t?k(RT,{container:s,onAddLink:n},"editor"):null}render(e){return this._watchSet.clear(),k("div",{className:"kanban-links",ref:this._ref,children:[this._renderLinks(e),this._renderEditor(e)]})}}function zT(i,e,t){if(!i||!i.length)return[];const{getCol:n,colProps:s,itemCountPerRow:r,itemGap:o}=e;let a=!1;const l=[],c=new Map;return i=i.reduce((h,d,f)=>{if(d=Pe({itemGap:o,itemCountPerRow:r},s,d),n){const p=n.call(this,d);p!==!1&&(d=p||d)}return d.deleted||(typeof d.order=="number"?a=!0:d.order=f,typeof d.name!="string"&&(d.name=String(d.name)),t==null||t.call(this,d),d.parentName!==void 0?(d.parentName=String(d.parentName),l.push(d)):(c.set(d.name,d),h.push(d))),h},[]),l.forEach(h=>{const d=c.get(h.parentName);d&&(d.subCols=cs(d.subCols,[h],"name"))}),a&&(i.sort(yo),[...c.values()].forEach(h=>{h.subCols&&h.subCols.sort(yo)})),i}function FT(i,e,t){if(!i||!i.length)return[];const{getLane:n,laneProps:s}=e;let r=!1;return i=i.reduce((o,a,l)=>{if(s&&(a=Pe({},s,a)),n){const c=n.call(this,a);c!==!1&&(a=c||a)}return a.deleted||(typeof a.order=="number"?r=!0:a.order=l,a.color===void 0&&(a.color=`hsl(${43*mh(a.name)%360}deg 40% 50%)`),typeof a.name!="string"&&(a.name=String(a.name)),t==null||t.call(this,a),o.push(a)),o},[]),r&&i.sort(yo),i}function j_(i,e,t,n,s){if(!(i!=null&&i.length))return[];const{itemProps:r,getItem:o}=n;let a=!1;return i=i.reduce((l,c)=>{r&&(c=Pe({},r,c));const h=(o==null?void 0:o.call(this,{col:t.name,lane:e.name,item:c,laneInfo:e,colInfo:t}))??c;return h!==!1&&!h.deleted&&(typeof h.order=="number"?a=!0:h.order=l.length-1,l.push(h),s==null||s.call(this,h)),l},[]),a&&i.sort(yo),i}function yo(i,e){return i.order-e.order}function cs(i,e,t="key"){if(!i)return e?[...e]:[];const n=[...i];if(e){let s=0;const r=n.reduce((o,a,l)=>(o.set(String(a[t]??l),l),s=Math.max(a.order??l,s),o),new Map);e.forEach(o=>{const a=String(o[t]);r.has(a)?n[r.get(a)]={...n[r.get(a)],...o}:n.push({order:s++,...o})})}return n}function H_(i,e){return Array.isArray(i)?i.map(t=>({...t,[e]:String(t[e])})):Object.keys(i).reduce((t,n)=>{const s=i[n];return Object.keys(s).forEach(r=>{t.push(...(s[r]||[]).map(o=>({...o,lane:n,col:r,[e]:String(o[e])})))}),t},[])}function U_(i,e){const{items:t=[],...n}=i;return{items:H_(t,e),...n}}function tf(i,e,t){var a;const n=cs(i.lanes,e.lanes,"name"),s=cs(i.cols,e.cols,"name"),r=cs(i.links,(a=e.links)==null?void 0:a.map(l=>(l[t]===void 0&&(l[t]=Ms(l)),l)),t),o=cs(i.items,H_(e.items||[],t),t);return{lanes:n,cols:s,items:o,links:r}}let vo=class extends Ve{constructor(){super(...arguments),this._ref=pe(),this._raf=0,this._data=new Ws(this._getData.bind(this),()=>{const{getCol:e,colProps:t,itemCountPerRow:n,itemGap:s,getLane:r,laneProps:o,itemProps:a,getItem:l,getLink:c,linkProps:h,responsive:d}=this.props;return[this._kanbanData,e,t,n,s,r,o,a,l,h,c,d]}),this._kanbanData=new Ws(()=>{const{itemKey:e,props:t}=this,{data:n}=t,{data:s,changes:r}=this.state,o=(s||Sh(n)?s:U_(n,e))||{};return r?tf(o,r,e):o},()=>{const{data:e,changes:t,selected:n}=this.state;return[e,t,n,this.props.data]}),this._handleGlobalClick=e=>{v(e.target).closest(".kanban-item").length||this.select([])},this._onAddLink=async e=>{const{onAddLink:t}=this.props;e[this.itemKey]=Ms(e),await(t==null?void 0:t.call(this,e))!==!1&&this.addLink(e)},this._onDeleteLink=async e=>{const{onDeleteLink:t}=this.props;await(t==null?void 0:t.call(this,e))!==!1&&this.deleteLink(e)},this._handleMouseMove=e=>{this._hoverTimer&&clearTimeout(this._hoverTimer);const t=this._getElementInfo(e.target),n=(t==null?void 0:t.type)==="item"?t.key:void 0;this._hoverTimer=window.setTimeout(()=>{n!==this.state.hover&&this.setState({hover:n},()=>{v(this._ref.current).trigger("kanbanItemHover",{kanban:this.props.key,hover:n})}),this._hoverTimer=0},!n&&this.state.hover?0:20)},this._handleClick=e=>{if(e.target.closest("a,button"))return;const{onClickItem:t,selectable:n}=this.props,s=this._getElementInfo(e.target);t&&(s==null?void 0:s.type)==="item"&&t.call(this,e,s)===!1||n&&(s==null?void 0:s.type)==="item"&&this.select(s.key,!0)}}get data(){return this._data.cache}get itemKey(){return this.props.itemKey||"id"}componentDidMount(){this._afterRender(!0),this.tryLoad(),this._initDraggable();const{responsive:e,selectable:t}=this.props,n=this._ref.current;if(n&&e){const s=new ResizeObserver(this.updateLayout.bind(this));v(typeof e!="boolean"?e:n.closest(".kanban-list")||n.parentElement).each((o,a)=>{s.observe(a)}),this._rob=s,this.state.containerWidth||this.updateLayout()}t&&v(document).on("click.kanban",this._handleGlobalClick)}componentDidUpdate(){this._afterRender(!1),this.tryLoad()}componentWillUnmount(){var e,t,n;(e=this.props.beforeDestroy)==null||e.call(this),(t=this._draggable)==null||t.destroy(),(n=this._rob)==null||n.disconnect(),this.props.selectable&&v(document).off("click.kanban",this._handleGlobalClick)}getDefaultState(e){return{loading:!1,selected:(e||this.props).defaultSelected,data:void 0,changes:void 0,loadFailed:void 0}}load(){const{data:e,onLoad:t,onLoadFail:n}=this.props;this._loadedSetting=e,this.setState({loading:!0},async()=>{const s={loading:!1};try{const r=U_(await Ne(e,[this],{throws:!0}),this.itemKey);s.data=(t==null?void 0:t.call(this,r))||r}catch(r){s.loadFailed=(typeof n=="function"?n.call(this,r):n)||String(r)}this.setState(s)})}updateLayout(){this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=0;const e=this._ref.current;if(e){const{responsive:t,laneNameWidth:n=20}=this.props,s=v(typeof t!="boolean"?t:e.closest(".kanban-list")||e.parentElement),r=s[0];let o=s.width()-n-(r.offsetWidth-r.clientWidth);const a=e.closest(".kanban-region");a&&(o-=a.clientWidth-v(a).width()),this.setState({containerWidth:o})}})}tryLoad(){const{loading:e}=this.state,{data:t}=this.props;e||!t||!Sh(t)||t===this._loadedSetting||this.load()}getCol(e){return this.data.colMap.get(String(e))}getLane(e){return e=String(e),this.data.lanes.find(t=>t.name===e)}getItem(e){return this.data.map.get(String(e))}update(e){return this.changeState(t=>({changes:tf({...t.changes},e,this.itemKey)}))}createSnap(){return{date:Date.now(),kanban:this,data:v.extend(!0,{},this._data),restore(){this.kanban.changeState({changes:this.data})}}}addItem(e,t,n){return this.updateItem(e,t,n)}updateItem(e,t,n){const s=Array.isArray(e)?e:[e];return this.update({items:t||n?s.map(r=>({...r,lane:t??r.lane,col:n??r.col})):s})}deleteItem(e){return this.updateItem(Array.isArray(e)?e.map(t=>({[this.props.itemKey||"id"]:t,deleted:!0})):{[this.itemKey]:e,deleted:!0})}updateLane(e){return this.update({lanes:Array.isArray(e)?e:[e]})}addLane(e){return this.updateLane(e)}deleteLane(e){return this.updateLane(Array.isArray(e)?e.map(t=>({name:t,deleted:!0})):{name:e,deleted:!0})}updateCol(e){return this.update({cols:Array.isArray(e)?e:[e]})}addCol(e){return this.updateCol(e)}deleteCol(e){return this.updateCol(Array.isArray(e)?e.map(t=>({name:t,deleted:!0})):{name:e,deleted:!0})}updateLink(e,t){return this.update({links:(Array.isArray(e)?e:[e]).map(n=>({deleted:!1,...n,...t,[this.itemKey]:Ms(n)}))})}addLink(e){return this.updateLink(e)}deleteLink(e){return this.updateLink(e,{deleted:!0})}select(e,t){let n=Array.isArray(e)?e:e?[e]:[],s=this.state.selected||[];const{onSelect:r}=this.props;return this.changeState(o=>{if(s=o.selected||[],t){const a=new Set(s),l=new Set;return n.forEach(c=>{a.has(c)?a.delete(c):l.add(c)}),n=[...a,...l],{selected:n}}return{selected:n}},()=>{r==null||r(n,s),v(this._ref.current).trigger("kanbanItemSelected",{kanban:this.props.key,selected:n,oldSelected:s})})}_getElementInfo(e){const t=v(e),n=t.closest(".kanban-item");if(n.length){const a=n.attr("z-key");if(a){const l=this.getItem(a);if(l)return{type:"item",key:a,element:e,item:l,lane:l.lane,col:l.col}}}if(t.closest(".kanban-new-item").length)return{type:"newItem",element:e};const r=t.closest(".kanban-header-col,.kanban-lane-col");if(r.length)return{type:"col",element:e,col:r.attr("z-col"),lane:r.attr("z-lane")};const o=t.closest(".kanban-lane").attr("z-lane");if(o!==void 0)return{type:"lane",element:e,lane:o}}_getDropInfo(e,t,n){const s=this._getElementInfo(t);if(!s)return;const r=this._getElementInfo(n);if(!r||r.element.closest(".kanban")!==this.element)return;let o;if(s.type==="item"&&r.type==="col")o="inside";else{const a=n.getBoundingClientRect();s.type==="col"?o=e.clientX<a.left+a.width/2?"before":"after":o=e.clientY<a.top+a.height/2?"before":"after"}return{side:o,event:e,drag:s,drop:r}}_getDropChanges(e){const{drag:t,drop:n}=e,s=this.data,r={},{itemKey:o}=this,a={list:[],lane:n.lane,col:n.col};if(t.type==="item"){const l=t.item,c=s.items[n.lane][n.col],h=[...c],d={[o]:l[o],order:l.order},f=n.col===l.col,p=n.lane===l.lane;if(f&&p&&l[o]===n.item[o])return{changes:r,data:a};f||(d.col=n.col),p||(d.lane=n.lane);let y=!1;if(n.type==="col"&&(!p||!f))h.push(d),y=!0;else if(n.type==="item"){const b=n.item,w=n.col!==l.col||n.lane!==l.lane?-1:h.findIndex(T=>T[o]===l[o]);w>=0&&h.splice(w,1);const x=h.findIndex(T=>T[o]===b[o]);h.splice(e.side==="before"?x:x+1,0,d),y=!0}if(y){r.items=[];let b=-1;h.forEach((w,x)=>{const T=Math.max(0,b+1,w.order??x),D=c[x];b=T,(D!==w||T!==D.order)&&(w={...w,order:T}),w!==D&&r.items.push(w),a.list.push(w[o])})}}else if(t.type==="newItem"){const{onDropNewItem:l}=this.props;let c;if(l?c=l.call(this,e):(c=v(t.element).data(),c!=null&&c.item&&(c=c.item)),c={lane:n.lane,col:n.col,...c},c!=null&&c[o]){const d=[...s.items[n.lane][n.col]];d.push(c),r.items=d,a.list.push(c[o])}}return{changes:r,data:a}}_initDraggable(){const{draggable:e}=this.props,t=this._ref.current;if(!e||!t)return;const{dragTypes:n=["item","newItem"],onDragStart:s,onDrop:r,canDrop:o,dropRules:a}=this.props,l=typeof n=="string"?n.split(","):n,c={item:".kanban-item",lane:".kanban-lane-name",col:".kanban-header-col",newItem:".kanban-new-item"},h=typeof e=="object"?e:{},d=(p,y)=>{v(p).attr({"z-drag-type":y?y.drag.type:null,"z-drop-type":y?y.drop.type:null,"z-drop-side":y?y.side:null})},f={...h,selector:h.selector||l.map(p=>c[p]||"").filter(Boolean).join(","),target:h.target||(p=>{const y=this._getElementInfo(p);if(!y)return;const b={lane:".kanban-lane",col:".kanban-header-col",item:".kanban-item,.kanban-items",newItem:".kanban-item,.kanban-items"}[y.type];return v(t).find(b)}),canDrop:h.canDrop||o||a?(p,y,b)=>{const w=this._getElementInfo(y);if(!w)return!1;const x=this._getElementInfo(b);if(!x||x.element.closest(".kanban")!==this.element)return!1;if(w.type==="item"&&a){const T=w.col,D=x.col,N=w.lane,A=x.lane,z=a[`${N}:${T}`]??a[T];return typeof z=="boolean"?z:!z||z.includes(D)||z.includes(`${A}:${D}`)||z.includes(`${A}:`)}if(o)return o.call(this,w,x)}:void 0,onDragStart:(p,y)=>{var w;const b=this._getElementInfo(y);return b?s?s.call(this,{event:p,drag:b}):(w=h.onDragStart)==null?void 0:w.call(this,p,y):!1},onDragOver:(p,y,b)=>{const w=this._getDropInfo(p,y,b);w&&d(b,w)},onDragLeave:(p,y,b)=>{d(b)},onDrop:(p,y,b)=>{var x;d(b);const w=this._getDropInfo(p,y,b);if(!w)return!1;if(r){const{changes:T,data:D}=this._getDropChanges(w);if(Object.keys(T).length){w.data=D;const N=this.createSnap();r.call(this,T,w,N.restore)!==!1&&this.update(T)}}return(x=h.onDrop)==null?void 0:x.call(this,p,y,b)}};this._draggable=new Br(t,f)}_afterRender(e){var t;(t=this.props.afterRender)==null||t.call(this,e)}_getData(){const{itemKey:e,props:t}=this,n=this._kanbanData.value;let s=!1;const{items:r=[]}=n,o={},a=new Map,l=zT.call(this,n.cols,t,w=>{w.parentName!==void 0&&(s=!0),a.set(w.name,w)}),c=FT.call(this,n.lanes,t,w=>{o[w.name]=l.reduce((x,T)=>(T.subCols?T.subCols.forEach(D=>{x[D.name]=[]}):x[T.name]=[],x),{})}),h=new Set,d=r.reduce((w,x)=>{if(x.deleted)return h.add(x[e]),w;w.set(x[e],x);const T=o[x.lane];if(T){const D=T[x.col];D&&D.push(x)}return w},new Map),{selected:f=[]}=this.state,p=new Set(f),y=w=>{w.selected=p.has(w[e])};c.forEach(w=>{const x=o[w.name];x&&l.forEach(T=>{var D;x[T.name]=j_.call(this,x[T.name],w,T,t,y),(D=T.subCols)==null||D.forEach(N=>{x[N.name]=j_.call(this,x[N.name],w,N,t,y)})})});let{links:b=[]}=n;return b=b.reduce((w,x)=>{var T;if(!x.deleted&&d.has(x.from)&&d.has(x.to)&&!h.has(x.from)&&!h.has(x.to)){x[e]===void 0&&(x[e]=Ms(x));const D=((T=t.getLink)==null?void 0:T.call(this,x))??x;D!==!1&&!D.deleted&&w.push(D)}return w},[]),{cols:l,lanes:c,items:o,map:d,colMap:a,links:b,hasSubCols:s}}_layoutCols(e,t){const{containerWidth:n=0}=this.state,{colsGap:s=8,minColWidth:r=150,maxColWidth:o=600,colWidth:a=200}=t,l=[];let c=0;const h=d=>{const{minWidth:f=r,maxWidth:p=o}=d;let{width:y=a}=d;typeof y=="function"&&(y=y.call(this,d));const b=y==="auto";if(b)y=f;else{const[w,x]=In(y);x==="%"?y=n*w/100:y=w}return y=Math.min(p,Math.max(f,y)),c+=y+(c?s:0),d={...d,width:y,maxWidth:p,minWidth:f},b&&l.push(d),d};if(e=e.map(d=>d.subCols?{...d,subCols:d.subCols.map(h)}:h(d)),l.length&&c<n){const d=Math.floor((n-c)/l.length);l.forEach(f=>{f.width=Math.min(f.maxWidth,Math.max(f.minWidth,f.width+d))})}return e}_layoutLanes(e,t){const{laneHeight:n,maxLaneHeight:s,minLaneHeight:r}=t;return!n&&!s&&!r?e:e.map(o=>({height:typeof n=="function"?n.call(this,o):n,maxHeight:s,minHeight:r,...o}))}_getClassName(e){return["kanban",e.className,e.sticky?"kanban-sticky":"",this.data.hasSubCols?"has-sub-cols":""]}_getProps(e){const{laneNameWidth:t,colsGap:n,lanesGap:s,selectable:r,onClickItem:o,showLinkOnHover:a}=e;return Pe(super._getProps(e),{ref:this._ref,style:{"--kanban-lane-name-width":t,"--kanban-cols-gap":Be(n),"--kanban-lanes-gap":Be(s)},onClick:o||r?this._handleClick:void 0,onMouseMove:a?this._handleMouseMove:void 0})}_renderLinks(e){const{links:t=[]}=this.data,{editLinks:n}=e;if(!n&&!t.length)return;const{showLinkOnHover:s,showLinkOnSelected:r}=e;let o;if(r||s){o=[];const{selected:a,hover:l}=this.state;r&&a&&o.push(...a),s&&l&&o.push(l),o=[...new Set(o)]}return k(B_,{links:t,filters:o,editLinks:n,onDeleteLink:n?this._onDeleteLink:void 0,onAddLink:n?this._onAddLink:void 0},"links")}_getChildren(e){const t=this._data.value,{cols:n,lanes:s,items:r}=t,{laneNameWidth:o}=e,a=this._layoutCols(n,e),l=this._layoutLanes(s,e);return[k($T,{cols:a},"header"),k(IT,{itemRender:e.itemRender,getLaneCol:e.getLaneCol,cols:a,lanes:l,items:r,hideLaneName:o===0},"body"),this._renderLinks(e),e.children]}};vo.defaultProps={draggable:!0,sticky:!0,responsive:!0,itemKey:"id",colWidth:200,colsGap:8},vo.customProps=["onDrop","onDragStart"];class V_ extends Ve{constructor(){super(...arguments),this._kanbanRefs=new Map,this._needUpdateData=new Map,this._handleClickHeading=e=>{v(e.target).closest("a,.btn,button").not(".kanban-region-toggle").length||this.setState(t=>({collapsed:!t.collapsed}))}}componentDidUpdate(){if(this.state.collapsed)return;const e=this._needUpdateData;[...e.keys()].forEach(t=>{const n=this.getKanban(t);n&&(n.update(e.get(t)),e.delete(t))})}getDefaultState(e){return{collapsed:(e||this.props).collapsed,heading:void 0,items:void 0}}resetState(e,t){this._kanbanRefs.forEach(n=>{var s;return(s=n.current)==null?void 0:s.resetState()}),super.resetState(e,t)}getKanban(e){var t;return(t=this._kanbanRefs.get(String(e)))==null?void 0:t.current}toggle(e){this.setState(t=>({collapsed:e===void 0?!t.collapsed:!e}))}update(e){const{items:t}=e;return t&&(e={...e},e.items=t.map((n,s)=>{const r=String(n.key||s);return n.deleted?{key:r,deleted:!0}:(n.data&&typeof n.data=="object"&&this.getKanban(r)&&(this._needUpdateKanban(r,n.data),n={...n},delete n.data),n)})),new Promise(n=>{this.setState(e.items?s=>({...e,items:cs(s.items,e.items)}):e,n)})}_needUpdateKanban(e,t){const n=this._needUpdateData,s=n.get(e),{kanbanItemKey:r="key"}=this.props;n.set(e,tf(s||{},t,r))}_buildItems(e){const{items:t=[],kanbanProps:n,kanbanItemKey:s="key"}=e;let{items:r}=this.state;r?(r=cs(t,r,s).filter(c=>!c.deleted),r.sort(yo)):r=t;const o=this._kanbanRefs,a=new Set(o.keys()),l=r.map((c,h)=>{if(c.deleted)return null;const d=Pe({className:"kanban-region-item",key:h},typeof n=="function"?n.call(this,c,h):n,c),f=String(d.key);let p=o.get(f);return p||(p=pe(),o.set(f,p)),d.ref=p,a.delete(f),k(vo,{"z-key":f,...d})});return a.forEach(c=>{o.delete(c)}),l}_getClassName(e){return["kanban-region",e.className,this.state.collapsed?"is-collapsed":"is-expanded",e.heading?"has-heading":""]}_getChildren(e){const{heading:t,toggleFromHeading:n}=e,{collapsed:s,heading:r}=this.state,o=Pe({className:"kanban-heading",onClick:n?this._handleClickHeading:void 0},typeof t=="function"?t.call(this):t,r);return[t&&k(Pn,{...o},"heading"),s?null:this._buildItems(e)]}}const nf=".kanban";let W_=class extends Ve{constructor(){super(...arguments),this.state={},this._ref=pe(),this._kanbanRefs=new Map,this._onAddLink=async e=>{const{onAddLink:t,linkItemKey:n}=this.props;e[n]=Ms(e),await(t==null?void 0:t.call(this,e))!==!1&&this.addLink(e)},this._onDeleteLink=async e=>{const{onDeleteLink:t}=this.props;await(t==null?void 0:t.call(this,e))!==!1&&this.deleteLink(e)}}componentDidMount(){const e=this._ref.current;if(e){const{moveable:t,responsive:n,showLinkOnSelected:s,showLinkOnHover:r}=this.props;if(t&&(this._moveable=new _s(e,v.extend({selector:"self",move:"scroll",onMoveStart:(o,a)=>{const{bottom:l,right:c}=a.getBoundingClientRect();return o.clientY<l&&o.clientY>l-20||o.clientX<c&&o.clientX>c-20?!1:!v(o.target).closest("a,input,.btn,.state,.kanban-item,.not-moveable").length}},typeof t=="object"?t:null))),s&&v(e).on(`kanbanItemSelected${nf}`,(o,a)=>{this.setState(l=>({selected:{...l.selected,[a.kanban]:a.selected}}))}),r&&v(e).on(`kanbanItemHover${nf}`,(o,{kanban:a,hover:l})=>{this.setState({hover:l===void 0?l:`${a}_${l}`})}),n){const o=new ResizeObserver(this._tryUpdateLayout.bind(this));(typeof n!="boolean"?v(n):v(e).parent()).each((l,c)=>{o.observe(c)}),this._rob=o}}}componentWillUnmount(){var t,n;(t=this._moveable)==null||t.destroy(),(n=this._rob)==null||n.disconnect();const e=this._ref.current;e&&v(e).off(nf)}getDefaultState(e){return{linkChanges:void 0}}resetState(e,t){this._kanbanRefs.forEach(n=>{var s;(s=n.current)==null||s.resetState()}),super.resetState(e,t)}getKanban(e){const t=String(e),n=this._kanbanRefs;if(n.has(t))return n.get(t).current;let s=null;const r=Array.from(n.values());for(const o of r){const a=o.current;if(a instanceof V_&&(s=a.getKanban(e),s))break}return s||null}updateKanban(e,t){const n=this.getKanban(e);return n?n.update(t):Promise.reject(new Error(`[ZUI] Kanban not found: ${e}`))}updateLayout(){const e=this._ref.current;if(!e)return;const t=v(e),n=t.width(),s=t.height();this.setState({width:n,height:s})}updateLink(e,t){return this.changeState(n=>{let s=Array.isArray(e)?e:[e];return t&&(s=s.map(r=>({...r,...t}))),{linkChanges:cs(n.linkChanges,s,this.props.linkItemKey)}})}addLink(e){return this.updateLink(e)}deleteLink(e){return this.updateLink(e,{deleted:!0})}_tryUpdateLayout(){this._layoutTimer&&cancelAnimationFrame(this._layoutTimer),this._layoutTimer=requestAnimationFrame(()=>{this.updateLayout(),this._layoutTimer=0})}_getClassName(e){return["kanban-list",e.className,e.sticky?"has-sticky":"",e.moveable?"is-moveable":"",e.scrollbarHover?"scrollbar-hover":""]}_getProps(e){const{width:t,height:n}=e,s=typeof t=="function"?t.call(this):t,r=typeof n=="function"?n.call(this):n,{width:o,height:a}=this.state??{};return Pe(super._getProps(e),{ref:this._ref,style:{width:s,height:r,"--kanban-list-width":`${o||t}px`,"--kanban-list-height":`${a||n}px`}})}_getLinks(e){const{linkChanges:t=[]}=this.state,{links:n=[],getLink:s,linkItemKey:r}=e;return cs(n,t,this.props.linkItemKey).reduce((o,a)=>{const l=s==null?void 0:s.call(this,a);return l!==!1&&(a=l||a,a.deleted||(a[r]||(a[r]=Ms(a)),o.push(a))),o},[])}_renderLinks(e){const t=this._getLinks(e),{editLinks:n}=e;if(!n&&!t.length)return;const{showLinkOnHover:s,showLinkOnSelected:r}=e;let o;if(t.length&&(r||s)){o=[];const{selected:a={},hover:l}=this.state;r&&a&&Object.keys(a).forEach(c=>{const h=a[c];h.length&&o.push(...h.map(d=>`${c}_${d}`))}),s&&l&&o.push(l),o=[...new Set(o)]}return k(B_,{container:".kanban-list",links:t,filters:o,editLinks:n,onDeleteLink:n?this._onDeleteLink:void 0,onAddLink:n?this._onAddLink:void 0},"links")}_getChildren(e){const{items:t=[],kanbanProps:n,showLinkOnSelected:s,showLinkOnHover:r,selectable:o,editLinks:a}=e,l=this._kanbanRefs,c=new Set(l.keys()),h=[...t.map((f,p)=>{n&&(f=typeof n=="function"?n.call(this,f,p):v.extend({},n,f));const y=String(f.key??p);let b=l.get(y);b||(b=pe(),l.set(y,b)),c.delete(y);const w=f.heading!==void 0||f.items;return(s||r||o)&&(w?f.kanbanProps={showLinkOnSelected:s,showLinkOnHover:r,selectable:o,...f.kanbanProps}:f={showLinkOnSelected:s,showLinkOnHover:r,selectable:o,...f}),a&&(w?f.items=(f.items||[]).map(T=>({...T,editLinks:!1})):f={...f,editLinks:!1}),k(w?V_:vo,{ref:b,sticky:e.sticky,...f,"z-key":y},y)}),e.children];c.forEach(f=>{l.delete(f)});const d=this._renderLinks(e);return d&&h.push(d),h}};W_.defaultProps={moveable:!0,sticky:!0,responsive:!0,scrollbarHover:!0,linkItemKey:"id"};class _o extends ve{}_o.NAME="Kanban",_o.replace=!0,_o.Component=vo,_o.register();class bo extends ve{update(e,t){if(e=Array.isArray(e)?e:[e],t)return this.render({items:e});const n=this.options.items||[],s=new Map(n.map((o,a)=>[o.key,a])),r=[...n];return e.forEach(o=>{if(s.has(o.key)){const a=s.get(o.key);r[a]={...n[a],...o}}else r.push(o)}),this.render({items:r.filter(o=>!o.deleted)})}}bo.NAME="KanbanList",bo.replace=!0,bo.Component=W_,bo.register();const AN="",PN="",LN="",RN="",zN="",FN="",ON="",BN="",jN="",HN="",OT="nav",sf='[data-toggle="tab"],[zui-toggle="tab"]',BT="active";class wo extends qe{constructor(){super(...arguments),this._timer=0}active(e){const t=this.$element,n=t.find(sf);let s=e?v(e).closest(sf):n.filter(`.${BT}`);if(!s.length&&(s=t.find(sf).first(),!s.length))return;n.removeClass("active"),s.addClass("active");let r=s.attr("href")||s.data("target");if(!r){const c=s.attr("zui-toggle-tab");r=Yn(c).target}const o=s.data("name")||r,a=t.closest(".tabs"),l=a.length?a.find(r):v(r);l.length&&(l.parent().children(".tab-pane").removeClass("active in"),l.addClass("active").trigger("show",[o]),this.emit("show",o),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{l.addClass("in").trigger("shown",[o]),this.emit("shown",o),this._timer=0},10))}}wo.NAME="Tabs",wo.toggle={name:"tab",handler(i,e){const t=v(i),n=t.closest(`.${OT}`);n.length&&wo.ensure(n,e).active(t)}},wo.register();function jT(i){const[e,t]=i.split(":"),n=e[0]==="-"?{name:e.substring(1),disabled:!0}:{name:e};return t!=null&&t.length&&(n.type="dropdown",n.items=t.split(",").reduce((s,r)=>(r=r.trim(),r.length&&s.push(r[0]==="-"?{name:r.substring(1),disabled:!0}:{name:r}),s),[])),n}const HT=(i,e)=>{var s;i.url&&(i.url=De(i.url,e.row.data));const t={row:e.row.id,col:e.col.name},n=((s=i.dropdown)==null?void 0:s.items)||i.items;return n&&n.forEach(r=>(r.url&&(r.url=De(r.url,e.row.data)),r.data=t,r)),i.data=t,i},K_=i=>i?(typeof i=="string"&&(i=i.split("|")),i.map(e=>typeof e=="string"?jT(e):e).filter(Boolean)):[],UT=et({name:"actions",colTypes:{actions:{onRenderCell(i,e){var h;const{row:t,col:n}=e,s=K_(((h=t.data)==null?void 0:h[n.name])||n.setting.actions);if(!s.length)return i;const{actionsSetting:r,actionsMap:o,actionsCreator:a=this.options.actionsCreator,actionItemCreator:l=this.options.actionItemCreator||HT}=n.setting,c={items:(a==null?void 0:a(e))??s.map(d=>{const{name:f,...p}=d;if(o&&f){Object.assign(p,o[f],{...p});const{buildProps:b}=p;typeof b=="function"&&(delete p.buildProps,Object.assign(p,b(i,e)))}const{items:y}=p;if(p.disabled&&(delete p.url,delete p["data-toggle"]),y&&p.type==="dropdown"){const{dropdown:b={placement:"bottom-end"}}=p;b.menu={className:"menu-dtable-actions"},b.items=y.map(w=>{const x=typeof w=="string"?{name:w}:{...w};return x.name&&o&&o[x.name]&&Object.assign(x,o[x.name],{...x}),x.disabled?(delete x.url,delete x["data-toggle"]):x.url&&(x.url=De(x.url,t.data)),x}),p.dropdown=b,delete p.items}return l?l(p,e):p}),btnProps:{btnType:"ghost",size:"sm",className:"text-primary"},...r};return i[0]=k(Fe,{...c}),i}}},beforeLayout(i){!Array.isArray(i.data)||!i.data.length||i.cols.forEach((e,t)=>{if(e.type!=="actions"||e.width)return;const{actionsMap:n={}}=e,r=K_(i.data[0][e.name]).reduce((o,a)=>{const l=a.name?n[a.name]:null;return l&&l.type==="dropdown"&&l.caret&&!l.text?o+16:o+24},24);i.cols[t]={...e,width:r}})}}),VT=et({name:"toolbar",footer:{toolbar(){const{footToolbar:i,showToolbarOnChecked:e}=this.options;return e&&!this.getChecks().length?[]:[i?Fe.render(i,[this],{gap:2}):null]}}}),WN="",q_=function(i,e){var s,r;const{col:t}=e,{sortColFrom:n}=this.state;if(n){n.name===t.name&&i.push({outer:!0,className:"is-sorting-from-col"});const o=(r=(s=this.data.sortColInfo)==null?void 0:s.colOffsetMap)==null?void 0:r[t.name];typeof o=="number"&&i.push({outer:!0,className:"is-sorting-col-move",style:{left:t.left+o}})}return i},WT=et({name:"sort-col",when:i=>!!i.sortCol,plugins:[mo,Xu],resetState:!0,state(){return{colOrders:{},sortColFrom:void 0,sortingColPos:void 0,sortingColTo:void 0,sortingColSide:void 0}},events:{mousedown(i){var r;if(this.data.disableSortCol)return;const e=this.getPointerInfo(i);if(!e||e.rowID!=="HEADER")return;const t=this.getColInfo(e.colName);if(!t||((r=this.options.onSortColStart)==null?void 0:r.call(this,t,i))===!1)return;v(i.target).closest("a,button,img").attr("draggable","false").length&&i.preventDefault(),i.preventDefault();const n=i.clientX,{cellElement:s}=e;this.data.sortColInfo={from:t,element:s,offset:n-s.getBoundingClientRect().left,startMouseX:n,lastMouseX:n},v(s).zuiCall("ContextMenu.hide")},document_mouseup(i){var n;const{sortColInfo:e}=this.data;if(!e)return;this.stopScrollToMouse();const t=this.getSortingColState(i);if(t){let s,r;const{from:o,to:a,side:l}=t;if(a){if(o.name===a.name)s={};else if(l){const c=this.layout.cols[o.side].list,h=o.sideIndex,d=a.sideIndex,f=c.splice(h,1);c.splice(d+(l==="after"?1:0),0,f[0]),s={},r=[],c.forEach(({name:p},y)=>{s[p]=y+1,r.push(p)}),((n=this.options.onSortCol)==null?void 0:n.call(this,o,a,l,r))===!1&&(s=void 0,r=void 0)}Math.abs(e.lastMouseX-e.startMouseX)>4&&this.ignoreNextClick()}this.disableAnimation(),this.update({dirtyType:"layout",state:v.extend({sortColFrom:void 0,sortingColPos:void 0,sortingColTo:void 0,sortingColSide:void 0},s?{colOrders:{...this.state.colOrders,...s}}:null)},()=>{var c;(c=this.options.onSortColEnd)==null||c.call(this,o,a,l,r)})}this.data.sortColInfo=void 0},document_mousemovesmooth(i){const{sortColInfo:e}=this.data;if(!e)return;const t=this.getSortingColState(i);t&&(e.state||this.startScrollToMouse({side:"x"}),e.lastMouseX=i.clientX,e.state=t,this.setState({sortColFrom:t.from,sortingColPos:t.pos,sortingColTo:t.to,sortingColSide:t.side}))}},methods:{getSortingColState(i){var w;const{disableSortCol:e,sortColInfo:t}=this.data;if(e||!t)return;const{from:n,element:s}=t,o=v(s).closest(".dtable-cells")[0].getBoundingClientRect(),a=i.clientX-o.left,{cols:l,scrollLeft:c}=this.layout,h=l[n.side].list;if(h.length<=1)return t.state;const d=c+a,f=h.find(x=>x.visible&&x.left<=d&&x.left+x.width>d);if(!f)return t.state;const p=d<f.left+f.width/2?"before":"after";return n.side===f.side&&((w=this.options.canSortColTo)==null?void 0:w.call(this,n,f,p))!==!1?{from:n,pos:a+c,to:f,side:n.name!==f.name?p:void 0}:{from:n,pos:a,to:void 0,side:void 0}}},onAddCol(i){const{colOrders:e={}}=this.state,t=e[i.name];t!==void 0&&(i.order=t)},beforeRender(i){const{sortColFrom:e,sortingColTo:t,sortingColSide:n}=this.state;if(e&&t){i.className=U(i.className,"has-sorting-col");const s=[...i.cols[e.side].list],r=e.sideIndex,o=t.sideIndex,a=s.splice(r,1);s.splice(o+(n==="after"?1:0),0,a[0]);let l=0;const c={};s.forEach(h=>{const d=l-h.left;d&&(c[h.name]=d),l+=h.realWidth}),this.data.sortColInfo.colOffsetMap=c}},onRenderHeaderCell(i,e,t,n){const{sortCol:s}=this.options;return s&&(this.layout.cols[e.col.side].list.length>1&&(s===!0||Array.isArray(s)&&s.includes(e.col.name)||typeof s=="function"&&s.call(this,e.col))&&i.push({outer:!0,className:"is-sortable-col"}),i=q_.call(this,i,e,t,n)),i},onRenderCell:q_}),qN="";function G_(i,e,t){const{colResizing:n}=i.state;if(!n)return;const s=Math.round(e.clientX-n.startX);if(!s&&!t)return;const r={};t&&(r.colResizing=void 0);const{colName:o}=n;let a=i.getColInfo(o);if(!a)return i.update({dirtyType:"layout",state:r});r.colsSizes={...i.state.colsSizes,[o]:n.startSize+s},i.update({dirtyType:"layout",state:r},t?()=>{var l;if(a=i.getColInfo(o),a){const c=i.data.colOriginSize.get(o);(l=i.options.onColResize)==null||l.call(i,o,a.width-c,a)}}:void 0),e.stopPropagation(),e.preventDefault()}const Z_=et({name:"resize",when:i=>!!i.colResize,plugins:[mo],resetState(i){var e;return{colsSizes:((e=i.cols)==null?void 0:e.reduce((t,n)=>(n.extraWidth!==void 0&&(t[n.name]=n.extraWidth),t),{}))||{}}},state(){var i;return{colsSizes:((i=this.props.cols)==null?void 0:i.reduce((e,t)=>(t.extraWidth!==void 0&&(e[t.name]=t.extraWidth),e),{}))||{}}},data(){return{colOriginSize:new Map}},events:{mousedown(i){const e=i.target.closest(".dtable-col-splitter");if(!e)return;const t=e.closest(".dtable-cell"),n=t==null?void 0:t.dataset.col;if(n)return this.setState({colResizing:{colName:n,startSize:this.state.colsSizes[n]??0,startX:i.clientX}},()=>{v(t).zuiCall("ContextMenu.hide")}),!1},dblclick(i){var s;const e=i.target.closest(".dtable-col-splitter");if(!e)return;const t=(s=e.closest(".dtable-cell"))==null?void 0:s.dataset.col;if(!t)return;const{colsSizes:n}=this.state;n[t]&&(delete n[t],this.update({dirtyType:"layout",state:{colResizing:void 0,colsSizes:{...n}}},()=>{var r;(r=this.options.onColResize)==null||r.call(this,t,0,this.getColInfo(t))}))},document_mouseup(i){if(this.state.colResizing)return G_(this,i,!0),!1},document_mousemovesmooth(i){if(this.state.colResizing)return G_(this,i),!1}},methods:{isColResizable(i){if(typeof i=="string"&&(i=this.getColInfo(i)),!i||i.side!=="left"&&i.sideIndex===this.layout.cols[i.side].list.length-1)return;let e=i.setting.colResize??this.options.colResize;return typeof e=="function"&&(e=e.call(this,i.name)),!!e}},onRenderHeaderCell(i,{col:e}){var t;return this.isColResizable(e)&&(i.push({className:"has-col-splitter",children:k("div",{className:"dtable-col-splitter no-cell-event"}),outer:!0}),((t=this.state.colResizing)==null?void 0:t.colName)===e.name&&i.push({className:"has-col-resizing",outer:!0})),i},onRenderCell(i,{col:e}){var t;return((t=this.state.colResizing)==null?void 0:t.colName)===e.name&&i.push({className:"is-col-resizing",outer:!0}),i},onAddCol(i){const e=this.state.colsSizes[i.name]??i.setting.extraWidth;typeof e=="number"&&(this.data.colOriginSize.set(i.name,i.width),i.width=av(i.width+e,i.setting.minWidth,i.setting.maxWidth))},onRender(){if(this.state.colResizing)return{className:"has-col-resizing"}}}),ZN="",KT=et({name:"contextmenu",when:i=>!!i.contextmenu,events:{contextmenu(i){const e=this.getPointerInfo(i);if(!e)return;const t=this.getContextMenuItems(i,e);if(!t||!t.length)return;i.preventDefault();const n=v(e.cellElement).addClass("has-contextmenu-show");e.cellElement.classList.add("active"),nr.show({items:t,key:`dtable-ctx-${this.id}`,triggerEvent:i,hideOthers:!0,onHide(){n.removeClass("has-contextmenu-show")}})}},methods:{getContextMenuItems(i,e){const{contextmenu:t}=this.options;if(typeof t=="function")return t.call(this,i,e);if(!t||Array.isArray(t))return t;const{header:n,cell:s}=t;return e.rowID==="HEADER"?typeof n=="function"?n.call(this,i,e):n:typeof s=="function"?s.call(this,i,e):s}}});function Y_(i,e){if(typeof e=="string"&&(e=i.getColInfo.call(i,e)),!e)return{};const{colBorders:t}=i.state,{side:n,sideIndex:s}=e,r=i.layout.cols[n].list,o=s>0?r[s-1]:null,a=r[s+1];return{prevName:o==null?void 0:o.name,nextName:a==null?void 0:a.name,prev:o?t[o.name]??o.setting.border:void 0,next:a?t[a.name]??a.setting.border:void 0}}function sr(i,e){return i===e||i===!0}const qT=et({name:"custom-col",when:i=>!!i.customCol,plugins:[KT],resetState:!0,options(i){return i.customCol&&!i.contextmenu&&(i.contextmenu={header:(e,t)=>{var o,a;const n=this.getColBorder(t.colName),s=l=>{const c={width:"12px",margin:"0 2px",height:"12px",border:"1px dotted var(--color-border-strong)"},h="2px solid var(--color-border-strong)";return l==="left"?c.borderLeft=h:l==="right"?c.borderRight=h:l===!0&&(c.borderLeft=h,c.borderRight=h),k("span",{style:c})},r=((o=this.getColInfo(t.colName))==null?void 0:o.setting.required)||!((a=this.options.canSetColVisibility)!=null&&a.call(this,t.colName,!1));return[{icon:s(n),text:this.i18n("setDivider"),items:[{text:this.i18n("leftDivider"),icon:s("left"),selected:n==="left",onClick:()=>this.setColBorder(t.colName,"left")},{text:this.i18n("rightDivider"),icon:s("right"),selected:n==="right",onClick:()=>this.setColBorder(t.colName,"right")},{text:this.i18n("allDivider"),icon:s(!0),selected:n===!0,onClick:()=>this.setColBorder(t.colName,!0)},{text:this.i18n("noDivider"),icon:s(!1),selected:!n,onClick:()=>this.setColBorder(t.colName,!1)}]},{text:this.i18n("hideCol"),icon:"eye-off",disabled:r,onClick:r?void 0:()=>this.setColVisibility(t.colName,!1)}]}}),i},state(){return{colBorders:{},colVisibility:{}}},methods:{getColBorder(i,e=!0){const t=this.getColInfo(i);if(!t)return!1;const{colBorders:n}=this.state,s=n[i]??t.setting.border;if(s===!0||!e)return s;const{prev:r,next:o}=Y_(this,t),a=s==="left"||sr(r,"right"),l=s==="right"||sr(o,"left");return a&&l?!0:a?"left":l?"right":!1},setColBorder(i,e){if(this.getColBorder(i,!1)===e)return;const{onSetColBorder:n}=this.options,{prev:s,next:r,prevName:o,nextName:a}=Y_(this,i);this.update({dirtyType:"layout",state:l=>{const c={...l.colBorders,[i]:e};return!sr(e,"left")&&sr(s,"right")&&(c[o]=!1),!sr(e,"right")&&sr(r,"left")&&(c[a]=!1),{colBorders:c}}},n?()=>{n.call(this,i,e,this.state.colBorders)}:void 0)},setColVisibility(i,e){const{onSetColVisibility:t}=this.options;this.update({dirtyType:"options",state:n=>({colVisibility:{...n.colVisibility,[i]:e}})},t?()=>{t.call(this,i,e)}:void 0)}},onAddCol(i){const{colBorders:e}=this.state;e[i.name]!==void 0&&(i.border=e[i.name])},beforeLayout(i){const{colVisibility:e}=this.state;Object.keys(e).length&&i.cols&&(i.cols=i.cols.map(t=>(e[t.name]!==void 0&&(t={...t,hidden:!e[t.name]}),t)))},i18n:{zh_cn:{setDivider:"设置分割线",leftDivider:"左侧",rightDivider:"右侧",allDivider:"两侧",noDivider:"无",hideCol:"隐藏此列"},zh_tw:{setDivider:"設置分割線",leftDivider:"左側",rightDivider:"右側",allDivider:"兩側",noDivider:"無",hideCol:"隱藏此列"},en:{setDivider:"Set divider",leftDivider:"Left Side",rightDivider:"Right Side",allDivider:"Both Sides",noDivider:"No Divider",hideCol:"Hide this column"}}}),XN="";function rf(i,e,t){if(t){if(typeof t=="object"){const n=t[i];return typeof n=="string"?n:typeof n=="object"&&n?n.realname:void 0}if(typeof t=="function")return t(i,e)}}function J_(i,e,t){let n;if(typeof i=="function"?n=i(e,t):typeof i=="object"&&(n=i[e]),n)return g($e,{className:"dtable-cell-icon",icon:n})}et({name:"zentao",plugins:["group","checkable","nested",UT,VT,P_,WT,Z_,qT],defaultOptions:{colHover:"header",rowHeight:36,striped:!1,responsive:"window,parent,.search-form,~document_layout",checkable:"auto",nested:"auto",width:"100%",footer:void 0,showToolbarOnChecked:!0,checkOnClickRow:!0,groupDivider:!0,preserveNested:!0,extraHeight:"+",height(i){var r;const e=(r=this.element)==null?void 0:r.closest(".modal-dialog"),t=v(e||"body");let n=this.options.extraHeight;typeof n=="string"&&(n[0]==="+"&&(n=(e?".modal-header,.modal-footer,.search-form,36,#featureBar,":"#header,#mainMenu,#mainNavbar,.search-form,")+n.slice(1)),n=n.split(",")),Array.isArray(n)||(n=[n]);const s=n.reduce((o,a)=>a?typeof a=="number"||/^\d+$/.test(a)?o+Number(a):o+(t.find(a).outerHeight()||0):o,0);return Math.min(i,window.innerHeight-(e?64:1)-s)}},options(i){var l;const{checkable:e,footToolbar:t,footPager:n,footer:s}=i;if(s===void 0){const c=[];if(e&&c.push("checkbox"),t){const h=Array.isArray(t)?{items:t}:t;c.push("toolbar"),h.btnProps=v.extend({btnType:"primary",size:"sm"},h.btnProps),typeof h=="object"&&(typeof h.items=="function"&&(h.items=h.items.call(this)),Array.isArray(h.items)&&h.items.forEach(d=>{if((d==null?void 0:d.type)==="dropdown"){const f=d.menu||d["data-menu"];f&&f.searchBox&&(f.searchPlacement===void 0&&(f.searchPlacement="bottom"),f.maxHeight||(f.maxHeight=480))}})),i.footToolbar=h}e&&c.push("checkedInfo"),n&&c.push("flex","pager"),c.length&&(i.footer=c)}const r={"data-load":"table","data-selector":"dtable","data-target":i.id,...i.loadOptions},o=i.loadPartial||((l=this.parent||this.element)==null?void 0:l.closest(".modal"));o&&(r["data-partial"]=!0),n&&(n.btnProps=v.extend({type:"ghost",size:"sm"},n.btnProps),n.items&&!i.localPager&&n.items.forEach(c=>{c.type==="size-menu"?v.extend(!0,c,{itemProps:o?{...r,...c.itemProps}:{"data-app":"current",...c.itemProps},placement:"top"}):c.type==="link"&&v.extend(c,r)}));let{sortLink:a}=i;if(a&&(typeof a=="string"&&(a={url:a}),typeof a=="object"&&(a=v.extend(r,a)),i.sortLink=a),i.customCols){i.colResize===void 0&&(i.colResize=!0),i.sortCol===void 0&&(i.sortCol=!0);const c=()=>{this.trySaveColsSetting()};i.sortCol&&!i.onSortColEnd&&(i.onSortColEnd=c),i.colResize&&!i.on&&(i.onColResize=c),i.customCol===void 0&&(i.customCol=!0),i.customCol&&(i.onSetColBorder||(i.onSetColBorder=c),i.onSetColVisibility||(i.onSetColVisibility=c),i.canSetColVisibility||(i.canSetColVisibility=h=>{const d=this.getColInfo(h);return!d||d.side!=="center"?!1:this.layout.cols[d.side].list.length>1}))}return i},i18n:{zh_cn:{unassigned:"未指派"},zh_tw:{unassigned:"未指派"},en:{unassigned:"Unassigned"}},colTypes:{id:{width:60,fixed:"left",align:"center",sortType:!0,maxWidth:120},checkID:{width:80,fixed:"left",align:"left",sortType:!0,checkbox:!0,maxWidth:160},title:{width:.44,fixed:"left",align:"left",sortType:!0,flex:1,hint:!0,maxWidth:600},shortTitle:{width:.2,align:"left",sortType:!0,fixed:"left",checkbox:!0,flex:1,hint:!0,maxWidth:250},nestedTitle:{width:.5,align:"left",sortType:!0,fixed:"left",flex:1,nestedToggle:!0,nestedIndent:20,hint:!0,maxWidth:650},shortNestedTitle:{width:.33,align:"left",sortType:!0,fixed:"left",flex:1,nestedToggle:!0,nestedIndent:20,hint:!0,maxWidth:300},status:{width:80,align:"center",sortType:!0,onRenderCell(i,{col:e,row:t}){var o,a;const n=(o=t.data)==null?void 0:o[e.name];let s,r;return typeof n=="string"?(s=n,r=(a=e.setting.statusMap)==null?void 0:a[n]):typeof n=="object"&&n&&({name:s,label:r}=n),i[0]=g("span",{class:`${e.setting.statusClassPrefix??"status-"}${s}`},r??s),i}},user:{width:80,align:"center",sortType:!0,onRenderCell(i,{col:e,row:t,value:n}){const{userMap:s=this.options.userMap,userJoiner:r=" "}=e.setting;if(Array.isArray(n))i[0]=n.map(o=>rf(o,t,s)).filter(Boolean).join(r);else{const o=rf(n,t,s);o!==void 0&&(i[0]=o)}return i}},assign:{width:108,align:"left",sortType:!0,cellClass:"px-1.5",onRenderCell(i,e){const{col:t,row:n,value:s}=e,{options:r}=this,{userMap:o=r.userMap,currentUser:a=r.currentUser,assignLink:l,unassignedText:c=r.unassignedText||this.i18n("unassigned")}=t.setting,h=!s,d=s==="closed",f=h?c:rf(s,n,o)??s;return i[0]=l?qu.call(this,l,e,[g("i",{className:"icon icon-hand-right"}),g("span",null,f)],{"data-toggle":d?void 0:"modal",className:`dtable-assign-btn${a===s?" is-me":""}${h?" is-unassigned":""}${d?" disabled":""}`}):f,i}},avatar:{width:44,align:"center",sortType:!0},avatarName:{width:108,align:"left",sortType:!0},avatarBtn:{width:108,align:"left",sortType:!0},category:{width:80,align:"center",flex:1,hint:!0},desc:{width:160,align:"left",flex:1,hint:!0},text:{width:136,align:"left",flex:1,hint:!0},icon:{width:52,align:"center",cellClass:"px-1",onRenderCell(i,{row:e,col:t,value:n}){const{iconRender:s}=t.setting,r=J_(s,n,e);return r&&(i[0]=r),i}},pri:{width:68,align:"center",cellClass:"px-1",sortType:!0,onRenderCell(i,{col:e,value:t}){const{priList:n=this.options.priList||{}}=e.setting,s=n[t]??t;return i[0]=g($v,{pri:t,text:s}),i}},severity:{width:92,align:"center",cellClass:"px-1",sortType:!0,onRenderCell(i,{col:e,value:t}){const{severityList:n=this.options.severityList||{}}=e.setting,s=n[t]??t;return i[0]=g(Dv,{severity:t,text:s}),i}},burn:{width:88,align:"center",onRenderCell(i,{col:e}){const t=i[0];if(!t)return i;const{burn:n}=e.setting,s={data:t,className:"border-b",width:64,height:24,responsive:!1,...n};return i[0]=g(eu,{...s}),i}},date:{width:96,align:"center",sortType:!0},time:{width:64,align:"center",sortType:!0},datetime:{width:128,align:"center",sortType:!0},progress:{width:64,align:"center",sortType:!0},money:{width:96,align:"right",sortType:!0},count:{width:92,align:"right",sortType:!0},number:{width:64,align:"center",sortType:!0,digits:-1},percent:{width:64,align:"center",sortType:!0,format(i){return typeof i=="string"&&i.endsWith("%")?i:`${i}%`}},actions:{minWidth:120,align:"left",fixed:"right"}},methods:{trySaveColsSetting(){this.data.saveColsSettingTimer&&clearTimeout(this.data.saveColsSettingTimer),this.data.saveColsSettingTimer=window.setTimeout(()=>{this.saveColsSetting(),this.data.saveColsSettingTimer=0},200)},getColsSetting(){const{colOrders:i,colsSizes:e,colBorders:t,colVisibility:n}=this.state,s={},r=(o,a)=>{const l=s[o];l?Object.assign(l,a):s[o]={id:o,...a}};return i&&Object.keys(i).forEach(o=>{r(o,{order:i[o]})}),e&&Object.keys(e).forEach(o=>{r(o,{extraWidth:e[o]})}),t&&Object.keys(t).forEach(o=>{r(o,{border:t[o]})}),n&&Object.keys(n).forEach(o=>{r(o,{show:n[o]})}),Object.values(s)},async saveColsSetting(){const i=this.getColsSetting();if(!i.length)return;const{saveFieldsUrl:e}=this.options.customCols||{};if(!e)return;const t=JSON.stringify(i);t!==this.data.lastSavedColsSetting&&(this.data.lastSavedColsSetting=t,await v.post(e,{fields:t}))}},onRenderCell(i,{row:e,col:t,value:n}){const{iconRender:s}=t.setting;if(s&&t.type!=="icon"){const r=J_(s,n,e);r&&i.push(r)}return i},onRender(){const{customCols:i}=this.options;if(!i)return;const{custom:e,setGlobal:t,reset:n,resetGlobal:s}=i;return{children:g("div",{className:"absolute gap-1.5 pr-1.5 top-0 right-0 z-20 row items-center",style:"background:var(--dtable-header-bg);height: calc(var(--dtable-header-height) - 2px)"},g("div",{className:"w-px border-l h-5"}),g("a",{className:"btn ghost square size-sm rounded","data-toggle":"dropdown","data-placement":"bottom-end"},g("i",{class:"icon icon-cog-outline"})),g("menu",{class:"dropdown-menu menu"},e&&g("li",{class:"menu-item"},g("a",{href:e.url,"data-toggle":"modal"},e.text)),t&&g("li",{class:"menu-item"},g("a",{class:"ajax-submit",href:t.url},t.text)),n&&g("li",{class:"menu-item"},g("a",{class:"ajax-submit",href:n.url},n.text)),s&&g("li",{class:"menu-item"},g("a",{class:"ajax-submit",href:s.url},s.text))))}},onUpdated(){const{updateCheckedRows:i}=this.options;i&&i!==this.data.updateCheckedRows&&(this.data.updateCheckedRows=i,this.toggleCheckRows(i,!0))}},{buildIn:!0});const eE="",Co=i=>`${i.col.name}[${i.row.id}]`,xo=(i,e,t,n="value")=>{const s=Co(e),r=i.data.formData[s]??e.value;return{[n]:r,className:"form-control",onChange:o=>i.setFormData(s,o instanceof Event?o.currentTarget.value:o),...t}};function of(i){const e=Co(i);let t=this.data.pickRefs.get(e);return t||(t=pe(),this.data.pickRefs.set(e,t)),xo(this,i,{ref:t},"defaultValue")}const GT={input:{component:"input",props(i){return xo(this,i,{type:"text"})}},select:{component:function(i){const{items:e,defaultValue:t,...n}=i;return g("select",{...n},e.map(s=>g("option",{key:s.value,value:s.value},s.text)))},props(i){return xo(this,i)}},picker:{component:Zt,props:of},datePicker:{component:Hi,props(i){return xo(this,i,{className:"flex-auto",icon:"calendar"},"defaultValue")}},timePicker:{component:qa,props(i){return xo(this,i,{className:"flex-auto",icon:"time"},"defaultValue")}},priPicker:{component:co,props:of},severityPicker:{component:bu,props:of}};et({name:"form",plugins:[k_],data(){return{formData:{},pickRefs:new Map}},colTypes:{control:{custom(i){let{control:e}=i.col.setting;if(typeof e=="function"&&(e=e.call(this,i)),!e)return;typeof e=="string"&&(e={type:e});const{controlMap:t}=this.options,{type:n}=e,s={name:Co(i)};let r;if([GT[n],t==null?void 0:t[n],e].forEach(o=>{if(o){const{props:a}=o;a&&v.extend(s,typeof a=="function"?a.call(this,i):a),r=o.component||r}}),!!r)return{component:r,props:s}}}},methods:{setFormData(i,e,t){var r,o;const{formData:n}=this.data;n[i]=e,t||(r=this.options.onFormChange)==null||r.call(this,i,e,n);const s=this.data.pickRefs.get(i);s&&((o=s.current)==null||o.setValue(e))},getFormData(i=!0){let{formData:e}=this.data;if(!i)return e;const{rows:t,cols:n}=this.layout,s=t.reduce((r,o)=>(n.list.forEach(a=>{var l;a.setting.control&&(r[Co({col:a,row:o})]=(l=o.data)==null?void 0:l[a.name])}),r),{});return e=v.extend(s,e),i===!0?e:e[i]},resetFormData(){this.data.formData={};const{rows:i,cols:e}=this.layout;i.forEach(t=>{e.list.forEach(n=>{var r,o;if(!n.setting.control)return;const s=this.data.pickRefs.get(Co({col:n,row:t}));s&&((o=s.current)==null||o.setValue(((r=t.data)==null?void 0:r[n.name])??""))})})}}});function af(i,e){return Object.entries(e).reduce((t,[n,s])=>{const r=t[n];return r?s===void 0?delete t[n]:Object.keys(s).forEach(o=>{const a=s[o];a===void 0?delete r[o]:r[o]=a}):s!==void 0&&(t[n]=s),t},i)}function ko(i){return Object.entries(i).reduce((e,[t,n])=>(e&&typeof n=="object"&&(e[t]={...n}),e),{})}const X_=et({name:"draft",defaultOptions:{draft:!0,selectAllOnFocus:!0,history:20},when:i=>!!i.draft,state(){return{stagingDraft:{},appliedDraft:{}}},methods:{getCellDraftValue(i,e){const t=this.getRowInfo(i);if(!t)return;const n=this.getColInfo(e);if(!n)return;const{id:s}=t,{name:r}=n,o=this.state.stagingDraft[s];if(o&&r in o)return o[r];const a=this.state.appliedDraft[s];return a&&r in a?a[r]:this.getCellValue(t,n)},getRowDraftData(i,e){const t=this.getRowInfo(i);return t?this.layout.cols.list.reduce((n,s)=>{if(!(e!=null&&e.includeIndexCol)&&s.name==="INDEX")return n;const r=this.getCellDraftValue(t,s);return n[s.name]=r===void 0?e==null?void 0:e.emptyCellValue:r,n},{}):{}},getColDraftData(i,e){const t=this.getColInfo(i);return t?this.layout.rows.reduce((n,s)=>{const r=this.getCellDraftValue(s,t);return n[s.id]=r===void 0?e==null?void 0:e.emptyCellValue:r,n},e!=null&&e.includeHeaderRow?{HEADER:this.getCellDraftValue("HEADER",t)}:{}):{}},stageDraft(i,e){var r;const{stagingDraft:t}=this.state;if(((r=this.options.onStageDraft)==null?void 0:r.call(this,i,t))===!1)return;const n=ko(t);af(t,i);const s=()=>{var o,a;(o=e==null?void 0:e.callback)==null||o.call(e,i),(a=this.options.afterStageDraft)==null||a.call(this,i,this.state.stagingDraft,n,{skipUpdate:!!(e!=null&&e.skipUpdate)})};e!=null&&e.skipUpdate?s():this.update(s)},applyDraft(i,e){const{stagingDraft:t,appliedDraft:n}=this.state,s=ko(n);Object.entries(i).forEach(([o,a])=>{const l=t[o];l&&typeof a=="object"&&(a===null?delete t[o]:Object.keys(a).forEach(h=>{l[h]===a[h]&&delete l[h]}),Object.keys(l).length||delete t[o]);const c=n[o];c?a===null?delete n[o]:Object.assign(c,a):a!==null&&(n[o]=a)});const r=()=>{var o,a;(o=e==null?void 0:e.callback)==null||o.call(e,i),(a=this.options.afterApplyDraft)==null||a.call(this,i,this.state.appliedDraft,s)};e!=null&&e.skipUpdate?r():this.forceUpdate(r)},renderDraftCell(i,{col:e,row:t}){let n=this.getCellDraftValue(t,e)??"";return typeof n=="string"&&!n.length&&t.id==="HEADER"&&(n=e.name),i[0]={children:n,attrs:{title:n}},i}},onRenderCell(i,...e){return this.options.skipRenderDraftCell?i:this.renderDraftCell(i,...e)},onRenderHeaderCell(i,...e){return this.options.skipRenderDraftCell?i:this.renderDraftCell(i,...e)}}),sE="";function Q_(i,e,t){return i.every(n=>e[n]===t[n])}const ZT=et({name:"editable",plugins:[X_],defaultOptions:{editable:!0,selectAllOnFocus:!0,history:20,skipRenderDraftCell:!0,emptyCellValue:""},when:i=>!!i.editable,events:{dblclick(i){this.editCell(this.getPointerInfo(i))},click(i){const e=this.getPointerInfo(i);e&&e.cellElement.classList.contains("is-selected")&&this.editCell(e)}},data(){return{editingInputRef:pe()}},methods:{isCellEditing(i,e){const{editingCell:t}=this.state;return!!t&&t.rowID===i&&t.colName===e},editCell(i){const{editable:e,headerEditable:t}=this.options;i&&(typeof e=="function"&&!e(i.rowID,i.colName)||!t&&i.rowID==="HEADER")&&(i=void 0),this.data.editingInputRef.current=null,this.data.needAutoFocus=!0,this.setState({editingCell:i?{colName:i.colName,rowID:i.rowID}:void 0})},deleteCells(i){const e={},{emptyCellValue:t}=this.options;return i.forEach(n=>{const s=e[n.rowID];s?s[n.colName]=t:e[n.rowID]={[n.colName]:t}}),Object.keys(e).length?(this.stageDraft(e),!0):!1},deleteRows(i,e){Array.isArray(i)||(i=[i]);const t=this.layout.cols.list.reduce((d,f)=>(f.name!=="HEADER"&&d.push(f.name),d),[]),n=i.reduce((d,f)=>{const p=this.getRowInfo(f);return p&&p.id!=="HEADER"&&d.push(p),d},[]).sort((d,f)=>d.index-f.index);if(!n.length)return;const s=new Set(n.map(d=>d.index)),r=new Map,o=this.layout.rows,a=o.length,{emptyCellValue:l}=this.options;let c=n[0].index;for(let d=c+1;d<a;d++){if(s.has(d))continue;const f=o[d];r.set(c,this.getRowDraftData(f,{emptyCellValue:l})),c++}const h={};c=n[0].index;for(let d=c;d<a;d++){const f=o[d],p=this.getRowDraftData(f,{emptyCellValue:l}),y=r.get(d)||{};Q_(t,p,y)||(h[f.id]=y)}Object.keys(h).length&&this.stageDraft(h,{skipUpdate:e==null?void 0:e.skipUpdate})},deleteCols(i,e){Array.isArray(i)||(i=[i]);const t=i.reduce((d,f)=>{const p=this.getColInfo(f);return p&&p.name!=="INDEX"&&d.push(p),d},[]).sort((d,f)=>d.index-f.index);if(!t.length)return;const n=new Set(t.map(d=>d.index)),s=new Map,{cols:{list:r}}=this.layout,o=r.length,a=this.layout.rows.reduce((d,f)=>(d.push(f.id),d),["HEADER"]),{emptyCellValue:l}=this.options;let c=t[0].index;for(let d=c+1;d<o;d++){if(n.has(d))continue;const f=r[d];s.set(c,this.getColDraftData(f,{emptyCellValue:l,includeHeaderRow:!0})),c++}const h={};c=t[0].index;for(let d=c;d<o;d++){const f=r[d],p=this.getColDraftData(f,{emptyCellValue:l,includeHeaderRow:!0}),y=s.get(d)||{};if(!Q_(a,p,y))for(const b of a)h[b]||(h[b]={}),h[b][f.name]=y[b]??l}Object.keys(h).length&&this.stageDraft(h,{skipUpdate:e==null?void 0:e.skipUpdate})},handleEditingInputChange(i){var o,a;const e=(o=i.target)==null?void 0:o.value,{editingCell:t}=this.state;if(typeof e!="string"||!t)return;const{rowID:n,colName:s}=t,r=this.getCellDraftValue(n,s);r!==e&&((a=this.options.onEditCell)==null?void 0:a.call(this,{rowID:n,colName:s,value:e,oldValue:r}))!==!1&&this.stageDraft({[n]:{[s]:e}})},handleEditingInputBlur(){this.editCell()},handleEditingKeyDown(i){var e;i.key==="Enter"?(e=this.data.editingInputRef.current)==null||e.blur():i.key==="Esc"&&this.editCell()},renderEditableCell(i,e,t,n){const{col:s,row:r}=e,{id:o}=r;if(this.isCellEditing(o,s.name)){const a=`${this.getCellDraftValue(o,s.name)??""}`;return[{outer:!0,className:"is-editing",children:k("input",{ref:this.data.editingInputRef,class:"dtable-editing-input",type:"text",defaultValue:a,style:{textAlign:s.setting.align},onChange:this.handleEditingInputChange,onBlur:this.handleEditingInputBlur,onKeyDown:this.handleEditingKeyDown,onPaste:this.options.onPasteToCell})}]}return this.renderDraftCell(i,e,t,n)}},onUpdated(){const i=this.data.editingInputRef.current;i&&this.data.needAutoFocus&&(this.data.needAutoFocus=!1,i.focus({preventScroll:!0}),this.options.selectAllOnFocus&&i.select())},onRender(){return{className:{"dtable-editable":this.options.editable,"dtable-editing":this.state.editingCell}}},onRenderCell(...i){return this.renderEditableCell(...i)},onRenderHeaderCell(...i){return this.renderEditableCell(...i)}}),rE="",YT=/C(\d+)R(\d+)/i,JT=/(?:C(\d+))?(?:R(\d+))?/i;function eb(i){const e=YT.exec(i);if(!e||e.length<3)return;const[,t,n]=e;return{col:+t,row:+n}}function lf(i){const e=JT.exec(i);if(!e)return;const[,t=-1,n=-1]=e,s=+t,r=+n;return{col:s,row:r}}function cf(i){const e=[],t=lf(i);if(!t)return e;const{col:n,row:s}=t;if(n>=0)if(s>=0)e.push({col:n,row:s});else{const r=this.layout.rows.length;for(let o=0;o<r;o++)e.push({col:n,row:o})}else if(s>=0){const{cols:r}=this.layout,o=r.list.length;for(let a=0;a<o;a++)e.push({col:a,row:s})}return e}function tb(i){const[e,t]=i.split(":");if(e){if(!t)return cf.call(this,e)}else return t?cf.call(this,t):[];const n=lf(e),s=lf(t);if(!n||!s)return[];const r=Math.min(n.col,s.col),o=Math.max(n.col,s.col),a=Math.min(n.row,s.row),l=Math.max(n.row,s.row),c=[],h=Object.keys(this.layout.cols.map).length;for(let d=r;d<=o;d++)if(a<0||l<0){const f=this.layout.rows.length;for(let p=0;p<f;p++)c.push({col:d,row:p})}else for(let f=a;f<=l;f++)if(d<0)for(let p=0;p<h;p++)c.push({col:p,row:f});else c.push({col:d,row:f});return c}function XT(i){return i.reduce((e,t)=>(typeof t=="object"?e.push(t):t.includes(":")?e.push(...tb.call(this,t)):e.push(...cf.call(this,t)),e),[])}function hf(i,e){const{col:t,row:n}=i,s=[];if(t>=0&&s.push(`C${t}`),n>=0&&s.push(`R${n}`),e){const r=hf(e);r&&s.push(":",r)}return s.join("")}function df(i,e){const{selectable:t}=i.options;return typeof t=="function"?t.call(i,e):!!t}function uf(i,e={}){var f;Array.isArray(i)||(i=[i]);let t=XT.call(this,i);const n=(f=this.options.beforeSelectCells)==null?void 0:f.call(this,t);n&&(t=n);const{clearBefore:s=!0,deselect:r,selecting:o,callback:a}=e,{selectingMap:l,selectedMap:c}=this.state,h=o?l:c;l.clear(),s&&c.clear();let d=!1;return r?t.forEach(p=>{if(!df(this,p))return;const{col:y,row:b}=p,w=h.get(y);w&&(w.delete(b),w.size||h.delete(y)),d=!0}):t.forEach(p=>{if(!df(this,p))return;const{col:y,row:b}=p,w=h.get(y);w?w.add(b):h.set(y,new Set([b])),d=!0}),d?(this.update({},()=>{var p;a==null||a.call(this,t),(p=this.options.onSelectCells)==null||p.call(this,t)}),t):[]}function QT(i){const{selectedMap:e}=this.state;let t=-1,n=-1;for(const[s,r]of e.entries()){n=n<0?s:Math.min(s,n);const o=Math.min(...r);t=t<0?o:Math.min(o,t)}if(!(t<0||n<0)&&(i==="down"?t++:i==="up"?t--:i==="left"?n--:n++,t>=0&&n>=0&&t<this.layout.rows.length&&n<this.layout.cols.list.length)){const s={col:n,row:t};if(df(this,s))return this.scrollTo(s),this.selectCells([s]),s}}function e$(i,e){return uf.call(this,i,{...e,selecting:!0})}function t$(i,e){return uf.call(this,i,{...e,deselect:!0})}function n$(){const{cols:i}=this.layout,e=i.list.length,t=this.layout.rows.length,{selectedMap:n}=this.state,s=typeof this.options.selectable=="function"?this.options.selectable:!1;for(let r=0;r<e;r++){let o=n.get(r);o||(o=new Set,n.set(r,o));for(let a=0;a<t;a++)s&&!s({row:a,col:r})||o.add(a)}this.forceUpdate()}function s$(){const{selectedMap:i}=this.state;return i.size?(i.clear(),this.forceUpdate(),!0):!1}function i$(i){var t;const e=typeof i=="string"?eb(i):i;return e?((t=this.state.selectedMap.get(e.col))==null?void 0:t.has(e.row))??!1:!1}function nb(i,e){for(const[,t]of i.state.selectedMap.entries())if(t.has(e))return!0;for(const[,t]of i.state.selectingMap.entries())if(t.has(e))return!0;return!1}function r$(i){var t;const e=(t=this.getRowInfo(i))==null?void 0:t.index;return typeof e!="number"?!1:this.layout.cols.list.every(n=>n.name==="INDEX"||this.isCellSelected({col:n.index,row:e}))}function o$(i){var n;const e=(n=this.getColInfo(i))==null?void 0:n.index;if(typeof e!="number")return!1;const{rows:t}=this.layout;return t.every(s=>this.isCellSelected({col:e,row:s.index}))}function sb(i,e){var t,n;return!!((t=i.state.selectedMap.get(e))!=null&&t.size||(n=i.state.selectingMap.get(e))!=null&&n.size)}function a$(i){var t;const e=typeof i=="string"?eb(i):i;return e?((t=this.state.selectingMap.get(e.col))==null?void 0:t.has(e.row))??!1:!1}function l$(){const i=[];for(const[e,t]of this.state.selectedMap.entries())for(const n of t)i.push({col:e,row:n});return i}function c$(){const i=[];for(const[t,n]of this.state.selectedMap.entries())n.size&&i.push(t);return[...new Set(i)].map(t=>this.getColInfo(t)).filter(t=>t&&this.isColSelected(t)).sort((t,n)=>t.index-n.index)}function h$(){const i=[];for(const[,t]of this.state.selectedMap.entries())i.push(...t);return[...new Set(i)].map(t=>this.getRowInfo(t)).filter(t=>t&&this.isRowSelected(t)).sort((t,n)=>t.index-n.index)}function d$(){let i=0;for(const e of this.state.selectedMap.values())i+=e.size;return i}function ff(i,e,t){var c,h;const n=i.getPointerInfo(e);if(!n||n.target.closest("input,textarea,[contenteditable]"))return;const{rowID:s,colName:r}=n,o=((c=i.getColInfo(r))==null?void 0:c.index)??-1;if(o<0)return;const a=s==="HEADER";if(a&&(t!=null&&t.ignoreHeaderCell))return;const l=a?-1:((h=i.getRowInfo(s))==null?void 0:h.index)??-1;return{col:o,row:l}}const u$=et({name:"selectable",defaultOptions:{selectable:!0,markSelectRange:!0},when:i=>!!i.selectable,plugins:[mo],state(){return{selectedMap:new Map,selectingMap:new Map}},methods:{selectCells:uf,selectNextCell:QT,selectingCells:e$,deselectCells:t$,isCellSelected:i$,isCellSelecting:a$,isRowSelected:r$,isColSelected:o$,hasCellSelectInRow:nb,hasCellSelectInCol:sb,getSelectedCols:c$,getSelectedRows:h$,getSelectedCells:l$,selectAllCells:n$,deselectAllCells:s$,getSelectedCellsSize:d$},events:{mousedown(i){if(this.data.disableSelectable)return;const e=ff(this,i);i.button!==0&&(!e||this.isCellSelected(e)||e.row<0&&this.isColSelected(e.col)||e.col<1&&this.isRowSelected(e.row))||(this.data.selectingStart=e,this.startScrollToMouse(),e&&i.stopPropagation())},document_mouseup(i){const{selectingStart:e}=this.data;if(this.stopScrollToMouse(),!e)return;this.data.selectingStart=void 0;const t=ff(this,i);if(t){const n=hf(e,t);n&&(requestAnimationFrame(()=>this.selectCells(n)),i.stopPropagation())}},document_click(i){const e=i.target;if(!e)return;const{ignoreDeselectOn:t}=this.options;e.closest(`#${this.id}${t?`,${t}`:""}`)||this.deselectAllCells()},mousemovesmooth(i){const e=this,{selectingStart:t}=e.data;if(!t)return;const n=ff(e,i);if(!n)return;const s=hf(t,n);s&&(e.selectingCells(s),i.preventDefault(),i.stopPropagation())}},onRender(){if(this.options.selectable)return{className:"dtable-selectable"}},onRenderCell(i,{row:e,col:t}){const n=this.getRowInfo(e.id);if(!n)return i;const s={col:t.index,row:n.index};return this.isCellSelecting(s)?i.push({outer:!0,className:"is-select is-selecting"}):this.isCellSelected(s)&&i.push({outer:!0,className:"is-select is-selected"}),this.options.markSelectRange&&t.name==="INDEX"&&(this.isRowSelected(n)?i.push({outer:!0,className:"is-row-selected has-cell-selected"}):nb(this,n.index)&&i.push({outer:!0,className:"has-cell-selected"})),i},onRenderHeaderCell(i,{col:e}){return this.options.markSelectRange&&e.name!=="INDEX"&&sb(this,e.index)&&(i.push({outer:!0,className:"has-cell-selected"}),this.isColSelected(e)&&i.push({outer:!0,className:"is-col-selected"})),i}}),f$=et({name:"hotkey",when:i=>!!i.hotkeys,onMounted(){const{hotkeys:i}=this.options;if(!i)return;const e={};if(Object.keys(i).forEach(n=>{const s=i[n];n.split(",").forEach(r=>{r=r.trim(),r.length&&(e[r]=s)})}),!Object.keys(e).length)return;const t=`dtable_${this.id}`;v(this.element).hotkeys(e,{scope:t}),this.data.hotkeysScope=t},onUnmounted(){this.data.hotkeysScope&&v(this.element).unbindHotkeys(this.data.hotkeysScope)}});function lc(i,e){const t=new Set([...Object.keys(i),...Object.keys(e)]);return Array.from(t).reduce((n,s)=>{const r=i[s]||{},o=e[s]||{};if(r===o)return n;const a=new Set([...Object.keys(r),...Object.keys(o)]),l={};let c=!1;return a.forEach(h=>{const d=r[h],f=o[h];d!==f&&(l[h]=d,c=!0)}),c&&(n[s]=l),n},{})}const p$=et({name:"history",plugins:[D_,X_],defaultOptions:{history:!0,historyTarget:"staging",historyThreshold:10},when:i=>!!i.history,options(i){const{afterApplyDraft:e,afterStageDraft:t,historyTarget:n,history:s}=i;return{afterApplyDraft:s&&n==="applied"?(r,o,a)=>{e&&e.call(this,r,o,a),this.addHistory({after:lc(o,a),before:lc(a,o)})}:e,afterStageDraft:s&&n!=="applied"?(r,o,a,l)=>{t&&t.call(this,r,o,a,l),this.addHistory({after:lc(o,a),before:lc(a,o)})}:t}},data(){return{historyIdx:1}},state(){return{historyCursor:0,historyItems:[]}},methods:{addHistory(i){let{historyCursor:e,historyItems:t}=this.state;e>0&&(t.splice(0,e).forEach(r=>{typeof r=="number"&&this.data.store.session.remove(`HISTORY:${this.id}:${r}`)}),e=0),t=[i,...t];const{historyThreshold:n}=this.options;if(n&&t.length>n)for(let s=n;s<t.length;s++){const r=t[s];if(typeof r=="number")break;const o=this.data.historyIdx++;this.data.store.session.set(`HISTORY:${this.id}:${o}`,r),t[s]=o}this.setState({historyCursor:e,historyItems:t})},getHistory(i){if(typeof i=="object")return i;const{historyCursor:e,historyItems:t}=this.state;i===void 0&&(i=e);const n=t[i];return typeof n=="number"?this.data.store.session.get(`HISTORY:${this.id}:${n}`):n},applyHistory(i,e,t){const n={historyCursor:i},s=this.options.historyTarget==="applied",{appliedDraft:r,stagingDraft:o}=this.state,a=ko((s?r:o)??{});s?n.appliedDraft=af(r,e):n.stagingDraft=af(o,e),this.setState(n,()=>{var c;t==null||t();const l=Object.entries(e).reduce((h,[d,f])=>{if(f){const p={};Object.entries(f).forEach(([y,b])=>{p[y]=b===void 0?this.getCellDraftValue(d,y):b}),h[d]=p}return h},{});(c=this.options.onHistoryApplied)==null||c.call(this,l,s?r:o??{},a)})},undoHistory(i){if(!this.canUndoHistory())return!1;const{historyCursor:e}=this.state,t=this.getHistory(e);return t?(this.applyHistory(e+1,ko(t.before),i),!0):!1},redoHistory(i){if(!this.canRedoHistory())return!1;const{historyCursor:e}=this.state,t=this.getHistory(e-1);return t?(this.applyHistory(e-1,ko(t.after),i),!0):!1},canUndoHistory(){const{historyCursor:i,historyItems:e}=this.state;return e.length>0&&i<e.length},canRedoHistory(){return this.state.historyCursor>0}}}),cE="";function m$(i,e){const{colsCount:t,rowsCount:n}=i.getGridSize(),{cols:s=[]}=e,{showRowIndex:r,defaultColWidth:o}=i.options,a=[];r!==!1&&a.push({width:`${n+1}`.length*8+24,name:"INDEX",fixed:"left",align:"right",title:"#",...s.find(l=>l.name==="INDEX")});for(let l=0;l<t;++l){const c=`C${l+1}`,h={name:c,width:o,...s.find(d=>d.name===c)};a.push(h)}return{cols:a,data:n}}function g$(i,e,t){var n,s;return e.name==="INDEX"?i.id==="HEADER"?t:i.index+1:i.id!=="HEADER"?(s=(n=this.options.datasource.data)==null?void 0:n[+i.id])==null?void 0:s[+e.name.replace("C","")-1]:t}function cc(i,e,t){i.selectNextCell(t)&&(e.preventDefault(),e.stopPropagation())}const y$={delete(i){v(i.target).is("input,textarea")||this.deleteSelections()},cut(){this.cutSelections()},selectAll(i){this.state.editingCell||(this.selectAllCells(),i.preventDefault())},paste(){this.pasteToSelection()},copy(i){this.copySelections(),i.preventDefault()},focus(){const i=this.getSelectedCells()[0];if(!i)return;const e=this.getColInfo(i.col),t=this.getRowInfo(i.row);!e||!t||this.editCell({rowID:t.id,colName:e.name})},cancel(){this.deselectAllCells()},undo(){this.undoHistory()},redo(){this.redoHistory()},selectRight(i){cc(this,i,"right")},selectLeft(i){cc(this,i,"left")},selectDown(i){cc(this,i,"down")},selectUp(i){cc(this,i,"up")}};function ib(i,e){Array.isArray(i)||(i=[i]);let t=0,n=0;const s=e==null?void 0:e.ignoreEmptyCell;return i.forEach(r=>{Object.entries(r).forEach(([o,a])=>{o!=="HEADER"&&(t=Math.max(t,+o+1),n=Math.max(n,...Object.keys(a).map(l=>s&&rb(a[l])||l[0]!=="C"?0:+l.replace("C",""))))})}),{maxRow:t,maxCol:n}}function v$(){const{minRows:i=1,minCols:e=1,extraRows:t=0,extraCols:n=0,datasource:s}=this.options,{data:r=[],cols:o=[]}=s,{stagingDraft:a,appliedDraft:l}=this.state,{maxRow:c,maxCol:h}=ib([a,l]);return{rowsCount:Math.max(c,r.length+t,i,this.data.rowsCount??0),colsCount:Math.max(h,e,o.length,r.reduce((d,f)=>Math.max(d,f.length),0)+n,this.data.colsCount??0)}}function _$(i=1,e){const{rowsCount:t}=this.getGridSize();let n=t;return typeof i=="number"?n=t+Math.max(i,0):Array.isArray(i)&&(n=t+Math.max(i.length,0),this.stageDraft(i.reduce((s,r,o)=>(Array.isArray(r)&&(r=r.reduce((a,l,c)=>(a[`C${c+1}`]=l,a),{})),s[t+o]=r,s),{}),{skipUpdate:!0})),n>t?(this.data.rowsCount=n,e!=null&&e.skipUpdate||this.update({dirtyType:"options"},()=>{(e==null?void 0:e.select)!==!1&&this.selectCells(`R${t}:R${n-1}`),(e==null?void 0:e.autoScroll)!==!1&&this.scrollTo({row:n-1,col:0})}),!0):!1}function b$(i=1,e){const{colsCount:t}=this.getGridSize();let n=t;const{showRowIndex:s}=this.options;return typeof i=="number"?n=t+Math.max(i,0):Array.isArray(i)&&(n=t+Math.max(i.length,0),this.stageDraft(i.reduce((r,o,a)=>(o.forEach((l,c)=>{const h=r[c],d=`C${t+a+(s?1:0)}`;h?h[d]=l:r[c]={[d]:l}}),r),{}),{skipUpdate:!0})),n>t?(this.data.colsCount=n,e!=null&&e.skipUpdate||this.update({dirtyType:"options"},()=>{(e==null?void 0:e.select)!==!1&&this.selectCells(`C${t+(s?1:0)}:C${n-1+(s?1:0)}`),(e==null?void 0:e.autoScroll)!==!1&&this.scrollTo({col:n-(s?0:1),row:0})}),!0):!1}function w$(i,e){const t=this.getGridSize(),n=Math.max(0,(i.rowsCount??0)-t.rowsCount),s=Math.max(0,(i.colsCount??0)-t.colsCount);return n&&this.appendRows(n,{skipUpdate:!0,select:!1}),s&&this.appendCols(s,{skipUpdate:!0,select:!1}),n||s?(e!=null&&e.skipUpdate||this.update({dirtyType:"options"}),!0):!1}function rb(i){return i==null||typeof i=="string"&&!i.length}function ob(i){let e=0,t=0;return i.forEach((n,s)=>{n.forEach((r,o)=>{rb(r)||(e=Math.max(e,o),t=Math.max(t,s))})}),i.slice(0,t+1).map(n=>n.slice(0,e+1))}et({name:"datagrid",plugins:[ZT,u$,f$,Z_,p$,Xu],defaultOptions:{defaultColWidth:80,headerEditable:!0,minRows:20,minCols:10,extraRows:5,extraCols:5,showRowIndex:!0,rowHover:!1,colHover:!1,cellHover:!0,bordered:!0,striped:!1,datagridHotkeys:{},cellValueSplitter:" ",cellValueGetter:g$,hotkeys:{},autoExpandGrid:!0},options(i){const{datagridHotkeys:e,datasource:t,hotkeys:n,editable:s,selectable:r,beforeSelectCells:o,showRowIndex:a,colResize:l,onPasteToCell:c,afterStageDraft:h}=i,d={delete:"Delete,Backspace",selectAll:"$mod+a",paste:"$mod+v",copy:"$mod+c",focus:"Enter",cancel:"Escape",cut:"$mod+x",redo:"$mod+Shift+z",undo:"$mod+z",selectRight:"Tab,ArrowRight",selectLeft:"ArrowLeft",selectDown:"ArrowDown",selectUp:"ArrowUp"};return{hotkeys:{...n,...Object.entries({...d,...e}).reduce((p,[y,b])=>{var w;return b&&(p[b===!0?d[y]:b]=(w=y$[y])==null?void 0:w.bind(this)),p},{})},colResize:l?p=>(typeof l!="function"||l.call(this,p))&&p!=="INDEX":!1,editable:s?(p,y)=>typeof s=="function"&&!s(p,y)?!1:y!=="INDEX":!1,selectable:r?p=>typeof r=="function"&&!r(p)?!1:p.col>=(a?1:0):!1,beforeSelectCells:a?p=>(p.every(y=>y.col===0)&&(p=tb.call(this,`R${Math.min(...p.map(y=>y.row))}:R${Math.max(...p.map(y=>y.row))}`)),o?o.call(this,p):p):o,...m$(this,t),onPasteToCell:p=>{var b;const y=(b=p.clipboardData)==null?void 0:b.getData("text");typeof y=="string"&&(y.includes(" ")||y.includes(`
  72. `))&&this.state.editingCell&&(this.pasteCells(this.state.editingCell,{data:y}),p.preventDefault()),c==null||c.call(this,p)},afterStageDraft:(p,y,b,w)=>{h==null||h.call(this,p,y,b,w);const{autoExpandGrid:x}=this.options;if(!x)return;const{maxCol:T,maxRow:D}=ib(y,{ignoreEmptyCell:!0}),{extraCols:N=1,extraRows:A=1}=this.options;this.expandGridSize({rowsCount:D+(typeof x=="number"?x:A),colsCount:T+(typeof x=="number"?x:N)},w)}}},methods:{deleteSelections(){const i=[];for(const[e,t]of this.state.selectedMap.entries()){const n=this.getColInfo(e);if(n)for(const s of t){const r=this.getRowInfo(s);r&&i.push({colName:n.name,rowID:r.id})}}return this.deleteCells(i)},deleteSelectedRows(){const i=this.getSelectedRows();return i.length?(this.deleteRows(i),this.deselectAllCells(),!0):!1},deleteSelectedCols(){const i=this.getSelectedCols();return i.length?(this.deleteCols(i),this.deselectAllCells(),!0):!1},copySelectedCols(){const i=this.getSelectedCols();if(!i.length)return!1;const e=this.layout.rows.length,t=[];for(let s=-1;s<e;++s)t.push(i.map(r=>{const o=this.getCellDraftValue(s,r);return s===-1&&o===r.name?"":o}));const n=ob(t).map(s=>s.join(" ")).join(`
  73. `);return navigator.clipboard.writeText(n),!0},clearSelectedCols(){const i=this.getSelectedCols();if(!i.length)return!1;const e={},{emptyCellValue:t}=this.options;return[this.getRowInfo("HEADER"),...this.layout.rows].forEach(n=>{const s={};i.forEach(r=>{const o=this.getCellDraftValue(n,r);o!=null&&o!==t&&(s[r.name]=t)}),Object.keys(s).length&&(e[n.id]=s)}),Object.keys(e).length?(this.stageDraft(e),!0):!1},async pasteToSelectedCol(){const i=this.getSelectedCols();return i.length?await this.pasteCells({colName:i[0].name,rowID:"HEADER"}):!1},cutSelectedCols(){return this.copySelectedCols(),this.clearSelectedCols()},copySelections(){const i=this.getSelectedCells();if(!i.length)return!1;let e=Number.MAX_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER;i.forEach(r=>{e=Math.min(r.col,e),t=Math.min(r.row,t)});const n=[];i.forEach(r=>{const o=this.getCellDraftValue(r.row,r.col);let a=n[r.row-t];a||(a=[],n[r.row-t]=a),a[r.col-e]=o});const s=ob(n).map(r=>r.join(" ")).join(`
  74. `);return navigator.clipboard.writeText(s),!0},cutSelections(){return this.copySelections(),this.deleteSelections()},async pasteCells(i,e){var f,p;let t=-1,n=-1;if("colName"in i){const y=this.getColInfo(i.colName),b=this.getRowInfo(i.rowID);if(!y||!b)return!1;t=y.index,n=b.index}else t=i.col,n=i.row;let s=e==null?void 0:e.data;if(s===void 0)try{const y="clipboard-read";if((await navigator.permissions.query({name:y})).state==="denied")return(f=this.options.onReadClipboardFail)==null||f.call(this),!1;s=await navigator.clipboard.readText()}catch{return(p=this.options.onReadClipboardFail)==null||p.call(this),!1}if(!s.length)return!1;const r={},o=[],a=(e==null?void 0:e.expandCells)!==!1;let l=!1,c=0,h=0;const d=s.split(/\r?\n/);return d.forEach((y,b)=>{var D;if(!y.trim().length&&b===d.length-1)return;const w=b+n;let x=(D=this.getRowInfo(w))==null?void 0:D.id;if(x===void 0){if(!a)return;l=!0,x=`${w}`}let T=r[x];T||(T={},r[x]=T),y.split(" ").forEach((N,A)=>{var K;const z=A+t;let O=(K=this.getColInfo(z))==null?void 0:K.name;if(O===void 0){if(!a)return;l=!0,O=`C${z}`}T[O]=N,o.push({col:z,row:w}),c=Math.max(c,w),h=Math.max(h,z)})}),this.stageDraft(r,{skipUpdate:!0}),(e==null?void 0:e.select)!==!1&&this.selectCells(o),this.update({dirtyType:l?"options":void 0},()=>{e!=null&&e.autoscroll&&this.scrollTo({col:h,row:c})}),!0},pasteToSelection(){const i=this.getSelectedCells();if(!i.length)return Promise.resolve(!1);const e=i[0];return this.pasteCells(e)},getGridSize:v$,appendRows:_$,appendCols:b$,expandGridSize:w$},onRender(){return{className:"dtable-datagrid"}}});const dE="",uE="",fE="",pE="",mE="",gE="",yE="",vE="",_E="",bE="",wE="",CE="",xE="",kE="",SE="";I.$=v,I.AIAgent=eo,I.AIChatView=Ml,I.AIChatsPanel=Jy,I.AIModelName=El,I.AIModelPicker=Nl,I.AIPanel=ni,I.AIPlugin=Pd,I.AIPopup=Xy,I.AIReactions=cy,I.AIStore=on,I.Ajax=Ir,I.AjaxForm=Wl,I.Avatar=Xh,I.BUILD=1776236333698,I.BUILD_HASH=rp,I.BUILD_MODE=ip,I.BatchForm=Qy,I.BtnGroup=Qh,I.Burn=tu,I.Bus=Qp,I.Calendar=Ra,I.Card=ic,I.CardList=Vu,I.Checkbox=_a,I.Collapsible=wa,I.ColorPicker=xs,I.CommonList=Pr,I.Component=qe,I.ComponentFromReact=ve,I.Computed=Ws,I.ContextMenu=nr,I.CopyBtn=Qs,I.Custom=va,I.CustomContent=de,I.CustomContentClass=Um,I.CustomRender=Lh,I.DTable=Is,I.Dashboard=Ku,I.DataHub=mg,I.DatePicker=Za,I.DatetimePicker=Ya,I.DeliverableList=Rl,I.Dexie=k0,I.DiffPicker=Yl,I.DocApp=On,I.DocViewer=uo,I.Draggable=Br,I.Dropdown=Ft,I.Dropmenu=Iu,I.ECharts=RS,I.Editor=gt,I.FileList=Pl,I.FileSelector=Zr,I.FormBuilder=rl,I.FormGrid=Gv,I.FormHelper=qi,I.FormSetting=qv,I.Gantt=Zv,I.GlobalSearch=Gl,I.Graph=Qv,I.HElement=Ve,I.HElementSignals=Er,I.HTMLDiff=qd,I.Highlight=no,I.HistoryPanel=er,I.HtmlContent=An,I.HtmlSandbox=ec,I.Icon=$e,I.ImageSelector=tl,I.ImgCutter=Au,I.Kanban=_o,I.KanbanList=bo,I.LibLoader=Ni,I.List=Rr,I.MINI_BTN_ID=Vy,I.Mammoth=jS,I.Markdown=Fd,I.Menu=Ca,I.Mermaid=t_,I.Messager=Ln,I.Modal=He,I.ModalBase=Vi,I.ModalTrigger=Ki,I.Moveable=_s,I.Nav=$d,I.NestedList=zr,I.PANEL_ID=Wy,I.POPUP_ID=Tl,I.PageEditor=Qi,I.Pager=Dd,I.Pick=cl,I.Picker=hl,I.Popover=Gt,I.PopoverPanel=Ka,I.Portal=Rh,I.PriPicker=Zl,I.ProgressCircle=Ta,I.RangePicker=Xl,I.ReactComponent=re,I.Resizable=Kh,I.ResponsiveNavHelper=dl,I.SearchBox=ul,I.SearchForm=an,I.SearchMenu=xa,I.SearchTree=Ed,I.SeverityPicker=Jl,I.Sidebar=Qr,I.Signal=vt,I.SizeStore=Zi,I.Sortable=Ia,I.SortableList=Ma,I.SortableTree=Na,I.Split=Pa,I.Sticky=oa,I.SuggestionMenu=fo,I.SvgBox=tc,I.TEditor=h_,I.TIME_DAY=Qn,I.Tabs=wo,I.TimeAgo=Da,I.TimePicker=Ga,I.TimeSpan=$a,I.Toolbar=Nd,I.Tooltip=Xs,I.Tree=pl,I.TurndownModule=Cl,I.Upload=ml,I.UploadImgs=Ad,I.UserAvatar=sc,I.VERSION=zc,I.ZAIStore=Sl,I.ZUI=ya,I.ZenEditor=ju,I.ZentaoAIStore=qk,I.ZentaoAgentResult=Al,I.ZentaoFormHelper=Kl,I.Zinbar=Uu,I.addDate=sa,I.addQueryToSearchForm=o_,I.ajaxSubmit=li,I.batch=gs,I.bindCommands=Mi,I.bindHotkeys=fh,I.bus=Mn,I.cash=v,I.classes=U,I.clearData=Zw,I.computed=Ce,I.convertBytes=$n,I.cookie=hg,I.copy=kh,I.copyText=vm,I.create=ia,I.createDate=Ye,I.createFormData=vr,I.createPortal=Wm,I.createRef=pe,I.debounce=ca,I.decodeBase64=Kw,I.deepCall=nn,I.deepGet=ki,I.deepGetPath=Np,I.defineFn=uC,I.delay=Dn,I.dexie=w0,I.disableScroll=ea,I.dom=wC,I.downloadFile=Xn,I.edgeDetect=$l,I.effect=_t,I.encodeBase64=Ep,I.enterFullscreen=sm,I.escapeHtml=Gn,I.evalValue=Yn,I.executeCommand=vh,I.executeCommands=_h,I.fetchData=Ne,I.formHelper=Kx,I.formatBytes=pt,I.formatDate=Ze,I.formatDateSpan=dC,I.formatString=De,I.getClassList=eh,I.getComponent=Tr,I.getDateTime=dn,I.getFullscreenElement=ta,I.getHotkeysMap=uh,I.getLib=xh,I.getReactComponent=jm,I.getUniqueCode=mh,I.getZData=Ti,I.getZentaoPageType=my,I.h=g,I.hotkeys=lC,I.htm=zh,I.html=Jm,I.i18n=be,I.init=yh,I.initGlobalComponents=gh,I.isDiff=_r,I.isFetchSetting=Sh,I.isNotEmptyString=Tn,I.isSameDay=Nn,I.isSameMonth=kr,I.isSameWeek=cC,I.isSameYear=xr,I.isToday=im,I.isTomorrow=hC,I.isValidDate=Sr,I.isYesterday=rm,I.jsRaw=Lp,I.jsx=PC,I.loadCSS=pm,I.loadJS=mm,I.loadModule=gm,I.mapFormData=Kv,I.mergeProps=Pe,I.morph=zd,I.nextGid=Xe,I.parseCommand=aa,I.parseCommands=cm,I.parseRawData=Go,I.parseSize=In,I.processSubmitResult=Eu,I.reactComponentMap=Ph,I.reactComponents=Bm,I.readFile=vC,I.registerComponent=am,I.registerGlobalCommand=dm,I.registerGlobalListener=Xp,I.registerLib=Ch,I.registerReactComponent=st,I.removeUndefinedProps=ch,I.render=ms,I.renderCustomContent=ga,I.renderCustomResult=Hm,I.runJS=Dr,I.selectFile=wh,I.setFormDataValue=Vs,I.setLibRoot=fm,I.setZData=th,I.shareData=Rp,I.showCommentModal=Tu,I.showInfo=f_,I.signal=fe,I.snapdom=a_,I.snapdomLoader=Ou,I.store=nt,I.storeData=qo,I.takeData=br,I.timeago=sg,I.toCssSize=Be,I.toggleFullscreen=na,I.toggleSearchForm=Fu,I.tryExec=ym,I.turndown=Ey,I.turndownLoader=My,I.turndownService=Ny,I.uid=Ot,I.unbindCommands=$r,I.unbindHotkeys=ph,I.untracked=Mh,I.updateSearchForm=r_,I.vhtml=Ym,I.waitUntil=_m,I.zentaoFormHelper=FS,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});